From 7939faac73117e3156af8b4fb39827bbe742e91f Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 3 Feb 2013 20:16:19 -0800 Subject: [PATCH 001/795] Bug 837566 - Remove js_RemoveRoot. r=terrence. --HG-- extra : rebase_source : b3b615c34cfa4b9766a3484060242498c5a57e63 --- dom/plugins/base/nsJSNPRuntime.cpp | 2 +- js/src/jsapi.cpp | 16 ++++++++-------- js/src/jsapi.h | 5 ----- js/src/jsgc.cpp | 6 +++--- js/src/jsgc.h | 3 +++ js/src/vm/OldDebugAPI.cpp | 6 +++--- js/xpconnect/public/nsAutoJSValHolder.h | 2 +- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index e2c682add5e8..a26514affff4 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -524,7 +524,7 @@ nsJSObjWrapper::NP_Invalidate(NPObject *npobj) if (jsnpobj && jsnpobj->mJSObj) { // Unroot the object's JSObject - js_RemoveRoot(sJSRuntime, &jsnpobj->mJSObj); + JS_RemoveObjectRootRT(sJSRuntime, &jsnpobj->mJSObj); if (sJSObjWrappers.ops) { // Remove the wrapper from the hash diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 0b89746864fe..fb38ad6f5322 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1654,52 +1654,52 @@ JS_PUBLIC_API(void) JS_RemoveValueRoot(JSContext *cx, jsval *vp) { CHECK_REQUEST(cx); - js_RemoveRoot(cx->runtime(), (void *)vp); + RemoveRoot(cx->runtime(), (void *)vp); } JS_PUBLIC_API(void) JS_RemoveStringRoot(JSContext *cx, JSString **rp) { CHECK_REQUEST(cx); - js_RemoveRoot(cx->runtime(), (void *)rp); + RemoveRoot(cx->runtime(), (void *)rp); } JS_PUBLIC_API(void) JS_RemoveObjectRoot(JSContext *cx, JSObject **rp) { CHECK_REQUEST(cx); - js_RemoveRoot(cx->runtime(), (void *)rp); + RemoveRoot(cx->runtime(), (void *)rp); } JS_PUBLIC_API(void) JS_RemoveScriptRoot(JSContext *cx, JSScript **rp) { CHECK_REQUEST(cx); - js_RemoveRoot(cx->runtime(), (void *)rp); + RemoveRoot(cx->runtime(), (void *)rp); } JS_PUBLIC_API(void) JS_RemoveValueRootRT(JSRuntime *rt, jsval *vp) { - js_RemoveRoot(rt, (void *)vp); + RemoveRoot(rt, (void *)vp); } JS_PUBLIC_API(void) JS_RemoveStringRootRT(JSRuntime *rt, JSString **rp) { - js_RemoveRoot(rt, (void *)rp); + RemoveRoot(rt, (void *)rp); } JS_PUBLIC_API(void) JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp) { - js_RemoveRoot(rt, (void *)rp); + RemoveRoot(rt, (void *)rp); } JS_PUBLIC_API(void) JS_RemoveScriptRootRT(JSRuntime *rt, JSScript **rp) { - js_RemoveRoot(rt, (void *)rp); + RemoveRoot(rt, (void *)rp); } JS_NEVER_INLINE JS_PUBLIC_API(void) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index f26ae68bce8d..9b4b43ac51b4 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -1980,11 +1980,6 @@ JS_RemoveObjectRootRT(JSRuntime *rt, JSObject **rp); extern JS_PUBLIC_API(void) JS_RemoveScriptRootRT(JSRuntime *rt, JSScript **rp); -/* TODO: remove these APIs */ - -extern JS_FRIEND_API(void) -js_RemoveRoot(JSRuntime *rt, void *rp); - /* * C-compatible version of the Anchor class. It should be called after the last * use of the variable it protects. diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index d0db35c78347..ccb99a69b5c8 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1104,11 +1104,11 @@ js_AddObjectRoot(JSRuntime *rt, JSObject **objp) extern JS_FRIEND_API(void) js_RemoveObjectRoot(JSRuntime *rt, JSObject **objp) { - js_RemoveRoot(rt, objp); + RemoveRoot(rt, objp); } -JS_FRIEND_API(void) -js_RemoveRoot(JSRuntime *rt, void *rp) +void +js::RemoveRoot(JSRuntime *rt, void *rp) { rt->gcRootsHash.remove(rp); rt->gcPoke = true; diff --git a/js/src/jsgc.h b/js/src/jsgc.h index 01152d5528cf..dc9e34168327 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -668,6 +668,9 @@ AddObjectRoot(JSRuntime *rt, JSObject **rp, const char *name); extern bool AddScriptRoot(JSContext *cx, JSScript **rp, const char *name); +extern void +RemoveRoot(JSRuntime *rt, void *rp); + } /* namespace js */ extern bool diff --git a/js/src/vm/OldDebugAPI.cpp b/js/src/vm/OldDebugAPI.cpp index 96ce76af49d3..dd28fcd9df3d 100644 --- a/js/src/vm/OldDebugAPI.cpp +++ b/js/src/vm/OldDebugAPI.cpp @@ -754,10 +754,10 @@ JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda) pd = pda->array; for (i = 0; i < pda->length; i++) { - js_RemoveRoot(cx->runtime(), &pd[i].id); - js_RemoveRoot(cx->runtime(), &pd[i].value); + RemoveRoot(cx->runtime(), &pd[i].id); + RemoveRoot(cx->runtime(), &pd[i].value); if (pd[i].flags & JSPD_ALIAS) - js_RemoveRoot(cx->runtime(), &pd[i].alias); + RemoveRoot(cx->runtime(), &pd[i].alias); } js_free(pd); pda->array = nullptr; diff --git a/js/xpconnect/public/nsAutoJSValHolder.h b/js/xpconnect/public/nsAutoJSValHolder.h index 4a737f33eee3..6577388fec43 100644 --- a/js/xpconnect/public/nsAutoJSValHolder.h +++ b/js/xpconnect/public/nsAutoJSValHolder.h @@ -64,7 +64,7 @@ public: bool Hold(JSRuntime* aRt) { // Do we really care about different runtimes? if (mRt && aRt != mRt) { - js_RemoveRoot(mRt, &mVal); + JS_RemoveValueRootRT(mRt, &mVal); mRt = nullptr; } From cb010e8737ccfd92dce67626d356fd81dd531cb1 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:42:45 +0900 Subject: [PATCH 002/795] Bug 932133 - Error out when entries in *SOURCES have an unknown file type. r=gps --- python/mozbuild/mozbuild/frontend/emitter.py | 49 +++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index fd6ef16286e2..5ea7a35f3592 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -175,24 +175,39 @@ class TreeMetadataEmitter(LoggingMixin): passthru.variables['VISIBILITY_FLAGS'] = '' varmap = dict( - ASFILES=('SOURCES', ('.s', '.asm')), - CSRCS=('SOURCES', '.c'), - CMMSRCS=('SOURCES', '.mm'), - CPPSRCS=('SOURCES', ('.cc', '.cpp')), - SSRCS=('SOURCES', '.S'), - HOST_CPPSRCS=('HOST_SOURCES', ('.cc', '.cpp')), - HOST_CSRCS=('HOST_SOURCES', '.c'), - GTEST_CMMSRCS=('GTEST_SOURCES', '.mm'), - GTEST_CPPSRCS=('GTEST_SOURCES', ('.cc', '.cpp')), - GTEST_CSRCS=('GTEST_SOURCES', '.c'), - UNIFIED_CSRCS=('UNIFIED_SOURCES', '.c'), - UNIFIED_CPPSRCS=('UNIFIED_SOURCES', ('.cc', '.cpp')), + SOURCES={ + '.s': 'ASFILES', + '.asm': 'ASFILES', + '.c': 'CSRCS', + '.mm': 'CMMSRCS', + '.cc': 'CPPSRCS', + '.cpp': 'CPPSRCS', + '.S': 'SSRCS', + }, + HOST_SOURCES={ + '.c': 'HOST_CSRCS', + '.cc': 'HOST_CPPSRCS', + '.cpp': 'HOST_CPPSRCS', + }, + GTEST_SOURCES={ + '.c': 'GTEST_CSRCS', + '.mm': 'GTEST_CMMSRCS', + '.cc': 'GTEST_CPPSRCS', + '.cpp': 'GTEST_CPPSRCS', + }, + UNIFIED_SOURCES={ + '.c': 'UNIFIED_CSRCS', + '.cc': 'UNIFIED_CPPSRCS', + '.cpp': 'UNIFIED_CPPSRCS', + } ) - for mak, (moz, ext) in varmap.items(): - if sandbox[moz]: - filtered = [f for f in sandbox[moz] if f.endswith(ext)] - if filtered: - passthru.variables[mak] = filtered + for variable, mapping in varmap.items(): + for f in sandbox[variable]: + ext = os.path.splitext(f)[1] + if ext not in mapping: + raise SandboxValidationError('%s has an unknown file type in %s' % (f, sandbox['RELATIVEDIR'])) + l = passthru.variables.setdefault(mapping[ext], []) + l.append(f) if passthru.variables: yield passthru From db283ea9de817b880b1d829bee5c1a0ac9191b02 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:42:58 +0900 Subject: [PATCH 003/795] Bug 932112 - Add stdc++-compat hack for std::__detail::_List_node_base::_M_reverse, necessary for webrtc update. r=nfroyd --- build/unix/stdc++compat/stdc++compat.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build/unix/stdc++compat/stdc++compat.cpp b/build/unix/stdc++compat/stdc++compat.cpp index cf1baafc0d9f..ba89c4dfd6f9 100644 --- a/build/unix/stdc++compat/stdc++compat.cpp +++ b/build/unix/stdc++compat/stdc++compat.cpp @@ -69,6 +69,8 @@ namespace std __attribute__((visibility("default"))) { /* Hack to avoid GLIBCXX_3.4.15 symbol versions */ #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15) static void swap(_List_node_base& __x, _List_node_base& __y) throw (); + + void reverse() throw(); }; namespace __detail { @@ -85,6 +87,8 @@ namespace std __attribute__((visibility("default"))) { #if MOZ_LIBSTDCXX_VERSION >= GLIBCXX_VERSION(3, 4, 15) static void swap(_List_node_base& __x, _List_node_base& __y) throw (); + + void _M_reverse() throw(); #endif }; @@ -116,6 +120,12 @@ namespace std __attribute__((visibility("default"))) { std::_List_node_base::swap(*((std::_List_node_base *) &__x), *((std::_List_node_base *) &__y)); } + + void + _List_node_base::_M_reverse() throw () + { + ((std::_List_node_base *)this)->reverse(); + } } #endif From 7cb0d256866dd1ac748bba11b9741428284d8315 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:43:39 +0900 Subject: [PATCH 004/795] Bug 932160 - Use UNIFIED_SOURCES for uconv unified sources. r=mshal --- intl/uconv/src/UnifiedUCV.cpp | 21 ----- intl/uconv/src/moz.build | 18 +++- intl/uconv/ucvcn/UnifiedUCVCN.cpp | 13 --- intl/uconv/ucvcn/moz.build | 10 +- intl/uconv/ucvibm/UnifiedUCVIBM.cpp | 17 ---- intl/uconv/ucvibm/UnifiedUCVIBMOS2.cpp | 11 --- intl/uconv/ucvibm/moz.build | 24 ++++- intl/uconv/ucvja/UnifiedUCVJA.cpp | 11 --- intl/uconv/ucvja/moz.build | 8 +- intl/uconv/ucvko/UnifiedUCVKO.cpp | 11 --- intl/uconv/ucvko/moz.build | 8 +- intl/uconv/ucvlatin/UnifiedUCVLatin.cpp | 120 ------------------------ intl/uconv/ucvlatin/moz.build | 117 ++++++++++++++++++++++- intl/uconv/ucvtw/UnifiedUCVTW.cpp | 11 --- intl/uconv/ucvtw/moz.build | 8 +- intl/uconv/ucvtw2/UnifiedUCVTW2.cpp | 8 -- intl/uconv/ucvtw2/moz.build | 5 +- intl/uconv/util/UnifiedUCVCUtils.c | 9 -- intl/uconv/util/UnifiedUCVUtils.cpp | 10 -- intl/uconv/util/moz.build | 13 ++- 20 files changed, 189 insertions(+), 264 deletions(-) delete mode 100644 intl/uconv/src/UnifiedUCV.cpp delete mode 100644 intl/uconv/ucvcn/UnifiedUCVCN.cpp delete mode 100644 intl/uconv/ucvibm/UnifiedUCVIBM.cpp delete mode 100644 intl/uconv/ucvibm/UnifiedUCVIBMOS2.cpp delete mode 100644 intl/uconv/ucvja/UnifiedUCVJA.cpp delete mode 100644 intl/uconv/ucvko/UnifiedUCVKO.cpp delete mode 100644 intl/uconv/ucvlatin/UnifiedUCVLatin.cpp delete mode 100644 intl/uconv/ucvtw/UnifiedUCVTW.cpp delete mode 100644 intl/uconv/ucvtw2/UnifiedUCVTW2.cpp delete mode 100644 intl/uconv/util/UnifiedUCVCUtils.c delete mode 100644 intl/uconv/util/UnifiedUCVUtils.cpp diff --git a/intl/uconv/src/UnifiedUCV.cpp b/intl/uconv/src/UnifiedUCV.cpp deleted file mode 100644 index 951f0f704e3e..000000000000 --- a/intl/uconv/src/UnifiedUCV.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsCP1252ToUnicode.cpp" -#include "nsCharsetConverterManager.cpp" -#include "nsConverterInputStream.cpp" -#include "nsConverterOutputStream.cpp" -#include "nsISO88591ToUnicode.cpp" -#include "nsMacRomanToUnicode.cpp" -#include "nsScriptableUConv.cpp" -#include "nsTextToSubURI.cpp" -#include "nsUConvModule.cpp" -#include "nsUTF8ConverterService.cpp" -#include "nsUTF8ToUnicode.cpp" -#include "nsUnicodeToCP1252.cpp" -#include "nsUnicodeToISO88591.cpp" -#include "nsUnicodeToMacRoman.cpp" -#include "nsUnicodeToUTF8.cpp" - diff --git a/intl/uconv/src/moz.build b/intl/uconv/src/moz.build index e74c9316be33..0c4a2ce0b346 100644 --- a/intl/uconv/src/moz.build +++ b/intl/uconv/src/moz.build @@ -6,8 +6,22 @@ MODULE = 'uconv' -SOURCES += [ - 'UnifiedUCV.cpp', +UNIFIED_SOURCES += [ + 'nsCharsetConverterManager.cpp', + 'nsConverterInputStream.cpp', + 'nsConverterOutputStream.cpp', + 'nsCP1252ToUnicode.cpp', + 'nsISO88591ToUnicode.cpp', + 'nsMacRomanToUnicode.cpp', + 'nsScriptableUConv.cpp', + 'nsTextToSubURI.cpp', + 'nsUConvModule.cpp', + 'nsUnicodeToCP1252.cpp', + 'nsUnicodeToISO88591.cpp', + 'nsUnicodeToMacRoman.cpp', + 'nsUnicodeToUTF8.cpp', + 'nsUTF8ConverterService.cpp', + 'nsUTF8ToUnicode.cpp', ] if CONFIG['INTEL_ARCHITECTURE']: diff --git a/intl/uconv/ucvcn/UnifiedUCVCN.cpp b/intl/uconv/ucvcn/UnifiedUCVCN.cpp deleted file mode 100644 index 013a400b0d98..000000000000 --- a/intl/uconv/ucvcn/UnifiedUCVCN.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsGBKConvUtil.cpp" -#include "nsGBKToUnicode.cpp" -#include "nsHZToUnicode.cpp" -#include "nsISO2022CNToUnicode.cpp" -#include "nsUnicodeToGB2312V2.cpp" -#include "nsUnicodeToGBK.cpp" -#include "nsUnicodeToHZ.cpp" - diff --git a/intl/uconv/ucvcn/moz.build b/intl/uconv/ucvcn/moz.build index 594d429d8476..559442ff45e8 100644 --- a/intl/uconv/ucvcn/moz.build +++ b/intl/uconv/ucvcn/moz.build @@ -10,8 +10,14 @@ EXPORTS += [ 'nsUCvCnCID.h', ] -SOURCES += [ - 'UnifiedUCVCN.cpp', +UNIFIED_SOURCES += [ + 'nsGBKConvUtil.cpp', + 'nsGBKToUnicode.cpp', + 'nsHZToUnicode.cpp', + 'nsISO2022CNToUnicode.cpp', + 'nsUnicodeToGB2312V2.cpp', + 'nsUnicodeToGBK.cpp', + 'nsUnicodeToHZ.cpp', ] LIBRARY_NAME = 'ucvcn_s' diff --git a/intl/uconv/ucvibm/UnifiedUCVIBM.cpp b/intl/uconv/ucvibm/UnifiedUCVIBM.cpp deleted file mode 100644 index 15768b79055c..000000000000 --- a/intl/uconv/ucvibm/UnifiedUCVIBM.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsCP850ToUnicode.cpp" -#include "nsCP852ToUnicode.cpp" -#include "nsCP855ToUnicode.cpp" -#include "nsCP857ToUnicode.cpp" -#include "nsCP862ToUnicode.cpp" -#include "nsCP864ToUnicode.cpp" -#include "nsUnicodeToCP850.cpp" -#include "nsUnicodeToCP852.cpp" -#include "nsUnicodeToCP855.cpp" -#include "nsUnicodeToCP857.cpp" -#include "nsUnicodeToCP862.cpp" -#include "nsUnicodeToCP864.cpp" - diff --git a/intl/uconv/ucvibm/UnifiedUCVIBMOS2.cpp b/intl/uconv/ucvibm/UnifiedUCVIBMOS2.cpp deleted file mode 100644 index f18ebe8fffba..000000000000 --- a/intl/uconv/ucvibm/UnifiedUCVIBMOS2.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsCP869ToUnicode.cpp" -#include "nsUnicodeToCP869.cpp" -#include "nsCP1125ToUnicode.cpp" -#include "nsUnicodeToCP1125.cpp" -#include "nsCP1131ToUnicode.cpp" -#include "nsUnicodeToCP1131.cpp" - diff --git a/intl/uconv/ucvibm/moz.build b/intl/uconv/ucvibm/moz.build index 4d31ef0802f5..7f0dfb2aa8df 100644 --- a/intl/uconv/ucvibm/moz.build +++ b/intl/uconv/ucvibm/moz.build @@ -10,13 +10,29 @@ EXPORTS += [ 'nsUCvIBMCID.h', ] -SOURCES += [ - 'UnifiedUCVIBM.cpp', +UNIFIED_SOURCES += [ + 'nsCP850ToUnicode.cpp', + 'nsCP852ToUnicode.cpp', + 'nsCP855ToUnicode.cpp', + 'nsCP857ToUnicode.cpp', + 'nsCP862ToUnicode.cpp', + 'nsCP864ToUnicode.cpp', + 'nsUnicodeToCP850.cpp', + 'nsUnicodeToCP852.cpp', + 'nsUnicodeToCP855.cpp', + 'nsUnicodeToCP857.cpp', + 'nsUnicodeToCP862.cpp', + 'nsUnicodeToCP864.cpp', ] if CONFIG['OS_ARCH'] == 'OS2': - SOURCES += [ - 'UnifiedUCVIBMOS2.cpp', + UNIFIED_SOURCES += [ + 'nsCP1125ToUnicode.cpp', + 'nsCP1131ToUnicode.cpp', + 'nsCP869ToUnicode.cpp', + 'nsUnicodeToCP1125.cpp', + 'nsUnicodeToCP1131.cpp', + 'nsUnicodeToCP869.cpp', ] LIBRARY_NAME = 'ucvibm_s' diff --git a/intl/uconv/ucvja/UnifiedUCVJA.cpp b/intl/uconv/ucvja/UnifiedUCVJA.cpp deleted file mode 100644 index 9b2262d019c1..000000000000 --- a/intl/uconv/ucvja/UnifiedUCVJA.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsJapaneseToUnicode.cpp" -#include "nsUnicodeToEUCJP.cpp" -#include "nsUnicodeToISO2022JP.cpp" -#include "nsUnicodeToJISx0201.cpp" -#include "nsUnicodeToSJIS.cpp" - diff --git a/intl/uconv/ucvja/moz.build b/intl/uconv/ucvja/moz.build index be0fbb534eb4..6d18f7458bf1 100644 --- a/intl/uconv/ucvja/moz.build +++ b/intl/uconv/ucvja/moz.build @@ -11,8 +11,12 @@ EXPORTS += [ 'nsUCVJACID.h', ] -SOURCES += [ - 'UnifiedUCVJA.cpp', +UNIFIED_SOURCES += [ + 'nsJapaneseToUnicode.cpp', + 'nsUnicodeToEUCJP.cpp', + 'nsUnicodeToISO2022JP.cpp', + 'nsUnicodeToJISx0201.cpp', + 'nsUnicodeToSJIS.cpp', ] LIBRARY_NAME = 'ucvja_s' diff --git a/intl/uconv/ucvko/UnifiedUCVKO.cpp b/intl/uconv/ucvko/UnifiedUCVKO.cpp deleted file mode 100644 index df8d7402fca8..000000000000 --- a/intl/uconv/ucvko/UnifiedUCVKO.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsCP949ToUnicode.cpp" -#include "nsISO2022KRToUnicode.cpp" -#include "nsJohabToUnicode.cpp" -#include "nsUnicodeToCP949.cpp" -#include "nsUnicodeToJohab.cpp" - diff --git a/intl/uconv/ucvko/moz.build b/intl/uconv/ucvko/moz.build index f6d7e8fc5973..913a76eb3450 100644 --- a/intl/uconv/ucvko/moz.build +++ b/intl/uconv/ucvko/moz.build @@ -10,8 +10,12 @@ EXPORTS += [ 'nsUCvKOCID.h', ] -SOURCES += [ - 'UnifiedUCVKO.cpp', +UNIFIED_SOURCES += [ + 'nsCP949ToUnicode.cpp', + 'nsISO2022KRToUnicode.cpp', + 'nsJohabToUnicode.cpp', + 'nsUnicodeToCP949.cpp', + 'nsUnicodeToJohab.cpp', ] LIBRARY_NAME = 'ucvko_s' diff --git a/intl/uconv/ucvlatin/UnifiedUCVLatin.cpp b/intl/uconv/ucvlatin/UnifiedUCVLatin.cpp deleted file mode 100644 index 8c3819fcf442..000000000000 --- a/intl/uconv/ucvlatin/UnifiedUCVLatin.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsARMSCII8ToUnicode.cpp" -#include "nsAsciiToUnicode.cpp" -#include "nsCP1250ToUnicode.cpp" -#include "nsCP1251ToUnicode.cpp" -#include "nsCP1253ToUnicode.cpp" -#include "nsCP1254ToUnicode.cpp" -#include "nsCP1255ToUnicode.cpp" -#include "nsCP1256ToUnicode.cpp" -#include "nsCP1257ToUnicode.cpp" -#include "nsCP1258ToUnicode.cpp" -#include "nsCP866ToUnicode.cpp" -#include "nsCP874ToUnicode.cpp" -#include "nsISO885910ToUnicode.cpp" -#include "nsISO885911ToUnicode.cpp" -#include "nsISO885913ToUnicode.cpp" -#include "nsISO885914ToUnicode.cpp" -#include "nsISO885915ToUnicode.cpp" -#include "nsISO885916ToUnicode.cpp" -#include "nsISO88592ToUnicode.cpp" -#include "nsISO88593ToUnicode.cpp" -#include "nsISO88594ToUnicode.cpp" -#include "nsISO88595ToUnicode.cpp" -#include "nsISO88596EToUnicode.cpp" -#include "nsISO88596IToUnicode.cpp" -#include "nsISO88596ToUnicode.cpp" -#include "nsISO88597ToUnicode.cpp" -#include "nsISO88598EToUnicode.cpp" -#include "nsISO88598IToUnicode.cpp" -#include "nsISO88598ToUnicode.cpp" -#include "nsISO88599ToUnicode.cpp" -#include "nsISOIR111ToUnicode.cpp" -#include "nsKOI8RToUnicode.cpp" -#include "nsKOI8UToUnicode.cpp" -#include "nsMUTF7ToUnicode.cpp" -#include "nsMacArabicToUnicode.cpp" -#include "nsMacCEToUnicode.cpp" -#include "nsMacCroatianToUnicode.cpp" -#include "nsMacCyrillicToUnicode.cpp" -#include "nsMacDevanagariToUnicode.cpp" -#include "nsMacFarsiToUnicode.cpp" -#include "nsMacGreekToUnicode.cpp" -#include "nsMacGujaratiToUnicode.cpp" -#include "nsMacGurmukhiToUnicode.cpp" -#include "nsMacHebrewToUnicode.cpp" -#include "nsMacIcelandicToUnicode.cpp" -#include "nsMacRomanianToUnicode.cpp" -#include "nsMacTurkishToUnicode.cpp" -#include "nsT61ToUnicode.cpp" -#include "nsTCVN5712ToUnicode.cpp" -#include "nsTIS620ToUnicode.cpp" -#include "nsUTF16ToUnicode.cpp" -#include "nsUTF7ToUnicode.cpp" -#include "nsUnicodeToARMSCII8.cpp" -#include "nsUnicodeToAdobeEuro.cpp" -#include "nsUnicodeToAscii.cpp" -#include "nsUnicodeToCP1250.cpp" -#include "nsUnicodeToCP1251.cpp" -#include "nsUnicodeToCP1253.cpp" -#include "nsUnicodeToCP1254.cpp" -#include "nsUnicodeToCP1255.cpp" -#include "nsUnicodeToCP1256.cpp" -#include "nsUnicodeToCP1257.cpp" -#include "nsUnicodeToCP1258.cpp" -#include "nsUnicodeToCP866.cpp" -#include "nsUnicodeToCP874.cpp" -#include "nsUnicodeToISO885910.cpp" -#include "nsUnicodeToISO885911.cpp" -#include "nsUnicodeToISO885913.cpp" -#include "nsUnicodeToISO885914.cpp" -#include "nsUnicodeToISO885915.cpp" -#include "nsUnicodeToISO885916.cpp" -#include "nsUnicodeToISO88592.cpp" -#include "nsUnicodeToISO88593.cpp" -#include "nsUnicodeToISO88594.cpp" -#include "nsUnicodeToISO88595.cpp" -#include "nsUnicodeToISO88596.cpp" -#include "nsUnicodeToISO88596E.cpp" -#include "nsUnicodeToISO88596I.cpp" -#include "nsUnicodeToISO88597.cpp" -#include "nsUnicodeToISO88598.cpp" -#include "nsUnicodeToISO88598E.cpp" -#include "nsUnicodeToISO88598I.cpp" -#include "nsUnicodeToISO88599.cpp" -#include "nsUnicodeToISOIR111.cpp" -#include "nsUnicodeToKOI8R.cpp" -#include "nsUnicodeToKOI8U.cpp" -#include "nsUnicodeToMUTF7.cpp" -#include "nsUnicodeToMacArabic.cpp" -#include "nsUnicodeToMacCE.cpp" -#include "nsUnicodeToMacCroatian.cpp" -#include "nsUnicodeToMacCyrillic.cpp" -#include "nsUnicodeToMacDevanagari.cpp" -#include "nsUnicodeToMacFarsi.cpp" -#include "nsUnicodeToMacGreek.cpp" -#include "nsUnicodeToMacGujarati.cpp" -#include "nsUnicodeToMacGurmukhi.cpp" -#include "nsUnicodeToMacHebrew.cpp" -#include "nsUnicodeToMacIcelandic.cpp" -#include "nsUnicodeToMacRomanian.cpp" -#include "nsUnicodeToMacTurkish.cpp" -#include "nsUnicodeToSymbol.cpp" -#include "nsUnicodeToT61.cpp" -#include "nsUnicodeToTCVN5712.cpp" -#include "nsUnicodeToTIS620.cpp" -#include "nsUnicodeToTSCII.cpp" -#include "nsUnicodeToUTF16.cpp" -#include "nsUnicodeToUTF7.cpp" -#include "nsUnicodeToUserDefined.cpp" -#include "nsUnicodeToVISCII.cpp" -#include "nsUnicodeToVPS.cpp" -#include "nsUnicodeToZapfDingbat.cpp" -#include "nsUserDefinedToUnicode.cpp" -#include "nsVISCIIToUnicode.cpp" -#include "nsVPSToUnicode.cpp" - diff --git a/intl/uconv/ucvlatin/moz.build b/intl/uconv/ucvlatin/moz.build index 6f1422c7cdde..e94c24e8bc7d 100644 --- a/intl/uconv/ucvlatin/moz.build +++ b/intl/uconv/ucvlatin/moz.build @@ -10,8 +10,121 @@ EXPORTS += [ 'nsUCvLatinCID.h', ] -SOURCES += [ - 'UnifiedUCVLatin.cpp', +UNIFIED_SOURCES += [ + 'nsARMSCII8ToUnicode.cpp', + 'nsAsciiToUnicode.cpp', + 'nsCP1250ToUnicode.cpp', + 'nsCP1251ToUnicode.cpp', + 'nsCP1253ToUnicode.cpp', + 'nsCP1254ToUnicode.cpp', + 'nsCP1255ToUnicode.cpp', + 'nsCP1256ToUnicode.cpp', + 'nsCP1257ToUnicode.cpp', + 'nsCP1258ToUnicode.cpp', + 'nsCP866ToUnicode.cpp', + 'nsCP874ToUnicode.cpp', + 'nsISO885910ToUnicode.cpp', + 'nsISO885911ToUnicode.cpp', + 'nsISO885913ToUnicode.cpp', + 'nsISO885914ToUnicode.cpp', + 'nsISO885915ToUnicode.cpp', + 'nsISO885916ToUnicode.cpp', + 'nsISO88592ToUnicode.cpp', + 'nsISO88593ToUnicode.cpp', + 'nsISO88594ToUnicode.cpp', + 'nsISO88595ToUnicode.cpp', + 'nsISO88596EToUnicode.cpp', + 'nsISO88596IToUnicode.cpp', + 'nsISO88596ToUnicode.cpp', + 'nsISO88597ToUnicode.cpp', + 'nsISO88598EToUnicode.cpp', + 'nsISO88598IToUnicode.cpp', + 'nsISO88598ToUnicode.cpp', + 'nsISO88599ToUnicode.cpp', + 'nsISOIR111ToUnicode.cpp', + 'nsKOI8RToUnicode.cpp', + 'nsKOI8UToUnicode.cpp', + 'nsMacArabicToUnicode.cpp', + 'nsMacCEToUnicode.cpp', + 'nsMacCroatianToUnicode.cpp', + 'nsMacCyrillicToUnicode.cpp', + 'nsMacDevanagariToUnicode.cpp', + 'nsMacFarsiToUnicode.cpp', + 'nsMacGreekToUnicode.cpp', + 'nsMacGujaratiToUnicode.cpp', + 'nsMacGurmukhiToUnicode.cpp', + 'nsMacHebrewToUnicode.cpp', + 'nsMacIcelandicToUnicode.cpp', + 'nsMacRomanianToUnicode.cpp', + 'nsMacTurkishToUnicode.cpp', + 'nsMUTF7ToUnicode.cpp', + 'nsT61ToUnicode.cpp', + 'nsTCVN5712ToUnicode.cpp', + 'nsTIS620ToUnicode.cpp', + 'nsUnicodeToAdobeEuro.cpp', + 'nsUnicodeToARMSCII8.cpp', + 'nsUnicodeToAscii.cpp', + 'nsUnicodeToCP1250.cpp', + 'nsUnicodeToCP1251.cpp', + 'nsUnicodeToCP1253.cpp', + 'nsUnicodeToCP1254.cpp', + 'nsUnicodeToCP1255.cpp', + 'nsUnicodeToCP1256.cpp', + 'nsUnicodeToCP1257.cpp', + 'nsUnicodeToCP1258.cpp', + 'nsUnicodeToCP866.cpp', + 'nsUnicodeToCP874.cpp', + 'nsUnicodeToISO885910.cpp', + 'nsUnicodeToISO885911.cpp', + 'nsUnicodeToISO885913.cpp', + 'nsUnicodeToISO885914.cpp', + 'nsUnicodeToISO885915.cpp', + 'nsUnicodeToISO885916.cpp', + 'nsUnicodeToISO88592.cpp', + 'nsUnicodeToISO88593.cpp', + 'nsUnicodeToISO88594.cpp', + 'nsUnicodeToISO88595.cpp', + 'nsUnicodeToISO88596.cpp', + 'nsUnicodeToISO88596E.cpp', + 'nsUnicodeToISO88596I.cpp', + 'nsUnicodeToISO88597.cpp', + 'nsUnicodeToISO88598.cpp', + 'nsUnicodeToISO88598E.cpp', + 'nsUnicodeToISO88598I.cpp', + 'nsUnicodeToISO88599.cpp', + 'nsUnicodeToISOIR111.cpp', + 'nsUnicodeToKOI8R.cpp', + 'nsUnicodeToKOI8U.cpp', + 'nsUnicodeToMacArabic.cpp', + 'nsUnicodeToMacCE.cpp', + 'nsUnicodeToMacCroatian.cpp', + 'nsUnicodeToMacCyrillic.cpp', + 'nsUnicodeToMacDevanagari.cpp', + 'nsUnicodeToMacFarsi.cpp', + 'nsUnicodeToMacGreek.cpp', + 'nsUnicodeToMacGujarati.cpp', + 'nsUnicodeToMacGurmukhi.cpp', + 'nsUnicodeToMacHebrew.cpp', + 'nsUnicodeToMacIcelandic.cpp', + 'nsUnicodeToMacRomanian.cpp', + 'nsUnicodeToMacTurkish.cpp', + 'nsUnicodeToMUTF7.cpp', + 'nsUnicodeToSymbol.cpp', + 'nsUnicodeToT61.cpp', + 'nsUnicodeToTCVN5712.cpp', + 'nsUnicodeToTIS620.cpp', + 'nsUnicodeToTSCII.cpp', + 'nsUnicodeToUserDefined.cpp', + 'nsUnicodeToUTF16.cpp', + 'nsUnicodeToUTF7.cpp', + 'nsUnicodeToVISCII.cpp', + 'nsUnicodeToVPS.cpp', + 'nsUnicodeToZapfDingbat.cpp', + 'nsUserDefinedToUnicode.cpp', + 'nsUTF16ToUnicode.cpp', + 'nsUTF7ToUnicode.cpp', + 'nsVISCIIToUnicode.cpp', + 'nsVPSToUnicode.cpp', ] LIBRARY_NAME = 'ucvlatin_s' diff --git a/intl/uconv/ucvtw/UnifiedUCVTW.cpp b/intl/uconv/ucvtw/UnifiedUCVTW.cpp deleted file mode 100644 index a88f315ac3e0..000000000000 --- a/intl/uconv/ucvtw/UnifiedUCVTW.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsBIG5HKSCSToUnicode.cpp" -#include "nsBIG5ToUnicode.cpp" -#include "nsUnicodeToBIG5.cpp" -#include "nsUnicodeToBIG5HKSCS.cpp" -#include "nsUnicodeToHKSCS.cpp" - diff --git a/intl/uconv/ucvtw/moz.build b/intl/uconv/ucvtw/moz.build index 2059cd26a502..79a8f2cd25bb 100644 --- a/intl/uconv/ucvtw/moz.build +++ b/intl/uconv/ucvtw/moz.build @@ -10,8 +10,12 @@ EXPORTS += [ 'nsUCvTWCID.h', ] -SOURCES += [ - 'UnifiedUCVTW.cpp', +UNIFIED_SOURCES += [ + 'nsBIG5HKSCSToUnicode.cpp', + 'nsBIG5ToUnicode.cpp', + 'nsUnicodeToBIG5.cpp', + 'nsUnicodeToBIG5HKSCS.cpp', + 'nsUnicodeToHKSCS.cpp', ] LIBRARY_NAME = 'ucvtw_s' diff --git a/intl/uconv/ucvtw2/UnifiedUCVTW2.cpp b/intl/uconv/ucvtw2/UnifiedUCVTW2.cpp deleted file mode 100644 index 91bc83bf3384..000000000000 --- a/intl/uconv/ucvtw2/UnifiedUCVTW2.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsEUCTWToUnicode.cpp" -#include "nsUnicodeToEUCTW.cpp" - diff --git a/intl/uconv/ucvtw2/moz.build b/intl/uconv/ucvtw2/moz.build index 387f5eb74c55..1a969969c3c4 100644 --- a/intl/uconv/ucvtw2/moz.build +++ b/intl/uconv/ucvtw2/moz.build @@ -10,8 +10,9 @@ EXPORTS += [ 'nsUCvTW2CID.h', ] -SOURCES += [ - 'UnifiedUCVTW2.cpp', +UNIFIED_SOURCES += [ + 'nsEUCTWToUnicode.cpp', + 'nsUnicodeToEUCTW.cpp', ] LIBRARY_NAME = 'ucvtw2_s' diff --git a/intl/uconv/util/UnifiedUCVCUtils.c b/intl/uconv/util/UnifiedUCVCUtils.c deleted file mode 100644 index 0aa658c8a999..000000000000 --- a/intl/uconv/util/UnifiedUCVCUtils.c +++ /dev/null @@ -1,9 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "ugen.c" -#include "umap.c" -#include "uscan.c" - diff --git a/intl/uconv/util/UnifiedUCVUtils.cpp b/intl/uconv/util/UnifiedUCVUtils.cpp deleted file mode 100644 index b96491348881..000000000000 --- a/intl/uconv/util/UnifiedUCVUtils.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsUCConstructors.cpp" -#include "nsUCSupport.cpp" -#include "nsUnicodeDecodeHelper.cpp" -#include "nsUnicodeEncodeHelper.cpp" - diff --git a/intl/uconv/util/moz.build b/intl/uconv/util/moz.build index e292f417da24..76682feca4a8 100644 --- a/intl/uconv/util/moz.build +++ b/intl/uconv/util/moz.build @@ -6,16 +6,21 @@ MODULE = 'uconv' -SOURCES += [ - 'UnifiedUCVUtils.cpp', +UNIFIED_SOURCES += [ + 'nsUCConstructors.cpp', + 'nsUCSupport.cpp', + 'nsUnicodeDecodeHelper.cpp', + 'nsUnicodeEncodeHelper.cpp', ] LIBRARY_NAME = 'ucvutil_s' LIBXUL_LIBRARY = True -SOURCES += [ - 'UnifiedUCVCUtils.c', +UNIFIED_SOURCES += [ + 'ugen.c', + 'umap.c', + 'uscan.c', ] MSVC_ENABLE_PGO = True From fb2def268d9f1af1a86a60c5b75141f8b104c9ad Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:45:01 +0900 Subject: [PATCH 005/795] Bug 932170 - Add moz.build variables for generated sources. r=gps --- media/libtheora/lib/Makefile.in | 6 ------ media/libtheora/lib/moz.build | 8 ++++++++ python/mozbuild/mozbuild/frontend/emitter.py | 5 +++++ .../mozbuild/frontend/sandbox_symbols.py | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/media/libtheora/lib/Makefile.in b/media/libtheora/lib/Makefile.in index acff5df867f1..e5b29150260e 100644 --- a/media/libtheora/lib/Makefile.in +++ b/media/libtheora/lib/Makefile.in @@ -80,12 +80,6 @@ armopts-gnu.S: armopts.s %-gnu.$(ASM_SUFFIX): %.s $(PERL) $(srcdir)/arm/arm2gnu.pl < $< > $@ -ASFILES += $(addsuffix .$(ASM_SUFFIX), \ - armbits-gnu \ - armfrag-gnu \ - armidct-gnu \ - armloop-gnu \ -) endif endif diff --git a/media/libtheora/lib/moz.build b/media/libtheora/lib/moz.build index 7f5d22690af1..de6841448a15 100644 --- a/media/libtheora/lib/moz.build +++ b/media/libtheora/lib/moz.build @@ -24,6 +24,14 @@ SOURCES += [ 'state.c', ] +if CONFIG['OS_TEST'] == 'arm' and CONFIG['GNU_AS']: + GENERATED_SOURCES += [ '%s.%s' % (f, CONFIG['ASM_SUFFIX']) for f in [ + 'armbits-gnu', + 'armfrag-gnu', + 'armidct-gnu', + 'armloop-gnu', + ]] + MSVC_ENABLE_PGO = True FORCE_STATIC_LIB = True diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 5ea7a35f3592..074b7e6416cd 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -201,6 +201,8 @@ class TreeMetadataEmitter(LoggingMixin): '.cpp': 'UNIFIED_CPPSRCS', } ) + varmap.update(dict(('GENERATED_%s' % k, v) for k, v in varmap.items() + if k in ('SOURCES', 'UNIFIED_SOURCES'))) for variable, mapping in varmap.items(): for f in sandbox[variable]: ext = os.path.splitext(f)[1] @@ -208,6 +210,9 @@ class TreeMetadataEmitter(LoggingMixin): raise SandboxValidationError('%s has an unknown file type in %s' % (f, sandbox['RELATIVEDIR'])) l = passthru.variables.setdefault(mapping[ext], []) l.append(f) + if variable.startswith('GENERATED_'): + l = passthru.variables.setdefault('GARBAGE', []) + l.append(f) if passthru.variables: yield passthru diff --git a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py index 83fd1efe9742..e743db704045 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py +++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py @@ -78,6 +78,13 @@ VARIABLES = { Accepts assembler, C, C++, Objective C/C++. """, 'compile'), + 'GENERATED_SOURCES': (StrictOrderingOnAppendList, list, [], + """Generated source code files. + + This variable contains a list of generated source code files to + compile. Accepts assembler, C, C++, Objective C/C++. + """, 'compile'), + 'UNIFIED_SOURCES': (StrictOrderingOnAppendList, list, [], """Source code files that can be compiled together. @@ -87,6 +94,15 @@ VARIABLES = { size. """, 'compile'), + 'GENERATED_UNIFIED_SOURCES': (StrictOrderingOnAppendList, list, [], + """Generated source code files that can be compiled together. + + This variable contains a list of generated source code files to + compile, that can be concatenated all together, with UNIFIED_SOURCES, + and built as a single source file. This can help make the build faster + and reduce the debug info size. + """, 'compile'), + 'DEFINES': (OrderedDict, dict, OrderedDict(), """Dictionary of compiler defines to declare. From 2222c566927b954dafd436e337083808ae77b5f9 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:46:17 +0900 Subject: [PATCH 006/795] Bug 932178 - Move ASFILES to moz.build in xpcom/reflect/xptcall/src/md/unix. r=gps This also cleans up assembler-with-cpp flags, by renaming .s files to .S, which are preprocessed without requiring additional flags. Also clean up the generated assembly torture. --HG-- rename : xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips.s => xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips.S rename : xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s => xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.S rename : xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.s => xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.S rename : xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.s => xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.S rename : xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s => xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.S rename : xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_linux.s => xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_linux.S --- xpcom/reflect/xptcall/src/md/unix/Makefile.in | 184 ++---------------- xpcom/reflect/xptcall/src/md/unix/moz.build | 70 +++++++ ...nvoke_asm_mips.s => xptcinvoke_asm_mips.S} | 0 ...e_asm_mips64.s => xptcinvoke_asm_mips64.S} | 0 ...ppc_linux.s => xptcinvoke_asm_ppc_linux.S} | 0 ...cstubs_asm_mips.s => xptcstubs_asm_mips.S} | 0 ...bs_asm_mips64.s => xptcstubs_asm_mips64.S} | 0 ..._ppc_linux.s => xptcstubs_asm_ppc_linux.S} | 0 8 files changed, 88 insertions(+), 166 deletions(-) rename xpcom/reflect/xptcall/src/md/unix/{xptcinvoke_asm_mips.s => xptcinvoke_asm_mips.S} (100%) rename xpcom/reflect/xptcall/src/md/unix/{xptcinvoke_asm_mips64.s => xptcinvoke_asm_mips64.S} (100%) rename xpcom/reflect/xptcall/src/md/unix/{xptcinvoke_asm_ppc_linux.s => xptcinvoke_asm_ppc_linux.S} (100%) rename xpcom/reflect/xptcall/src/md/unix/{xptcstubs_asm_mips.s => xptcstubs_asm_mips.S} (100%) rename xpcom/reflect/xptcall/src/md/unix/{xptcstubs_asm_mips64.s => xptcstubs_asm_mips64.S} (100%) rename xpcom/reflect/xptcall/src/md/unix/{xptcstubs_asm_ppc_linux.s => xptcstubs_asm_ppc_linux.S} (100%) diff --git a/xpcom/reflect/xptcall/src/md/unix/Makefile.in b/xpcom/reflect/xptcall/src/md/unix/Makefile.in index d3e4f3151dc8..05453ff5adb1 100644 --- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in +++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in @@ -35,43 +35,6 @@ endif endif endif -# IA64 Linux -ifneq (,$(filter Linux FreeBSD,$(OS_ARCH))) -ifneq (,$(findstring ia64,$(OS_TEST))) -ASFILES := xptcstubs_asm_ipf64.s xptcinvoke_asm_ipf64.s -endif -endif -# -# Neutrino/Intel (uses the same unixish_x86 code) -# -ifeq ($(OS_TARGET),NTO) -ifeq ($(OS_TEST),sh) -ASFILES := xptcstubs_asm_shle.s -endif -endif - - -###################################################################### -# Solaris/Intel -###################################################################### -# -# Solaris/Intel -# -ifeq ($(OS_ARCH),SunOS) -ifeq (x86_64,$(OS_TEST)) -ifndef GNU_CC -ASFILES := xptcstubs_asm_x86_64_solaris_SUNW.s -endif -else -ifeq (86,$(findstring 86,$(OS_TEST))) -# 28817: if Solaris Intel OS, and native compiler, always build optimised. -ifndef GNU_CC -ASFILES := xptcinvoke_asm_x86_solaris_SUNW.s xptcstubs_asm_x86_solaris_SUNW.s -endif -endif -endif -endif - ###################################################################### # ARM ###################################################################### @@ -93,12 +56,6 @@ endif # for gas and gcc, check comment in xptcinvoke_asm_pa32.s ifeq ($(OS_ARCH),HP-UX) ifneq ($(CC),gcc) -ifneq ($(OS_TEST),ia64) -ASFILES := xptcstubs_asm_pa32.s xptcinvoke_asm_pa32.s -else -ASFILES := xptcstubs_asm_ipf32.s xptcinvoke_asm_ipf32.s -endif - # #18875 Building the CPP's (CXX) optimized causes a crash CXXFLAGS := $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS)) endif @@ -111,7 +68,6 @@ ifeq ($(OS_ARCH),Linux) ifneq (,$(filter hppa hppa2.0 hppa1.1,$(OS_TEST))) ifndef GNU_CXX else -ASFILES := xptcstubs_asm_parisc_linux.s xptcinvoke_asm_parisc_linux.s # #434190 optimized builds crash CXXFLAGS := $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS)) endif @@ -125,12 +81,7 @@ endif ifeq ($(OS_ARCH),Linux) ifneq (,$(findstring mips, $(OS_TEST))) -ifneq (,$(findstring mips64, $(OS_TEST))) -ASFILES := xptcinvoke_asm_mips64.s xptcstubs_asm_mips64.s -else -ASFILES := xptcinvoke_asm_mips.s xptcstubs_asm_mips.s -endif -ASFLAGS += -I$(DIST)/include -x assembler-with-cpp +ASFLAGS += -I$(DIST)/include endif endif @@ -141,91 +92,14 @@ endif # AIX/PPC # ifeq ($(OS_ARCH),AIX) -ifdef HAVE_64BIT_OS -ASFILES := xptcinvoke_asm_ppc_aix64.s xptcstubs_asm_ppc_aix64.s -else -ifeq ($(AIX_OBJMODEL),ibm) -ASFILES := xptcinvoke_asm_ppc_ibmobj_aix.s xptcstubs_asm_ppc_aix.s -else -ASFILES := xptcinvoke_asm_ppc_aix.s xptcstubs_asm_ppc_aix.s -endif -endif - # #24617 Building the CPP's (CXX) optimized causes a crash CXXFLAGS := $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(CXXFLAGS)) endif -# -# Linux/PPC -# -ifneq (,$(filter Linuxpowerpc FreeBSDpowerpc,$(OS_ARCH)$(OS_TEST))) -ASFILES := xptcinvoke_asm_ppc_linux.s xptcstubs_asm_ppc_linux.s -AS := $(CC) -c -x assembler-with-cpp -endif - -# -# Linux/PPC64 -# -ifneq (,$(filter Linuxpowerpc64 FreeBSDpowerpc64,$(OS_ARCH)$(OS_TEST))) -ASFILES := xptcinvoke_asm_ppc64_linux.s xptcstubs_asm_ppc64_linux.s -AS := $(CC) -c -x assembler-with-cpp -endif - -# -# NetBSD/PPC -# -ifneq (,$(filter NetBSDmacppc NetBSDbebox NetBSDofppc NetBSDprep NetBSDamigappc,$(OS_ARCH)$(OS_TEST))) -ASFILES := xptcinvoke_asm_ppc_netbsd.s xptcstubs_asm_ppc_netbsd.s -endif - -# -# OpenBSD/PPC -# -ifeq ($(OS_ARCH)$(OS_TEST),OpenBSDpowerpc) -ASFILES := xptcinvoke_asm_ppc_openbsd.s xptcstubs_asm_ppc_openbsd.s -AS := $(CC) -c -x assembler-with-cpp -endif - -# -# Darwin/PPC -# -ifeq ($(OS_ARCH),Darwin) -ifeq ($(TARGET_CPU), powerpc) -ASFLAGS += -x assembler-with-cpp # assumes $(AS) == $(CC) -ASFILES := xptcinvoke_asm_ppc_rhapsody.s xptcstubs_asm_ppc_darwin.s -endif -endif - ###################################################################### # SPARC ###################################################################### # -# Linux/SPARC -# -ifeq ($(OS_ARCH),Linux) -ifneq (,$(findstring sparc,$(OS_TEST))) -ASFILES := xptcinvoke_asm_sparc_linux_GCC3.s xptcstubs_asm_sparc_solaris.s -endif -endif -# -# NetBSD/SPARC -# -ifeq ($(OS_ARCH)$(OS_TEST),NetBSDsparc) -ASFILES := xptcinvoke_asm_sparc_netbsd.s xptcstubs_asm_sparc_netbsd.s -endif -# -# OpenBSD/SPARC -# -ifeq ($(OS_ARCH)$(OS_TEST),OpenBSDsparc) -ASFILES := xptcinvoke_asm_sparc_openbsd.s xptcstubs_asm_sparc_openbsd.s -endif -# -# OpenBSD/SPARC64 -# -ifneq (,$(filter OpenBSDsparc64 FreeBSDsparc64,$(OS_ARCH)$(OS_TEST))) -ASFILES := xptcinvoke_asm_sparc64_openbsd.s xptcstubs_asm_sparc64_openbsd.s -endif -# # Solaris/SPARC # ifeq ($(OS_ARCH),SunOS) @@ -233,18 +107,6 @@ ifneq (86,$(findstring 86,$(OS_TEST))) ifdef HAVE_64BIT_OS ASFLAGS += -xarch=v9 endif - -ifeq ($(GNU_CC),1) -ASFILES := xptcinvoke_asm_sparc_solaris_GCC3.s xptcstubs_asm_sparc_solaris.s -else - -ifdef HAVE_64BIT_OS -ASFILES := xptcinvoke_asm_sparcv9_solaris_SUNW.s xptcstubs_asm_sparcv9_solaris.s -else -ASFILES := xptcinvoke_asm_sparc_solaris_SUNW.s xptcstubs_asm_sparc_solaris.s -endif -endif - endif endif @@ -278,47 +140,37 @@ endif endif ifeq ($(OS_ARCH),Darwin) -xptcstubs_asm_ppc_darwin.o: xptcstubs_asm_ppc_darwin.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile - gm4 $(INCLUDES) $< > ./xptcstubs_asm_ppc_darwin.s && \ - $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_darwin.s - $(RM) -f ./xptcstubs_asm_ppc_darwin.s +xptcstubs_asm_ppc_darwin.s: xptcstubs_asm_ppc_darwin.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile + gm4 $(INCLUDES) $< > $@ endif ifeq ($(OS_ARCH),AIX) ifdef HAVE_64BIT_OS -xptcstubs_asm_ppc_aix64.o: xptcstubs_asm_ppc_aix64.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile - m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > ./xptcstubs_asm_ppc_aix64.s && \ - $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_aix64.s - $(RM) ./xptcstubs_asm_ppc_aix64.s +xptcstubs_asm_ppc_aix64.s: xptcstubs_asm_ppc_aix64.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile + m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > $@ else -xptcstubs_asm_ppc_aix.o: xptcstubs_asm_ppc_aix.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile - m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > ./xptcstubs_asm_ppc_aix.s && \ - $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) ./xptcstubs_asm_ppc_aix.s - $(RM) ./xptcstubs_asm_ppc_aix.s +xptcstubs_asm_ppc_aix.s: xptcstubs_asm_ppc_aix.s.m4 $(DIST)/include/xptcstubsdef.inc Makefile + m4 -DAIX_OBJMODEL=$(AIX_OBJMODEL) $(INCLUDES) -I. $< > $@ endif endif ifeq ($(OS_ARCH),SunOS) ifeq (86,$(findstring 86,$(OS_TEST))) ifndef GNU_CC +xptcstubsdef_asm.solx86: $(DIST)/include/xptcstubsdef.inc + sed \ + -e 's/^\(STUB_ENTRY\)(\([0-9]\))/\11\(\2\)/' \ + -e 's/^\(STUB_ENTRY\)(\([0-9][0-9]\))/\12\(\2\)/' \ + -e 's/^\(STUB_ENTRY\)(\([0-9][0-9][0-9]\))/\13\(\2\)/' \ + $(DIST)/include/xptcstubsdef.inc > $@ ifeq (x86_64,$(OS_TEST)) -xptcstubs_asm_x86_64_solaris_SUNW.o: $(DIST)/include/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_x86_64_solaris_SUNW.s - sed \ - -e 's/^\(STUB_ENTRY\)(\([0-9]\))/\11\(\2\)/' \ - -e 's/^\(STUB_ENTRY\)(\([0-9][0-9]\))/\12\(\2\)/' \ - -e 's/^\(STUB_ENTRY\)(\([0-9][0-9][0-9]\))/\13\(\2\)/' \ - $(DIST)/include/xptcstubsdef.inc > ./xptcstubsdef_asm.solx86 - $(AS) -o $@ -xarch=amd64 $(ASFLAGS) $(AS_DASH_C_FLAG) -I./ $(srcdir)/xptcstubs_asm_x86_64_solaris_SUNW.s +ASFLAGS += -xarch=amd64 + +xptcstubs_asm_x86_64_solaris_SUNW.$(OBJ_SUFFIX): xptcstubsdef_asm.solx86 else -xptcstubs_asm_x86_solaris_SUNW.o: $(DIST)/include/xptcstubsdef.inc $(srcdir)/xptcstubs_asm_x86_solaris_SUNW.s - sed \ - -e 's/^\(STUB_ENTRY\)(\([0-9]\))/\11\(\2\)/' \ - -e 's/^\(STUB_ENTRY\)(\([0-9][0-9]\))/\12\(\2\)/' \ - -e 's/^\(STUB_ENTRY\)(\([0-9][0-9][0-9]\))/\13\(\2\)/' \ - $(DIST)/include/xptcstubsdef.inc > ./xptcstubsdef_asm.solx86 - $(AS) -o $@ $(ASFLAGS) $(AS_DASH_C_FLAG) -I./ $(srcdir)/xptcstubs_asm_x86_solaris_SUNW.s +xptcstubs_asm_x86_solaris_SUNW.$(OBJ_SUFFIX): xptcstubsdef_asm.solx86 endif - @rm -f ./xptcstubsdef_asm.solx86 + endif endif endif diff --git a/xpcom/reflect/xptcall/src/md/unix/moz.build b/xpcom/reflect/xptcall/src/md/unix/moz.build index 4127ba7dfb91..91bcda9685e7 100644 --- a/xpcom/reflect/xptcall/src/md/unix/moz.build +++ b/xpcom/reflect/xptcall/src/md/unix/moz.build @@ -11,6 +11,13 @@ if CONFIG['OS_ARCH'] == 'Darwin': 'xptcinvoke_darwin.cpp', 'xptcstubs_darwin.cpp', ] + if CONFIG['OS_TEST'] == 'powerpc': + SOURCES += [ + 'xptcinvoke_asm_ppc_rhapsody.s', + ] + GENERATED_SOURCES += [ + 'xptcstubs_asm_ppc_darwin.s', + ] if CONFIG['OS_ARCH'] in ('NetBSD', 'OpenBSD', 'GNU'): if CONFIG['CPU_ARCH'] == 'x86': @@ -35,7 +42,9 @@ if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD') or \ if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'): if CONFIG['OS_TEST'].find('ia64') != -1: SOURCES += [ + 'xptcinvoke_asm_ipf64.s', 'xptcinvoke_ipf64.cpp', + 'xptcstubs_asm_ipf64.s', 'xptcstubs_ipf64.cpp' ] @@ -59,6 +68,7 @@ if CONFIG['OS_TARGET'] == 'NTO': elif CONFIG['OS_TEST'] == 'sh': SOURCES += [ 'xptcinvoke_nto_shle.cpp', + 'xptcstubs_asm_shle.s', 'xptcstubs_nto_shle.cpp' ] @@ -72,6 +82,7 @@ if CONFIG['OS_ARCH'] == 'SunOS': else: SOURCES += [ 'xptcinvoke_x86_64_solaris.cpp', + 'xptcstubs_asm_x86_64_solaris_SUNW.s', 'xptcstubs_x86_64_solaris.cpp', ] elif CONFIG['OS_TEST'].find('86') != -1: @@ -82,7 +93,9 @@ if CONFIG['OS_ARCH'] == 'SunOS': ] else: SOURCES += [ + 'xptcinvoke_asm_x86_solaris_SUNW.s', 'xptcinvoke_x86_solaris.cpp', + 'xptcstubs_asm_x86_solaris_SUNW.s', 'xptcstubs_x86_solaris.cpp' ] @@ -120,12 +133,16 @@ if CONFIG['OS_ARCH'] == 'HP-UX': if CONFIG['CC'] != 'gcc': if CONFIG['OS_TEST'] == 'ia64': SOURCES += [ + 'xptcinvoke_asm_ipf32.s', 'xptcinvoke_ipf32.cpp', + 'xptcstubs_asm_ipf32.s', 'xptcstubs_ipf32.cpp', ] else: SOURCES += [ + 'xptcinvoke_asm_pa32.s', 'xptcinvoke_pa32.cpp', + 'xptcstubs_asm_pa32.s', 'xptcstubs_pa32.cpp' ] @@ -133,7 +150,9 @@ if CONFIG['OS_ARCH'] == 'Linux': if CONFIG['OS_TEST'] in ('hppa', 'hppa2.0', 'hppa1.1'): if CONFIG['GNU_CXX']: SOURCES += [ + 'xptcinvoke_asm_parisc_linux.s', 'xptcinvoke_pa32.cpp', + 'xptcstubs_asm_parisc_linux.s', 'xptcstubs_pa32.cpp', ] else: @@ -156,75 +175,110 @@ if CONFIG['OS_ARCH'] == 'Linux': if CONFIG['OS_TEST'].find('mips') != -1: if CONFIG['OS_TEST'].find('mips64') != -1: SOURCES += [ + 'xptcinvoke_asm_mips64.S', 'xptcinvoke_mips64.cpp', + 'xptcstubs_asm_mips64.S', 'xptcstubs_mips64.cpp', ] else: SOURCES += [ + 'xptcinvoke_asm_mips.S', 'xptcinvoke_mips.cpp', + 'xptcstubs_asm_mips.S', 'xptcstubs_mips.cpp', ] if CONFIG['OS_ARCH'] == 'AIX': if CONFIG['HAVE_64BIT_OS']: SOURCES += [ + 'xptcinvoke_asm_ppc_aix64.s', 'xptcinvoke_ppc_aix64.cpp', 'xptcstubs_ppc_aix64.cpp', ] + GENERATED_SOURCES += [ + 'xptcstubs_asm_ppc_aix64.s', + ] else: SOURCES += [ 'xptcinvoke_ppc_aix.cpp', 'xptcstubs_ppc_aix.cpp', ] + if CONFIG['AIX_OBJMODEL'] == 'ibm': + SOURCES += [ + 'xptcinvoke_asm_ppc_ibmobj_aix.s', + ] + else: + SOURCES += [ + 'xptcinvoke_asm_ppc_aix.s', + ] + GENERATED_SOURCES += [ + 'xptcstubs_asm_ppc_aix.s', + ] if CONFIG['OS_TEST'] == 'powerpc': if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'): SOURCES += [ + 'xptcinvoke_asm_ppc_linux.S', 'xptcinvoke_ppc_linux.cpp', + 'xptcstubs_asm_ppc_linux.S', 'xptcstubs_ppc_linux.cpp', ] if CONFIG['OS_TEST'] == 'powerpc64': if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD'): SOURCES += [ + 'xptcinvoke_asm_ppc64_linux.s', 'xptcinvoke_ppc64_linux.cpp', + 'xptcstubs_asm_ppc64_linux.s', 'xptcstubs_ppc64_linux.cpp', ] if CONFIG['OS_TEST'] in ('macppc', 'bebox', 'ofppc', 'prep', 'amigappc'): if CONFIG['OS_ARCH'] == 'NetBSD': SOURCES += [ + 'xptcinvoke_asm_ppc_netbsd.s', 'xptcinvoke_ppc_netbsd.cpp', + 'xptcstubs_asm_ppc_netbsd.s', 'xptcstubs_ppc_netbsd.cpp', ] if CONFIG['OS_ARCH'] == 'OpenBSD' and CONFIG['OS_TEST'] == 'powerpc': SOURCES += [ + 'xptcinvoke_asm_ppc_openbsd.s', 'xptcinvoke_ppc_openbsd.cpp', + 'xptcstubs_asm_ppc_openbsd.s', 'xptcstubs_ppc_openbsd.cpp', ] if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TEST'].find('sparc') != -1: SOURCES += [ + 'xptcinvoke_asm_sparc_linux_GCC3.s', 'xptcinvoke_sparc_solaris.cpp', + 'xptcstubs_asm_sparc_solaris.s', 'xptcstubs_sparc_solaris.cpp', ] if CONFIG['OS_ARCH'] == 'NetBSD' and CONFIG['OS_TEST'] == 'sparc': SOURCES += [ + 'xptcinvoke_asm_sparc_netbsd.s', 'xptcinvoke_sparc_netbsd.cpp', + 'xptcstubs_asm_sparc_netbsd.s', 'xptcstubs_sparc_netbsd.cpp', ] if CONFIG['OS_ARCH'] == 'OpenBSD' and CONFIG['OS_TEST'] == 'sparc': SOURCES += [ + 'xptcinvoke_asm_sparc_openbsd.s', 'xptcinvoke_sparc_openbsd.cpp', + 'xptcstubs_asm_sparc_openbsd.s', 'xptcstubs_sparc_openbsd.cpp', ] if CONFIG['OS_ARCH'] == 'OpenBSD' and CONFIG['OS_TEST'] == 'sparc64': SOURCES += [ + 'xptcinvoke_asm_sparc64_openbsd.s', 'xptcinvoke_sparc64_openbsd.cpp', + 'xptcstubs_asm_sparc64_openbsd.s', 'xptcstubs_sparc64_openbsd.cpp', ] @@ -239,6 +293,22 @@ if CONFIG['OS_ARCH'] == 'SunOS' and CONFIG['OS_TEST'].find('86') == -1: 'xptcinvoke_sparc_solaris.cpp', 'xptcstubs_sparc_solaris.cpp', ] + if CONFIG['GNU_CC']: + SOURCES += [ + 'xptcinvoke_asm_sparc_solaris_GCC3.s', + 'xptcstubs_asm_sparc_solaris.s', + ] + else: + if CONFIG['HAVE_64BIT_OS']: + SOURCES += [ + 'xptcinvoke_asm_sparcv9_solaris_SUNW.s', + 'xptcstubs_asm_sparcv9_solaris.s', + ] + else: + SOURCES += [ + 'xptcinvoke_asm_sparc_solaris_SUNW.s', + 'xptcstubs_asm_sparc_solaris.s', + ] if CONFIG['OS_ARCH'] == 'Linux': if CONFIG['OS_TEST'] == 's390': diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips.S similarity index 100% rename from xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips.s rename to xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips.S diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.S similarity index 100% rename from xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.s rename to xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_mips64.S diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.s b/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.S similarity index 100% rename from xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.s rename to xpcom/reflect/xptcall/src/md/unix/xptcinvoke_asm_ppc_linux.S diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.s b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.S similarity index 100% rename from xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.s rename to xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips.S diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.S similarity index 100% rename from xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.s rename to xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_mips64.S diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_linux.s b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_linux.S similarity index 100% rename from xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_linux.s rename to xpcom/reflect/xptcall/src/md/unix/xptcstubs_asm_ppc_linux.S From 84fe98b48f57c0e7a2114997f36375d6dc2a8384 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 1 Nov 2013 10:30:45 +0900 Subject: [PATCH 007/795] Bug 870406 part n - Move more CSRCS to moz.build. r=mshal --- accessible/public/msaa/Makefile.in | 10 ------ accessible/public/msaa/moz.build | 9 +++++ b2g/gaia/Makefile.in | 1 - b2g/gaia/moz.build | 4 +++ build/stlport/Makefile.in | 5 --- build/stlport/moz.build | 38 ++++++++++++++++++++ build/unix/elfhack/Makefile.in | 2 +- build/unix/elfhack/inject/Makefile.in | 17 +-------- build/unix/elfhack/inject/moz.build | 12 +++++++ gfx/cairo/cairo/src/Makefile.in | 51 +-------------------------- gfx/cairo/cairo/src/moz.build | 51 +++++++++++++++++++++++---- gfx/ots/src/Makefile.in | 3 -- ipc/chromium/Makefile.in | 31 ---------------- ipc/chromium/moz.build | 36 +++++++++++++++++++ media/libtheora/lib/Makefile.in | 40 ++------------------- media/libtheora/lib/moz.build | 27 ++++++++++++++ xpcom/base/Makefile.in | 7 ---- xpcom/base/moz.build | 6 ++-- xpcom/build/Makefile.in | 4 --- xpcom/build/moz.build | 1 + 20 files changed, 179 insertions(+), 176 deletions(-) diff --git a/accessible/public/msaa/Makefile.in b/accessible/public/msaa/Makefile.in index e2ca272f32d6..05a6fb1a9b92 100644 --- a/accessible/public/msaa/Makefile.in +++ b/accessible/public/msaa/Makefile.in @@ -10,16 +10,6 @@ GARBAGE += $(MIDL_GENERATED_FILES) done_gen dlldata.c FORCE_SHARED_LIB = 1 -CSRCS = \ - dlldata.c \ - ISimpleDOMNode_p.c \ - ISimpleDOMNode_i.c \ - ISimpleDOMDocument_p.c \ - ISimpleDOMDocument_i.c \ - ISimpleDOMText_p.c \ - ISimpleDOMText_i.c \ - $(NULL) - MIDL_GENERATED_FILES = \ ISimpleDOMNode.h \ ISimpleDOMNode_p.c \ diff --git a/accessible/public/msaa/moz.build b/accessible/public/msaa/moz.build index 0b8d28869dbd..c268719ddd16 100644 --- a/accessible/public/msaa/moz.build +++ b/accessible/public/msaa/moz.build @@ -8,3 +8,12 @@ MODULE = 'accessibility' LIBRARY_NAME = 'AccessibleMarshal' +GENERATED_SOURCES += [ + 'dlldata.c', + 'ISimpleDOMDocument_i.c', + 'ISimpleDOMDocument_p.c', + 'ISimpleDOMNode_i.c', + 'ISimpleDOMNode_p.c', + 'ISimpleDOMText_i.c', + 'ISimpleDOMText_p.c', +] diff --git a/b2g/gaia/Makefile.in b/b2g/gaia/Makefile.in index 2e51324e16ac..47e4713ad1b7 100644 --- a/b2g/gaia/Makefile.in +++ b/b2g/gaia/Makefile.in @@ -10,7 +10,6 @@ DEFINES += \ -DGAIA_PATH=L\"$(subst /,\\\\,$(GAIA_PATH))\" \ $(NULL) else # Non-windows machines use the same wrapper program -CSRCS = run-b2g.c DEFINES += \ -DB2G_NAME=\"$(MOZ_APP_NAME)-bin$(BIN_SUFFIX)\" \ -DGAIA_PATH=\"$(GAIA_PATH)\" \ diff --git a/b2g/gaia/moz.build b/b2g/gaia/moz.build index a99a73ad96b7..6713659202d2 100644 --- a/b2g/gaia/moz.build +++ b/b2g/gaia/moz.build @@ -10,3 +10,7 @@ if CONFIG['OS_ARCH'] == 'WINNT': SOURCES += [ 'run-b2g.cpp', ] +else: + SOURCES += [ + 'run-b2g.c', + ] diff --git a/build/stlport/Makefile.in b/build/stlport/Makefile.in index 1b4dfb8eb044..cca81f61da3c 100644 --- a/build/stlport/Makefile.in +++ b/build/stlport/Makefile.in @@ -9,11 +9,6 @@ STL_FLAGS = # installing it in dist/lib. LIBRARY = $(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX) -VPATH += $(srcdir)/src - -CPPSRCS += $(notdir $(wildcard $(srcdir)/src/*.cpp)) -CSRCS = $(notdir $(wildcard $(srcdir)/src/*.c)) - include $(topsrcdir)/config/rules.mk DEFINES += -D_GNU_SOURCE diff --git a/build/stlport/moz.build b/build/stlport/moz.build index d30f879bbb80..77277e67949a 100644 --- a/build/stlport/moz.build +++ b/build/stlport/moz.build @@ -7,3 +7,41 @@ LIBRARY_NAME = 'stlport_static' FORCE_STATIC_LIB = True + +SOURCES += [ + 'src/allocators.cpp', + 'src/bitset.cpp', + 'src/codecvt.cpp', + 'src/collate.cpp', + 'src/complex.cpp', + 'src/complex_io.cpp', + 'src/complex_trig.cpp', + 'src/ctype.cpp', + 'src/dll_main.cpp', + 'src/facets_byname.cpp', + 'src/fstream.cpp', + 'src/ios.cpp', + 'src/iostream.cpp', + 'src/istream.cpp', + 'src/locale.cpp', + 'src/locale_catalog.cpp', + 'src/locale_impl.cpp', + 'src/messages.cpp', + 'src/monetary.cpp', + 'src/num_get.cpp', + 'src/num_get_float.cpp', + 'src/num_put.cpp', + 'src/num_put_float.cpp', + 'src/numpunct.cpp', + 'src/ostream.cpp', + 'src/sstream.cpp', + 'src/stdio_streambuf.cpp', + 'src/string.cpp', + 'src/strstream.cpp', + 'src/time_facets.cpp', +] + +SOURCES += [ + 'src/c_locale.c', + 'src/cxa.c', +] diff --git a/build/unix/elfhack/Makefile.in b/build/unix/elfhack/Makefile.in index 7c6209650f6d..0df8871f8de8 100644 --- a/build/unix/elfhack/Makefile.in +++ b/build/unix/elfhack/Makefile.in @@ -18,7 +18,7 @@ include $(topsrcdir)/config/rules.mk DEFINES += -DELFHACK_BUILD -test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack $(filter inject/%,$(CSRCS:.c=.$(OBJ_SUFFIX))) +test-array$(DLL_SUFFIX) test-ctors$(DLL_SUFFIX): %$(DLL_SUFFIX): %.$(OBJ_SUFFIX) elfhack $(MKSHLIB) $(LDFLAGS) $< -nostartfiles @echo === @echo === If you get failures below, please file a bug describing the error diff --git a/build/unix/elfhack/inject/Makefile.in b/build/unix/elfhack/inject/Makefile.in index 13fb7b32bdb0..f0366c843a06 100644 --- a/build/unix/elfhack/inject/Makefile.in +++ b/build/unix/elfhack/inject/Makefile.in @@ -6,21 +6,6 @@ INTERNAL_TOOLS = 1 NO_PROFILE_GUIDED_OPTIMIZE = 1 -ifneq (,$(filter %86,$(TARGET_CPU))) -CPU := x86 -else -ifneq (,$(filter arm%,$(TARGET_CPU))) -CPU := arm -else -CPU := $(TARGET_CPU) -endif -endif - -CSRCS := \ - $(CPU).c \ - $(CPU)-noinit.c \ - $(NULL) - include $(topsrcdir)/config/rules.mk export:: $(CSRCS:.c=.$(OBJ_SUFFIX)) @@ -33,4 +18,4 @@ GARBAGE += $(CSRCS) DEFINES += -DELFHACK_BUILD CFLAGS := -O2 -fno-stack-protector $(filter -m% -I%,$(CFLAGS)) -$(CPU)-noinit.$(OBJ_SUFFIX): DEFINES += -DNOINIT +%-noinit.$(OBJ_SUFFIX): DEFINES += -DNOINIT diff --git a/build/unix/elfhack/inject/moz.build b/build/unix/elfhack/inject/moz.build index 5a964a96b8c0..380ecd218149 100644 --- a/build/unix/elfhack/inject/moz.build +++ b/build/unix/elfhack/inject/moz.build @@ -5,3 +5,15 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. NO_DIST_INSTALL = True + +if CONFIG['TARGET_CPU'].endswith('86'): + cpu = 'x86' +elif CONFIG['TARGET_CPU'].startswith('arm'): + cpu = 'arm' +else: + cpu = CONFIG['TARGET_CPU'] + +GENERATED_SOURCES += [ s % cpu for s in [ + "%s-noinit.c", + "%s.c", +]] diff --git a/gfx/cairo/cairo/src/Makefile.in b/gfx/cairo/cairo/src/Makefile.in index b6559ac3ba85..d39295392424 100644 --- a/gfx/cairo/cairo/src/Makefile.in +++ b/gfx/cairo/cairo/src/Makefile.in @@ -9,40 +9,11 @@ endif endif -ifneq ($(MOZ_WIDGET_TOOLKIT),cocoa) -CSRCS += cairo-deflate-stream.c -endif - -# cairo-type1-subset.c should be here, but it's only supported on freetype platforms - -PSPDF_BASE_CSRCS = \ - cairo-base85-stream.c \ - cairo-type1-fallback.c \ - cairo-type3-glyph-surface.c \ - cairo-truetype-subset.c \ - cairo-cff-subset.c \ - $(NULL) - -PDF_CSRCS = \ - cairo-pdf-surface.c \ - cairo-pdf-operators.c \ - $(NULL) - -PS_CSRCS = cairo-ps-surface.c - ifeq ($(MOZ_WIDGET_TOOLKIT),windows) DEFINES += -DDISABLE_SOME_FLOATING_POINT -CSRCS += cairo-win32-surface.c - -CSRCS += cairo-win32-font.c - -ifdef NS_PRINTING -CSRCS += cairo-win32-printing-surface.c -else +ifndef NS_PRINTING DEFINES += -DCAIRO_OMIT_WIN32_PRINTING endif - -CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS) endif ifeq ($(MOZ_WIDGET_TOOLKIT),os2) @@ -50,37 +21,17 @@ DEFINES += -DOS2_USE_PLATFORM_ALLOC ifdef MOZ_OS2_HIGH_MEMORY DEFINES += -DOS2_HIGH_MEMORY endif -CSRCS += cairo-os2-surface.c -CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS) -endif - -ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -CSRCS += cairo-quartz-surface.c cairo-quartz-image-surface.c cairo-quartz-font.c -endif - -ifdef MOZ_WIDGET_GTK -CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS) $(PS_CSRCS) -endif - -ifneq (,$(filter android gonk,$(MOZ_WIDGET_TOOLKIT))) -CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS) endif ifeq ($(MOZ_WIDGET_TOOLKIT),qt) -CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS) OS_INCLUDES += $(MOZ_QT_CFLAGS) endif ifdef MOZ_X11 -CSRCS += cairo-xlib-surface.c \ - cairo-xlib-screen.c \ - cairo-xlib-visual.c \ - cairo-xlib-display.c OS_INCLUDES += $(XCFLAGS) endif ifdef MOZ_ENABLE_CAIRO_FT -CSRCS += cairo-ft-font.c cairo-type1-subset.c OS_INCLUDES += $(CAIRO_FT_CFLAGS) endif diff --git a/gfx/cairo/cairo/src/moz.build b/gfx/cairo/cairo/src/moz.build index 64b88141fe31..6e055155fba1 100644 --- a/gfx/cairo/cairo/src/moz.build +++ b/gfx/cairo/cairo/src/moz.build @@ -17,9 +17,24 @@ EXPORTS.cairo += [ 'cairo.h', ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': +if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('cocoa', 'uikit'): EXPORTS.cairo += [ 'cairo-pdf.h', + ] + SOURCES += [ + 'cairo-base85-stream.c', + 'cairo-cff-subset.c', + 'cairo-deflate-stream.c', + 'cairo-pdf-operators.c', + 'cairo-pdf-surface.c', + 'cairo-truetype-subset.c', + # cairo-type1-subset.c should be here, but it's only supported on freetype platforms + 'cairo-type1-fallback.c', + 'cairo-type3-glyph-surface.c', + ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + EXPORTS.cairo += [ 'cairo-win32.h', ] if CONFIG['MOZ_ENABLE_DWRITE_FONT']: @@ -30,17 +45,32 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': SOURCES += [ 'cairo-d2d-surface.cpp', ] + SOURCES += [ + 'cairo-win32-font.c', + 'cairo-win32-surface.c', + ] + if CONFIG['NS_PRINTING']: + SOURCES += [ + 'cairo-win32-printing-surface.c', + ] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'os2': EXPORTS.cairo += [ 'cairo-os2-private.h', 'cairo-os2.h', - 'cairo-pdf.h', + ] + SOURCES += [ + 'cairo-os2-surface.c', ] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': EXPORTS.cairo += [ 'cairo-quartz-image.h', 'cairo-quartz.h', ] + SOURCES += [ + 'cairo-quartz-font.c', + 'cairo-quartz-image-surface.c', + 'cairo-quartz-surface.c', + ] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'beos': EXPORTS.cairo += [ 'cairo-beos.h', @@ -50,16 +80,13 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'beos': ] elif CONFIG['MOZ_WIDGET_GTK']: EXPORTS.cairo += [ - 'cairo-pdf.h', 'cairo-ps.h', ] -elif CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gonk'): - EXPORTS.cairo += [ - 'cairo-pdf.h', + SOURCES += [ + 'cairo-ps-surface.c', ] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': EXPORTS.cairo += [ - 'cairo-pdf.h', 'cairo-qt.h', ] SOURCES += [ @@ -71,11 +98,21 @@ if CONFIG['MOZ_X11']: 'cairo-xlib-xrender.h', 'cairo-xlib.h', ] + SOURCES += [ + 'cairo-xlib-display.c', + 'cairo-xlib-screen.c', + 'cairo-xlib-surface.c', + 'cairo-xlib-visual.c', + ] if CONFIG['MOZ_ENABLE_CAIRO_FT']: EXPORTS.cairo += [ 'cairo-ft.h', ] + SOURCES += [ + 'cairo-ft-font.c', + 'cairo-type1-subset.c', + ] LIBRARY_NAME = 'mozcairo' diff --git a/gfx/ots/src/Makefile.in b/gfx/ots/src/Makefile.in index f6aa1758abec..0435a64872c4 100644 --- a/gfx/ots/src/Makefile.in +++ b/gfx/ots/src/Makefile.in @@ -28,9 +28,6 @@ ifeq (WINNT,$(OS_TARGET)) endif -CSRCS = \ - $(NULL) - include $(topsrcdir)/config/rules.mk DEFINES += -DPACKAGE_VERSION="\"moz\"" diff --git a/ipc/chromium/Makefile.in b/ipc/chromium/Makefile.in index d9b8c07899ef..4ec2f6313b80 100644 --- a/ipc/chromium/Makefile.in +++ b/ipc/chromium/Makefile.in @@ -42,32 +42,8 @@ LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/include DEFINES += -DHAVE_CONFIG_H -CSRCS += \ - buffer.c \ - bufferevent.c \ - bufferevent_sock.c \ - bufferevent_ratelim.c \ - evdns.c \ - event.c \ - event_tagging.c \ - evmap.c \ - evthread.c \ - evthread_pthread.c \ - evrpc.c \ - evutil.c \ - evutil_rand.c \ - http.c \ - listener.c \ - log.c \ - poll.c \ - select.c \ - signal.c \ - strlcpy.c \ - $(NULL) - ifeq ($(OS_ARCH),Darwin) # (OS_MACOSX) { LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/mac -CSRCS += kqueue.c else # } else { @@ -76,13 +52,7 @@ ifeq ($(OS_TARGET),Android) # { LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/android else # } else { LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/linux -CSRCS += \ - epoll_sub.c \ - $(NULL) endif # } -CSRCS += \ - epoll.c \ - $(NULL) else # } else (OS_BSD) { @@ -90,7 +60,6 @@ ifneq (,$(filter DragonFly FreeBSD,$(OS_ARCH))) # (not OS_DRAGONFLY and not OS_F DEFINES += -D_EVENT_HAVE_SENDFILE endif # } LOCAL_INCLUDES += -I$(srcdir)/src/third_party/libevent/bsd -CSRCS += kqueue.c endif # } diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build index d5186084da85..f4a10038d26b 100644 --- a/ipc/chromium/moz.build +++ b/ipc/chromium/moz.build @@ -123,6 +123,29 @@ if os_win: 'src/chrome/common/process_watcher_win.cc', 'src/chrome/common/transport_dib_win.cc', ] +else: + SOURCES += [ + 'src/third_party/libevent/buffer.c', + 'src/third_party/libevent/bufferevent.c', + 'src/third_party/libevent/bufferevent_ratelim.c', + 'src/third_party/libevent/bufferevent_sock.c', + 'src/third_party/libevent/evdns.c', + 'src/third_party/libevent/event.c', + 'src/third_party/libevent/event_tagging.c', + 'src/third_party/libevent/evmap.c', + 'src/third_party/libevent/evrpc.c', + 'src/third_party/libevent/evthread.c', + 'src/third_party/libevent/evthread_pthread.c', + 'src/third_party/libevent/evutil.c', + 'src/third_party/libevent/evutil_rand.c', + 'src/third_party/libevent/http.c', + 'src/third_party/libevent/listener.c', + 'src/third_party/libevent/log.c', + 'src/third_party/libevent/poll.c', + 'src/third_party/libevent/select.c', + 'src/third_party/libevent/signal.c', + 'src/third_party/libevent/strlcpy.c', + ] if os_posix: SOURCES += [ @@ -180,6 +203,9 @@ if os_macosx: 'src/chrome/common/chrome_paths_mac.mm', 'src/chrome/common/mach_ipc_mac.mm', ] + SOURCES += [ + 'src/third_party/libevent/kqueue.c', + ] if os_linux: SOURCES += [ @@ -199,6 +225,13 @@ if os_linux: 'src/base/message_pump_qt.cc', 'src/base/moc_message_pump_qt.cc', ] + if CONFIG['OS_TARGET'] != 'Android': + SOURCES += [ + 'src/third_party/libevent/epoll_sub.c', + ] + SOURCES += [ + 'src/third_party/libevent/epoll.c', + ] if os_bsd: SOURCES += [ @@ -222,6 +255,9 @@ if os_bsd: 'src/base/message_pump_qt.cc', 'src/base/moc_message_pump_qt.cc', ] + SOURCES += [ + 'src/third_party/libevent/kqueue.c', + ] if CONFIG['_MSC_VER']: SOURCES += [ diff --git a/media/libtheora/lib/Makefile.in b/media/libtheora/lib/Makefile.in index e5b29150260e..fced5ac16fe8 100644 --- a/media/libtheora/lib/Makefile.in +++ b/media/libtheora/lib/Makefile.in @@ -17,45 +17,9 @@ endif endif endif -VPATH := $(srcdir) - -ifeq ($(findstring 86,$(OS_TEST)), 86) -ifdef _MSC_VER -ifneq (64,$(findstring 64,$(OS_TEST))) -VPATH += $(srcdir)/x86_vc - -CSRCS += \ - mmxidct.c \ - mmxfrag.c \ - mmxstate.c \ - x86state.c \ - x86cpu.c \ - $(NULL) -endif -else -VPATH += $(srcdir)/x86 - -CSRCS += \ - mmxidct.c \ - mmxfrag.c \ - mmxstate.c \ - sse2idct.c \ - x86state.c \ - x86cpu.c \ - $(NULL) -endif -endif - ifdef GNU_AS ifeq ($(findstring arm,$(OS_TEST)), arm) -VPATH += $(srcdir)/arm - -CSRCS += \ - armcpu.c \ - armstate.c \ - $(NULL) - DEFINES += -DOC_ARM_ASM -DOC_ARM_ASM_EDSP -DOC_ARM_ASM_MEDIA -DOC_ARM_ASM_NEON # The Android NDK doesn't pre-define anything to indicate the OS it's on, so @@ -74,10 +38,10 @@ armloop-gnu.$(ASM_SUFFIX): armopts-gnu.S # armopts needs a specific rule, because arm2gnu.pl will always add the .S # suffix when translating the files that include it. -armopts-gnu.S: armopts.s +armopts-gnu.S: arm/armopts.s $(PERL) $(srcdir)/arm/arm2gnu.pl < $< > $@ # For all others, we can use an implicit rule with the configured $(ASM_SUFFIX). -%-gnu.$(ASM_SUFFIX): %.s +%-gnu.$(ASM_SUFFIX): arm/%.s $(PERL) $(srcdir)/arm/arm2gnu.pl < $< > $@ endif diff --git a/media/libtheora/lib/moz.build b/media/libtheora/lib/moz.build index de6841448a15..82ec973d6e07 100644 --- a/media/libtheora/lib/moz.build +++ b/media/libtheora/lib/moz.build @@ -32,6 +32,33 @@ if CONFIG['OS_TEST'] == 'arm' and CONFIG['GNU_AS']: 'armloop-gnu', ]] +if '86' in CONFIG['OS_TEST']: + if CONFIG['_MSC_VER']: + if '64' not in CONFIG['OS_TEST']: + SOURCES += [ + 'x86_vc/mmxfrag.c', + 'x86_vc/mmxidct.c', + 'x86_vc/mmxstate.c', + 'x86_vc/x86cpu.c', + 'x86_vc/x86state.c', + ] + else: + SOURCES += [ + 'x86/mmxfrag.c', + 'x86/mmxidct.c', + 'x86/mmxstate.c', + 'x86/sse2idct.c', + 'x86/x86cpu.c', + 'x86/x86state.c', + ] + +if CONFIG['GNU_AS']: + if 'arm' in CONFIG['OS_TEST']: + SOURCES += [ + 'arm/armcpu.c', + 'arm/armstate.c', + ] + MSVC_ENABLE_PGO = True FORCE_STATIC_LIB = True diff --git a/xpcom/base/Makefile.in b/xpcom/base/Makefile.in index 4df050591076..c06f5109cece 100644 --- a/xpcom/base/Makefile.in +++ b/xpcom/base/Makefile.in @@ -4,13 +4,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. MOZILLA_INTERNAL_API =1 -ifeq ($(OS_ARCH),WINNT) - -ifdef MOZ_DEBUG -CSRCS += pure_api.c -endif - -endif #if OS_ARCH == WINNT INSTALL_TARGETS += errorlist errorlist_FILES := \ diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index 1df8f329169b..cf1508d79252 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -63,13 +63,13 @@ EXPORTS += [ 'nsWeakPtr.h', ] -if CONFIG['MOZ_DEBUG']: - EXPORTS += ['pure.h'] - if CONFIG['OS_ARCH'] == 'WINNT': EXPORTS += [ 'nsWindowsHelpers.h', ] + if CONFIG['MOZ_DEBUG']: + EXPORTS += ['pure.h'] + SOURCES += ['pure_api.c'] EXPORTS.mozilla += [ 'AvailableMemoryTracker.h', diff --git a/xpcom/build/Makefile.in b/xpcom/build/Makefile.in index 3837dcfa1e65..f2b995dea815 100644 --- a/xpcom/build/Makefile.in +++ b/xpcom/build/Makefile.in @@ -7,10 +7,6 @@ MOZILLA_INTERNAL_API = 1 -ifeq (Darwin, $(OS_ARCH)) -CSRCS = mach_override.c -endif - SHARED_LIBRARY_LIBS = \ $(DEPTH)/chrome/src/$(LIB_PREFIX)chrome_s.$(LIB_SUFFIX) \ ../ds/$(LIB_PREFIX)xpcomds_s.$(LIB_SUFFIX) \ diff --git a/xpcom/build/moz.build b/xpcom/build/moz.build index 8e483458a1c1..8c09b04deb3c 100644 --- a/xpcom/build/moz.build +++ b/xpcom/build/moz.build @@ -33,6 +33,7 @@ if CONFIG['OS_ARCH'] == 'WINNT': ] elif CONFIG['OS_ARCH'] == 'Darwin': SOURCES += [ + 'mach_override.c', 'mozPoisonWriteBase.cpp', 'mozPoisonWriteMac.cpp', ] From 5e41d2d75c3cd426e5ef2d65809a1156c078e900 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 1 Nov 2013 10:30:45 +0900 Subject: [PATCH 008/795] Bug 932197 - Put QT generated files in GENERATED_SOURCES. r=gps --- dom/plugins/ipc/moz.build | 4 +++- dom/system/unix/moz.build | 4 +++- ipc/chromium/moz.build | 4 ++++ netwerk/system/qt/moz.build | 5 ++++- toolkit/xre/moz.build | 4 +++- widget/qt/faststartupqt/moz.build | 12 +++++++++--- widget/qt/moz.build | 13 ++++++++++--- 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/dom/plugins/ipc/moz.build b/dom/plugins/ipc/moz.build index 098de5486347..801fd3e08976 100644 --- a/dom/plugins/ipc/moz.build +++ b/dom/plugins/ipc/moz.build @@ -61,8 +61,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': ] if CONFIG['MOZ_ENABLE_QT']: - SOURCES += [ + GENERATED_SOURCES += [ 'moc_NestedLoopTimer.cpp', + ] + SOURCES += [ 'NestedLoopTimer.cpp', ] diff --git a/dom/system/unix/moz.build b/dom/system/unix/moz.build index 0e4a9aa72e87..3f50ea68a5ee 100644 --- a/dom/system/unix/moz.build +++ b/dom/system/unix/moz.build @@ -7,8 +7,10 @@ MODULE = 'dom' if CONFIG['MOZ_ENABLE_QTMOBILITY']: - SOURCES += [ + GENERATED_SOURCES += [ 'moc_QTMLocationProvider.cpp', + ] + SOURCES += [ 'QTMLocationProvider.cpp', ] diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build index f4a10038d26b..39c249a6894d 100644 --- a/ipc/chromium/moz.build +++ b/ipc/chromium/moz.build @@ -223,6 +223,8 @@ if os_linux: if CONFIG['MOZ_ENABLE_QT']: SOURCES += [ 'src/base/message_pump_qt.cc', + ] + GENERATED_SOURCES += [ 'src/base/moc_message_pump_qt.cc', ] if CONFIG['OS_TARGET'] != 'Android': @@ -253,6 +255,8 @@ if os_bsd: if CONFIG['MOZ_ENABLE_QT']: SOURCES += [ 'src/base/message_pump_qt.cc', + ] + GENERATED_SOURCES += [ 'src/base/moc_message_pump_qt.cc', ] SOURCES += [ diff --git a/netwerk/system/qt/moz.build b/netwerk/system/qt/moz.build index bd61f27d19e6..57fea4f14ba9 100644 --- a/netwerk/system/qt/moz.build +++ b/netwerk/system/qt/moz.build @@ -7,11 +7,14 @@ MODULE = 'necko' SOURCES += [ - 'moc_nsQtNetworkManager.cpp', 'nsQtNetworkLinkService.cpp', 'nsQtNetworkManager.cpp', ] +GENERATED_SOURCES += [ + 'moc_nsQtNetworkManager.cpp', +] + LIBRARY_NAME = 'neckosystem_s' FAIL_ON_WARNINGS = True diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build index e5e1f1eb0c3a..1ee6996d1fdc 100644 --- a/toolkit/xre/moz.build +++ b/toolkit/xre/moz.build @@ -39,8 +39,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': ] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt': EXPORTS += ['nsQAppInstance.h'] - SOURCES += [ + GENERATED_SOURCES += [ 'moc_nsNativeAppSupportQt.cpp', + ] + SOURCES += [ 'nsNativeAppSupportQt.cpp', 'nsQAppInstance.cpp', ] diff --git a/widget/qt/faststartupqt/moz.build b/widget/qt/faststartupqt/moz.build index 76c4b789c59d..96338c801de3 100644 --- a/widget/qt/faststartupqt/moz.build +++ b/widget/qt/faststartupqt/moz.build @@ -6,13 +6,19 @@ MODULE = 'faststartupqt' -SOURCES += [ +GENERATED_SOURCES += [ 'moc_moziqwidget.cpp', 'moc_nsFastStartupQt.cpp', - 'mozqglwidgetwrapper.cpp', 'mozqwidgetfast.cpp', +] + +SOURCES += [ + TOPSRCDIR + '/toolkit/xre/nsQAppInstance.cpp', + TOPSRCDIR + '/widget/qt/mozqglwidgetwrapper.cpp', +] + +SOURCES += [ 'nsFastStartupQt.cpp', - 'nsQAppInstance.cpp', ] LIBRARY_NAME = 'faststartupqt' diff --git a/widget/qt/moz.build b/widget/qt/moz.build index 307a3e64b0f7..128e4362e794 100644 --- a/widget/qt/moz.build +++ b/widget/qt/moz.build @@ -12,10 +12,13 @@ EXPORTS += [ 'nsQtKeyUtils.h', ] -SOURCES += [ +GENERATED_SOURCES += [ 'moc_moziqwidget.cpp', 'moc_mozqwidget.cpp', 'moc_nsAppShell.cpp', +] + +SOURCES += [ 'mozqglwidgetwrapper.cpp', 'mozqwidget.cpp', 'mozSwipeGesture.cpp', @@ -41,15 +44,19 @@ SOURCES += [ if CONFIG['MOZ_ENABLE_CONTENTMANAGER']: SOURCES += [ - 'moc_nsMFilePicker.cpp', 'nsMFilePicker.cpp', ] + GENERATED_SOURCES += [ + 'moc_nsMFilePicker.cpp', + ] if CONFIG[' MOZ_ENABLE_QTMOBILITY']: SOURCES += [ - 'moc_mozqorientationsensorfilter.cpp', 'mozqorientationsensorfilter.cpp', ] + GENERATED_SOURCES += [ + 'moc_mozqorientationsensorfilter.cpp', + ] LIBXUL_LIBRARY = True From 4a02ac1e8a958e845aaaac1e202fbe0373d042be Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:51:03 +0900 Subject: [PATCH 009/795] Bug 864774 part 3 - Move some more CPPSRCS to moz.build. r=mshal --- accessible/src/xpcom/Makefile.in | 2 -- accessible/src/xpcom/moz.build | 4 ++++ ipc/ipdl/test/cxx/Makefile.in | 2 -- ipc/ipdl/test/cxx/moz.build | 4 ++++ js/xpconnect/src/Makefile.in | 6 ------ js/xpconnect/src/moz.build | 6 ++++++ mozglue/build/Makefile.in | 3 --- mozglue/build/moz.build | 3 +++ 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/accessible/src/xpcom/Makefile.in b/accessible/src/xpcom/Makefile.in index bc59fb2e6c47..93e8eb34ee98 100644 --- a/accessible/src/xpcom/Makefile.in +++ b/accessible/src/xpcom/Makefile.in @@ -9,8 +9,6 @@ xpcaccevents_FILES := xpcAccEvents.h xpcaccevents_DEST = $(DIST)/include xpcaccevents_TARGET := export -CPPSRCS += xpcAccEvents.cpp - include $(topsrcdir)/config/rules.mk ifneq ($(A11Y_LOG),0) diff --git a/accessible/src/xpcom/moz.build b/accessible/src/xpcom/moz.build index b7c4149cf24e..148569fa4e0e 100644 --- a/accessible/src/xpcom/moz.build +++ b/accessible/src/xpcom/moz.build @@ -12,6 +12,10 @@ SOURCES += [ 'xpcAccessibleTableCell.cpp', ] +GENERATED_SOURCES += [ + 'xpcAccEvents.cpp', +] + LIBRARY_NAME = 'accessibility_xpcom_s' LIBXUL_LIBRARY = True diff --git a/ipc/ipdl/test/cxx/Makefile.in b/ipc/ipdl/test/cxx/Makefile.in index b6ca0bc92d50..5b0441c73adb 100644 --- a/ipc/ipdl/test/cxx/Makefile.in +++ b/ipc/ipdl/test/cxx/Makefile.in @@ -5,8 +5,6 @@ IPDLTESTSRCS = $(filter Test%,$(CPPSRCS)) IPDLTESTS = $(IPDLTESTSRCS:.cpp=) -CPPSRCS += IPDLUnitTests.cpp - EXTRA_PROTOCOLS = \ TestBridgeSub \ $(NULL) diff --git a/ipc/ipdl/test/cxx/moz.build b/ipc/ipdl/test/cxx/moz.build index 7a7bd99e3ca3..7e351b54788b 100644 --- a/ipc/ipdl/test/cxx/moz.build +++ b/ipc/ipdl/test/cxx/moz.build @@ -60,6 +60,10 @@ SOURCES += [ 'IPDLUnitTestSubprocess.cpp', ] +GENERATED_SOURCES += [ + 'IPDLUnitTests.cpp', +] + IPDL_SOURCES += [ 'PTestActorPunning.ipdl', 'PTestActorPunningPunned.ipdl', diff --git a/js/xpconnect/src/Makefile.in b/js/xpconnect/src/Makefile.in index 9745bd8a8c99..ca84f594eaf6 100644 --- a/js/xpconnect/src/Makefile.in +++ b/js/xpconnect/src/Makefile.in @@ -3,12 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -CPPSRCS += \ - DictionaryHelpers.cpp \ - GeneratedEvents.cpp \ - dom_quickstubs.cpp \ - $(NULL) - LOCAL_INCLUDES = \ -I$(srcdir)/../wrappers \ -I$(srcdir)/../loader \ diff --git a/js/xpconnect/src/moz.build b/js/xpconnect/src/moz.build index 1e0abcd8fdd2..dfda09fdc290 100644 --- a/js/xpconnect/src/moz.build +++ b/js/xpconnect/src/moz.build @@ -50,6 +50,12 @@ SOURCES += [ 'XPCWrapper.cpp', ] +GENERATED_SOURCES += [ + 'DictionaryHelpers.cpp', + 'dom_quickstubs.cpp', + 'GeneratedEvents.cpp', +] + FAIL_ON_WARNINGS = True LIBXUL_LIBRARY = True diff --git a/mozglue/build/Makefile.in b/mozglue/build/Makefile.in index 8f13775b26cb..0ad69ec9fa94 100644 --- a/mozglue/build/Makefile.in +++ b/mozglue/build/Makefile.in @@ -75,9 +75,6 @@ endif endif ifeq (Android,$(OS_TARGET)) -ifdef MOZ_NUWA_PROCESS -CPPSRCS += Nuwa.cpp -endif SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,android,$(DEPTH)/other-licenses/android) endif diff --git a/mozglue/build/moz.build b/mozglue/build/moz.build index f03d3df473aa..861e8b497209 100644 --- a/mozglue/build/moz.build +++ b/mozglue/build/moz.build @@ -35,6 +35,9 @@ if CONFIG['MOZ_NUWA_PROCESS']: EXPORTS.ipc += [ 'Nuwa.h', ] + SOURCES += [ + 'Nuwa.cpp', + ] EXPORTS.mozilla += [ 'arm.h', From 1ee80e6d08c66ca19aaa66b07d0de00cb08cfcaa Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:51:27 +0900 Subject: [PATCH 010/795] Bug 901561 - Move CMSRCS to moz.build. r=gps --- config/config.mk | 1 + js/src/config/config.mk | 1 + python/mozbuild/mozbuild/frontend/emitter.py | 1 + .../google-breakpad/src/common/mac/Makefile.in | 7 ------- .../crashreporter/google-breakpad/src/common/mac/moz.build | 4 ++++ 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/config.mk b/config/config.mk index 6860a79db9ea..67da9929e8f6 100644 --- a/config/config.mk +++ b/config/config.mk @@ -36,6 +36,7 @@ endif _MOZBUILD_EXTERNAL_VARIABLES := \ ANDROID_GENERATED_RESFILES \ ANDROID_RESFILES \ + CMSRCS \ CMMSRCS \ CPP_UNIT_TESTS \ DIRS \ diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 6860a79db9ea..67da9929e8f6 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -36,6 +36,7 @@ endif _MOZBUILD_EXTERNAL_VARIABLES := \ ANDROID_GENERATED_RESFILES \ ANDROID_RESFILES \ + CMSRCS \ CMMSRCS \ CPP_UNIT_TESTS \ DIRS \ diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 074b7e6416cd..7d24e86cf666 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -179,6 +179,7 @@ class TreeMetadataEmitter(LoggingMixin): '.s': 'ASFILES', '.asm': 'ASFILES', '.c': 'CSRCS', + '.m': 'CMSRCS', '.mm': 'CMMSRCS', '.cc': 'CPPSRCS', '.cpp': 'CPPSRCS', diff --git a/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in b/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in index 281953386165..c02efdc408a6 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in @@ -4,13 +4,6 @@ LOCAL_INCLUDES = -I$(srcdir)/../.. -# This is a little weird, but we're building a host and a target lib here. -# The host lib is used for dump_syms, and the target lib for the -# crash reporter client. Therefore, we don't need all the srcs in both. -CMSRCS = \ - HTTPMultipartUpload.m \ - $(NULL) - HOST_CMMSRCS = \ dump_syms.mm \ $(NULL) diff --git a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build index 12012bd2217c..a26f33c25c74 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build @@ -17,10 +17,14 @@ SOURCES += [ 'string_utilities.cc', ] +# This is a little weird, but we're building a host and a target lib here. +# The host lib is used for dump_syms, and the target lib for the +# crash reporter client. Therefore, we don't need all the srcs in both. HOST_SOURCES += SOURCES HOST_LIBRARY_NAME = 'host_breakpad_mac_common_s' SOURCES += [ + 'HTTPMultipartUpload.m', 'MachIPC.mm', ] From d162c6c32d654cbae80e58ade5c3ca2478af42f3 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 30 Oct 2013 07:51:48 +0900 Subject: [PATCH 011/795] Bug 932213 - Move HOST_CMMSRCS to moz.build. r=gps --- config/config.mk | 1 + js/src/config/config.mk | 1 + python/mozbuild/mozbuild/frontend/emitter.py | 1 + .../crashreporter/google-breakpad/src/common/mac/Makefile.in | 4 ---- .../crashreporter/google-breakpad/src/common/mac/moz.build | 4 ++++ .../google-breakpad/src/tools/mac/dump_syms/Makefile.in | 4 ---- .../google-breakpad/src/tools/mac/dump_syms/moz.build | 3 +++ 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/config.mk b/config/config.mk index 67da9929e8f6..d00b3f8b3950 100644 --- a/config/config.mk +++ b/config/config.mk @@ -47,6 +47,7 @@ _MOZBUILD_EXTERNAL_VARIABLES := \ GTEST_CPPSRCS \ GTEST_CSRCS \ HOST_CSRCS \ + HOST_CMMSRCS \ HOST_LIBRARY_NAME \ IS_COMPONENT \ JAVA_JAR_TARGETS \ diff --git a/js/src/config/config.mk b/js/src/config/config.mk index 67da9929e8f6..d00b3f8b3950 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -47,6 +47,7 @@ _MOZBUILD_EXTERNAL_VARIABLES := \ GTEST_CPPSRCS \ GTEST_CSRCS \ HOST_CSRCS \ + HOST_CMMSRCS \ HOST_LIBRARY_NAME \ IS_COMPONENT \ JAVA_JAR_TARGETS \ diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 7d24e86cf666..3b08fd943678 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -187,6 +187,7 @@ class TreeMetadataEmitter(LoggingMixin): }, HOST_SOURCES={ '.c': 'HOST_CSRCS', + '.mm': 'HOST_CMMSRCS', '.cc': 'HOST_CPPSRCS', '.cpp': 'HOST_CPPSRCS', }, diff --git a/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in b/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in index c02efdc408a6..ca51a66b5815 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/Makefile.in @@ -4,10 +4,6 @@ LOCAL_INCLUDES = -I$(srcdir)/../.. -HOST_CMMSRCS = \ - dump_syms.mm \ - $(NULL) - include $(topsrcdir)/config/rules.mk COMPILE_CMFLAGS += -std=c99 diff --git a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build index a26f33c25c74..9387edec5b1d 100644 --- a/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/moz.build @@ -22,6 +22,10 @@ SOURCES += [ # crash reporter client. Therefore, we don't need all the srcs in both. HOST_SOURCES += SOURCES +HOST_SOURCES += [ + 'dump_syms.mm', +] + HOST_LIBRARY_NAME = 'host_breakpad_mac_common_s' SOURCES += [ 'HTTPMultipartUpload.m', diff --git a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/Makefile.in b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/Makefile.in index d62363170e74..75ea54264580 100644 --- a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/Makefile.in +++ b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/Makefile.in @@ -9,10 +9,6 @@ LOCAL_INCLUDES = \ -I$(srcdir)/../../../common/mac \ $(NULL) -HOST_CMMSRCS = \ - dump_syms_tool.mm \ - $(NULL) - HOST_LIBS += \ $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/dwarf/$(LIB_PREFIX)host_breakpad_dwarf_s.$(LIB_SUFFIX) \ $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/mac/$(LIB_PREFIX)host_breakpad_mac_common_s.$(LIB_SUFFIX) \ diff --git a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build index 895d11993cfb..41f349c07aca 100644 --- a/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build +++ b/toolkit/crashreporter/google-breakpad/src/tools/mac/dump_syms/moz.build @@ -4,3 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +HOST_SOURCES += [ + 'dump_syms_tool.mm', +] From aefaa836ba7bf539e8338331f43aca2739a83720 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 1 Nov 2013 10:30:46 +0900 Subject: [PATCH 012/795] Bug 933047 - Add a configure check whether the C++ compiler actually is a C++ compiler. r=ted --- build/autoconf/compiler-opts.m4 | 12 ++++++++++++ js/src/build/autoconf/compiler-opts.m4 | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 index 62190544eb42..fc953d1f3c29 100644 --- a/build/autoconf/compiler-opts.m4 +++ b/build/autoconf/compiler-opts.m4 @@ -192,6 +192,18 @@ if test "$CLANG_CXX"; then _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-mismatched-tags" fi +AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) actually is a C++ compiler]) +AC_LANG_SAVE +AC_LANG_CPLUSPLUS +_SAVE_LIBS=$LIBS +LIBS= +AC_TRY_LINK([#include ], [int *foo = new int;],, + AC_MSG_RESULT([no]) + AC_MSG_ERROR([$CXX $CXXFLAGS $LDFLAGS failed to compile and link a simple C++ source.])) +LIBS=$_SAVE_LIBS +AC_LANG_RESTORE +AC_MSG_RESULT([yes]) + if test -z "$GNU_CC"; then case "$target" in *-mingw*) diff --git a/js/src/build/autoconf/compiler-opts.m4 b/js/src/build/autoconf/compiler-opts.m4 index 62190544eb42..fc953d1f3c29 100644 --- a/js/src/build/autoconf/compiler-opts.m4 +++ b/js/src/build/autoconf/compiler-opts.m4 @@ -192,6 +192,18 @@ if test "$CLANG_CXX"; then _WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-mismatched-tags" fi +AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) actually is a C++ compiler]) +AC_LANG_SAVE +AC_LANG_CPLUSPLUS +_SAVE_LIBS=$LIBS +LIBS= +AC_TRY_LINK([#include ], [int *foo = new int;],, + AC_MSG_RESULT([no]) + AC_MSG_ERROR([$CXX $CXXFLAGS $LDFLAGS failed to compile and link a simple C++ source.])) +LIBS=$_SAVE_LIBS +AC_LANG_RESTORE +AC_MSG_RESULT([yes]) + if test -z "$GNU_CC"; then case "$target" in *-mingw*) From 87cceb9126de64d5299f8d199f34c0700ab5c00d Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 1 Nov 2013 10:30:46 +0900 Subject: [PATCH 013/795] Bug 933062 - Avoid using > for preprocessing rules, so that pymake is happy. r=ted --- config/rules.mk | 10 ++++++---- js/src/config/rules.mk | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config/rules.mk b/config/rules.mk index 20461b4d4af0..735280e47b25 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -568,8 +568,10 @@ endif ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) OUTOPTION = -Fo# eol +PREPROCESS_OPTION = -P -Fi# eol else OUTOPTION = -o # eol +PREPROCESS_OPTION = -E -o #eol endif # WINNT && !GNU_CC ifneq (,$(filter ml%,$(AS))) @@ -1069,19 +1071,19 @@ $(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR)) $(filter %.i,$(CPPSRCS:%.cpp=%.i)): %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CCC) -C -E $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(filter %.i,$(CPPSRCS:%.cc=%.i)): %.i: %.cc $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CCC) -C -E $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(filter %.i,$(CSRCS:%.c=%.i)): %.i: %.c $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CC) -C -E $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(filter %.i,$(CMMSRCS:%.mm=%.i)): %.i: %.mm $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(RESFILE): %.res: %.rc $(REPORT_BUILD) diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 20461b4d4af0..735280e47b25 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -568,8 +568,10 @@ endif ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH)) OUTOPTION = -Fo# eol +PREPROCESS_OPTION = -P -Fi# eol else OUTOPTION = -o # eol +PREPROCESS_OPTION = -E -o #eol endif # WINNT && !GNU_CC ifneq (,$(filter ml%,$(AS))) @@ -1069,19 +1071,19 @@ $(filter %.s,$(CSRCS:%.c=%.s)): %.s: %.c $(call mkdir_deps,$(MDDEPDIR)) $(filter %.i,$(CPPSRCS:%.cpp=%.i)): %.i: %.cpp $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CCC) -C -E $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(filter %.i,$(CPPSRCS:%.cc=%.i)): %.i: %.cc $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CCC) -C -E $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(filter %.i,$(CSRCS:%.c=%.i)): %.i: %.c $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CC) -C -E $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(filter %.i,$(CMMSRCS:%.mm=%.i)): %.i: %.mm $(call mkdir_deps,$(MDDEPDIR)) $(REPORT_BUILD) - $(CCC) -C -E $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) > $*.i + $(CCC) -C $(PREPROCESS_OPTION)$@ $(COMPILE_CXXFLAGS) $(COMPILE_CMMFLAGS) $(TARGET_LOCAL_INCLUDES) $(_VPATH_SRCS) $(RESFILE): %.res: %.rc $(REPORT_BUILD) From e1f9084a2a988f43b32bafa0660a97ac7766dfe3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 30 Oct 2013 15:10:06 -0700 Subject: [PATCH 014/795] Bug 815467 - Store pldhash's recursionLevel in a better place, so that debug and non-debug pldhashes take up the same amount of memory. r=dbaron. --HG-- extra : rebase_source : c3c928f6706be4ef55620f05320050991a657a6c --- xpcom/glue/pldhash.cpp | 46 +++++++++++++++++------------------------- xpcom/glue/pldhash.h | 7 +++++++ 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/xpcom/glue/pldhash.cpp b/xpcom/glue/pldhash.cpp index d8897b29926f..3f5a7b526780 100644 --- a/xpcom/glue/pldhash.cpp +++ b/xpcom/glue/pldhash.cpp @@ -29,16 +29,10 @@ /* * The following DEBUG-only code is used to assert that calls to one of * table->ops or to an enumerator do not cause re-entry into a call that - * can mutate the table. The recursion level is stored in additional - * space allocated at the end of the entry store to avoid changing - * PLDHashTable, which could cause issues when mixing DEBUG and - * non-DEBUG components. + * can mutate the table. */ #ifdef DEBUG -#define RECURSION_LEVEL(table_) (*(uint32_t*)(table_->entryStore + \ - PL_DHASH_TABLE_SIZE(table_) * \ - table_->entrySize)) /* * Most callers that assert about the recursion level don't care about * this magical value because they are asserting that mutation is @@ -47,29 +41,27 @@ * * Only PL_DHashTableFinish needs to allow this special value. */ -#define IMMUTABLE_RECURSION_LEVEL ((uint32_t)-1) +#define IMMUTABLE_RECURSION_LEVEL ((uint16_t)-1) #define RECURSION_LEVEL_SAFE_TO_FINISH(table_) \ - (RECURSION_LEVEL(table_) == 0 || \ - RECURSION_LEVEL(table_) == IMMUTABLE_RECURSION_LEVEL) + (table_->recursionLevel == 0 || \ + table_->recursionLevel == IMMUTABLE_RECURSION_LEVEL) -#define ENTRY_STORE_EXTRA sizeof(uint32_t) #define INCREMENT_RECURSION_LEVEL(table_) \ PR_BEGIN_MACRO \ - if (RECURSION_LEVEL(table_) != IMMUTABLE_RECURSION_LEVEL) \ - ++RECURSION_LEVEL(table_); \ + if (table_->recursionLevel != IMMUTABLE_RECURSION_LEVEL) \ + ++table_->recursionLevel; \ PR_END_MACRO #define DECREMENT_RECURSION_LEVEL(table_) \ PR_BEGIN_MACRO \ - if (RECURSION_LEVEL(table_) != IMMUTABLE_RECURSION_LEVEL) { \ - MOZ_ASSERT(RECURSION_LEVEL(table_) > 0); \ - --RECURSION_LEVEL(table_); \ + if (table->recursionLevel != IMMUTABLE_RECURSION_LEVEL) { \ + MOZ_ASSERT(table->recursionLevel > 0); \ + --table->recursionLevel; \ } \ PR_END_MACRO #else -#define ENTRY_STORE_EXTRA 0 #define INCREMENT_RECURSION_LEVEL(table_) PR_BEGIN_MACRO PR_END_MACRO #define DECREMENT_RECURSION_LEVEL(table_) PR_BEGIN_MACRO PR_END_MACRO @@ -234,15 +226,14 @@ PL_DHashTableInit(PLDHashTable *table, const PLDHashTableOps *ops, void *data, if (!SizeOfEntryStore(capacity, entrySize, &nbytes)) return false; // overflowed - table->entryStore = (char *) ops->allocTable(table, - nbytes + ENTRY_STORE_EXTRA); + table->entryStore = (char *) ops->allocTable(table, nbytes); if (!table->entryStore) return false; memset(table->entryStore, 0, nbytes); METER(memset(&table->stats, 0, sizeof table->stats)); #ifdef DEBUG - RECURSION_LEVEL(table) = 0; + table->recursionLevel = 0; #endif return true; @@ -488,14 +479,13 @@ ChangeTable(PLDHashTable *table, int deltaLog2) if (!SizeOfEntryStore(newCapacity, entrySize, &nbytes)) return false; // overflowed - newEntryStore = (char *) table->ops->allocTable(table, - nbytes + ENTRY_STORE_EXTRA); + newEntryStore = (char *) table->ops->allocTable(table, nbytes); if (!newEntryStore) return false; /* We can't fail from here on, so update table parameters. */ #ifdef DEBUG - recursionLevel = RECURSION_LEVEL(table); + recursionLevel = table->recursionLevel; #endif table->hashShift = PL_DHASH_BITS - newLog2; table->removedCount = 0; @@ -507,7 +497,7 @@ ChangeTable(PLDHashTable *table, int deltaLog2) table->entryStore = newEntryStore; moveEntry = table->ops->moveEntry; #ifdef DEBUG - RECURSION_LEVEL(table) = recursionLevel; + table->recursionLevel = recursionLevel; #endif /* Copy only live entries, leaving removed ones behind. */ @@ -536,7 +526,7 @@ PL_DHashTableOperate(PLDHashTable *table, const void *key, PLDHashOperator op) uint32_t size; int deltaLog2; - MOZ_ASSERT(op == PL_DHASH_LOOKUP || RECURSION_LEVEL(table) == 0); + MOZ_ASSERT(op == PL_DHASH_LOOKUP || table->recursionLevel == 0); INCREMENT_RECURSION_LEVEL(table); keyHash = table->ops->hashKey(table, key); @@ -637,7 +627,7 @@ PL_DHashTableRawRemove(PLDHashTable *table, PLDHashEntryHdr *entry) { PLDHashNumber keyHash; /* load first in case clearEntry goofs it */ - MOZ_ASSERT(RECURSION_LEVEL(table) != IMMUTABLE_RECURSION_LEVEL); + MOZ_ASSERT(table->recursionLevel != IMMUTABLE_RECURSION_LEVEL); NS_ASSERTION(PL_DHASH_ENTRY_IS_LIVE(entry), "PL_DHASH_ENTRY_IS_LIVE(entry)"); @@ -685,7 +675,7 @@ PL_DHashTableEnumerate(PLDHashTable *table, PLDHashEnumerator etor, void *arg) entryAddr += entrySize; } - MOZ_ASSERT(!didRemove || RECURSION_LEVEL(table) == 1); + MOZ_ASSERT(!didRemove || table->recursionLevel == 1); /* * Shrink or compress if a quarter or more of all entries are removed, or @@ -764,7 +754,7 @@ PL_DHashTableSizeOfIncludingThis(const PLDHashTable *table, void PL_DHashMarkTableImmutable(PLDHashTable *table) { - RECURSION_LEVEL(table) = IMMUTABLE_RECURSION_LEVEL; + table->recursionLevel = IMMUTABLE_RECURSION_LEVEL; } #endif diff --git a/xpcom/glue/pldhash.h b/xpcom/glue/pldhash.h index 66366c4f1d25..bdb08c7c3663 100644 --- a/xpcom/glue/pldhash.h +++ b/xpcom/glue/pldhash.h @@ -186,6 +186,13 @@ struct PLDHashTable { const PLDHashTableOps *ops; /* virtual operations, see below */ void *data; /* ops- and instance-specific data */ int16_t hashShift; /* multiplicative hash shift */ + /* + * |recursionLevel| is only used in debug builds, but is present in opt + * builds to avoid binary compatibility problems when mixing DEBUG and + * non-DEBUG components. (Actually, even if it were removed, + * sizeof(PLDHashTable) wouldn't change, due to struct padding.) + */ + uint16_t recursionLevel; /* used to detect unsafe re-entry */ uint32_t entrySize; /* number of bytes in an entry */ uint32_t entryCount; /* number of entries in table */ uint32_t removedCount; /* removed entry sentinels in table */ From feef731f1339a988ef51871e38073a486c2f3067 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 1 Nov 2013 14:54:14 +1300 Subject: [PATCH 015/795] Bug 887791 - Add MacIOSurfaceImage. r=roc --- gfx/layers/ImageContainer.cpp | 7 +++++ gfx/layers/ImageTypes.h | 5 ++++ gfx/layers/MacIOSurfaceImage.h | 55 ++++++++++++++++++++++++++++++++++ gfx/layers/moz.build | 3 ++ 4 files changed, 70 insertions(+) create mode 100644 gfx/layers/MacIOSurfaceImage.h diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index d3325ff58ba8..4af2aa4da112 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -22,6 +22,7 @@ #ifdef XP_MACOSX #include "mozilla/gfx/QuartzSupport.h" +#include "MacIOSurfaceImage.h" #endif #ifdef XP_WIN @@ -74,6 +75,12 @@ ImageFactory::CreateImage(const ImageFormat *aFormats, img = new SharedTextureImage(); return img.forget(); } +#ifdef XP_MACOSX + if (FormatInList(aFormats, aNumFormats, MAC_IOSURFACE)) { + img = new MacIOSurfaceImage(); + return img.forget(); + } +#endif #ifdef XP_WIN if (FormatInList(aFormats, aNumFormats, D3D9_RGB32_TEXTURE)) { img = new D3D9SurfaceImage(); diff --git a/gfx/layers/ImageTypes.h b/gfx/layers/ImageTypes.h index 6386d5d87cf6..114b5a748cbd 100644 --- a/gfx/layers/ImageTypes.h +++ b/gfx/layers/ImageTypes.h @@ -45,6 +45,11 @@ enum ImageFormat { */ CAIRO_SURFACE, + /** + * A MacIOSurface object. + */ + MAC_IOSURFACE, + /** * An bitmap image that can be shared with a remote process. */ diff --git a/gfx/layers/MacIOSurfaceImage.h b/gfx/layers/MacIOSurfaceImage.h new file mode 100644 index 000000000000..5a07fc1d7a08 --- /dev/null +++ b/gfx/layers/MacIOSurfaceImage.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GFX_MACIOSURFACEIMAGE_H +#define GFX_MACIOSURFACEIMAGE_H + +#include "mozilla/gfx/MacIOSurface.h" +#include "gfxImageSurface.h" + +namespace mozilla { + +namespace layers { + +class MacIOSurfaceImage : public Image { +public: + void SetSurface(MacIOSurface* aSurface) { mSurface = aSurface; } + MacIOSurface* GetSurface() { return mSurface; } + + gfxIntSize GetSize() { + return gfxIntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight()); + } + + virtual already_AddRefed GetAsSurface() { + mSurface->Lock(); + size_t bytesPerRow = mSurface->GetBytesPerRow(); + size_t ioWidth = mSurface->GetDevicePixelWidth(); + size_t ioHeight = mSurface->GetDevicePixelHeight(); + + unsigned char* ioData = (unsigned char*)mSurface->GetBaseAddress(); + + nsRefPtr imgSurface = + new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormatARGB32); + + for (size_t i = 0; i < ioHeight; i++) { + memcpy(imgSurface->Data() + i * imgSurface->Stride(), + ioData + i * bytesPerRow, ioWidth * 4); + } + + mSurface->Unlock(); + + return imgSurface.forget(); + } + + MacIOSurfaceImage() : Image(nullptr, MAC_IOSURFACE) {} + +private: + RefPtr mSurface; +}; + +} // layers +} // mozilla + +#endif // GFX_SHAREDTEXTUREIMAGE_H diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 83ccd7297cbe..86b9d15ab004 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -161,6 +161,9 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': EXPORTS.mozilla.layers += [ 'opengl/GLManager.h', ] + EXPORTS += [ + 'MacIOSurfaceImage.h', + ] SOURCES += [ 'ipc/ShadowLayerUtilsMac.cpp', 'opengl/GLManager.cpp', From 858f960ea32161b5d343b7bf27ed8c384c030db9 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 1 Nov 2013 14:54:14 +1300 Subject: [PATCH 016/795] Bug 887791 - Add a TextureClient implementation for MacIOSurface. r=nical --- gfx/layers/ipc/LayersSurfaces.ipdlh | 7 +++++ gfx/layers/opengl/TextureClientOGL.cpp | 15 +++++++++- gfx/layers/opengl/TextureClientOGL.h | 41 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 46679b7460b3..8cdac5cdb013 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -51,6 +51,12 @@ struct SurfaceDescriptorD3D10 { bool hasAlpha; }; +struct SurfaceDescriptorMacIOSurface { + uint32_t surface; + double scaleFactor; + bool hasAlpha; +}; + struct SharedTextureDescriptor { SharedTextureShareType shareType; SharedTextureHandle handle; @@ -176,6 +182,7 @@ union SurfaceDescriptor { SurfaceDescriptorX11; SharedTextureDescriptor; SurfaceStreamDescriptor; + SurfaceDescriptorMacIOSurface; NewSurfaceDescriptorGralloc; YCbCrImage; // XXX - deprecated SurfaceDescriptorGralloc; // XXX - deprecated diff --git a/gfx/layers/opengl/TextureClientOGL.cpp b/gfx/layers/opengl/TextureClientOGL.cpp index b7c63d65c5e4..038907ff69c6 100644 --- a/gfx/layers/opengl/TextureClientOGL.cpp +++ b/gfx/layers/opengl/TextureClientOGL.cpp @@ -66,7 +66,20 @@ SharedTextureClientOGL::IsAllocated() const return mHandle != 0; } - +#ifdef XP_MACOSX +bool +MacIOSurfaceTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) +{ + MOZ_ASSERT(IsValid()); + if (!IsAllocated()) { + return false; + } + aOutDescriptor = SurfaceDescriptorMacIOSurface(mSurface->GetIOSurfaceID(), + mSurface->GetContentsScaleFactor(), + mSurface->HasAlpha()); + return true; +} +#endif DeprecatedTextureClientSharedOGL::DeprecatedTextureClientSharedOGL(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo) diff --git a/gfx/layers/opengl/TextureClientOGL.h b/gfx/layers/opengl/TextureClientOGL.h index f60729ff959d..ba19b228d451 100644 --- a/gfx/layers/opengl/TextureClientOGL.h +++ b/gfx/layers/opengl/TextureClientOGL.h @@ -13,6 +13,9 @@ #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor #include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc +#ifdef XP_MACOSX +#include "mozilla/gfx/MacIOSurface.h" +#endif namespace mozilla { namespace layers { @@ -57,6 +60,44 @@ protected: bool mInverted; }; +#ifdef XP_MACOSX +class MacIOSurfaceTextureClientOGL : public TextureClient +{ +public: + MacIOSurfaceTextureClientOGL(TextureFlags aFlags) + : TextureClient(aFlags) + {} + + virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mSurface; } + + virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; + + void InitWith(MacIOSurface* aSurface) + { + MOZ_ASSERT(IsValid()); + MOZ_ASSERT(!IsAllocated()); + mSurface = aSurface; + } + + virtual gfx::IntSize GetSize() const + { + return gfx::IntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight()); + } + + virtual TextureClientData* DropTextureData() MOZ_OVERRIDE + { + // MacIOSurface has proper cross-process refcounting so we can just drop + // our reference now, and the data will stay alive (at least) until the host + // has also been torn down. + mSurface = nullptr; + MarkInvalid(); + return nullptr; + } + +protected: + RefPtr mSurface; +}; +#endif class DeprecatedTextureClientSharedOGL : public DeprecatedTextureClient { From 19adca2566f676b6b23a4df6dd3c5bbcbb1bf436 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 1 Nov 2013 14:54:14 +1300 Subject: [PATCH 017/795] Bug 887791 - Add a TextureHost implementation for MacIOSurface. r=nical --- gfx/layers/opengl/TextureHostOGL.cpp | 65 +++++++++++++++++ gfx/layers/opengl/TextureHostOGL.h | 105 +++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 0d65282ce425..f08102601ee2 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -104,6 +104,14 @@ CreateTextureHostOGL(uint64_t aID, desc.inverted()); break; } +#ifdef XP_MACOSX + case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: { + const SurfaceDescriptorMacIOSurface& desc = + aDesc.get_SurfaceDescriptorMacIOSurface(); + result = new MacIOSurfaceTextureHostOGL(aID, aFlags, desc); + break; + } +#endif #ifdef MOZ_WIDGET_GONK case SurfaceDescriptor::TNewSurfaceDescriptorGralloc: { const NewSurfaceDescriptorGralloc& desc = @@ -429,6 +437,63 @@ SharedTextureHostOGL::GetFormat() const return mTextureSource->GetFormat(); } +#ifdef XP_MACOSX +MacIOSurfaceTextureHostOGL::MacIOSurfaceTextureHostOGL(uint64_t aID, + TextureFlags aFlags, + const SurfaceDescriptorMacIOSurface& aDescriptor) + : TextureHost(aID, aFlags) +{ + mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(), + aDescriptor.scaleFactor(), + aDescriptor.hasAlpha()); +} + +bool +MacIOSurfaceTextureHostOGL::Lock() +{ + if (!mCompositor) { + return false; + } + + if (!mTextureSource) { + mTextureSource = new MacIOSurfaceTextureSourceOGL(mCompositor, mSurface); + } + return true; +} + +void +MacIOSurfaceTextureHostOGL::SetCompositor(Compositor* aCompositor) +{ + CompositorOGL* glCompositor = static_cast(aCompositor); + mCompositor = glCompositor; + if (mTextureSource) { + mTextureSource->SetCompositor(glCompositor); + } +} + +void +MacIOSurfaceTextureSourceOGL::BindTexture(GLenum aTextureUnit) +{ + if (!gl()) { + NS_WARNING("Trying to bind a texture without a GLContext"); + return; + } + GLuint tex = mCompositor->GetTemporaryTexture(aTextureUnit); + + gl()->fActiveTexture(aTextureUnit); + gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, tex); + void *nativeGL = gl()->GetNativeData(gl::GLContext::NativeGLContext); + mSurface->CGLTexImageIOSurface2D(nativeGL); + gl()->fActiveTexture(LOCAL_GL_TEXTURE0); +} + +gl::GLContext* +MacIOSurfaceTextureSourceOGL::gl() const +{ + return mCompositor ? mCompositor->gl() : nullptr; +} +#endif + TextureImageDeprecatedTextureHostOGL::~TextureImageDeprecatedTextureHostOGL() { MOZ_COUNT_DTOR(TextureImageDeprecatedTextureHostOGL); diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index 1b327d7c0029..43b381c944dd 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -34,6 +34,9 @@ #ifdef MOZ_WIDGET_GONK #include #endif +#ifdef XP_MACOSX +#include "mozilla/gfx/MacIOSurface.h" +#endif class gfxImageSurface; class gfxReusableSurfaceWrapper; @@ -348,6 +351,108 @@ protected: RefPtr mTextureSource; }; +#ifdef XP_MACOSX +/** + * A texture source meant for use with MacIOSurfaceTextureHostOGL. + * + * It does not own any GL texture, and attaches its shared handle to one of + * the compositor's temporary textures when binding. + */ +class MacIOSurfaceTextureSourceOGL : public NewTextureSource + , public TextureSourceOGL +{ +public: + MacIOSurfaceTextureSourceOGL(CompositorOGL* aCompositor, + MacIOSurface* aSurface) + : mCompositor(aCompositor) + , mSurface(aSurface) + {} + + virtual TextureSourceOGL* AsSourceOGL() { return this; } + + virtual void BindTexture(GLenum activetex) MOZ_OVERRIDE; + + virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); } + + virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { + return gfx::IntSize(mSurface->GetDevicePixelWidth(), + mSurface->GetDevicePixelHeight()); + } + + virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { + return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8; } + + virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_RECTANGLE_ARB; } + + virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; } + + virtual void UnbindTexture() MOZ_OVERRIDE {} + + // MacIOSurfaceTextureSourceOGL doesn't own any gl texture + virtual void DeallocateDeviceData() {} + + void SetCompositor(CompositorOGL* aCompositor) { + mCompositor = aCompositor; + } + + gl::GLContext* gl() const; + +protected: + CompositorOGL* mCompositor; + RefPtr mSurface; +}; + +/** + * A TextureHost for shared MacIOSurface + * + * Most of the logic actually happens in MacIOSurfaceTextureSourceOGL. + */ +class MacIOSurfaceTextureHostOGL : public TextureHost +{ +public: + MacIOSurfaceTextureHostOGL(uint64_t aID, + TextureFlags aFlags, + const SurfaceDescriptorMacIOSurface& aDescriptor); + + // SharedTextureHostOGL doesn't own any GL texture + virtual void DeallocateDeviceData() MOZ_OVERRIDE {} + + virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; + + virtual bool Lock() MOZ_OVERRIDE; + + virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { + return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8; + } + + virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE + { + return mTextureSource; + } + + virtual already_AddRefed GetAsSurface() MOZ_OVERRIDE + { + return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING) + } + + gl::GLContext* gl() const; + + virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { + return gfx::IntSize(mSurface->GetDevicePixelWidth(), + mSurface->GetDevicePixelHeight()); + } + +#ifdef MOZ_LAYERS_HAVE_LOG + virtual const char* Name() { return "MacIOSurfaceTextureHostOGL"; } +#endif + +protected: + CompositorOGL* mCompositor; + RefPtr mTextureSource; + RefPtr mSurface; +}; +#endif + /** * DeprecatedTextureHost implementation using a TextureImage as the underlying texture. */ From ec7aaa7f24d937694e27d4c2d00339b319dacf95 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 1 Nov 2013 14:54:14 +1300 Subject: [PATCH 018/795] Bug 887791 - Implement ISharedImage for MacIOSurfaceImage. r=nical --- gfx/layers/MacIOSurfaceImage.cpp | 21 +++++++++++++++++++++ gfx/layers/MacIOSurfaceImage.h | 11 ++++++++++- gfx/layers/moz.build | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gfx/layers/MacIOSurfaceImage.cpp diff --git a/gfx/layers/MacIOSurfaceImage.cpp b/gfx/layers/MacIOSurfaceImage.cpp new file mode 100644 index 000000000000..bd09bc6d1224 --- /dev/null +++ b/gfx/layers/MacIOSurfaceImage.cpp @@ -0,0 +1,21 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "MacIOSurfaceImage.h" +#include "mozilla/layers/TextureClientOGL.h" + +using namespace mozilla::layers; + +TextureClient* +MacIOSurfaceImage::GetTextureClient() +{ + if (!mTextureClient) { + RefPtr buffer = + new MacIOSurfaceTextureClientOGL(TEXTURE_FLAGS_DEFAULT); + buffer->InitWith(mSurface); + mTextureClient = buffer; + } + return mTextureClient; +} diff --git a/gfx/layers/MacIOSurfaceImage.h b/gfx/layers/MacIOSurfaceImage.h index 5a07fc1d7a08..66ba6b18df9f 100644 --- a/gfx/layers/MacIOSurfaceImage.h +++ b/gfx/layers/MacIOSurfaceImage.h @@ -6,14 +6,17 @@ #ifndef GFX_MACIOSURFACEIMAGE_H #define GFX_MACIOSURFACEIMAGE_H +#include "ImageContainer.h" #include "mozilla/gfx/MacIOSurface.h" +#include "mozilla/layers/TextureClient.h" #include "gfxImageSurface.h" namespace mozilla { namespace layers { -class MacIOSurfaceImage : public Image { +class MacIOSurfaceImage : public Image, + public ISharedImage { public: void SetSurface(MacIOSurface* aSurface) { mSurface = aSurface; } MacIOSurface* GetSurface() { return mSurface; } @@ -22,6 +25,8 @@ public: return gfxIntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight()); } + virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; } + virtual already_AddRefed GetAsSurface() { mSurface->Lock(); size_t bytesPerRow = mSurface->GetBytesPerRow(); @@ -43,10 +48,14 @@ public: return imgSurface.forget(); } + virtual TextureClient* GetTextureClient() MOZ_OVERRIDE; + virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; } + MacIOSurfaceImage() : Image(nullptr, MAC_IOSURFACE) {} private: RefPtr mSurface; + RefPtr mTextureClient; }; } // layers diff --git a/gfx/layers/moz.build b/gfx/layers/moz.build index 86b9d15ab004..d5c27b8f6071 100644 --- a/gfx/layers/moz.build +++ b/gfx/layers/moz.build @@ -166,6 +166,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': ] SOURCES += [ 'ipc/ShadowLayerUtilsMac.cpp', + 'MacIOSurfaceImage.cpp', 'opengl/GLManager.cpp', ] From 3552a1ef3d7ea1715d136412428e2b966255d044 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 1 Nov 2013 14:54:15 +1300 Subject: [PATCH 019/795] Bug 887791 - Use the MacIOSurface TextureClient/Host for sharing MacIOSurface objects. r=roc --- dom/plugins/ipc/PluginInstanceParent.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index a4fd7a435219..5b0edfe88b35 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -31,6 +31,10 @@ #include "GLContext.h" #include "GLContextProvider.h" +#ifdef XP_MACOSX +#include "MacIOSurfaceImage.h" +#endif + #if defined(OS_WIN) #include #include "gfxWindowsPlatform.h" @@ -713,26 +717,16 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer) #ifdef XP_MACOSX if (ioSurface) { - ImageFormat format = SHARED_TEXTURE; + ImageFormat format = MAC_IOSURFACE; nsRefPtr image = container->CreateImage(&format, 1); if (!image) { return NS_ERROR_FAILURE; } - NS_ASSERTION(image->GetFormat() == SHARED_TEXTURE, "Wrong format?"); + NS_ASSERTION(image->GetFormat() == MAC_IOSURFACE, "Wrong format?"); - SharedTextureImage::Data data; - data.mShareType = gl::SameProcess; - data.mHandle = GLContextProviderCGL::CreateSharedHandle(data.mShareType, - ioSurface, - gl::IOSurface); - data.mInverted = false; - // Use the device pixel size of the IOSurface, since layers handles resolution scaling - // already. - data.mSize = gfxIntSize(ioSurface->GetDevicePixelWidth(), ioSurface->GetDevicePixelHeight()); - - SharedTextureImage* pluginImage = static_cast(image.get()); - pluginImage->SetData(data); + MacIOSurfaceImage* pluginImage = static_cast(image.get()); + pluginImage->SetSurface(ioSurface); container->SetCurrentImageInTransaction(pluginImage); From c3b05bed48d7436fcc1c1d2e7f5f75292b3bdaac Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Fri, 1 Nov 2013 14:54:15 +1300 Subject: [PATCH 020/795] Bug 887791 - Remove a bunch of now-unused SharedTextureHandle code. r=roc --- gfx/gl/GLContextProviderCGL.mm | 74 -------------------------------- gfx/gl/GLContextProviderEGL.cpp | 15 ------- gfx/gl/GLContextProviderGLX.cpp | 15 ------- gfx/gl/GLContextProviderImpl.h | 13 ------ gfx/gl/GLContextProviderNull.cpp | 15 ------- gfx/gl/GLContextProviderWGL.cpp | 15 ------- gfx/layers/SharedTextureImage.h | 4 +- 7 files changed, 2 insertions(+), 149 deletions(-) diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index f83f20d22423..3422743162ab 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -202,39 +202,6 @@ public: TextureImage::Flags aFlags = TextureImage::NoFlags, TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown) MOZ_OVERRIDE; - virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType) - { - return GLContextProviderCGL::CreateSharedHandle(shareType, buffer, bufferType); - } - - virtual void ReleaseSharedHandle(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) - { - if (sharedHandle) { - reinterpret_cast(sharedHandle)->Release(); - } - } - - virtual bool GetSharedHandleDetails(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle, - SharedHandleDetails& details) - { - MacIOSurface* surf = reinterpret_cast(sharedHandle); - details.mTarget = LOCAL_GL_TEXTURE_RECTANGLE_ARB; - details.mTextureFormat = surf->HasAlpha() ? FORMAT_R8G8B8A8 : FORMAT_R8G8B8X8; - return true; - } - - virtual bool AttachSharedHandle(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) - { - MacIOSurface* surf = reinterpret_cast(sharedHandle); - surf->CGLTexImageIOSurface2D(mContext); - return true; - } - NSOpenGLContext *mContext; GLuint mTempTextureName; @@ -526,47 +493,6 @@ GLContextProviderCGL::GetGlobalContext(const ContextFlags) return gGlobalContext; } -SharedTextureHandle -GLContextProviderCGL::CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType) -{ - if (shareType != SameProcess || - bufferType != gl::IOSurface) { - return 0; - } - - MacIOSurface* surf = static_cast(buffer); - surf->AddRef(); - - return (SharedTextureHandle)surf; -} - -already_AddRefed -GLContextProviderCGL::GetSharedHandleAsSurface(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) -{ - MacIOSurface* surf = reinterpret_cast(sharedHandle); - surf->Lock(); - size_t bytesPerRow = surf->GetBytesPerRow(); - size_t ioWidth = surf->GetDevicePixelWidth(); - size_t ioHeight = surf->GetDevicePixelHeight(); - - unsigned char* ioData = (unsigned char*)surf->GetBaseAddress(); - - nsRefPtr imgSurface = - new gfxImageSurface(gfxIntSize(ioWidth, ioHeight), gfxImageFormatARGB32); - - for (size_t i = 0; i < ioHeight; i++) { - memcpy(imgSurface->Data() + i * imgSurface->Stride(), - ioData + i * bytesPerRow, ioWidth * 4); - } - - surf->Unlock(); - - return imgSurface.forget(); -} - void GLContextProviderCGL::Shutdown() { diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 05a1fbbdb370..1076e5c193c9 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -1329,21 +1329,6 @@ GLContextProviderEGL::CreateOffscreen(const gfxIntSize& size, return glContext.forget(); } -SharedTextureHandle -GLContextProviderEGL::CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType) -{ - return 0; -} - -already_AddRefed -GLContextProviderEGL::GetSharedHandleAsSurface(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) -{ - return nullptr; -} - // Don't want a global context on Android as 1) share groups across 2 threads fail on many Tegra drivers (bug 759225) // and 2) some mobile devices have a very strict limit on global number of GL contexts (bug 754257) // and 3) each EGL context eats 750k on B2G (bug 813783) diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 774481e5f921..141cd7807b30 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -1426,21 +1426,6 @@ GLContextProviderGLX::CreateOffscreen(const gfxIntSize& size, return glContext.forget(); } -SharedTextureHandle -GLContextProviderGLX::CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType) -{ - return 0; -} - -already_AddRefed -GLContextProviderGLX::GetSharedHandleAsSurface(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) -{ - return nullptr; -} - static nsRefPtr gGlobalContext[GLXLibrary::LIBS_MAX]; // TODO move that out of static initializaion static bool gUseContextSharing = getenv("MOZ_DISABLE_CONTEXT_SHARING_GLX") == 0; diff --git a/gfx/gl/GLContextProviderImpl.h b/gfx/gl/GLContextProviderImpl.h index 34591f2368ba..a5c53838f4ae 100644 --- a/gfx/gl/GLContextProviderImpl.h +++ b/gfx/gl/GLContextProviderImpl.h @@ -68,19 +68,6 @@ public: static GLContext* GetGlobalContext(ContextFlags flags = ContextFlagsNone); - /* - * Create a new shared GLContext content handle, using the passed buffer as a source. - * Must be released by ReleaseSharedHandle. UpdateSharedHandle will have no effect - * on handles created with this method, as the caller owns the source (the passed buffer) - * and is responsible for updating it accordingly. - */ - static SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType); - - static already_AddRefed GetSharedHandleAsSurface(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle); - /** * Free any resources held by this Context Provider. */ diff --git a/gfx/gl/GLContextProviderNull.cpp b/gfx/gl/GLContextProviderNull.cpp index d6500ce32e5d..1d8f8e31553b 100644 --- a/gfx/gl/GLContextProviderNull.cpp +++ b/gfx/gl/GLContextProviderNull.cpp @@ -22,21 +22,6 @@ GLContextProviderNull::CreateOffscreen(const gfxIntSize&, return nullptr; } -SharedTextureHandle -GLContextProviderNull::CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType) -{ - return 0; -} - -already_AddRefed -GLContextProviderNull::GetSharedHandleAsSurface(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) -{ - return nullptr; -} - GLContext* GLContextProviderNull::GetGlobalContext(ContextFlags) { diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index f293c28b2976..51ecb41f7968 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -688,21 +688,6 @@ GLContextProviderWGL::CreateOffscreen(const gfxIntSize& size, return glContext.forget(); } -SharedTextureHandle -GLContextProviderWGL::CreateSharedHandle(SharedTextureShareType shareType, - void* buffer, - SharedTextureBufferType bufferType) -{ - return 0; -} - -already_AddRefed -GLContextProviderWGL::GetSharedHandleAsSurface(SharedTextureShareType shareType, - SharedTextureHandle sharedHandle) -{ - return nullptr; -} - static nsRefPtr gGlobalContext[WGLLibrary::LIBS_MAX]; GLContext * diff --git a/gfx/layers/SharedTextureImage.h b/gfx/layers/SharedTextureImage.h index 9fce04c4c934..575c2f370683 100644 --- a/gfx/layers/SharedTextureImage.h +++ b/gfx/layers/SharedTextureImage.h @@ -36,8 +36,8 @@ public: gfxIntSize GetSize() { return mData.mSize; } - virtual already_AddRefed GetAsSurface() { - return gl::GLContextProvider::GetSharedHandleAsSurface(mData.mShareType, mData.mHandle); + virtual already_AddRefed GetAsSurface() { + return nullptr; } SharedTextureImage() : Image(nullptr, SHARED_TEXTURE) {} From a2f07bbb8aa8542999ebfa066261bc5d49992f97 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 11 Oct 2013 12:28:23 -0400 Subject: [PATCH 021/795] Bug 882541 part 1. Don't require all arguments after an optional argument to be optional. r=khuey --- dom/bindings/parser/WebIDL.py | 33 +++---------------- dom/bindings/parser/tests/test_dictionary.py | 17 ++++++++++ .../parser/tests/test_optional_constraints.py | 6 ++-- dom/bindings/parser/tests/test_overload.py | 12 ++++++- .../parser/tests/test_variadic_constraints.py | 29 +++++++++++----- 5 files changed, 55 insertions(+), 42 deletions(-) diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 18762c97724a..f4359b247fbb 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -3153,15 +3153,12 @@ class IDLMethod(IDLInterfaceMember, IDLScope): def finish(self, scope): for overload in self._overloads: - inOptionalArguments = False variadicArgument = None arguments = overload.arguments for (idx, argument) in enumerate(arguments): - if argument.isComplete(): - continue - - argument.complete(scope) + if not argument.isComplete(): + argument.complete(scope) assert argument.type.isComplete() if (argument.type.isDictionary() or @@ -3171,7 +3168,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope): # end of the list or followed by optional arguments must be # optional. if (not argument.optional and - (idx == len(arguments) - 1 or arguments[idx+1].optional)): + all(arg.optional for arg in arguments[idx+1:])): raise WebIDLError("Dictionary argument or union " "argument containing a dictionary " "not followed by a required argument " @@ -3189,13 +3186,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope): if variadicArgument: raise WebIDLError("Variadic argument is not last argument", [variadicArgument.location]) - # Once we see an optional argument, there can't be any non-optional - # arguments. - if inOptionalArguments and not argument.optional: - raise WebIDLError("Non-optional argument after optional " - "arguments", - [argument.location]) - inOptionalArguments = argument.optional if argument.variadic: variadicArgument = argument @@ -3240,7 +3230,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope): return [overload for overload in self._overloads if len(overload.arguments) == argc or (len(overload.arguments) > argc and - overload.arguments[argc].optional) or + all(arg.optional for arg in overload.arguments[argc:])) or (len(overload.arguments) < argc and len(overload.arguments) > 0 and overload.arguments[-1].variadic)] @@ -4070,21 +4060,6 @@ class Parser(Tokenizer): raise WebIDLError("stringifier must have DOMString return type", [self.getLocation(p, 2)]) - inOptionalArguments = False - variadicArgument = False - for argument in arguments: - # Only the last argument can be variadic - if variadicArgument: - raise WebIDLError("Only the last argument can be variadic", - [variadicArgument.location]) - # Once we see an optional argument, there can't be any non-optional - # arguments. - if inOptionalArguments and not argument.optional: - raise WebIDLError("Cannot have a non-optional argument following an optional argument", - [argument.location]) - inOptionalArguments = argument.optional - variadicArgument = argument if argument.variadic else None - # identifier might be None. This is only permitted for special methods. if not identifier: if not getter and not setter and not creator and \ diff --git a/dom/bindings/parser/tests/test_dictionary.py b/dom/bindings/parser/tests/test_dictionary.py index 4de41050981c..4f6902c43d42 100644 --- a/dom/bindings/parser/tests/test_dictionary.py +++ b/dom/bindings/parser/tests/test_dictionary.py @@ -171,6 +171,23 @@ def WebIDLTest(parser, harness): harness.ok(threw, "Dictionary arg followed by optional arg must be optional") + parser = parser.reset() + threw = False + try: + parser.parse(""" + dictionary A { + }; + interface X { + void doFoo(A arg1, optional long arg2, long arg3); + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(not threw, + "Dictionary arg followed by non-optional arg doesn't have to be optional") + parser = parser.reset() threw = False try: diff --git a/dom/bindings/parser/tests/test_optional_constraints.py b/dom/bindings/parser/tests/test_optional_constraints.py index 99fd07fe93f8..6217465ce7df 100644 --- a/dom/bindings/parser/tests/test_optional_constraints.py +++ b/dom/bindings/parser/tests/test_optional_constraints.py @@ -11,9 +11,9 @@ def WebIDLTest(parser, harness): except: threw = True - harness.ok(threw, - "Should have thrown on non-optional argument following optional " - "argument.") + harness.ok(not threw, + "Should not have thrown on non-optional argument following " + "optional argument.") parser = parser.reset() parser.parse(""" diff --git a/dom/bindings/parser/tests/test_overload.py b/dom/bindings/parser/tests/test_overload.py index e9a03958b6f5..3c680ad52333 100644 --- a/dom/bindings/parser/tests/test_overload.py +++ b/dom/bindings/parser/tests/test_overload.py @@ -11,6 +11,8 @@ def WebIDLTest(parser, harness): void withVariadics(long... numbers); void withVariadics(TestOverloads iface); void withVariadics(long num, TestOverloads iface); + void optionalTest(); + void optionalTest(optional long num1, long num2); }; """) @@ -23,7 +25,7 @@ def WebIDLTest(parser, harness): "Should be an IDLInterface") harness.check(iface.identifier.QName(), "::TestOverloads", "Interface has the right QName") harness.check(iface.identifier.name, "TestOverloads", "Interface has the right name") - harness.check(len(iface.members), 3, "Expect %s members" % 3) + harness.check(len(iface.members), 4, "Expect %s members" % 4) member = iface.members[0] harness.check(member.identifier.QName(), "::TestOverloads::basic", "Method has the right QName") @@ -48,3 +50,11 @@ def WebIDLTest(parser, harness): harness.check(argument.identifier.QName(), "::TestOverloads::basic::arg1", "Argument has the right QName") harness.check(argument.identifier.name, "arg1", "Argument has the right name") harness.check(str(argument.type), "Long", "Argument has the right type") + + member = iface.members[3] + harness.check(len(member.overloadsForArgCount(0)), 1, + "Only one overload for no args") + harness.check(len(member.overloadsForArgCount(1)), 0, + "No overloads for one arg") + harness.check(len(member.overloadsForArgCount(2)), 1, + "Only one overload for two args") diff --git a/dom/bindings/parser/tests/test_variadic_constraints.py b/dom/bindings/parser/tests/test_variadic_constraints.py index e9d060892e63..7448e40d5a97 100644 --- a/dom/bindings/parser/tests/test_variadic_constraints.py +++ b/dom/bindings/parser/tests/test_variadic_constraints.py @@ -1,51 +1,62 @@ def WebIDLTest(parser, harness): threw = False try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints1 { void foo(byte... arg1, byte arg2); }; """) + results = parser.finish() except: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, + "Should have thrown on variadic argument followed by required " + "argument.") + parser = parser.reset() threw = False try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints2 { void foo(byte... arg1, optional byte arg2); }; """) - + results = parser.finish(); except: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, + "Should have thrown on variadic argument followed by optional " + "argument.") + parser = parser.reset() threw = False try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints3 { void foo(optional byte... arg1); }; """) + results = parser.finish() except: threw = True - harness.ok(threw, "Should have thrown.") + harness.ok(threw, + "Should have thrown on variadic argument explicitly flagged as " + "optional.") + parser = parser.reset() threw = False try: - results = parser.parse(""" + parser.parse(""" interface VariadicConstraints4 { void foo(byte... arg1 = 0); }; """) - + results = parser.finish() except: threw = True From 9253bde16b6bdf9b5dc6e0c3d2edfc1cd2d97ee1 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 11 Oct 2013 12:28:23 -0400 Subject: [PATCH 022/795] Bug 882541 part 2. Fix a bug that crept in with overloading a string and a nullable number and then passing in null, due to the number conversion being conditional on the input type in that case. r=khuey Also removes a footgun conversion operator on Nullable that was causing it to silently convert to int32_t. --- dom/bindings/Codegen.py | 51 ++++++++++++++++++------- dom/bindings/Nullable.h | 5 --- dom/bindings/test/TestBindingHeader.h | 10 +++++ dom/bindings/test/TestCodeGen.webidl | 10 +++++ dom/bindings/test/TestExampleGen.webidl | 10 +++++ dom/bindings/test/TestJSImplGen.webidl | 10 +++++ dom/quota/QuotaManager.cpp | 6 +-- 7 files changed, 80 insertions(+), 22 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 4ddfc9375433..0d469092c8d8 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -5140,24 +5140,47 @@ class CGMethodCall(CGThing): getPerSignatureCall(signature, distinguishingIndex + 1), indent)) + def hasConditionalConversion(type): + """ + Return whether the argument conversion for this type will be + conditional on the type of incoming JS value. For example, for + interface types the conversion is conditional on the incoming + value being isObject(). + + For the types for which this returns false, we do not have to + output extra isUndefined() or isNullOrUndefined() cases, because + null/undefined values will just fall through into our + unconditional conversion. + """ + if type.isString() or type.isEnum(): + return False + if type.isBoolean(): + distinguishingTypes = (distinguishingType(s) for s in + possibleSignatures) + return any(t.isString() or t.isEnum() or t.isNumeric() + for t in distinguishingTypes) + if type.isNumeric(): + distinguishingTypes = (distinguishingType(s) for s in + possibleSignatures) + return any(t.isString() or t.isEnum() + for t in distinguishingTypes) + return True + # First check for null or undefined. That means looking for # nullable arguments at the distinguishing index and outputting a - # separate branch for them. But if the nullable argument is a - # primitive, string, or enum, we don't need to do that. The reason + # separate branch for them. But if the nullable argument has an + # unconditional conversion, we don't need to do that. The reason # for that is that at most one argument at the distinguishing index # is nullable (since two nullable arguments are not - # distinguishable), and all the argument types other than - # primitive/string/enum end up inside isObject() checks. So if our - # nullable is a primitive/string/enum it's safe to not output the - # extra branch: we'll fall through to conversion for those types, - # which correctly handles null as needed, because isObject() will be - # false for null and undefined. - nullOrUndefSigs = [s for s in possibleSignatures - if ((distinguishingType(s).nullable() and not - distinguishingType(s).isString() and not - distinguishingType(s).isEnum() and not - distinguishingType(s).isPrimitive()) or - distinguishingType(s).isDictionary())] + # distinguishable), and null/undefined values will always fall + # through to the unconditional conversion we have, if any, since + # they will fail whatever the conditions on the input value are for + # our other conversions. + nullOrUndefSigs = [ + s for s in possibleSignatures + if ((distinguishingType(s).nullable() and + hasConditionalConversion(distinguishingType(s))) or + distinguishingType(s).isDictionary())] # Can't have multiple nullable types here assert len(nullOrUndefSigs) < 2 if len(nullOrUndefSigs) > 0: diff --git a/dom/bindings/Nullable.h b/dom/bindings/Nullable.h index a39f41c7d93b..80f2d3f3672c 100644 --- a/dom/bindings/Nullable.h +++ b/dom/bindings/Nullable.h @@ -81,11 +81,6 @@ public: return !Equals(aOtherNullable); } - operator bool() const - { - return !mIsNull; - } - // Make it possible to use a const Nullable of an array type with other // array types. template diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index 4b09a2f2c47a..2d2a0602955c 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -634,6 +634,16 @@ public: void Overload7(const nsCString&); void Overload8(int32_t); void Overload8(TestInterface&); + void Overload9(const Nullable&); + void Overload9(const nsAString&); + void Overload10(const Nullable&); + void Overload10(JSContext*, JS::Handle); + void Overload11(int32_t); + void Overload11(const nsAString&); + void Overload12(int32_t); + void Overload12(const Nullable&); + void Overload13(const Nullable&); + void Overload13(bool); // Variadic handling void PassVariadicThirdArg(const nsAString&, int32_t, diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index 8af0542e0706..64e8899edbbe 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -584,6 +584,16 @@ interface TestInterface { void overload7(ByteString arg); void overload8(long arg); void overload8(TestInterface arg); + void overload9(long? arg); + void overload9(DOMString arg); + void overload10(long? arg); + void overload10(object arg); + void overload11(long arg); + void overload11(DOMString? arg); + void overload12(long arg); + void overload12(boolean? arg); + void overload13(long? arg); + void overload13(boolean arg); // Variadic handling void passVariadicThirdArg(DOMString arg1, long arg2, TestInterface... arg3); diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl index 5cfcfdc4ed0a..e0430ef34a67 100644 --- a/dom/bindings/test/TestExampleGen.webidl +++ b/dom/bindings/test/TestExampleGen.webidl @@ -481,6 +481,16 @@ interface TestExampleInterface { void overload7(ByteString arg); void overload8(long arg); void overload8(TestInterface arg); + void overload9(long? arg); + void overload9(DOMString arg); + void overload10(long? arg); + void overload10(object arg); + void overload11(long arg); + void overload11(DOMString? arg); + void overload12(long arg); + void overload12(boolean? arg); + void overload13(long? arg); + void overload13(boolean arg); // Variadic handling void passVariadicThirdArg(DOMString arg1, long arg2, TestInterface... arg3); diff --git a/dom/bindings/test/TestJSImplGen.webidl b/dom/bindings/test/TestJSImplGen.webidl index dac3527304de..73b62a97ab30 100644 --- a/dom/bindings/test/TestJSImplGen.webidl +++ b/dom/bindings/test/TestJSImplGen.webidl @@ -509,6 +509,16 @@ interface TestJSImplInterface { void overload7(ByteString arg); void overload8(long arg); void overload8(TestJSImplInterface arg); + void overload9(long? arg); + void overload9(DOMString arg); + void overload10(long? arg); + void overload10(object arg); + void overload11(long arg); + void overload11(DOMString? arg); + void overload12(long arg); + void overload12(boolean? arg); + void overload13(long? arg); + void overload13(boolean arg); // Variadic handling void passVariadicThirdArg(DOMString arg1, long arg2, TestJSImplInterface... arg3); diff --git a/dom/quota/QuotaManager.cpp b/dom/quota/QuotaManager.cpp index aa3e2d802165..b13d8f03bb6c 100644 --- a/dom/quota/QuotaManager.cpp +++ b/dom/quota/QuotaManager.cpp @@ -2802,7 +2802,7 @@ QuotaManager::FindSynchronizedOp(const nsACString& aPattern, for (uint32_t index = 0; index < mSynchronizedOps.Length(); index++) { const nsAutoPtr& currentOp = mSynchronizedOps[index]; if (PatternMatchesOrigin(aPattern, currentOp->mOriginOrPattern) && - (!currentOp->mPersistenceType || + (currentOp->mPersistenceType.IsNull() || currentOp->mPersistenceType == aPersistenceType) && (!currentOp->mId || currentOp->mId == aId)) { return currentOp; @@ -3067,7 +3067,7 @@ QuotaManager::CollectOriginsForEviction(uint64_t aMinSizeToBeFreed, uint32_t index; for (index = 0; index < mSynchronizedOps.Length(); index++) { nsAutoPtr& op = mSynchronizedOps[index]; - if (!op->mPersistenceType || + if (op->mPersistenceType.IsNull() || op->mPersistenceType.Value() == PERSISTENCE_TYPE_TEMPORARY) { if (op->mOriginOrPattern.IsPattern() && !originCollection.ContainsPattern(op->mOriginOrPattern)) { @@ -3078,7 +3078,7 @@ QuotaManager::CollectOriginsForEviction(uint64_t aMinSizeToBeFreed, for (index = 0; index < mSynchronizedOps.Length(); index++) { nsAutoPtr& op = mSynchronizedOps[index]; - if (!op->mPersistenceType || + if (op->mPersistenceType.IsNull() || op->mPersistenceType.Value() == PERSISTENCE_TYPE_TEMPORARY) { if (op->mOriginOrPattern.IsOrigin() && !originCollection.ContainsOrigin(op->mOriginOrPattern)) { From 98d74fb3cb8962fa003cd4a173b5c8beaa1976d8 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 11 Oct 2013 12:28:24 -0400 Subject: [PATCH 023/795] Bug 882541 part 3. Rework the overload resolution algorithm to WebIDL spec changes in handling of optional arguments. r=khuey The major changes are as follows: 1) The new algorithm no longer adjusts "argcount" based on the interaction of trailing undefined and [TreatUndefinedAs=Missing] arguments. We never implemented this; just asserted that we didn't have to deal with this situation. 2) If the distinguishing argument is undefined and there is an overload that has an optional argument at the distinguishing argument index, that overload is selected. --- dom/bindings/Codegen.py | 71 +++++++++++++++++-------- dom/bindings/test/TestBindingHeader.h | 6 +++ dom/bindings/test/TestCodeGen.webidl | 6 +++ dom/bindings/test/TestExampleGen.webidl | 6 +++ dom/bindings/test/TestJSImplGen.webidl | 6 +++ 5 files changed, 73 insertions(+), 22 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 0d469092c8d8..26a1bfee17fb 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2708,8 +2708,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, # A helper function for wrapping up the template body for # possibly-nullable objecty stuff def wrapObjectTemplate(templateBody, type, codeToSetNull, failureCode=None): - if isNullOrUndefined: - assert type.nullable() + if isNullOrUndefined and type.nullable(): # Just ignore templateBody and set ourselves to null. # Note that we don't have to worry about default values # here either, since we already examined this value. @@ -5017,15 +5016,6 @@ class CGMethodCall(CGThing): CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n")) return - # We don't handle [TreatUndefinedAs=Missing] arguments in overload - # resolution yet. - for (_, sigArgs) in signatures: - for arg in sigArgs: - if arg.treatUndefinedAs == "Missing": - raise TypeError("No support for [TreatUndefinedAs=Missing] " - "handling in overload resolution yet: %s" % - arg.location) - # Need to find the right overload maxArgCount = method.maxArgCount allowedArgCounts = method.allowedArgCounts @@ -5115,22 +5105,30 @@ class CGMethodCall(CGThing): else: failureCode = None type = distinguishingType(signature) - # The argument at index distinguishingIndex can't possibly - # be unset here, because we've already checked that argc is - # large enough that we can examine this argument. + # The argument at index distinguishingIndex can't possibly be + # unset here, because we've already checked that argc is large + # enough that we can examine this argument. But note that we + # still want to claim that optional arguments are optional, in + # case undefined was passed in. + argIsOptional = (distinguishingArgument(signature).optional and + not distinguishingArgument(signature).defaultValue) testCode = instantiateJSToNativeConversion( getJSToNativeConversionInfo(type, descriptor, failureCode=failureCode, isDefinitelyObject=isDefinitelyObject, isNullOrUndefined=isNullOrUndefined, + isOptional=argIsOptional, sourceDescription=(argDesc % (distinguishingIndex + 1))), { "declName" : "arg%d" % distinguishingIndex, "holderName" : ("arg%d" % distinguishingIndex) + "_holder", "val" : distinguishingArg, "mutableVal" : distinguishingArg, - "obj" : "obj" - }) + "obj" : "obj", + "haveValue": "args.hasDefined(%d)" % distinguishingIndex + }, + checkForValue=argIsOptional + ) caseBody.append(CGIndenter(testCode, indent)); # If we got this far, we know we unwrapped to the right # C++ type, so just do the call. Start conversion with @@ -5166,7 +5164,39 @@ class CGMethodCall(CGThing): for t in distinguishingTypes) return True - # First check for null or undefined. That means looking for + def needsNullOrUndefinedCase(type): + """ + Return true if the type needs a special isNullOrUndefined() case + """ + return ((type.nullable() and + hasConditionalConversion(type)) or + type.isDictionary()) + + # First check for undefined and optional distinguishing arguments + # and output a special branch for that case. Note that we don't + # use distinguishingArgument here because we actualy want to + # exclude variadic arguments. Also note that we skip this check if + # we plan to output a isNullOrUndefined() special case for this + # argument anyway, since that will subsume our isUndefined() check. + # This is safe, because there can be at most one nullable + # distinguishing argument, so if we're it we'll definitely get + # picked up by the nullable handling. Also, we can skip this check + # if the argument has an unconditional conversion later on. + undefSigs = [s for s in possibleSignatures if + distinguishingIndex < len(s[1]) and + s[1][distinguishingIndex].optional and + hasConditionalConversion(s[1][distinguishingIndex].type) and + not needsNullOrUndefinedCase(s[1][distinguishingIndex].type)] + # Can't have multiple signatures with an optional argument at the + # same index. + assert len(undefSigs) < 2 + if len(undefSigs) > 0: + caseBody.append(CGGeneric("if (%s.isUndefined()) {" % + distinguishingArg)) + tryCall(undefSigs[0], 2, isNullOrUndefined=True) + caseBody.append(CGGeneric("}")) + + # Next, check for null or undefined. That means looking for # nullable arguments at the distinguishing index and outputting a # separate branch for them. But if the nullable argument has an # unconditional conversion, we don't need to do that. The reason @@ -5176,11 +5206,8 @@ class CGMethodCall(CGThing): # through to the unconditional conversion we have, if any, since # they will fail whatever the conditions on the input value are for # our other conversions. - nullOrUndefSigs = [ - s for s in possibleSignatures - if ((distinguishingType(s).nullable() and - hasConditionalConversion(distinguishingType(s))) or - distinguishingType(s).isDictionary())] + nullOrUndefSigs = [s for s in possibleSignatures + if needsNullOrUndefinedCase(distinguishingType(s))] # Can't have multiple nullable types here assert len(nullOrUndefSigs) < 2 if len(nullOrUndefSigs) > 0: diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index 2d2a0602955c..0f7bb01760ce 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -644,6 +644,12 @@ public: void Overload12(const Nullable&); void Overload13(const Nullable&); void Overload13(bool); + void Overload14(const Optional&); + void Overload14(TestInterface&); + void Overload15(int32_t); + void Overload15(const Optional >&); + void Overload16(int32_t); + void Overload16(const Optional&); // Variadic handling void PassVariadicThirdArg(const nsAString&, int32_t, diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index 64e8899edbbe..6921744765b6 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -594,6 +594,12 @@ interface TestInterface { void overload12(boolean? arg); void overload13(long? arg); void overload13(boolean arg); + void overload14(optional long arg); + void overload14(TestInterface arg); + void overload15(long arg); + void overload15(optional TestInterface arg); + void overload16(long arg); + void overload16(optional TestInterface? arg); // Variadic handling void passVariadicThirdArg(DOMString arg1, long arg2, TestInterface... arg3); diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl index e0430ef34a67..09f6cfdf9f6f 100644 --- a/dom/bindings/test/TestExampleGen.webidl +++ b/dom/bindings/test/TestExampleGen.webidl @@ -491,6 +491,12 @@ interface TestExampleInterface { void overload12(boolean? arg); void overload13(long? arg); void overload13(boolean arg); + void overload14(optional long arg); + void overload14(TestInterface arg); + void overload15(long arg); + void overload15(optional TestInterface arg); + void overload16(long arg); + void overload16(optional TestInterface? arg); // Variadic handling void passVariadicThirdArg(DOMString arg1, long arg2, TestInterface... arg3); diff --git a/dom/bindings/test/TestJSImplGen.webidl b/dom/bindings/test/TestJSImplGen.webidl index 73b62a97ab30..17c0f5ea7fa0 100644 --- a/dom/bindings/test/TestJSImplGen.webidl +++ b/dom/bindings/test/TestJSImplGen.webidl @@ -519,6 +519,12 @@ interface TestJSImplInterface { void overload12(boolean? arg); void overload13(long? arg); void overload13(boolean arg); + void overload14(optional long arg); + void overload14(TestInterface arg); + void overload15(long arg); + void overload15(optional TestInterface arg); + void overload16(long arg); + void overload16(optional TestInterface? arg); // Variadic handling void passVariadicThirdArg(DOMString arg1, long arg2, TestJSImplInterface... arg3); From 20b04d6057927b9f8cdd854c73c78bcf61d0f077 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 11 Oct 2013 12:28:24 -0400 Subject: [PATCH 024/795] Bug 882541 part 4. Treat undefined as missing for optional WebIDL arguments. r=khuey,ms2ger --- content/base/public/Element.h | 4 ++ content/base/public/nsIDocument.h | 5 +++ content/base/public/nsINode.h | 4 ++ content/base/src/nsXMLHttpRequest.h | 7 ++++ .../base/test/test_createHTMLDocument.html | 16 ++++--- dom/bindings/Codegen.py | 10 +---- dom/bindings/parser/WebIDL.py | 11 ++--- dom/bindings/test/TestBindingHeader.h | 6 +-- dom/bindings/test/TestCodeGen.webidl | 6 +-- dom/bindings/test/TestExampleGen.webidl | 6 +-- dom/bindings/test/TestJSImplGen.webidl | 6 +-- dom/bindings/test/mochitest.ini | 1 + .../test/test_cloneAndImportNode.html | 42 +++++++++++++++++++ ..._DOMImplementation-createHTMLDocument.html | 14 ++++--- .../documents/dta/test_document.title-07.html | 2 +- dom/webidl/CanvasRenderingContext2D.webidl | 6 +-- dom/webidl/Document.webidl | 4 +- dom/webidl/Element.webidl | 3 +- dom/webidl/Node.webidl | 4 +- dom/webidl/Promise.webidl | 6 +-- dom/webidl/XMLHttpRequest.webidl | 4 +- dom/workers/XMLHttpRequest.h | 5 +++ .../tests/unit/test_allowedDomainsXHR.js | 2 +- 23 files changed, 119 insertions(+), 55 deletions(-) create mode 100644 dom/bindings/test/test_cloneAndImportNode.html diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 5f323e245c29..2ebdcf6be54f 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -646,6 +646,10 @@ public: already_AddRefed GetClientRects(); already_AddRefed GetBoundingClientRect(); + void ScrollIntoView() + { + ScrollIntoView(true); + } void ScrollIntoView(bool aTop); int32_t ScrollTop() { diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 798e117889fe..50c33fcb0178 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -2001,6 +2001,11 @@ public: mozilla::ErrorResult& rv) const; already_AddRefed ImportNode(nsINode& aNode, bool aDeep, mozilla::ErrorResult& rv) const; + already_AddRefed + ImportNode(nsINode& aNode, mozilla::ErrorResult& rv) const + { + return ImportNode(aNode, true, rv); + } nsINode* AdoptNode(nsINode& aNode, mozilla::ErrorResult& rv); already_AddRefed CreateEvent(const nsAString& aEventType, mozilla::ErrorResult& rv) const; diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 2fbc246fd01d..a6da12d4613f 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -1533,6 +1533,10 @@ public: return ReplaceOrInsertBefore(true, &aNode, &aChild, aError); } nsINode* RemoveChild(nsINode& aChild, mozilla::ErrorResult& aError); + already_AddRefed CloneNode(mozilla::ErrorResult& aError) + { + return CloneNode(true, aError); + } already_AddRefed CloneNode(bool aDeep, mozilla::ErrorResult& aError); bool IsEqualNode(nsINode* aNode); void GetNamespaceURI(nsAString& aNamespaceURI) const diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h index ef2eb8e50fa6..e66da6040af3 100644 --- a/content/base/src/nsXMLHttpRequest.h +++ b/content/base/src/nsXMLHttpRequest.h @@ -282,6 +282,13 @@ public: uint16_t ReadyState(); // request + void Open(const nsACString& aMethod, const nsAString& aUrl, ErrorResult& aRv) + { + Open(aMethod, aUrl, true, + mozilla::dom::Optional(), + mozilla::dom::Optional(), + aRv); + } void Open(const nsACString& aMethod, const nsAString& aUrl, bool aAsync, const mozilla::dom::Optional& aUser, const mozilla::dom::Optional& aPassword, diff --git a/content/base/test/test_createHTMLDocument.html b/content/base/test/test_createHTMLDocument.html index 40f585b2b060..14749a2df849 100644 --- a/content/base/test/test_createHTMLDocument.html +++ b/content/base/test/test_createHTMLDocument.html @@ -27,11 +27,15 @@ function checkDoc(title, expectedtitle, normalizedtitle) { is(doc.doctype.internalSubset, null, "internalSubset should be null!"); isElement(doc.documentElement, "html"); isElement(doc.documentElement.firstChild, "head"); - is(doc.documentElement.firstChild.childNodes.length, 1); - isElement(doc.documentElement.firstChild.firstChild, "title"); - // Doesn't always work out in WebKit. - ok(doc.documentElement.firstChild.firstChild.firstChild, "Need a text node."); - is(doc.documentElement.firstChild.firstChild.firstChild.data, expectedtitle); + if (title !== undefined) { + is(doc.documentElement.firstChild.childNodes.length, 1); + isElement(doc.documentElement.firstChild.firstChild, "title"); + // Doesn't always work out in WebKit. + ok(doc.documentElement.firstChild.firstChild.firstChild, "Need a text node."); + is(doc.documentElement.firstChild.firstChild.firstChild.data, expectedtitle); + } else { + is(doc.documentElement.firstChild.childNodes.length, 0); + } isElement(doc.documentElement.lastChild, "body"); is(doc.documentElement.lastChild.childNodes.length, 0); ((!title || title.indexOf("\f") === -1) ? is : todo_is) @@ -41,7 +45,7 @@ function checkDoc(title, expectedtitle, normalizedtitle) { } checkDoc("", "", ""); checkDoc(null, "null", "null"); -checkDoc(undefined, "undefined", "undefined"); +checkDoc(undefined, "", ""); checkDoc("foo bar baz", "foo bar baz", "foo bar baz"); checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz"); checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz"); diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 26a1bfee17fb..ee8beec371f9 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -3348,9 +3348,6 @@ for (uint32_t i = 0; i < length; ++i) { "Default": "eStringify", "EmptyString": "eEmpty", "Null": "eNull", - # For Missing it doesn't matter what we use here, since we'll never - # call ConvertJSValueToString on undefined in that case. - "Missing": "eStringify" } if type.nullable(): # For nullable strings null becomes a null string. @@ -3870,11 +3867,8 @@ class CGArgumentConverter(CGThing): "args[${index}]" ).substitute(replacer) self.replacementVariables["mutableVal"] = self.replacementVariables["val"] - if argument.treatUndefinedAs == "Missing": - haveValueCheck = "args.hasDefined(${index})" - else: - haveValueCheck = "${index} < args.length()" - haveValueCheck = string.Template(haveValueCheck).substitute(replacer) + haveValueCheck = string.Template( + "args.hasDefined(${index})").substitute(replacer) self.replacementVariables["haveValue"] = haveValueCheck self.descriptorProvider = descriptorProvider if self.argument.optional and not self.argument.defaultValue: diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index f4359b247fbb..51921078fccb 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -401,12 +401,7 @@ class IDLObjectWithIdentifier(IDLObject): if isDictionaryMember: raise WebIDLError("[TreatUndefinedAs] is not allowed for " "dictionary members", [self.location]) - if value == 'Missing': - if not isOptional: - raise WebIDLError("[TreatUndefinedAs=Missing] is only " - "allowed on optional arguments", - [self.location]) - elif value == 'Null': + if value == 'Null': if not self.type.isDOMString(): raise WebIDLError("[TreatUndefinedAs=Null] is only " "allowed on arguments or " @@ -426,8 +421,8 @@ class IDLObjectWithIdentifier(IDLObject): [self.location]) else: raise WebIDLError("[TreatUndefinedAs] must take the " - "identifiers EmptyString or Null or " - "Missing", [self.location]) + "identifiers EmptyString or Null", + [self.location]) self.treatUndefinedAs = value else: unhandledAttrs.append(attr) diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index 0f7bb01760ce..8c8ce0a0c269 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -161,9 +161,9 @@ public: void PassByte(int8_t); int8_t ReceiveByte(); void PassOptionalByte(const Optional&); - void PassOptionalUndefinedMissingByte(const Optional&); + void PassOptionalByteBeforeRequired(const Optional&, int8_t); void PassOptionalByteWithDefault(int8_t); - void PassOptionalUndefinedMissingByteWithDefault(int8_t); + void PassOptionalByteWithDefaultBeforeRequired(int8_t, int8_t); void PassNullableByte(const Nullable&); void PassOptionalNullableByte(const Optional< Nullable >&); void PassVariadicByte(const Sequence&); @@ -410,9 +410,7 @@ public: void PassString(const nsAString&); void PassNullableString(const nsAString&); void PassOptionalString(const Optional&); - void PassOptionalUndefinedMissingString(const Optional&); void PassOptionalStringWithDefaultValue(const nsAString&); - void PassOptionalUndefinedMissingStringWithDefaultValue(const nsAString&); void PassOptionalNullableString(const Optional&); void PassOptionalNullableStringWithDefaultValue(const nsAString&); void PassVariadicString(const Sequence&); diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index 6921744765b6..b5e945c0f81d 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -118,9 +118,9 @@ interface TestInterface { void passByte(byte arg); byte receiveByte(); void passOptionalByte(optional byte arg); - void passOptionalUndefinedMissingByte([TreatUndefinedAs=Missing] optional byte arg); + void passOptionalByteBeforeRequired(optional byte arg1, byte arg2); void passOptionalByteWithDefault(optional byte arg = 0); - void passOptionalUndefinedMissingByteWithDefault([TreatUndefinedAs=Missing] optional byte arg = 0); + void passOptionalByteWithDefaultBeforeRequired(optional byte arg1 = 0, byte arg2); void passNullableByte(byte? arg); void passOptionalNullableByte(optional byte? arg); void passVariadicByte(byte... arg); @@ -365,9 +365,7 @@ interface TestInterface { void passString(DOMString arg); void passNullableString(DOMString? arg); void passOptionalString(optional DOMString arg); - void passOptionalUndefinedMissingString([TreatUndefinedAs=Missing] optional DOMString arg); void passOptionalStringWithDefaultValue(optional DOMString arg = "abc"); - void passOptionalUndefinedMissingStringWithDefaultValue([TreatUndefinedAs=Missing] optional DOMString arg = "abc"); void passOptionalNullableString(optional DOMString? arg); void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null); void passVariadicString(DOMString... arg); diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl index 09f6cfdf9f6f..109068eab104 100644 --- a/dom/bindings/test/TestExampleGen.webidl +++ b/dom/bindings/test/TestExampleGen.webidl @@ -23,9 +23,9 @@ interface TestExampleInterface { void passByte(byte arg); byte receiveByte(); void passOptionalByte(optional byte arg); - void passOptionalUndefinedMissingByte([TreatUndefinedAs=Missing] optional byte arg); + void passOptionalByteBeforeRequired(optional byte arg1, byte arg2); void passOptionalByteWithDefault(optional byte arg = 0); - void passOptionalUndefinedMissingByteWithDefault([TreatUndefinedAs=Missing] optional byte arg = 0); + void passOptionalByteWithDefaultBeforeRequired(optional byte arg1 = 0, byte arg2); void passNullableByte(byte? arg); void passOptionalNullableByte(optional byte? arg); void passVariadicByte(byte... arg); @@ -263,9 +263,7 @@ interface TestExampleInterface { void passString(DOMString arg); void passNullableString(DOMString? arg); void passOptionalString(optional DOMString arg); - void passOptionalUndefinedMissingString([TreatUndefinedAs=Missing] optional DOMString arg); void passOptionalStringWithDefaultValue(optional DOMString arg = "abc"); - void passOptionalUndefinedMissingStringWithDefaultValue([TreatUndefinedAs=Missing] optional DOMString arg = "abc"); void passOptionalNullableString(optional DOMString? arg); void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null); void passVariadicString(DOMString... arg); diff --git a/dom/bindings/test/TestJSImplGen.webidl b/dom/bindings/test/TestJSImplGen.webidl index 17c0f5ea7fa0..a4a48e131f06 100644 --- a/dom/bindings/test/TestJSImplGen.webidl +++ b/dom/bindings/test/TestJSImplGen.webidl @@ -35,9 +35,9 @@ interface TestJSImplInterface { void passByte(byte arg); byte receiveByte(); void passOptionalByte(optional byte arg); - void passOptionalUndefinedMissingByte([TreatUndefinedAs=Missing] optional byte arg); + void passOptionalByteBeforeRequired(optional byte arg1, byte arg2); void passOptionalByteWithDefault(optional byte arg = 0); - void passOptionalUndefinedMissingByteWithDefault([TreatUndefinedAs=Missing] optional byte arg = 0); + void passOptionalByteWithDefaultBeforeRequired(optional byte arg1 = 0, byte arg2); void passNullableByte(byte? arg); void passOptionalNullableByte(optional byte? arg); void passVariadicByte(byte... arg); @@ -285,9 +285,7 @@ interface TestJSImplInterface { void passString(DOMString arg); void passNullableString(DOMString? arg); void passOptionalString(optional DOMString arg); - void passOptionalUndefinedMissingString([TreatUndefinedAs=Missing] optional DOMString arg); void passOptionalStringWithDefaultValue(optional DOMString arg = "abc"); - void passOptionalUndefinedMissingStringWithDefaultValue([TreatUndefinedAs=Missing] optional DOMString arg = "abc"); void passOptionalNullableString(optional DOMString? arg); void passOptionalNullableStringWithDefaultValue(optional DOMString? arg = null); void passVariadicString(DOMString... arg); diff --git a/dom/bindings/test/mochitest.ini b/dom/bindings/test/mochitest.ini index a93f7a1fea10..3b019305bd7d 100644 --- a/dom/bindings/test/mochitest.ini +++ b/dom/bindings/test/mochitest.ini @@ -16,6 +16,7 @@ support-files = [test_bug788369.html] [test_bug852846.html] [test_bug862092.html] +[test_cloneAndImportNode.html] [test_defineProperty.html] [test_enums.html] [test_exceptionThrowing.html] diff --git a/dom/bindings/test/test_cloneAndImportNode.html b/dom/bindings/test/test_cloneAndImportNode.html new file mode 100644 index 000000000000..d173131a7ced --- /dev/null +++ b/dom/bindings/test/test_cloneAndImportNode.html @@ -0,0 +1,42 @@ + + + + + + Test for Bug 882541 + + + + + +Mozilla Bug 882541 +

+ +
+
+ + diff --git a/dom/imptests/html/dom/nodes/test_DOMImplementation-createHTMLDocument.html b/dom/imptests/html/dom/nodes/test_DOMImplementation-createHTMLDocument.html index d80482817974..12d1bb76e85f 100644 --- a/dom/imptests/html/dom/nodes/test_DOMImplementation-createHTMLDocument.html +++ b/dom/imptests/html/dom/nodes/test_DOMImplementation-createHTMLDocument.html @@ -18,17 +18,21 @@ function checkDoc(title, expectedtitle, normalizedtitle) { assert_equals(doc.doctype.systemId, "") assert_equals(doc.documentElement.localName, "html") assert_equals(doc.documentElement.firstChild.localName, "head") - assert_equals(doc.documentElement.firstChild.childNodes.length, 1) - assert_equals(doc.documentElement.firstChild.firstChild.localName, "title") - assert_equals(doc.documentElement.firstChild.firstChild.firstChild.data, - expectedtitle) + if (title !== undefined) { + assert_equals(doc.documentElement.firstChild.childNodes.length, 1) + assert_equals(doc.documentElement.firstChild.firstChild.localName, "title") + assert_equals(doc.documentElement.firstChild.firstChild.firstChild.data, + expectedtitle) + } else { + assert_equals(doc.documentElement.firstChild.childNodes.length, 0) + } assert_equals(doc.documentElement.lastChild.localName, "body") assert_equals(doc.documentElement.lastChild.childNodes.length, 0) }) } checkDoc("", "", "") checkDoc(null, "null", "null") -checkDoc(undefined, "undefined", "undefined") +checkDoc(undefined, "", "") checkDoc("foo bar baz", "foo bar baz", "foo bar baz") checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz") checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz") diff --git a/dom/imptests/html/html/dom/documents/dta/test_document.title-07.html b/dom/imptests/html/html/dom/documents/dta/test_document.title-07.html index ad6e7111d27a..eea97c9ede1b 100644 --- a/dom/imptests/html/html/dom/documents/dta/test_document.title-07.html +++ b/dom/imptests/html/html/dom/documents/dta/test_document.title-07.html @@ -12,7 +12,7 @@ function checkDoc(title, expectedtitle, normalizedtitle) { } checkDoc("", "", "") checkDoc(null, "null", "null") -checkDoc(undefined, "undefined", "undefined") +checkDoc(undefined, "", "") checkDoc("foo bar baz", "foo bar baz", "foo bar baz") checkDoc("foo\t\tbar baz", "foo\t\tbar baz", "foo bar baz") checkDoc("foo\n\nbar baz", "foo\n\nbar baz", "foo bar baz") diff --git a/dom/webidl/CanvasRenderingContext2D.webidl b/dom/webidl/CanvasRenderingContext2D.webidl index cf1914b06d29..de8f5155115e 100644 --- a/dom/webidl/CanvasRenderingContext2D.webidl +++ b/dom/webidl/CanvasRenderingContext2D.webidl @@ -73,7 +73,7 @@ interface CanvasRenderingContext2D { // path API (see also CanvasPathMethods) void beginPath(); - void fill([TreatUndefinedAs=Missing] optional CanvasWindingRule winding = "nonzero"); + void fill(optional CanvasWindingRule winding = "nonzero"); // NOT IMPLEMENTED void fill(Path path); void stroke(); // NOT IMPLEMENTED void stroke(Path path); @@ -83,10 +83,10 @@ interface CanvasRenderingContext2D { // NOT IMPLEMENTED boolean drawCustomFocusRing(Path path, Element element); // NOT IMPLEMENTED void scrollPathIntoView(); // NOT IMPLEMENTED void scrollPathIntoView(Path path); - void clip([TreatUndefinedAs=Missing] optional CanvasWindingRule winding = "nonzero"); + void clip(optional CanvasWindingRule winding = "nonzero"); // NOT IMPLEMENTED void clip(Path path); // NOT IMPLEMENTED void resetClip(); - boolean isPointInPath(unrestricted double x, unrestricted double y, [TreatUndefinedAs=Missing] optional CanvasWindingRule winding = "nonzero"); + boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasWindingRule winding = "nonzero"); // NOT IMPLEMENTED boolean isPointInPath(Path path, unrestricted double x, unrestricted double y); boolean isPointInStroke(double x, double y); diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 6f24026b98dd..1520239d0e33 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -54,7 +54,9 @@ interface Document : Node { ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); [Throws] - Node importNode(Node node, optional boolean deep = true); + Node importNode(Node node, boolean deep); + [Throws] + Node importNode(Node node); [Throws] Node adoptNode(Node node); diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 266b8cfd535c..1e741312ef91 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -141,7 +141,8 @@ partial interface Element { DOMRect getBoundingClientRect(); // scrolling - void scrollIntoView(optional boolean top = true); + void scrollIntoView(); + void scrollIntoView(boolean top); // None of the CSSOM attributes are [Pure], because they flush attribute long scrollTop; // scroll on setting attribute long scrollLeft; // scroll on setting diff --git a/dom/webidl/Node.webidl b/dom/webidl/Node.webidl index cddd9a47a65d..d89d18c7ddd3 100644 --- a/dom/webidl/Node.webidl +++ b/dom/webidl/Node.webidl @@ -68,7 +68,9 @@ interface Node : EventTarget { void normalize(); [Throws] - Node cloneNode(optional boolean deep = true); + Node cloneNode(); + [Throws] + Node cloneNode(boolean deep); boolean isEqualNode(Node? node); const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; diff --git a/dom/webidl/Promise.webidl b/dom/webidl/Promise.webidl index 9d9d1a19aeec..8cea8a33aff0 100644 --- a/dom/webidl/Promise.webidl +++ b/dom/webidl/Promise.webidl @@ -28,9 +28,9 @@ interface Promise { static Promise reject(any value); [NewObject] - Promise then([TreatUndefinedAs=Missing] optional AnyCallback fulfillCallback, - [TreatUndefinedAs=Missing] optional AnyCallback rejectCallback); + Promise then(optional AnyCallback fulfillCallback, + optional AnyCallback rejectCallback); [NewObject] - Promise catch([TreatUndefinedAs=Missing] optional AnyCallback rejectCallback); + Promise catch(optional AnyCallback rejectCallback); }; diff --git a/dom/webidl/XMLHttpRequest.webidl b/dom/webidl/XMLHttpRequest.webidl index 16dee05baa9d..ba20b72ca0f7 100644 --- a/dom/webidl/XMLHttpRequest.webidl +++ b/dom/webidl/XMLHttpRequest.webidl @@ -71,7 +71,9 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget { // request [Throws] - void open(ByteString method, DOMString url, optional boolean async = true, + void open(ByteString method, DOMString url); + [Throws] + void open(ByteString method, DOMString url, boolean async, optional DOMString? user, optional DOMString? password); [Throws] void setRequestHeader(ByteString header, ByteString value); diff --git a/dom/workers/XMLHttpRequest.h b/dom/workers/XMLHttpRequest.h index 29ba0536ccc4..85616f8361a7 100644 --- a/dom/workers/XMLHttpRequest.h +++ b/dom/workers/XMLHttpRequest.h @@ -121,6 +121,11 @@ public: return mStateData.mReadyState; } + void Open(const nsACString& aMethod, const nsAString& aUrl, ErrorResult& aRv) + { + Open(aMethod, aUrl, true, Optional(), + Optional(), aRv); + } void Open(const nsACString& aMethod, const nsAString& aUrl, bool aAsync, const Optional& aUser, const Optional& aPassword, diff --git a/js/xpconnect/tests/unit/test_allowedDomainsXHR.js b/js/xpconnect/tests/unit/test_allowedDomainsXHR.js index 7d257c5a9ad9..387a34c1e9cf 100644 --- a/js/xpconnect/tests/unit/test_allowedDomainsXHR.js +++ b/js/xpconnect/tests/unit/test_allowedDomainsXHR.js @@ -52,7 +52,7 @@ function run_test() // Test sync XHR sending cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb); var res = cu.evalInSandbox('var sync = createXHR("4444/simple"); sync.send(null); sync', sb); - checkResults(res); + do_check_true(checkResults(res)); // negative test sync XHR sending (to ensure that the xhr do not have chrome caps, see bug 779821) try { From 120ff6b66e4724d1863171e691fa4bdc484b26a2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 31 Oct 2013 22:07:10 -0400 Subject: [PATCH 025/795] Bug 925737. Allow copy-constructing owning unions with safe enough members. r=peterv --- dom/bindings/Codegen.py | 53 ++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index ee8beec371f9..7460be0e5892 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -53,6 +53,14 @@ def toStringBool(arg): def toBindingNamespace(arg): return re.sub("((_workers)?$)", "Binding\\1", arg); +def isTypeCopyConstructible(type): + # Nullable and sequence stuff doesn't affect copy/constructibility + type = type.unroll() + return (type.isPrimitive() or type.isString() or type.isEnum() or + (type.isUnion() and CGUnionStruct.isUnionCopyConstructible(type)) or + (type.isDictionary() and + CGDictionary.isDictionaryCopyConstructible(type.inner))) + class CGThing(): """ Abstract base class for things that spit out code. @@ -6318,6 +6326,10 @@ class CGUnionStruct(CGThing): enumValues = ["eUninitialized"] toJSValCases = [CGCase("eUninitialized", CGGeneric("return false;"))] destructorCases = [CGCase("eUninitialized", None)] + assignmentCases = [ + CGCase("eUninitialized", + CGGeneric('MOZ_ASSERT(mType == eUninitialized,\n' + ' "We need to destroy ourselves?");'))] traceCases = [] unionValues = [] if self.type.hasNullableType: @@ -6329,6 +6341,8 @@ class CGUnionStruct(CGThing): body="mType = eNull;", bodyInHeader=True)) destructorCases.append(CGCase("eNull", None)) + assignmentCases.append(CGCase("eNull", + CGGeneric("mType = eNull;"))) toJSValCases.append(CGCase("eNull", CGGeneric("rval.setNull();\n" "return true;"))) @@ -6396,6 +6410,10 @@ class CGUnionStruct(CGThing): destructorCases.append(CGCase("e" + vars["name"], CGGeneric("Destroy%s();" % vars["name"]))) + assignmentCases.append( + CGCase("e" + vars["name"], + CGGeneric("SetAs%s() = aOther.GetAs%s();" % + (vars["name"], vars["name"])))) if self.ownsMembers and typeNeedsRooting(t): if t.isObject(): traceCases.append( @@ -6424,6 +6442,8 @@ class CGUnionStruct(CGThing): ], body=CGSwitch("mType", toJSValCases, default=CGGeneric("return false;")).define(), const=True)) + constructors = [ctor] + selfName = ("Owning" if self.ownsMembers else "") + str(self.type) if self.ownsMembers: if len(traceCases): traceBody = CGSwitch("mType", traceCases, @@ -6433,13 +6453,30 @@ class CGUnionStruct(CGThing): methods.append(ClassMethod("TraceUnion", "void", [Argument("JSTracer*", "trc")], body=traceBody)) + if CGUnionStruct.isUnionCopyConstructible(self.type): + constructors.append( + ClassConstructor([Argument("const %s&" % selfName, + "aOther")], + bodyInHeader=True, + visibility="public", + explicit=True, + body="*this = aOther;")) + methods.append(ClassMethod( + "operator=", "void", + [Argument("const %s&" % selfName, "aOther")], + body=CGSwitch("aOther.mType", assignmentCases).define())) + disallowCopyConstruction = False + else: + disallowCopyConstruction = True + else: + disallowCopyConstruction = True friend=" friend class %sArgument;\n" % str(self.type) if not self.ownsMembers else "" - return CGClass(("Owning" if self.ownsMembers else "") + str(self.type), + return CGClass(selfName, members=members, - constructors=[ctor], + constructors=constructors, methods=methods, - disallowCopyConstruction=True, + disallowCopyConstruction=disallowCopyConstruction, extradeclarations=friend, destructor=ClassDestructor(visibility="public", body=dtor, @@ -6461,6 +6498,10 @@ class CGUnionStruct(CGThing): }) return CGGeneric(wrapCode) + @staticmethod + def isUnionCopyConstructible(type): + return all(isTypeCopyConstructible(t) for t in type.flatMemberTypes) + class CGUnionConversionStruct(CGThing): def __init__(self, type, descriptorProvider): CGThing.__init__(self) @@ -8754,12 +8795,6 @@ if (""", @staticmethod def isDictionaryCopyConstructible(dictionary): - def isTypeCopyConstructible(type): - # Nullable and sequence stuff doesn't affect copy/constructibility - type = type.unroll() - return (type.isPrimitive() or type.isString() or type.isEnum() or - (type.isDictionary() and - CGDictionary.isDictionaryCopyConstructible(type.inner))) if (dictionary.parent and not CGDictionary.isDictionaryCopyConstructible(dictionary.parent)): return False From f3657739555609b568fa5b16ffe19c73c9c9c32a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 31 Oct 2013 22:07:10 -0400 Subject: [PATCH 026/795] Bug 932421. Stop including windows.h (via Hal.h) in Screen.h, so we don't screw up our bindings code. r=smaug Also stops Hal.h bootlegging Observer.h. --- dom/base/nsGlobalWindow.cpp | 22 +++++++++++---------- dom/base/nsScreen.h | 2 +- dom/ipc/PCOMContentPermissionRequestChild.h | 2 ++ hal/Hal.h | 6 ++---- hal/HalScreenConfiguration.h | 20 +++++++++++++++++++ hal/moz.build | 1 + 6 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 hal/HalScreenConfiguration.h diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 1c8e829a48a5..79e3c69f010a 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -36,16 +36,6 @@ #include "nsIScriptTimeoutHandler.h" #include "nsIController.h" -#ifdef XP_WIN -// Thanks so much, Microsoft! :( -#ifdef GetClassName -#undef GetClassName -#endif // GetClassName -#ifdef CreateEvent -#undef CreateEvent -#endif -#endif // XP_WIN - // Helper Classes #include "nsJSUtils.h" #include "jsapi.h" // for JSAutoRequest @@ -75,6 +65,18 @@ #include "nsIWidgetListener.h" #include "nsIBaseWindow.h" #include "nsDeviceSensors.h" + +#ifdef XP_WIN +// Thanks so much, Microsoft and the people who pull in windows.h via +// random silly headers! :( +#ifdef GetClassName +#undef GetClassName +#endif // GetClassName +#ifdef CreateEvent +#undef CreateEvent +#endif +#endif // XP_WIN + #include "nsIContent.h" #include "nsIDocShell.h" #include "nsIDocCharset.h" diff --git a/dom/base/nsScreen.h b/dom/base/nsScreen.h index 1837e44d12c4..47f19c913e66 100644 --- a/dom/base/nsScreen.h +++ b/dom/base/nsScreen.h @@ -8,7 +8,7 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/ScreenOrientation.h" #include "mozilla/ErrorResult.h" -#include "mozilla/Hal.h" +#include "mozilla/HalScreenConfiguration.h" #include "nsIDOMScreen.h" #include "nsCOMPtr.h" #include "nsDOMEventTargetHelper.h" diff --git a/dom/ipc/PCOMContentPermissionRequestChild.h b/dom/ipc/PCOMContentPermissionRequestChild.h index de797364470b..9b8f87a63fd2 100644 --- a/dom/ipc/PCOMContentPermissionRequestChild.h +++ b/dom/ipc/PCOMContentPermissionRequestChild.h @@ -7,6 +7,8 @@ #include "mozilla/dom/PContentPermissionRequestChild.h" // Microsoft's API Name hackery sucks +// XXXbz Doing this in a header is a gigantic footgun. See +// https://bugzilla.mozilla.org/show_bug.cgi?id=932421#c3 for why. #undef CreateEvent /* diff --git a/hal/Hal.h b/hal/Hal.h index 640cc98e71c1..50932bdcaf30 100644 --- a/hal/Hal.h +++ b/hal/Hal.h @@ -10,6 +10,7 @@ #include "mozilla/hal_sandbox/PHal.h" #include "mozilla/HalTypes.h" #include "base/basictypes.h" +#include "mozilla/Observer.h" #include "mozilla/Types.h" #include "nsTArray.h" #include "prlog.h" @@ -18,6 +19,7 @@ #include "mozilla/dom/power/Types.h" #include "mozilla/hal_sandbox/PHal.h" #include "mozilla/dom/ScreenOrientation.h" +#include "mozilla/HalScreenConfiguration.h" /* * Hal.h contains the public Hal API. @@ -38,13 +40,9 @@ class nsIDOMWindow; namespace mozilla { -template -class Observer; - namespace hal { typedef Observer AlarmObserver; -typedef Observer ScreenConfigurationObserver; class WindowIdentifier; diff --git a/hal/HalScreenConfiguration.h b/hal/HalScreenConfiguration.h new file mode 100644 index 000000000000..f1bb42a751f5 --- /dev/null +++ b/hal/HalScreenConfiguration.h @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=8 et ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_HalScreenConfiguration_h +#define mozilla_HalScreenConfiguration_h + +#include "mozilla/Observer.h" + +namespace mozilla { +namespace hal { +struct ScreenConfiguration; +typedef Observer ScreenConfigurationObserver; +} // namespace hal +} // namespace mozilla + +#endif // mozilla_HalScreenConfiguration_h + diff --git a/hal/moz.build b/hal/moz.build index f8fd247839d0..f72669012d77 100644 --- a/hal/moz.build +++ b/hal/moz.build @@ -14,6 +14,7 @@ EXPORTS.mozilla += [ 'Hal.h', 'HalImpl.h', 'HalSandbox.h', + 'HalScreenConfiguration.h', 'HalSensor.h', 'HalTypes.h', 'HalWakeLock.h', From d16195f15c6b62889c5cea9b6be7d3b8d04cd48c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 31 Oct 2013 22:07:11 -0400 Subject: [PATCH 027/795] Bug 932870. Cache the "invalid selector" state in our parsed-selector cache as well when doing querySelector(All). r=smaug --- content/base/public/nsIDocument.h | 8 +++++--- content/base/src/nsINode.cpp | 29 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 50c33fcb0178..f0e579723d73 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -696,10 +696,12 @@ public: // We do not call MarkUsed because it would just slow down lookups and // because we're OK expiring things after a few seconds even if they're - // being used. - nsCSSSelectorList* GetList(const nsAString& aSelector) + // being used. Returns whether we actually had an entry for aSelector. + // If we have an entry and *aList is null, that indicates that aSelector + // has already been parsed and is not a syntactically valid selector. + bool GetList(const nsAString& aSelector, nsCSSSelectorList** aList) { - return mTable.Get(aSelector); + return mTable.Get(aSelector, aList); } ~SelectorCache() diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index ddc48830754a..8592273b607f 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -2291,8 +2291,7 @@ ParseSelectorList(nsINode* aNode, const nsAString& aSelectorString, nsCSSSelectorList** aSelectorList) { - NS_ENSURE_ARG(aNode); - + MOZ_ASSERT(aNode); nsIDocument* doc = aNode->OwnerDoc(); nsCSSParser parser(doc->CSSLoader()); @@ -2345,24 +2344,34 @@ FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList) nsIDocument* doc = aRoot->OwnerDoc(); nsIDocument::SelectorCache& cache = doc->GetSelectorCache(); - nsCSSSelectorList* selectorList = cache.GetList(aSelector); + nsCSSSelectorList* selectorList = nullptr; + bool haveCachedList = cache.GetList(aSelector, &selectorList); - if (!selectorList) { - nsresult rv = ParseSelectorList(aRoot, aSelector, - &selectorList); + if (!haveCachedList) { + nsresult rv = ParseSelectorList(aRoot, aSelector, &selectorList); if (NS_FAILED(rv)) { - delete selectorList; + MOZ_ASSERT(!selectorList); + MOZ_ASSERT(rv == NS_ERROR_DOM_SYNTAX_ERR, + "Unexpected error, so cached version won't return it"); // We hit this for syntax errors, which are quite common, so don't // use NS_ENSURE_SUCCESS. (For example, jQuery has an extended set // of selectors, but it sees if we can parse them first.) - return rv; + } else if (!selectorList) { + // This is the "only pseudo-element selectors" case, which is + // not common, so just don't worry about caching it. That way a + // null cached value can always indicate an invalid selector. + // Also don't try to do any matching, of course. + return NS_OK; } - NS_ENSURE_TRUE(selectorList, NS_OK); - cache.CacheList(aSelector, selectorList); } + if (!selectorList) { + // Invalid selector, since we've already handled the pseudo-element case. + return NS_ERROR_DOM_SYNTAX_ERR; + } + NS_ASSERTION(selectorList->mSelectors, "How can we not have any selectors?"); From 45644e69163c8ff5eb1d7df99410b72ab958f701 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 31 Oct 2013 22:07:11 -0400 Subject: [PATCH 028/795] Bug 932998. Don't try to codegen code that keeps alive objects with 'owned' nativeOwnership, since we have no way to do that. r=smaug --- dom/bindings/Codegen.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 7460be0e5892..4860582baeb8 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -3210,6 +3210,12 @@ for (uint32_t i = 0; i < length; ++i) { isMember or isCallbackReturnValue) + if forceOwningType and descriptor.nativeOwnership == 'owned': + raise TypeError("Interface %s has 'owned' nativeOwnership, so we " + "don't know how to keep it alive in %s" % + (descriptor.interface.identifier.name, + sourceDescription)) + typeName = descriptor.nativeType typePtr = typeName + "*" From 7763b195d42b3f5bac3f2ff25260b3d8332e48be Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 31 Oct 2013 22:07:11 -0400 Subject: [PATCH 029/795] Bug 933087. Make sure we don't violate stack discipline for Rooted, even when playing Maybe games. r=khuey --- dom/bindings/Codegen.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 4860582baeb8..59d44c1471a1 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -4839,6 +4839,18 @@ if (global.Failed()) { else: assert self.argCount == 0 + if needsUnwrap: + # It's very important that we construct our unwrappedObj, if we need + # to do it, before we might start setting up Rooted things for our + # arguments, so that we don't violate the stack discipline Rooted + # depends on. + cgThings.append(CGGeneric( + "bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);")) + if needsUnwrappedVar: + cgThings.append(CGIfWrapper( + CGGeneric("unwrappedObj.construct(cx, obj);"), + "objIsXray")) + cgThings.extend([CGArgumentConverter(arguments[i], i, self.descriptor, argDescription % { "index": i + 1 }, invalidEnumValueFatal=not setter, @@ -4849,10 +4861,6 @@ if (global.Failed()) { if needsUnwrap: # Something depends on having the unwrapped object, so unwrap it now. xraySteps = [] - if needsUnwrappedVar: - xraySteps.append( - CGGeneric("unwrappedObj.construct(cx, obj);")) - # XXXkhuey we should be able to MOZ_ASSERT that ${obj} is # not null. xraySteps.append( @@ -4878,7 +4886,7 @@ if (!${obj}) { cgThings.append( CGIfWrapper(CGList(xraySteps, "\n"), - "xpc::WrapperFactory::IsXrayWrapper(obj)")) + "objIsXray")) cgThings.append(CGCallGenerator( self.getErrorReport() if self.isFallible() else None, From 5da5c4cd53e4d2379e96b394d261c86e27a2a463 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 24 Oct 2013 20:47:48 -0700 Subject: [PATCH 030/795] Bug 930851 (part 1) - Make child process naming consistent in both memory reporting paths. r=khuey. --HG-- extra : rebase_source : 6c212dd1ddc701af8297a6de373c8650b18a1b56 --- dom/ipc/ContentChild.cpp | 22 +++++++++++++++++-- dom/ipc/ContentChild.h | 4 +++- .../tests/test_memoryReporters2.xul | 2 +- xpcom/base/nsMemoryInfoDumper.cpp | 18 +++++---------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 95e123c55922..9786249dcf42 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -383,12 +383,28 @@ ContentChild::SetProcessName(const nsAString& aName) mozilla::ipc::SetThisProcessName(NS_LossyConvertUTF16toASCII(aName).get()); } -const void +void ContentChild::GetProcessName(nsAString& aName) { aName.Assign(mProcessName); } +void +ContentChild::GetProcessName(nsACString& aName) +{ + aName.Assign(NS_ConvertUTF16toUTF8(mProcessName)); +} + +/* static */ void +ContentChild::AppendProcessId(nsACString& aName) +{ + if (!aName.IsEmpty()) { + aName.AppendLiteral(" "); + } + unsigned pid = getpid(); + aName.Append(nsPrintfCString("(pid %u)", pid)); +} + void ContentChild::InitXPCOM() { @@ -469,7 +485,9 @@ ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* chi InfallibleTArray reports; - nsPrintfCString process("Content (%d)", getpid()); + nsCString process; + GetProcessName(process); + AppendProcessId(process); // Run each reporter. The callback will turn each measurement into a // MemoryReport. diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 4f15636a89ce..40dfbe5ca7f6 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -75,7 +75,9 @@ public: } void SetProcessName(const nsAString& aName); - const void GetProcessName(nsAString& aName); + void GetProcessName(nsAString& aName); + void GetProcessName(nsACString& aName); + static void AppendProcessId(nsACString& aName); PCompositorChild* AllocPCompositorChild(mozilla::ipc::Transport* aTransport, diff --git a/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul b/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul index 38d5ed9edc20..2be3d7c468f9 100644 --- a/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul +++ b/toolkit/components/aboutmemory/tests/test_memoryReporters2.xul @@ -96,7 +96,7 @@ if (processes[i] == "") { numEmptyProcesses++; } else { - ok(processes[i].startsWith("Content ("), + ok(processes[i].startsWith("Browser ("), "correct non-empty process name prefix"); numNonEmptyProcesses++; } diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index fff63e707abd..82d046a5d6a2 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -627,26 +627,18 @@ DumpReport(nsIGZFileWriter *aWriter, bool *aIsFirstPtr, // Generate the process identifier, which is of the form "$PROCESS_NAME // (pid $PID)", or just "(pid $PID)" if we don't have a process name. If // we're the main process, we let $PROCESS_NAME be "Main Process". - nsAutoCString processId; + nsAutoCString process; if (XRE_GetProcessType() == GeckoProcessType_Default) { // We're the main process. - processId.AssignLiteral("Main Process "); + process.AssignLiteral("Main Process "); } else if (ContentChild *cc = ContentChild::GetSingleton()) { // Try to get the process name from ContentChild. - nsAutoString processName; - cc->GetProcessName(processName); - processId.Assign(NS_ConvertUTF16toUTF8(processName)); - if (!processId.IsEmpty()) { - processId.AppendLiteral(" "); - } + cc->GetProcessName(process); } - - // Add the PID to the identifier. - unsigned pid = getpid(); - processId.Append(nsPrintfCString("(pid %u)", pid)); + ContentChild::AppendProcessId(process); DUMP(aWriter, "\n {\"process\": \""); - DUMP(aWriter, processId); + DUMP(aWriter, process); DUMP(aWriter, "\", \"path\": \""); nsCString path(aPath); From 6796f7febccec7e05764d748b9eee1b32edb8141 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 15 Oct 2013 17:16:13 -0700 Subject: [PATCH 031/795] Bug 930851 (part 2) - Inline some functions in aboutMemory.js that have a single call site. r=johns. --HG-- extra : rebase_source : 8b669e495ffcd6cab292767abf5b85cca3eb14f5 --- .../aboutmemory/content/aboutMemory.js | 184 +++++++----------- 1 file changed, 73 insertions(+), 111 deletions(-) diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index f47ba3b8beee..03aaadce0f59 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -126,48 +126,6 @@ function onUnload() //--------------------------------------------------------------------------- -/** - * Iterates over each reporter. - * - * @param aHandleReport - * The function that's called for each non-skipped report. - */ -function processMemoryReporters(aHandleReport) -{ - let handleReport = function(aProcess, aUnsafePath, aKind, aUnits, - aAmount, aDescription) { - aHandleReport(aProcess, aUnsafePath, aKind, aUnits, aAmount, - aDescription, /* presence = */ undefined); - } - - let e = gMgr.enumerateReporters(); - while (e.hasMoreElements()) { - let mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter); - mr.collectReports(handleReport, null); - } -} - -/** - * Iterates over each report. - * - * @param aReports - * Array of reports, read from a file or the clipboard. - * @param aHandleReport - * The function that's called for each report. - */ -function processMemoryReportsFromFile(aReports, aHandleReport) -{ - // Process each memory reporter with aHandleReport. - - for (let i = 0; i < aReports.length; i++) { - let r = aReports[i]; - aHandleReport(r.process, r.path, r.kind, r.units, r.amount, - r.description, r._presence); - } -} - -//--------------------------------------------------------------------------- - // The
holding everything but the header and footer (if they're present). // It's what is updated each time the page changes. let gMain; @@ -450,6 +408,20 @@ function updateAboutMemoryFromReporters() updateMainAndFooter("", SHOW_FOOTER); try { + let processMemoryReporters = function(aHandleReport) { + let handleReport = function(aProcess, aUnsafePath, aKind, aUnits, + aAmount, aDescription) { + aHandleReport(aProcess, aUnsafePath, aKind, aUnits, aAmount, + aDescription, /* presence = */ undefined); + } + + let e = gMgr.enumerateReporters(); + while (e.hasMoreElements()) { + let mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter); + mr.collectReports(handleReport, null); + } + } + // Process the reports from the memory reporters. appendAboutMemoryMain(processMemoryReporters, gMgr.hasMozMallocUsableSize); @@ -480,10 +452,16 @@ function updateAboutMemoryFromJSONObject(aObj) "missing 'hasMozMallocUsableSize' property"); assertInput(aObj.reports && aObj.reports instanceof Array, "missing or non-array 'reports' property"); - let process = function(aHandleReport) { - processMemoryReportsFromFile(aObj.reports, aHandleReport); + + let processMemoryReportsFromFile = function(aHandleReport) { + for (let i = 0; i < aObj.reports.length; i++) { + let r = aObj.reports[i]; + aHandleReport(r.process, r.path, r.kind, r.units, r.amount, + r.description, r._presence); + } } - appendAboutMemoryMain(process, aObj.hasMozMallocUsableSize); + appendAboutMemoryMain(processMemoryReportsFromFile, + aObj.hasMozMallocUsableSize); } catch (ex) { handleException(ex); } @@ -838,71 +816,6 @@ function PColl() * Boolean indicating if moz_malloc_usable_size works. */ function appendAboutMemoryMain(aProcessReports, aHasMozMallocUsableSize) -{ - let pcollsByProcess = getPCollsByProcess(aProcessReports); - - // Sort the processes. - let processes = Object.keys(pcollsByProcess); - processes.sort(function(aProcessA, aProcessB) { - assert(aProcessA != aProcessB, - "Elements of Object.keys() should be unique, but " + - "saw duplicate '" + aProcessA + "' elem."); - - // Always put the main process first. - if (aProcessA == gUnnamedProcessStr) { - return -1; - } - if (aProcessB == gUnnamedProcessStr) { - return 1; - } - - // Then sort by resident size. - let nodeA = pcollsByProcess[aProcessA]._degenerates['resident']; - let nodeB = pcollsByProcess[aProcessB]._degenerates['resident']; - let residentA = nodeA ? nodeA._amount : -1; - let residentB = nodeB ? nodeB._amount : -1; - - if (residentA > residentB) { - return -1; - } - if (residentA < residentB) { - return 1; - } - - // Then sort by process name. - if (aProcessA < aProcessB) { - return -1; - } - if (aProcessA > aProcessB) { - return 1; - } - - return 0; - }); - - // Generate output for each process. - for (let i = 0; i < processes.length; i++) { - let process = processes[i]; - let section = appendElement(gMain, 'div', 'section'); - - appendProcessAboutMemoryElements(section, i, process, - pcollsByProcess[process]._trees, - pcollsByProcess[process]._degenerates, - pcollsByProcess[process]._heapTotal, - aHasMozMallocUsableSize); - } -} - -/** - * This function reads all the memory reports, and puts that data in structures - * that will be used to generate the page. - * - * @param aProcessReports - * Function that extracts the memory reports from the reporters or from - * file. - * @return The table of PColls by process. - */ -function getPCollsByProcess(aProcessReports) { let pcollsByProcess = {}; @@ -1010,7 +923,56 @@ function getPCollsByProcess(aProcessReports) aProcessReports(handleReport); - return pcollsByProcess; + // Sort the processes. + let processes = Object.keys(pcollsByProcess); + processes.sort(function(aProcessA, aProcessB) { + assert(aProcessA != aProcessB, + "Elements of Object.keys() should be unique, but " + + "saw duplicate '" + aProcessA + "' elem."); + + // Always put the main process first. + if (aProcessA == gUnnamedProcessStr) { + return -1; + } + if (aProcessB == gUnnamedProcessStr) { + return 1; + } + + // Then sort by resident size. + let nodeA = pcollsByProcess[aProcessA]._degenerates['resident']; + let nodeB = pcollsByProcess[aProcessB]._degenerates['resident']; + let residentA = nodeA ? nodeA._amount : -1; + let residentB = nodeB ? nodeB._amount : -1; + + if (residentA > residentB) { + return -1; + } + if (residentA < residentB) { + return 1; + } + + // Then sort by process name. + if (aProcessA < aProcessB) { + return -1; + } + if (aProcessA > aProcessB) { + return 1; + } + + return 0; + }); + + // Generate output for each process. + for (let i = 0; i < processes.length; i++) { + let process = processes[i]; + let section = appendElement(gMain, 'div', 'section'); + + appendProcessAboutMemoryElements(section, i, process, + pcollsByProcess[process]._trees, + pcollsByProcess[process]._degenerates, + pcollsByProcess[process]._heapTotal, + aHasMozMallocUsableSize); + } } //--------------------------------------------------------------------------- From f97143587d6b1fb991a2deb86f8bf033adb15e59 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 24 Oct 2013 21:39:16 -0700 Subject: [PATCH 032/795] Bug 930851 (part 3) - Use |data| instead of |closure| for some callback environment arguments. r=mccr8. --HG-- extra : rebase_source : a96709da6d9a880a03e2e79149ba0e3558b4a355 --- xpcom/base/nsIMemoryReporter.idl | 8 ++++---- xpcom/base/nsMemoryReporterManager.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index fff600bd7d25..56943cc3fd38 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -122,7 +122,7 @@ interface nsIMemoryReporterCallback : nsISupports */ void callback(in ACString process, in AUTF8String path, in int32_t kind, in int32_t units, in int64_t amount, - in AUTF8String description, in nsISupports closure); + in AUTF8String description, in nsISupports data); }; /* @@ -161,7 +161,7 @@ interface nsIMemoryReporter : nsISupports * Run the reporter. */ void collectReports(in nsIMemoryReporterCallback callback, - in nsISupports closure); + in nsISupports data); /* * Kinds. See the |kind| comment in nsIMemoryReporterCallback. @@ -494,14 +494,14 @@ public: } NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCallback, - nsISupports* aClosure) + nsISupports* aData) { int64_t amount; nsresult rv = GetAmount(&amount); NS_ENSURE_SUCCESS(rv, rv); return aCallback->Callback(EmptyCString(), mNameAndPath, mKind, mUnits, - amount, mDescription, aClosure); + amount, mDescription, aData); } protected: diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 07c441cb8b94..373be344be90 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -680,7 +680,7 @@ public: } NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCallback, - nsISupports* aClosure) + nsISupports* aData) { dmd::Sizes sizes; dmd::SizeOf(&sizes); @@ -691,7 +691,7 @@ public: rv = aCallback->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ nsIMemoryReporter::KIND_HEAP, \ nsIMemoryReporter::UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aClosure); \ + NS_LITERAL_CSTRING(_desc), aData); \ NS_ENSURE_SUCCESS(rv, rv); \ } while (0) From 652e854b1c181e471d65ed25735b75840d37290c Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 15 Oct 2013 18:08:35 -0700 Subject: [PATCH 033/795] Bug 930851 (part 4) - Prepare aboutMemory.js for asynchronous memory report processing. r=khuey. --- .../aboutmemory/content/aboutMemory.js | 112 ++++++++++-------- 1 file changed, 60 insertions(+), 52 deletions(-) diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 03aaadce0f59..639289a7d335 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -408,7 +408,8 @@ function updateAboutMemoryFromReporters() updateMainAndFooter("", SHOW_FOOTER); try { - let processMemoryReporters = function(aHandleReport) { + let processLiveMemoryReports = + function(aHandleReport, aDisplayReports) { let handleReport = function(aProcess, aUnsafePath, aKind, aUnits, aAmount, aDescription) { aHandleReport(aProcess, aUnsafePath, aKind, aUnits, aAmount, @@ -420,10 +421,12 @@ function updateAboutMemoryFromReporters() let mr = e.getNext().QueryInterface(Ci.nsIMemoryReporter); mr.collectReports(handleReport, null); } + aDisplayReports(); } - // Process the reports from the memory reporters. - appendAboutMemoryMain(processMemoryReporters, gMgr.hasMozMallocUsableSize); + // Process the reports from the live memory reporters. + appendAboutMemoryMain(processLiveMemoryReports, + gMgr.hasMozMallocUsableSize); } catch (ex) { handleException(ex); @@ -453,12 +456,14 @@ function updateAboutMemoryFromJSONObject(aObj) assertInput(aObj.reports && aObj.reports instanceof Array, "missing or non-array 'reports' property"); - let processMemoryReportsFromFile = function(aHandleReport) { + let processMemoryReportsFromFile = + function(aHandleReport, aDisplayReports) { for (let i = 0; i < aObj.reports.length; i++) { let r = aObj.reports[i]; aHandleReport(r.process, r.path, r.kind, r.units, r.amount, r.description, r._presence); } + aDisplayReports(); } appendAboutMemoryMain(processMemoryReportsFromFile, aObj.hasMozMallocUsableSize); @@ -921,58 +926,61 @@ function appendAboutMemoryMain(aProcessReports, aHasMozMallocUsableSize) } } - aProcessReports(handleReport); + function displayReports() + { + // Sort the processes. + let processes = Object.keys(pcollsByProcess); + processes.sort(function(aProcessA, aProcessB) { + assert(aProcessA != aProcessB, + "Elements of Object.keys() should be unique, but " + + "saw duplicate '" + aProcessA + "' elem."); - // Sort the processes. - let processes = Object.keys(pcollsByProcess); - processes.sort(function(aProcessA, aProcessB) { - assert(aProcessA != aProcessB, - "Elements of Object.keys() should be unique, but " + - "saw duplicate '" + aProcessA + "' elem."); + // Always put the main process first. + if (aProcessA == gUnnamedProcessStr) { + return -1; + } + if (aProcessB == gUnnamedProcessStr) { + return 1; + } - // Always put the main process first. - if (aProcessA == gUnnamedProcessStr) { - return -1; + // Then sort by resident size. + let nodeA = pcollsByProcess[aProcessA]._degenerates['resident']; + let nodeB = pcollsByProcess[aProcessB]._degenerates['resident']; + let residentA = nodeA ? nodeA._amount : -1; + let residentB = nodeB ? nodeB._amount : -1; + + if (residentA > residentB) { + return -1; + } + if (residentA < residentB) { + return 1; + } + + // Then sort by process name. + if (aProcessA < aProcessB) { + return -1; + } + if (aProcessA > aProcessB) { + return 1; + } + + return 0; + }); + + // Generate output for each process. + for (let i = 0; i < processes.length; i++) { + let process = processes[i]; + let section = appendElement(gMain, 'div', 'section'); + + appendProcessAboutMemoryElements(section, i, process, + pcollsByProcess[process]._trees, + pcollsByProcess[process]._degenerates, + pcollsByProcess[process]._heapTotal, + aHasMozMallocUsableSize); } - if (aProcessB == gUnnamedProcessStr) { - return 1; - } - - // Then sort by resident size. - let nodeA = pcollsByProcess[aProcessA]._degenerates['resident']; - let nodeB = pcollsByProcess[aProcessB]._degenerates['resident']; - let residentA = nodeA ? nodeA._amount : -1; - let residentB = nodeB ? nodeB._amount : -1; - - if (residentA > residentB) { - return -1; - } - if (residentA < residentB) { - return 1; - } - - // Then sort by process name. - if (aProcessA < aProcessB) { - return -1; - } - if (aProcessA > aProcessB) { - return 1; - } - - return 0; - }); - - // Generate output for each process. - for (let i = 0; i < processes.length; i++) { - let process = processes[i]; - let section = appendElement(gMain, 'div', 'section'); - - appendProcessAboutMemoryElements(section, i, process, - pcollsByProcess[process]._trees, - pcollsByProcess[process]._degenerates, - pcollsByProcess[process]._heapTotal, - aHasMozMallocUsableSize); } + + aProcessReports(handleReport, displayReports); } //--------------------------------------------------------------------------- From c59a010330401bd413b3ae77c8eaf4e03cc5d124 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 12 Sep 2013 01:14:32 -0400 Subject: [PATCH 034/795] bug 913442 - rewrite build-gcc.py r=glandium DONTBUILD because NPOTB --- build/unix/build-gcc/build-gcc.sh | 41 +++ build/unix/build-gcc/gcc-bt.patch | 25 ++ .../binutils-deterministic.patch | 22 -- build/unix/build-toolchain/build-gcc.py | 315 ------------------ build/unix/build-toolchain/gcc-fixinc.patch | 12 - build/unix/build-toolchain/gcc-include.patch | 24 -- .../build-toolchain/glibc-deterministic.patch | 115 ------- ...993c178a1386ea5e2363a01d919738402f30.patch | 12 - .../build-toolchain/plugin_finish_decl.diff | 179 ---------- build/unix/build-toolchain/pr49911.diff | 274 --------------- .../r159628-r163231-r171807.patch | 98 ------ 11 files changed, 66 insertions(+), 1051 deletions(-) create mode 100755 build/unix/build-gcc/build-gcc.sh create mode 100644 build/unix/build-gcc/gcc-bt.patch delete mode 100644 build/unix/build-toolchain/binutils-deterministic.patch delete mode 100755 build/unix/build-toolchain/build-gcc.py delete mode 100644 build/unix/build-toolchain/gcc-fixinc.patch delete mode 100644 build/unix/build-toolchain/gcc-include.patch delete mode 100644 build/unix/build-toolchain/glibc-deterministic.patch delete mode 100644 build/unix/build-toolchain/libtool-74c8993c178a1386ea5e2363a01d919738402f30.patch delete mode 100644 build/unix/build-toolchain/plugin_finish_decl.diff delete mode 100644 build/unix/build-toolchain/pr49911.diff delete mode 100644 build/unix/build-toolchain/r159628-r163231-r171807.patch diff --git a/build/unix/build-gcc/build-gcc.sh b/build/unix/build-gcc/build-gcc.sh new file mode 100755 index 000000000000..c5d7aafe7658 --- /dev/null +++ b/build/unix/build-gcc/build-gcc.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +gcc_version=4.7.3 +binutils_version=2.23.1 +gcc_bt_patch=$(readlink -f $(dirname $0))/gcc-bt.patch +make_flags='-j12' + +root_dir=$(mktemp -d) +cd $root_dir + +if test -z $TMPDIR; then + TMPDIR=/tmp/ +fi + +wget -c -P $TMPDIR ftp://ftp.gnu.org/gnu/binutils/binutils-$binutils_version.tar.bz2 || exit 1 +tar xjf $TMPDIR/binutils-$binutils_version.tar.bz2 +mkdir binutils-objdir +cd binutils-objdir +../binutils-$binutils_version/configure --prefix /tools/gcc/ --enable-gold --enable-plugins --disable-nls || exit 1 +make $make_flags || exit 1 +make install $make_flags DESTDIR=$root_dir || exit 1 +cd .. + + wget -c -P $TMPDIR ftp://ftp.gnu.org/gnu/gcc/gcc-$gcc_version/gcc-$gcc_version.tar.bz2 || exit 1 +tar xjf $TMPDIR/gcc-$gcc_version.tar.bz2 +cd gcc-$gcc_version + +./contrib/download_prerequisites + +# gcc 4.7 doesn't dump a stack on ICE so hack that in +patch -p1 < $gcc_bt_patch || exit 1 + +cd .. +mkdir gcc-objdir +cd gcc-objdir +../gcc-$gcc_version/configure --prefix=/tools/gcc --enable-languages=c,c++ --disable-nls --disable-gnu-unique-object --enable-__cxa_atexit --with-arch-32=pentiumpro || exit 1 +make $make_flags || exit 1 +make $make_flags install DESTDIR=$root_dir || exit 1 + +cd $root_dir/tools +tar caf $root_dir/gcc.tar.xz gcc/ diff --git a/build/unix/build-gcc/gcc-bt.patch b/build/unix/build-gcc/gcc-bt.patch new file mode 100644 index 000000000000..087515c2d8d8 --- /dev/null +++ b/build/unix/build-gcc/gcc-bt.patch @@ -0,0 +1,25 @@ +--- gcc-4.7.3/gcc/diagnostic.c 2012-02-02 15:46:06.000000000 -0500 ++++ gcc-patched/gcc/diagnostic.c 2013-05-23 14:07:10.756527912 -0400 +@@ -31,6 +31,10 @@ + #include "intl.h" + #include "diagnostic.h" + ++#include ++#include ++#include ++#include + #define pedantic_warning_kind(DC) \ + ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING) + #define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR) +@@ -237,6 +241,11 @@ + if (context->abort_on_error) + real_abort (); + ++ { ++ void *stack[100]; ++ int count = backtrace(stack, 100); ++ backtrace_symbols_fd(stack, count, STDERR_FILENO); ++ } + fnotice (stderr, "Please submit a full bug report,\n" + "with preprocessed source if appropriate.\n" + "See %s for instructions.\n", bug_report_url); diff --git a/build/unix/build-toolchain/binutils-deterministic.patch b/build/unix/build-toolchain/binutils-deterministic.patch deleted file mode 100644 index f602013cb644..000000000000 --- a/build/unix/build-toolchain/binutils-deterministic.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff -ru a/binutils/ar.c b/binutils/ar.c ---- a/binutils/ar.c 2011-03-16 04:35:58.000000000 -0400 -+++ b/binutils/ar.c 2012-01-19 15:44:46.211226017 -0500 -@@ -98,7 +98,7 @@ - /* Operate in deterministic mode: write zero for timestamps, uids, - and gids for archive members and the archive symbol table, and write - consistent file modes. */ --int deterministic = 0; -+int deterministic = TRUE; - - /* Nonzero means it's the name of an existing member; position new or moved - files with respect to this one. */ -@@ -634,9 +634,6 @@ - if (newer_only && operation != replace) - fatal (_("`u' is only meaningful with the `r' option.")); - -- if (newer_only && deterministic) -- fatal (_("`u' is not meaningful with the `D' option.")); -- - if (postype != pos_default) - posname = argv[arg_index++]; - diff --git a/build/unix/build-toolchain/build-gcc.py b/build/unix/build-toolchain/build-gcc.py deleted file mode 100755 index cd1e63f9db26..000000000000 --- a/build/unix/build-toolchain/build-gcc.py +++ /dev/null @@ -1,315 +0,0 @@ -#!/usr/bin/python -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - - -# The directories end up in the debug info, so the easy way of getting -# a reproducible build is to run it in a know absolute directory. -# We use a directory in /builds/slave because the mozilla infrastructure -# cleans it up automatically. -base_dir = "/builds/slave/moz-toolchain" - -source_dir = base_dir + "/src" -build_dir = base_dir + "/build" -aux_inst_dir = build_dir + '/aux_inst' -old_make = aux_inst_dir + '/bin/make' - -############################################## - -import urllib -import os -import os.path -import shutil -import tarfile -import subprocess - -def download_uri(uri): - fname = uri.split('/')[-1] - if (os.path.exists(fname)): - return fname - urllib.urlretrieve(uri, fname) - return fname - -def extract(tar, path): - t = tarfile.open(tar) - t.extractall(path) - -def check_run(args): - r = subprocess.call(args) - assert r == 0 - -def run_in(path, args): - d = os.getcwd() - os.chdir(path) - check_run(args) - os.chdir(d) - -def patch(patch, plevel, srcdir): - patch = os.path.realpath(patch) - check_run(['patch', '-d', srcdir, '-p%s' % plevel, '-i', patch, '--fuzz=0', - '-s']) - -def build_package(package_source_dir, package_build_dir, configure_args, - make = old_make): - if not os.path.exists(package_build_dir): - os.mkdir(package_build_dir) - run_in(package_build_dir, - ["%s/configure" % package_source_dir] + configure_args) - run_in(package_build_dir, [make, "-j8"]) - run_in(package_build_dir, [make, "install"]) - -def build_aux_tools(base_dir): - make_build_dir = base_dir + '/make_build' - build_package(make_source_dir, make_build_dir, - ["--prefix=%s" % aux_inst_dir], "make") - - run_in(unifdef_source_dir, ["make"]) - run_in(unifdef_source_dir, ["make", "prefix=%s" % aux_inst_dir, "install"]) - - tar_build_dir = base_dir + '/tar_build' - build_package(tar_source_dir, tar_build_dir, - ["--prefix=%s" % aux_inst_dir]) - - gawk_build_dir = base_dir + '/gawk_build' - build_package(gawk_source_dir, gawk_build_dir, - ["--prefix=%s" % aux_inst_dir]) - -def with_env(env, f): - old_env = os.environ.copy() - os.environ.update(env) - f() - os.environ.clear() - os.environ.update(old_env) - -def build_glibc(env, stage_dir, inst_dir): - def f(): - build_glibc_aux(stage_dir, inst_dir) - with_env(env, f) - -def build_glibc_aux(stage_dir, inst_dir): - glibc_build_dir = stage_dir + '/glibc' - build_package(glibc_source_dir, glibc_build_dir, - ["--disable-profile", - "--enable-add-ons=nptl", - "--without-selinux", - "--enable-kernel=%s" % linux_version, - "--libdir=%s/lib64" % inst_dir, - "--prefix=%s" % inst_dir]) - -def build_linux_headers_aux(inst_dir): - run_in(linux_source_dir, [old_make, "headers_check"]) - run_in(linux_source_dir, [old_make, "INSTALL_HDR_PATH=dest", - "headers_install"]) - shutil.move(linux_source_dir + "/dest/include", inst_dir + '/include') - -def build_linux_headers(inst_dir): - def f(): - build_linux_headers_aux(inst_dir) - with_env({"PATH" : aux_inst_dir + "/bin:%s" % os.environ["PATH"]}, f) - -def build_gcc(stage_dir, is_stage_one): - gcc_build_dir = stage_dir + '/gcc' - tool_inst_dir = stage_dir + '/inst' - lib_inst_dir = stage_dir + '/libinst' - gcc_configure_args = ["--prefix=%s" % tool_inst_dir, - "--enable-__cxa_atexit", - "--with-gmp=%s" % lib_inst_dir, - "--with-mpfr=%s" % lib_inst_dir, - "--with-mpc=%s" % lib_inst_dir, - "--enable-languages=c,c++", - "--disable-lto", - "--disable-multilib", - "--disable-bootstrap"] - if is_stage_one: - # We build the stage1 gcc without shared libraries. Otherwise its - # libgcc.so would depend on the system libc.so, which causes problems - # when it tries to use that libgcc.so and the libc we are about to - # build. - gcc_configure_args.append("--disable-shared") - - build_package(gcc_source_dir, gcc_build_dir, gcc_configure_args) - - if is_stage_one: - # The glibc build system uses -lgcc_eh, but at least in this setup - # libgcc.a has all it needs. - d = tool_inst_dir + "/lib/gcc/x86_64-unknown-linux-gnu/4.5.2/" - os.symlink(d + "libgcc.a", d + "libgcc_eh.a") - -def build_one_stage(env, stage_dir, is_stage_one): - def f(): - build_one_stage_aux(stage_dir, is_stage_one) - with_env(env, f) - -def build_one_stage_aux(stage_dir, is_stage_one): - os.mkdir(stage_dir) - - lib_inst_dir = stage_dir + '/libinst' - - gmp_build_dir = stage_dir + '/gmp' - build_package(gmp_source_dir, gmp_build_dir, - ["--prefix=%s" % lib_inst_dir, "--disable-shared"]) - mpfr_build_dir = stage_dir + '/mpfr' - build_package(mpfr_source_dir, mpfr_build_dir, - ["--prefix=%s" % lib_inst_dir, "--disable-shared", - "--with-gmp=%s" % lib_inst_dir]) - mpc_build_dir = stage_dir + '/mpc' - build_package(mpc_source_dir, mpc_build_dir, - ["--prefix=%s" % lib_inst_dir, "--disable-shared", - "--with-gmp=%s" % lib_inst_dir, - "--with-mpfr=%s" % lib_inst_dir]) - - tool_inst_dir = stage_dir + '/inst' - os.mkdir(tool_inst_dir) - os.mkdir(tool_inst_dir + '/lib64') - os.symlink('lib64', tool_inst_dir + '/lib') - - build_linux_headers(tool_inst_dir) - - # zlib's configure only works if run from the source dir, copy the source - zlib_build_dir = stage_dir + '/zlib' - shutil.copytree(zlib_source_dir, zlib_build_dir) - build_package(zlib_build_dir, zlib_build_dir, - ["--prefix=%s" % tool_inst_dir]) - - binutils_build_dir = stage_dir + '/binutils' - build_package(binutils_source_dir, binutils_build_dir, - ["--prefix=%s" % tool_inst_dir, - "--without-zlib"]) - - # During stage one we have to build gcc first, this glibc doesn't even - # build with gcc 4.6. During stage two, we have to build glibc first. - # The problem is that libstdc++ is built with xgcc and if glibc has - # not been built yet xgcc will use the system one. - if is_stage_one: - build_gcc(stage_dir, is_stage_one) - build_glibc({"CC" : tool_inst_dir + "/bin/gcc", - "CXX" : tool_inst_dir + "/bin/g++"}, - stage_dir, tool_inst_dir) - else: - build_glibc({}, stage_dir, tool_inst_dir) - build_gcc(stage_dir, is_stage_one) - -def build_tar_package(tar, name, base, directory): - name = os.path.realpath(name) - run_in(base, [tar, "-cf", name, "--mtime=2012-01-01", "--owner=root", - directory]) - -############################################## - -def build_source_dir(prefix, version): - return source_dir + '/' + prefix + version - -binutils_version = "2.21.1" -glibc_version = "2.5.1" -linux_version = "2.6.18" -tar_version = "1.26" -gawk_version = "3.1.5" -make_version = "3.81" -gcc_version = "4.5.2" -mpfr_version = "2.4.2" -zlib_version = "1.2.3" -gmp_version = "5.0.1" -mpc_version = "0.8.1" -unifdef_version = "2.6" - -binutils_source_uri = "http://ftp.gnu.org/gnu/binutils/binutils-%sa.tar.bz2" % \ - binutils_version -glibc_source_uri = "http://ftp.gnu.org/gnu/glibc/glibc-%s.tar.bz2" % \ - glibc_version -linux_source_uri = "http://www.kernel.org/pub/linux/kernel/v2.6/linux-%s.tar.bz2" % \ - linux_version -tar_source_uri = "http://ftp.gnu.org/gnu/tar/tar-%s.tar.bz2" % \ - tar_version -gawk_source_uri = "http://ftp.gnu.org/gnu/gawk/gawk-%s.tar.bz2" % \ - gawk_version -make_source_uri = "http://ftp.gnu.org/gnu/make/make-%s.tar.bz2" % \ - make_version -unifdef_source_uri = "http://dotat.at/prog/unifdef/unifdef-%s.tar.gz" % \ - unifdef_version -gcc_source_uri = "http://ftp.gnu.org/gnu/gcc/gcc-%s/gcc-%s.tar.bz2" % \ - (gcc_version, gcc_version) -mpfr_source_uri = "http://www.mpfr.org/mpfr-%s/mpfr-%s.tar.bz2" % \ - (mpfr_version, mpfr_version) -zlib_source_uri = "http://iweb.dl.sourceforge.net/project/libpng/zlib/%s/zlib-%s.tar.bz2" % (zlib_version, zlib_version) -gmp_source_uri = "http://ftp.gnu.org/gnu/gmp/gmp-%s.tar.bz2" % gmp_version -mpc_source_uri = "http://www.multiprecision.org/mpc/download/mpc-%s.tar.gz" % \ - mpc_version - -binutils_source_tar = download_uri(binutils_source_uri) -glibc_source_tar = download_uri(glibc_source_uri) -linux_source_tar = download_uri(linux_source_uri) -tar_source_tar = download_uri(tar_source_uri) -gawk_source_tar = download_uri(gawk_source_uri) -make_source_tar = download_uri(make_source_uri) -unifdef_source_tar = download_uri(unifdef_source_uri) -mpc_source_tar = download_uri(mpc_source_uri) -mpfr_source_tar = download_uri(mpfr_source_uri) -zlib_source_tar = download_uri(zlib_source_uri) -gmp_source_tar = download_uri(gmp_source_uri) -gcc_source_tar = download_uri(gcc_source_uri) - -binutils_source_dir = build_source_dir('binutils-', binutils_version) -glibc_source_dir = build_source_dir('glibc-', glibc_version) -linux_source_dir = build_source_dir('linux-', linux_version) -tar_source_dir = build_source_dir('tar-', tar_version) -gawk_source_dir = build_source_dir('gawk-', gawk_version) -make_source_dir = build_source_dir('make-', make_version) -unifdef_source_dir = build_source_dir('unifdef-', unifdef_version) -mpc_source_dir = build_source_dir('mpc-', mpc_version) -mpfr_source_dir = build_source_dir('mpfr-', mpfr_version) -zlib_source_dir = build_source_dir('zlib-', zlib_version) -gmp_source_dir = build_source_dir('gmp-', gmp_version) -gcc_source_dir = build_source_dir('gcc-', gcc_version) - -if not os.path.exists(source_dir): - os.makedirs(source_dir) - extract(binutils_source_tar, source_dir) - patch('binutils-deterministic.patch', 1, binutils_source_dir) - extract(glibc_source_tar, source_dir) - extract(linux_source_tar, source_dir) - patch('glibc-deterministic.patch', 1, glibc_source_dir) - run_in(glibc_source_dir, ["autoconf"]) - extract(tar_source_tar, source_dir) - extract(gawk_source_tar, source_dir) - extract(make_source_tar, source_dir) - extract(unifdef_source_tar, source_dir) - extract(mpc_source_tar, source_dir) - extract(mpfr_source_tar, source_dir) - extract(zlib_source_tar, source_dir) - extract(gmp_source_tar, source_dir) - extract(gcc_source_tar, source_dir) - patch('plugin_finish_decl.diff', 0, gcc_source_dir) - patch('libtool-74c8993c178a1386ea5e2363a01d919738402f30.patch', 1, gcc_source_dir) - patch('pr49911.diff', 1, gcc_source_dir) - patch('r159628-r163231-r171807.patch', 1, gcc_source_dir) - patch('gcc-fixinc.patch', 1, gcc_source_dir) - patch('gcc-include.patch', 1, gcc_source_dir) - -if os.path.exists(build_dir): - shutil.rmtree(build_dir) -os.makedirs(build_dir) - -build_aux_tools(build_dir) - -basic_path = aux_inst_dir + "/bin:/bin:/usr/bin" - -stage1_dir = build_dir + '/stage1' -build_one_stage({"PATH" : basic_path, - "CC" : "gcc", - "CXX" : "g++" }, - stage1_dir, True) - -for stage_num in range(2, 4): - prev_stage_dir = build_dir + '/stage' + str(stage_num - 1) - prev_stage_inst_dir = prev_stage_dir + '/inst' - cur_stage_dir = build_dir + '/stage' + str(stage_num) - build_one_stage({"PATH" : prev_stage_inst_dir + "/bin:" + basic_path, - "CC" : "gcc -fgnu89-inline", - "CXX" : "g++", - "RANLIB" : "true" }, - cur_stage_dir, False) - -stage3_dir = build_dir + '/stage3' -build_tar_package(aux_inst_dir + "/bin/tar", - "toolchain.tar", stage3_dir, "inst") diff --git a/build/unix/build-toolchain/gcc-fixinc.patch b/build/unix/build-toolchain/gcc-fixinc.patch deleted file mode 100644 index 3fb7f5654af3..000000000000 --- a/build/unix/build-toolchain/gcc-fixinc.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ru a/fixincludes/Makefile.in b/fixincludes/Makefile.in ---- a/fixincludes/Makefile.in 2009-07-30 18:33:49.000000000 -0400 -+++ b/fixincludes/Makefile.in 2012-02-27 14:59:09.371875951 -0500 -@@ -126,7 +126,7 @@ - fixlib.o : fixlib.c - - fixinc.sh : fixinc.in mkfixinc.sh Makefile -- srcdir="$(srcdir)" $(SHELL) $(srcdir)/mkfixinc.sh $(target) -+ echo "#!/bin/sh" > $@ - - $(srcdir)/fixincl.x: @MAINT@ fixincl.tpl inclhack.def - cd $(srcdir) ; $(SHELL) ./genfixes diff --git a/build/unix/build-toolchain/gcc-include.patch b/build/unix/build-toolchain/gcc-include.patch deleted file mode 100644 index 35c5147a961d..000000000000 --- a/build/unix/build-toolchain/gcc-include.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff -ru a/configure b/configure ---- a/configure 2010-10-06 06:29:55.000000000 -0400 -+++ b/configure 2012-02-27 20:46:26.303460301 -0500 -@@ -8047,7 +8047,7 @@ - # being built; programs in there won't even run. - if test "${build}" = "${host}" && test -d ${srcdir}/gcc; then - # Search for pre-installed headers if nothing else fits. -- FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include' -+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(exec_prefix)/bin/ -B$(exec_prefix)/lib/ -isystem $(exec_prefix)/include -isystem $(exec_prefix)/sys-include' - fi - - if test "x${use_gnu_ld}" = x && -diff -ru a/configure.ac b/configure.ac ---- a/configure.ac 2010-10-06 06:29:55.000000000 -0400 -+++ b/configure.ac 2012-02-27 20:46:22.587442745 -0500 -@@ -3100,7 +3100,7 @@ - # being built; programs in there won't even run. - if test "${build}" = "${host}" && test -d ${srcdir}/gcc; then - # Search for pre-installed headers if nothing else fits. -- FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include' -+ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(exec_prefix)/bin/ -B$(exec_prefix)/lib/ -isystem $(exec_prefix)/include -isystem $(exec_prefix)/sys-include' - fi - - if test "x${use_gnu_ld}" = x && diff --git a/build/unix/build-toolchain/glibc-deterministic.patch b/build/unix/build-toolchain/glibc-deterministic.patch deleted file mode 100644 index bc5a11f09206..000000000000 --- a/build/unix/build-toolchain/glibc-deterministic.patch +++ /dev/null @@ -1,115 +0,0 @@ -diff -ru a/configure.in b/configure.in ---- a/configure.in 2011-01-17 23:34:07.000000000 -0500 -+++ b/configure.in 2012-01-25 20:40:27.919485606 -0500 -@@ -841,14 +841,6 @@ - LIBC_PROG_BINUTILS - AC_SUBST(MIG)dnl Needed by sysdeps/mach/configure.in - --# Accept binutils 2.13 or newer. --AC_CHECK_PROG_VER(AS, $AS, --version, -- [GNU assembler.* \([0-9]*\.[0-9.]*\)], -- [2.1[3-9]*], AS=: critic_missing="$critic_missing as") --AC_CHECK_PROG_VER(LD, $LD, --version, -- [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)], -- [2.1[3-9]*], LD=: critic_missing="$critic_missing ld") -- - # We need the physical current working directory. We cannot use the - # "pwd -P" shell builtin since that's not portable. Instead we try to - # find a pwd binary. Note that assigning to the PWD environment -@@ -2175,6 +2167,7 @@ - fi - AC_SUBST(old_glibc_headers) - -+libc_cv_slibdir=${prefix}/lib64 - AC_SUBST(libc_cv_slibdir) - AC_SUBST(libc_cv_localedir) - AC_SUBST(libc_cv_sysconfdir) -diff -ru a/csu/Makefile b/csu/Makefile ---- a/csu/Makefile 2011-01-17 23:34:07.000000000 -0500 -+++ b/csu/Makefile 2012-01-23 13:58:28.957792633 -0500 -@@ -223,8 +223,7 @@ - if [ -z "$$os" ]; then \ - os=Linux; \ - fi; \ -- printf '"Compiled on a %s %s system on %s.\\n"\n' \ -- "$$os" "$$version" "`date +%Y-%m-%d`";; \ -+ ;; \ - *) ;; \ - esac; \ - files="$(all-Banner-files)"; \ -diff -ru a/elf/Makefile b/elf/Makefile ---- a/elf/Makefile 2008-10-31 16:35:11.000000000 -0400 -+++ b/elf/Makefile 2012-02-16 12:20:00.038593752 -0500 -@@ -295,18 +295,11 @@ - z-now-yes = -Wl,-z,now - - $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map) -- @rm -f $@.lds -- $(LINK.o) -nostdlib -nostartfiles -shared $(z-now-$(bind-now)) \ -- $(LDFLAGS-rtld) -Wl,-z,defs -Wl,--verbose 2>&1 | \ -- LC_ALL=C \ -- sed -e '/^=========/,/^=========/!d;/^=========/d' \ -- -e 's/\. = 0 + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \ -- > $@.lds - $(LINK.o) -nostdlib -nostartfiles -shared -o $@ \ - $(LDFLAGS-rtld) -Wl,-z,defs $(z-now-$(bind-now)) \ - $(filter-out $(map-file),$^) $(load-map-file) \ -- -Wl,-soname=$(rtld-installed-name) -T $@.lds -- rm -f $@.lds -+ -Wl,-soname=$(rtld-installed-name) \ -+ -Wl,-defsym=_begin=0 - - # interp.c exists just to get this string into the libraries. - CFLAGS-interp.c = -D'RUNTIME_LINKER="$(slibdir)/$(rtld-installed-name)"' \ -diff -ru a/localedata/Makefile b/localedata/Makefile ---- a/localedata/Makefile 2006-04-26 01:14:03.000000000 -0400 -+++ b/localedata/Makefile 2012-02-17 10:31:24.592345047 -0500 -@@ -113,7 +113,7 @@ - $(make-target-directory) - rm -f $(@:.gz=) $@ - $(INSTALL_DATA) $< $(@:.gz=) -- gzip -9 $(@:.gz=) -+ gzip -9n $(@:.gz=) - - # Install the locale source files in the appropriate directory. - $(inst_i18ndir)/locales/%: locales/% $(+force); $(do-install) -diff -ru a/Makeconfig b/Makeconfig ---- a/Makeconfig 2006-07-10 17:42:27.000000000 -0400 -+++ b/Makeconfig 2012-02-17 08:28:31.859584817 -0500 -@@ -674,7 +674,7 @@ - $(foreach lib,$(libof-$(basename $(@F))) \ - $(libof-$( $@.new - mv -f $@.new $@ - -diff -ru a/nscd/nscd_stat.c b/nscd/nscd_stat.c ---- a/nscd/nscd_stat.c 2011-01-17 23:34:07.000000000 -0500 -+++ b/nscd/nscd_stat.c 2012-01-23 15:54:45.231607606 -0500 -@@ -38,7 +38,7 @@ - - - /* We use this to make sure the receiver is the same. */ --static const char compilation[21] = __DATE__ " " __TIME__; -+static const char compilation[21] = "don't need this"; - - /* Statistic data for one database. */ - struct dbstat diff --git a/build/unix/build-toolchain/libtool-74c8993c178a1386ea5e2363a01d919738402f30.patch b/build/unix/build-toolchain/libtool-74c8993c178a1386ea5e2363a01d919738402f30.patch deleted file mode 100644 index 15187f6a7373..000000000000 --- a/build/unix/build-toolchain/libtool-74c8993c178a1386ea5e2363a01d919738402f30.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ruN a/ltmain.sh b/ltmain.sh ---- a/ltmain.sh 2009-12-05 12:18:53.000000000 -0500 -+++ b/ltmain.sh 2012-05-07 16:19:31.871827967 -0400 -@@ -2932,7 +2932,7 @@ - func_extract_an_archive "$my_xdir" "$my_xabs" - ;; - esac -- my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` -+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` - done - - func_extract_archives_result="$my_oldobjs" diff --git a/build/unix/build-toolchain/plugin_finish_decl.diff b/build/unix/build-toolchain/plugin_finish_decl.diff deleted file mode 100644 index 711ba4712112..000000000000 --- a/build/unix/build-toolchain/plugin_finish_decl.diff +++ /dev/null @@ -1,179 +0,0 @@ -Index: gcc/doc/plugins.texi -=================================================================== ---- gcc/doc/plugins.texi (revision 162126) -+++ gcc/doc/plugins.texi (working copy) -@@ -144,6 +144,7 @@ - @{ - PLUGIN_PASS_MANAGER_SETUP, /* To hook into pass manager. */ - PLUGIN_FINISH_TYPE, /* After finishing parsing a type. */ -+ PLUGIN_FINISH_DECL, /* After finishing parsing a declaration. */ - PLUGIN_FINISH_UNIT, /* Useful for summary processing. */ - PLUGIN_PRE_GENERICIZE, /* Allows to see low level AST in C and C++ frontends. */ - PLUGIN_FINISH, /* Called before GCC exits. */ -Index: gcc/plugin.def -=================================================================== ---- gcc/plugin.def (revision 162126) -+++ gcc/plugin.def (working copy) -@@ -24,6 +24,9 @@ - /* After finishing parsing a type. */ - DEFEVENT (PLUGIN_FINISH_TYPE) - -+/* After finishing parsing a declaration. */ -+DEFEVENT (PLUGIN_FINISH_DECL) -+ - /* Useful for summary processing. */ - DEFEVENT (PLUGIN_FINISH_UNIT) - -Index: gcc/testsuite/g++.dg/plugin/plugin.exp -=================================================================== ---- gcc/testsuite/g++.dg/plugin/plugin.exp (revision 162126) -+++ gcc/testsuite/g++.dg/plugin/plugin.exp (working copy) -@@ -51,7 +51,8 @@ - { pragma_plugin.c pragma_plugin-test-1.C } \ - { selfassign.c self-assign-test-1.C self-assign-test-2.C self-assign-test-3.C } \ - { dumb_plugin.c dumb-plugin-test-1.C } \ -- { header_plugin.c header-plugin-test.C } ] -+ { header_plugin.c header-plugin-test.C } \ -+ { decl_plugin.c decl-plugin-test.C } ] - - foreach plugin_test $plugin_test_list { - # Replace each source file with its full-path name -Index: gcc/testsuite/g++.dg/plugin/decl-plugin-test.C -=================================================================== ---- gcc/testsuite/g++.dg/plugin/decl-plugin-test.C (revision 0) -+++ gcc/testsuite/g++.dg/plugin/decl-plugin-test.C (revision 0) -@@ -0,0 +1,32 @@ -+ -+ -+extern int global; // { dg-warning "Decl Global global" } -+int global_array[] = { 1, 2, 3 }; // { dg-warning "Decl Global global_array" } -+ -+int takes_args(int arg1, int arg2) -+{ -+ int local = arg1 + arg2 + global; // { dg-warning "Decl Local local" } -+ return local + 1; -+} -+ -+int global = 12; // { dg-warning "Decl Global global" } -+ -+struct test_str { -+ int field; // { dg-warning "Decl Field field" } -+}; -+ -+class test_class { -+ int class_field1; // { dg-warning "Decl Field class_field1" } -+ int class_field2; // { dg-warning "Decl Field class_field2" } -+ -+ test_class() // { dg-warning "Decl Function test_class" } -+ : class_field1(0), class_field2(0) -+ {} -+ -+ void swap_fields(int bias) // { dg-warning "Decl Function swap_fields" } -+ { -+ int temp = class_field1 + bias; // { dg-warning "Decl Local temp" } -+ class_field1 = class_field2 - bias; -+ class_field2 = temp; -+ } -+}; -Index: gcc/testsuite/g++.dg/plugin/decl_plugin.c -=================================================================== ---- gcc/testsuite/g++.dg/plugin/decl_plugin.c (revision 0) -+++ gcc/testsuite/g++.dg/plugin/decl_plugin.c (revision 0) -@@ -0,0 +1,51 @@ -+/* A plugin example that shows which declarations are caught by FINISH_DECL */ -+ -+#include "gcc-plugin.h" -+#include -+#include "config.h" -+#include "system.h" -+#include "coretypes.h" -+#include "tree.h" -+#include "tree-pass.h" -+#include "intl.h" -+ -+int plugin_is_GPL_compatible; -+ -+/* Callback function to invoke after GCC finishes a declaration. */ -+ -+void plugin_finish_decl (void *event_data, void *data) -+{ -+ tree decl = (tree) event_data; -+ -+ const char *kind = NULL; -+ switch (TREE_CODE(decl)) { -+ case FUNCTION_DECL: -+ kind = "Function"; break; -+ case PARM_DECL: -+ kind = "Parameter"; break; -+ case VAR_DECL: -+ if (DECL_CONTEXT(decl) != NULL) -+ kind = "Local"; -+ else -+ kind = "Global"; -+ break; -+ case FIELD_DECL: -+ kind = "Field"; break; -+ default: -+ kind = "Unknown"; -+ } -+ -+ warning (0, G_("Decl %s %s"), -+ kind, IDENTIFIER_POINTER (DECL_NAME (decl))); -+} -+ -+int -+plugin_init (struct plugin_name_args *plugin_info, -+ struct plugin_gcc_version *version) -+{ -+ const char *plugin_name = plugin_info->base_name; -+ -+ register_callback (plugin_name, PLUGIN_FINISH_DECL, -+ plugin_finish_decl, NULL); -+ return 0; -+} -Index: gcc/cp/decl.c -=================================================================== ---- gcc/cp/decl.c (revision 162126) -+++ gcc/cp/decl.c (working copy) -@@ -5967,6 +5967,8 @@ - /* If this was marked 'used', be sure it will be output. */ - if (lookup_attribute ("used", DECL_ATTRIBUTES (decl))) - mark_decl_referenced (decl); -+ -+ invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl); - } - - /* Returns a declaration for a VAR_DECL as if: -Index: gcc/c-decl.c -=================================================================== ---- gcc/c-decl.c (revision 162126) -+++ gcc/c-decl.c (working copy) -@@ -4392,6 +4392,8 @@ - && DECL_INITIAL (decl) == NULL_TREE) - warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, - "uninitialized const %qD is invalid in C++", decl); -+ -+ invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl); - } - - /* Given a parsed parameter declaration, decode it into a PARM_DECL. */ -Index: gcc/plugin.c -=================================================================== ---- gcc/plugin.c (revision 162126) -+++ gcc/plugin.c (working copy) -@@ -400,6 +400,7 @@ - } - /* Fall through. */ - case PLUGIN_FINISH_TYPE: -+ case PLUGIN_FINISH_DECL: - case PLUGIN_START_UNIT: - case PLUGIN_FINISH_UNIT: - case PLUGIN_PRE_GENERICIZE: -@@ -481,6 +482,7 @@ - gcc_assert (event < event_last); - /* Fall through. */ - case PLUGIN_FINISH_TYPE: -+ case PLUGIN_FINISH_DECL: - case PLUGIN_START_UNIT: - case PLUGIN_FINISH_UNIT: - case PLUGIN_PRE_GENERICIZE: diff --git a/build/unix/build-toolchain/pr49911.diff b/build/unix/build-toolchain/pr49911.diff deleted file mode 100644 index 3583f00aa5f9..000000000000 --- a/build/unix/build-toolchain/pr49911.diff +++ /dev/null @@ -1,274 +0,0 @@ -diff -ru gcc-4.5.2/gcc/double-int.c gcc-4.5.2-new/gcc/double-int.c ---- gcc-4.5.2/gcc/double-int.c 2009-11-25 05:55:54.000000000 -0500 -+++ gcc-4.5.2-new/gcc/double-int.c 2011-11-29 10:20:27.625583810 -0500 -@@ -296,7 +296,12 @@ - tree - double_int_to_tree (tree type, double_int cst) - { -- cst = double_int_ext (cst, TYPE_PRECISION (type), TYPE_UNSIGNED (type)); -+ /* Size types *are* sign extended. */ -+ bool sign_extended_type = (!TYPE_UNSIGNED (type) -+ || (TREE_CODE (type) == INTEGER_TYPE -+ && TYPE_IS_SIZETYPE (type))); -+ -+ cst = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type); - - return build_int_cst_wide (type, cst.low, cst.high); - } -diff -ru gcc-4.5.2/gcc/tree.c gcc-4.5.2-new/gcc/tree.c ---- gcc-4.5.2/gcc/tree.c 2010-07-07 11:24:27.000000000 -0400 -+++ gcc-4.5.2-new/gcc/tree.c 2011-11-29 10:20:27.626583813 -0500 -@@ -9750,7 +9750,7 @@ - tree - upper_bound_in_type (tree outer, tree inner) - { -- unsigned HOST_WIDE_INT lo, hi; -+ double_int high; - unsigned int det = 0; - unsigned oprec = TYPE_PRECISION (outer); - unsigned iprec = TYPE_PRECISION (inner); -@@ -9797,18 +9797,18 @@ - /* Compute 2^^prec - 1. */ - if (prec <= HOST_BITS_PER_WIDE_INT) - { -- hi = 0; -- lo = ((~(unsigned HOST_WIDE_INT) 0) -+ high.high = 0; -+ high.low = ((~(unsigned HOST_WIDE_INT) 0) - >> (HOST_BITS_PER_WIDE_INT - prec)); - } - else - { -- hi = ((~(unsigned HOST_WIDE_INT) 0) -+ high.high = ((~(unsigned HOST_WIDE_INT) 0) - >> (2 * HOST_BITS_PER_WIDE_INT - prec)); -- lo = ~(unsigned HOST_WIDE_INT) 0; -+ high.low = ~(unsigned HOST_WIDE_INT) 0; - } - -- return build_int_cst_wide (outer, lo, hi); -+ return double_int_to_tree (outer, high); - } - - /* Returns the smallest value obtainable by casting something in INNER type to -diff -ru gcc-4.5.2/gcc/tree-vrp.c gcc-4.5.2-new/gcc/tree-vrp.c ---- gcc-4.5.2/gcc/tree-vrp.c 2010-06-14 11:23:31.000000000 -0400 -+++ gcc-4.5.2-new/gcc/tree-vrp.c 2011-11-29 10:20:27.628583820 -0500 -@@ -127,10 +127,10 @@ - static inline tree - vrp_val_max (const_tree type) - { -- if (!INTEGRAL_TYPE_P (type)) -- return NULL_TREE; -+ if (INTEGRAL_TYPE_P (type)) -+ return upper_bound_in_type (CONST_CAST_TREE (type), CONST_CAST_TREE (type)); - -- return TYPE_MAX_VALUE (type); -+ return NULL_TREE; - } - - /* Return the minimum value for TYPE. */ -@@ -138,10 +138,10 @@ - static inline tree - vrp_val_min (const_tree type) - { -- if (!INTEGRAL_TYPE_P (type)) -- return NULL_TREE; -+ if (INTEGRAL_TYPE_P (type)) -+ return lower_bound_in_type (CONST_CAST_TREE (type), CONST_CAST_TREE (type)); - -- return TYPE_MIN_VALUE (type); -+ return NULL_TREE; - } - - /* Return whether VAL is equal to the maximum value of its type. This -@@ -539,7 +539,7 @@ - set_value_range (vr, VR_RANGE, zero, - (overflow_infinity - ? positive_overflow_infinity (type) -- : TYPE_MAX_VALUE (type)), -+ : vrp_val_max (type)), - vr->equiv); - } - -@@ -1595,7 +1595,7 @@ - } - else if (cond_code == LE_EXPR || cond_code == LT_EXPR) - { -- min = TYPE_MIN_VALUE (type); -+ min = vrp_val_min (type); - - if (limit_vr == NULL || limit_vr->type == VR_ANTI_RANGE) - max = limit; -@@ -1630,7 +1630,7 @@ - } - else if (cond_code == GE_EXPR || cond_code == GT_EXPR) - { -- max = TYPE_MAX_VALUE (type); -+ max = vrp_val_max (type); - - if (limit_vr == NULL || limit_vr->type == VR_ANTI_RANGE) - min = limit; -@@ -2047,11 +2047,11 @@ - || code == ROUND_DIV_EXPR) - return (needs_overflow_infinity (TREE_TYPE (res)) - ? positive_overflow_infinity (TREE_TYPE (res)) -- : TYPE_MAX_VALUE (TREE_TYPE (res))); -+ : vrp_val_max (TREE_TYPE (res))); - else - return (needs_overflow_infinity (TREE_TYPE (res)) - ? negative_overflow_infinity (TREE_TYPE (res)) -- : TYPE_MIN_VALUE (TREE_TYPE (res))); -+ : vrp_val_min (TREE_TYPE (res))); - } - - return res; -@@ -2750,8 +2750,8 @@ - && TYPE_PRECISION (inner_type) < TYPE_PRECISION (outer_type)) - { - vr0.type = VR_RANGE; -- vr0.min = TYPE_MIN_VALUE (inner_type); -- vr0.max = TYPE_MAX_VALUE (inner_type); -+ vr0.min = vrp_val_min (inner_type); -+ vr0.max = vrp_val_max (inner_type); - } - - /* If VR0 is a constant range or anti-range and the conversion is -@@ -2836,7 +2836,7 @@ - } - } - else -- min = TYPE_MIN_VALUE (type); -+ min = vrp_val_min (type); - - if (is_positive_overflow_infinity (vr0.min)) - max = negative_overflow_infinity (type); -@@ -2855,7 +2855,7 @@ - } - } - else -- max = TYPE_MIN_VALUE (type); -+ max = vrp_val_min (type); - } - else if (code == NEGATE_EXPR - && TYPE_UNSIGNED (type)) -@@ -2897,7 +2897,7 @@ - else if (!vrp_val_is_min (vr0.min)) - min = fold_unary_to_constant (code, type, vr0.min); - else if (!needs_overflow_infinity (type)) -- min = TYPE_MAX_VALUE (type); -+ min = vrp_val_max (type); - else if (supports_overflow_infinity (type)) - min = positive_overflow_infinity (type); - else -@@ -2911,7 +2911,7 @@ - else if (!vrp_val_is_min (vr0.max)) - max = fold_unary_to_constant (code, type, vr0.max); - else if (!needs_overflow_infinity (type)) -- max = TYPE_MAX_VALUE (type); -+ max = vrp_val_max (type); - else if (supports_overflow_infinity (type) - /* We shouldn't generate [+INF, +INF] as set_value_range - doesn't like this and ICEs. */ -@@ -2941,7 +2941,7 @@ - TYPE_MIN_VALUE, remember -TYPE_MIN_VALUE = TYPE_MIN_VALUE. */ - if (TYPE_OVERFLOW_WRAPS (type)) - { -- tree type_min_value = TYPE_MIN_VALUE (type); -+ tree type_min_value = vrp_val_min (type); - - min = (vr0.min != type_min_value - ? int_const_binop (PLUS_EXPR, type_min_value, -@@ -2953,7 +2953,7 @@ - if (overflow_infinity_range_p (&vr0)) - min = negative_overflow_infinity (type); - else -- min = TYPE_MIN_VALUE (type); -+ min = vrp_val_min (type); - } - } - else -@@ -2974,7 +2974,7 @@ - } - } - else -- max = TYPE_MAX_VALUE (type); -+ max = vrp_val_max (type); - } - } - -@@ -3258,11 +3258,11 @@ - if (POINTER_TYPE_P (type) || !TYPE_MIN_VALUE (type)) - tmin = lower_bound_in_type (type, type); - else -- tmin = TYPE_MIN_VALUE (type); -+ tmin = vrp_val_min (type); - if (POINTER_TYPE_P (type) || !TYPE_MAX_VALUE (type)) - tmax = upper_bound_in_type (type, type); - else -- tmax = TYPE_MAX_VALUE (type); -+ tmax = vrp_val_max (type); - - if (vr->type == VR_VARYING || vr->type == VR_UNDEFINED) - { -@@ -4146,8 +4146,8 @@ - if ((comp_code == GT_EXPR || comp_code == LT_EXPR) - && INTEGRAL_TYPE_P (TREE_TYPE (val))) - { -- tree min = TYPE_MIN_VALUE (TREE_TYPE (val)); -- tree max = TYPE_MAX_VALUE (TREE_TYPE (val)); -+ tree min = vrp_val_min (TREE_TYPE (val)); -+ tree max = vrp_val_max (TREE_TYPE (val)); - - if (comp_code == GT_EXPR - && (!max -@@ -6426,13 +6426,13 @@ - VARYING. Same if the previous max value was invalid for - the type and we'd end up with vr_result.min > vr_result.max. */ - if (vrp_val_is_max (vr_result.max) -- || compare_values (TYPE_MIN_VALUE (TREE_TYPE (vr_result.min)), -+ || compare_values (vrp_val_min (TREE_TYPE (vr_result.min)), - vr_result.max) > 0) - goto varying; - - if (!needs_overflow_infinity (TREE_TYPE (vr_result.min)) - || !vrp_var_may_overflow (lhs, phi)) -- vr_result.min = TYPE_MIN_VALUE (TREE_TYPE (vr_result.min)); -+ vr_result.min = vrp_val_min (TREE_TYPE (vr_result.min)); - else if (supports_overflow_infinity (TREE_TYPE (vr_result.min))) - vr_result.min = - negative_overflow_infinity (TREE_TYPE (vr_result.min)); -@@ -6448,13 +6448,13 @@ - VARYING. Same if the previous min value was invalid for - the type and we'd end up with vr_result.max < vr_result.min. */ - if (vrp_val_is_min (vr_result.min) -- || compare_values (TYPE_MAX_VALUE (TREE_TYPE (vr_result.max)), -+ || compare_values (vrp_val_max (TREE_TYPE (vr_result.max)), - vr_result.min) < 0) - goto varying; - - if (!needs_overflow_infinity (TREE_TYPE (vr_result.max)) - || !vrp_var_may_overflow (lhs, phi)) -- vr_result.max = TYPE_MAX_VALUE (TREE_TYPE (vr_result.max)); -+ vr_result.max = vrp_val_max (TREE_TYPE (vr_result.max)); - else if (supports_overflow_infinity (TREE_TYPE (vr_result.max))) - vr_result.max = - positive_overflow_infinity (TREE_TYPE (vr_result.max)); -@@ -6782,7 +6782,7 @@ - { - /* This should not be negative infinity; there is no overflow - here. */ -- min = TYPE_MIN_VALUE (TREE_TYPE (op0)); -+ min = vrp_val_min (TREE_TYPE (op0)); - - max = op1; - if (cond_code == LT_EXPR && !is_overflow_infinity (max)) -@@ -6797,7 +6797,7 @@ - { - /* This should not be positive infinity; there is no overflow - here. */ -- max = TYPE_MAX_VALUE (TREE_TYPE (op0)); -+ max = vrp_val_max (TREE_TYPE (op0)); - - min = op1; - if (cond_code == GT_EXPR && !is_overflow_infinity (min)) diff --git a/build/unix/build-toolchain/r159628-r163231-r171807.patch b/build/unix/build-toolchain/r159628-r163231-r171807.patch deleted file mode 100644 index b8ea2f1481b4..000000000000 --- a/build/unix/build-toolchain/r159628-r163231-r171807.patch +++ /dev/null @@ -1,98 +0,0 @@ -diff -ru gcc-4.5.2/libstdc++-v3/include/bits/stl_pair.h gcc-4.5.2-new/libstdc++-v3/include/bits/stl_pair.h ---- gcc-4.5.2/libstdc++-v3/include/bits/stl_pair.h 2010-06-10 06:26:14.000000000 -0400 -+++ gcc-4.5.2-new/libstdc++-v3/include/bits/stl_pair.h 2011-11-29 10:25:51.203597393 -0500 -@@ -88,6 +88,8 @@ - : first(__a), second(__b) { } - - #ifdef __GXX_EXPERIMENTAL_CXX0X__ -+ pair(const pair&) = default; -+ - // DR 811. - template::value>::type> -@@ -131,6 +133,15 @@ - - template - pair& -+ operator=(const pair<_U1, _U2>& __p) -+ { -+ first = __p.first; -+ second = __p.second; -+ return *this; -+ } -+ -+ template -+ pair& - operator=(pair<_U1, _U2>&& __p) - { - first = std::move(__p.first); -diff -ru gcc-4.5.2/libstdc++-v3/include/bits/stl_queue.h gcc-4.5.2-new/libstdc++-v3/include/bits/stl_queue.h ---- gcc-4.5.2/libstdc++-v3/include/bits/stl_queue.h 2010-02-04 13:20:34.000000000 -0500 -+++ gcc-4.5.2-new/libstdc++-v3/include/bits/stl_queue.h 2011-11-29 10:26:22.511695475 -0500 -@@ -1,6 +1,6 @@ - // Queue implementation -*- C++ -*- - --// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 - // Free Software Foundation, Inc. - // - // This file is part of the GNU ISO C++ Library. This library is free -@@ -137,16 +137,6 @@ - explicit - queue(_Sequence&& __c = _Sequence()) - : c(std::move(__c)) { } -- -- queue(queue&& __q) -- : c(std::move(__q.c)) { } -- -- queue& -- operator=(queue&& __q) -- { -- c = std::move(__q.c); -- return *this; -- } - #endif - - /** -@@ -451,17 +441,6 @@ - c.insert(c.end(), __first, __last); - std::make_heap(c.begin(), c.end(), comp); - } -- -- priority_queue(priority_queue&& __pq) -- : c(std::move(__pq.c)), comp(std::move(__pq.comp)) { } -- -- priority_queue& -- operator=(priority_queue&& __pq) -- { -- c = std::move(__pq.c); -- comp = std::move(__pq.comp); -- return *this; -- } - #endif - - /** -diff -ru gcc-4.5.2/libstdc++-v3/libsupc++/exception_ptr.h gcc-4.5.2-new/libstdc++-v3/libsupc++/exception_ptr.h ---- gcc-4.5.2/libstdc++-v3/libsupc++/exception_ptr.h 2009-11-09 17:09:30.000000000 -0500 -+++ gcc-4.5.2-new/libstdc++-v3/libsupc++/exception_ptr.h 2011-11-29 10:26:10.878659023 -0500 -@@ -129,7 +129,7 @@ - operator==(const exception_ptr&, const exception_ptr&) throw() - __attribute__ ((__pure__)); - -- const type_info* -+ const class type_info* - __cxa_exception_type() const throw() __attribute__ ((__pure__)); - }; - -diff -ru gcc-4.5.2/libstdc++-v3/libsupc++/nested_exception.h gcc-4.5.2-new/libstdc++-v3/libsupc++/nested_exception.h ---- gcc-4.5.2/libstdc++-v3/libsupc++/nested_exception.h 2010-02-18 12:20:16.000000000 -0500 -+++ gcc-4.5.2-new/libstdc++-v3/libsupc++/nested_exception.h 2011-11-29 10:26:10.879659026 -0500 -@@ -119,7 +119,7 @@ - // with a type that has an accessible nested_exception base. - template - inline void -- __throw_with_nested(_Ex&& __ex, const nested_exception* = 0) -+ __throw_with_nested(_Ex&& __ex, const nested_exception*) - { throw __ex; } - - template From c52ddd0b8bf55f8d619a47bee94b39e7e01ce016 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Thu, 31 Oct 2013 17:49:37 -0500 Subject: [PATCH 035/795] Bug 932880 - Fix a bunch of devtools test leaks. r=past --- browser/devtools/framework/target.js | 1 + browser/devtools/inspector/inspector-panel.js | 2 + .../browser_inspector_basic_highlighter.js | 1 + .../browser_inspector_select_last_selected.js | 40 ++++++++----------- .../test/browser_inspector_sidebarstate.js | 6 +-- .../test/browser_inspector_markup_subset.js | 2 +- browser/devtools/scratchpad/scratchpad.js | 1 + browser/devtools/scratchpad/test/browser.ini | 5 ++- browser/devtools/styleinspector/rule-view.js | 2 + .../browser_bug722691_rule_view_increment.js | 2 +- .../test/browser_ruleview_copy.js | 2 +- .../test/browser_ruleview_inherit.js | 2 +- .../test/browser_ruleview_override.js | 2 +- .../test/browser_ruleview_pseudoelement.js | 2 +- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/browser/devtools/framework/target.js b/browser/devtools/framework/target.js index eb81d5be0cd0..a417c22334a5 100644 --- a/browser/devtools/framework/target.js +++ b/browser/devtools/framework/target.js @@ -443,6 +443,7 @@ TabTarget.prototype = { if (this._inspector) { this._inspector.destroy(); + this._inspector = null; } // First of all, do cleanup tasks that pertain to both remoted and diff --git a/browser/devtools/inspector/inspector-panel.js b/browser/devtools/inspector/inspector-panel.js index 5c6f4ab06d70..e612b7ff8d44 100644 --- a/browser/devtools/inspector/inspector-panel.js +++ b/browser/devtools/inspector/inspector-panel.js @@ -675,6 +675,8 @@ InspectorPanel.prototype = { this._markupFrame.parentNode.removeChild(this._markupFrame); delete this._markupFrame; } + + this._markupBox = null; }, /** diff --git a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js index 2817383d42b3..c0bfa84276fb 100644 --- a/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js +++ b/browser/devtools/inspector/test/browser_inspector_basic_highlighter.js @@ -84,6 +84,7 @@ function test() { function finishUp() { let h = require("devtools/inspector/highlighter"); h._forceBasic.value = false; + inspector = doc = null; gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/inspector/test/browser_inspector_select_last_selected.js b/browser/devtools/inspector/test/browser_inspector_select_last_selected.js index 5299da7063e4..6a3a779bee9e 100644 --- a/browser/devtools/inspector/test/browser_inspector_select_last_selected.js +++ b/browser/devtools/inspector/test/browser_inspector_select_last_selected.js @@ -30,8 +30,9 @@ function test() { } function endTests() { - executeSoon(() => { - toolbox.destroy(); + inspector.destroy().then(() => + toolbox.destroy() + ).then(() => { toolbox = inspector = page1 = page2 = null; gBrowser.removeCurrentTab(); finish(); @@ -40,7 +41,7 @@ function test() { function loadPageAnd(page, callback) { inspector.once("markuploaded", () => { - executeSoon(callback); + callback(); }); if (page) { @@ -58,7 +59,7 @@ function test() { loadPageAnd(false, () => { is(inspector.selection.node.id, id, "Node re-selected after reload"); - executeSoon(callback); + callback(); }); }); @@ -85,14 +86,12 @@ function test() { // Last node selected was id4, go to a different page and check body is // selected loadPageAnd(page2, () => { - executeSoon(() => { - is( - inspector.selection.node.tagName.toLowerCase(), - "body", - "Node not found, body selected" - ); - executeSoon(testSameNodeSelectedOnNavigateAwayAndBack); - }); + is( + inspector.selection.node.tagName.toLowerCase(), + "body", + "Node not found, body selected" + ); + testSameNodeSelectedOnNavigateAwayAndBack(); }); } @@ -106,17 +105,12 @@ function test() { inspector.once("inspector-updated", () => { is(inspector.selection.node.id, id); - executeSoon(() => { - // go to page1 but do not select anything - loadPageAnd(page1, () => { - - executeSoon(() => { - // go back to page2 and check id5 is still the current selection - loadPageAnd(page2, () => { - is(inspector.selection.node.id, id, "Node re-selected after navigation"); - executeSoon(endTests); - }); - }); + // go to page1 but do not select anything + loadPageAnd(page1, () => { + // go back to page2 and check id5 is still the current selection + loadPageAnd(page2, () => { + is(inspector.selection.node.id, id, "Node re-selected after navigation"); + endTests(); }); }); }); diff --git a/browser/devtools/inspector/test/browser_inspector_sidebarstate.js b/browser/devtools/inspector/test/browser_inspector_sidebarstate.js index ae4f2b561122..09acfad3b150 100644 --- a/browser/devtools/inspector/test/browser_inspector_sidebarstate.js +++ b/browser/devtools/inspector/test/browser_inspector_sidebarstate.js @@ -25,10 +25,7 @@ function inspectorRuleViewOpened() gDevTools.once("toolbox-destroyed", inspectorClosed); let target = TargetFactory.forTab(gBrowser.selectedTab); - let toolbox = gDevTools.getToolbox(target); - executeSoon(function() { - toolbox.destroy(); - }); + gDevTools.getToolbox(target).destroy(); } function inspectorClosed() @@ -55,6 +52,7 @@ function testNewDefaultTab() function finishTest() { + doc = inspector = null; gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/markupview/test/browser_inspector_markup_subset.js b/browser/devtools/markupview/test/browser_inspector_markup_subset.js index e9fee61a069e..f7a0eef14e83 100644 --- a/browser/devtools/markupview/test/browser_inspector_markup_subset.js +++ b/browser/devtools/markupview/test/browser_inspector_markup_subset.js @@ -140,7 +140,7 @@ function test() { } function finishUp() { - doc = inspector = null; + doc = inspector = markup = null; gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index 48b54004c494..b4f330f52730 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -1350,6 +1350,7 @@ var Scratchpad = { } PreferenceObserver.uninit(); + CloseObserver.uninit(); this.editor.off("change", this._onChanged); this.editor.destroy(); diff --git a/browser/devtools/scratchpad/test/browser.ini b/browser/devtools/scratchpad/test/browser.ini index 2e686bb020a3..d8df071595ba 100644 --- a/browser/devtools/scratchpad/test/browser.ini +++ b/browser/devtools/scratchpad/test/browser.ini @@ -28,8 +28,9 @@ support-files = head.js [browser_scratchpad_long_string.js] [browser_scratchpad_open.js] [browser_scratchpad_open_error_console.js] -[browser_scratchpad_pprint-02.js] -[browser_scratchpad_pprint.js] +# Disabled, as escodegen is being replaced - bug 930141 +# [browser_scratchpad_pprint-02.js] +# [browser_scratchpad_pprint.js] [browser_scratchpad_restore.js] [browser_scratchpad_tab_switch.js] [browser_scratchpad_ui.js] diff --git a/browser/devtools/styleinspector/rule-view.js b/browser/devtools/styleinspector/rule-view.js index d84862a96e1d..14e5f29027db 100644 --- a/browser/devtools/styleinspector/rule-view.js +++ b/browser/devtools/styleinspector/rule-view.js @@ -75,6 +75,7 @@ function createDummyDocument() { eventTarget.addEventListener("DOMContentLoaded", function handler(event) { eventTarget.removeEventListener("DOMContentLoaded", handler, false); deferred.resolve(window.document); + frame.remove(); }, false); gDummyPromise = deferred.promise; return gDummyPromise; @@ -1251,6 +1252,7 @@ CssRuleView.prototype = { { this.clear(); + gDummyPromise = null; gDevTools.off("pref-changed", this._handlePrefChange); this.element.removeEventListener("copy", this._onCopy); diff --git a/browser/devtools/styleinspector/test/browser_bug722691_rule_view_increment.js b/browser/devtools/styleinspector/test/browser_bug722691_rule_view_increment.js index 48ea679ff81f..76aca3098767 100644 --- a/browser/devtools/styleinspector/test/browser_bug722691_rule_view_increment.js +++ b/browser/devtools/styleinspector/test/browser_bug722691_rule_view_increment.js @@ -174,7 +174,7 @@ function testIncrement( aEditor, aOptions ) function finishTest() { - doc = null; + doc = view = inspector = null; gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_copy.js b/browser/devtools/styleinspector/test/browser_ruleview_copy.js index f7e5e7e2ed2a..f4872aaaaf25 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_copy.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_copy.js @@ -150,7 +150,7 @@ function failedClipboard(aExpectedPattern, aCallback) function finishup() { gBrowser.removeCurrentTab(); - doc = inspector = null; + doc = inspector = win = null; finish(); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_inherit.js b/browser/devtools/styleinspector/test/browser_ruleview_inherit.js index 04b8b0bd1440..e0ce0307d9e6 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_inherit.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_inherit.js @@ -97,7 +97,7 @@ function elementStyleInherit() function finishTest() { - doc = null; + doc = inspector = view = null; gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_override.js b/browser/devtools/styleinspector/test/browser_ruleview_override.js index 0e6be1ac791c..d8a00861aa04 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_override.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_override.js @@ -159,7 +159,7 @@ function disableOverride() function finishTest() { - doc = null; + doc = inspector = view = null; gBrowser.removeCurrentTab(); finish(); } diff --git a/browser/devtools/styleinspector/test/browser_ruleview_pseudoelement.js b/browser/devtools/styleinspector/test/browser_ruleview_pseudoelement.js index daee7ddf4b64..ca93550015e4 100644 --- a/browser/devtools/styleinspector/test/browser_ruleview_pseudoelement.js +++ b/browser/devtools/styleinspector/test/browser_ruleview_pseudoelement.js @@ -301,7 +301,7 @@ function testNode(node, cb) function finishTest() { - doc = null; + doc = inspector = view = null; gBrowser.removeCurrentTab(); finish(); } From ce3e3352061d5841e3840e8cbe7a6256dfda276f Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:02 -0700 Subject: [PATCH 036/795] Bug 903880 part 1: Create a helper-function to set a flex item's base size (and update its hypothetical main size). r=dbaron --- layout/generic/nsFlexContainerFrame.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 047bc9e2aac8..3a6c00f18bb9 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -368,6 +368,20 @@ public: // Setters // ======= + // This sets our flex base size, and then updates the main size to the + // base size clamped to our main-axis [min,max] constraints. + void SetFlexBaseSizeAndMainSize(nscoord aNewFlexBaseSize) + { + MOZ_ASSERT(!mIsFrozen, + "flex base size shouldn't change after we're frozen"); + mFlexBaseSize = aNewFlexBaseSize; + + // Before we've resolved flexible lengths, we keep mMainSize set to + // the 'hypothetical main size', which is the flex base size, clamped + // to the [min,max] range: + mMainSize = NS_CSS_MINMAX(mFlexBaseSize, mMainMinSize, mMainMaxSize); + } + // Setters used while we're resolving flexible lengths // --------------------------------------------------- @@ -463,7 +477,7 @@ protected: const nsMargin mBorderPadding; nsMargin mMargin; // non-const because we need to resolve auto margins - const nscoord mFlexBaseSize; + nscoord mFlexBaseSize; const nscoord mMainMinSize; const nscoord mMainMaxSize; @@ -847,14 +861,10 @@ FlexItem::FlexItem(nsIFrame* aChildFrame, mFlexShrink(aFlexShrink), mBorderPadding(aBorderPadding), mMargin(aMargin), - mFlexBaseSize(aFlexBaseSize), mMainMinSize(aMainMinSize), mMainMaxSize(aMainMaxSize), mCrossMinSize(aCrossMinSize), mCrossMaxSize(aCrossMaxSize), - // Init main-size to 'hypothetical main size', which is flex base size - // clamped to [min,max] range: - mMainSize(NS_CSS_MINMAX(aFlexBaseSize, aMainMinSize, aMainMaxSize)), mMainPosn(0), mCrossSize(0), mCrossPosn(0), @@ -869,6 +879,8 @@ FlexItem::FlexItem(nsIFrame* aChildFrame, { MOZ_ASSERT(aChildFrame, "expecting a non-null child frame"); + SetFlexBaseSizeAndMainSize(aFlexBaseSize); + // Assert that any "auto" margin components are set to 0. // (We'll resolve them later; until then, we want to treat them as 0-sized.) #ifdef DEBUG From 086b60b963401b47394f73922959c1d25b2a7248 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:02 -0700 Subject: [PATCH 037/795] Bug 903880 part 2: Resolve the flex base size produced by "height:auto" *after* we create a FlexItem object. r=dbaron --- layout/generic/nsFlexContainerFrame.cpp | 188 +++++++++++++----------- layout/generic/nsFlexContainerFrame.h | 19 ++- 2 files changed, 112 insertions(+), 95 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 3a6c00f18bb9..22f0284adb91 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -372,8 +372,9 @@ public: // base size clamped to our main-axis [min,max] constraints. void SetFlexBaseSizeAndMainSize(nscoord aNewFlexBaseSize) { - MOZ_ASSERT(!mIsFrozen, - "flex base size shouldn't change after we're frozen"); + MOZ_ASSERT(!mIsFrozen || mFlexBaseSize == NS_INTRINSICSIZE, + "flex base size shouldn't change after we're frozen " + "(unless we're just resolving an intrinsic size)"); mFlexBaseSize = aNewFlexBaseSize; // Before we've resolved flexible lengths, we keep mMainSize set to @@ -670,13 +671,12 @@ nsFlexContainerFrame::IsHorizontal() return IsAxisHorizontal(axisTracker.GetMainAxis()); } -nsresult -nsFlexContainerFrame::AppendFlexItemForChild( +FlexItem +nsFlexContainerFrame::GenerateFlexItemForChild( nsPresContext* aPresContext, nsIFrame* aChildFrame, const nsHTMLReflowState& aParentReflowState, - const FlexboxAxisTracker& aAxisTracker, - nsTArray& aFlexItems) + const FlexboxAxisTracker& aAxisTracker) { // Create temporary reflow state just for sizing -- to get hypothetical // main-size and the computed values of min / max main-size property. @@ -705,72 +705,6 @@ nsFlexContainerFrame::AppendFlexItemForChild( // This is enforced by the nsHTMLReflowState where these values come from: MOZ_ASSERT(mainMinSize <= mainMaxSize, "min size is larger than max size"); - // SPECIAL MAIN-SIZING FOR VERTICAL FLEX CONTAINERS - // If we're vertical and our main size ended up being unconstrained - // (e.g. because we had height:auto), we need to instead use our - // "max-content" height, which is what we get from reflowing into our - // available width. - bool needToMeasureMaxContentHeight = false; - if (!IsAxisHorizontal(aAxisTracker.GetMainAxis())) { - // NOTE: If & when we handle "min-height: min-content" for flex items, - // this is probably the spot where we'll want to resolve it to the - // actual intrinsic height given our computed width. It'll be the same - // auto-height that we determine here. - needToMeasureMaxContentHeight = (NS_AUTOHEIGHT == flexBaseSize); - - if (needToMeasureMaxContentHeight) { - // Give the item a special reflow with "mIsFlexContainerMeasuringHeight" - // set. This tells it to behave as if it had "height: auto", regardless - // of what the "height" property is actually set to. - nsHTMLReflowState - childRSForMeasuringHeight(aPresContext, aParentReflowState, - aChildFrame, - nsSize(aParentReflowState.ComputedWidth(), - NS_UNCONSTRAINEDSIZE), - -1, -1, nsHTMLReflowState::CALLER_WILL_INIT); - childRSForMeasuringHeight.mFlags.mIsFlexContainerMeasuringHeight = true; - childRSForMeasuringHeight.Init(aPresContext); - - // If this item is flexible (vertically), then we assume that the - // computed-height we're reflowing with now could be different - // from the one we'll use for this flex item's "actual" reflow later on. - // In that case, we need to be sure the flex item treats this as a - // vertical resize, even though none of its ancestors are necessarily - // being vertically resized. - // (Note: We don't have to do this for width, because InitResizeFlags - // will always turn on mHResize on when it sees that the computed width - // is different from current width, and that's all we need.) - if (flexGrow != 0.0f || flexShrink != 0.0f) { // Are we flexible? - childRSForMeasuringHeight.mFlags.mVResize = true; - } - - nsHTMLReflowMetrics childDesiredSize; - nsReflowStatus childReflowStatus; - nsresult rv = ReflowChild(aChildFrame, aPresContext, - childDesiredSize, childRSForMeasuringHeight, - 0, 0, NS_FRAME_NO_MOVE_FRAME, - childReflowStatus); - NS_ENSURE_SUCCESS(rv, rv); - - MOZ_ASSERT(NS_FRAME_IS_COMPLETE(childReflowStatus), - "We gave flex item unconstrained available height, so it " - "should be complete"); - - rv = FinishReflowChild(aChildFrame, aPresContext, - &childRSForMeasuringHeight, childDesiredSize, - 0, 0, 0); - NS_ENSURE_SUCCESS(rv, rv); - - // Subtract border/padding in vertical axis, to get _just_ - // the effective computed value of the "height" property. - nscoord childDesiredHeight = childDesiredSize.height - - childRS.mComputedBorderPadding.TopBottom(); - childDesiredHeight = std::max(0, childDesiredHeight); - - flexBaseSize = childDesiredHeight; - } - } - // CROSS MIN/MAX SIZE // ------------------ @@ -826,27 +760,104 @@ nsFlexContainerFrame::AppendFlexItemForChild( } } - aFlexItems.AppendElement(FlexItem(aChildFrame, - flexGrow, flexShrink, flexBaseSize, - mainMinSize, mainMaxSize, - crossMinSize, crossMaxSize, - childRS.mComputedMargin, - childRS.mComputedBorderPadding, - aAxisTracker)); + // Construct the flex item! + FlexItem item(aChildFrame, + flexGrow, flexShrink, flexBaseSize, + mainMinSize, mainMaxSize, + crossMinSize, crossMaxSize, + childRS.mComputedMargin, + childRS.mComputedBorderPadding, + aAxisTracker); // If we're inflexible, we can just freeze to our hypothetical main-size // up-front. Similarly, if we're a fixed-size widget, we only have one // valid size, so we freeze to keep ourselves from flexing. if (isFixedSizeWidget || (flexGrow == 0.0f && flexShrink == 0.0f)) { - aFlexItems.LastElement().Freeze(); + item.Freeze(); } - // If we did a height-measuring reflow for this flex item, make a note of - // that, so our "actual" reflow can set resize flags accordingly. - if (needToMeasureMaxContentHeight) { - aFlexItems.LastElement().SetHadMeasuringReflow(); + return item; +} + +nsresult +nsFlexContainerFrame:: + ResolveFlexItemMaxContentSizing(nsPresContext* aPresContext, + FlexItem& aFlexItem, + const nsHTMLReflowState& aParentReflowState, + const FlexboxAxisTracker& aAxisTracker) +{ + if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) { + // Nothing to do -- this function is only for measuring flex items + // in a vertical flex container. + return NS_OK; } + if (NS_AUTOHEIGHT != aFlexItem.GetFlexBaseSize()) { + // Nothing to do; this function's only relevant for flex items + // with a base size of "auto" (or equivalent). + // XXXdholbert If & when we handle "min-height: min-content" for flex items, + // we'll want to resolve that in this function, too. + return NS_OK; + } + + // If we get here, we're vertical and our main size ended up being + // unconstrained. We need to use our "max-content" height, which is what we + // get from reflowing into our available width. + // Note: This has to come *after* we construct the FlexItem, since we + // invoke at least one convenience method (ResolveStretchedCrossSize) which + // requires a FlexItem. + + // Give the item a special reflow with "mIsFlexContainerMeasuringHeight" + // set. This tells it to behave as if it had "height: auto", regardless + // of what the "height" property is actually set to. + nsHTMLReflowState + childRSForMeasuringHeight(aPresContext, aParentReflowState, + aFlexItem.Frame(), + nsSize(aParentReflowState.ComputedWidth(), + NS_UNCONSTRAINEDSIZE), + -1, -1, nsHTMLReflowState::CALLER_WILL_INIT); + childRSForMeasuringHeight.mFlags.mIsFlexContainerMeasuringHeight = true; + childRSForMeasuringHeight.Init(aPresContext); + + // If this item is flexible (vertically), then we assume that the + // computed-height we're reflowing with now could be different + // from the one we'll use for this flex item's "actual" reflow later on. + // In that case, we need to be sure the flex item treats this as a + // vertical resize, even though none of its ancestors are necessarily + // being vertically resized. + // (Note: We don't have to do this for width, because InitResizeFlags + // will always turn on mHResize on when it sees that the computed width + // is different from current width, and that's all we need.) + if (!aFlexItem.IsFrozen()) { // Are we flexible? + childRSForMeasuringHeight.mFlags.mVResize = true; + } + + nsHTMLReflowMetrics childDesiredSize; + nsReflowStatus childReflowStatus; + nsresult rv = ReflowChild(aFlexItem.Frame(), aPresContext, + childDesiredSize, childRSForMeasuringHeight, + 0, 0, NS_FRAME_NO_MOVE_FRAME, + childReflowStatus); + NS_ENSURE_SUCCESS(rv, rv); + + MOZ_ASSERT(NS_FRAME_IS_COMPLETE(childReflowStatus), + "We gave flex item unconstrained available height, so it " + "should be complete"); + + rv = FinishReflowChild(aFlexItem.Frame(), aPresContext, + &childRSForMeasuringHeight, childDesiredSize, + 0, 0, 0); + NS_ENSURE_SUCCESS(rv, rv); + + // Subtract border/padding in vertical axis, to get _just_ + // the effective computed value of the "height" property. + nscoord childDesiredHeight = childDesiredSize.height - + childRSForMeasuringHeight.mComputedBorderPadding.TopBottom(); + childDesiredHeight = std::max(0, childDesiredHeight); + + aFlexItem.SetFlexBaseSizeAndMainSize(childDesiredHeight); + aFlexItem.SetHadMeasuringReflow(); + return NS_OK; } @@ -1947,9 +1958,12 @@ nsFlexContainerFrame::GenerateFlexItems( // list, so we can easily split into multiple lines. aFlexItems.SetCapacity(mFrames.GetLength()); for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) { - nsresult rv = AppendFlexItemForChild(aPresContext, e.get(), - aReflowState, aAxisTracker, - aFlexItems); + FlexItem* item = aFlexItems.AppendElement( + GenerateFlexItemForChild(aPresContext, e.get(), + aReflowState, aAxisTracker)); + + nsresult rv = ResolveFlexItemMaxContentSizing(aPresContext, *item, + aReflowState, aAxisTracker); NS_ENSURE_SUCCESS(rv,rv); } diff --git a/layout/generic/nsFlexContainerFrame.h b/layout/generic/nsFlexContainerFrame.h index aa372f308259..a4922657a9be 100644 --- a/layout/generic/nsFlexContainerFrame.h +++ b/layout/generic/nsFlexContainerFrame.h @@ -80,15 +80,18 @@ protected: void SanityCheckAnonymousFlexItems() const; #endif // DEBUG + FlexItem GenerateFlexItemForChild(nsPresContext* aPresContext, + nsIFrame* aChildFrame, + const nsHTMLReflowState& aParentReflowState, + const FlexboxAxisTracker& aAxisTracker); - // Returns nsresult because we might have to reflow aChildFrame (to get its - // vertical intrinsic size in a vertical flexbox), and if that reflow fails - // (returns a failure nsresult), we want to bail out. - nsresult AppendFlexItemForChild(nsPresContext* aPresContext, - nsIFrame* aChildFrame, - const nsHTMLReflowState& aParentReflowState, - const FlexboxAxisTracker& aAxisTracker, - nsTArray& aFlexItems); + // Returns nsresult because we might have to reflow aFlexItem.Frame() (to + // get its vertical intrinsic size in a vertical flexbox), and if that + // reflow fails (returns a failure nsresult), we want to bail out. + nsresult ResolveFlexItemMaxContentSizing(nsPresContext* aPresContext, + FlexItem& aFlexItem, + const nsHTMLReflowState& aParentReflowState, + const FlexboxAxisTracker& aAxisTracker); // Runs the "resolve the flexible lengths" algorithm, distributing // |aFlexContainerMainSize| among the |aItems| and freezing them. From 7e3931a5e32cb7c81855ab3c10d437f4b48910eb Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:02 -0700 Subject: [PATCH 038/795] Bug 903880 part 3: Convert "ResolveStretchedSize" into a member-function on FlexItem. r=dbaron --- layout/generic/nsFlexContainerFrame.cpp | 43 +++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 22f0284adb91..5d350e18f745 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -465,6 +465,9 @@ public: MarginComponentForSide(mMargin, aSide) = aLength; } + void ResolveStretchedCrossSize(nscoord aLineCrossSize, + const FlexboxAxisTracker& aAxisTracker); + uint32_t GetNumAutoMarginsInAxis(AxisOrientationType aAxis) const; protected: @@ -1083,7 +1086,6 @@ public: mLineCrossSize = aNewLineCrossSize; } - void ResolveStretchedCrossSize(FlexItem& aItem); void ResolveAutoMarginsInCrossAxis(FlexItem& aItem); void EnterAlignPackingSpace(const FlexItem& aItem); @@ -1758,32 +1760,36 @@ SingleLineCrossAxisPositionTracker:: } void -SingleLineCrossAxisPositionTracker:: - ResolveStretchedCrossSize(FlexItem& aItem) +FlexItem::ResolveStretchedCrossSize(nscoord aLineCrossSize, + const FlexboxAxisTracker& aAxisTracker) { + AxisOrientationType crossAxis = aAxisTracker.GetCrossAxis(); // We stretch IFF we are align-self:stretch, have no auto margins in // cross axis, and have cross-axis size property == "auto". If any of those - // conditions don't hold up, we can just return. - if (aItem.GetAlignSelf() != NS_STYLE_ALIGN_ITEMS_STRETCH || - aItem.GetNumAutoMarginsInAxis(mAxis) != 0 || - GetSizePropertyForAxis(aItem.Frame(), mAxis).GetUnit() != - eStyleUnit_Auto) { + // conditions don't hold up, we won't stretch. + if (mAlignSelf != NS_STYLE_ALIGN_ITEMS_STRETCH || + GetNumAutoMarginsInAxis(crossAxis) != 0 || + eStyleUnit_Auto != GetSizePropertyForAxis(mFrame, crossAxis).GetUnit()) { + return; + } + + // If we've already been stretched, we can bail out early, too. + // No need to redo the calculation. + if (mIsStretched) { return; } // Reserve space for margins & border & padding, and then use whatever // remains as our item's cross-size (clamped to its min/max range). - nscoord stretchedSize = mLineCrossSize - - aItem.GetMarginBorderPaddingSizeInAxis(mAxis); + nscoord stretchedSize = aLineCrossSize - + GetMarginBorderPaddingSizeInAxis(crossAxis); - stretchedSize = NS_CSS_MINMAX(stretchedSize, - aItem.GetCrossMinSize(), - aItem.GetCrossMaxSize()); + stretchedSize = NS_CSS_MINMAX(stretchedSize, mCrossMinSize, mCrossMaxSize); // Update the cross-size & make a note that it's stretched, so we know to // override the reflow state's computed cross-size in our final reflow. - aItem.SetCrossSize(stretchedSize); - aItem.SetIsStretched(); + SetCrossSize(stretchedSize); + mIsStretched = true; } void @@ -2141,8 +2147,6 @@ nsFlexContainerFrame::PositionItemInCrossAxis( MOZ_ASSERT(aLineCrossAxisPosnTracker.GetPosition() == 0, "per-line cross-axis position tracker wasn't correctly reset"); - // Resolve any to-be-stretched cross-sizes & auto margins in cross axis. - aLineCrossAxisPosnTracker.ResolveStretchedCrossSize(aItem); aLineCrossAxisPosnTracker.ResolveAutoMarginsInCrossAxis(aItem); // Compute the cross-axis position of this item @@ -2321,6 +2325,11 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, // Cross-Axis Alignment - Flexbox spec section 9.6 // =============================================== for (uint32_t i = 0; i < items.Length(); ++i) { + // Resolve stretched cross-size, if appropriate + nscoord lineCrossSize = lineCrossAxisPosnTracker.GetLineCrossSize(); + items[i].ResolveStretchedCrossSize(lineCrossSize, axisTracker); + + // ...and position. PositionItemInCrossAxis(crossAxisPosnTracker.GetPosition(), lineCrossAxisPosnTracker, items[i]); } From 5728c8148f077c3985bb5e822957e046c12c32f7 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:02 -0700 Subject: [PATCH 039/795] Bug 903880 part 4: Resolve stretched cross-size early, if we know the container's cross size, and use the result when establishing main size. r=dbaron --- layout/generic/nsFlexContainerFrame.cpp | 40 ++++++++++++++++--------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 5d350e18f745..2460f8156955 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -433,7 +433,8 @@ public: // Sets the cross-size of our flex item's content-box. void SetCrossSize(nscoord aCrossSize) { - MOZ_ASSERT(mIsFrozen, "main size should be resolved before this"); + MOZ_ASSERT(!mIsStretched, + "Cross size shouldn't be modified after it's been stretched"); mCrossSize = aCrossSize; } @@ -822,6 +823,13 @@ nsFlexContainerFrame:: childRSForMeasuringHeight.mFlags.mIsFlexContainerMeasuringHeight = true; childRSForMeasuringHeight.Init(aPresContext); + aFlexItem.ResolveStretchedCrossSize(aParentReflowState.ComputedWidth(), + aAxisTracker); + if (aFlexItem.IsStretched()) { + childRSForMeasuringHeight.SetComputedWidth(aFlexItem.GetCrossSize()); + childRSForMeasuringHeight.mFlags.mHResize = true; + } + // If this item is flexible (vertically), then we assume that the // computed-height we're reflowing with now could be different // from the one we'll use for this flex item's "actual" reflow later on. @@ -2239,20 +2247,24 @@ nsFlexContainerFrame::Reflow(nsPresContext* aPresContext, for (uint32_t i = 0; i < items.Length(); ++i) { FlexItem& curItem = items[i]; - nsHTMLReflowState childReflowState(aPresContext, aReflowState, - curItem.Frame(), - nsSize(aReflowState.ComputedWidth(), - NS_UNCONSTRAINEDSIZE)); - // Override computed main-size - if (IsAxisHorizontal(axisTracker.GetMainAxis())) { - childReflowState.SetComputedWidth(curItem.GetMainSize()); - } else { - childReflowState.SetComputedHeight(curItem.GetMainSize()); - } + // (If the item's already been stretched, then it already knows its + // cross size. Don't bother trying to recalculate it.) + if (!curItem.IsStretched()) { + nsHTMLReflowState childReflowState(aPresContext, aReflowState, + curItem.Frame(), + nsSize(aReflowState.ComputedWidth(), + NS_UNCONSTRAINEDSIZE)); + // Override computed main-size + if (IsAxisHorizontal(axisTracker.GetMainAxis())) { + childReflowState.SetComputedWidth(curItem.GetMainSize()); + } else { + childReflowState.SetComputedHeight(curItem.GetMainSize()); + } - nsresult rv = SizeItemInCrossAxis(aPresContext, axisTracker, - childReflowState, curItem); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = SizeItemInCrossAxis(aPresContext, axisTracker, + childReflowState, curItem); + NS_ENSURE_SUCCESS(rv, rv); + } } // Calculate the cross size of our (single) flex line: From e1fb391022ce241d0c891cbc97ca67574d6e5a3d Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:02 -0700 Subject: [PATCH 040/795] Bug 903880 part 5: Reftest. r=dbaron --- ...flexbox-align-self-stretch-vert-1-ref.html | 29 +++++++++++ .../flexbox-align-self-stretch-vert-1.html | 49 +++++++++++++++++++ .../w3c-css/submitted/flexbox/reftest.list | 2 + 3 files changed, 80 insertions(+) create mode 100644 layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1-ref.html create mode 100644 layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1.html diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1-ref.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1-ref.html new file mode 100644 index 000000000000..3ffa8647bb26 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1-ref.html @@ -0,0 +1,29 @@ + + + + + + CSS Reftest Reference + + + + + +
+ A B C +
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1.html new file mode 100644 index 000000000000..97500acfd7cc --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-align-self-stretch-vert-1.html @@ -0,0 +1,49 @@ + + + + + CSS Test: Testing the sizing of a stretched horizontal flex container in a vertical flex container + + + + + + + + + +
+
+
+
+
A B C
+
+
+
+
+
+ + diff --git a/layout/reftests/w3c-css/submitted/flexbox/reftest.list b/layout/reftests/w3c-css/submitted/flexbox/reftest.list index e8124b2233c3..f39632d3802b 100644 --- a/layout/reftests/w3c-css/submitted/flexbox/reftest.list +++ b/layout/reftests/w3c-css/submitted/flexbox/reftest.list @@ -1,6 +1,8 @@ # Tests for cross-axis alignment (align-self / align-items properties) == flexbox-align-self-baseline-horiz-1.xhtml flexbox-align-self-baseline-horiz-1-ref.xhtml +== flexbox-align-self-stretch-vert-1.html flexbox-align-self-stretch-vert-1-ref.html + == flexbox-align-self-horiz-1-block.xhtml flexbox-align-self-horiz-1-ref.xhtml == flexbox-align-self-horiz-1-table.xhtml flexbox-align-self-horiz-1-ref.xhtml == flexbox-align-self-horiz-2.xhtml flexbox-align-self-horiz-2-ref.xhtml From b0d4f38205c54f51f2712e925cddbd0e86212fcc Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Mon, 28 Oct 2013 22:08:36 -0700 Subject: [PATCH 041/795] Bug 932303: Mark parser/htmlparser/src as FAIL_ON_WARNINGS. r=mrbkap --- parser/htmlparser/src/moz.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parser/htmlparser/src/moz.build b/parser/htmlparser/src/moz.build index aa4fd8eec0ca..6e2674ceb956 100644 --- a/parser/htmlparser/src/moz.build +++ b/parser/htmlparser/src/moz.build @@ -24,6 +24,8 @@ SOURCES += [ LIBRARY_NAME = 'htmlpars' +FAIL_ON_WARNINGS = True + LIBXUL_LIBRARY = True EXPORT_LIBRARY = True From 4908bbab5e2d90eec563d559007ca87eb715ed36 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:03 -0700 Subject: [PATCH 042/795] Bug 926275: Remove mozalloc_macro_wrappers.h and mozalloc_undef_macro_wrappers.h. r=bsmedberg --- .../hunspell/src/hunspell_alloc_hooks.h | 3 -- ipc/chromium/src/base/message_pump_qt.h | 5 -- memory/mozalloc/moz.build | 2 - memory/mozalloc/mozalloc.cpp | 2 - memory/mozalloc/mozalloc_macro_wrappers.h | 51 ------------------- .../mozalloc/mozalloc_undef_macro_wrappers.h | 44 ---------------- tools/jprof/stub/libmalloc.cpp | 2 - xpcom/base/nscore.h | 1 - 8 files changed, 110 deletions(-) delete mode 100644 memory/mozalloc/mozalloc_macro_wrappers.h delete mode 100644 memory/mozalloc/mozalloc_undef_macro_wrappers.h diff --git a/extensions/spellcheck/hunspell/src/hunspell_alloc_hooks.h b/extensions/spellcheck/hunspell/src/hunspell_alloc_hooks.h index 8c600744b05f..8cd83dbca565 100644 --- a/extensions/spellcheck/hunspell/src/hunspell_alloc_hooks.h +++ b/extensions/spellcheck/hunspell/src/hunspell_alloc_hooks.h @@ -47,9 +47,6 @@ * allocated using C memory allocation functions. */ -// Prevent the standard macros from being redefined -#define mozilla_mozalloc_macro_wrappers_h - #include "mozilla/mozalloc.h" extern void HunspellReportMemoryAllocation(void*); diff --git a/ipc/chromium/src/base/message_pump_qt.h b/ipc/chromium/src/base/message_pump_qt.h index ccf403a4feba..48a956756ff9 100644 --- a/ipc/chromium/src/base/message_pump_qt.h +++ b/ipc/chromium/src/base/message_pump_qt.h @@ -5,11 +5,6 @@ #ifndef BASE_MESSAGE_PUMP_QT_H_ #define BASE_MESSAGE_PUMP_QT_H_ -#ifdef mozilla_mozalloc_macro_wrappers_h -/* The "anti-header" */ -# include "mozilla/mozalloc_undef_macro_wrappers.h" -#endif - #include #include "base/message_pump.h" diff --git a/memory/mozalloc/moz.build b/memory/mozalloc/moz.build index 191523e852a3..850e39d9b1c8 100644 --- a/memory/mozalloc/moz.build +++ b/memory/mozalloc/moz.build @@ -11,9 +11,7 @@ EXPORTS.mozilla += [ 'fallible.h', 'mozalloc.h', 'mozalloc_abort.h', - 'mozalloc_macro_wrappers.h', 'mozalloc_oom.h', - 'mozalloc_undef_macro_wrappers.h', ] if CONFIG['MOZ_MSVC_STL_WRAP__RAISE'] or CONFIG['MOZ_MSVC_STL_WRAP__Throw']: diff --git a/memory/mozalloc/mozalloc.cpp b/memory/mozalloc/mozalloc.cpp index 5da9943726c0..f43e0bb63b9e 100644 --- a/memory/mozalloc/mozalloc.cpp +++ b/memory/mozalloc/mozalloc.cpp @@ -24,8 +24,6 @@ # define MOZALLOC_EXPORT __declspec(dllexport) #endif -// Make sure that "malloc" et al. resolve to their libc variants. -#define MOZALLOC_DONT_DEFINE_MACRO_WRAPPERS #include "mozilla/mozalloc.h" #include "mozilla/mozalloc_oom.h" // for mozalloc_handle_oom diff --git a/memory/mozalloc/mozalloc_macro_wrappers.h b/memory/mozalloc/mozalloc_macro_wrappers.h deleted file mode 100644 index 465a58784f8b..000000000000 --- a/memory/mozalloc/mozalloc_macro_wrappers.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_mozalloc_macro_wrappers_h -#define mozilla_mozalloc_macro_wrappers_h - - -/* - * Make libc "allocating functions" never fail (return NULL). - * - * FIXME: use infallible allocators by default after - * http://bugzilla.mozilla.org/show_bug.cgi?id=507249 - * lands. - */ -#define free(_) moz_free(_) - -#define malloc(_) moz_malloc(_) - -#define calloc(_, __) moz_calloc(_, __) - -#define realloc(_, __) moz_realloc(_, __) - -/* - * Note: on some platforms, strdup may be a macro instead of a function. - * So we have to #undef it to avoid build warnings about redefining it. - */ -#undef strdup -#define strdup(_) moz_strdup(_) - -#if defined(HAVE_STRNDUP) -#define strndup(_, __) moz_strndup(_, __) -#endif - -#if defined(HAVE_POSIX_MEMALIGN) -#define posix_memalign(_, __, ___) moz_posix_memalign(_, __, ___) -#endif - -#if defined(HAVE_MEMALIGN) -#define memalign(_, __) moz_memalign(_, __) -#endif - -#if defined(HAVE_VALLOC) -#define valloc(_) moz_valloc(_) -#endif - - -#endif /* ifndef mozilla_mozalloc_macro_wrappers_h */ diff --git a/memory/mozalloc/mozalloc_undef_macro_wrappers.h b/memory/mozalloc/mozalloc_undef_macro_wrappers.h deleted file mode 100644 index 0ab5c28f9a09..000000000000 --- a/memory/mozalloc/mozalloc_undef_macro_wrappers.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * This header is the "anti-header" for mozalloc_macro_wrappers.h. - * Including it undefines all the macros defined by - * mozalloc_macro_wrappers.h. - */ - -#ifndef mozilla_mozalloc_macro_wrappers_h -# error "mozalloc macro wrappers haven't been defined" -#endif - -/* - * This allows the wrappers to be redefined by including - * mozalloc_macro_wrappers.h again - */ -#undef mozilla_mozalloc_macro_wrappers_h - -#undef free -#undef malloc -#undef calloc -#undef realloc -#undef strdup - -#if defined(HAVE_STRNDUP) -# undef strndup -#endif - -#if defined(HAVE_POSIX_MEMALIGN) -# undef posix_memalign -#endif - -#if defined(HAVE_MEMALIGN) -# undef memalign -#endif - -#if defined(HAVE_VALLOC) -# undef valloc -#endif diff --git a/tools/jprof/stub/libmalloc.cpp b/tools/jprof/stub/libmalloc.cpp index ea74941f2288..c68d65bf9eb8 100644 --- a/tools/jprof/stub/libmalloc.cpp +++ b/tools/jprof/stub/libmalloc.cpp @@ -37,8 +37,6 @@ #include #include -#include "mozilla/mozalloc_undef_macro_wrappers.h" - // Must define before including jprof.h void *moz_xmalloc(size_t size) { diff --git a/xpcom/base/nscore.h b/xpcom/base/nscore.h index b4f1489bbe62..c21c017ce7d9 100644 --- a/xpcom/base/nscore.h +++ b/xpcom/base/nscore.h @@ -17,7 +17,6 @@ /* Definitions of functions and operators that allocate memory. */ #if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC) # include "mozilla/mozalloc.h" -# include "mozilla/mozalloc_macro_wrappers.h" #endif /** From 5e8b8c07865a1f9f0011d6dbf4ca1e78d5492059 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 31 Oct 2013 19:39:03 -0700 Subject: [PATCH 043/795] Bug 839269: Mark gfx/2d as FAIL_ON_WARNINGS. r=jmuizelaar --- gfx/2d/moz.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build index 6c73e4229472..e211eca4d9b9 100644 --- a/gfx/2d/moz.build +++ b/gfx/2d/moz.build @@ -103,6 +103,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 'QuartzSupport.mm', ] +FAIL_ON_WARNINGS = True + LIBXUL_LIBRARY = True MSVC_ENABLE_PGO = True From cf872bdeadc0fcd23fed1c1f3dae8a1604b85454 Mon Sep 17 00:00:00 2001 From: Jeff Hammel Date: Thu, 31 Oct 2013 10:26:49 -0700 Subject: [PATCH 044/795] Bug 930590 - Sync manifestdestiny with m-c;r=edmorley --HG-- extra : rebase_source : 425d5dfa0ae7dbd356bbfe3947fc29838294c1bb --- .../manifestparser/manifestparser.py | 486 ++++++++++++++---- testing/mozbase/manifestdestiny/setup.py | 2 +- .../manifestdestiny/tests/manifest.ini | 6 +- .../manifestdestiny/tests/relative-path.ini | 5 + .../tests/test_convert_directory.py | 166 ++++++ .../tests/test_convert_symlinks.py | 115 +++++ .../tests/test_manifestparser.py | 142 ++--- .../tests/verifyDirectory/subdir/manifest.ini | 1 + .../tests/verifyDirectory/subdir/test_sub.js | 1 + .../tests/verifyDirectory/test_1.js | 1 + .../tests/verifyDirectory/test_2.js | 1 + .../tests/verifyDirectory/test_3.js | 1 + .../tests/verifyDirectory/verifyDirectory.ini | 4 + .../verifyDirectory_incomplete.ini | 3 + .../verifyDirectory_toocomplete.ini | 5 + 15 files changed, 759 insertions(+), 180 deletions(-) create mode 100644 testing/mozbase/manifestdestiny/tests/relative-path.ini create mode 100755 testing/mozbase/manifestdestiny/tests/test_convert_directory.py create mode 100755 testing/mozbase/manifestdestiny/tests/test_convert_symlinks.py create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/manifest.ini create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/test_sub.js create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/test_1.js create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/test_2.js create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/test_3.js create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory.ini create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_incomplete.ini create mode 100644 testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_toocomplete.ini diff --git a/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py b/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py index 938f4e7815d8..d6d14c2df84f 100755 --- a/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py +++ b/testing/mozbase/manifestdestiny/manifestparser/manifestparser.py @@ -12,14 +12,18 @@ __all__ = ['read_ini', # .ini reader 'ManifestParser', 'TestManifest', 'convert', # manifest handling 'parse', 'ParseError', 'ExpressionParser'] # conditional expression parser +import fnmatch import os import re import shutil import sys -from fnmatch import fnmatch + from optparse import OptionParser +from StringIO import StringIO relpath = os.path.relpath +string = (basestring,) + # expr.py # from: @@ -134,13 +138,45 @@ for index, rank in enumerate(precedence): token.lbp = index # lbp = lowest left binding power class ParseError(Exception): - """errror parsing conditional expression""" + """error parsing conditional expression""" class ExpressionParser(object): + """ + A parser for a simple expression language. + + The expression language can be described as follows:: + + EXPRESSION ::= LITERAL | '(' EXPRESSION ')' | '!' EXPRESSION | EXPRESSION OP EXPRESSION + OP ::= '==' | '!=' | '&&' | '||' + LITERAL ::= BOOL | INT | IDENT | STRING + BOOL ::= 'true' | 'false' + INT ::= [0-9]+ + IDENT ::= [a-zA-Z_]\w* + STRING ::= '"' [^\"] '"' | ''' [^\'] ''' + + At its core, expressions consist of booleans, integers, identifiers and. + strings. Booleans are one of *true* or *false*. Integers are a series + of digits. Identifiers are a series of English letters and underscores. + Strings are a pair of matching quote characters (single or double) with + zero or more characters inside. + + Expressions can be combined with operators: the equals (==) and not + equals (!=) operators compare two expressions and produce a boolean. The + and (&&) and or (||) operators take two expressions and produce the logical + AND or OR value of them, respectively. An expression can also be prefixed + with the not (!) operator, which produces its logical negation. + + Finally, any expression may be contained within parentheses for grouping. + + Identifiers take their values from the mapping provided. + """ def __init__(self, text, valuemapping, strict=False): """ - Initialize the parser with input |text|, and |valuemapping| as - a dict mapping identifier names to values. + Initialize the parser + :param text: The expression to parse as a string. + :param valuemapping: A dict mapping identifier names to values. + :param strict: If true, referencing an identifier that was not + provided in :valuemapping: will raise an error. """ self.text = text self.valuemapping = valuemapping @@ -164,6 +200,7 @@ class ExpressionParser(object): def not_(scanner, t): return not_op_token() scanner = re.Scanner([ + # Note: keep these in sync with the class docstring above. (r"true|false", bool_), (r"[a-zA-Z_]\w*", identifier), (r"[0-9]+", integer), @@ -232,12 +269,18 @@ class ExpressionParser(object): def parse(text, **values): """ - Parse and evaluate a boolean expression in |text|. Use |values| to look - up the value of identifiers referenced in the expression. Returns the final - value of the expression. A ParseError will be raised if parsing fails. + Parse and evaluate a boolean expression. + :param text: The expression to parse, as a string. + :param values: A dict containing a name to value mapping for identifiers + referenced in *text*. + :rtype: the final value of the expression. + :raises: :py:exc::ParseError: will be raised if parsing fails. """ return ExpressionParser(text, values).parse() + +### path normalization + def normalize_path(path): """normalize a relative path""" if sys.platform.startswith('win'): @@ -251,6 +294,8 @@ def denormalize_path(path): return path +### .ini reader + def read_ini(fp, variables=None, default='DEFAULT', comments=';#', separators=('=', ':'), strict=True): @@ -264,15 +309,13 @@ def read_ini(fp, variables=None, default='DEFAULT', - strict : whether to be strict about parsing """ - if variables is None: - variables = {} - - if isinstance(fp, basestring): - fp = file(fp) - + # variables + variables = variables or {} sections = [] key = value = None - section_names = set([]) + section_names = set() + if isinstance(fp, basestring): + fp = file(fp) # read the lines for line in fp.readlines(): @@ -354,8 +397,6 @@ def read_ini(fp, variables=None, default='DEFAULT', class ManifestParser(object): """read .ini manifests""" - ### methods for reading manifests - def __init__(self, manifests=(), defaults=None, strict=True): self._defaults = defaults or {} self.tests = [] @@ -368,14 +409,30 @@ class ManifestParser(object): def getRelativeRoot(self, root): return root + ### methods for reading manifests + def _read(self, root, filename, defaults): - # get directory of this file - here = os.path.dirname(os.path.abspath(filename)) + # get directory of this file if not file-like object + if isinstance(filename, string): + filename = os.path.abspath(filename) + fp = open(filename) + here = os.path.dirname(filename) + else: + fp = filename + filename = here = None defaults['here'] = here + # Rootdir is needed for relative path calculation. Precompute it for + # the microoptimization used below. + if self.rootdir is None: + rootdir = "" + else: + assert os.path.isabs(self.rootdir) + rootdir = self.rootdir + os.path.sep + # read the configuration - sections = read_ini(fp=filename, variables=defaults, strict=self.strict) + sections = read_ini(fp=fp, variables=defaults, strict=self.strict) # get the tests for section, data in sections: @@ -389,9 +446,11 @@ class ManifestParser(object): if not os.path.isabs(include_file): include_file = os.path.join(self.getRelativeRoot(here), include_file) if not os.path.exists(include_file): + message = "Included file '%s' does not exist" % include_file if self.strict: - raise IOError("File '%s' does not exist" % include_file) + raise IOError(message) else: + sys.stderr.write("%s\n" % message) continue include_defaults = data.copy() self._read(root, include_file, include_defaults) @@ -400,16 +459,34 @@ class ManifestParser(object): # otherwise an item test = data test['name'] = section - test['manifest'] = os.path.abspath(filename) + + # Will be None if the manifest being read is a file-like object. + test['manifest'] = filename # determine the path path = test.get('path', section) _relpath = path if '://' not in path: # don't futz with URLs path = normalize_path(path) - if not os.path.isabs(path): - path = os.path.join(here, path) - _relpath = relpath(path, self.rootdir) + if here and not os.path.isabs(path): + path = os.path.normpath(os.path.join(here, path)) + + # Microoptimization, because relpath is quite expensive. + # We know that rootdir is an absolute path or empty. If path + # starts with rootdir, then path is also absolute and the tail + # of the path is the relative path (possibly non-normalized, + # when here is unknown). + # For this to work rootdir needs to be terminated with a path + # separator, so that references to sibling directories with + # a common prefix don't get misscomputed (e.g. /root and + # /rootbeer/file). + # When the rootdir is unknown, the relpath needs to be left + # unchanged. We use an empty string as rootdir in that case, + # which leaves relpath unchanged after slicing. + if path.startswith(rootdir): + _relpath = path[len(rootdir):] + else: + _relpath = relpath(path, rootdir) test['path'] = path test['relpath'] = _relpath @@ -418,20 +495,32 @@ class ManifestParser(object): self.tests.append(test) def read(self, *filenames, **defaults): + """ + read and add manifests from file paths or file-like objects + + filenames -- file paths or file-like objects to read as manifests + defaults -- default variables + """ # ensure all files exist - missing = [ filename for filename in filenames - if not os.path.exists(filename) ] + missing = [filename for filename in filenames + if isinstance(filename, string) and not os.path.exists(filename) ] if missing: raise IOError('Missing files: %s' % ', '.join(missing)) + # default variables + _defaults = defaults.copy() or self._defaults.copy() + _defaults.setdefault('here', None) + # process each file for filename in filenames: # set the per file defaults - defaults = defaults.copy() or self._defaults.copy() - here = os.path.dirname(os.path.abspath(filename)) - defaults['here'] = here + defaults = _defaults.copy() + here = None + if isinstance(filename, string): + here = os.path.dirname(os.path.abspath(filename)) + defaults['here'] = here # directory of master .ini file if self.rootdir is None: # set the root directory @@ -440,6 +529,7 @@ class ManifestParser(object): self._read(here, filename, defaults) + ### methods for querying manifests def query(self, *checks, **kw): @@ -499,13 +589,6 @@ class ManifestParser(object): # return the tests return tests - def missing(self, tests=None): - """return list of tests that do not exist on the filesystem""" - if tests is None: - tests = self.tests - return [test for test in tests - if not os.path.exists(test['path'])] - def manifests(self, tests=None): """ return manifests in order in which they appear in the tests @@ -521,7 +604,52 @@ class ManifestParser(object): manifests.append(manifest) return manifests - ### methods for outputting from manifests + def paths(self): + return [i['path'] for i in self.tests] + + + ### methods for auditing + + def missing(self, tests=None): + """return list of tests that do not exist on the filesystem""" + if tests is None: + tests = self.tests + return [test for test in tests + if not os.path.exists(test['path'])] + + def verifyDirectory(self, directories, pattern=None, extensions=None): + """ + checks what is on the filesystem vs what is in a manifest + returns a 2-tuple of sets: + (missing_from_filesystem, missing_from_manifest) + """ + + files = set([]) + if isinstance(directories, basestring): + directories = [directories] + + # get files in directories + for directory in directories: + for dirpath, dirnames, filenames in os.walk(directory, topdown=True): + + # only add files that match a pattern + if pattern: + filenames = fnmatch.filter(filenames, pattern) + + # only add files that have one of the extensions + if extensions: + filenames = [filename for filename in filenames + if os.path.splitext(filename)[-1] in extensions] + + files.update([os.path.join(dirpath, filename) for filename in filenames]) + + paths = set(self.paths()) + missing_from_filesystem = paths.difference(files) + missing_from_manifest = files.difference(paths) + return (missing_from_filesystem, missing_from_manifest) + + + ### methods for output def write(self, fp=sys.stdout, rootdir=None, global_tags=None, global_kwargs=None, @@ -533,6 +661,12 @@ class ManifestParser(object): locals (if given) will be written per test """ + # open file if `fp` given as string + close = False + if isinstance(fp, string): + fp = file(fp, 'w') + close = True + # root directory if rootdir is None: rootdir = self.rootdir @@ -586,6 +720,16 @@ class ManifestParser(object): print >> fp, '%s = %s' % (key, test[key]) print >> fp + if close: + # close the created file + fp.close() + + def __str__(self): + fp = StringIO() + self.write(fp=fp) + value = fp.getvalue() + return value + def copy(self, directory, rootdir=None, *tags, **kwargs): """ copy the manifests and associated tests @@ -666,6 +810,220 @@ class ManifestParser(object): destination = os.path.join(rootdir, _relpath) shutil.copy(source, destination) + ### directory importers + + @classmethod + def _walk_directories(cls, directories, function, pattern=None, ignore=()): + """ + internal function to import directories + """ + + class FilteredDirectoryContents(object): + """class to filter directory contents""" + + sort = sorted + + def __init__(self, pattern=pattern, ignore=ignore, cache=None): + if pattern is None: + pattern = set() + if isinstance(pattern, basestring): + pattern = [pattern] + self.patterns = pattern + self.ignore = set(ignore) + + # cache of (dirnames, filenames) keyed on directory real path + # assumes volume is frozen throughout scope + self._cache = cache or {} + + def __call__(self, directory): + """returns 2-tuple: dirnames, filenames""" + directory = os.path.realpath(directory) + if directory not in self._cache: + dirnames, filenames = self.contents(directory) + + # filter out directories without progeny + # XXX recursive: should keep track of seen directories + dirnames = [ dirname for dirname in dirnames + if not self.empty(os.path.join(directory, dirname)) ] + + self._cache[directory] = (tuple(dirnames), filenames) + + # return cached values + return self._cache[directory] + + def empty(self, directory): + """ + returns if a directory and its descendents are empty + """ + return self(directory) == ((), ()) + + def contents(self, directory, sort=None): + """ + return directory contents as (dirnames, filenames) + with `ignore` and `pattern` applied + """ + + if sort is None: + sort = self.sort + + # split directories and files + dirnames = [] + filenames = [] + for item in os.listdir(directory): + path = os.path.join(directory, item) + if os.path.isdir(path): + dirnames.append(item) + else: + # XXX not sure what to do if neither a file or directory + # (if anything) + assert os.path.isfile(path) + filenames.append(item) + + # filter contents; + # this could be done in situ re the above for loop + # but it is really disparate in intent + # and could conceivably go to a separate method + dirnames = [dirname for dirname in dirnames + if dirname not in self.ignore] + filenames = set(filenames) + # we use set functionality to filter filenames + if self.patterns: + matches = set() + matches.update(*[fnmatch.filter(filenames, pattern) + for pattern in self.patterns]) + filenames = matches + + if sort is not None: + # sort dirnames, filenames + dirnames = sort(dirnames) + filenames = sort(filenames) + + return (tuple(dirnames), tuple(filenames)) + + # make a filtered directory object + directory_contents = FilteredDirectoryContents(pattern=pattern, ignore=ignore) + + # walk the directories, generating manifests + for index, directory in enumerate(directories): + + for dirpath, dirnames, filenames in os.walk(directory): + + # get the directory contents from the caching object + _dirnames, filenames = directory_contents(dirpath) + # filter out directory names + dirnames[:] = _dirnames + + # call callback function + function(directory, dirpath, dirnames, filenames) + + @classmethod + def populate_directory_manifests(cls, directories, filename, pattern=None, ignore=(), overwrite=False): + """ + walks directories and writes manifests of name `filename` in-place; returns `cls` instance populated + with the given manifests + + filename -- filename of manifests to write + pattern -- shell pattern (glob) or patterns of filenames to match + ignore -- directory names to ignore + overwrite -- whether to overwrite existing files of given name + """ + + manifest_dict = {} + seen = [] # top-level directories seen + + if os.path.basename(filename) != filename: + raise IOError("filename should not include directory name") + + # no need to hit directories more than once + _directories = directories + directories = [] + for directory in _directories: + if directory not in directories: + directories.append(directory) + + def callback(directory, dirpath, dirnames, filenames): + """write a manifest for each directory""" + + manifest_path = os.path.join(dirpath, filename) + if (dirnames or filenames) and not (os.path.exists(manifest_path) and overwrite): + with file(manifest_path, 'w') as manifest: + for dirname in dirnames: + print >> manifest, '[include:%s]' % os.path.join(dirname, filename) + for _filename in filenames: + print >> manifest, '[%s]' % _filename + + # add to list of manifests + manifest_dict.setdefault(directory, manifest_path) + + # walk the directories to gather files + cls._walk_directories(directories, callback, pattern=pattern, ignore=ignore) + # get manifests + manifests = [manifest_dict[directory] for directory in _directories] + + # create a `cls` instance with the manifests + return cls(manifests=manifests) + + @classmethod + def from_directories(cls, directories, pattern=None, ignore=(), write=None, relative_to=None): + """ + convert directories to a simple manifest; returns ManifestParser instance + + pattern -- shell pattern (glob) or patterns of filenames to match + ignore -- directory names to ignore + write -- filename or file-like object of manifests to write; + if `None` then a StringIO instance will be created + relative_to -- write paths relative to this path; + if false then the paths are absolute + """ + + + # determine output + opened_manifest_file = None # name of opened manifest file + absolute = not relative_to # whether to output absolute path names as names + if isinstance(write, string): + opened_manifest_file = write + write = file(write, 'w') + if write is None: + write = StringIO() + + # walk the directories, generating manifests + def callback(directory, dirpath, dirnames, filenames): + + # absolute paths + filenames = [os.path.join(dirpath, filename) + for filename in filenames] + # ensure new manifest isn't added + filenames = [filename for filename in filenames + if filename != opened_manifest_file] + # normalize paths + if not absolute and relative_to: + filenames = [relpath(filename, relative_to) + for filename in filenames] + + # write to manifest + print >> write, '\n'.join(['[%s]' % denormalize_path(filename) + for filename in filenames]) + + + cls._walk_directories(directories, callback, pattern=pattern, ignore=ignore) + + if opened_manifest_file: + # close file + write.close() + manifests = [opened_manifest_file] + else: + # manifests/write is a file-like object; + # rewind buffer + write.flush() + write.seek(0) + manifests = [write] + + + # make a ManifestParser instance + return cls(manifests=manifests) + +convert = ManifestParser.from_directories + class TestManifest(ManifestParser): """ @@ -676,8 +1034,8 @@ class TestManifest(ManifestParser): def filter(self, values, tests): """ filter on a specific list tag, e.g.: - run-if = os == "win" - skip-if = os == "mac" + run-if = os == win linux + skip-if = os == mac """ # tags: @@ -743,56 +1101,6 @@ class TestManifest(ManifestParser): return [test['path'] for test in self.active_tests()] -### utility function(s); probably belongs elsewhere - -def convert(directories, pattern=None, ignore=(), write=None): - """ - convert directories to a simple manifest - """ - - retval = [] - include = [] - for directory in directories: - for dirpath, dirnames, filenames in os.walk(directory): - - # filter out directory names - dirnames = [ i for i in dirnames if i not in ignore ] - dirnames.sort() - - # reference only the subdirectory - _dirpath = dirpath - dirpath = dirpath.split(directory, 1)[-1].strip(os.path.sep) - - if dirpath.split(os.path.sep)[0] in ignore: - continue - - # filter by glob - if pattern: - filenames = [filename for filename in filenames - if fnmatch(filename, pattern)] - - filenames.sort() - - # write a manifest for each directory - if write and (dirnames or filenames): - manifest = file(os.path.join(_dirpath, write), 'w') - for dirname in dirnames: - print >> manifest, '[include:%s]' % os.path.join(dirname, write) - for filename in filenames: - print >> manifest, '[%s]' % filename - manifest.close() - - # add to the list - retval.extend([denormalize_path(os.path.join(dirpath, filename)) - for filename in filenames]) - - if write: - return # the manifests have already been written! - - retval.sort() - retval = ['[%s]' % filename for filename in retval] - return '\n'.join(retval) - ### command line attributes class ParserError(Exception): diff --git a/testing/mozbase/manifestdestiny/setup.py b/testing/mozbase/manifestdestiny/setup.py index 8e5a2396edbf..4e4e4ea9261c 100644 --- a/testing/mozbase/manifestdestiny/setup.py +++ b/testing/mozbase/manifestdestiny/setup.py @@ -5,7 +5,7 @@ from setuptools import setup PACKAGE_NAME = "ManifestDestiny" -PACKAGE_VERSION = '0.5.7' +PACKAGE_VERSION = '0.6' setup(name=PACKAGE_NAME, version=PACKAGE_VERSION, diff --git a/testing/mozbase/manifestdestiny/tests/manifest.ini b/testing/mozbase/manifestdestiny/tests/manifest.ini index 6dad6e959358..3a224ade6e86 100644 --- a/testing/mozbase/manifestdestiny/tests/manifest.ini +++ b/testing/mozbase/manifestdestiny/tests/manifest.ini @@ -1,5 +1,9 @@ -# test manifest for mozbase tests +# test manifest for manifestparser [test_expressionparser.py] [test_manifestparser.py] [test_testmanifest.py] [test_read_ini.py] +[test_convert_directory.py] + +[test_convert_symlinks.py] +disabled = https://bugzilla.mozilla.org/show_bug.cgi?id=920938 diff --git a/testing/mozbase/manifestdestiny/tests/relative-path.ini b/testing/mozbase/manifestdestiny/tests/relative-path.ini new file mode 100644 index 000000000000..57105489ba99 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/relative-path.ini @@ -0,0 +1,5 @@ +[foo] +path = ../fleem + +[bar] +path = ../testsSIBLING/example diff --git a/testing/mozbase/manifestdestiny/tests/test_convert_directory.py b/testing/mozbase/manifestdestiny/tests/test_convert_directory.py new file mode 100755 index 000000000000..2e9bd7211ac6 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/test_convert_directory.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +import shutil +import tempfile +import unittest + +from manifestparser import convert +from manifestparser import ManifestParser +from StringIO import StringIO + +here = os.path.dirname(os.path.abspath(__file__)) + +class TestDirectoryConversion(unittest.TestCase): + """test conversion of a directory tree to a manifest structure""" + + def create_stub(self, directory=None): + """stub out a directory with files in it""" + + files = ('foo', 'bar', 'fleem') + if directory is None: + directory = tempfile.mkdtemp() + for i in files: + file(os.path.join(directory, i), 'w').write(i) + subdir = os.path.join(directory, 'subdir') + os.mkdir(subdir) + file(os.path.join(subdir, 'subfile'), 'w').write('baz') + return directory + + def test_directory_to_manifest(self): + """ + Test our ability to convert a static directory structure to a + manifest. + """ + + # create a stub directory + stub = self.create_stub() + try: + stub = stub.replace(os.path.sep, "/") + self.assertTrue(os.path.exists(stub) and os.path.isdir(stub)) + + # Make a manifest for it + manifest = convert([stub]) + self.assertEqual(str(manifest), +"""[%(stub)s/bar] + +[%(stub)s/fleem] + +[%(stub)s/foo] + +[%(stub)s/subdir/subfile] + +""" % dict(stub=stub)) + except: + raise + finally: + shutil.rmtree(stub) # cleanup + + def test_convert_directory_manifests_in_place(self): + """ + keep the manifests in place + """ + + stub = self.create_stub() + try: + ManifestParser.populate_directory_manifests([stub], filename='manifest.ini') + self.assertEqual(sorted(os.listdir(stub)), + ['bar', 'fleem', 'foo', 'manifest.ini', 'subdir']) + parser = ManifestParser() + parser.read(os.path.join(stub, 'manifest.ini')) + self.assertEqual([i['name'] for i in parser.tests], + ['subfile', 'bar', 'fleem', 'foo']) + parser = ManifestParser() + parser.read(os.path.join(stub, 'subdir', 'manifest.ini')) + self.assertEqual(len(parser.tests), 1) + self.assertEqual(parser.tests[0]['name'], 'subfile') + except: + raise + finally: + shutil.rmtree(stub) + + def test_manifest_ignore(self): + """test manifest `ignore` parameter for ignoring directories""" + + stub = self.create_stub() + try: + ManifestParser.populate_directory_manifests([stub], filename='manifest.ini', ignore=('subdir',)) + parser = ManifestParser() + parser.read(os.path.join(stub, 'manifest.ini')) + self.assertEqual([i['name'] for i in parser.tests], + ['bar', 'fleem', 'foo']) + self.assertFalse(os.path.exists(os.path.join(stub, 'subdir', 'manifest.ini'))) + except: + raise + finally: + shutil.rmtree(stub) + + def test_pattern(self): + """test directory -> manifest with a file pattern""" + + stub = self.create_stub() + try: + parser = convert([stub], pattern='f*', relative_to=stub) + self.assertEqual([i['name'] for i in parser.tests], + ['fleem', 'foo']) + + # test multiple patterns + parser = convert([stub], pattern=('f*', 's*'), relative_to=stub) + self.assertEqual([i['name'] for i in parser.tests], + ['fleem', 'foo', 'subdir/subfile']) + except: + raise + finally: + shutil.rmtree(stub) + + def test_update(self): + """ + Test our ability to update tests from a manifest and a directory of + files + """ + + # boilerplate + tempdir = tempfile.mkdtemp() + for i in range(10): + file(os.path.join(tempdir, str(i)), 'w').write(str(i)) + + # otherwise empty directory with a manifest file + newtempdir = tempfile.mkdtemp() + manifest_file = os.path.join(newtempdir, 'manifest.ini') + manifest_contents = str(convert([tempdir], relative_to=tempdir)) + with file(manifest_file, 'w') as f: + f.write(manifest_contents) + + # get the manifest + manifest = ManifestParser(manifests=(manifest_file,)) + + # All of the tests are initially missing: + paths = [str(i) for i in range(10)] + self.assertEqual([i['name'] for i in manifest.missing()], + paths) + + # But then we copy one over: + self.assertEqual(manifest.get('name', name='1'), ['1']) + manifest.update(tempdir, name='1') + self.assertEqual(sorted(os.listdir(newtempdir)), + ['1', 'manifest.ini']) + + # Update that one file and copy all the "tests": + file(os.path.join(tempdir, '1'), 'w').write('secret door') + manifest.update(tempdir) + self.assertEqual(sorted(os.listdir(newtempdir)), + ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'manifest.ini']) + self.assertEqual(file(os.path.join(newtempdir, '1')).read().strip(), + 'secret door') + + # clean up: + shutil.rmtree(tempdir) + shutil.rmtree(newtempdir) + + +if __name__ == '__main__': + unittest.main() diff --git a/testing/mozbase/manifestdestiny/tests/test_convert_symlinks.py b/testing/mozbase/manifestdestiny/tests/test_convert_symlinks.py new file mode 100755 index 000000000000..c55bf3473e88 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/test_convert_symlinks.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python + +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +import shutil +import tempfile +import unittest + +from manifestparser import convert + +class TestSymlinkConversion(unittest.TestCase): + """ + test conversion of a directory tree with symlinks to a manifest structure + """ + + # Currently broken: see + # https://bugzilla.mozilla.org/show_bug.cgi?id=902610 + # https://bugzilla.mozilla.org/show_bug.cgi?id=920938 + + def create_stub(self, directory=None): + """stub out a directory with files in it""" + + files = ('foo', 'bar', 'fleem') + if directory is None: + directory = tempfile.mkdtemp() + for i in files: + file(os.path.join(directory, i), 'w').write(i) + subdir = os.path.join(directory, 'subdir') + os.mkdir(subdir) + file(os.path.join(subdir, 'subfile'), 'w').write('baz') + return directory + + def test_relpath(self): + """test convert `relative_to` functionality""" + + oldcwd = os.getcwd() + stub = self.create_stub() + try: + # subdir with in-memory manifest + files = ['../bar', '../fleem', '../foo', 'subfile'] + subdir = os.path.join(stub, 'subdir') + os.chdir(subdir) + parser = convert([stub], relative_to='.') + self.assertEqual([i['name'] for i in parser.tests], + files) + except: + raise + finally: + shutil.rmtree(stub) + os.chdir(oldcwd) + + def test_relpath_symlink(self): + """ + Ensure `relative_to` works in a symlink. + Not available on windows. + """ + + symlink = getattr(os, 'symlink', None) + if symlink is None: + return # symlinks unavailable on this platform + + oldcwd = os.getcwd() + workspace = tempfile.mkdtemp() + try: + tmpdir = os.path.join(workspace, 'directory') + os.makedirs(tmpdir) + linkdir = os.path.join(workspace, 'link') + symlink(tmpdir, linkdir) + self.create_stub(tmpdir) + + # subdir with in-memory manifest + files = ['../bar', '../fleem', '../foo', 'subfile'] + subdir = os.path.join(linkdir, 'subdir') + os.chdir(os.path.realpath(subdir)) + for directory in (tmpdir, linkdir): + parser = convert([directory], relative_to='.') + self.assertEqual([i['name'] for i in parser.tests], + files) + finally: + shutil.rmtree(workspace) + os.chdir(oldcwd) + + # a more complicated example + oldcwd = os.getcwd() + workspace = tempfile.mkdtemp() + try: + tmpdir = os.path.join(workspace, 'directory') + os.makedirs(tmpdir) + linkdir = os.path.join(workspace, 'link') + symlink(tmpdir, linkdir) + self.create_stub(tmpdir) + files = ['../bar', '../fleem', '../foo', 'subfile'] + subdir = os.path.join(linkdir, 'subdir') + subsubdir = os.path.join(subdir, 'sub') + os.makedirs(subsubdir) + linksubdir = os.path.join(linkdir, 'linky') + linksubsubdir = os.path.join(subsubdir, 'linky') + symlink(subdir, linksubdir) + symlink(subdir, linksubsubdir) + for dest in (subdir,): + os.chdir(dest) + for directory in (tmpdir, linkdir): + parser = convert([directory], relative_to='.') + self.assertEqual([i['name'] for i in parser.tests], + files) + finally: + shutil.rmtree(workspace) + os.chdir(oldcwd) + + +if __name__ == '__main__': + unittest.main() diff --git a/testing/mozbase/manifestdestiny/tests/test_manifestparser.py b/testing/mozbase/manifestdestiny/tests/test_manifestparser.py index ef58590e05e4..cd8de4c20f7e 100755 --- a/testing/mozbase/manifestdestiny/tests/test_manifestparser.py +++ b/testing/mozbase/manifestdestiny/tests/test_manifestparser.py @@ -1,5 +1,9 @@ #!/usr/bin/env python +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + import os import shutil import tempfile @@ -10,7 +14,7 @@ from StringIO import StringIO here = os.path.dirname(os.path.abspath(__file__)) -class TestManifestparser(unittest.TestCase): +class TestManifestParser(unittest.TestCase): """ Test the manifest parser @@ -86,7 +90,7 @@ class TestManifestparser(unittest.TestCase): self.assertEqual(parser.get(name='flowers')[0]['yellow'], 'submarine') - # You can query multiple times if you need to:: + # You can query multiple times if you need to: flowers = parser.get(foo='bar') self.assertEqual(len(flowers), 2) @@ -94,7 +98,7 @@ class TestManifestparser(unittest.TestCase): self.assertEqual(parser.get('name', inverse=True, tags=['red']), ['crash-handling', 'fleem']) - # All of the included tests actually exist:: + # All of the included tests actually exist: self.assertEqual([i['name'] for i in parser.missing()], []) # Write the output to a manifest: @@ -103,49 +107,6 @@ class TestManifestparser(unittest.TestCase): self.assertEqual(buffer.getvalue().strip(), '[DEFAULT]\nfoo = bar\n\n[fleem]\n\n[include/flowers]\nblue = ocean\nred = roses\nyellow = submarine') - - def test_directory_to_manifest(self): - """ - Test our ability to convert a static directory structure to a - manifest. - """ - - # First, stub out a directory with files in it:: - def create_stub(): - directory = tempfile.mkdtemp() - for i in 'foo', 'bar', 'fleem': - file(os.path.join(directory, i), 'w').write(i) - subdir = os.path.join(directory, 'subdir') - os.mkdir(subdir) - file(os.path.join(subdir, 'subfile'), 'w').write('baz') - return directory - stub = create_stub() - self.assertTrue(os.path.exists(stub) and os.path.isdir(stub)) - - # Make a manifest for it: - self.assertEqual(convert([stub]), - """[bar] -[fleem] -[foo] -[subdir/subfile]""") - shutil.rmtree(stub) # cleanup - - # Now do the same thing but keep the manifests in place: - stub = create_stub() - convert([stub], write='manifest.ini') - self.assertEqual(sorted(os.listdir(stub)), - ['bar', 'fleem', 'foo', 'manifest.ini', 'subdir']) - parser = ManifestParser() - parser.read(os.path.join(stub, 'manifest.ini')) - self.assertEqual([i['name'] for i in parser.tests], - ['subfile', 'bar', 'fleem', 'foo']) - parser = ManifestParser() - parser.read(os.path.join(stub, 'subdir', 'manifest.ini')) - self.assertEqual(len(parser.tests), 1) - self.assertEqual(parser.tests[0]['name'], 'subfile') - shutil.rmtree(stub) - - def test_copy(self): """Test our ability to copy a set of manifests""" @@ -163,49 +124,6 @@ class TestManifestparser(unittest.TestCase): self.assertEqual(to_manifest.get('name'), from_manifest.get('name')) shutil.rmtree(tempdir) - - def test_update(self): - """ - Test our ability to update tests from a manifest and a directory of - files - """ - - # boilerplate - tempdir = tempfile.mkdtemp() - for i in range(10): - file(os.path.join(tempdir, str(i)), 'w').write(str(i)) - - # First, make a manifest: - manifest = convert([tempdir]) - newtempdir = tempfile.mkdtemp() - manifest_file = os.path.join(newtempdir, 'manifest.ini') - file(manifest_file,'w').write(manifest) - manifest = ManifestParser(manifests=(manifest_file,)) - self.assertEqual(manifest.get('name'), - [str(i) for i in range(10)]) - - # All of the tests are initially missing: - self.assertEqual([i['name'] for i in manifest.missing()], - [str(i) for i in range(10)]) - - # But then we copy one over: - self.assertEqual(manifest.get('name', name='1'), ['1']) - manifest.update(tempdir, name='1') - self.assertEqual(sorted(os.listdir(newtempdir)), - ['1', 'manifest.ini']) - - # Update that one file and copy all the "tests": - file(os.path.join(tempdir, '1'), 'w').write('secret door') - manifest.update(tempdir) - self.assertEqual(sorted(os.listdir(newtempdir)), - ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'manifest.ini']) - self.assertEqual(file(os.path.join(newtempdir, '1')).read().strip(), - 'secret door') - - # clean up: - shutil.rmtree(tempdir) - shutil.rmtree(newtempdir) - def test_path_override(self): """You can override the path in the section too. This shows that you can use a relative path""" @@ -214,6 +132,28 @@ class TestManifestparser(unittest.TestCase): self.assertEqual(manifest.tests[0]['path'], os.path.join(here, 'fleem')) + def test_relative_path(self): + """ + Relative test paths are correctly calculated. + """ + relative_path = os.path.join(here, 'relative-path.ini') + manifest = ManifestParser(manifests=(relative_path,)) + self.assertEqual(manifest.tests[0]['path'], + os.path.join(os.path.dirname(here), 'fleem')) + self.assertEqual(manifest.tests[0]['relpath'], + os.path.join('..', 'fleem')) + self.assertEqual(manifest.tests[1]['relpath'], + os.path.join('..', 'testsSIBLING', 'example')) + + def test_path_from_fd(self): + """ + Test paths are left untouched when manifest is a file-like object. + """ + fp = StringIO("[section]\npath=fleem") + manifest = ManifestParser(manifests=(fp,)) + self.assertEqual(manifest.tests[0]['path'], 'fleem') + self.assertEqual(manifest.tests[0]['relpath'], 'fleem') + self.assertEqual(manifest.tests[0]['manifest'], None) def test_comments(self): """ @@ -226,5 +166,29 @@ class TestManifestparser(unittest.TestCase): names = [i['name'] for i in manifest.tests] self.assertFalse('test_0202_app_launch_apply_update_dirlocked.js' in names) + def test_verifyDirectory(self): + + directory = os.path.join(here, 'verifyDirectory') + + # correct manifest + manifest_path = os.path.join(directory, 'verifyDirectory.ini') + manifest = ManifestParser(manifests=(manifest_path,)) + missing = manifest.verifyDirectory(directory, extensions=('.js',)) + self.assertEqual(missing, (set(), set())) + + # manifest is missing test_1.js + test_1 = os.path.join(directory, 'test_1.js') + manifest_path = os.path.join(directory, 'verifyDirectory_incomplete.ini') + manifest = ManifestParser(manifests=(manifest_path,)) + missing = manifest.verifyDirectory(directory, extensions=('.js',)) + self.assertEqual(missing, (set(), set([test_1]))) + + # filesystem is missing test_notappearinginthisfilm.js + missing_test = os.path.join(directory, 'test_notappearinginthisfilm.js') + manifest_path = os.path.join(directory, 'verifyDirectory_toocomplete.ini') + manifest = ManifestParser(manifests=(manifest_path,)) + missing = manifest.verifyDirectory(directory, extensions=('.js',)) + self.assertEqual(missing, (set([missing_test]), set())) + if __name__ == '__main__': unittest.main() diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/manifest.ini b/testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/manifest.ini new file mode 100644 index 000000000000..509ebd62ef53 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/manifest.ini @@ -0,0 +1 @@ +[test_sub.js] diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/test_sub.js b/testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/test_sub.js new file mode 100644 index 000000000000..df48720d9d1b --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/subdir/test_sub.js @@ -0,0 +1 @@ +// test_sub.js diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_1.js b/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_1.js new file mode 100644 index 000000000000..c5a966f46a74 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_1.js @@ -0,0 +1 @@ +// test_1.js diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_2.js b/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_2.js new file mode 100644 index 000000000000..d8648599c5b6 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_2.js @@ -0,0 +1 @@ +// test_2.js diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_3.js b/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_3.js new file mode 100644 index 000000000000..794bc2c341a1 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/test_3.js @@ -0,0 +1 @@ +// test_3.js diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory.ini b/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory.ini new file mode 100644 index 000000000000..10e0c79c81d7 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory.ini @@ -0,0 +1,4 @@ +[test_1.js] +[test_2.js] +[test_3.js] +[include:subdir/manifest.ini] diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_incomplete.ini b/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_incomplete.ini new file mode 100644 index 000000000000..cde526acfcf3 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_incomplete.ini @@ -0,0 +1,3 @@ +[test_2.js] +[test_3.js] +[include:subdir/manifest.ini] diff --git a/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_toocomplete.ini b/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_toocomplete.ini new file mode 100644 index 000000000000..88994ae26ff9 --- /dev/null +++ b/testing/mozbase/manifestdestiny/tests/verifyDirectory/verifyDirectory_toocomplete.ini @@ -0,0 +1,5 @@ +[test_1.js] +[test_2.js] +[test_3.js] +[test_notappearinginthisfilm.js] +[include:subdir/manifest.ini] From 5abd447f7b546b8ca7044d0a13b94d092453d1ea Mon Sep 17 00:00:00 2001 From: Cykesiopka Date: Thu, 31 Oct 2013 22:48:45 -0400 Subject: [PATCH 045/795] Bug 887832 - moz.build: Fix other remaining OS_TEST==arm references in the tree. r=gps --- xpcom/reflect/xptcall/src/md/unix/moz.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xpcom/reflect/xptcall/src/md/unix/moz.build b/xpcom/reflect/xptcall/src/md/unix/moz.build index 91bcda9685e7..b1855573dcca 100644 --- a/xpcom/reflect/xptcall/src/md/unix/moz.build +++ b/xpcom/reflect/xptcall/src/md/unix/moz.build @@ -60,7 +60,7 @@ if CONFIG['OS_TARGET'] == 'NTO': 'xptcinvoke_gcc_x86_unix.cpp', 'xptcstubs_gcc_x86_unix.cpp', ] - elif CONFIG['OS_TEST'] == 'arm': + elif CONFIG['CPU_ARCH'] == 'arm': SOURCES += [ 'xptcinvoke_nto_arm.cpp', 'xptcstubs_nto_arm.cpp', @@ -111,7 +111,7 @@ if CONFIG['OS_TEST'] == 'alpha': 'xptcstubs_alpha_openbsd.cpp', ] -if CONFIG['OS_TEST'].startswith('arm') or CONFIG['OS_TEST'] == 'sa110': +if CONFIG['CPU_ARCH'] == 'arm' or CONFIG['OS_TEST'] == 'sa110': if CONFIG['OS_ARCH'] == 'Linux': SOURCES += [ 'xptcinvoke_arm.cpp', @@ -123,7 +123,7 @@ if CONFIG['OS_TEST'].startswith('arm') or CONFIG['OS_TEST'] == 'sa110': 'xptcstubs_arm_netbsd.cpp', ] -if CONFIG['OS_TEST'] == 'arm' and CONFIG['OS_ARCH'] == 'OpenBSD': +if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['OS_ARCH'] == 'OpenBSD': SOURCES += [ 'xptcinvoke_arm_openbsd.cpp', 'xptcstubs_arm_openbsd.cpp', From 613ec93e22edbff8af402ad2536ff7e2b24babe0 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Wed, 30 Oct 2013 17:39:01 -0700 Subject: [PATCH 046/795] Bug 902755 - Fix deadlock in mozilla::ipc::GeckoChildProcessHost::LaunchAndWaitForProcessHandle exposed by turning on new tab page thumbnails. r=bent --- ipc/glue/GeckoChildProcessHost.cpp | 17 +++++++++++++---- ipc/glue/GeckoChildProcessHost.h | 6 ++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 573e94339873..cf9101eae325 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -666,6 +666,11 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt GetChannel()->CloseClientFileDescriptor(); #ifdef MOZ_WIDGET_COCOA + if (!process) { + SetErrorState(); + return false; + } + // Wait for the child process to send us its 'task_t' data. const int kTimeoutMs = 10000; @@ -675,17 +680,20 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt if (err != KERN_SUCCESS) { std::string errString = StringPrintf("0x%x %s", err, mach_error_string(err)); LOG(ERROR) << "parent WaitForMessage() failed: " << errString; + SetErrorState(); return false; } task_t child_task = child_message.GetTranslatedPort(0); if (child_task == MACH_PORT_NULL) { LOG(ERROR) << "parent GetTranslatedPort(0) failed."; + SetErrorState(); return false; } if (child_message.GetTranslatedPort(1) == MACH_PORT_NULL) { LOG(ERROR) << "parent GetTranslatedPort(1) failed."; + SetErrorState(); return false; } MachPortSender parent_sender(child_message.GetTranslatedPort(1)); @@ -693,6 +701,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt MachSendMessage parent_message(/* id= */0); if (!parent_message.AddDescriptor(bootstrap_port)) { LOG(ERROR) << "parent AddDescriptor(" << bootstrap_port << ") failed."; + SetErrorState(); return false; } @@ -700,6 +709,7 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt if (err != KERN_SUCCESS) { std::string errString = StringPrintf("0x%x %s", err, mach_error_string(err)); LOG(ERROR) << "parent SendMessage() failed: " << errString; + SetErrorState(); return false; } #endif @@ -760,14 +770,13 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt #else # error Sorry -#endif +#endif // OS_POSIX if (!process) { - MonitorAutoLock lock(mMonitor); - mProcessState = PROCESS_ERROR; - lock.Notify(); + SetErrorState(); return false; } + // NB: on OS X, we block much longer than we need to in order to // reach this call, waiting for the child process's task_t. The // best way to fix that is to refactor this file, hard. diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h index ef843b2f4914..f04895842714 100644 --- a/ipc/glue/GeckoChildProcessHost.h +++ b/ipc/glue/GeckoChildProcessHost.h @@ -177,6 +177,12 @@ private: bool RunPerformAsyncLaunch(StringVector aExtraOpts=StringVector(), base::ProcessArchitecture aArch=base::GetCurrentProcessArchitecture()); + inline void SetErrorState() { + MonitorAutoLock lock(mMonitor); + mProcessState = PROCESS_ERROR; + lock.Notify(); + } + // In between launching the subprocess and handing off its IPC // channel, there's a small window of time in which *we* might still // be the channel listener, and receive messages. That's bad From 1a058a0e490326b61655edd947ad50d03a8fedb8 Mon Sep 17 00:00:00 2001 From: Garrett Robinson Date: Mon, 28 Oct 2013 11:25:16 -0700 Subject: [PATCH 047/795] Bug 924708 - Fix regression of report-only CSP's that use policy-uri. r=sstamm --- content/base/src/CSPUtils.jsm | 54 +++++++++---------- content/base/src/contentSecurityPolicy.js | 8 +-- ...policyuri_regression_from_multipolicy.html | 9 ++++ ..._regression_from_multipolicy.html^headers^ | 1 + ...licyuri_regression_from_multipolicy_policy | 1 + content/base/test/csp/mochitest.ini | 4 ++ ...policyuri_regression_from_multipolicy.html | 29 ++++++++++ content/base/test/unit/test_bug558431.js | 4 +- testing/mochitest/b2g.json | 1 + 9 files changed, 77 insertions(+), 34 deletions(-) create mode 100644 content/base/test/csp/file_policyuri_regression_from_multipolicy.html create mode 100644 content/base/test/csp/file_policyuri_regression_from_multipolicy.html^headers^ create mode 100644 content/base/test/csp/file_policyuri_regression_from_multipolicy_policy create mode 100644 content/base/test/csp/test_policyuri_regression_from_multipolicy.html diff --git a/content/base/src/CSPUtils.jsm b/content/base/src/CSPUtils.jsm index a84ed96f7a7d..a9898f8a3264 100644 --- a/content/base/src/CSPUtils.jsm +++ b/content/base/src/CSPUtils.jsm @@ -242,23 +242,23 @@ CSPRep.ALLOW_DIRECTIVE = "allow"; * string rep of a CSP * @param self (optional) * URI representing the "self" source + * @param reportOnly (optional) + * whether or not this CSP is report-only (defaults to false) * @param docRequest (optional) * request for the parent document which may need to be suspended * while the policy-uri is asynchronously fetched * @param csp (optional) * the CSP object to update once the policy has been fetched - * @param reportOnly (optional) - * whether or not this CSP is report-only (defaults to false) * @returns * an instance of CSPRep */ -CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { - if (typeof reportOnly === 'undefined') reportOnly = false; +CSPRep.fromString = function(aStr, self, reportOnly, docRequest, csp) { var SD = CSPRep.SRC_DIRECTIVES_OLD; var UD = CSPRep.URI_DIRECTIVES; var aCSPR = new CSPRep(); aCSPR._originalText = aStr; aCSPR._innerWindowID = innerWindowFromRequest(docRequest); + if (typeof reportOnly === 'undefined') reportOnly = false; aCSPR._reportOnlyMode = reportOnly; var selfUri = null; @@ -416,13 +416,13 @@ CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { // POLICY_URI can only be alone if (aCSPR._directives.length > 0 || dirs.length > 1) { cspError(aCSPR, CSPLocalizer.getStr("policyURINotAlone")); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } // if we were called without a reference to the parent document request // we won't be able to suspend it while we fetch the policy -> fail closed if (!docRequest || !csp) { cspError(aCSPR, CSPLocalizer.getStr("noParentRequest")); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } var uri = ''; @@ -431,7 +431,7 @@ CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { } catch(e) { cspError(aCSPR, CSPLocalizer.getFormatStr("policyURIParseError", [dirvalue])); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } // Verify that policy URI comes from the same origin @@ -439,17 +439,17 @@ CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { if (selfUri.host !== uri.host) { cspError(aCSPR, CSPLocalizer.getFormatStr("nonMatchingHost", [uri.host])); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } if (selfUri.port !== uri.port) { cspError(aCSPR, CSPLocalizer.getFormatStr("nonMatchingPort", [uri.port.toString()])); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } if (selfUri.scheme !== uri.scheme) { cspError(aCSPR, CSPLocalizer.getFormatStr("nonMatchingScheme", [uri.scheme])); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } } @@ -468,12 +468,12 @@ CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { docRequest.resume(); cspError(aCSPR, CSPLocalizer.getFormatStr("errorFetchingPolicy", [e.toString()])); - return CSPRep.fromString("default-src 'none'"); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } // return a fully-open policy to be used until the contents of the // policy-uri come back. - return CSPRep.fromString("default-src *"); + return CSPRep.fromString("default-src *", null, reportOnly); } // UNIDENTIFIED DIRECTIVE ///////////////////////////////////////////// @@ -486,8 +486,7 @@ CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { // directive to be present. if (!aCSPR._directives[SD.DEFAULT_SRC]) { cspWarn(aCSPR, CSPLocalizer.getStr("allowOrDefaultSrcRequired")); - return CSPRep.fromString("default-src 'none'", selfUri, docRequest, csp, - reportOnly); + return CSPRep.fromString("default-src 'none'", null, reportOnly); } return aCSPR; }; @@ -500,26 +499,25 @@ CSPRep.fromString = function(aStr, self, docRequest, csp, reportOnly) { * string rep of a CSP * @param self (optional) * URI representing the "self" source + * @param reportOnly (optional) + * whether or not this CSP is report-only (defaults to false) * @param docRequest (optional) * request for the parent document which may need to be suspended * while the policy-uri is asynchronously fetched * @param csp (optional) * the CSP object to update once the policy has been fetched - * @param reportOnly (optional) - * whether or not this CSP is report-only (defaults to false) * @returns * an instance of CSPRep */ // When we deprecate our original CSP implementation, we rename this to // CSPRep.fromString and remove the existing CSPRep.fromString above. -CSPRep.fromStringSpecCompliant = function(aStr, self, docRequest, csp, reportOnly) { - if (typeof reportOnly === 'undefined') reportOnly = false; - +CSPRep.fromStringSpecCompliant = function(aStr, self, reportOnly, docRequest, csp) { var SD = CSPRep.SRC_DIRECTIVES_NEW; var UD = CSPRep.URI_DIRECTIVES; var aCSPR = new CSPRep(true); aCSPR._originalText = aStr; aCSPR._innerWindowID = innerWindowFromRequest(docRequest); + if (typeof reportOnly === 'undefined') reportOnly = false; aCSPR._reportOnlyMode = reportOnly; var selfUri = null; @@ -682,13 +680,13 @@ CSPRep.fromStringSpecCompliant = function(aStr, self, docRequest, csp, reportOnl // POLICY_URI can only be alone if (aCSPR._directives.length > 0 || dirs.length > 1) { cspError(aCSPR, CSPLocalizer.getStr("policyURINotAlone")); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } // if we were called without a reference to the parent document request // we won't be able to suspend it while we fetch the policy -> fail closed if (!docRequest || !csp) { cspError(aCSPR, CSPLocalizer.getStr("noParentRequest")); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } var uri = ''; @@ -696,22 +694,22 @@ CSPRep.fromStringSpecCompliant = function(aStr, self, docRequest, csp, reportOnl uri = gIoService.newURI(dirvalue, null, selfUri); } catch(e) { cspError(aCSPR, CSPLocalizer.getFormatStr("policyURIParseError", [dirvalue])); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } // Verify that policy URI comes from the same origin if (selfUri) { if (selfUri.host !== uri.host){ cspError(aCSPR, CSPLocalizer.getFormatStr("nonMatchingHost", [uri.host])); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } if (selfUri.port !== uri.port){ cspError(aCSPR, CSPLocalizer.getFormatStr("nonMatchingPort", [uri.port.toString()])); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } if (selfUri.scheme !== uri.scheme){ cspError(aCSPR, CSPLocalizer.getFormatStr("nonMatchingScheme", [uri.scheme])); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } } @@ -723,18 +721,18 @@ CSPRep.fromStringSpecCompliant = function(aStr, self, docRequest, csp, reportOnl // policy-uri can't be abused for CSRF chan.loadFlags |= Components.interfaces.nsIChannel.LOAD_ANONYMOUS; chan.loadGroup = docRequest.loadGroup; - chan.asyncOpen(new CSPPolicyURIListener(uri, docRequest, csp), null); + chan.asyncOpen(new CSPPolicyURIListener(uri, docRequest, csp, reportOnly), null); } catch (e) { // resume the document request and apply most restrictive policy docRequest.resume(); cspError(aCSPR, CSPLocalizer.getFormatStr("errorFetchingPolicy", [e.toString()])); - return CSPRep.fromStringSpecCompliant("default-src 'none'"); + return CSPRep.fromStringSpecCompliant("default-src 'none'", null, reportOnly); } // return a fully-open policy to be used until the contents of the // policy-uri come back - return CSPRep.fromStringSpecCompliant("default-src *"); + return CSPRep.fromStringSpecCompliant("default-src *", null, reportOnly); } // UNIDENTIFIED DIRECTIVE ///////////////////////////////////////////// diff --git a/content/base/src/contentSecurityPolicy.js b/content/base/src/contentSecurityPolicy.js index a5c14ac380ff..06cf4b69beca 100644 --- a/content/base/src/contentSecurityPolicy.js +++ b/content/base/src/contentSecurityPolicy.js @@ -311,15 +311,15 @@ ContentSecurityPolicy.prototype = { if (aSpecCompliant) { newpolicy = CSPRep.fromStringSpecCompliant(aPolicy, selfURI, + aReportOnly, this._docRequest, - this, - aReportOnly); + this); } else { newpolicy = CSPRep.fromString(aPolicy, selfURI, + aReportOnly, this._docRequest, - this, - aReportOnly); + this); } newpolicy._specCompliant = !!aSpecCompliant; diff --git a/content/base/test/csp/file_policyuri_regression_from_multipolicy.html b/content/base/test/csp/file_policyuri_regression_from_multipolicy.html new file mode 100644 index 000000000000..2a75eef7e8ca --- /dev/null +++ b/content/base/test/csp/file_policyuri_regression_from_multipolicy.html @@ -0,0 +1,9 @@ + + + +
Inline script didn't run
+ + + diff --git a/content/base/test/csp/file_policyuri_regression_from_multipolicy.html^headers^ b/content/base/test/csp/file_policyuri_regression_from_multipolicy.html^headers^ new file mode 100644 index 000000000000..4b4dcecaec53 --- /dev/null +++ b/content/base/test/csp/file_policyuri_regression_from_multipolicy.html^headers^ @@ -0,0 +1 @@ +content-security-policy-report-only: policy-uri /tests/content/base/test/csp/file_CSP_policyuri_regression_from_multipolicy_policy diff --git a/content/base/test/csp/file_policyuri_regression_from_multipolicy_policy b/content/base/test/csp/file_policyuri_regression_from_multipolicy_policy new file mode 100644 index 000000000000..a5c610cd7bcd --- /dev/null +++ b/content/base/test/csp/file_policyuri_regression_from_multipolicy_policy @@ -0,0 +1 @@ +default-src 'self'; diff --git a/content/base/test/csp/mochitest.ini b/content/base/test/csp/mochitest.ini index fd95b4a27b61..b0634e0c3afd 100644 --- a/content/base/test/csp/mochitest.ini +++ b/content/base/test/csp/mochitest.ini @@ -82,6 +82,9 @@ support-files = file_CSP_bug909029_star.html^headers^ file_CSP_bug909029_none.html file_CSP_bug909029_none.html^headers^ + file_policyuri_regression_from_multipolicy.html + file_policyuri_regression_from_multipolicy.html^headers^ + file_policyuri_regression_from_multipolicy_policy [test_CSP.html] [test_CSP_bug663567.html] @@ -99,3 +102,4 @@ support-files = [test_csp_redirects.html] [test_CSP_bug910139.html] [test_CSP_bug909029.html] +[test_policyuri_regression_from_multipolicy.html] diff --git a/content/base/test/csp/test_policyuri_regression_from_multipolicy.html b/content/base/test/csp/test_policyuri_regression_from_multipolicy.html new file mode 100644 index 000000000000..2b2b59e9027b --- /dev/null +++ b/content/base/test/csp/test_policyuri_regression_from_multipolicy.html @@ -0,0 +1,29 @@ + + + + Test for Bug 924708 + + + + + + + + + diff --git a/content/base/test/unit/test_bug558431.js b/content/base/test/unit/test_bug558431.js index 0fbaa71e8e6b..2842f3cabf4e 100644 --- a/content/base/test/unit/test_bug558431.js +++ b/content/base/test/unit/test_bug558431.js @@ -139,7 +139,7 @@ function test_CSPRep_fromPolicyURI() { // "allow *"; when the policy-uri fetching call-back happens, the *real* // policy will be in csp.policy CSPRep.fromString("policy-uri " + POLICY_URI, - mkuri(DOCUMENT_URI), docChan, csp); + mkuri(DOCUMENT_URI), false, docChan, csp); } function test_CSPRep_fromRelativePolicyURI() { @@ -159,5 +159,5 @@ function test_CSPRep_fromRelativePolicyURI() { // "allow *"; when the policy-uri fetching call-back happens, the *real* // policy will be in csp.policy CSPRep.fromString("policy-uri " + POLICY_URI_RELATIVE, - mkuri(DOCUMENT_URI), docChan, csp); + mkuri(DOCUMENT_URI), false, docChan, csp); } diff --git a/testing/mochitest/b2g.json b/testing/mochitest/b2g.json index 1d3575b4312a..6c0a3d292814 100644 --- a/testing/mochitest/b2g.json +++ b/testing/mochitest/b2g.json @@ -210,6 +210,7 @@ "content/base/test/csp/test_bug836922_npolicies.html":"observer not working", "content/base/test/csp/test_CSP_bug916446.html":"observer not working", "content/base/test/csp/test_CSP_bug909029.html":"observer not working", + "content/base/test/csp/test_policyuri_regression_from_multipolicy.html":"observer not working", "content/base/test/test_CrossSiteXHR_origin.html":"https not working, bug 907770", "content/base/test/test_plugin_freezing.html":"", From cccce8b04baf6da9bed1e8c530968f2743eb03bb Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Thu, 31 Oct 2013 22:48:46 -0400 Subject: [PATCH 048/795] Bug 929299 - Fix DrawTargetSkia to not copy and render in place. r=gwright --- gfx/2d/DrawTargetSkia.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp index f83ef8509f0e..5ae1a9b6a9ab 100644 --- a/gfx/2d/DrawTargetSkia.cpp +++ b/gfx/2d/DrawTargetSkia.cpp @@ -745,19 +745,14 @@ DrawTargetSkia::Init(unsigned char* aData, const IntSize &aSize, int32_t aStride ConvertBGRXToBGRA(aData, aSize, aStride); isOpaque = true; } - - SkAutoTUnref device(new SkDevice(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, isOpaque)); - SkBitmap bitmap = (SkBitmap)device->accessBitmap(true); - bitmap.lockPixels(); - bitmap.setPixels(aData); + SkBitmap bitmap; bitmap.setConfig(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height, aStride); - bitmap.unlockPixels(); - bitmap.notifyPixelsChanged(); + bitmap.setPixels(aData); + bitmap.setIsOpaque(isOpaque); + SkAutoTUnref canvas(new SkCanvas(new SkDevice(bitmap))); - SkAutoTUnref canvas(new SkCanvas(device.get())); mSize = aSize; - mCanvas = canvas.get(); mFormat = aFormat; } From 8a7175ea9f5c7a3513fc63ae998594310cb45c6e Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Fri, 1 Nov 2013 13:44:27 +1100 Subject: [PATCH 049/795] Bug 927734 - Loosen assertions about the contents of the style scope stack. r=dbaron --HG-- extra : rebase_source : 6b9b7e4051bebeb7da640c7878229b1d014841dd --- layout/style/crashtests/927734-1.html | 10 ++++++++++ layout/style/crashtests/crashtests.list | 1 + layout/style/nsCSSRuleProcessor.cpp | 1 + layout/style/nsRuleProcessorData.h | 17 +++++------------ 4 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 layout/style/crashtests/927734-1.html diff --git a/layout/style/crashtests/927734-1.html b/layout/style/crashtests/927734-1.html new file mode 100644 index 000000000000..bd99f9b9ee39 --- /dev/null +++ b/layout/style/crashtests/927734-1.html @@ -0,0 +1,10 @@ + + + + + +
+ + +
+ diff --git a/layout/style/crashtests/crashtests.list b/layout/style/crashtests/crashtests.list index c68685163324..523929f7eab2 100644 --- a/layout/style/crashtests/crashtests.list +++ b/layout/style/crashtests/crashtests.list @@ -97,3 +97,4 @@ load 867487.html load 880862.html load 873222.html load 915440.html +load 927734-1.html diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index f13fa336c5bf..13cafc3212f1 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -3410,6 +3410,7 @@ TreeMatchContext::InitAncestors(Element *aElement) { MOZ_ASSERT(!mAncestorFilter.mFilter); MOZ_ASSERT(mAncestorFilter.mHashes.IsEmpty()); + MOZ_ASSERT(mStyleScopes.IsEmpty()); mAncestorFilter.mFilter = new AncestorFilter::Filter(); diff --git a/layout/style/nsRuleProcessorData.h b/layout/style/nsRuleProcessorData.h index d66f83f7483c..f07bb5f9e4f7 100644 --- a/layout/style/nsRuleProcessorData.h +++ b/layout/style/nsRuleProcessorData.h @@ -176,20 +176,13 @@ struct MOZ_STACK_CLASS TreeMatchContext { #ifdef DEBUG void AssertHasAllStyleScopes(mozilla::dom::Element* aElement) { - int32_t i = mStyleScopes.Length() - 1; - nsINode* node = aElement->GetParentNode(); - while (node && i != -1) { - if (node->IsScopedStyleRoot()) { - MOZ_ASSERT(mStyleScopes[i] == node); - --i; + nsINode* cur = aElement->GetParentNode(); + while (cur) { + if (cur->IsScopedStyleRoot()) { + MOZ_ASSERT(mStyleScopes.Contains(cur)); } - node = node->GetParentNode(); + cur = cur->GetParentNode(); } - while (node) { - MOZ_ASSERT(!node->IsScopedStyleRoot()); - node = node->GetParentNode(); - } - MOZ_ASSERT(i == -1); } #endif From 63e8d03dd6c347a6946bafb4c188f58a3d5c333f Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Fri, 1 Nov 2013 13:44:40 +1100 Subject: [PATCH 050/795] Bug 930270 - Don't initialize the ancestor filter for elements outside the document. r=dbaron --HG-- extra : rebase_source : fa10a28a8bbd9eaf670f8133ccd81a9c706ebec7 --- layout/style/crashtests/930270-1.html | 6 ++++++ layout/style/crashtests/930270-2.html | 9 +++++++++ layout/style/crashtests/crashtests.list | 2 ++ layout/style/nsCSSRuleProcessor.cpp | 26 +++++++++++++++++++++++++ layout/style/nsRuleProcessorData.h | 8 +++++++- layout/style/nsStyleSet.cpp | 18 ++++++++--------- 6 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 layout/style/crashtests/930270-1.html create mode 100644 layout/style/crashtests/930270-2.html diff --git a/layout/style/crashtests/930270-1.html b/layout/style/crashtests/930270-1.html new file mode 100644 index 000000000000..cbdf5a9e3842 --- /dev/null +++ b/layout/style/crashtests/930270-1.html @@ -0,0 +1,6 @@ + +
+ + +
From f0af93a2925da40cc40eb8baee843dd3b9831e46 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Fri, 1 Nov 2013 14:47:44 +0100 Subject: [PATCH 182/795] Bug 925949: Add fastpath to zeroLastIndex the normal RegExpObject, r=jwalden --- js/src/jsstr.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index ccc86152a5a7..b2e06a9863e0 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -1788,8 +1788,14 @@ class MOZ_STACK_CLASS StringRegExpGuard if (!regExpIsObject()) return true; - // Don't use RegExpObject::setLastIndex, because that ignores the - // writability of "lastIndex" on this user-controlled RegExp object. + // Use a fast path for same-global RegExp objects with writable + // lastIndex. + if (obj_->is() && obj_->nativeLookup(cx, cx->names().lastIndex)->writable()) { + obj_->as().zeroLastIndex(); + return true; + } + + // Handle everything else generically (including throwing if .lastIndex is non-writable). RootedValue zero(cx, Int32Value(0)); return JSObject::setProperty(cx, obj_, obj_, cx->names().lastIndex, &zero, true); } From 4c0646b2d25849cac5229b2fb168bc43d2829167 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 30 Oct 2013 16:58:45 -0700 Subject: [PATCH 183/795] Bug 925571 - Build config for plugin_container windows sandboxing. r=bsmedberg --- ipc/app/Makefile.in | 10 +++++++++ ipc/glue/Makefile.in | 6 ++++++ security/sandbox/moz.build | 3 +++ .../sandbox/win/src/sandboxbroker/Makefile.in | 21 +++++++++++++++++++ .../sandbox/win/src/sandboxbroker/moz.build | 17 +++++++++++++++ toolkit/library/Makefile.in | 7 +++++++ 6 files changed, 64 insertions(+) create mode 100644 security/sandbox/win/src/sandboxbroker/Makefile.in create mode 100644 security/sandbox/win/src/sandboxbroker/moz.build diff --git a/ipc/app/Makefile.in b/ipc/app/Makefile.in index 935f9a45f320..6399fd2b3fb0 100644 --- a/ipc/app/Makefile.in +++ b/ipc/app/Makefile.in @@ -50,6 +50,16 @@ include $(topsrcdir)/config/rules.mk LDFLAGS += $(MOZ_ALLOW_HEAP_EXECUTE_FLAGS) ifeq ($(OS_ARCH),WINNT) #{ + +ifdef MOZ_CONTENT_SANDBOX +LIBS += ../../security/sandbox/$(LIB_PREFIX)sandbox_s.$(LIB_SUFFIX) +LIBS += $(NSPR_LIBS) +LOCAL_INCLUDES += \ + -I$(topsrcdir)/security/sandbox \ + -I$(topsrcdir)/security/ \ + $(NULL) +endif + # Note the manifest file exists in the tree, so we use the explicit filename # here. EXTRA_DEPS += plugin-container.exe.manifest diff --git a/ipc/glue/Makefile.in b/ipc/glue/Makefile.in index db14b2daa3a3..ca6b5ec22954 100644 --- a/ipc/glue/Makefile.in +++ b/ipc/glue/Makefile.in @@ -8,3 +8,9 @@ DEFINES += -DMOZ_CHILD_PROCESS_NAME=\"$(MOZ_CHILD_PROCESS_NAME)\" DEFINES += -DMOZ_CHILD_PROCESS_BUNDLE=\"$(MOZ_CHILD_PROCESS_BUNDLE)\" include $(topsrcdir)/config/rules.mk + +ifdef MOZ_CONTENT_SANDBOX +ifeq ($(OS_ARCH),WINNT) +LOCAL_INCLUDES += -I$(topsrcdir)/security/sandbox/win/src/sandboxbroker +endif +endif diff --git a/security/sandbox/moz.build b/security/sandbox/moz.build index 6b386953860f..28c144dda11e 100644 --- a/security/sandbox/moz.build +++ b/security/sandbox/moz.build @@ -13,6 +13,9 @@ elif CONFIG['OS_ARCH'] == 'WINNT': MODULE = 'sandbox' LIBRARY_NAME = 'sandbox_s' EXPORT_LIBRARY = True + FORCE_STATIC_LIB = True + + DIRS += ['win/src/sandboxbroker'] SOURCES += [ 'base/at_exit.cc', diff --git a/security/sandbox/win/src/sandboxbroker/Makefile.in b/security/sandbox/win/src/sandboxbroker/Makefile.in new file mode 100644 index 000000000000..5798c5244426 --- /dev/null +++ b/security/sandbox/win/src/sandboxbroker/Makefile.in @@ -0,0 +1,21 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +FORCE_SHARED_LIB = 1 +MOZ_GLUE_LDFLAGS = +STL_FLAGS = + +LOCAL_INCLUDES += \ + -I$(topsrcdir)/security \ + -I$(topsrcdir)/security/sandbox \ + $(NULL) + +SHARED_LIBRARY_LIBS += \ + ../../../$(LIB_PREFIX)sandbox_s.$(LIB_SUFFIX) \ + $(NSPR_LIBS) \ + $(NULL) + +OS_LIBS += $(call EXPAND_LIBNAME,dbghelp) + +DEFINES += -DUNICODE -D_UNICODE -DNS_NO_XPCOM -DNOMINMAX -DSANDBOX_EXPORTS diff --git a/security/sandbox/win/src/sandboxbroker/moz.build b/security/sandbox/win/src/sandboxbroker/moz.build new file mode 100644 index 000000000000..bad0179334d1 --- /dev/null +++ b/security/sandbox/win/src/sandboxbroker/moz.build @@ -0,0 +1,17 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +MODULE = 'sandboxbroker' +LIBRARY_NAME = 'sandboxbroker_s' +EXPORT_LIBRARY = True + +SOURCES += [ + 'sandboxBroker.cpp', +] + +EXPORTS += [ + 'sandboxBroker.h', +] diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 3746e7f20571..9f6177a42300 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -40,6 +40,13 @@ SHARED_LIBRARY_LIBS += \ $(NULL) endif +ifdef MOZ_CONTENT_SANDBOX +ifeq ($(OS_ARCH),WINNT) + LOCAL_INCLUDES += -I$(srcdir)/../sandboxbroker + SHARED_LIBRARY_LIBS += ../../security/sandbox/win/src/sandboxbroker/$(LIB_PREFIX)sandboxbroker_s.$(LIB_SUFFIX) +endif +endif + ifdef MOZ_XUL SHARED_LIBRARY_LIBS += $(DEPTH)/accessible/src/xul/$(LIB_PREFIX)accessibility_xul_s.$(LIB_SUFFIX) endif From 1dbd236c5cfb70d3ae11e56c0f9a729bdc7fd9a1 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 30 Oct 2013 16:58:49 -0700 Subject: [PATCH 184/795] Bug 925571 - Initial Windows sandbox target process (plugin-container) code. r=aklotz --- ipc/app/MozillaRuntimeMain.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/ipc/app/MozillaRuntimeMain.cpp b/ipc/app/MozillaRuntimeMain.cpp index e1f3388bbf02..995abd5e53a7 100644 --- a/ipc/app/MozillaRuntimeMain.cpp +++ b/ipc/app/MozillaRuntimeMain.cpp @@ -18,10 +18,15 @@ // but we don't want its DLL load protection, because we'll handle it here #define XRE_DONT_PROTECT_DLL_LOAD #include "nsWindowsWMain.cpp" - #include "nsSetDllDirectory.h" #endif +#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) +#include "sandbox/base/basictypes.h" +#include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sandbox_factory.h" +#endif + #ifdef MOZ_WIDGET_GONK # include # include @@ -93,14 +98,26 @@ main(int argc, char* argv[]) #endif #endif -#if defined(XP_WIN) && defined(DEBUG_bent) - MessageBox(nullptr, L"Hi", L"Hi", MB_OK); +#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) + sandbox::TargetServices* target_service = + sandbox::SandboxFactory::GetTargetServices(); + if (!target_service) { + return 1; + } + + sandbox::ResultCode result = target_service->Init(); + if (result != sandbox::SBOX_ALL_OK) { + return 2; + } + + // Initialization is finished, switch to the lowered token + target_service->LowerToken(); #endif // Check for the absolute minimum number of args we need to move // forward here. We expect the last arg to be the child process type. if (argc < 1) - return 1; + return 3; GeckoProcessType proctype = XRE_StringToChildProcessType(argv[--argc]); #ifdef XP_WIN From eba93af7a1ae02c02a1adcaefd95c363b6f65f9d Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 30 Oct 2013 16:58:52 -0700 Subject: [PATCH 185/795] Bug 925571 - Initial Windows content process sandbox broker code. r=aklotz --- ipc/glue/GeckoChildProcessHost.cpp | 12 ++++ .../win/src/sandboxbroker/sandboxBroker.cpp | 70 +++++++++++++++++++ .../win/src/sandboxbroker/sandboxBroker.h | 36 ++++++++++ 3 files changed, 118 insertions(+) create mode 100644 security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp create mode 100644 security/sandbox/win/src/sandboxbroker/sandboxBroker.h diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 573e94339873..eaf805b35ee0 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -6,6 +6,10 @@ #include "GeckoChildProcessHost.h" +#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) +#include "sandboxBroker.h" +#endif + #include "base/command_line.h" #include "base/path_service.h" #include "base/string_util.h" @@ -756,7 +760,15 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt // Process type cmdLine.AppendLooseValue(UTF8ToWide(childProcessType)); +#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) + mozilla::SandboxBroker sandboxBroker; + sandboxBroker.LaunchApp(cmdLine.program().c_str(), + cmdLine.command_line_string().c_str(), + &process); +#else base::LaunchApp(cmdLine, false, false, &process); +#endif + #else # error Sorry diff --git a/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp new file mode 100644 index 000000000000..7427946282ac --- /dev/null +++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "sandboxBroker.h" +#include "sandbox/win/src/sandbox.h" +#include "sandbox/win/src/sandbox_factory.h" + +namespace mozilla +{ + +SandboxBroker::SandboxBroker() : + mBrokerService(nullptr) +{ +} + +bool +SandboxBroker::LaunchApp(const wchar_t *aPath, + const wchar_t *aArguments, + void **aProcessHandle) +{ + sandbox::ResultCode result; + + // If the broker service isn't already initialized, do it now + if (!mBrokerService) { + mBrokerService = sandbox::SandboxFactory::GetBrokerServices(); + if (!mBrokerService) { + return false; + } + + result = mBrokerService->Init(); + if (result != sandbox::SBOX_ALL_OK) { + return false; + } + } + + // Setup the sandbox policy, this is initially: + // Medium integrity, unrestricted, in the same window station, within the + // same desktop, and has no job object. + // We'll start to increase the restrictions over time. + sandbox::TargetPolicy *policy = mBrokerService->CreatePolicy(); + policy->SetJobLevel(sandbox::JOB_NONE, 0); + policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, + sandbox::USER_RESTRICTED_SAME_ACCESS); + policy->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_MEDIUM); + + // Ceate the sandboxed process + PROCESS_INFORMATION targetInfo; + result = mBrokerService->SpawnTarget(aPath, aArguments, policy, &targetInfo); + + // The sandboxed process is started in a suspended state, resumeit now that + // we'eve set things up. + ResumeThread(targetInfo.hThread); + CloseHandle(targetInfo.hThread); + + // Return the process handle to the caller + *aProcessHandle = targetInfo.hProcess; + + policy->Release(); + + return true; +} + +SandboxBroker::~SandboxBroker() +{ +} + +} diff --git a/security/sandbox/win/src/sandboxbroker/sandboxBroker.h b/security/sandbox/win/src/sandboxbroker/sandboxBroker.h new file mode 100644 index 000000000000..9657a639d7cb --- /dev/null +++ b/security/sandbox/win/src/sandboxbroker/sandboxBroker.h @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef __SECURITY_SANDBOX_SANDBOXBROKER_H__ +#define __SECURITY_SANDBOX_SANDBOXBROKER_H__ + +#ifdef SANDBOX_EXPORTS +#define SANDBOX_EXPORT __declspec(dllexport) +#else +#define SANDBOX_EXPORT __declspec(dllimport) +#endif + +namespace sandbox { + class BrokerServices; +} + +namespace mozilla { + +class SANDBOX_EXPORT SandboxBroker +{ +public: + SandboxBroker(); + bool LaunchApp(const wchar_t *aPath, const wchar_t *aArguments, + void **aProcessHandle); + virtual ~SandboxBroker(); + +private: + sandbox::BrokerServices *mBrokerService; +}; + +} // mozilla + +#endif From 71d02b04887746b8bec892e038033c60b3b44992 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 30 Oct 2013 16:58:56 -0700 Subject: [PATCH 186/795] Bug 925571 - Packaging for Sandboxing dll. r=bsmedberg --- browser/installer/package-manifest.in | 5 +++++ security/sandbox/win/src/sandboxbroker/moz.build | 2 +- toolkit/library/Makefile.in | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 02250c4abb65..c6249313dde8 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -698,6 +698,11 @@ @BINPATH@/components/pipnss.xpt @BINPATH@/components/pippki.xpt +; For content sandboxing +#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) +@BINPATH@/@DLL_PREFIX@sandboxbroker@DLL_SUFFIX@ +#endif + ; for Solaris SPARC #ifdef SOLARIS bin/libfreebl_32fpu_3.so diff --git a/security/sandbox/win/src/sandboxbroker/moz.build b/security/sandbox/win/src/sandboxbroker/moz.build index bad0179334d1..f2f0894bb750 100644 --- a/security/sandbox/win/src/sandboxbroker/moz.build +++ b/security/sandbox/win/src/sandboxbroker/moz.build @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. MODULE = 'sandboxbroker' -LIBRARY_NAME = 'sandboxbroker_s' +LIBRARY_NAME = 'sandboxbroker' EXPORT_LIBRARY = True SOURCES += [ diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 9f6177a42300..6dffaba2843c 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -43,7 +43,7 @@ endif ifdef MOZ_CONTENT_SANDBOX ifeq ($(OS_ARCH),WINNT) LOCAL_INCLUDES += -I$(srcdir)/../sandboxbroker - SHARED_LIBRARY_LIBS += ../../security/sandbox/win/src/sandboxbroker/$(LIB_PREFIX)sandboxbroker_s.$(LIB_SUFFIX) + SHARED_LIBRARY_LIBS += ../../security/sandbox/win/src/sandboxbroker/$(LIB_PREFIX)sandboxbroker.$(LIB_SUFFIX) endif endif From 3a11641f785f873cb826dfe471bb080531d02508 Mon Sep 17 00:00:00 2001 From: "Nicholas D. Matsakis" Date: Fri, 20 Sep 2013 16:19:29 -0400 Subject: [PATCH 187/795] Bug 922216 - Self-host equivalent() for typed objects r=till --- js/src/builtin/TypedObject.cpp | 42 +------------ js/src/builtin/TypedObject.js | 9 +++ js/src/tests/ecma_6/TypedObject/arrayequiv.js | 59 +++++++++++++++++++ .../tests/ecma_6/TypedObject/simpleequiv.js | 34 +++++++++++ .../tests/ecma_6/TypedObject/structequiv.js | 2 +- 5 files changed, 106 insertions(+), 40 deletions(-) create mode 100644 js/src/tests/ecma_6/TypedObject/arrayequiv.js create mode 100644 js/src/tests/ecma_6/TypedObject/simpleequiv.js diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 2d2f0c76cbdd..d58b2e971bf1 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -291,38 +291,6 @@ IsTypedDatumOfKind(JSObject &obj, TypeRepresentation::Kind kind) return repr->kind() == kind; } -static bool -TypeEquivalent(JSContext *cx, unsigned int argc, Value *vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - - RootedObject thisObj(cx, ToObjectIfObject(args.thisv())); - if (!thisObj || !IsTypeObject(*thisObj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, - JSMSG_INCOMPATIBLE_PROTO, - "Type", "equivalent", - InformalValueTypeName(args.thisv())); - return false; - } - - if (args.length() < 1) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, - "Type.equivalent", "1", "s"); - return false; - } - - RootedObject otherObj(cx, ToObjectIfObject(args[0])); - if (!otherObj || !IsTypeObject(*otherObj)) { - JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPEDOBJECT_NOT_TYPE_OBJECT); - return false; - } - - TypeRepresentation *thisRepr = typeRepresentation(*thisObj); - TypeRepresentation *otherRepr = typeRepresentation(*otherObj); - args.rval().setBoolean(thisRepr == otherRepr); - return true; -} - #define BINARYDATA_NUMERIC_CLASSES(constant_, type_, name_) \ { \ #name_, \ @@ -344,6 +312,7 @@ TypeEquivalent(JSContext *cx, unsigned int argc, Value *vp) static const JSFunctionSpec NumericTypeObjectMethods[] = { {"handle", {nullptr, nullptr}, 2, 0, "HandleCreate"}, + {"equivalent", {nullptr, nullptr}, 1, 0, "TypeObjectEquivalent"}, JS_FS_END }; @@ -549,6 +518,7 @@ const JSFunctionSpec ArrayType::typeObjectMethods[] = { {"handle", {nullptr, nullptr}, 2, 0, "HandleCreate"}, JS_FN("repeat", ArrayType::repeat, 1, 0), JS_FN("toSource", ArrayType::toSource, 0, 0), + {"equivalent", {nullptr, nullptr}, 1, 0, "TypeObjectEquivalent"}, JS_FS_END }; @@ -790,13 +760,6 @@ InitializeCommonTypeDescriptorProperties(JSContext *cx, TypeRepresentation *typeRepr = TypeRepresentation::fromOwnerObject(*typeReprOwnerObj); - // equivalent() - if (!JS_DefineFunction(cx, obj, "equivalent", - TypeEquivalent, 1, 0)) - { - return false; - } - // byteLength RootedValue typeByteLength(cx, NumberValue(typeRepr->size())); if (!JSObject::defineProperty(cx, obj, cx->names().byteLength, @@ -980,6 +943,7 @@ const JSPropertySpec StructType::typeObjectProperties[] = { const JSFunctionSpec StructType::typeObjectMethods[] = { {"handle", {nullptr, nullptr}, 2, 0, "HandleCreate"}, JS_FN("toSource", StructType::toSource, 0, 0), + {"equivalent", {nullptr, nullptr}, 1, 0, "TypeObjectEquivalent"}, JS_FS_END }; diff --git a/js/src/builtin/TypedObject.js b/js/src/builtin/TypedObject.js index 8b69aae76caa..3a80d6873ea4 100644 --- a/js/src/builtin/TypedObject.js +++ b/js/src/builtin/TypedObject.js @@ -404,6 +404,15 @@ function FillTypedArrayWithValue(destArray, fromValue) { Memcpy(destArray, offset, destArray, 0, elementSize); } +// Warning: user exposed! +function TypeObjectEquivalent(otherTypeObj) { + if (!IsObject(this) || !ObjectIsTypeObject(this)) + ThrowError(JSMSG_TYPEDOBJECT_HANDLE_BAD_ARGS, "this", "type object"); + if (!IsObject(otherTypeObj) || !ObjectIsTypeObject(otherTypeObj)) + ThrowError(JSMSG_TYPEDOBJECT_HANDLE_BAD_ARGS, "1", "type object"); + return TYPE_TYPE_REPR(this) === TYPE_TYPE_REPR(otherTypeObj); +} + /////////////////////////////////////////////////////////////////////////// // Handles // diff --git a/js/src/tests/ecma_6/TypedObject/arrayequiv.js b/js/src/tests/ecma_6/TypedObject/arrayequiv.js new file mode 100644 index 000000000000..65a6e5f00921 --- /dev/null +++ b/js/src/tests/ecma_6/TypedObject/arrayequiv.js @@ -0,0 +1,59 @@ +// |reftest| skip-if(!this.hasOwnProperty("TypedObject")) +var BUGNUMBER = 922216; +var summary = 'TypedObjects Equivalent ArrayTypes'; + +var ArrayType = TypedObject.ArrayType; +var StructType = TypedObject.StructType; +var uint8 = TypedObject.uint8; +var uint16 = TypedObject.uint16; +var uint32 = TypedObject.uint32; +var uint8Clamped = TypedObject.uint8Clamped; +var int8 = TypedObject.int8; +var int16 = TypedObject.int16; +var int32 = TypedObject.int32; +var float32 = TypedObject.float32; +var float64 = TypedObject.float64; + +function assertEquivalent(t1, t2) { + assertEq(true, t1.equivalent(t2)); + assertEq(true, t2.equivalent(t1)); +} + +function assertNotEquivalent(t1, t2) { + assertEq(false, t1.equivalent(t2)); + assertEq(false, t2.equivalent(t1)); +} + +function runTests() { + print(BUGNUMBER + ": " + summary); + + // Create a line: + var PixelType1 = new StructType({x: uint8, y: uint8}); + var PixelsType1 = new ArrayType(PixelType1, 22); + + // Sanity checks about type equivalence: + assertEquivalent(PixelType1, PixelType1); + assertEquivalent(PixelsType1, PixelsType1); + assertNotEquivalent(PixelType1, PixelsType1); + + // Define the same two types again. Equivalent. + var PixelType2 = new StructType({x: uint8, y: uint8}); + var PixelsType2 = new ArrayType(PixelType2, 22); + assertEquivalent(PixelType1, PixelType2); + assertEquivalent(PixelsType1, PixelsType2); + + // Define the pixel type with field order reversed. Not equivalent. + var PixelType3 = new StructType({y: uint8, x: uint8}); + var PixelsType3 = new ArrayType(PixelType3, 22); + assertNotEquivalent(PixelType1, PixelType3); + assertNotEquivalent(PixelsType1, PixelsType3); + + // Define the pixels type with different number of elements. Not equivalent. + var PixelsType3 = new ArrayType(PixelType1, 23); + assertNotEquivalent(PixelsType1, PixelsType3); + + reportCompare(true, true); + print("Tests complete"); +} + +runTests(); diff --git a/js/src/tests/ecma_6/TypedObject/simpleequiv.js b/js/src/tests/ecma_6/TypedObject/simpleequiv.js new file mode 100644 index 000000000000..d8fb3c2f1195 --- /dev/null +++ b/js/src/tests/ecma_6/TypedObject/simpleequiv.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty("TypedObject")) +var BUGNUMBER = 922216; +var summary = 'TypedObjects Equivalent Numeric Types'; + +var ArrayType = TypedObject.ArrayType; +var StructType = TypedObject.StructType; +var uint8 = TypedObject.uint8; +var uint16 = TypedObject.uint16; +var uint32 = TypedObject.uint32; +var uint8Clamped = TypedObject.uint8Clamped; +var int8 = TypedObject.int8; +var int16 = TypedObject.int16; +var int32 = TypedObject.int32; +var float32 = TypedObject.float32; +var float64 = TypedObject.float64; + +function runTests() { + print(BUGNUMBER + ": " + summary); + + var scalarTypes = [ + int8, int16, int32, + uint8, uint16, uint32, + float32, float64 + ]; + + for (var i = 0; i < scalarTypes.length; i++) + for (var j = 0; j < scalarTypes.length; j++) + assertEq(i == j, scalarTypes[i].equivalent(scalarTypes[j])); + + reportCompare(true, true); + print("Tests complete"); +} + +runTests(); diff --git a/js/src/tests/ecma_6/TypedObject/structequiv.js b/js/src/tests/ecma_6/TypedObject/structequiv.js index add0e1a53e04..6881e3ba37a6 100644 --- a/js/src/tests/ecma_6/TypedObject/structequiv.js +++ b/js/src/tests/ecma_6/TypedObject/structequiv.js @@ -1,5 +1,5 @@ // |reftest| skip-if(!this.hasOwnProperty("TypedObject")) -var BUGNUMBER = 578700; +var BUGNUMBER = 922216; var summary = 'TypedObjects Equivalent StructTypes'; var ArrayType = TypedObject.ArrayType; From 9c45655710764245eb32817f66e96d8b3aa2b0f3 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 2 Nov 2013 21:02:03 +1300 Subject: [PATCH 188/795] Fix annotations for tests that are fixed by the patches in bug 911889. --- layout/reftests/bugs/reftest.list | 2 +- layout/reftests/transform/reftest.list | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list index b3880dacfa9c..7e7873b1cc70 100644 --- a/layout/reftests/bugs/reftest.list +++ b/layout/reftests/bugs/reftest.list @@ -1625,7 +1625,7 @@ HTTP(..) == 615121-1.html 615121-1-ref.html HTTP(..) != 615121-2.html 615121-2-notref.html fails-if(Android) == 617242-1.html 617242-1-ref.html != 618071.html 618071-notref.html -fails-if(Android) == 619117-1.html 619117-1-ref.html +== 619117-1.html 619117-1-ref.html HTTP(..) == 619511-1.html 619511-1-ref.html skip-if(Android) HTTP(..) == 621253-1-externalFilter.html 621253-1-ref.html skip-if(Android) == 621253-1-internalFilter.html 621253-1-ref.html diff --git a/layout/reftests/transform/reftest.list b/layout/reftests/transform/reftest.list index eefdf1f64eef..b3ae5b21eb55 100644 --- a/layout/reftests/transform/reftest.list +++ b/layout/reftests/transform/reftest.list @@ -100,7 +100,7 @@ random == rotate-1f.html rotate-1-ref.html # ensure matrix 3d does not break us - should do nothing == matrix3d-1.html matrix3d-1-ref.html # Test that complex transform can be reversed -skip-if(B2G) fails-if(Android) fuzzy-if(cocoaWidget,1,2) == stresstest-1.html stresstest-1-ref.html # bug 773482 +skip-if(B2G) == stresstest-1.html stresstest-1-ref.html # bug 773482 # Test scale transforms == scalex-1.html scalex-1-ref.html == scaley-1.html scaley-1-ref.html From 592c2cad3638f698211bda7ee3007f86a41ae456 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 2 Nov 2013 17:57:40 +0900 Subject: [PATCH 189/795] Bug 933586 - Define MOZ_HAVE_CXX11_DELETE for MSVC 12+. r=waldo --- mfbt/Attributes.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index 0786cb2fe5c5..4e7824cd97f1 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -89,6 +89,9 @@ # define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) # define MOZ_HAVE_NORETURN __attribute__((noreturn)) #elif defined(_MSC_VER) +# if _MSC_VER >= 1800 +# define MOZ_HAVE_CXX11_DELETE +# endif # if _MSC_VER >= 1700 # define MOZ_HAVE_CXX11_FINAL final # else From b349adf8d4ed0da16d174d89066d821bbd6d7efa Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Fri, 1 Nov 2013 13:29:53 +0000 Subject: [PATCH 190/795] Bug 931915, part 2 - Make gfxContext::RoundedRectangle use Moz2D's AppendRoundedRectToPath helper. r=Bas --- gfx/thebes/gfxContext.cpp | 62 ++++----------------------------------- 1 file changed, 6 insertions(+), 56 deletions(-) diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 200b819da2ac..7ca1340b06e2 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -22,6 +22,7 @@ #include "gfxTeeSurface.h" #include "GeckoProfiler.h" #include "gfx2DGlue.h" +#include "mozilla/gfx/PathHelpers.h" #include #if CAIRO_HAS_DWRITE_FONT @@ -1911,62 +1912,11 @@ gfxContext::RoundedRectangle(const gfxRect& rect, cairo_close_path (mCairo); } else { EnsurePathBuilder(); - - const gfxFloat alpha = 0.55191497064665766025; - - typedef struct { gfxFloat a, b; } twoFloats; - - twoFloats cwCornerMults[4] = { { -1, 0 }, - { 0, -1 }, - { +1, 0 }, - { 0, +1 } }; - twoFloats ccwCornerMults[4] = { { +1, 0 }, - { 0, -1 }, - { -1, 0 }, - { 0, +1 } }; - - twoFloats *cornerMults = draw_clockwise ? cwCornerMults : ccwCornerMults; - - gfxPoint pc, p0, p1, p2, p3; - - if (draw_clockwise) - mPathBuilder->MoveTo(Point(Float(rect.X() + corners[NS_CORNER_TOP_LEFT].width), Float(rect.Y()))); - else - mPathBuilder->MoveTo(Point(Float(rect.X() + rect.Width() - corners[NS_CORNER_TOP_RIGHT].width), Float(rect.Y()))); - - NS_FOR_CSS_CORNERS(i) { - // the corner index -- either 1 2 3 0 (cw) or 0 3 2 1 (ccw) - mozilla::css::Corner c = mozilla::css::Corner(draw_clockwise ? ((i+1) % 4) : ((4-i) % 4)); - - // i+2 and i+3 respectively. These are used to index into the corner - // multiplier table, and were deduced by calculating out the long form - // of each corner and finding a pattern in the signs and values. - int i2 = (i+2) % 4; - int i3 = (i+3) % 4; - - pc = rect.AtCorner(c); - - if (corners[c].width > 0.0 && corners[c].height > 0.0) { - p0.x = pc.x + cornerMults[i].a * corners[c].width; - p0.y = pc.y + cornerMults[i].b * corners[c].height; - - p3.x = pc.x + cornerMults[i3].a * corners[c].width; - p3.y = pc.y + cornerMults[i3].b * corners[c].height; - - p1.x = p0.x + alpha * cornerMults[i2].a * corners[c].width; - p1.y = p0.y + alpha * cornerMults[i2].b * corners[c].height; - - p2.x = p3.x - alpha * cornerMults[i3].a * corners[c].width; - p2.y = p3.y - alpha * cornerMults[i3].b * corners[c].height; - - mPathBuilder->LineTo(ToPoint(p0)); - mPathBuilder->BezierTo(ToPoint(p1), ToPoint(p2), ToPoint(p3)); - } else { - mPathBuilder->LineTo(ToPoint(pc)); - } - } - - mPathBuilder->Close(); + Size radii[] = { ToSize(corners[NS_CORNER_TOP_LEFT]), + ToSize(corners[NS_CORNER_TOP_RIGHT]), + ToSize(corners[NS_CORNER_BOTTOM_RIGHT]), + ToSize(corners[NS_CORNER_BOTTOM_LEFT]) }; + AppendRoundedRectToPath(mPathBuilder, ToRect(rect), radii, draw_clockwise); } } From 6e5310720b086ce51345e96ad523db51b5f848f2 Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Sat, 2 Nov 2013 17:45:17 +0800 Subject: [PATCH 191/795] Backout b796080cf4d0 (bug 931699) due to causing bug 933787. --- dom/system/gonk/RadioInterfaceLayer.js | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index f16c079c5dc1..bc48806c869a 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -2209,28 +2209,13 @@ RadioInterface.prototype = { break; case kNetworkInterfaceStateChangedTopic: let network = subject.QueryInterface(Ci.nsINetworkInterface); - if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { - return; - } - - // SNTP can only update when we have mobile or Wifi connections. - if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && - network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { - return; - } - - // If the network comes from RIL, make sure the RIL service is matched. - if (subject instanceof Ci.nsIRilNetworkInterface) { - network = subject.QueryInterface(Ci.nsIRilNetworkInterface); - if (network.serviceId != this.clientId) { - return; + if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { + // Check SNTP when we have data connection, this may not take + // effect immediately before the setting get enabled. + if (this._sntp.isExpired()) { + this._sntp.request(); } } - - // SNTP won't update unless the SNTP is already expired. - if (this._sntp.isExpired()) { - this._sntp.request(); - } break; case kScreenStateChangedTopic: this.workerMessenger.send("setScreenState", { on: (data === "on") }); From ac08cd69cc93cff4ecb44828a2b5c1e6d9145a10 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Sat, 2 Nov 2013 11:54:07 +0100 Subject: [PATCH 192/795] Bug 933475 - Rewrite Array.prototype.push fast path to work on all native objects with dense elements. r=Waldo --- js/src/jsarray.cpp | 53 +++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index e6cdcfa3a301..d36e20f7dd8f 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -2043,33 +2043,42 @@ js::array_push(JSContext *cx, unsigned argc, Value *vp) if (!obj) return false; - /* Fast path for the fully-dense case. */ - if (obj->is()) { - Rooted arr(cx, &obj->as()); - if (arr->lengthIsWritable() && !ObjectMayHaveExtraIndexedProperties(arr)) { - uint32_t length = arr->length(); - uint32_t argCount = args.length(); - JSObject::EnsureDenseResult result = arr->ensureDenseElements(cx, length, argCount); - if (result == JSObject::ED_FAILED) - return false; - - if (result == JSObject::ED_OK) { - arr->setLengthInt32(length + argCount); - for (uint32_t i = 0, index = length; i < argCount; index++, i++) - JSObject::setDenseElementWithType(cx, arr, index, args[i]); - args.rval().setNumber(arr->length()); - return true; - } - - MOZ_ASSERT(result == JSObject::ED_SPARSE); - } - } - /* Steps 2-3. */ uint32_t length; if (!GetLengthProperty(cx, obj, &length)) return false; + /* Fast path for native objects with dense elements. */ + do { + if (!obj->isNative()) + break; + + if (obj->is() && !obj->as().lengthIsWritable()) + break; + + if (ObjectMayHaveExtraIndexedProperties(obj)) + break; + + uint32_t argCount = args.length(); + JSObject::EnsureDenseResult result = obj->ensureDenseElements(cx, length, argCount); + if (result == JSObject::ED_FAILED) + return false; + + if (result == JSObject::ED_OK) { + for (uint32_t i = 0, index = length; i < argCount; index++, i++) + JSObject::setDenseElementWithType(cx, obj, index, args[i]); + uint32_t newlength = length + argCount; + args.rval().setNumber(newlength); + if (obj->is()) { + obj->as().setLengthInt32(newlength); + return true; + } + return SetLengthProperty(cx, obj, newlength); + } + + MOZ_ASSERT(result == JSObject::ED_SPARSE); + } while (false); + /* Steps 4-5. */ if (!InitArrayElements(cx, obj, length, args.length(), args.array(), UpdateTypes)) return false; From 121dda43b7735342ef577da0b9c7488c19f0cb9a Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Sat, 2 Nov 2013 11:10:38 +0000 Subject: [PATCH 193/795] Bug 932761 - Implement Moz2D path builders for all of the SVG element types. r=dholbert --- content/svg/content/src/SVGCircleElement.cpp | 18 ++++ content/svg/content/src/SVGCircleElement.h | 1 + content/svg/content/src/SVGContentUtils.cpp | 22 +++++ content/svg/content/src/SVGContentUtils.h | 11 +++ content/svg/content/src/SVGEllipseElement.cpp | 19 ++++ content/svg/content/src/SVGEllipseElement.h | 1 + content/svg/content/src/SVGImageElement.cpp | 26 ++++++ content/svg/content/src/SVGImageElement.h | 1 + content/svg/content/src/SVGLineElement.cpp | 17 ++++ content/svg/content/src/SVGLineElement.h | 1 + content/svg/content/src/SVGPathData.cpp | 88 ++++++++++++------- content/svg/content/src/SVGPathData.h | 8 +- content/svg/content/src/SVGPathElement.cpp | 44 ++++++++++ content/svg/content/src/SVGPathElement.h | 1 + content/svg/content/src/SVGPoint.h | 7 ++ content/svg/content/src/SVGRectElement.cpp | 50 +++++++++++ content/svg/content/src/SVGRectElement.h | 1 + .../content/src/nsSVGPathGeometryElement.cpp | 66 ++++++++++++++ .../content/src/nsSVGPathGeometryElement.h | 34 +++++++ content/svg/content/src/nsSVGPolyElement.cpp | 18 ++++ content/svg/content/src/nsSVGPolyElement.h | 1 + layout/svg/nsSVGTextFrame2.cpp | 6 +- layout/svg/nsSVGUtils.cpp | 38 ++------ layout/svg/nsSVGUtils.h | 9 -- 24 files changed, 409 insertions(+), 79 deletions(-) diff --git a/content/svg/content/src/SVGCircleElement.cpp b/content/svg/content/src/SVGCircleElement.cpp index d45e6b9527e4..f08aab018b84 100644 --- a/content/svg/content/src/SVGCircleElement.cpp +++ b/content/svg/content/src/SVGCircleElement.cpp @@ -4,12 +4,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/SVGCircleElement.h" +#include "mozilla/gfx/2D.h" #include "nsGkAtoms.h" #include "gfxContext.h" #include "mozilla/dom/SVGCircleElementBinding.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Circle) +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -90,5 +93,20 @@ SVGCircleElement::ConstructPath(gfxContext *aCtx) aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI); } +TemporaryRef +SVGCircleElement::BuildPath() +{ + RefPtr pathBuilder = CreatePathBuilder(); + + float x, y, r; + GetAnimatedLengthValues(&x, &y, &r, nullptr); + + if (r > 0.0f) { + pathBuilder->Arc(Point(x, y), r, 0, Float(2*M_PI)); + } + + return pathBuilder->Finish(); +} + } // namespace dom } // namespace mozilla diff --git a/content/svg/content/src/SVGCircleElement.h b/content/svg/content/src/SVGCircleElement.h index cac82ce45059..32de01fb1e15 100644 --- a/content/svg/content/src/SVGCircleElement.h +++ b/content/svg/content/src/SVGCircleElement.h @@ -32,6 +32,7 @@ public: // nsSVGPathGeometryElement methods: virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual TemporaryRef BuildPath() MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGContentUtils.cpp b/content/svg/content/src/SVGContentUtils.cpp index 4bd8b2c39516..283d585e43a2 100644 --- a/content/svg/content/src/SVGContentUtils.cpp +++ b/content/svg/content/src/SVGContentUtils.cpp @@ -565,3 +565,25 @@ SVGContentUtils::ParseInteger(const nsAString& aString, int64_t(std::numeric_limits::max()))); return true; } + +float +SVGContentUtils::CoordToFloat(nsPresContext *aPresContext, + nsSVGElement *aContent, + const nsStyleCoord &aCoord) +{ + switch (aCoord.GetUnit()) { + case eStyleUnit_Factor: + // user units + return aCoord.GetFactorValue(); + + case eStyleUnit_Coord: + return nsPresContext::AppUnitsToFloatCSSPixels(aCoord.GetCoordValue()); + + case eStyleUnit_Percent: { + SVGSVGElement* ctx = aContent->GetCtx(); + return ctx ? aCoord.GetPercentValue() * ctx->GetLength(SVGContentUtils::XY) : 0.0f; + } + default: + return 0.0f; + } +} diff --git a/content/svg/content/src/SVGContentUtils.h b/content/svg/content/src/SVGContentUtils.h index 656796b37334..38d1728de7b6 100644 --- a/content/svg/content/src/SVGContentUtils.h +++ b/content/svg/content/src/SVGContentUtils.h @@ -16,7 +16,9 @@ class nsIContent; class nsIDocument; class nsIFrame; +class nsPresContext; class nsStyleContext; +class nsStyleCoord; class nsSVGElement; namespace mozilla { @@ -169,6 +171,15 @@ public: */ static bool ParseInteger(const nsAString& aString, int32_t& aValue); + + /** + * Converts an nsStyleCoord into a userspace value. Handles units + * Factor (straight userspace), Coord (dimensioned), and Percent (of + * aContent's SVG viewport) + */ + static float CoordToFloat(nsPresContext *aPresContext, + nsSVGElement *aContent, + const nsStyleCoord &aCoord); }; #endif diff --git a/content/svg/content/src/SVGEllipseElement.cpp b/content/svg/content/src/SVGEllipseElement.cpp index f131fdb10b27..e342e35f3538 100644 --- a/content/svg/content/src/SVGEllipseElement.cpp +++ b/content/svg/content/src/SVGEllipseElement.cpp @@ -5,10 +5,14 @@ #include "mozilla/dom/SVGEllipseElement.h" #include "mozilla/dom/SVGEllipseElementBinding.h" +#include "mozilla/gfx/2D.h" +#include "mozilla/gfx/PathHelpers.h" #include "gfxContext.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Ellipse) +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -100,5 +104,20 @@ SVGEllipseElement::ConstructPath(gfxContext *aCtx) } } +TemporaryRef +SVGEllipseElement::BuildPath() +{ + RefPtr pathBuilder = CreatePathBuilder(); + + float x, y, rx, ry; + GetAnimatedLengthValues(&x, &y, &rx, &ry, nullptr); + + if (rx > 0.0f && ry > 0.0f) { + AppendEllipseToPath(pathBuilder, Point(x, y), Size(2.0*rx, 2.0*ry)); + } + + return pathBuilder->Finish(); +} + } // namespace dom } // namespace mozilla diff --git a/content/svg/content/src/SVGEllipseElement.h b/content/svg/content/src/SVGEllipseElement.h index 6e5cc5dfa4e4..d42ae459c8cd 100644 --- a/content/svg/content/src/SVGEllipseElement.h +++ b/content/svg/content/src/SVGEllipseElement.h @@ -32,6 +32,7 @@ public: // nsSVGPathGeometryElement methods: virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual TemporaryRef BuildPath() MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGImageElement.cpp b/content/svg/content/src/SVGImageElement.cpp index 6514938b08fe..11b7c96bb966 100644 --- a/content/svg/content/src/SVGImageElement.cpp +++ b/content/svg/content/src/SVGImageElement.cpp @@ -6,6 +6,7 @@ #include "mozilla/Util.h" #include "mozilla/dom/SVGImageElement.h" +#include "mozilla/gfx/2D.h" #include "nsCOMPtr.h" #include "nsIURI.h" #include "nsNetUtil.h" @@ -16,6 +17,8 @@ NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Image) +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -236,6 +239,29 @@ SVGImageElement::ConstructPath(gfxContext *aCtx) aCtx->Rectangle(gfxRect(x, y, width, height)); } +TemporaryRef +SVGImageElement::BuildPath() +{ + // We get called in order to get bounds for this element, and for + // hit-testing against it. For that we just pretend to be a rectangle. + + RefPtr pathBuilder = CreatePathBuilder(); + + float x, y, width, height; + GetAnimatedLengthValues(&x, &y, &width, &height, nullptr); + + if (width <= 0 || height <= 0) { + Rect r(x, y, width, height); + pathBuilder->MoveTo(r.TopLeft()); + pathBuilder->LineTo(r.TopRight()); + pathBuilder->LineTo(r.BottomRight()); + pathBuilder->LineTo(r.BottomLeft()); + pathBuilder->Close(); + } + + return pathBuilder->Finish(); +} + //---------------------------------------------------------------------- // nsSVGElement methods diff --git a/content/svg/content/src/SVGImageElement.h b/content/svg/content/src/SVGImageElement.h index ea68f156846e..91a9f50527fc 100644 --- a/content/svg/content/src/SVGImageElement.h +++ b/content/svg/content/src/SVGImageElement.h @@ -55,6 +55,7 @@ public: // nsSVGPathGeometryElement methods: virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual TemporaryRef BuildPath() MOZ_OVERRIDE; // nsSVGSVGElement methods: virtual bool HasValidDimensions() const MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGLineElement.cpp b/content/svg/content/src/SVGLineElement.cpp index 620319c9fd86..3c42e7dade5f 100644 --- a/content/svg/content/src/SVGLineElement.cpp +++ b/content/svg/content/src/SVGLineElement.cpp @@ -5,10 +5,13 @@ #include "mozilla/dom/SVGLineElement.h" #include "mozilla/dom/SVGLineElementBinding.h" +#include "mozilla/gfx/2D.h" #include "gfxContext.h" NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Line) +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -115,5 +118,19 @@ SVGLineElement::ConstructPath(gfxContext *aCtx) aCtx->LineTo(gfxPoint(x2, y2)); } +TemporaryRef +SVGLineElement::BuildPath() +{ + RefPtr pathBuilder = CreatePathBuilder(); + + float x1, y1, x2, y2; + GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nullptr); + + pathBuilder->MoveTo(Point(x1, y1)); + pathBuilder->LineTo(Point(x2, y2)); + + return pathBuilder->Finish(); +} + } // namespace dom } // namespace mozilla diff --git a/content/svg/content/src/SVGLineElement.h b/content/svg/content/src/SVGLineElement.h index e4ba08b67822..aadda35ed156 100644 --- a/content/svg/content/src/SVGLineElement.h +++ b/content/svg/content/src/SVGLineElement.h @@ -34,6 +34,7 @@ public: virtual bool IsMarkable() MOZ_OVERRIDE { return true; } virtual void GetMarkPoints(nsTArray *aMarks) MOZ_OVERRIDE; virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual TemporaryRef BuildPath() MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; diff --git a/content/svg/content/src/SVGPathData.cpp b/content/svg/content/src/SVGPathData.cpp index 7ea1907abac4..537fc63f1f23 100644 --- a/content/svg/content/src/SVGPathData.cpp +++ b/content/svg/content/src/SVGPathData.cpp @@ -16,6 +16,7 @@ #include "nsSVGPathDataParser.h" #include "nsSVGPathGeometryElement.h" // for nsSVGMark #include +#include "nsStyleConsts.h" #include "SVGContentUtils.h" #include "SVGPathSegUtils.h" #include "gfxContext.h" @@ -217,18 +218,51 @@ SVGPathData::GetPathSegAtLength(float aDistance) const * * Cairo only does this for |stroke-linecap: round| and not for * |stroke-linecap: square| (since that's what Adobe Acrobat has always done). + * Most likely the other backends that DrawTarget uses have the same behavior. * * To help us conform to the SVG spec we have this helper function to draw an * approximation of square caps for zero length subpaths. It does this by - * inserting a subpath containing a single axis aligned straight line that is - * as small as it can be without cairo throwing it away for being too small to - * affect rendering. Cairo will then draw stroke caps for this axis aligned - * line, creating an axis aligned rectangle (approximating the square that - * would ideally be drawn). + * inserting a subpath containing a single user space axis aligned straight + * line that is as small as it can be while minimizing the risk of it being + * thrown away by the DrawTarget's backend for being too small to affect + * rendering. The idea is that we'll then get stroke caps drawn for this axis + * aligned line, creating an axis aligned rectangle that approximates the + * square that would ideally be drawn. + * + * Since we don't have any information about transforms from user space to + * device space, we choose the length of the small line that we insert by + * making it a small percentage of the stroke width of the path. This should + * hopefully allow us to make the line as long as possible (to avoid rounding + * issues in the backend resulting in the backend seeing it as having zero + * length) while still avoiding the small rectangle being noticably different + * from a square. * * Note that this function inserts a subpath into the current gfx path that * will be present during both fill and stroke operations. */ +static void +ApproximateZeroLengthSubpathSquareCaps(PathBuilder* aPB, + const Point& aPoint, + Float aStrokeWidth) +{ + // Note that caps are proportional to stroke width, so if stroke width is + // zero it's actually fine for |tinyLength| below to end up being zero. + // However, it would be a waste to inserting a LineTo in that case, so better + // not to. + MOZ_ASSERT(aStrokeWidth > 0.0f, + "Make the caller check for this, or check it here"); + + // The fraction of the stroke width that we choose for the length of the + // line is rather arbitrary, other than being chosen to meet the requirements + // described in the comment above. + + Float tinyLength = aStrokeWidth / 32; + + aPB->MoveTo(aPoint); + aPB->LineTo(aPoint + Point(tinyLength, 0)); + aPB->MoveTo(aPoint); +} + static void ApproximateZeroLengthSubpathSquareCaps(const gfxPoint &aPoint, gfxContext *aCtx) { @@ -244,32 +278,12 @@ ApproximateZeroLengthSubpathSquareCaps(const gfxPoint &aPoint, gfxContext *aCtx) aCtx->MoveTo(aPoint); } -static void -ApproximateZeroLengthSubpathSquareCaps(const Point& aPoint, - DrawTarget* aDT, - PathBuilder* aPB) -{ - // Cairo's fixed point fractional part is 8 bits wide, so its device space - // coordinate granularity is 1/256 pixels. However, to prevent user space - // |aPoint| and |aPoint + tinyAdvance| being rounded to the same device - // coordinates, we double this for |tinyAdvance|: - - Matrix currentTransform = aDT->GetTransform(); - currentTransform.Invert(); - Size tinyAdvance = currentTransform * Size(2.0/256.0, 0.0); - - aPB->MoveTo(aPoint); - aPB->LineTo(aPoint + Point(tinyAdvance.width, tinyAdvance.height)); - aPB->MoveTo(aPoint); -} - #define MAYBE_APPROXIMATE_ZERO_LENGTH_SUBPATH_SQUARE_CAPS_TO_DT \ do { \ - if (capsAreSquare && !subpathHasLength && subpathContainsNonArc && \ - SVGPathSegUtils::IsValidType(prevSegType) && \ - (!IsMoveto(prevSegType) || \ - segType == PATHSEG_CLOSEPATH)) { \ - ApproximateZeroLengthSubpathSquareCaps(segStart, aDT, builder); \ + if (capsAreSquare && !subpathHasLength && aStrokeWidth > 0 && \ + subpathContainsNonArc && SVGPathSegUtils::IsValidType(prevSegType) && \ + (!IsMoveto(prevSegType) || segType == PATHSEG_CLOSEPATH)) { \ + ApproximateZeroLengthSubpathSquareCaps(builder, segStart, aStrokeWidth);\ } \ } while(0) @@ -284,17 +298,23 @@ ApproximateZeroLengthSubpathSquareCaps(const Point& aPoint, } while(0) TemporaryRef -SVGPathData::ConstructPath(DrawTarget *aDT, - FillRule aFillRule, - CapStyle aCapStyle) const +SVGPathData::BuildPath(FillRule aFillRule, + uint8_t aStrokeLineCap, + Float aStrokeWidth) const { if (mData.IsEmpty() || !IsMoveto(SVGPathSegUtils::DecodeType(mData[0]))) { return nullptr; // paths without an initial moveto are invalid } - RefPtr builder = aDT->CreatePathBuilder(aFillRule); + RefPtr drawTarget = + gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget(); + NS_ASSERTION(gfxPlatform::GetPlatform()-> + SupportsAzureContentForDrawTarget(drawTarget), + "Should support Moz2D content drawing"); - bool capsAreSquare = aCapStyle == CAP_SQUARE; + RefPtr builder = drawTarget->CreatePathBuilder(aFillRule); + + bool capsAreSquare = aStrokeLineCap == NS_STYLE_STROKE_LINECAP_SQUARE; bool subpathHasLength = false; // visual length bool subpathContainsNonArc = false; diff --git a/content/svg/content/src/SVGPathData.h b/content/svg/content/src/SVGPathData.h index fdc5966b4e4d..12eccf2da6bf 100644 --- a/content/svg/content/src/SVGPathData.h +++ b/content/svg/content/src/SVGPathData.h @@ -12,6 +12,7 @@ #include "nsINode.h" #include "nsIWeakReferenceUtils.h" #include "mozilla/gfx/2D.h" +#include "mozilla/gfx/Types.h" #include "mozilla/RefPtr.h" #include "nsSVGElement.h" #include "nsTArray.h" @@ -85,6 +86,7 @@ class SVGPathData typedef gfx::DrawTarget DrawTarget; typedef gfx::Path Path; typedef gfx::FillRule FillRule; + typedef gfx::Float Float; typedef gfx::CapStyle CapStyle; public: @@ -161,9 +163,9 @@ public: ToPath(const gfxMatrix& aMatrix) const; void ConstructPath(gfxContext *aCtx) const; - TemporaryRef ConstructPath(DrawTarget* aDT, - FillRule aFillRule, - CapStyle aCapStyle) const; + TemporaryRef BuildPath(FillRule aFillRule, + uint8_t aCapStyle, + Float aStrokeWidth) const; const_iterator begin() const { return mData.Elements(); } const_iterator end() const { return mData.Elements() + mData.Length(); } diff --git a/content/svg/content/src/SVGPathElement.cpp b/content/svg/content/src/SVGPathElement.cpp index 3bd015438f17..9a32d748349b 100644 --- a/content/svg/content/src/SVGPathElement.cpp +++ b/content/svg/content/src/SVGPathElement.cpp @@ -13,12 +13,18 @@ #include "gfxPath.h" #include "mozilla/dom/SVGPathElementBinding.h" #include "nsCOMPtr.h" +#include "nsComputedDOMStyle.h" #include "nsGkAtoms.h" +#include "nsStyleConsts.h" +#include "nsStyleStruct.h" +#include "SVGContentUtils.h" class gfxContext; NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Path) +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -350,5 +356,43 @@ SVGPathElement::GetPathLengthScale(PathLengthScaleForType aFor) return 1.0; } +TemporaryRef +SVGPathElement::BuildPath() +{ + // The Moz2D PathBuilder that our SVGPathData will be using only cares about + // the fill rule. However, in order to fulfill the requirements of the SVG + // spec regarding zero length sub-paths when square line caps are in use, + // SVGPathData needs to know our stroke-linecap style and, if "square", then + // also our stroke width. See the comment for + // ApproximateZeroLengthSubpathSquareCaps for more info. + + uint8_t strokeLineCap = NS_STYLE_STROKE_LINECAP_BUTT; + Float strokeWidth = 0; + + nsRefPtr styleContext = + nsComputedDOMStyle::GetStyleContextForElementNoFlush(this, nullptr, nullptr); + if (styleContext) { + const nsStyleSVG* style = styleContext->StyleSVG(); + // Note: the path that we return may be used for hit-testing, and SVG + // exposes hit-testing of strokes that are not actually painted. For that + // reason we do not check for eStyleSVGPaintType_None or check the stroke + // opacity here. + if (style->mStrokeLinecap == NS_STYLE_STROKE_LINECAP_SQUARE) { + strokeLineCap = style->mStrokeLinecap; + strokeWidth = GetStrokeWidth(); + } + } + + // The fill rule that we pass must be the current + // computed value of our CSS 'fill-rule' property if the path that we return + // will be used for painting or hit-testing. For all other uses (bounds + // calculatons, length measurement, position-at-offset calculations) the fill + // rule that we pass doesn't matter. As a result we can just pass the current + // computed value regardless of who's calling us, or what they're going to do + // with the path that we return. + + return mD.GetAnimValue().BuildPath(GetFillRule(), strokeLineCap, strokeWidth); +} + } // namespace dom } // namespace mozilla diff --git a/content/svg/content/src/SVGPathElement.h b/content/svg/content/src/SVGPathElement.h index bb05b8161dea..2cc9c0a2f878 100644 --- a/content/svg/content/src/SVGPathElement.h +++ b/content/svg/content/src/SVGPathElement.h @@ -47,6 +47,7 @@ public: virtual bool IsMarkable() MOZ_OVERRIDE; virtual void GetMarkPoints(nsTArray *aMarks) MOZ_OVERRIDE; virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual TemporaryRef BuildPath() MOZ_OVERRIDE; virtual already_AddRefed GetPath(const gfxMatrix &aMatrix) MOZ_OVERRIDE; diff --git a/content/svg/content/src/SVGPoint.h b/content/svg/content/src/SVGPoint.h index 6959a90fdf4f..bbe23b077f1f 100644 --- a/content/svg/content/src/SVGPoint.h +++ b/content/svg/content/src/SVGPoint.h @@ -8,6 +8,7 @@ #include "nsDebug.h" #include "gfxPoint.h" +#include "mozilla/gfx/Point.h" namespace mozilla { @@ -18,6 +19,8 @@ namespace mozilla { */ class SVGPoint { + typedef mozilla::gfx::Point Point; + public: SVGPoint() @@ -57,6 +60,10 @@ public: return gfxPoint(mX, mY); } + operator Point() const { + return Point(mX, mY); + } + #ifdef DEBUG bool IsValid() const { return NS_finite(mX) && NS_finite(mY); diff --git a/content/svg/content/src/SVGRectElement.cpp b/content/svg/content/src/SVGRectElement.cpp index 64a22ba23fe7..a570077977d6 100644 --- a/content/svg/content/src/SVGRectElement.cpp +++ b/content/svg/content/src/SVGRectElement.cpp @@ -7,10 +7,14 @@ #include "nsGkAtoms.h" #include "gfxContext.h" #include "mozilla/dom/SVGRectElementBinding.h" +#include "mozilla/gfx/2D.h" +#include "mozilla/gfx/PathHelpers.h" #include NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Rect) +using namespace mozilla::gfx; + namespace mozilla { namespace dom { @@ -148,5 +152,51 @@ SVGRectElement::ConstructPath(gfxContext *aCtx) gfxCornerSizes(corner, corner, corner, corner)); } +TemporaryRef +SVGRectElement::BuildPath() +{ + RefPtr pathBuilder = CreatePathBuilder(); + + float x, y, width, height, rx, ry; + GetAnimatedLengthValues(&x, &y, &width, &height, &rx, &ry, nullptr); + + if (width > 0 && height > 0) { + rx = std::max(rx, 0.0f); + ry = std::max(ry, 0.0f); + + if (rx == 0 && ry == 0) { + // Optimization for the no rounded corners case. + Rect r(x, y, width, height); + pathBuilder->MoveTo(r.TopLeft()); + pathBuilder->LineTo(r.TopRight()); + pathBuilder->LineTo(r.BottomRight()); + pathBuilder->LineTo(r.BottomLeft()); + pathBuilder->Close(); + } else { + // If either the 'rx' or the 'ry' attribute isn't set, then we have to + // set it to the value of the other: + bool hasRx = mLengthAttributes[ATTR_RX].IsExplicitlySet(); + bool hasRy = mLengthAttributes[ATTR_RY].IsExplicitlySet(); + MOZ_ASSERT(hasRx || hasRy); + + if (hasRx && !hasRy) { + ry = rx; + } else if (hasRy && !hasRx) { + rx = ry; + } + + // Clamp rx and ry to half the rect's width and height respectively: + rx = std::min(rx, width / 2); + ry = std::min(ry, height / 2); + + Size cornerRadii(rx, ry); + Size radii[] = { cornerRadii, cornerRadii, cornerRadii, cornerRadii }; + AppendRoundedRectToPath(pathBuilder, Rect(x, y, width, height), radii); + } + } + + return pathBuilder->Finish(); +} + } // namespace dom } // namespace mozilla diff --git a/content/svg/content/src/SVGRectElement.h b/content/svg/content/src/SVGRectElement.h index 04ad8f1dcd9a..a5d20cf1f0f4 100644 --- a/content/svg/content/src/SVGRectElement.h +++ b/content/svg/content/src/SVGRectElement.h @@ -32,6 +32,7 @@ public: // nsSVGPathGeometryElement methods: virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual TemporaryRef BuildPath() MOZ_OVERRIDE; virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; diff --git a/content/svg/content/src/nsSVGPathGeometryElement.cpp b/content/svg/content/src/nsSVGPathGeometryElement.cpp index cbfeeb8ebf94..41761909dd85 100644 --- a/content/svg/content/src/nsSVGPathGeometryElement.cpp +++ b/content/svg/content/src/nsSVGPathGeometryElement.cpp @@ -4,7 +4,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsSVGPathGeometryElement.h" + +#include "gfxPlatform.h" +#include "mozilla/gfx/2D.h" +#include "nsComputedDOMStyle.h" #include "nsSVGLength2.h" +#include "SVGContentUtils.h" + +using namespace mozilla; +using namespace mozilla::gfx; //---------------------------------------------------------------------- // Implementation @@ -57,3 +65,61 @@ nsSVGPathGeometryElement::GetPath(const gfxMatrix &aMatrix) { return nullptr; } + +TemporaryRef +nsSVGPathGeometryElement::CreatePathBuilder() +{ + RefPtr drawTarget = + gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget(); + NS_ASSERTION(gfxPlatform::GetPlatform()-> + SupportsAzureContentForDrawTarget(drawTarget), + "Should support Moz2D content drawing"); + + // The fill rule that we pass to CreatePathBuilder must be the current + // computed value of our CSS 'fill-rule' property if the path that we return + // will be used for painting or hit-testing. For all other uses (bounds + // calculatons, length measurement, position-at-offset calculations) the fill + // rule that we pass doesn't matter. As a result we can just pass the current + // computed value regardless of who's calling us, or what they're going to do + // with the path that we return. + + return drawTarget->CreatePathBuilder(GetFillRule()); +} + +FillRule +nsSVGPathGeometryElement::GetFillRule() +{ + FillRule fillRule = FILL_WINDING; // Equivalent to NS_STYLE_FILL_RULE_NONZERO + + nsRefPtr styleContext = + nsComputedDOMStyle::GetStyleContextForElementNoFlush(this, nullptr, + nullptr); + + if (styleContext) { + MOZ_ASSERT(styleContext->StyleSVG()->mFillRule == + NS_STYLE_FILL_RULE_NONZERO || + styleContext->StyleSVG()->mFillRule == + NS_STYLE_FILL_RULE_EVENODD); + + if (styleContext->StyleSVG()->mFillRule == NS_STYLE_FILL_RULE_EVENODD) { + fillRule = FILL_EVEN_ODD; + } + } else { + // ReportToConsole + NS_WARNING("Couldn't get style context for content in GetFillRule"); + } + + return fillRule; +} + +Float +nsSVGPathGeometryElement::GetStrokeWidth() +{ + nsRefPtr styleContext = + nsComputedDOMStyle::GetStyleContextForElementNoFlush(this, nullptr, + nullptr); + return styleContext ? + SVGContentUtils::CoordToFloat(styleContext->PresContext(), this, + styleContext->StyleSVG()->mStrokeWidth) : + 0.0f; +} diff --git a/content/svg/content/src/nsSVGPathGeometryElement.h b/content/svg/content/src/nsSVGPathGeometryElement.h index 438d32a82df9..b884fbaa5872 100644 --- a/content/svg/content/src/nsSVGPathGeometryElement.h +++ b/content/svg/content/src/nsSVGPathGeometryElement.h @@ -6,6 +6,7 @@ #ifndef __NS_SVGPATHGEOMETRYELEMENT_H__ #define __NS_SVGPATHGEOMETRYELEMENT_H__ +#include "mozilla/gfx/2D.h" #include "SVGGraphicsElement.h" class gfxPath; @@ -33,6 +34,12 @@ typedef mozilla::dom::SVGGraphicsElement nsSVGPathGeometryElementBase; class nsSVGPathGeometryElement : public nsSVGPathGeometryElementBase { +protected: + typedef mozilla::gfx::FillRule FillRule; + typedef mozilla::gfx::Float Float; + typedef mozilla::gfx::Path Path; + typedef mozilla::gfx::PathBuilder PathBuilder; + public: nsSVGPathGeometryElement(already_AddRefed aNodeInfo); @@ -52,7 +59,34 @@ public: virtual bool IsMarkable(); virtual void GetMarkPoints(nsTArray *aMarks); virtual void ConstructPath(gfxContext *aCtx) = 0; + + /** + * Returns a Path that can be used to paint, hit-test or calculate bounds for + * this element. + */ + virtual mozilla::TemporaryRef BuildPath() = 0; + virtual already_AddRefed GetPath(const gfxMatrix &aMatrix); + + /** + * Returns a PathBuilder object created using the current computed value of + * the CSS property 'fill-rule' for this element. + */ + mozilla::TemporaryRef CreatePathBuilder(); + + /** + * Returns the current computed value of the CSS property 'fill-rule' for + * this element. + */ + FillRule GetFillRule(); + + /** + * Returns the current computed value of the CSS property 'stroke-width' for + * this element. (I.e. this does NOT take account of the value of the + * 'stroke' and 'stroke-opacity' properties to, say, return zero if they are + * "none" or "0", respectively.) + */ + Float GetStrokeWidth(); }; #endif diff --git a/content/svg/content/src/nsSVGPolyElement.cpp b/content/svg/content/src/nsSVGPolyElement.cpp index fa43533d8b03..c14446c1aacf 100644 --- a/content/svg/content/src/nsSVGPolyElement.cpp +++ b/content/svg/content/src/nsSVGPolyElement.cpp @@ -6,9 +6,11 @@ #include "nsSVGPolyElement.h" #include "DOMSVGPointList.h" #include "gfxContext.h" +#include "mozilla/gfx/2D.h" #include "SVGContentUtils.h" using namespace mozilla; +using namespace mozilla::gfx; //---------------------------------------------------------------------- // nsISupports methods @@ -120,3 +122,19 @@ nsSVGPolyElement::ConstructPath(gfxContext *aCtx) } } +TemporaryRef +nsSVGPolyElement::BuildPath() +{ + RefPtr pathBuilder = CreatePathBuilder(); + + const SVGPointList &points = mPoints.GetAnimValue(); + + if (!points.IsEmpty()) { + pathBuilder->MoveTo(points[0]); + for (uint32_t i = 1; i < points.Length(); ++i) { + pathBuilder->LineTo(points[i]); + } + } + + return pathBuilder->Finish(); +} diff --git a/content/svg/content/src/nsSVGPolyElement.h b/content/svg/content/src/nsSVGPolyElement.h index baee9063d147..08dfb7aad3c6 100644 --- a/content/svg/content/src/nsSVGPolyElement.h +++ b/content/svg/content/src/nsSVGPolyElement.h @@ -43,6 +43,7 @@ public: virtual bool IsMarkable() MOZ_OVERRIDE { return true; } virtual void GetMarkPoints(nsTArray *aMarks) MOZ_OVERRIDE; virtual void ConstructPath(gfxContext *aCtx) MOZ_OVERRIDE; + virtual mozilla::TemporaryRef BuildPath() MOZ_OVERRIDE; // WebIDL already_AddRefed Points(); diff --git a/layout/svg/nsSVGTextFrame2.cpp b/layout/svg/nsSVGTextFrame2.cpp index c83ec2d3dc57..e19e3711a14e 100644 --- a/layout/svg/nsSVGTextFrame2.cpp +++ b/layout/svg/nsSVGTextFrame2.cpp @@ -5058,9 +5058,9 @@ nsSVGTextFrame2::ShouldRenderAsPath(nsRenderingContext* aContext, // Text has a stroke. if (!(style->mStroke.mType == eStyleSVGPaintType_None || style->mStrokeOpacity == 0 || - nsSVGUtils::CoordToFloat(PresContext(), - static_cast(mContent), - style->mStrokeWidth) == 0)) { + SVGContentUtils::CoordToFloat(PresContext(), + static_cast(mContent), + style->mStrokeWidth) == 0)) { return true; } diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index c237e53365b9..ad3bdd0953df 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -391,28 +391,6 @@ nsSVGUtils::ComputeAlphaMask(uint8_t *aData, } } -float -nsSVGUtils::CoordToFloat(nsPresContext *aPresContext, - nsSVGElement *aContent, - const nsStyleCoord &aCoord) -{ - switch (aCoord.GetUnit()) { - case eStyleUnit_Factor: - // user units - return aCoord.GetFactorValue(); - - case eStyleUnit_Coord: - return nsPresContext::AppUnitsToFloatCSSPixels(aCoord.GetCoordValue()); - - case eStyleUnit_Percent: { - SVGSVGElement* ctx = aContent->GetCtx(); - return ctx ? aCoord.GetPercentValue() * ctx->GetLength(SVGContentUtils::XY) : 0.0f; - } - default: - return 0.0f; - } -} - nsSVGDisplayContainerFrame* nsSVGUtils::GetNearestSVGViewport(nsIFrame *aFrame) { @@ -1621,8 +1599,8 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint) nsSVGElement *ctx = static_cast(content); - return CoordToFloat(aFrame->PresContext(), ctx, - style->mStrokeWidth); + return SVGContentUtils::CoordToFloat(aFrame->PresContext(), ctx, + style->mStrokeWidth); } void @@ -1713,9 +1691,9 @@ GetStrokeDashData(nsIFrame* aFrame, const nsStyleCoord *dasharray = style->mStrokeDasharray; for (uint32_t i = 0; i < count; i++) { - aDashes[i] = nsSVGUtils::CoordToFloat(presContext, - ctx, - dasharray[i]) * pathScale; + aDashes[i] = SVGContentUtils::CoordToFloat(presContext, + ctx, + dasharray[i]) * pathScale; if (aDashes[i] < 0.0) { return false; } @@ -1726,9 +1704,9 @@ GetStrokeDashData(nsIFrame* aFrame, if (aContextPaint && style->mStrokeDashoffsetFromObject) { *aDashOffset = aContextPaint->GetStrokeDashOffset(); } else { - *aDashOffset = nsSVGUtils::CoordToFloat(presContext, - ctx, - style->mStrokeDashoffset); + *aDashOffset = SVGContentUtils::CoordToFloat(presContext, + ctx, + style->mStrokeDashoffset); } return (totalLength > 0.0); diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index 97718c21d45e..ba880db8077b 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -292,15 +292,6 @@ public: const nsIntRect &aRect, float aOpacity); - /* - * Converts a nsStyleCoord into a userspace value. Handles units - * Factor (straight userspace), Coord (dimensioned), and Percent (of - * the current SVG viewport) - */ - static float CoordToFloat(nsPresContext *aPresContext, - nsSVGElement *aContent, - const nsStyleCoord &aCoord); - /** * Gets the nearest nsSVGInnerSVGFrame or nsSVGOuterSVGFrame frame. aFrame * must be an SVG frame. If aFrame is of type nsGkAtoms::svgOuterSVGFrame, From 152817226f240591afdd70ba2c9e3fcd63a09616 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Fri, 1 Nov 2013 19:09:45 -0700 Subject: [PATCH 194/795] Bug 928042 - Add an environment variable to disable content processes sandboxing even when MOZ_CONTENT_SANDBOX is defined. r=aklotz --- dom/ipc/ContentParent.cpp | 11 +++++++++ dom/ipc/ContentParent.h | 1 + ipc/app/MozillaRuntimeMain.cpp | 38 +++++++++++++++++------------- ipc/glue/GeckoChildProcessHost.cpp | 25 ++++++++++++++------ ipc/glue/GeckoChildProcessHost.h | 6 +++++ 5 files changed, 57 insertions(+), 24 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index b9ae75f74fc3..8df99afdbe3e 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1421,6 +1421,7 @@ ContentParent::ContentParent(mozIApplication* aApp, NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, aOSPrivileges); + mSubprocess->SetSandboxEnabled(ShouldSandboxContentProcesses()); IToplevelProtocol::SetTransport(mSubprocess->GetChannel()); @@ -3282,5 +3283,15 @@ ContentParent::ShouldContinueFromReplyTimeout() return false; } +bool +ContentParent::ShouldSandboxContentProcesses() +{ +#ifdef MOZ_CONTENT_SANDBOX + return !PR_GetEnv("MOZ_DISABLE_CONTENT_SANDBOX"); +#else + return true; +#endif +} + } // namespace dom } // namespace mozilla diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index b7cadc838cb0..c291d3965b9f 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -220,6 +220,7 @@ protected: void OnNuwaForkTimeout(); bool ShouldContinueFromReplyTimeout() MOZ_OVERRIDE; + bool ShouldSandboxContentProcesses(); private: static nsDataHashtable *sAppContentParents; diff --git a/ipc/app/MozillaRuntimeMain.cpp b/ipc/app/MozillaRuntimeMain.cpp index 995abd5e53a7..fdf008ad6f1c 100644 --- a/ipc/app/MozillaRuntimeMain.cpp +++ b/ipc/app/MozillaRuntimeMain.cpp @@ -70,14 +70,16 @@ InitializeBinder(void *aDummy) { int main(int argc, char* argv[]) { -#ifdef MOZ_NUWA_PROCESS bool isNuwa = false; + bool isSandboxEnabled = false; for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-nuwa") == 0) { - PrepareNuwaProcess(); - isNuwa = true; - break; - } + isNuwa |= strcmp(argv[i], "-nuwa") == 0; + isSandboxEnabled |= strcmp(argv[i], "-sandbox") == 0; + } + +#ifdef MOZ_NUWA_PROCESS + if (isNuwa) { + PrepareNuwaProcess(); } #endif @@ -99,19 +101,21 @@ main(int argc, char* argv[]) #endif #if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) - sandbox::TargetServices* target_service = - sandbox::SandboxFactory::GetTargetServices(); - if (!target_service) { - return 1; - } + if (isSandboxEnabled) { + sandbox::TargetServices* target_service = + sandbox::SandboxFactory::GetTargetServices(); + if (!target_service) { + return 1; + } - sandbox::ResultCode result = target_service->Init(); - if (result != sandbox::SBOX_ALL_OK) { - return 2; - } + sandbox::ResultCode result = target_service->Init(); + if (result != sandbox::SBOX_ALL_OK) { + return 2; + } - // Initialization is finished, switch to the lowered token - target_service->LowerToken(); + // Initialization is finished, switch to the lowered token + target_service->LowerToken(); + } #endif // Check for the absolute minimum number of args we need to move diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index eaf805b35ee0..165fec29d8c9 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -87,6 +87,7 @@ GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType, ChildPrivileges aPrivileges) : ChildProcessHost(RENDER_PROCESS), // FIXME/cjones: we should own this enum mProcessType(aProcessType), + mSandboxEnabled(true), mPrivileges(aPrivileges), mMonitor("mozilla.ipc.GeckChildProcessHost.mMonitor"), mProcessState(CREATING_CHANNEL), @@ -739,6 +740,13 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt } } +#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) + if (mSandboxEnabled) { + // Tell the process that it should lower its rights after initialization. + cmdLine.AppendLooseValue(UTF8ToWide("-sandbox")); + } +#endif + // Add the application directory path (-appdir path) AddAppDirToCommandLine(cmdLine); @@ -761,14 +769,17 @@ GeckoChildProcessHost::PerformAsyncLaunchInternal(std::vector& aExt cmdLine.AppendLooseValue(UTF8ToWide(childProcessType)); #if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) - mozilla::SandboxBroker sandboxBroker; - sandboxBroker.LaunchApp(cmdLine.program().c_str(), - cmdLine.command_line_string().c_str(), - &process); -#else - base::LaunchApp(cmdLine, false, false, &process); -#endif + if (mSandboxEnabled) { + mozilla::SandboxBroker sandboxBroker; + sandboxBroker.LaunchApp(cmdLine.program().c_str(), + cmdLine.command_line_string().c_str(), + &process); + } else +#endif + { + base::LaunchApp(cmdLine, false, false, &process); + } #else # error Sorry diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h index ef843b2f4914..242bb6d1afdb 100644 --- a/ipc/glue/GeckoChildProcessHost.h +++ b/ipc/glue/GeckoChildProcessHost.h @@ -123,11 +123,17 @@ public: */ void Join(); + void SetSandboxEnabled(bool aSandboxEnabled) { + mSandboxEnabled = aSandboxEnabled; + } + protected: GeckoProcessType mProcessType; + bool mSandboxEnabled; ChildPrivileges mPrivileges; Monitor mMonitor; FilePath mProcessPath; + // This value must be accessed while holding mMonitor. enum { // This object has been constructed, but the OS process has not From 9aa750b23b7b1cf98627ec7c7eefdbc49a734018 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Sat, 2 Nov 2013 12:11:30 +0000 Subject: [PATCH 195/795] Bug 933260 - Honor the specified CSS width and height on also on Linux. r=karlt --- .../checkbox/gtk-theme-width-height-ref.html | 31 +++++++++++++++++++ .../checkbox/gtk-theme-width-height.html | 30 ++++++++++++++++++ .../forms/input/checkbox/reftest.list | 1 + .../radio/gtk-theme-width-height-ref.html | 31 +++++++++++++++++++ .../input/radio/gtk-theme-width-height.html | 30 ++++++++++++++++++ .../reftests/forms/input/radio/reftest.list | 1 + widget/gtk/gtk2drawing.c | 12 +++---- widget/gtk/gtk3drawing.c | 12 +++---- widget/gtk/nsNativeThemeGTK.cpp | 1 - 9 files changed, 136 insertions(+), 13 deletions(-) create mode 100644 layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html create mode 100644 layout/reftests/forms/input/checkbox/gtk-theme-width-height.html create mode 100644 layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html create mode 100644 layout/reftests/forms/input/radio/gtk-theme-width-height.html diff --git a/layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html b/layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html new file mode 100644 index 000000000000..380f52286417 --- /dev/null +++ b/layout/reftests/forms/input/checkbox/gtk-theme-width-height-ref.html @@ -0,0 +1,31 @@ + + + + + Testcase for bug 932506 + + + + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+ + + diff --git a/layout/reftests/forms/input/checkbox/gtk-theme-width-height.html b/layout/reftests/forms/input/checkbox/gtk-theme-width-height.html new file mode 100644 index 000000000000..456864e9533a --- /dev/null +++ b/layout/reftests/forms/input/checkbox/gtk-theme-width-height.html @@ -0,0 +1,30 @@ + + + + + Testcase for bug 932506 + + + + +
+
+ + +
+
+ +
+
+
+ +
+
+
+ + + diff --git a/layout/reftests/forms/input/checkbox/reftest.list b/layout/reftests/forms/input/checkbox/reftest.list index 5d4b9b428797..058f1b01fddd 100644 --- a/layout/reftests/forms/input/checkbox/reftest.list +++ b/layout/reftests/forms/input/checkbox/reftest.list @@ -11,3 +11,4 @@ skip-if(B2G) fails-if(Android) == radio-stretched.html radio-stretched-ref.html != indeterminate-native-checked.html indeterminate-native-checked-notref.html != indeterminate-native-unchecked.html indeterminate-native-unchecked-notref.html == indeterminate-selector.html indeterminate-selector-ref.html +skip-if(!gtk2Widget) == gtk-theme-width-height.html gtk-theme-width-height-ref.html diff --git a/layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html b/layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html new file mode 100644 index 000000000000..65b31236c988 --- /dev/null +++ b/layout/reftests/forms/input/radio/gtk-theme-width-height-ref.html @@ -0,0 +1,31 @@ + + + + + Testcase for bug 932506 + + + + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+ + + diff --git a/layout/reftests/forms/input/radio/gtk-theme-width-height.html b/layout/reftests/forms/input/radio/gtk-theme-width-height.html new file mode 100644 index 000000000000..3c336f2c89de --- /dev/null +++ b/layout/reftests/forms/input/radio/gtk-theme-width-height.html @@ -0,0 +1,30 @@ + + + + + Testcase for bug 932506 + + + + +
+
+ + +
+
+ +
+
+
+ +
+
+
+ + + diff --git a/layout/reftests/forms/input/radio/reftest.list b/layout/reftests/forms/input/radio/reftest.list index 48d0cd10a40e..3de124197f3b 100644 --- a/layout/reftests/forms/input/radio/reftest.list +++ b/layout/reftests/forms/input/radio/reftest.list @@ -5,3 +5,4 @@ != checked-notref.html about:blank != checked-native.html about:blank != checked-native-notref.html about:blank +skip-if(!gtk2Widget) == gtk-theme-width-height.html gtk-theme-width-height-ref.html diff --git a/widget/gtk/gtk2drawing.c b/widget/gtk/gtk2drawing.c index 7c8413d02c25..ef4418f90a64 100644 --- a/widget/gtk/gtk2drawing.c +++ b/widget/gtk/gtk2drawing.c @@ -1046,13 +1046,13 @@ moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect, w = gCheckboxWidget; } - NS_ASSERTION(rect->width == indicator_size, + // XXX we should assert rect->height >= indicator_size too + // after bug 369581 is fixed. + NS_ASSERTION(rect->width >= indicator_size, "GetMinimumWidgetSize was ignored"); - /* - * vertically center in the box, since XUL sometimes ignores our - * GetMinimumWidgetSize in the vertical dimension - */ - x = rect->x; + + // Paint it center aligned in the rect. + x = rect->x + (rect->width - indicator_size) / 2; y = rect->y + (rect->height - indicator_size) / 2; width = indicator_size; height = indicator_size; diff --git a/widget/gtk/gtk3drawing.c b/widget/gtk/gtk3drawing.c index 77c3a807c399..17692e413cb7 100644 --- a/widget/gtk/gtk3drawing.c +++ b/widget/gtk/gtk3drawing.c @@ -958,13 +958,13 @@ moz_gtk_toggle_paint(cairo_t *cr, GdkRectangle* rect, w = gCheckboxWidget; } - NS_ASSERTION(rect->width == indicator_size, + // XXX we should assert rect->height >= indicator_size too + // after bug 369581 is fixed. + NS_ASSERTION(rect->width >= indicator_size, "GetMinimumWidgetSize was ignored"); - /* - * vertically center in the box, since XUL sometimes ignores our - * GetMinimumWidgetSize in the vertical dimension - */ - x = rect->x; + + // Paint it center aligned in the rect. + x = rect->x + (rect->width - indicator_size) / 2; y = rect->y + (rect->height - indicator_size) / 2; width = indicator_size; height = indicator_size; diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 5c4833063342..4c43b77cedc4 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -1186,7 +1186,6 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsRenderingContext* aContext, // Include space for the indicator and the padding around it. aResult->width = indicator_size; aResult->height = indicator_size; - *aIsOverridable = false; } break; case NS_THEME_TOOLBAR_BUTTON_DROPDOWN: From 9d34d8815f8a74a1641fa7404e1829c166e69270 Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Sat, 2 Nov 2013 09:32:22 -0600 Subject: [PATCH 196/795] Bug 932769 - Ignore resolve hooks for properties that already exist on the object being examined, r=jandem. --- js/src/jit/IonBuilder.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index ffe941e9ed53..b8ca6afc90ab 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -5933,18 +5933,25 @@ IonBuilder::maybeInsertResume() } static bool -ClassHasEffectlessLookup(JSCompartment *comp, const Class *clasp, PropertyName *name) +ClassHasEffectlessLookup(const Class *clasp) { - if (!clasp->isNative() || clasp->ops.lookupGeneric) + return clasp->isNative() && !clasp->ops.lookupGeneric; +} + +static bool +ClassHasResolveHook(JSCompartment *comp, const Class *clasp, PropertyName *name) +{ + if (clasp->resolve != JS_ResolveStub) return false; - if (clasp->resolve != JS_ResolveStub && - // Note: str_resolve only resolves integers, not names. - clasp->resolve != (JSResolveOp)str_resolve && - (clasp->resolve != (JSResolveOp)fun_resolve || - FunctionHasResolveHook(comp->runtimeFromAnyThread(), name))) - { + + if (clasp->resolve == (JSResolveOp)str_resolve) { + // str_resolve only resolves integers, not names. return false; } + + if (clasp->resolve == (JSResolveOp)fun_resolve) + return FunctionHasResolveHook(comp->runtimeFromAnyThread(), name); + return true; } @@ -5966,7 +5973,7 @@ IonBuilder::testSingletonProperty(JSObject *obj, JSObject *singleton, PropertyNa // property will change and trigger invalidation. while (obj) { - if (!ClassHasEffectlessLookup(compartment, obj->getClass(), name)) + if (!ClassHasEffectlessLookup(obj->getClass())) return false; types::TypeObjectKey *objType = types::TypeObjectKey::get(obj); @@ -5980,6 +5987,9 @@ IonBuilder::testSingletonProperty(JSObject *obj, JSObject *singleton, PropertyNa return false; } + if (ClassHasResolveHook(compartment, obj->getClass(), name)) + return false; + obj = obj->getProto(); } @@ -7604,7 +7614,7 @@ IonBuilder::objectsHaveCommonPrototype(types::TemporaryTypeSet *types, PropertyN return false; const Class *clasp = type->clasp(); - if (!ClassHasEffectlessLookup(compartment, clasp, name)) + if (!ClassHasEffectlessLookup(clasp) || ClassHasResolveHook(compartment, clasp, name)) return false; // Look for a getter/setter on the class itself which may need From 822b70dad6f79bd435539ba7550182fc44359a00 Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Sat, 2 Nov 2013 13:48:09 +0100 Subject: [PATCH 197/795] Bug 933946 - Remove the rest of the old number conversion functions from SpiderMonkey. r=terrence --- ipc/testshell/XPCShellEnvironment.cpp | 11 ++--- js/src/builtin/TestingFunctions.cpp | 8 +--- js/src/jsapi.cpp | 59 +-------------------------- js/src/jsapi.h | 35 ++-------------- js/src/shell/js.cpp | 17 +------- js/xpconnect/src/XPCShellImpl.cpp | 9 ++-- 6 files changed, 20 insertions(+), 119 deletions(-) diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index dc23b492d176..9a098c1a5a8d 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -228,17 +228,18 @@ DumpXPC(JSContext *cx, unsigned argc, JS::Value *vp) { - int32_t depth = 2; + JS::CallArgs args = CallArgsFromVp(argc, vp); - if (argc > 0) { - if (!JS_ValueToInt32(cx, JS_ARGV(cx, vp)[0], &depth)) + uint16_t depth = 2; + if (args.length() > 0) { + if (!JS::ToUint16(cx, args[0], &depth)) return false; } nsCOMPtr xpc = do_GetService(nsIXPConnect::GetCID()); - if(xpc) + if (xpc) xpc->DebugDump(int16_t(depth)); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + args.rval().setUndefined(); return true; } diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 4d843be66242..8c5831fb98ac 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -773,13 +773,9 @@ OOMAfterAllocations(JSContext *cx, unsigned argc, jsval *vp) return false; } - int32_t count; - if (!JS_ValueToInt32(cx, args[0], &count)) + uint32_t count; + if (!JS::ToUint32(cx, args[0], &count)) return false; - if (count <= 0) { - JS_ReportError(cx, "count argument must be positive"); - return false; - } OOM_maxAllocations = OOM_counter + count; return true; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 58bc29875988..0b89746864fe 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -245,10 +245,11 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for *va_arg(ap, bool *) = ToBoolean(*sp); break; case 'c': - if (!JS_ValueToUint16(cx, *sp, va_arg(ap, uint16_t *))) + if (!ToUint16(cx, arg, va_arg(ap, uint16_t *))) return false; break; case 'i': + case 'j': // "j" was broken, you should not use it. if (!ToInt32(cx, arg, va_arg(ap, int32_t *))) return false; break; @@ -256,10 +257,6 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for if (!ToUint32(cx, arg, va_arg(ap, uint32_t *))) return false; break; - case 'j': - if (!JS_ValueToInt32(cx, *sp, va_arg(ap, int32_t *))) - return false; - break; case 'd': if (!ToNumber(cx, arg, va_arg(ap, double *))) return false; @@ -447,58 +444,6 @@ JS_DoubleToUint32(double d) return ToUint32(d); } -JS_PUBLIC_API(bool) -JS_ValueToInt64(JSContext *cx, jsval valueArg, int64_t *ip) -{ - RootedValue value(cx, valueArg); - return JS::ToInt64(cx, value, ip); -} - -JS_PUBLIC_API(bool) -JS_ValueToUint64(JSContext *cx, jsval valueArg, uint64_t *ip) -{ - RootedValue value(cx, valueArg); - return JS::ToUint64(cx, value, ip); -} - -JS_PUBLIC_API(bool) -JS_ValueToInt32(JSContext *cx, jsval vArg, int32_t *ip) -{ - AssertHeapIsIdle(cx); - CHECK_REQUEST(cx); - - RootedValue v(cx, vArg); - assertSameCompartment(cx, v); - - if (v.isInt32()) { - *ip = v.toInt32(); - return true; - } - - double d; - if (v.isDouble()) { - d = v.toDouble(); - } else if (!ToNumberSlow(cx, v, &d)) { - return false; - } - - if (mozilla::IsNaN(d) || d <= -2147483649.0 || 2147483648.0 <= d) { - js_ReportValueError(cx, JSMSG_CANT_CONVERT, - JSDVG_SEARCH_STACK, v, NullPtr()); - return false; - } - - *ip = (int32_t) floor(d + 0.5); /* Round to nearest */ - return true; -} - -JS_PUBLIC_API(bool) -JS_ValueToUint16(JSContext *cx, jsval valueArg, uint16_t *ip) -{ - RootedValue value(cx, valueArg); - return ToUint16(cx, value, ip); -} - JS_PUBLIC_API(bool) JS_ValueToBoolean(JSContext *cx, jsval value, bool *bp) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 74fea08e0b87..f26ae68bce8d 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -992,8 +992,8 @@ JS_GetEmptyString(JSRuntime *rt); * b bool Boolean * c uint16_t/jschar ECMA uint16_t, Unicode char * i int32_t ECMA int32_t + * j int32_t ECMA int32_t (used to be different) * u uint32_t ECMA uint32_t - * j int32_t Rounded int32_t (coordinate) * d double IEEE double * I double Integral IEEE double * S JSString * Unicode string, accessed by a JSString pointer @@ -1107,30 +1107,17 @@ JS_DoubleToInt32(double d); extern JS_PUBLIC_API(uint32_t) JS_DoubleToUint32(double d); -/* - * Convert a value to a number, then to an int64_t, according to the WebIDL - * rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long - */ -extern JS_PUBLIC_API(bool) -JS_ValueToInt64(JSContext *cx, jsval v, int64_t *ip); - -/* - * Convert a value to a number, then to an uint64_t, according to the WebIDL - * rules for ToUint64: http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long-long - */ -extern JS_PUBLIC_API(bool) -JS_ValueToUint64(JSContext *cx, jsval v, uint64_t *ip); namespace js { -/* DO NOT CALL THIS. Use JS::ToInt16. */ +/* DO NOT CALL THIS. Use JS::ToUint16. */ extern JS_PUBLIC_API(bool) ToUint16Slow(JSContext *cx, JS::Handle v, uint16_t *out); -/* DO NOT CALL THIS. Use JS::ToInt32. */ +/* DO NOT CALL THIS. Use JS::ToInt32. */ extern JS_PUBLIC_API(bool) ToInt32Slow(JSContext *cx, JS::Handle v, int32_t *out); -/* DO NOT CALL THIS. Use JS::ToUint32. */ +/* DO NOT CALL THIS. Use JS::ToUint32. */ extern JS_PUBLIC_API(bool) ToUint32Slow(JSContext *cx, JS::Handle v, uint32_t *out); @@ -1216,20 +1203,6 @@ ToUint64(JSContext *cx, JS::Handle v, uint64_t *out) } /* namespace JS */ -/* - * Convert a value to a number, then to an int32_t if it fits by rounding to - * nearest; but failing with an error report if the double is out of range - * or unordered. - */ -extern JS_PUBLIC_API(bool) -JS_ValueToInt32(JSContext *cx, jsval v, int32_t *ip); - -/* - * ECMA ToUint16, for mapping a jsval to a Unicode point. - */ -extern JS_PUBLIC_API(bool) -JS_ValueToUint16(JSContext *cx, jsval v, uint16_t *ip); - extern JS_PUBLIC_API(bool) JS_ValueToBoolean(JSContext *cx, jsval v, bool *bp); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index e754546d9293..4da6f93e8d02 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -1526,7 +1526,7 @@ GetScriptAndPCArgs(JSContext *cx, unsigned argc, jsval *argv, MutableHandleScrip intarg++; } if (argc > intarg) { - if (!JS_ValueToInt32(cx, argv[intarg], ip)) + if (!JS::ToInt32(cx, HandleValue::fromMarkedLocation(&argv[intarg]), ip)) return false; if ((uint32_t)*ip >= script->length) { JS_ReportError(cx, "Invalid PC"); @@ -2431,17 +2431,6 @@ GetSLX(JSContext *cx, unsigned argc, jsval *vp) return true; } -static bool -ToInt32(JSContext *cx, unsigned argc, jsval *vp) -{ - int32_t i; - - if (!JS_ValueToInt32(cx, argc == 0 ? UndefinedValue() : vp[2], &i)) - return false; - JS_SET_RVAL(cx, vp, JS_NumberValue(i)); - return true; -} - static bool ThrowError(JSContext *cx, unsigned argc, jsval *vp) { @@ -4172,10 +4161,6 @@ static const JSFunctionSpecWithHelp shell_functions[] = { "getslx(obj)", " Get script line extent."), - JS_FN_HELP("toint32", ToInt32, 1, 0, -"toint32(n)", -" Testing hook for JS_ValueToInt32."), - JS_FN_HELP("evalcx", EvalInContext, 1, 0, "evalcx(s[, o])", " Evaluate s in optional sandbox object o.\n" diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index 4f343ab3c690..d4599d2f41b5 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -387,17 +387,18 @@ IgnoreReportedErrors(JSContext *cx, unsigned argc, jsval *vp) static bool DumpXPC(JSContext *cx, unsigned argc, jsval *vp) { - int32_t depth = 2; + JS::CallArgs args = CallArgsFromVp(argc, vp); - if (argc > 0) { - if (!JS_ValueToInt32(cx, JS_ARGV(cx, vp)[0], &depth)) + uint16_t depth = 2; + if (args.length() > 0) { + if (!JS::ToUint16(cx, args[0], &depth)) return false; } nsCOMPtr xpc = do_GetService(nsIXPConnect::GetCID()); if (xpc) xpc->DebugDump(int16_t(depth)); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + args.rval().setUndefined(); return true; } From 589a5e02d06399f8476447060725083f656f067a Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Sat, 2 Nov 2013 17:35:00 +0100 Subject: [PATCH 198/795] Bug 932769 followup - Fix typo. rs=evilpie --- js/src/jit/IonBuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index b8ca6afc90ab..394d3edbef34 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -5941,7 +5941,7 @@ ClassHasEffectlessLookup(const Class *clasp) static bool ClassHasResolveHook(JSCompartment *comp, const Class *clasp, PropertyName *name) { - if (clasp->resolve != JS_ResolveStub) + if (clasp->resolve == JS_ResolveStub) return false; if (clasp->resolve == (JSResolveOp)str_resolve) { From c41a24510b78aca77716bab1bf7f6a6b5f660a74 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Fri, 18 Oct 2013 14:48:13 -0400 Subject: [PATCH 199/795] Bug 918651 - part 1 - remove unnecessary using statements from IPDL files; r=ehsan --- dom/ipc/PContent.ipdl | 2 -- gfx/layers/ipc/PImageBridge.ipdl | 1 - ipc/ipdl/test/cxx/PTestActorPunning.ipdl | 2 -- 3 files changed, 5 deletions(-) diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 2a41c12d4418..8e0330660c61 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -40,7 +40,6 @@ include "nsGeoPositionIPCSerialiser.h"; include "gfxPoint.h"; using GeoPosition; -using PrefTuple; using ChromePackage; using ResourceMapping; @@ -52,7 +51,6 @@ using mozilla::null_t; using mozilla::void_t; using mozilla::dom::AudioChannelType; using mozilla::dom::AudioChannelState; -using mozilla::dom::BlobConstructorParams; using mozilla::dom::NativeThreadId; using mozilla::hal::ProcessPriority; using gfxIntSize; diff --git a/gfx/layers/ipc/PImageBridge.ipdl b/gfx/layers/ipc/PImageBridge.ipdl index 664568e987a0..85c1b0550ba5 100644 --- a/gfx/layers/ipc/PImageBridge.ipdl +++ b/gfx/layers/ipc/PImageBridge.ipdl @@ -12,7 +12,6 @@ include ProtocolTypes; include "mozilla/layers/CompositorTypes.h"; include "mozilla/GfxMessageUtils.h"; -using ImageHandle; using mozilla::layers::TextureInfo; namespace mozilla { diff --git a/ipc/ipdl/test/cxx/PTestActorPunning.ipdl b/ipc/ipdl/test/cxx/PTestActorPunning.ipdl index 413be9cdc1a3..6b47ec31e31e 100644 --- a/ipc/ipdl/test/cxx/PTestActorPunning.ipdl +++ b/ipc/ipdl/test/cxx/PTestActorPunning.ipdl @@ -3,8 +3,6 @@ include protocol PTestActorPunningPunned; include protocol PTestActorPunningSub; include "mozilla/_ipdltest/IPDLUnitTestUtils.h"; -using mozilla::_ipdltest::Bad; - namespace mozilla { namespace _ipdltest { From 072677915009ad8987561566a508b1ffe8f06ba1 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 1 Oct 2013 11:42:50 -0400 Subject: [PATCH 200/795] Bug 918651 - part 2 - don't munge the translation unit's headers; r=ehsan Keep the builtin headers separate from the translation unit's headers. We do this so when we start twiddling with the translation unit's headers, we don't have to handle cases where those headers are actually builtin headers. --- ipc/ipdl/ipdl/lower.py | 4 +++- ipc/ipdl/ipdl/type.py | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 636f824f366c..1f00d7abf8fb 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -8,7 +8,7 @@ from copy import deepcopy import ipdl.ast import ipdl.builtin from ipdl.cxx.ast import * -from ipdl.type import Actor, ActorType, ProcessGraph, TypeVisitor +from ipdl.type import Actor, ActorType, ProcessGraph, TypeVisitor, builtinHeaderIncludes # FIXME/cjones: the chromium Message logging code doesn't work on # gcc/POSIX, because it wprintf()s across the chromium/mozilla @@ -1418,6 +1418,8 @@ class _GenerateProtocolCode(ipdl.ast.Visitor): hf.addthings(_includeGuardStart(hf)) hf.addthing(Whitespace.NL) + for inc in builtinHeaderIncludes: + self.visitCxxInclude(inc) ipdl.ast.Visitor.visitTranslationUnit(self, tu) if tu.filetype == 'header': self.cppIncludeHeaders.append(_ipdlhHeaderName(tu)) diff --git a/ipc/ipdl/ipdl/type.py b/ipc/ipdl/ipdl/type.py index 611e9212466a..c35ff3cf1d8e 100644 --- a/ipc/ipdl/ipdl/type.py +++ b/ipc/ipdl/ipdl/type.py @@ -597,8 +597,6 @@ With this information, it finally type checks the AST.''' return False return True - tu.cxxIncludes = builtinHeaderIncludes + tu.cxxIncludes - # tag each relevant node with "decl" information, giving type, name, # and location of declaration if not runpass(GatherDecls(builtinUsing, self.errors)): From f177ad89af470cf21fe8936cf146ea2a59c2a353 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 23 Sep 2013 21:20:18 -0400 Subject: [PATCH 201/795] Bug 918651 - part 3 - add optional |from header| qualification to using statements in ipdl; r=bent --- ipc/ipdl/ipdl/ast.py | 13 ++++++++++++- ipc/ipdl/ipdl/parser.py | 25 ++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ipc/ipdl/ipdl/ast.py b/ipc/ipdl/ipdl/ast.py index 3b4cc90c3798..6fa8e8a01c41 100644 --- a/ipc/ipdl/ipdl/ast.py +++ b/ipc/ipdl/ipdl/ast.py @@ -186,9 +186,20 @@ class Include(Node): self.file = "%s.%s" % (name, suffix) class UsingStmt(Node): - def __init__(self, loc, cxxTypeSpec): + def __init__(self, loc, cxxTypeSpec, cxxHeader=None, kind=None): Node.__init__(self, loc) + assert not isinstance(cxxTypeSpec, str) + assert cxxHeader is None or isinstance(cxxHeader, str); + assert kind is None or kind == 'class' or kind == 'struct' self.type = cxxTypeSpec + self.header = cxxHeader + self.kind = kind + def canBeForwardDeclared(self): + return self.isClass() or self.isStruct() + def isClass(self): + return self.kind == 'class' + def isStruct(self): + return self.kind == 'struct' # "singletons" class PrettyPrinted: diff --git a/ipc/ipdl/ipdl/parser.py b/ipc/ipdl/ipdl/parser.py index 343f1ccd656d..b8f0d131c583 100644 --- a/ipc/ipdl/ipdl/parser.py +++ b/ipc/ipdl/ipdl/parser.py @@ -121,9 +121,11 @@ reserved = set(( 'bridges', 'call', 'child', + 'class', 'compress', '__delete__', 'delete', # reserve 'delete' to prevent its use + 'from', 'goto', 'include', 'intr', @@ -267,13 +269,30 @@ def p_IncludeStmt(p): if path is None: raise ParseError(loc, "can't locate include file `%s'"% ( inc.file)) - + inc.tu = Parser(type, id).parse(open(path).read(), path, Parser.current.includedirs, Parser.current.errout) p[0] = inc def p_UsingStmt(p): - """UsingStmt : USING CxxType""" - p[0] = UsingStmt(locFromTok(p, 1), p[2]) + """UsingStmt : USING CxxType + | USING CxxType FROM STRING + | USING CLASS CxxType FROM STRING + | USING STRUCT CxxType FROM STRING""" + if 6 == len(p): + header = p[5] + elif 5 == len(p): + header = p[4] + else: + header = None + if 6 == len(p): + kind = p[2] + else: + kind = None + if 6 == len(p): + cxxtype = p[3] + else: + cxxtype = p[2] + p[0] = UsingStmt(locFromTok(p, 1), cxxtype, header, kind) ##-------------------- ## Namespaced stuff From bd9f1542f0cc419cc05c7f66455dc4d79c5e849b Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 19:25:24 -0700 Subject: [PATCH 202/795] Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/99fccbaf953b Author: Arthur Chen Desc: Merge pull request #13158 from crh0716/911701 Bug 911701 - Show data signal strength when connecting to EVDO r=alive ======== https://hg.mozilla.org/integration/gaia-central/rev/5507232168db Author: Arthur Chen Desc: Bug 911701 - Show data signal strength when connecting to EVDO ======== https://hg.mozilla.org/integration/gaia-central/rev/529ce3503314 Author: Arthur Chen Desc: Merge pull request #13173 from crh0716/929792 But 929792 - Add a observer on keyboard name changes r=evelyn ======== https://hg.mozilla.org/integration/gaia-central/rev/ef6f8c6ff42e Author: Arthur Chen Desc: But 929792 - Add a observer on keyboard name changes --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index e433075777d7..f8010eef8d96 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "aa1ebd9c011628a4e1a9802fd552ec853610b2f5", + "revision": "99fccbaf953b2a2b1601ea6013f991a1925ff71d", "repo_path": "/integration/gaia-central" } From 2ce07b10aded0ff2b1a6056f1bd4f4bd8ddf02a1 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 20:00:24 -0700 Subject: [PATCH 203/795] Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/4b20ba0aa48d Author: Rex KM Lee Desc: Merge pull request #13213 from rexboy7/fix-bug912005 Bug 912005 - [Dialer][CDMA] Inform bluetooth of call manipulations, r=etienne ======== https://hg.mozilla.org/integration/gaia-central/rev/ac9667038774 Author: Rex Lee Desc: Bug 912005 - [Dialer][CDMA] Inform bluetooth of call manipulations ======== https://hg.mozilla.org/integration/gaia-central/rev/823f786bbd8a Author: Arthur Chen Desc: Merge pull request #13216 from soumyakanti/Bug_931379 Bug 931379 - Remove Pinyin (Simplified Chinese) selection from Developer... r=crh0716 ======== https://hg.mozilla.org/integration/gaia-central/rev/acb0747cc887 Author: Soumya Kanti Chakraborty Desc: Bug 931379 - Remove Pinyin (Simplified Chinese) selection from Developer>Keyboard layouts --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index f8010eef8d96..12805328c12a 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "99fccbaf953b2a2b1601ea6013f991a1925ff71d", + "revision": "4b20ba0aa48d1f26da98e72f8e8f013a6e8d2fe9", "repo_path": "/integration/gaia-central" } From 1e41980cf35426cb81465182b4a99e935ff6142e Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 30 Sep 2013 17:34:38 +0800 Subject: [PATCH 204/795] Bug 926343 - Part 1: nsIIccProvider.idl changes. r=hsinyi --- dom/icc/interfaces/nsIIccProvider.idl | 63 +++++++++++++++++---------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/dom/icc/interfaces/nsIIccProvider.idl b/dom/icc/interfaces/nsIIccProvider.idl index cf1b321bacd1..f65b20733943 100644 --- a/dom/icc/interfaces/nsIIccProvider.idl +++ b/dom/icc/interfaces/nsIIccProvider.idl @@ -20,7 +20,7 @@ interface nsIIccListener : nsISupports /** * XPCOM component (in the content process) that provides the ICC information. */ -[scriptable, uuid(52fa6780-c913-11e2-8b8b-0800200c9a66)] +[scriptable, uuid(7c67ab92-52a3-4e11-995c-c0ad2f66c4cb)] interface nsIIccProvider : nsISupports { /** @@ -28,48 +28,62 @@ interface nsIIccProvider : nsISupports * RadioInterfaceLayer in the chrome process. Only a content process that has * the 'mobileconnection' permission is allowed to register. */ - void registerIccMsg(in nsIIccListener listener); - void unregisterIccMsg(in nsIIccListener listener); + void registerIccMsg(in unsigned long clientId, in nsIIccListener listener); + void unregisterIccMsg(in unsigned long clientId, in nsIIccListener listener); /** * UICC Information */ - readonly attribute nsIDOMMozIccInfo iccInfo; + nsIDOMMozIccInfo getIccInfo(in unsigned long clientId); /** * Card State */ - readonly attribute DOMString cardState; + DOMString getCardState(in unsigned long clientId); /** * STK interfaces. */ - void sendStkResponse(in nsIDOMWindow window, - in jsval command, - in jsval response); - void sendStkMenuSelection(in nsIDOMWindow window, + void sendStkResponse(in unsigned long clientId, + in nsIDOMWindow window, + in jsval command, + in jsval response); + void sendStkMenuSelection(in unsigned long clientId, + in nsIDOMWindow window, in unsigned short itemIdentifier, - in boolean helpRequested); - void sendStkTimerExpiration(in nsIDOMWindow window, - in jsval timer); - void sendStkEventDownload(in nsIDOMWindow window, - in jsval event); + in boolean helpRequested); + void sendStkTimerExpiration(in unsigned long clientId, + in nsIDOMWindow window, + in jsval timer); + void sendStkEventDownload(in unsigned long clientId, + in nsIDOMWindow window, + in jsval event); /** * Card lock interfaces. */ - nsIDOMDOMRequest getCardLockState(in nsIDOMWindow window, in DOMString lockType); - nsIDOMDOMRequest unlockCardLock(in nsIDOMWindow window, in jsval info); - nsIDOMDOMRequest setCardLock(in nsIDOMWindow window, in jsval info); - nsIDOMDOMRequest getCardLockRetryCount(in nsIDOMWindow window, in DOMString lockType); + nsIDOMDOMRequest getCardLockState(in unsigned long clientId, + in nsIDOMWindow window, + in DOMString lockType); + nsIDOMDOMRequest unlockCardLock(in unsigned long clientId, + in nsIDOMWindow window, + in jsval info); + nsIDOMDOMRequest setCardLock(in unsigned long clientId, + in nsIDOMWindow window, + in jsval info); + nsIDOMDOMRequest getCardLockRetryCount(in unsigned long clientId, + in nsIDOMWindow window, + in DOMString lockType); /** * Phonebook interfaces. */ - nsIDOMDOMRequest readContacts(in nsIDOMWindow window, + nsIDOMDOMRequest readContacts(in unsigned long clientId, + in nsIDOMWindow window, in DOMString contactType); - nsIDOMDOMRequest updateContact(in nsIDOMWindow window, + nsIDOMDOMRequest updateContact(in unsigned long clientId, + in nsIDOMWindow window, in DOMString contactType, in jsval contact, in DOMString pin2); @@ -77,13 +91,16 @@ interface nsIIccProvider : nsISupports /** * Secure Card Icc communication channel */ - nsIDOMDOMRequest iccOpenChannel(in nsIDOMWindow window, + nsIDOMDOMRequest iccOpenChannel(in unsigned long clientId, + in nsIDOMWindow window, in DOMString aid); - nsIDOMDOMRequest iccExchangeAPDU(in nsIDOMWindow window, + nsIDOMDOMRequest iccExchangeAPDU(in unsigned long clientId, + in nsIDOMWindow window, in long channel, in jsval apdu); - nsIDOMDOMRequest iccCloseChannel(in nsIDOMWindow window, + nsIDOMDOMRequest iccCloseChannel(in unsigned long clientId, + in nsIDOMWindow window, in long channel); }; From d3b654cc3ea794f6b967813cb889ccb418dfe5a5 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Tue, 15 Oct 2013 12:21:36 +0800 Subject: [PATCH 205/795] Bug 926343 - Part 2: DOM changes for adding clientId in nsIIccProvider. f=hsinyi. r=smaug --- dom/icc/src/IccManager.cpp | 42 +++++++++++++++++++++++--------------- dom/icc/src/IccManager.h | 4 ++++ 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/dom/icc/src/IccManager.cpp b/dom/icc/src/IccManager.cpp index 0300314fdf48..552c62c32369 100644 --- a/dom/icc/src/IccManager.cpp +++ b/dom/icc/src/IccManager.cpp @@ -60,8 +60,15 @@ IccManager::IccManager() return; } + // TODO: Bug 814637 - WebIccManager API: support multiple sim cards + // In Multi-sim, there is more than one client in iccProvider. Each client + // represents a icc service. To maintain the backward compatibility with + // single sim, we always use client 0 for now. Adding support for multiple sim + // will be addressed in bug 814637. + mClientId = 0; + mListener = new Listener(this); - DebugOnly rv = mProvider->RegisterIccMsg(mListener); + DebugOnly rv = mProvider->RegisterIccMsg(mClientId, mListener); NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed registering icc messages with provider"); } @@ -77,7 +84,7 @@ IccManager::Shutdown() { if (mProvider && mListener) { mListener->Disconnect(); - mProvider->UnregisterIccMsg(mListener); + mProvider->UnregisterIccMsg(mClientId, mListener); mProvider = nullptr; mListener = nullptr; } @@ -93,7 +100,7 @@ IccManager::SendStkResponse(const JS::Value& aCommand, return NS_ERROR_FAILURE; } - mProvider->SendStkResponse(GetOwner(), aCommand, aResponse); + mProvider->SendStkResponse(mClientId, GetOwner(), aCommand, aResponse); return NS_OK; } @@ -104,7 +111,7 @@ IccManager::SendStkMenuSelection(uint16_t aItemIdentifier, bool aHelpRequested) return NS_ERROR_FAILURE; } - mProvider->SendStkMenuSelection(GetOwner(), aItemIdentifier, aHelpRequested); + mProvider->SendStkMenuSelection(mClientId, GetOwner(), aItemIdentifier, aHelpRequested); return NS_OK; } @@ -115,7 +122,7 @@ IccManager::SendStkTimerExpiration(const JS::Value& aTimer) return NS_ERROR_FAILURE; } - mProvider->SendStkTimerExpiration(GetOwner(), aTimer); + mProvider->SendStkTimerExpiration(mClientId, GetOwner(), aTimer); return NS_OK; } @@ -126,7 +133,7 @@ IccManager::SendStkEventDownload(const JS::Value& aEvent) return NS_ERROR_FAILURE; } - mProvider->SendStkEventDownload(GetOwner(), aEvent); + mProvider->SendStkEventDownload(mClientId, GetOwner(), aEvent); return NS_OK; } @@ -139,7 +146,7 @@ IccManager::GetIccInfo(nsIDOMMozIccInfo** aIccInfo) return NS_ERROR_FAILURE; } - return mProvider->GetIccInfo(aIccInfo); + return mProvider->GetIccInfo(mClientId, aIccInfo); } NS_IMETHODIMP @@ -150,7 +157,8 @@ IccManager::GetCardState(nsAString& cardState) if (!mProvider) { return NS_ERROR_FAILURE; } - return mProvider->GetCardState(cardState); + + return mProvider->GetCardState(mClientId, cardState); } NS_IMETHODIMP @@ -160,7 +168,7 @@ IccManager::GetCardLock(const nsAString& aLockType, nsIDOMDOMRequest** aDomReque return NS_ERROR_FAILURE; } - return mProvider->GetCardLockState(GetOwner(), aLockType, aDomRequest); + return mProvider->GetCardLockState(mClientId, GetOwner(), aLockType, aDomRequest); } NS_IMETHODIMP @@ -170,7 +178,7 @@ IccManager::SetCardLock(const JS::Value& aInfo, nsIDOMDOMRequest** aDomRequest) return NS_ERROR_FAILURE; } - return mProvider->SetCardLock(GetOwner(), aInfo, aDomRequest); + return mProvider->SetCardLock(mClientId, GetOwner(), aInfo, aDomRequest); } NS_IMETHODIMP @@ -180,7 +188,7 @@ IccManager::UnlockCardLock(const JS::Value& aInfo, nsIDOMDOMRequest** aDomReques return NS_ERROR_FAILURE; } - return mProvider->UnlockCardLock(GetOwner(), aInfo, aDomRequest); + return mProvider->UnlockCardLock(mClientId, GetOwner(), aInfo, aDomRequest); } NS_IMETHODIMP @@ -190,7 +198,7 @@ IccManager::GetCardLockRetryCount(const nsAString& aLockType, nsIDOMDOMRequest** return NS_ERROR_FAILURE; } - return mProvider->GetCardLockRetryCount(GetOwner(), aLockType, aDomRequest); + return mProvider->GetCardLockRetryCount(mClientId, GetOwner(), aLockType, aDomRequest); } NS_IMETHODIMP @@ -200,7 +208,7 @@ IccManager::IccOpenChannel(const nsAString& aAid, nsIDOMDOMRequest** aRequest) return NS_ERROR_FAILURE; } - return mProvider->IccOpenChannel(GetOwner(), aAid, aRequest); + return mProvider->IccOpenChannel(mClientId, GetOwner(), aAid, aRequest); } NS_IMETHODIMP @@ -210,7 +218,7 @@ IccManager::IccExchangeAPDU(int32_t aChannel, const jsval& aApdu, nsIDOMDOMReque return NS_ERROR_FAILURE; } - return mProvider->IccExchangeAPDU(GetOwner(), aChannel, aApdu, aRequest); + return mProvider->IccExchangeAPDU(mClientId, GetOwner(), aChannel, aApdu, aRequest); } NS_IMETHODIMP @@ -220,7 +228,7 @@ IccManager::IccCloseChannel(int32_t aChannel, nsIDOMDOMRequest** aRequest) return NS_ERROR_FAILURE; } - return mProvider->IccCloseChannel(GetOwner(), aChannel, aRequest); + return mProvider->IccCloseChannel(mClientId, GetOwner(), aChannel, aRequest); } NS_IMETHODIMP @@ -230,7 +238,7 @@ IccManager::ReadContacts(const nsAString& aContactType, nsIDOMDOMRequest** aRequ return NS_ERROR_FAILURE; } - return mProvider->ReadContacts(GetOwner(), aContactType, aRequest); + return mProvider->ReadContacts(mClientId, GetOwner(), aContactType, aRequest); } NS_IMETHODIMP @@ -243,7 +251,7 @@ IccManager::UpdateContact(const nsAString& aContactType, return NS_ERROR_FAILURE; } - return mProvider->UpdateContact(GetOwner(), aContactType, aContact, aPin2, aRequest); + return mProvider->UpdateContact(mClientId, GetOwner(), aContactType, aContact, aPin2, aRequest); } NS_IMPL_EVENT_HANDLER(IccManager, stkcommand) diff --git a/dom/icc/src/IccManager.h b/dom/icc/src/IccManager.h index 997e456275e0..20f8029794ae 100644 --- a/dom/icc/src/IccManager.h +++ b/dom/icc/src/IccManager.h @@ -37,6 +37,10 @@ public: void Shutdown(); private: + // TODO: Bug 814637 - WebIccManager API: support multiple sim cards + // The private member, mClient, will be moved to other proper place for + // supporting multiple sim cards. + uint32_t mClientId; nsCOMPtr mProvider; nsRefPtr mListener; }; From 4e050df812f4d245179d22ae97dbb236f65295b3 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 30 Sep 2013 18:22:33 +0800 Subject: [PATCH 206/795] Bug 926343 - Part 3: Bluetooth changes for adding clientId in nsIIccProvider. r=gyeh --- dom/bluetooth/BluetoothHfpManager.cpp | 3 ++- dom/bluetooth/BluetoothRilListener.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 43e901710605..5a9d02588d80 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -665,7 +665,8 @@ BluetoothHfpManager::HandleIccInfoChanged() NS_ENSURE_TRUE_VOID(icc); nsCOMPtr iccInfo; - icc->GetIccInfo(getter_AddRefs(iccInfo)); + // TODO: Bug 921991 - B2G BT: support multiple sim cards + icc->GetIccInfo(0, getter_AddRefs(iccInfo)); NS_ENSURE_TRUE_VOID(iccInfo); nsCOMPtr gsmIccInfo = do_QueryInterface(iccInfo); diff --git a/dom/bluetooth/BluetoothRilListener.cpp b/dom/bluetooth/BluetoothRilListener.cpp index 71d731808949..acbb4f719135 100644 --- a/dom/bluetooth/BluetoothRilListener.cpp +++ b/dom/bluetooth/BluetoothRilListener.cpp @@ -276,7 +276,8 @@ BluetoothRilListener::StartIccListening() do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE(provider, false); - nsresult rv = provider->RegisterIccMsg(mIccListener); + // TODO: Bug 921991 - B2G BT: support multiple sim cards + nsresult rv = provider->RegisterIccMsg(0, mIccListener); return NS_SUCCEEDED(rv); } @@ -287,7 +288,8 @@ BluetoothRilListener::StopIccListening() do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE(provider, false); - nsresult rv = provider->UnregisterIccMsg(mIccListener); + // TODO: Bug 921991 - B2G BT: support multiple sim cards + nsresult rv = provider->UnregisterIccMsg(0, mIccListener); return NS_SUCCEEDED(rv); } From 9e3a6991a89e49a92154807fd04ab2f82c8c3280 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 30 Sep 2013 18:46:02 +0800 Subject: [PATCH 207/795] Bug 926343 - Part 4: RIL implementation changes. r=hsinyi --- dom/system/gonk/RILContentHelper.js | 81 ++++++++++++++--------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index 7991e858335c..aadaf07f8036 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -617,15 +617,13 @@ RILContentHelper.prototype = { * nsIIccProvider */ - get iccInfo() { - //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. - let context = this.getRilContext(0); + getIccInfo: function getIccInfo(clientId) { + let context = this.getRilContext(clientId); return context && context.iccInfo; }, - get cardState() { - //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. - let context = this.getRilContext(0); + getCardState: function getIccInfo(clientId) { + let context = this.getRilContext(clientId); return context && context.cardState; }, @@ -836,7 +834,7 @@ RILContentHelper.prototype = { return request; }, - getCardLockState: function getCardLockState(window, lockType) { + getCardLockState: function getCardLockState(clientId, window, lockType) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -846,7 +844,7 @@ RILContentHelper.prototype = { this._windowsMap[requestId] = window; cpmm.sendAsyncMessage("RIL:GetCardLockState", { - clientId: 0, + clientId: clientId, data: { lockType: lockType, requestId: requestId @@ -855,7 +853,7 @@ RILContentHelper.prototype = { return request; }, - unlockCardLock: function unlockCardLock(window, info) { + unlockCardLock: function unlockCardLock(clientId, window, info) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -865,13 +863,13 @@ RILContentHelper.prototype = { this._windowsMap[info.requestId] = window; cpmm.sendAsyncMessage("RIL:UnlockCardLock", { - clientId: 0, + clientId: clientId, data: info }); return request; }, - setCardLock: function setCardLock(window, info) { + setCardLock: function setCardLock(clientId, window, info) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -881,13 +879,15 @@ RILContentHelper.prototype = { this._windowsMap[info.requestId] = window; cpmm.sendAsyncMessage("RIL:SetCardLock", { - clientId: 0, + clientId: clientId, data: info }); return request; }, - getCardLockRetryCount: function getCardLockRetryCount(window, lockType) { + getCardLockRetryCount: function getCardLockRetryCount(clientId, + window, + lockType) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -895,7 +895,7 @@ RILContentHelper.prototype = { let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:GetCardLockRetryCount", { - clientId: 0, + clientId: clientId, data: { lockType: lockType, requestId: requestId @@ -943,19 +943,20 @@ RILContentHelper.prototype = { return request; }, - sendStkResponse: function sendStkResponse(window, command, response) { + sendStkResponse: function sendStkResponse(clientId, window, command, response) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); } response.command = command; cpmm.sendAsyncMessage("RIL:SendStkResponse", { - clientId: 0, + clientId: clientId, data: response }); }, - sendStkMenuSelection: function sendStkMenuSelection(window, + sendStkMenuSelection: function sendStkMenuSelection(clientId, + window, itemIdentifier, helpRequested) { if (window == null) { @@ -963,7 +964,7 @@ RILContentHelper.prototype = { Cr.NS_ERROR_UNEXPECTED); } cpmm.sendAsyncMessage("RIL:SendStkMenuSelection", { - clientId: 0, + clientId: clientId, data: { itemIdentifier: itemIdentifier, helpRequested: helpRequested @@ -971,36 +972,35 @@ RILContentHelper.prototype = { }); }, - sendStkTimerExpiration: function sendStkTimerExpiration(window, + sendStkTimerExpiration: function sendStkTimerExpiration(clientId, + window, timer) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); } cpmm.sendAsyncMessage("RIL:SendStkTimerExpiration", { - clientId: 0, + clientId: clientId, data: { timer: timer } }); }, - sendStkEventDownload: function sendStkEventDownload(window, - event) { + sendStkEventDownload: function sendStkEventDownload(clientId, window, event) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); } cpmm.sendAsyncMessage("RIL:SendStkEventDownload", { - clientId: 0, + clientId: clientId, data: { event: event } }); }, - iccOpenChannel: function iccOpenChannel(window, - aid) { + iccOpenChannel: function iccOpenChannel(clientId, window, aid) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1010,7 +1010,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:IccOpenChannel", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, aid: aid @@ -1019,9 +1019,7 @@ RILContentHelper.prototype = { return request; }, - iccExchangeAPDU: function iccExchangeAPDU(window, - channel, - apdu) { + iccExchangeAPDU: function iccExchangeAPDU(clientId, window, channel, apdu) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1032,7 +1030,7 @@ RILContentHelper.prototype = { //Potentially you need serialization here and can't pass the jsval through cpmm.sendAsyncMessage("RIL:IccExchangeAPDU", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, channel: channel, @@ -1042,8 +1040,7 @@ RILContentHelper.prototype = { return request; }, - iccCloseChannel: function iccCloseChannel(window, - channel) { + iccCloseChannel: function iccCloseChannel(clientId, window, channel) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1053,7 +1050,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:IccCloseChannel", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, channel: channel @@ -1062,7 +1059,7 @@ RILContentHelper.prototype = { return request; }, - readContacts: function readContacts(window, contactType) { + readContacts: function readContacts(clientId, window, contactType) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1073,7 +1070,7 @@ RILContentHelper.prototype = { this._windowsMap[requestId] = window; cpmm.sendAsyncMessage("RIL:ReadIccContacts", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, contactType: contactType @@ -1082,7 +1079,7 @@ RILContentHelper.prototype = { return request; }, - updateContact: function updateContact(window, contactType, contact, pin2) { + updateContact: function updateContact(clientId, window, contactType, contact, pin2) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1117,7 +1114,7 @@ RILContentHelper.prototype = { iccContact.id = contact.id; cpmm.sendAsyncMessage("RIL:UpdateIccContact", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, contactType: contactType, @@ -1467,16 +1464,14 @@ RILContentHelper.prototype = { this.unregisterListener("_cellBroadcastListeners", 0, listener); }, - registerIccMsg: function registerIccMsg(listener) { + registerIccMsg: function registerIccMsg(clientId, listener) { debug("Registering for ICC related messages"); - //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. - this.registerListener("_iccListeners", 0, listener); + this.registerListener("_iccListeners", clientId, listener); cpmm.sendAsyncMessage("RIL:RegisterIccMsg"); }, - unregisterIccMsg: function unregisterIccMsg(listener) { - //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. - this.unregisterListener("_iccListeners", 0, listener); + unregisterIccMsg: function unregisterIccMsg(clientId, listener) { + this.unregisterListener("_iccListeners", clientId, listener); }, // nsIObserver From f4c2384809c0be4b22aba2fed5311c4edcde0986 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 1 Oct 2013 12:02:57 -0400 Subject: [PATCH 208/795] Bug 918651 - part 4 - add keyword arguments to _makeForwardDeclForQClass; r=ehsan We're going to need these later when we hand-roll our own forward declarations for classes and structs. --- ipc/ipdl/ipdl/lower.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 1f00d7abf8fb..5b2f2078cc15 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -239,8 +239,8 @@ def _shmemRevokeRights(shmemexpr): def _lookupShmem(idexpr): return ExprCall(ExprVar('LookupSharedMemory'), args=[ idexpr ]) -def _makeForwardDeclForQClass(clsname, quals): - fd = ForwardDecl(clsname, cls=1) +def _makeForwardDeclForQClass(clsname, quals, cls=1, struct=0): + fd = ForwardDecl(clsname, cls=cls, struct=struct) if 0 == len(quals): return fd From ebcc1e1abf060a5e6c1d71f117047791391301ea Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 1 Oct 2013 15:25:07 -0400 Subject: [PATCH 209/795] Bug 918651 - part 5 - qualify all IPDL using statements with required header; r=ehsan --- dom/bluetooth/ipc/PBluetooth.ipdl | 2 +- dom/fmradio/ipc/PFMRadio.ipdl | 2 +- dom/indexedDB/ipc/IndexedDBParams.ipdlh | 8 +-- dom/indexedDB/ipc/PIndexedDB.ipdl | 2 +- dom/indexedDB/ipc/PIndexedDBCursor.ipdl | 6 +- dom/indexedDB/ipc/PIndexedDBDatabase.ipdl | 6 +- dom/indexedDB/ipc/PIndexedDBObjectStore.ipdl | 6 +- dom/indexedDB/ipc/PIndexedDBRequest.ipdl | 6 +- dom/indexedDB/ipc/PIndexedDBTransaction.ipdl | 2 +- dom/ipc/DOMTypes.ipdlh | 2 +- dom/ipc/PBrowser.ipdl | 55 ++++++++++--------- dom/ipc/PContent.ipdl | 28 +++++----- dom/ipc/PDocumentRenderer.ipdl | 2 +- dom/ipc/PTabContext.ipdlh | 2 +- dom/mobilemessage/src/ipc/SmsTypes.ipdlh | 10 ++-- dom/network/src/PTCPSocket.ipdl | 2 +- dom/plugins/ipc/PBrowserStream.ipdl | 8 +-- dom/plugins/ipc/PPluginInstance.ipdl | 34 ++++++------ dom/plugins/ipc/PPluginModule.ipdl | 10 ++-- dom/plugins/ipc/PPluginScriptableObject.ipdl | 4 +- dom/plugins/ipc/PPluginStream.ipdl | 6 +- dom/plugins/ipc/PStreamNotify.ipdl | 2 +- gfx/layers/ipc/LayersMessages.ipdlh | 30 +++++----- gfx/layers/ipc/LayersSurfaces.ipdlh | 38 ++++++------- gfx/layers/ipc/PCompositor.ipdl | 6 +- gfx/layers/ipc/PImageBridge.ipdl | 2 +- gfx/layers/ipc/PLayerTransaction.ipdl | 2 +- hal/sandbox/PHal.ipdl | 30 +++++----- ipc/glue/InputStreamParams.ipdlh | 2 +- ipc/glue/URIParams.ipdlh | 2 +- .../test/cxx/PTestDataStructuresCommon.ipdlh | 4 +- ipc/ipdl/test/cxx/PTestJSON.ipdl | 4 +- ipc/ipdl/test/ipdl/error/shmem.ipdl | 2 +- ipc/ipdl/test/ipdl/ok/header.ipdlh | 4 +- .../test/ipdl/ok/multipleUsingCxxTypes.ipdl | 4 +- js/ipc/JavaScriptTypes.ipdlh | 2 +- js/ipc/PJavaScript.ipdl | 2 +- layout/ipc/PRenderFrame.ipdl | 2 +- netwerk/cookie/PCookieService.ipdl | 2 +- netwerk/ipc/NeckoChannelParams.ipdlh | 6 +- netwerk/ipc/PNecko.ipdl | 2 +- netwerk/protocol/ftp/PFTPChannel.ipdl | 2 +- netwerk/protocol/http/PHttpChannel.ipdl | 10 ++-- netwerk/protocol/websocket/PWebSocket.ipdl | 2 +- netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl | 2 +- 45 files changed, 184 insertions(+), 183 deletions(-) diff --git a/dom/bluetooth/ipc/PBluetooth.ipdl b/dom/bluetooth/ipc/PBluetooth.ipdl index c66f97f120f1..e6ae3f72d803 100644 --- a/dom/bluetooth/ipc/PBluetooth.ipdl +++ b/dom/bluetooth/ipc/PBluetooth.ipdl @@ -12,7 +12,7 @@ include BluetoothTypes; include "mozilla/dom/bluetooth/ipc/BluetoothMessageUtils.h"; -using mozilla::dom::bluetooth::BluetoothObjectType; +using mozilla::dom::bluetooth::BluetoothObjectType from "mozilla/dom/bluetooth/BluetoothCommon.h"; namespace mozilla { namespace dom { diff --git a/dom/fmradio/ipc/PFMRadio.ipdl b/dom/fmradio/ipc/PFMRadio.ipdl index 9672cb73b36e..f36b135d2746 100644 --- a/dom/fmradio/ipc/PFMRadio.ipdl +++ b/dom/fmradio/ipc/PFMRadio.ipdl @@ -7,7 +7,7 @@ include "mozilla/HalTypes.h"; include protocol PContent; include protocol PFMRadioRequest; -using mozilla::hal::FMRadioSeekDirection; +using mozilla::hal::FMRadioSeekDirection from "mozilla/HalTypes.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/IndexedDBParams.ipdlh b/dom/indexedDB/ipc/IndexedDBParams.ipdlh index a1222bbadbfd..d39e2cad9857 100644 --- a/dom/indexedDB/ipc/IndexedDBParams.ipdlh +++ b/dom/indexedDB/ipc/IndexedDBParams.ipdlh @@ -4,11 +4,11 @@ include "mozilla/dom/indexedDB/SerializationHelpers.h"; -using mozilla::dom::indexedDB::Key; -using mozilla::dom::indexedDB::IDBCursor::Direction; -using mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo; +using class mozilla::dom::indexedDB::Key from "mozilla/dom/indexedDB/Key.h"; +using mozilla::dom::indexedDB::IDBCursor::Direction from "mozilla/dom/indexedDB/IDBCursor.h"; +using struct mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo from "mozilla/dom/indexedDB/IndexedDatabase.h"; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/PIndexedDB.ipdl b/dom/indexedDB/ipc/PIndexedDB.ipdl index 6071deabd1e1..4677685709ad 100644 --- a/dom/indexedDB/ipc/PIndexedDB.ipdl +++ b/dom/indexedDB/ipc/PIndexedDB.ipdl @@ -9,7 +9,7 @@ include protocol PIndexedDBDeleteDatabaseRequest; include "mozilla/dom/indexedDB/SerializationHelpers.h"; -using mozilla::dom::quota::PersistenceType; +using mozilla::dom::quota::PersistenceType from "mozilla/dom/quota/PersistenceType.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/PIndexedDBCursor.ipdl b/dom/indexedDB/ipc/PIndexedDBCursor.ipdl index 97e9523df0ab..1daa93417355 100644 --- a/dom/indexedDB/ipc/PIndexedDBCursor.ipdl +++ b/dom/indexedDB/ipc/PIndexedDBCursor.ipdl @@ -8,10 +8,10 @@ include protocol PIndexedDBRequest; include "mozilla/dom/indexedDB/SerializationHelpers.h"; -using mozilla::dom::indexedDB::Key; -using mozilla::dom::indexedDB::IDBCursor::Direction; +using class mozilla::dom::indexedDB::Key from "mozilla/dom/indexedDB/Key.h"; +using mozilla::dom::indexedDB::IDBCursor::Direction from "mozilla/dom/indexedDB/IDBCursor.h"; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/PIndexedDBDatabase.ipdl b/dom/indexedDB/ipc/PIndexedDBDatabase.ipdl index 9efe393c7b78..f765687337cb 100644 --- a/dom/indexedDB/ipc/PIndexedDBDatabase.ipdl +++ b/dom/indexedDB/ipc/PIndexedDBDatabase.ipdl @@ -7,9 +7,9 @@ include protocol PIndexedDBTransaction; include "mozilla/dom/indexedDB/SerializationHelpers.h"; -using mozilla::dom::indexedDB::DatabaseInfoGuts; -using mozilla::dom::indexedDB::ObjectStoreInfoGuts; -using mozilla::dom::indexedDB::IDBTransaction::Mode; +using struct mozilla::dom::indexedDB::DatabaseInfoGuts from "mozilla/dom/indexedDB/DatabaseInfo.h"; +using struct mozilla::dom::indexedDB::ObjectStoreInfoGuts from "mozilla/dom/indexedDB/DatabaseInfo.h"; +using mozilla::dom::indexedDB::IDBTransaction::Mode from "mozilla/dom/indexedDB/IDBTransaction.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/PIndexedDBObjectStore.ipdl b/dom/indexedDB/ipc/PIndexedDBObjectStore.ipdl index df689242728f..8026db4086cd 100644 --- a/dom/indexedDB/ipc/PIndexedDBObjectStore.ipdl +++ b/dom/indexedDB/ipc/PIndexedDBObjectStore.ipdl @@ -10,9 +10,9 @@ include protocol PIndexedDBTransaction; include IndexedDBParams; -using mozilla::dom::indexedDB::IndexInfo; -using mozilla::dom::indexedDB::IndexUpdateInfo; -using mozilla::dom::indexedDB::SerializedStructuredCloneWriteInfo; +using struct mozilla::dom::indexedDB::IndexInfo from "mozilla/dom/indexedDB/DatabaseInfo.h"; +using struct mozilla::dom::indexedDB::IndexUpdateInfo from "mozilla/dom/indexedDB/DatabaseInfo.h"; +using struct mozilla::dom::indexedDB::SerializedStructuredCloneWriteInfo from "mozilla/dom/indexedDB/IndexedDatabase.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/PIndexedDBRequest.ipdl b/dom/indexedDB/ipc/PIndexedDBRequest.ipdl index f3b2b46d251d..4c83fed55110 100644 --- a/dom/indexedDB/ipc/PIndexedDBRequest.ipdl +++ b/dom/indexedDB/ipc/PIndexedDBRequest.ipdl @@ -9,10 +9,10 @@ include protocol PIndexedDBObjectStore; include "mozilla/dom/indexedDB/SerializationHelpers.h"; -using mozilla::dom::indexedDB::Key; -using mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo; +using class mozilla::dom::indexedDB::Key from "mozilla/dom/indexedDB/Key.h"; +using struct mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo from "mozilla/dom/indexedDB/IndexedDatabase.h"; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace dom { diff --git a/dom/indexedDB/ipc/PIndexedDBTransaction.ipdl b/dom/indexedDB/ipc/PIndexedDBTransaction.ipdl index de1177204ca1..ff6d88a7b74f 100644 --- a/dom/indexedDB/ipc/PIndexedDBTransaction.ipdl +++ b/dom/indexedDB/ipc/PIndexedDBTransaction.ipdl @@ -7,7 +7,7 @@ include protocol PIndexedDBObjectStore; include "mozilla/dom/indexedDB/SerializationHelpers.h"; -using mozilla::dom::indexedDB::ObjectStoreInfoGuts; +using struct mozilla::dom::indexedDB::ObjectStoreInfoGuts from "mozilla/dom/indexedDB/DatabaseInfo.h"; namespace mozilla { namespace dom { diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index 7087997b9aa8..037ee51e4f19 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -7,7 +7,7 @@ include protocol PBlob; include InputStreamParams; -using mozilla::SerializedStructuredCloneBuffer; +using struct mozilla::SerializedStructuredCloneBuffer from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace dom { diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 53f08ca648af..8c7209e93795 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -26,33 +26,34 @@ include "mozilla/dom/PermissionMessageUtils.h"; include "mozilla/layout/RenderFrameUtils.h"; include "mozilla/layers/CompositorTypes.h"; -using IPC::Principal; -using gfxMatrix; -using gfxSize; -using CSSRect; -using mozilla::layers::FrameMetrics; -using FrameMetrics::ViewID; -using mozilla::layout::ScrollingBehavior; -using mozilla::void_t; -using mozilla::WindowsHandle; -using nscolor; -using mozilla::WidgetCompositionEvent; -using nsIMEUpdatePreference; -using nsIntPoint; -using nsIntRect; -using nsIntSize; -using mozilla::WidgetKeyboardEvent; -using mozilla::WidgetMouseEvent; -using mozilla::WidgetWheelEvent; -using nsRect; -using mozilla::WidgetSelectionEvent; -using mozilla::WidgetTextEvent; -using mozilla::WidgetTouchEvent; -using RemoteDOMEvent; -using mozilla::dom::ScreenOrientation; -using mozilla::layers::TextureFactoryIdentifier; -using mozilla::CSSIntPoint; -using mozilla::CSSToScreenScale; +using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; +using struct gfxMatrix from "gfxMatrix.h"; +using struct gfxSize from "gfxPoint.h"; +using CSSRect from "Units.h"; +using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; +using FrameMetrics::ViewID from "FrameMetrics.h"; +using mozilla::layout::ScrollingBehavior from "mozilla/layout/RenderFrameUtils.h"; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; +using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h"; +using nscolor from "nsColor.h"; +using class mozilla::WidgetCompositionEvent from "ipc/nsGUIEventIPC.h"; +using struct nsIMEUpdatePreference from "nsIWidget.h"; +using struct nsIntPoint from "nsPoint.h"; +using struct nsIntRect from "nsRect.h"; +using struct nsIntSize from "nsSize.h"; +using class mozilla::WidgetKeyboardEvent from "ipc/nsGUIEventIPC.h"; +using class mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h"; +using class mozilla::WidgetWheelEvent from "ipc/nsGUIEventIPC.h"; +using struct nsRect from "nsRect.h"; +using class mozilla::WidgetSelectionEvent from "ipc/nsGUIEventIPC.h"; +using class mozilla::WidgetTextEvent from "ipc/nsGUIEventIPC.h"; +using class mozilla::WidgetTouchEvent from "ipc/nsGUIEventIPC.h"; +using struct mozilla::dom::RemoteDOMEvent from "mozilla/dom/TabMessageUtils.h"; +using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h"; +using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; +using mozilla::CSSIntPoint from "Units.h"; +using mozilla::CSSToScreenScale from "Units.h"; + namespace mozilla { namespace dom { diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 8e0330660c61..dc70f0424be2 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -39,21 +39,21 @@ include "mozilla/net/NeckoMessageUtils.h"; include "nsGeoPositionIPCSerialiser.h"; include "gfxPoint.h"; -using GeoPosition; +using GeoPosition from "nsGeoPositionIPCSerialiser.h"; -using ChromePackage; -using ResourceMapping; -using OverrideMapping; -using base::ChildPrivileges; -using IPC::Permission; -using IPC::Principal; -using mozilla::null_t; -using mozilla::void_t; -using mozilla::dom::AudioChannelType; -using mozilla::dom::AudioChannelState; -using mozilla::dom::NativeThreadId; -using mozilla::hal::ProcessPriority; -using gfxIntSize; +using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h"; +using struct ResourceMapping from "mozilla/chrome/RegistryMessageUtils.h"; +using struct OverrideMapping from "mozilla/chrome/RegistryMessageUtils.h"; +using base::ChildPrivileges from "base/process_util.h"; +using struct IPC::Permission from "mozilla/net/NeckoMessageUtils.h"; +using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h"; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; +using mozilla::dom::AudioChannelType from "AudioChannelCommon.h"; +using mozilla::dom::AudioChannelState from "AudioChannelCommon.h"; +using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h"; +using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h"; +using gfxIntSize from "nsSize.h"; namespace mozilla { namespace dom { diff --git a/dom/ipc/PDocumentRenderer.ipdl b/dom/ipc/PDocumentRenderer.ipdl index 4851cf967f4b..6ee3358f7f1a 100644 --- a/dom/ipc/PDocumentRenderer.ipdl +++ b/dom/ipc/PDocumentRenderer.ipdl @@ -7,7 +7,7 @@ include protocol PBrowser; include "mozilla/GfxMessageUtils.h"; -using nsIntSize; +using struct nsIntSize from "nsSize.h"; namespace mozilla { namespace ipc { diff --git a/dom/ipc/PTabContext.ipdlh b/dom/ipc/PTabContext.ipdlh index 0c50763d44c8..da5bd3236ce8 100644 --- a/dom/ipc/PTabContext.ipdlh +++ b/dom/ipc/PTabContext.ipdlh @@ -8,7 +8,7 @@ include protocol PBrowser; include "mozilla/layout/RenderFrameUtils.h"; -using mozilla::layout::ScrollingBehavior; +using mozilla::layout::ScrollingBehavior from "mozilla/layout/RenderFrameUtils.h"; namespace mozilla { namespace dom { diff --git a/dom/mobilemessage/src/ipc/SmsTypes.ipdlh b/dom/mobilemessage/src/ipc/SmsTypes.ipdlh index 6ac02a125f3f..05f6bdc3108c 100644 --- a/dom/mobilemessage/src/ipc/SmsTypes.ipdlh +++ b/dom/mobilemessage/src/ipc/SmsTypes.ipdlh @@ -7,11 +7,11 @@ include "mozilla/dom/mobilemessage/Types.h"; include protocol PBlob; -using DeliveryState; -using DeliveryStatus; -using MessageClass; -using ReadState; -using MessageType; +using DeliveryState from "mozilla/dom/mobilemessage/Types.h"; +using DeliveryStatus from "mozilla/dom/mobilemessage/Types.h"; +using MessageClass from "mozilla/dom/mobilemessage/Types.h"; +using ReadState from "mozilla/dom/mobilemessage/Types.h"; +using MessageType from "mozilla/dom/mobilemessage/Types.h"; namespace mozilla { namespace dom { diff --git a/dom/network/src/PTCPSocket.ipdl b/dom/network/src/PTCPSocket.ipdl index 6e257cc54408..d66291e8f111 100644 --- a/dom/network/src/PTCPSocket.ipdl +++ b/dom/network/src/PTCPSocket.ipdl @@ -9,7 +9,7 @@ include protocol PNecko; include "mozilla/net/NeckoMessageUtils.h"; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; struct TCPError { nsString name; diff --git a/dom/plugins/ipc/PBrowserStream.ipdl b/dom/plugins/ipc/PBrowserStream.ipdl index 53435a93489c..4a46294c2261 100644 --- a/dom/plugins/ipc/PBrowserStream.ipdl +++ b/dom/plugins/ipc/PBrowserStream.ipdl @@ -7,11 +7,11 @@ include protocol PPluginInstance; include "mozilla/plugins/PluginMessageUtils.h"; -using mozilla::plugins::Buffer; -using mozilla::plugins::IPCByteRanges; +using mozilla::plugins::Buffer from "mozilla/plugins/PluginMessageUtils.h"; +using mozilla::plugins::IPCByteRanges from "mozilla/plugins/PluginMessageUtils.h"; -using NPError; -using NPReason; +using NPError from "npapi.h"; +using NPReason from "npapi.h"; namespace mozilla { namespace plugins { diff --git a/dom/plugins/ipc/PPluginInstance.ipdl b/dom/plugins/ipc/PPluginInstance.ipdl index 42d763205c95..c31cae1cb0a8 100644 --- a/dom/plugins/ipc/PPluginInstance.ipdl +++ b/dom/plugins/ipc/PPluginInstance.ipdl @@ -15,23 +15,23 @@ include "mozilla/plugins/PluginMessageUtils.h"; include "ipc/nsGUIEventIPC.h"; include "gfxTypes.h"; -using NPError; -using NPRemoteWindow; -using NPRemoteEvent; -using NPRect; -using NPImageFormat; -using NPNURLVariable; -using NPCoordinateSpace; -using NPNVariable; -using mozilla::plugins::NativeWindowHandle; -using gfxSurfaceType; -using gfxIntSize; -using mozilla::null_t; -using mozilla::plugins::WindowsSharedMemoryHandle; -using mozilla::plugins::DXGISharedSurfaceHandle; -using mozilla::CrossProcessMutexHandle; -using SurfaceDescriptorX11; -using nsIntRect; +using NPError from "npapi.h"; +using struct mozilla::plugins::NPRemoteWindow from "mozilla/plugins/PluginMessageUtils.h"; +using struct mozilla::plugins::NPRemoteEvent from "mozilla/plugins/PluginMessageUtils.h"; +using NPRect from "npapi.h"; +using NPImageFormat from "npapi.h"; +using NPNURLVariable from "npapi.h"; +using NPCoordinateSpace from "npapi.h"; +using NPNVariable from "npapi.h"; +using mozilla::plugins::NativeWindowHandle from "mozilla/plugins/PluginMessageUtils.h"; +using gfxSurfaceType from "gfxTypes.h"; +using gfxIntSize from "nsSize.h"; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; +using mozilla::plugins::WindowsSharedMemoryHandle from "mozilla/plugins/PluginMessageUtils.h"; +using mozilla::plugins::DXGISharedSurfaceHandle from "mozilla/plugins/PluginMessageUtils.h"; +using mozilla::CrossProcessMutexHandle from "mozilla/ipc/CrossProcessMutex.h"; +using struct SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h"; +using struct nsIntRect from "nsRect.h"; namespace mozilla { namespace plugins { diff --git a/dom/plugins/ipc/PPluginModule.ipdl b/dom/plugins/ipc/PPluginModule.ipdl index c8454452d4cb..3ec6a119da54 100644 --- a/dom/plugins/ipc/PPluginModule.ipdl +++ b/dom/plugins/ipc/PPluginModule.ipdl @@ -12,11 +12,11 @@ include "npapi.h"; include "mozilla/plugins/PluginMessageUtils.h"; include "mozilla/dom/TabMessageUtils.h"; -using NPError; -using NPNVariable; -using mozilla::dom::NativeThreadId; -using mac_plugin_interposing::NSCursorInfo; -using nsID; +using NPError from "npapi.h"; +using NPNVariable from "npapi.h"; +using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h"; +using class mac_plugin_interposing::NSCursorInfo from "mozilla/plugins/PluginMessageUtils.h"; +using struct nsID from "nsID.h"; namespace mozilla { namespace plugins { diff --git a/dom/plugins/ipc/PPluginScriptableObject.ipdl b/dom/plugins/ipc/PPluginScriptableObject.ipdl index f3ecb59aa6a3..13a80bd90e82 100644 --- a/dom/plugins/ipc/PPluginScriptableObject.ipdl +++ b/dom/plugins/ipc/PPluginScriptableObject.ipdl @@ -10,8 +10,8 @@ include "npapi.h"; include "npruntime.h"; include "mozilla/plugins/PluginMessageUtils.h"; -using mozilla::void_t; -using mozilla::null_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace plugins { diff --git a/dom/plugins/ipc/PPluginStream.ipdl b/dom/plugins/ipc/PPluginStream.ipdl index 162f96af7e4a..bf923404e446 100644 --- a/dom/plugins/ipc/PPluginStream.ipdl +++ b/dom/plugins/ipc/PPluginStream.ipdl @@ -7,9 +7,9 @@ include protocol PPluginInstance; include "mozilla/plugins/PluginMessageUtils.h"; -using mozilla::plugins::Buffer; -using NPError; -using NPReason; +using mozilla::plugins::Buffer from "mozilla/plugins/PluginMessageUtils.h"; +using NPError from "npapi.h"; +using NPReason from "npapi.h"; namespace mozilla { namespace plugins { diff --git a/dom/plugins/ipc/PStreamNotify.ipdl b/dom/plugins/ipc/PStreamNotify.ipdl index 0ce06b8c90f4..a2704fc1e899 100644 --- a/dom/plugins/ipc/PStreamNotify.ipdl +++ b/dom/plugins/ipc/PStreamNotify.ipdl @@ -8,7 +8,7 @@ include protocol PPluginInstance; include "npapi.h"; -using NPReason; +using NPReason from "npapi.h"; namespace mozilla { namespace plugins { diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index e145c35fb11f..2ee2f72c3345 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -21,21 +21,21 @@ include "mozilla/GfxMessageUtils.h"; include "ImageLayers.h"; include "mozilla/layers/CompositorTypes.h"; -using gfxPoint3D; -using nscoord; -using nsRect; -using nsPoint; -using mozilla::TimeDuration; -using mozilla::TimeStamp; -using mozilla::ScreenRotation; -using nsCSSProperty; -using mozilla::dom::ScreenOrientation; -using mozilla::layers::TextureInfo; -using mozilla::LayerMargin; -using mozilla::LayerPoint; -using mozilla::LayerRect; -using mozilla::layers::ScaleMode; -using mozilla::layers::DiagnosticTypes; +using struct gfxPoint3D from "gfxPoint3D.h"; +using nscoord from "nsCoord.h"; +using struct nsRect from "nsRect.h"; +using struct nsPoint from "nsPoint.h"; +using class mozilla::TimeDuration from "mozilla/TimeStamp.h"; +using class mozilla::TimeStamp from "mozilla/TimeStamp.h"; +using mozilla::ScreenRotation from "mozilla/WidgetUtils.h"; +using nsCSSProperty from "nsCSSProperty.h"; +using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h"; +using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; +using mozilla::LayerMargin from "Units.h"; +using mozilla::LayerPoint from "Units.h"; +using mozilla::LayerRect from "Units.h"; +using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h"; +using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h"; namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 8cdac5cdb013..b407a14bb100 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -8,25 +8,25 @@ include "gfxipc/ShadowLayerUtils.h"; include "mozilla/gfx/Types.h"; include "nsRegion.h"; -using gfx3DMatrix; -using gfxIntSize; -using gfxPoint; -using gfxRGBA; -using nsIntPoint; -using nsIntRect; -using nsIntRegion; -using nsIntSize; -using mozilla::GraphicsFilterType; -using mozilla::layers::FrameMetrics; -using mozilla::layers::MagicGrallocBufferHandle; -using mozilla::layers::SurfaceDescriptorX11; -using mozilla::null_t; -using mozilla::WindowsHandle; -using mozilla::gl::SharedTextureHandle; -using mozilla::gl::SharedTextureShareType; -using mozilla::gfx::SurfaceStreamHandle; -using mozilla::gfx::SurfaceFormat; -using mozilla::gfx::IntSize; +using class gfx3DMatrix from "gfx3DMatrix.h"; +using gfxIntSize from "nsSize.h"; +using struct gfxPoint from "gfxPoint.h"; +using struct gfxRGBA from "gfxColor.h"; +using struct nsIntPoint from "nsPoint.h"; +using struct nsIntRect from "nsRect.h"; +using nsIntRegion from "nsRegion.h"; +using struct nsIntSize from "nsSize.h"; +using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; +using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; +using struct mozilla::layers::MagicGrallocBufferHandle from "gfxipc/ShadowLayerUtils.h"; +using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h"; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; +using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h"; +using mozilla::gl::SharedTextureHandle from "GLContextTypes.h"; +using mozilla::gl::SharedTextureShareType from "GLContextTypes.h"; +using mozilla::gfx::SurfaceStreamHandle from "SurfaceTypes.h"; +using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; +using mozilla::gfx::IntSize from "mozilla/gfx/Point.h"; namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/PCompositor.ipdl b/gfx/layers/ipc/PCompositor.ipdl index e8bf33dc3a62..7cd2d40973a9 100644 --- a/gfx/layers/ipc/PCompositor.ipdl +++ b/gfx/layers/ipc/PCompositor.ipdl @@ -11,9 +11,9 @@ include protocol PLayerTransaction; include "mozilla/layers/CompositorTypes.h"; include "mozilla/GfxMessageUtils.h"; -using mozilla::null_t; -using mozilla::layers::TextureFactoryIdentifier; -using mozilla::layers::LayersBackend; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; +using struct mozilla::layers::TextureFactoryIdentifier from "mozilla/layers/CompositorTypes.h"; +using mozilla::layers::LayersBackend from "mozilla/layers/LayersTypes.h"; namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/PImageBridge.ipdl b/gfx/layers/ipc/PImageBridge.ipdl index 85c1b0550ba5..391e3402b960 100644 --- a/gfx/layers/ipc/PImageBridge.ipdl +++ b/gfx/layers/ipc/PImageBridge.ipdl @@ -12,7 +12,7 @@ include ProtocolTypes; include "mozilla/layers/CompositorTypes.h"; include "mozilla/GfxMessageUtils.h"; -using mozilla::layers::TextureInfo; +using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/PLayerTransaction.ipdl b/gfx/layers/ipc/PLayerTransaction.ipdl index 2c29d1ff7e54..508fcf875b7b 100644 --- a/gfx/layers/ipc/PLayerTransaction.ipdl +++ b/gfx/layers/ipc/PLayerTransaction.ipdl @@ -19,7 +19,7 @@ include "nsCSSProperty.h"; include "gfxipc/ShadowLayerUtils.h"; include "mozilla/GfxMessageUtils.h"; -using mozilla::layers::TextureInfo; +using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h"; /** * The layers protocol is spoken between thread contexts that manage diff --git a/hal/sandbox/PHal.ipdl b/hal/sandbox/PHal.ipdl index 4f71b61eef65..f488bbf31b47 100644 --- a/hal/sandbox/PHal.ipdl +++ b/hal/sandbox/PHal.ipdl @@ -12,21 +12,21 @@ include "mozilla/HalTypes.h"; include "mozilla/dom/ScreenOrientation.h"; include "nsRect.h"; -using mozilla::dom::ScreenOrientation; -using mozilla::hal::FlashMode; -using mozilla::hal::LightType; -using mozilla::hal::LightMode; -using mozilla::hal::SensorType; -using mozilla::hal::SensorAccuracyType; -using mozilla::hal::WakeLockControl; -using mozilla::hal::SwitchState; -using mozilla::hal::SwitchDevice; -using mozilla::hal::ProcessPriority; -using nsIntRect; -using PRTime; -using mozilla::hal::FMRadioCountry; -using mozilla::hal::FMRadioOperation; -using mozilla::hal::FMRadioOperationStatus; +using mozilla::dom::ScreenOrientation from "mozilla/dom/ScreenOrientation.h"; +using mozilla::hal::FlashMode from "mozilla/HalTypes.h"; +using mozilla::hal::LightType from "mozilla/HalTypes.h"; +using mozilla::hal::LightMode from "mozilla/HalTypes.h"; +using mozilla::hal::SensorType from "mozilla/HalSensor.h"; +using mozilla::hal::SensorAccuracyType from "mozilla/HalSensor.h"; +using mozilla::hal::WakeLockControl from "mozilla/HalTypes.h"; +using mozilla::hal::SwitchState from "mozilla/HalTypes.h"; +using mozilla::hal::SwitchDevice from "mozilla/HalTypes.h"; +using mozilla::hal::ProcessPriority from "mozilla/HalTypes.h"; +using struct nsIntRect from "nsRect.h"; +using PRTime from "prtime.h"; +using mozilla::hal::FMRadioCountry from "mozilla/HalTypes.h"; +using mozilla::hal::FMRadioOperation from "mozilla/HalTypes.h"; +using mozilla::hal::FMRadioOperationStatus from "mozilla/HalTypes.h"; namespace mozilla { diff --git a/ipc/glue/InputStreamParams.ipdlh b/ipc/glue/InputStreamParams.ipdlh index b7d33a7f4a05..7129aa9e0799 100644 --- a/ipc/glue/InputStreamParams.ipdlh +++ b/ipc/glue/InputStreamParams.ipdlh @@ -4,7 +4,7 @@ include "ipc/IPCMessageUtils.h"; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; include protocol PBlob; namespace mozilla { diff --git a/ipc/glue/URIParams.ipdlh b/ipc/glue/URIParams.ipdlh index 127d0b5b18ff..3c59589e1adc 100644 --- a/ipc/glue/URIParams.ipdlh +++ b/ipc/glue/URIParams.ipdlh @@ -4,7 +4,7 @@ include "ipc/IPCMessageUtils.h"; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace ipc { diff --git a/ipc/ipdl/test/cxx/PTestDataStructuresCommon.ipdlh b/ipc/ipdl/test/cxx/PTestDataStructuresCommon.ipdlh index dad37d6fcc58..891b0c991d5a 100644 --- a/ipc/ipdl/test/cxx/PTestDataStructuresCommon.ipdlh +++ b/ipc/ipdl/test/cxx/PTestDataStructuresCommon.ipdlh @@ -1,7 +1,7 @@ include protocol PTestDataStructuresSub; -using mozilla::null_t; -using nsIntRegion; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; +using nsIntRegion from "nsRegion.h"; namespace mozilla { namespace _foo { diff --git a/ipc/ipdl/test/cxx/PTestJSON.ipdl b/ipc/ipdl/test/cxx/PTestJSON.ipdl index 099a6bd9b777..6e8f3c1deac0 100644 --- a/ipc/ipdl/test/cxx/PTestJSON.ipdl +++ b/ipc/ipdl/test/cxx/PTestJSON.ipdl @@ -1,7 +1,7 @@ include protocol PTestHandle; -using mozilla::void_t; -using mozilla::null_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; +using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace _ipdltest { diff --git a/ipc/ipdl/test/ipdl/error/shmem.ipdl b/ipc/ipdl/test/ipdl/error/shmem.ipdl index 6520b1ceb35b..f9046fb4cd5e 100644 --- a/ipc/ipdl/test/ipdl/error/shmem.ipdl +++ b/ipc/ipdl/test/ipdl/error/shmem.ipdl @@ -1,4 +1,4 @@ -using mozilla::ipc::Shmem; // redeclaration +using class mozilla::ipc::Shmem from "mozilla/ipc/Shmem.h"; // redeclaration protocol shmem { child: Msg(Shmem s); diff --git a/ipc/ipdl/test/ipdl/ok/header.ipdlh b/ipc/ipdl/test/ipdl/ok/header.ipdlh index ac238f84f704..ae3c813d60aa 100644 --- a/ipc/ipdl/test/ipdl/ok/header.ipdlh +++ b/ipc/ipdl/test/ipdl/ok/header.ipdlh @@ -1,7 +1,7 @@ include "foo.h"; -using foo; -using bar::baz; +using foo from "foo.h"; +using bar::baz from "foo.h"; struct Outer { }; diff --git a/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl b/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl index dbe208eef706..6bdbd7843efe 100644 --- a/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl +++ b/ipc/ipdl/test/ipdl/ok/multipleUsingCxxTypes.ipdl @@ -1,5 +1,5 @@ -using mozilla::void_t; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; protocol multipleUsingCxxTypes { child: diff --git a/js/ipc/JavaScriptTypes.ipdlh b/js/ipc/JavaScriptTypes.ipdlh index 949e2e79de09..10e16b87a4d7 100644 --- a/js/ipc/JavaScriptTypes.ipdlh +++ b/js/ipc/JavaScriptTypes.ipdlh @@ -7,7 +7,7 @@ include DOMTypes; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace jsipc { diff --git a/js/ipc/PJavaScript.ipdl b/js/ipc/PJavaScript.ipdl index 2df8816d0c69..5103fe650302 100644 --- a/js/ipc/PJavaScript.ipdl +++ b/js/ipc/PJavaScript.ipdl @@ -9,7 +9,7 @@ include protocol PContent; include DOMTypes; include JavaScriptTypes; -using mozilla::void_t; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; namespace mozilla { namespace jsipc { diff --git a/layout/ipc/PRenderFrame.ipdl b/layout/ipc/PRenderFrame.ipdl index cc6e57a24c30..37bb70408519 100644 --- a/layout/ipc/PRenderFrame.ipdl +++ b/layout/ipc/PRenderFrame.ipdl @@ -10,7 +10,7 @@ include protocol PLayerTransaction; include "nsRegion.h"; -using nsRegion; +using class nsRegion from "nsRegion.h"; namespace mozilla { namespace layout { diff --git a/netwerk/cookie/PCookieService.ipdl b/netwerk/cookie/PCookieService.ipdl index 768eabf1f53e..73c969bc2c6a 100644 --- a/netwerk/cookie/PCookieService.ipdl +++ b/netwerk/cookie/PCookieService.ipdl @@ -10,7 +10,7 @@ include URIParams; include "SerializedLoadContext.h"; -using IPC::SerializedLoadContext; +using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; namespace mozilla { namespace net { diff --git a/netwerk/ipc/NeckoChannelParams.ipdlh b/netwerk/ipc/NeckoChannelParams.ipdlh index 4e2a083267ec..59f9545bf80a 100644 --- a/netwerk/ipc/NeckoChannelParams.ipdlh +++ b/netwerk/ipc/NeckoChannelParams.ipdlh @@ -9,9 +9,9 @@ include URIParams; include InputStreamParams; include "mozilla/net/PHttpChannelParams.h"; -using mozilla::void_t; -using RequestHeaderTuples; -using nsHttpAtom; +using struct mozilla::void_t from "ipc/IPCMessageUtils.h"; +using RequestHeaderTuples from "mozilla/net/PHttpChannelParams.h"; +using struct nsHttpAtom from "nsHttp.h"; namespace mozilla { namespace net { diff --git a/netwerk/ipc/PNecko.ipdl b/netwerk/ipc/PNecko.ipdl index ff66c658b65c..54aba6b1ad75 100644 --- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -24,7 +24,7 @@ include NeckoChannelParams; include "SerializedLoadContext.h"; -using IPC::SerializedLoadContext; +using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; namespace mozilla { namespace net { diff --git a/netwerk/protocol/ftp/PFTPChannel.ipdl b/netwerk/protocol/ftp/PFTPChannel.ipdl index e7bb1e89ef0e..8ca22e54768e 100644 --- a/netwerk/protocol/ftp/PFTPChannel.ipdl +++ b/netwerk/protocol/ftp/PFTPChannel.ipdl @@ -15,7 +15,7 @@ include protocol PBlob; //FIXME: bug #792908 include "SerializedLoadContext.h"; -using PRTime; +using PRTime from "prtime.h"; namespace mozilla { namespace net { diff --git a/netwerk/protocol/http/PHttpChannel.ipdl b/netwerk/protocol/http/PHttpChannel.ipdl index e1fff68d3179..8d9a64bab5e6 100644 --- a/netwerk/protocol/http/PHttpChannel.ipdl +++ b/netwerk/protocol/http/PHttpChannel.ipdl @@ -16,11 +16,11 @@ include "mozilla/net/NeckoMessageUtils.h"; include "mozilla/net/DNS.h"; include "prio.h"; -using RequestHeaderTuples; -using nsHttpHeaderArray; -using nsHttpResponseHead; -using nsHttpAtom; -using mozilla::net::NetAddr; +using RequestHeaderTuples from "mozilla/net/PHttpChannelParams.h"; +using class nsHttpHeaderArray from "nsHttpHeaderArray.h"; +using class nsHttpResponseHead from "nsHttpResponseHead.h"; +using struct nsHttpAtom from "nsHttp.h"; +using mozilla::net::NetAddr from "mozilla/net/DNS.h"; namespace mozilla { namespace net { diff --git a/netwerk/protocol/websocket/PWebSocket.ipdl b/netwerk/protocol/websocket/PWebSocket.ipdl index 68585d0fb93c..0f0d70985de6 100644 --- a/netwerk/protocol/websocket/PWebSocket.ipdl +++ b/netwerk/protocol/websocket/PWebSocket.ipdl @@ -13,7 +13,7 @@ include URIParams; include protocol PBlob; //FIXME: bug #792908 include "SerializedLoadContext.h"; -using IPC::SerializedLoadContext; +using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; namespace mozilla { namespace net { diff --git a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl index 046168f9d5f5..e2b7676dc03d 100644 --- a/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl +++ b/netwerk/protocol/wyciwyg/PWyciwygChannel.ipdl @@ -8,7 +8,7 @@ include URIParams; include "SerializedLoadContext.h"; -using IPC::SerializedLoadContext; +using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; namespace mozilla { namespace net { From e5d5df0e6c0455fb5bd03fccb79a1a9ff450f44b Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Fri, 18 Oct 2013 12:08:10 -0400 Subject: [PATCH 210/795] Bug 918651 - part 6 - add unqualifiedTypedefs parameter to _ComputeTypeDeps; r=ehsan When computing what set of includes a header file needs, we need to know about all types that protocol-defined types use, not just qualified ones: both global-scope names and same-namespace-as-protocol names are valid to use without any sort of qualification. This flag would normally not be used in generating actual C++ code and therefore defaults to False. --- ipc/ipdl/ipdl/lower.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 5b2f2078cc15..6571612b99c1 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -1842,14 +1842,15 @@ class _ComputeTypeDeps(TypeVisitor): types that need forward declaration; (ii) types that need a |using| stmt. Some types generate both kinds.''' - def __init__(self, fortype): + def __init__(self, fortype, unqualifiedTypedefs=False): ipdl.type.TypeVisitor.__init__(self) self.usingTypedefs = [ ] self.forwardDeclStmts = [ ] self.fortype = fortype + self.unqualifiedTypedefs = unqualifiedTypedefs def maybeTypedef(self, fqname, name): - if fqname != name: + if fqname != name or self.unqualifiedTypedefs: self.usingTypedefs.append(Typedef(Type(fqname), name)) def visitBuiltinCxxType(self, t): From 05e020c835ca5f034765238e8d590508a865b087 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Fri, 18 Oct 2013 16:57:55 -0400 Subject: [PATCH 211/795] Bug 918651 - part 7a - fix source files bootlegging things from IPDL headers; rs=ehsan --- dom/ipc/ContentChild.cpp | 1 + dom/ipc/ContentParent.cpp | 1 + dom/ipc/TabChild.cpp | 1 + dom/ipc/TabChild.h | 5 +---- dom/ipc/TabParent.h | 2 ++ dom/media/MediaPermissionGonk.cpp | 1 + dom/plugins/ipc/PluginModuleChild.h | 1 + dom/plugins/ipc/PluginModuleParent.h | 1 + dom/plugins/ipc/PluginScriptableObjectChild.h | 1 + dom/plugins/ipc/PluginScriptableObjectParent.h | 1 + dom/src/geolocation/nsGeolocation.cpp | 1 + dom/src/notification/Notification.cpp | 1 + extensions/cookie/nsPermissionManager.cpp | 1 + layout/base/nsPresContext.cpp | 1 + netwerk/cookie/CookieServiceChild.cpp | 1 + netwerk/cookie/CookieServiceParent.cpp | 1 + netwerk/ipc/NeckoChild.cpp | 1 + netwerk/ipc/NeckoParent.cpp | 1 + netwerk/protocol/ftp/FTPChannelChild.cpp | 1 + netwerk/protocol/ftp/FTPChannelParent.cpp | 1 + netwerk/protocol/http/HttpChannelChild.cpp | 1 + netwerk/protocol/http/HttpChannelParent.cpp | 1 + netwerk/protocol/websocket/WebSocketChannelChild.cpp | 1 + netwerk/protocol/websocket/WebSocketChannelParent.cpp | 1 + netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp | 1 + netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp | 1 + 26 files changed, 27 insertions(+), 4 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 2887b2c4f190..755e479cf85f 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -117,6 +117,7 @@ #include "AudioChannelService.h" #include "JavaScriptChild.h" #include "mozilla/dom/telephony/PTelephonyChild.h" +#include "mozilla/net/NeckoMessageUtils.h" using namespace base; using namespace mozilla; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 8df99afdbe3e..3ae773bb5b39 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -91,6 +91,7 @@ #include "URIUtils.h" #include "nsIWebBrowserChrome.h" #include "nsIDocShell.h" +#include "mozilla/net/NeckoMessageUtils.h" #if defined(ANDROID) || defined(LINUX) #include "nsSystemInfo.h" diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 20510fc8898c..bba78399a77b 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -69,6 +69,7 @@ #include "JavaScriptChild.h" #include "APZCCallbackHelper.h" #include "nsILoadContext.h" +#include "ipc/nsGUIEventIPC.h" #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 87ea2f4a3cb8..cdfbc6271768 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -35,6 +35,7 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/TabContext.h" #include "mozilla/EventForwards.h" +#include "mozilla/layers/CompositorTypes.h" struct gfxMatrix; class nsICachedFileDescriptorListener; @@ -45,10 +46,6 @@ namespace layout { class RenderFrameChild; } -namespace layers { -struct TextureFactoryIdentifier; -} - namespace dom { class TabChild; diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index ecdbf899a543..bfbc9644ebc8 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -22,7 +22,9 @@ struct gfxMatrix; class nsFrameLoader; +class nsIContent; class nsIURI; +class nsIWidget; class CpowHolder; namespace mozilla { diff --git a/dom/media/MediaPermissionGonk.cpp b/dom/media/MediaPermissionGonk.cpp index 3f14f2efc3aa..a4f18ed0ae6b 100644 --- a/dom/media/MediaPermissionGonk.cpp +++ b/dom/media/MediaPermissionGonk.cpp @@ -20,6 +20,7 @@ #include "mozilla/dom/MediaStreamTrackBinding.h" #include "nsISupportsPrimitives.h" #include "nsServiceManagerUtils.h" +#include "mozilla/dom/PermissionMessageUtils.h" #define AUDIO_PERMISSION_NAME "audio-capture" diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h index 0cb69fd9c49b..e65f678e623f 100644 --- a/dom/plugins/ipc/PluginModuleChild.h +++ b/dom/plugins/ipc/PluginModuleChild.h @@ -31,6 +31,7 @@ #include "mozilla/plugins/PPluginModuleChild.h" #include "mozilla/plugins/PluginInstanceChild.h" #include "mozilla/plugins/PluginIdentifierChild.h" +#include "mozilla/plugins/PluginMessageUtils.h" // NOTE: stolen from nsNPAPIPlugin.h diff --git a/dom/plugins/ipc/PluginModuleParent.h b/dom/plugins/ipc/PluginModuleParent.h index 040b72235b63..c3c970e8bcd8 100644 --- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -13,6 +13,7 @@ #include "mozilla/plugins/ScopedMethodFactory.h" #include "mozilla/plugins/PluginProcessParent.h" #include "mozilla/plugins/PPluginModuleParent.h" +#include "mozilla/plugins/PluginMessageUtils.h" #include "npapi.h" #include "npfunctions.h" #include "nsAutoPtr.h" diff --git a/dom/plugins/ipc/PluginScriptableObjectChild.h b/dom/plugins/ipc/PluginScriptableObjectChild.h index 5c23aa8525b9..f92e8b035d50 100644 --- a/dom/plugins/ipc/PluginScriptableObjectChild.h +++ b/dom/plugins/ipc/PluginScriptableObjectChild.h @@ -8,6 +8,7 @@ #define dom_plugins_PluginScriptableObjectChild_h 1 #include "mozilla/plugins/PPluginScriptableObjectChild.h" +#include "mozilla/plugins/PluginMessageUtils.h" #include "npruntime.h" diff --git a/dom/plugins/ipc/PluginScriptableObjectParent.h b/dom/plugins/ipc/PluginScriptableObjectParent.h index 75ed6feb156c..fc2cf09b9960 100644 --- a/dom/plugins/ipc/PluginScriptableObjectParent.h +++ b/dom/plugins/ipc/PluginScriptableObjectParent.h @@ -8,6 +8,7 @@ #define dom_plugins_PluginScriptableObjectParent_h 1 #include "mozilla/plugins/PPluginScriptableObjectParent.h" +#include "mozilla/plugins/PluginMessageUtils.h" #include "npfunctions.h" #include "npruntime.h" diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index f75810bafcb4..e7a7836ac2e6 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -24,6 +24,7 @@ #include "mozilla/Preferences.h" #include "mozilla/ClearOnShutdown.h" #include "PCOMContentPermissionRequestChild.h" +#include "mozilla/dom/PermissionMessageUtils.h" class nsIPrincipal; diff --git a/dom/src/notification/Notification.cpp b/dom/src/notification/Notification.cpp index c4d0c9fa6f04..7f4de6d609aa 100644 --- a/dom/src/notification/Notification.cpp +++ b/dom/src/notification/Notification.cpp @@ -23,6 +23,7 @@ #include "nsGlobalWindow.h" #include "nsDOMJSUtils.h" #include "nsIScriptSecurityManager.h" +#include "mozilla/dom/PermissionMessageUtils.h" #ifdef MOZ_B2G #include "nsIDOMDesktopNotification.h" #endif diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index a2e3fa90a798..461dc516a4e1 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -32,6 +32,7 @@ #include "nsIEffectiveTLDService.h" #include "nsPIDOMWindow.h" #include "nsIDocument.h" +#include "mozilla/net/NeckoMessageUtils.h" static nsPermissionManager *gPermissionManager = nullptr; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index be6e2510e412..dafcdc8ebe69 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -51,6 +51,7 @@ #include "mozilla/dom/TabChild.h" #include "nsRefreshDriver.h" #include "Layers.h" +#include "nsIDOMEvent.h" #include "nsContentUtils.h" #include "nsCxPusher.h" diff --git a/netwerk/cookie/CookieServiceChild.cpp b/netwerk/cookie/CookieServiceChild.cpp index 59ed33b2ae0d..40b51502781e 100644 --- a/netwerk/cookie/CookieServiceChild.cpp +++ b/netwerk/cookie/CookieServiceChild.cpp @@ -10,6 +10,7 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsNetUtil.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; diff --git a/netwerk/cookie/CookieServiceParent.cpp b/netwerk/cookie/CookieServiceParent.cpp index f12a0718a5d2..7f3887b23c2e 100644 --- a/netwerk/cookie/CookieServiceParent.cpp +++ b/netwerk/cookie/CookieServiceParent.cpp @@ -11,6 +11,7 @@ #include "nsCookieService.h" #include "nsNetUtil.h" #include "nsPrintfCString.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; using mozilla::dom::PContentParent; diff --git a/netwerk/ipc/NeckoChild.cpp b/netwerk/ipc/NeckoChild.cpp index 50abf2e78048..0ca0bec71a99 100644 --- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -19,6 +19,7 @@ #ifdef MOZ_RTSP #include "mozilla/net/RtspControllerChild.h" #endif +#include "SerializedLoadContext.h" using mozilla::dom::TCPSocketChild; using mozilla::dom::TCPServerSocketChild; diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index ca208e0eb959..d3cbf4f941a4 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -28,6 +28,7 @@ #include "nsIAppsService.h" #include "nsEscape.h" #include "RemoteOpenFileParent.h" +#include "SerializedLoadContext.h" using mozilla::dom::ContentParent; using mozilla::dom::TabParent; diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp index 38c6407684d6..8de70d392550 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.cpp +++ b/netwerk/protocol/ftp/FTPChannelChild.cpp @@ -15,6 +15,7 @@ #include "base/compiler_specific.h" #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp index f54df6788f02..a8da09f12b90 100644 --- a/netwerk/protocol/ftp/FTPChannelParent.cpp +++ b/netwerk/protocol/ftp/FTPChannelParent.cpp @@ -11,6 +11,7 @@ #include "nsFtpProtocolHandler.h" #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 78a31767c5e5..85be5e8b677a 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -21,6 +21,7 @@ #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/net/DNS.h" +#include "SerializedLoadContext.h" using namespace mozilla::dom; using namespace mozilla::ipc; diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 0fc264fd928d..45bcee52219e 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -22,6 +22,7 @@ #include "nsIApplicationCacheService.h" #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" +#include "SerializedLoadContext.h" using namespace mozilla::dom; using namespace mozilla::ipc; diff --git a/netwerk/protocol/websocket/WebSocketChannelChild.cpp b/netwerk/protocol/websocket/WebSocketChannelChild.cpp index 4bf6b1858e75..1d8262712580 100644 --- a/netwerk/protocol/websocket/WebSocketChannelChild.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelChild.cpp @@ -14,6 +14,7 @@ #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/net/ChannelEventQueue.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; diff --git a/netwerk/protocol/websocket/WebSocketChannelParent.cpp b/netwerk/protocol/websocket/WebSocketChannelParent.cpp index 51a3b2f36d12..bc70e9f1fcc3 100644 --- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp @@ -9,6 +9,7 @@ #include "nsIAuthPromptProvider.h" #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp index c30789c3807d..1c5e197f475d 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp @@ -17,6 +17,7 @@ #include "nsSerializationHelper.h" #include "nsIProgressEventSink.h" #include "mozilla/ipc/URIUtils.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp index 006aa0032a73..9e576449d3b7 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -12,6 +12,7 @@ #include "nsSerializationHelper.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/net/NeckoParent.h" +#include "SerializedLoadContext.h" using namespace mozilla::ipc; From 91725bfec2c2a08a2414624c203a1dc22315c826 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Sat, 19 Oct 2013 12:09:59 -0400 Subject: [PATCH 212/795] Bug 918651 - part 7b - fix Layers{Surfaces,Messages}.ipdlh header bootlegging; rs=ehsan LayersSurfaces.ipdlh declares itself as |using| a bunch of types that only get used in LayersMessages.ipdlh. Since intelligent include-placing recognizes that these types are not used in LayersSurfaces.h, the necessary header lines get left out of the generated LayersSurfaces.h, leading to compilation problems on some platforms. Fix this by moving the appropriate lines to LayersMessages.ipdlh. --- gfx/layers/ipc/LayersMessages.ipdlh | 5 +++++ gfx/layers/ipc/LayersSurfaces.ipdlh | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index 2ee2f72c3345..fdf0d8634f1b 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -21,8 +21,12 @@ include "mozilla/GfxMessageUtils.h"; include "ImageLayers.h"; include "mozilla/layers/CompositorTypes.h"; +using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; +using struct gfxRGBA from "gfxColor.h"; using struct gfxPoint3D from "gfxPoint3D.h"; +using class gfx3DMatrix from "gfx3DMatrix.h"; using nscoord from "nsCoord.h"; +using struct nsIntPoint from "nsPoint.h"; using struct nsRect from "nsRect.h"; using struct nsPoint from "nsPoint.h"; using class mozilla::TimeDuration from "mozilla/TimeStamp.h"; @@ -36,6 +40,7 @@ using mozilla::LayerPoint from "Units.h"; using mozilla::LayerRect from "Units.h"; using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h"; using mozilla::layers::DiagnosticTypes from "mozilla/layers/CompositorTypes.h"; +using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; namespace mozilla { namespace layers { diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index b407a14bb100..2f02a8c291c4 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -8,16 +8,11 @@ include "gfxipc/ShadowLayerUtils.h"; include "mozilla/gfx/Types.h"; include "nsRegion.h"; -using class gfx3DMatrix from "gfx3DMatrix.h"; using gfxIntSize from "nsSize.h"; using struct gfxPoint from "gfxPoint.h"; -using struct gfxRGBA from "gfxColor.h"; -using struct nsIntPoint from "nsPoint.h"; using struct nsIntRect from "nsRect.h"; using nsIntRegion from "nsRegion.h"; using struct nsIntSize from "nsSize.h"; -using mozilla::GraphicsFilterType from "mozilla/GfxMessageUtils.h"; -using struct mozilla::layers::FrameMetrics from "FrameMetrics.h"; using struct mozilla::layers::MagicGrallocBufferHandle from "gfxipc/ShadowLayerUtils.h"; using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h"; using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; From f478d39678b6403d1a59a728ca1c4d1b38cf8ff9 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 1 Oct 2013 12:55:42 -0400 Subject: [PATCH 213/795] Bug 918651 - part 7 - place includes intelligently in generated IPDL files; r=bent This is where the magic starts to happen. We move includes from the base protocol header (${NAME}.h) to the parent and child headers (${NAME}Parent.h and ${NAME}Child.h) to follow good include hygiene. For the base protocol header, we examine the set of types used by struct and union definitions to determine which headers we need to include. For parent and child headers, we forward declare what we can and include appropriate headers otherwise. For forward-declared types, we include the appropriate headers in the parent and child source files. --- ipc/ipdl/ipdl/lower.py | 85 ++++++++++++++++++++++++++++++++++++---- widget/gonk/nsWindow.cpp | 1 + 2 files changed, 79 insertions(+), 7 deletions(-) diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index 6571612b99c1..1fc762150e69 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -1419,7 +1419,37 @@ class _GenerateProtocolCode(ipdl.ast.Visitor): hf.addthing(Whitespace.NL) for inc in builtinHeaderIncludes: - self.visitCxxInclude(inc) + self.visitBuiltinCxxInclude(inc) + + # Compute the set of includes we need for declared structure/union + # classes for this protocol. + typesToIncludes = {} + for using in tu.using: + typestr = str(using.type.spec) + assert typestr not in typesToIncludes + typesToIncludes[typestr] = using.header + + aggregateTypeIncludes = set() + for su in tu.structsAndUnions: + typedeps = _ComputeTypeDeps(su.decl.type, True) + if isinstance(su, ipdl.ast.StructDecl): + for f in su.fields: + f.ipdltype.accept(typedeps) + elif isinstance(su, ipdl.ast.UnionDecl): + for c in su.components: + c.ipdltype.accept(typedeps) + + for typename in [t.fromtype.name for t in typedeps.usingTypedefs]: + if typename in typesToIncludes: + aggregateTypeIncludes.add(typesToIncludes[typename]) + + if len(aggregateTypeIncludes) != 0: + hf.addthing(Whitespace.NL) + hf.addthings([ Whitespace("// Headers for typedefs"), Whitespace.NL ]) + + for headername in sorted(iter(aggregateTypeIncludes)): + hf.addthing(CppDirective('include', '"' + headername + '"')) + ipdl.ast.Visitor.visitTranslationUnit(self, tu) if tu.filetype == 'header': self.cppIncludeHeaders.append(_ipdlhHeaderName(tu)) @@ -1446,7 +1476,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor): cf.addthings(self.structUnionDefns) - def visitCxxInclude(self, inc): + def visitBuiltinCxxInclude(self, inc): self.hdrfile.addthing(CppDirective('include', '"'+ inc.file +'"')) def visitInclude(self, inc): @@ -2456,6 +2486,10 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): self.includedActorTypedefs = [ ] self.includedActorUsings = [ ] self.protocolCxxIncludes = [ ] + self.actorForwardDecls = [ ] + self.usingDecls = [ ] + self.externalIncludes = set() + self.nonForwardDeclaredHeaders = set() def lower(self, tu, clsname, cxxHeaderFile, cxxFile): self.clsname = clsname @@ -2497,6 +2531,11 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): for inc in tu.includes: inc.accept(self) + for inc in tu.cxxIncludes: + inc.accept(self) + + for using in tu.using: + using.accept(self) # this generates the actor's full impl in self.cls tu.protocol.accept(self) @@ -2510,6 +2549,10 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): if stmt.decl.ret and stmt.decl.ret.name == 'Result': stmt.decl.ret.name = clsdecl.name +'::'+ stmt.decl.ret.name + def setToIncludes(s): + return [ CppDirective('include', '"%s"' % i) + for i in sorted(iter(s)) ] + def makeNamespace(p, file): if 0 == len(p.namespaces): return file @@ -2518,6 +2561,16 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): file.addthing(outerns) return ns + if len(self.nonForwardDeclaredHeaders) != 0: + self.hdrfile.addthings( + [ Whitespace('// Headers for things that cannot be forward declared'), + Whitespace.NL ] + + setToIncludes(self.nonForwardDeclaredHeaders) + + [ Whitespace.NL ] + ) + self.hdrfile.addthings(self.actorForwardDecls) + self.hdrfile.addthings(self.usingDecls) + hdrns = makeNamespace(self.protocol, self.hdrfile) hdrns.addstmts([ Whitespace.NL, @@ -2545,8 +2598,8 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): Whitespace.NL, CppDirective( 'include', - '"'+ _protocolHeaderName(self.protocol, self.side) +'.h"') - ]) + '"'+ _protocolHeaderName(self.protocol, self.side) +'.h"') ] + + setToIncludes(self.externalIncludes)) if self.protocol.decl.type.isToplevel(): cf.addthings([ @@ -2574,13 +2627,32 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): Whitespace.NL ]) + def visitUsingStmt(self, using): + if using.header is None: + return + + if using.canBeForwardDeclared(): + spec = using.type.spec + + self.usingDecls.extend([ + _makeForwardDeclForQClass(spec.baseid, spec.quals, + cls=using.isClass(), + struct=using.isStruct()), + Whitespace.NL + ]) + self.externalIncludes.add(using.header) + else: + self.nonForwardDeclaredHeaders.add(using.header) + + def visitCxxInclude(self, inc): + self.nonForwardDeclaredHeaders.add(inc.file) def visitInclude(self, inc): ip = inc.tu.protocol if not ip: return - self.hdrfile.addthings([ + self.actorForwardDecls.extend([ _makeForwardDeclForActor(ip.decl.type, self.side), Whitespace.NL ]) @@ -2648,8 +2720,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): friends.discard(ptype) for friend in friends: - self.hdrfile.addthings([ - Whitespace.NL, + self.actorForwardDecls.extend([ _makeForwardDeclForActor(friend, self.prettyside), Whitespace.NL ]) diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 3dd9616d000b..015717d15b9b 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -43,6 +43,7 @@ #include "BasicLayers.h" #include "libdisplay/GonkDisplay.h" #include "pixelflinger/format.h" +#include "mozilla/BasicEvents.h" #include "HwcComposer2D.h" From 28de12df7b093d10c198dbdaf4cef627ca57d114 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Wed, 16 Oct 2013 18:11:24 +0200 Subject: [PATCH 214/795] Bug 932309 - Don't null out mDoc in nsGlobalWindow::FreeInnerObjects. r=smaug. --HG-- extra : rebase_source : 21c472ff3917bc386664050e761b4297cbdfa3a9 --- dom/base/nsGlobalWindow.cpp | 19 +++++++++++-------- dom/base/nsPIDOMWindow.h | 9 +++++++++ dom/gamepad/GamepadService.cpp | 7 ++++--- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 79e3c69f010a..0a64e0acf89c 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1509,7 +1509,6 @@ nsGlobalWindow::FreeInnerObjects() } // Remove our reference to the document and the document principal. - mDoc = nullptr; mFocusedNode = nullptr; if (mApplicationCache) { @@ -8911,6 +8910,9 @@ NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsGlobalWindow) NS_IMETHODIMP nsGlobalWindow::DispatchEvent(nsIDOMEvent* aEvent, bool* aRetVal) { + MOZ_ASSERT(!IsInnerWindow() || IsCurrentInnerWindow(), + "We should only fire events on the current inner window."); + FORWARD_TO_INNER(DispatchEvent, (aEvent, aRetVal), NS_OK); if (!mDoc) { @@ -9040,10 +9042,7 @@ nsIScriptContext* nsGlobalWindow::GetContextForEventHandlers(nsresult* aRv) { *aRv = NS_ERROR_UNEXPECTED; - if (IsInnerWindow()) { - nsPIDOMWindow* outer = GetOuterWindow(); - NS_ENSURE_TRUE(outer && outer->GetCurrentInnerWindow() == this, nullptr); - } + NS_ENSURE_TRUE(!IsInnerWindow() || IsCurrentInnerWindow(), nullptr); nsIScriptContext* scx; if ((scx = GetContext())) { @@ -10699,7 +10698,7 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, // need to fire only one idle event while the window is frozen. mNotifyIdleObserversIdleOnThaw = true; mNotifyIdleObserversActiveOnThaw = false; - } else if (mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this) { + } else if (IsCurrentInnerWindow()) { HandleIdleActiveEvent(); } return NS_OK; @@ -10710,13 +10709,17 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, if (IsFrozen()) { mNotifyIdleObserversActiveOnThaw = true; mNotifyIdleObserversIdleOnThaw = false; - } else if (mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this) { + } else if (IsCurrentInnerWindow()) { ScheduleActiveTimerCallback(); } return NS_OK; } - if (IsInnerWindow() && !nsCRT::strcmp(aTopic, "dom-storage2-changed")) { + if (!nsCRT::strcmp(aTopic, "dom-storage2-changed")) { + if (!IsInnerWindow() || !IsCurrentInnerWindow()) { + return NS_OK; + } + nsIPrincipal *principal; nsresult rv; diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 45f524d779fa..78914a8ad342 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -327,6 +327,15 @@ public: return mIsInnerWindow; } + // Returns true if this object has an outer window and it is the current inner + // window of that outer. Only call this on inner windows. + bool IsCurrentInnerWindow() const + { + MOZ_ASSERT(IsInnerWindow(), + "It doesn't make sense to call this on outer windows."); + return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this; + } + bool IsOuterWindow() const { return !IsInnerWindow(); diff --git a/dom/gamepad/GamepadService.cpp b/dom/gamepad/GamepadService.cpp index ba118b3d09a0..879b6b3cedfe 100644 --- a/dom/gamepad/GamepadService.cpp +++ b/dom/gamepad/GamepadService.cpp @@ -209,7 +209,7 @@ GamepadService::NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, --i; // Only send events to non-background windows - if (!listeners[i]->GetOuterWindow() || + if (!listeners[i]->IsCurrentInnerWindow() || listeners[i]->GetOuterWindow()->IsBackground()) { continue; } @@ -274,7 +274,7 @@ GamepadService::NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue) --i; // Only send events to non-background windows - if (!listeners[i]->GetOuterWindow() || + if (!listeners[i]->IsCurrentInnerWindow() || listeners[i]->GetOuterWindow()->IsBackground()) { continue; } @@ -340,7 +340,7 @@ GamepadService::NewConnectionEvent(uint32_t aIndex, bool aConnected) --i; // Only send events to non-background windows - if (!listeners[i]->GetOuterWindow() || + if (!listeners[i]->IsCurrentInnerWindow() || listeners[i]->GetOuterWindow()->IsBackground()) { continue; } @@ -525,6 +525,7 @@ GamepadServiceTest::CreateService() GamepadServiceTest::GamepadServiceTest() { /* member initializers and constructor code */ + nsRefPtr service = GamepadService::GetService(); } /* uint32_t addGamepad (in string id, in unsigned long mapping, in unsigned long numButtons, in unsigned long numAxes); */ From 4c6a6456d7cc7e50f54d8ae9dfc9367acebec10f Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Fri, 1 Nov 2013 14:31:00 +0100 Subject: [PATCH 215/795] Bug 932309 - Don't null out mDoc in nsGlobalWindow::FreeInnerObjects, additional fixes. r=smaug. --HG-- extra : rebase_source : 71604344bd4d50dbce7d1364ab2d88f0ee5d2175 --- dom/base/nsGlobalWindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 0a64e0acf89c..0f3663f229ec 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -9562,7 +9562,7 @@ nsGlobalWindow::FireHashchange(const nsAString &aOldURL, return NS_OK; // Get a presentation shell for use in creating the hashchange event. - NS_ENSURE_STATE(mDoc); + NS_ENSURE_STATE(IsCurrentInnerWindow()); nsIPresShell *shell = mDoc->GetShell(); nsRefPtr presContext; @@ -10119,7 +10119,7 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink) void nsGlobalWindow::FireOfflineStatusEvent() { - if (!mDoc) + if (!IsCurrentInnerWindow()) return; nsAutoString name; if (NS_IsOffline()) { @@ -10841,6 +10841,11 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic, #ifdef MOZ_B2G if (!nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC) || !nsCRT::strcmp(aTopic, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC)) { + MOZ_ASSERT(IsInnerWindow()); + if (!IsCurrentInnerWindow()) { + return NS_OK; + } + nsCOMPtr event; NS_NewDOMEvent(getter_AddRefs(event), this, nullptr, nullptr); nsresult rv = event->InitEvent( From 395356226a862adde03ebb6b24ebb479ac3091d8 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Tue, 8 Oct 2013 18:18:40 +0200 Subject: [PATCH 216/795] Bug 932322 - Make Window's WebIDL properties be own properties of window. r=bz. --HG-- extra : rebase_source : b8ce4fedf7fc46b14a1d01663945d1b0e22bdcdd --- content/base/public/nsIDocument.h | 3 - content/base/src/nsDocument.cpp | 51 -------- .../forms/test_restore_form_elements.html | 6 +- dom/base/nsDOMClassInfo.cpp | 118 ++++++------------ dom/base/nsDOMClassInfo.h | 53 +------- dom/bindings/BindingUtils.cpp | 16 ++- dom/bindings/BindingUtils.h | 7 +- .../test_window-properties.html.json | 102 +++++++++++++++ .../test_window-properties.html | 21 ++-- dom/tests/mochitest/bugs/test_bug684544.html | 14 ++- .../mochitest/general/file_interfaces.xml | 2 +- .../mochitest/general/test_interfaces.html | 21 +++- .../js1_5/LexicalConventions/lexical-001.js | 50 ++++---- .../tests/js1_5/extensions/regress-406572.js | 16 +-- js/xpconnect/src/XPCQuickStubs.cpp | 2 +- .../tests/mochitest/test_bug691059.html | 1 - 16 files changed, 232 insertions(+), 251 deletions(-) diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index f0e579723d73..dfa6afdd1e12 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -2171,9 +2171,6 @@ public: virtual nsHTMLDocument* AsHTMLDocument() { return nullptr; } - virtual JSObject* WrapObject(JSContext *aCx, - JS::Handle aScope) MOZ_OVERRIDE; - private: uint64_t mWarnedAbout; SelectorCache mSelectorCache; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 6a4d68ff9369..d4e7f1e0d9dc 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -11329,57 +11329,6 @@ nsDocument::Evaluate(const nsAString& aExpression, nsIDOMNode* aContextNode, aInResult, aResult); } -// This is just a hack around the fact that window.document is not -// [Unforgeable] yet. -JSObject* -nsIDocument::WrapObject(JSContext *aCx, JS::Handle aScope) -{ - MOZ_ASSERT(IsDOMBinding()); - - JS::Rooted obj(aCx, nsINode::WrapObject(aCx, aScope)); - if (!obj) { - return nullptr; - } - - nsCOMPtr win = do_QueryInterface(GetInnerWindow()); - if (!win) { - // No window, nothing else to do here - return obj; - } - - if (this != win->GetExtantDoc()) { - // We're not the current document; we're also done here - return obj; - } - - JSAutoCompartment ac(aCx, obj); - - JS::Rooted winVal(aCx); - nsCOMPtr holder; - nsresult rv = nsContentUtils::WrapNative(aCx, obj, win, - &NS_GET_IID(nsIDOMWindow), - &winVal, - getter_AddRefs(holder), - false); - if (NS_FAILED(rv)) { - Throw(aCx, rv); - return nullptr; - } - - NS_NAMED_LITERAL_STRING(doc_str, "document"); - - if (!JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(winVal), - reinterpret_cast - (doc_str.get()), - doc_str.Length(), JS::ObjectValue(*obj), - JS_PropertyStub, JS_StrictPropertyStub, - JSPROP_READONLY | JSPROP_ENUMERATE)) { - return nullptr; - } - - return obj; -} - XPathEvaluator* nsIDocument::XPathEvaluator() { diff --git a/content/html/content/test/forms/test_restore_form_elements.html b/content/html/content/test/forms/test_restore_form_elements.html index 8474e48ca45e..786887ebf5b7 100644 --- a/content/html/content/test/forms/test_restore_form_elements.html +++ b/content/html/content/test/forms/test_restore_form_elements.html @@ -62,8 +62,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=737851
       
-        
-        
+  
+  
+  
 
 
   
diff --git a/toolkit/content/tests/widgets/test_menubar.xul b/toolkit/content/tests/widgets/test_menubar.xul
index faccd94f0851..7aa15fb2ac3d 100644
--- a/toolkit/content/tests/widgets/test_menubar.xul
+++ b/toolkit/content/tests/widgets/test_menubar.xul
@@ -8,7 +8,7 @@
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   Menubar Popup Tests
-        
+  
 
       
-
-
-
-
-

-

- -
-
- - - diff --git a/toolkit/content/tests/widgets/test_popupanchor.xul b/toolkit/content/tests/widgets/test_popupanchor.xul index b255c06ba8b2..9ad60e28786d 100644 --- a/toolkit/content/tests/widgets/test_popupanchor.xul +++ b/toolkit/content/tests/widgets/test_popupanchor.xul @@ -13,7 +13,7 @@ noautohide="true"> - + - + + + + + Test for Bug 933193 + + + + +Mozilla Bug 933193 +

+ +
+
+ + + diff --git a/content/svg/content/src/SVGSVGElement.h b/content/svg/content/src/SVGSVGElement.h index 6e02d22971e8..f44ecbc49ce9 100644 --- a/content/svg/content/src/SVGSVGElement.h +++ b/content/svg/content/src/SVGSVGElement.h @@ -246,7 +246,6 @@ public: already_AddRefed CreateSVGRect(); already_AddRefed CreateSVGTransform(); already_AddRefed CreateSVGTransformFromMatrix(SVGMatrix& matrix); - using nsINode::GetElementById; // This does what we want already_AddRefed ViewBox(); already_AddRefed PreserveAspectRatio(); uint16_t ZoomAndPan(); diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index 1520239d0e33..616d1fbce786 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -38,7 +38,6 @@ interface Document : Node { HTMLCollection getElementsByTagName(DOMString localName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString classNames); - Element? getElementById(DOMString elementId); [NewObject, Throws] Element createElement(DOMString localName); diff --git a/dom/webidl/ParentNode.webidl b/dom/webidl/ParentNode.webidl index da08b7497566..b2a8c86ad798 100644 --- a/dom/webidl/ParentNode.webidl +++ b/dom/webidl/ParentNode.webidl @@ -21,4 +21,6 @@ interface ParentNode { // Not implemented yet // void prepend((Node or DOMString)... nodes); // void append((Node or DOMString)... nodes); + + Element? getElementById(DOMString elementId); }; diff --git a/dom/webidl/SVGSVGElement.webidl b/dom/webidl/SVGSVGElement.webidl index 583f3eeb0a8d..98b6e495c883 100644 --- a/dom/webidl/SVGSVGElement.webidl +++ b/dom/webidl/SVGSVGElement.webidl @@ -59,7 +59,6 @@ interface SVGSVGElement : SVGGraphicsElement { SVGTransform createSVGTransform(); [NewObject] SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix); - Element? getElementById(DOMString elementId); }; /*SVGSVGElement implements ViewCSS; From 37ee9de83c1115ffdc1292499c57d83013addc7c Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Fri, 1 Nov 2013 20:44:05 +0100 Subject: [PATCH 243/795] Bug 933810 - Really remove JS_ValueToECMAUint32. r=terrence f=mccr8 --- ipc/testshell/XPCShellEnvironment.cpp | 101 +------------- js/src/builtin/TestingFunctions.cpp | 103 ++++++++------- js/src/jsapi.cpp | 10 +- js/src/jsapi.h | 14 -- js/src/shell/js.cpp | 153 +++++++++------------- js/src/vm/Debugger.cpp | 2 +- js/xpconnect/src/XPCComponents.cpp | 5 +- js/xpconnect/src/XPCShellImpl.cpp | 96 +------------- js/xpconnect/src/dictionary_helper_gen.py | 4 +- js/xpconnect/src/qsgen.py | 6 +- 10 files changed, 127 insertions(+), 367 deletions(-) diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index f54901c3dd3e..dc23b492d176 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -258,14 +258,12 @@ GC(JSContext *cx, #ifdef JS_GC_ZEAL static bool -GCZeal(JSContext *cx, - unsigned argc, - JS::Value *vp) +GCZeal(JSContext *cx, unsigned argc, JS::Value *vp) { - JS::Value* argv = JS_ARGV(cx, vp); + CallArgs args = CallArgsFromVp(argc, vp); uint32_t zeal; - if (!JS_ValueToECMAUint32(cx, argv[0], &zeal)) + if (!ToUint32(cx, args.get(0), &zeal)) return false; JS_SetGCZeal(cx, uint8_t(zeal), JS_DEFAULT_ZEAL_FREQ); @@ -273,96 +271,6 @@ GCZeal(JSContext *cx, } #endif -#ifdef DEBUG - -static bool -DumpHeap(JSContext *cx, - unsigned argc, - JS::Value *vp) -{ - JSAutoByteString fileName; - void* startThing = nullptr; - JSGCTraceKind startTraceKind = JSTRACE_OBJECT; - void *thingToFind = nullptr; - size_t maxDepth = (size_t)-1; - void *thingToIgnore = nullptr; - FILE *dumpFile; - bool ok; - - JS::Value *argv = JS_ARGV(cx, vp); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - - vp = argv + 0; - if (argc > 0 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - JSString *str; - - str = JS_ValueToString(cx, *vp); - if (!str) - return false; - *vp = STRING_TO_JSVAL(str); - if (!fileName.encodeLatin1(cx, str)) - return false; - } - - vp = argv + 1; - if (argc > 1 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - if (!JSVAL_IS_TRACEABLE(*vp)) - goto not_traceable_arg; - startThing = JSVAL_TO_TRACEABLE(*vp); - startTraceKind = JSVAL_TRACE_KIND(*vp); - } - - vp = argv + 2; - if (argc > 2 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - if (!JSVAL_IS_TRACEABLE(*vp)) - goto not_traceable_arg; - thingToFind = JSVAL_TO_TRACEABLE(*vp); - } - - vp = argv + 3; - if (argc > 3 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - uint32_t depth; - - if (!JS_ValueToECMAUint32(cx, *vp, &depth)) - return false; - maxDepth = depth; - } - - vp = argv + 4; - if (argc > 4 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - if (!JSVAL_IS_TRACEABLE(*vp)) - goto not_traceable_arg; - thingToIgnore = JSVAL_TO_TRACEABLE(*vp); - } - - if (!fileName) { - dumpFile = stdout; - } else { - dumpFile = fopen(fileName.ptr(), "w"); - if (!dumpFile) { - fprintf(stderr, "dumpHeap: can't open %s: %s\n", - fileName.ptr(), strerror(errno)); - return false; - } - } - - ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, startThing, startTraceKind, thingToFind, - maxDepth, thingToIgnore); - if (dumpFile != stdout) - fclose(dumpFile); - if (!ok) - JS_ReportOutOfMemory(cx); - return ok; - - not_traceable_arg: - fprintf(stderr, - "dumpHeap: argument %u is not null or a heap-allocated thing\n", - (unsigned)(vp - argv)); - return false; -} - -#endif /* DEBUG */ - const JSFunctionSpec gGlobalFunctions[] = { JS_FS("print", Print, 0,0), @@ -375,9 +283,6 @@ const JSFunctionSpec gGlobalFunctions[] = JS_FS("gc", GC, 0,0), #ifdef JS_GC_ZEAL JS_FS("gczeal", GCZeal, 1,0), - #endif - #ifdef DEBUG - JS_FS("dumpHeap", DumpHeap, 5,0), #endif JS_FS_END }; diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 93d4eda0f190..4d843be66242 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -269,18 +269,13 @@ static const struct ParamPair { }; static bool -GCParameter(JSContext *cx, unsigned argc, jsval *vp) +GCParameter(JSContext *cx, unsigned argc, Value *vp) { - JSString *str; - if (argc == 0) { - str = JS_ValueToString(cx, JSVAL_VOID); - JS_ASSERT(str); - } else { - str = JS_ValueToString(cx, vp[2]); - if (!str) - return false; - vp[2] = STRING_TO_JSVAL(str); - } + CallArgs args = CallArgsFromVp(argc, vp); + + JSString *str = JS_ValueToString(cx, args.get(0)); + if (!str) + return false; JSFlatString *flatStr = JS_FlattenString(cx, str); if (!flatStr) @@ -300,24 +295,23 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp) } JSGCParamKey param = paramMap[paramIndex].param; - if (argc == 1) { + // Request mode. + if (args.length() == 1) { uint32_t value = JS_GetGCParameter(cx->runtime(), param); - vp[0] = JS_NumberValue(value); + args.rval().setNumber(value); return true; } - if (param == JSGC_NUMBER || - param == JSGC_BYTES) { + if (param == JSGC_NUMBER || param == JSGC_BYTES) { JS_ReportError(cx, "Attempt to change read-only parameter %s", paramMap[paramIndex].name); return false; } uint32_t value; - if (!JS_ValueToECMAUint32(cx, vp[3], &value)) { - JS_ReportError(cx, - "the second argument must be convertable to uint32_t " - "with non-zero value"); + if (!ToUint32(cx, args[1], &value)) { + JS_ReportError(cx, "the second argument must be convertable to uint32_t " + "with non-zero value"); return false; } @@ -333,12 +327,12 @@ GCParameter(JSContext *cx, unsigned argc, jsval *vp) } JS_SetGCParameter(cx->runtime(), param, value); - *vp = JSVAL_VOID; + args.rval().setUndefined(); return true; } static bool -IsProxy(JSContext *cx, unsigned argc, jsval *vp) +IsProxy(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); if (argc != 1) { @@ -396,29 +390,33 @@ GCPreserveCode(JSContext *cx, unsigned argc, jsval *vp) #ifdef JS_GC_ZEAL static bool -GCZeal(JSContext *cx, unsigned argc, jsval *vp) +GCZeal(JSContext *cx, unsigned argc, Value *vp) { - uint32_t zeal, frequency = JS_DEFAULT_ZEAL_FREQ; CallArgs args = CallArgsFromVp(argc, vp); - if (argc > 2) { + if (args.length() > 2) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Too many arguments"); return false; } - if (!JS_ValueToECMAUint32(cx, argc < 1 ? JSVAL_VOID : args[0], &zeal)) + + uint32_t zeal; + if (!ToUint32(cx, args.get(0), &zeal)) return false; - if (argc >= 2) - if (!JS_ValueToECMAUint32(cx, args[1], &frequency)) + + uint32_t frequency = JS_DEFAULT_ZEAL_FREQ; + if (args.length() >= 2) { + if (!ToUint32(cx, args.get(1), &frequency)) return false; + } JS_SetGCZeal(cx, (uint8_t)zeal, frequency); - *vp = JSVAL_VOID; + args.rval().setUndefined(); return true; } static bool -ScheduleGC(JSContext *cx, unsigned argc, jsval *vp) +ScheduleGC(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -440,24 +438,24 @@ ScheduleGC(JSContext *cx, unsigned argc, jsval *vp) PrepareZoneForGC(args[0].toString()->zone()); } - *vp = JSVAL_VOID; + args.rval().setUndefined(); return true; } static bool -SelectForGC(JSContext *cx, unsigned argc, jsval *vp) +SelectForGC(JSContext *cx, unsigned argc, Value *vp) { - JSRuntime *rt = cx->runtime(); + CallArgs args = CallArgsFromVp(argc, vp); - for (unsigned i = 0; i < argc; i++) { - Value arg(JS_ARGV(cx, vp)[i]); - if (arg.isObject()) { - if (!rt->gcSelectedForMarking.append(&arg.toObject())) + JSRuntime *rt = cx->runtime(); + for (unsigned i = 0; i < args.length(); i++) { + if (args[i].isObject()) { + if (!rt->gcSelectedForMarking.append(&args[i].toObject())) return false; } } - *vp = JSVAL_VOID; + args.rval().setUndefined(); return true; } @@ -466,13 +464,14 @@ VerifyPreBarriers(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc) { + if (args.length() > 0) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Too many arguments"); return false; } + gc::VerifyBarriers(cx->runtime(), gc::PreBarrierVerifier); - *vp = JSVAL_VOID; + args.rval().setUndefined(); return true; } @@ -536,27 +535,27 @@ DeterministicGC(JSContext *cx, unsigned argc, jsval *vp) #endif /* JS_GC_ZEAL */ static bool -GCSlice(JSContext *cx, unsigned argc, jsval *vp) +GCSlice(JSContext *cx, unsigned argc, Value *vp) { - bool limit = true; - uint32_t budget = 0; CallArgs args = CallArgsFromVp(argc, vp); - if (argc > 1) { + if (args.length() > 1) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Wrong number of arguments"); return false; } - if (argc == 1) { - if (!JS_ValueToECMAUint32(cx, args[0], &budget)) + bool limit = true; + uint32_t budget = 0; + if (args.length() == 1) { + if (!ToUint32(cx, args[0], &budget)) return false; } else { limit = false; } GCDebugSlice(cx->runtime(), limit, budget); - *vp = JSVAL_VOID; + args.rval().setUndefined(); return true; } @@ -565,14 +564,14 @@ ValidateGC(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Wrong number of arguments"); return false; } - gc::SetValidateGC(cx, ToBoolean(vp[2])); - *vp = JSVAL_VOID; + gc::SetValidateGC(cx, ToBoolean(args[0])); + args.rval().setUndefined(); return true; } @@ -581,14 +580,14 @@ FullCompartmentChecks(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Wrong number of arguments"); return false; } - gc::SetFullCompartmentChecks(cx, ToBoolean(vp[2])); - *vp = JSVAL_VOID; + gc::SetFullCompartmentChecks(cx, ToBoolean(args[0])); + args.rval().setUndefined(); return true; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index dfd02bbde3ea..58bc29875988 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -253,7 +253,7 @@ JS_ConvertArgumentsVA(JSContext *cx, unsigned argc, jsval *argv, const char *for return false; break; case 'u': - if (!JS_ValueToECMAUint32(cx, *sp, va_arg(ap, uint32_t *))) + if (!ToUint32(cx, arg, va_arg(ap, uint32_t *))) return false; break; case 'j': @@ -447,14 +447,6 @@ JS_DoubleToUint32(double d) return ToUint32(d); } - -JS_PUBLIC_API(bool) -JS_ValueToECMAUint32(JSContext *cx, jsval valueArg, uint32_t *ip) -{ - RootedValue value(cx, valueArg); - return JS::ToUint32(cx, value, ip); -} - JS_PUBLIC_API(bool) JS_ValueToInt64(JSContext *cx, jsval valueArg, int64_t *ip) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 44aa58332109..74fea08e0b87 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -1107,13 +1107,6 @@ JS_DoubleToInt32(double d); extern JS_PUBLIC_API(uint32_t) JS_DoubleToUint32(double d); -/* - * Convert a value to a number, then to an int32_t, according to the ECMA rules - * for ToInt32. - */ -extern JS_PUBLIC_API(bool) -JS_ValueToECMAInt32(JSContext *cx, jsval v, int32_t *ip); - /* * Convert a value to a number, then to an int64_t, according to the WebIDL * rules for ToInt64: http://dev.w3.org/2006/webapi/WebIDL/#es-long-long @@ -1223,13 +1216,6 @@ ToUint64(JSContext *cx, JS::Handle v, uint64_t *out) } /* namespace JS */ -/* - * Convert a value to a number, then to a uint32_t, according to the ECMA rules - * for ToUint32. - */ -extern JS_PUBLIC_API(bool) -JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32_t *ip); - /* * Convert a value to a number, then to an int32_t if it fits by rounding to * nearest; but failing with an error report if the double is out of range diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 799146b7c303..e754546d9293 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -978,7 +978,7 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp) return false; if (!JSVAL_IS_VOID(v)) { uint32_t u; - if (!JS_ValueToECMAUint32(cx, v, &u)) + if (!ToUint32(cx, v, &u)) return false; lineNumber = u; } @@ -1663,28 +1663,26 @@ static bool LineToPC(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - RootedScript script(cx); - int32_t lineArg = 0; - uint32_t lineno; - jsbytecode *pc; if (args.length() == 0) { JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_LINE2PC_USAGE); return false; } - script = GetTopScript(cx); - jsval v = args[0]; - if (!JSVAL_IS_PRIMITIVE(v) && - JS_GetClass(&v.toObject()) == Jsvalify(&JSFunction::class_)) - { - script = ValueToScript(cx, v); + + RootedScript script(cx, GetTopScript(cx)); + int32_t lineArg = 0; + if (args[0].isObject() && args[0].toObject().is()) { + script = ValueToScript(cx, args[0]); if (!script) return false; lineArg++; } - if (!JS_ValueToECMAUint32(cx, args[lineArg], &lineno)) - return false; - pc = JS_LineNumberToPC(cx, script, lineno); + + uint32_t lineno; + if (!ToUint32(cx, args.get(lineArg), &lineno)) + return false; + + jsbytecode *pc = JS_LineNumberToPC(cx, script, lineno); if (!pc) return false; args.rval().setInt32(pc - script->code); @@ -2190,107 +2188,76 @@ DumpHeap(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - jsval v; - void* startThing; - JSGCTraceKind startTraceKind; - const char *badTraceArg; - void *thingToFind; - size_t maxDepth; - void *thingToIgnore; - FILE *dumpFile; - bool ok; + JSAutoByteString fileName; + if (args.hasDefined(0)) { + RootedString str(cx, JS_ValueToString(cx, args[0])); + if (!str) + return false; - const char *fileName = nullptr; - JSAutoByteString fileNameBytes; - if (args.length() > 0) { - v = args[0]; - if (!v.isNull()) { - JSString *str; - - str = JS_ValueToString(cx, v); - if (!str) - return false; - args[0].setString(str); - if (!fileNameBytes.encodeLatin1(cx, str)) - return false; - fileName = fileNameBytes.ptr(); - } + if (!fileName.encodeLatin1(cx, str)) + return false; } - // Grab the depth param first, because JS_ValueToECMAUint32 can GC, and - // there's no easy way to root the traceable void* parameters below. - maxDepth = (size_t)-1; - if (args.length() > 3) { - v = args[3]; - if (!v.isNull()) { - uint32_t depth; - - if (!JS_ValueToECMAUint32(cx, v, &depth)) - return false; - maxDepth = depth; + RootedValue startThing(cx); + if (args.hasDefined(1)) { + if (!args[1].isGCThing()) { + JS_ReportError(cx, "dumpHeap: Second argument not a GC thing!"); + return false; } + startThing = args[1]; } - startThing = nullptr; - startTraceKind = JSTRACE_OBJECT; - if (args.length() > 1) { - v = args[1]; - if (v.isMarkable()) { - startThing = JSVAL_TO_TRACEABLE(v); - startTraceKind = v.gcKind(); - } else if (!v.isNull()) { - badTraceArg = "start"; - goto not_traceable_arg; + RootedValue thingToFind(cx); + if (args.hasDefined(2)) { + if (!args[2].isGCThing()) { + JS_ReportError(cx, "dumpHeap: Third argument not a GC thing!"); + return false; } + thingToFind = args[2]; } - thingToFind = nullptr; - if (args.length() > 2) { - v = args[2]; - if (v.isMarkable()) { - thingToFind = JSVAL_TO_TRACEABLE(v); - } else if (!v.isNull()) { - badTraceArg = "toFind"; - goto not_traceable_arg; - } + size_t maxDepth = size_t(-1); + if (args.hasDefined(3)) { + uint32_t depth; + if (!ToUint32(cx, args[3], &depth)) + return false; + maxDepth = depth; } - thingToIgnore = nullptr; - if (args.length() > 4) { - v = args[4]; - if (v.isMarkable()) { - thingToIgnore = JSVAL_TO_TRACEABLE(v); - } else if (!v.isNull()) { - badTraceArg = "toIgnore"; - goto not_traceable_arg; + RootedValue thingToIgnore(cx); + if (args.hasDefined(4)) { + if (!args[2].isGCThing()) { + JS_ReportError(cx, "dumpHeap: Fifth argument not a GC thing!"); + return false; } + thingToIgnore = args[4]; } - if (!fileName) { - dumpFile = stdout; - } else { - dumpFile = fopen(fileName, "w"); + + FILE *dumpFile = stdout; + if (fileName.length()) { + dumpFile = fopen(fileName.ptr(), "w"); if (!dumpFile) { - JS_ReportError(cx, "can't open %s: %s", fileName, strerror(errno)); + JS_ReportError(cx, "dumpHeap: can't open %s: %s\n", + fileName.ptr(), strerror(errno)); return false; } } - ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, startThing, startTraceKind, thingToFind, - maxDepth, thingToIgnore); + bool ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, + startThing.isUndefined() ? nullptr : startThing.toGCThing(), + startThing.isUndefined() ? JSTRACE_OBJECT : startThing.get().gcKind(), + thingToFind.isUndefined() ? nullptr : thingToFind.toGCThing(), + maxDepth, + thingToIgnore.isUndefined() ? nullptr : thingToIgnore.toGCThing()); + if (dumpFile != stdout) fclose(dumpFile); - if (!ok) { - JS_ReportOutOfMemory(cx); - return false; - } - args.rval().setUndefined(); - return true; - not_traceable_arg: - JS_ReportError(cx, "argument '%s' is not null or a heap-allocated thing", - badTraceArg); - return false; + if (!ok) + JS_ReportOutOfMemory(cx); + + return ok; } static bool diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 1a2489a243fc..c88cba6a204d 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -4305,7 +4305,7 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName, const Value &code return false; if (!v.isUndefined()) { uint32_t lineno; - if (!JS_ValueToECMAUint32(cx, v, &lineno)) + if (!ToUint32(cx, v, &lineno)) return false; lineNumber = lineno; } diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 58e942b76f32..885c18732a37 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -1845,7 +1845,7 @@ struct MOZ_STACK_CLASS ExceptionArgParser } bool parseResult(HandleValue v) { - return JS_ValueToECMAUint32(cx, v, (uint32_t*) &eResult); + return JS::ToUint32(cx, v, (uint32_t*) &eResult); } bool parseStack(HandleValue v) { @@ -3687,8 +3687,9 @@ nsXPCComponents::SetProperty(nsIXPConnectWrappedNative *wrapper, return NS_ERROR_FAILURE; if (id == rt->GetStringID(XPCJSRuntime::IDX_RETURN_CODE)) { + RootedValue v(cx, *vp); nsresult rv; - if (JS_ValueToECMAUint32(cx, *vp, (uint32_t*)&rv)) { + if (ToUint32(cx, v, (uint32_t*)&rv)) { xpcc->SetPendingResult(rv); xpcc->SetLastResult(rv); return NS_SUCCESS_I_DID_SOMETHING; diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index fae6186572c3..4f343ab3c690 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -417,104 +417,17 @@ GC(JSContext *cx, unsigned argc, jsval *vp) static bool GCZeal(JSContext *cx, unsigned argc, jsval *vp) { + CallArgs args = CallArgsFromVp(argc, vp); uint32_t zeal; - if (!JS_ValueToECMAUint32(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID, &zeal)) + if (!ToUint32(cx, args.get(0), &zeal)) return false; JS_SetGCZeal(cx, uint8_t(zeal), JS_DEFAULT_ZEAL_FREQ); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + args.rval().setUndefined(); return true; } #endif -#ifdef DEBUG - -static bool -DumpHeap(JSContext *cx, unsigned argc, jsval *vp) -{ - void* startThing = nullptr; - JSGCTraceKind startTraceKind = JSTRACE_OBJECT; - void *thingToFind = nullptr; - size_t maxDepth = (size_t)-1; - void *thingToIgnore = nullptr; - FILE *dumpFile; - bool ok; - - jsval *argv = JS_ARGV(cx, vp); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - - vp = argv + 0; - JSAutoByteString fileName; - if (argc > 0 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - JSString *str; - - str = JS_ValueToString(cx, *vp); - if (!str) - return false; - *vp = STRING_TO_JSVAL(str); - if (!fileName.encodeLatin1(cx, str)) - return false; - } - - vp = argv + 1; - if (argc > 1 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - if (!JSVAL_IS_TRACEABLE(*vp)) - goto not_traceable_arg; - startThing = JSVAL_TO_TRACEABLE(*vp); - startTraceKind = JSVAL_TRACE_KIND(*vp); - } - - vp = argv + 2; - if (argc > 2 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - if (!JSVAL_IS_TRACEABLE(*vp)) - goto not_traceable_arg; - thingToFind = JSVAL_TO_TRACEABLE(*vp); - } - - vp = argv + 3; - if (argc > 3 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - uint32_t depth; - - if (!JS_ValueToECMAUint32(cx, *vp, &depth)) - return false; - maxDepth = depth; - } - - vp = argv + 4; - if (argc > 4 && *vp != JSVAL_NULL && *vp != JSVAL_VOID) { - if (!JSVAL_IS_TRACEABLE(*vp)) - goto not_traceable_arg; - thingToIgnore = JSVAL_TO_TRACEABLE(*vp); - } - - if (!fileName) { - dumpFile = gOutFile; - } else { - dumpFile = fopen(fileName.ptr(), "w"); - if (!dumpFile) { - fprintf(gErrFile, "dumpHeap: can't open %s: %s\n", - fileName.ptr(), strerror(errno)); - return false; - } - } - - ok = JS_DumpHeap(JS_GetRuntime(cx), dumpFile, startThing, startTraceKind, thingToFind, - maxDepth, thingToIgnore); - if (dumpFile != gOutFile) - fclose(dumpFile); - if (!ok) - JS_ReportOutOfMemory(cx); - return ok; - - not_traceable_arg: - fprintf(gErrFile, - "dumpHeap: argument %u is not null or a heap-allocated thing\n", - (unsigned)(vp - argv)); - return false; -} - -#endif /* DEBUG */ - static bool SendCommand(JSContext* cx, unsigned argc, @@ -798,9 +711,6 @@ static const JSFunctionSpec glob_functions[] = { #endif JS_FS("options", Options, 0,0), JS_FN("parent", Parent, 1,0), -#ifdef DEBUG - JS_FS("dumpHeap", DumpHeap, 5,0), -#endif JS_FS("sendCommand", SendCommand, 1,0), JS_FS("atob", Atob, 1,0), JS_FS("btoa", Btoa, 1,0), diff --git a/js/xpconnect/src/dictionary_helper_gen.py b/js/xpconnect/src/dictionary_helper_gen.py index 6b0f777417b5..857b04e394f3 100644 --- a/js/xpconnect/src/dictionary_helper_gen.py +++ b/js/xpconnect/src/dictionary_helper_gen.py @@ -287,14 +287,14 @@ def write_getter(a, iface, fd): fd.write(" aDict.%s = b;\n" % a.name) elif realtype.count("uint16_t"): fd.write(" uint32_t u;\n") - fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &u));\n") + fd.write(" NS_ENSURE_STATE(JS::ToUint32(aCx, v, &u));\n") fd.write(" aDict.%s = u;\n" % a.name) elif realtype.count("int16_t"): fd.write(" int32_t i;\n") fd.write(" NS_ENSURE_STATE(JS::ToInt32(aCx, v, &i));\n") fd.write(" aDict.%s = i;\n" % a.name) elif realtype.count("uint32_t"): - fd.write(" NS_ENSURE_STATE(JS_ValueToECMAUint32(aCx, v, &aDict.%s));\n" % a.name) + fd.write(" NS_ENSURE_STATE(JS::ToUint32(aCx, v, &aDict.%s));\n" % a.name) elif realtype.count("int32_t"): fd.write(" NS_ENSURE_STATE(JS::ToInt32(aCx, v, &aDict.%s));\n" % a.name) elif realtype.count("uint64_t"): diff --git a/js/xpconnect/src/qsgen.py b/js/xpconnect/src/qsgen.py index 36bf36c277a8..990ba41e7cb5 100644 --- a/js/xpconnect/src/qsgen.py +++ b/js/xpconnect/src/qsgen.py @@ -385,7 +385,7 @@ def substitute(template, vals): argumentUnboxingTemplates = { 'octet': " uint32_t ${name}_u32;\n" - " if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n" + " if (!JS::ToUint32(cx, ${argVal}, &${name}_u32))\n" " return false;\n" " uint8_t ${name} = (uint8_t) ${name}_u32;\n", @@ -397,7 +397,7 @@ argumentUnboxingTemplates = { 'unsigned short': " uint32_t ${name}_u32;\n" - " if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n" + " if (!JS::ToUint32(cx, ${argVal}, &${name}_u32))\n" " return false;\n" " uint16_t ${name} = (uint16_t) ${name}_u32;\n", @@ -408,7 +408,7 @@ argumentUnboxingTemplates = { 'unsigned long': " uint32_t ${name};\n" - " if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}))\n" + " if (!JS::ToUint32(cx, ${argVal}, &${name}))\n" " return false;\n", 'long long': From 6f411f2bfd4b6c654bf55249fba69c7393dbf3cc Mon Sep 17 00:00:00 2001 From: Brian O'Keefe Date: Mon, 28 Oct 2013 10:21:29 -0400 Subject: [PATCH 244/795] Bug 870401 - Fix up the MFBT exports and the sources. r=mshal --- js/src/Makefile.in | 16 -------- js/src/configure.in | 13 +++++++ js/src/moz.build | 7 ++++ mfbt/Makefile.in | 13 ------- mfbt/common.mozbuild | 84 ++++++++++++++++++++++++++++++++++++++++ mfbt/exported_headers.mk | 61 ----------------------------- mfbt/moz.build | 3 ++ mfbt/sources.mk | 39 ------------------- 8 files changed, 107 insertions(+), 129 deletions(-) create mode 100644 mfbt/common.mozbuild delete mode 100644 mfbt/exported_headers.mk delete mode 100644 mfbt/sources.mk diff --git a/js/src/Makefile.in b/js/src/Makefile.in index c9e3acc896e5..00030759faca 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -33,13 +33,6 @@ FORCE_SHARED_LIB = 1 endif DIST_INSTALL = 1 -############################################### -# BEGIN include sources for low-level code shared with mfbt -# -MFBT_ROOT = $(srcdir)/../../mfbt -VPATH += $(MFBT_ROOT) -include $(MFBT_ROOT)/exported_headers.mk - VPATH += \ $(srcdir) \ $(srcdir)/builtin \ @@ -133,8 +126,6 @@ endif endif # JS_HAS_CTYPES -LOCAL_INCLUDES += -I$(MFBT_ROOT)/double-conversion - # PerfMeasurement is available regardless of low-level support for it; # it just doesn't necessarily do anything useful. There is one # implementation source file per supported operating system, plus a stub @@ -149,13 +140,6 @@ else SDK_LIBRARY = $(SHARED_LIBRARY) endif -ifeq (,$(MOZ_GLUE_PROGRAM_LDFLAGS)) -# When building standalone, we need to include mfbt sources, and to declare -# "exported" mfbt symbols on its behalf when we use its headers. -include $(MFBT_ROOT)/sources.mk -DEFINES += -DIMPL_MFBT -endif - EXTRA_DSO_LDOPTS += $(NSPR_LIBS) # Define keyword generator before rules.mk, see bug 323979 comment 50 diff --git a/js/src/configure.in b/js/src/configure.in index 3094c8a00629..1283b6a8cf70 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2970,6 +2970,19 @@ MOZ_ARG_HEADER(Application) ENABLE_TESTS=1 +dnl ======================================================== +dnl Tell the build system that ../../mfbt exists outside +dnl the source tree, but files from there are included from +dnl inside the tree. +dnl +dnl This should probably be a --with-external-source-dir +dnl option, like the root mozilla-central configure, but +dnl then anyone building the standalone js shell would need +dnl to remember to pass it, and it is only used in one file. +dnl ======================================================== +EXTERNAL_SOURCE_DIR=../../mfbt +AC_SUBST(EXTERNAL_SOURCE_DIR) + USE_ARM_KUSER= case "${target}" in diff --git a/js/src/moz.build b/js/src/moz.build index 46282eda107d..2a2063a535c2 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -20,8 +20,15 @@ TEST_DIRS += ['jsapi-tests', 'tests', 'gdb'] MODULE = 'js' +mfbt_root = '../../mfbt' +LOCAL_INCLUDES += ['%s/double-conversion' % mfbt_root] + if CONFIG['JS_STANDALONE']: LIBRARY_NAME = 'mozjs-%s' % CONFIG['MOZILLA_SYMBOLVERSION'] + + # When building standalone, we need to include mfbt sources, and to declare + # "exported" mfbt symbols on its behalf when we use its headers. + include('%s/common.mozbuild' % mfbt_root) else: LIBRARY_NAME = 'mozjs' diff --git a/mfbt/Makefile.in b/mfbt/Makefile.in index 34c626d324c2..ded3e30ce192 100644 --- a/mfbt/Makefile.in +++ b/mfbt/Makefile.in @@ -3,16 +3,3 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. STL_FLAGS = - -# exported_headers.mk defines the headers exported by mfbt. It is included by -# mfbt itself and by the JS engine, which, when built standalone, must do the -# work to install mfbt's exported headers itself. -include $(srcdir)/exported_headers.mk - -# sources.mk defines the source files built for mfbt. It is included by mfbt -# itself and by the JS engine, which, when built standalone, must do the work -# to build mfbt sources itself. -MFBT_ROOT = $(srcdir) -include $(MFBT_ROOT)/sources.mk - -DEFINES += -DIMPL_MFBT diff --git a/mfbt/common.mozbuild b/mfbt/common.mozbuild new file mode 100644 index 000000000000..2fa4e51d2b5e --- /dev/null +++ b/mfbt/common.mozbuild @@ -0,0 +1,84 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# This file defines the headers exported by and the sources build for mfbt. +# It is included by mfbt itself and by the JS engine, which, when built +# standalone, must install mfbt's exported headers and build mfbt sources +# itself. It expects that mfbt_root is set to the relative path to mfbt +# before this file in included. + +mfbt_headers = [ + 'Alignment.h', + 'AllocPolicy.h', + 'Array.h', + 'Assertions.h', + 'Atomics.h', + 'Attributes.h', + 'BloomFilter.h', + 'Casting.h', + 'Char16.h', + 'CheckedInt.h', + 'Compiler.h', + 'Compression.h', + 'Constants.h', + 'DebugOnly.h', + 'decimal/Decimal.h', + 'Endian.h', + 'EnumSet.h', + 'FloatingPoint.h', + 'GuardObjects.h', + 'HashFunctions.h', + 'IntegerPrintfMacros.h', + 'Likely.h', + 'LinkedList.h', + 'MathAlgorithms.h', + 'Maybe.h', + 'MemoryChecking.h', + 'MemoryReporting.h', + 'Move.h', + 'MSIntTypes.h', + 'NullPtr.h', + 'NumericLimits.h', + 'PodOperations.h', + 'Poison.h', + 'Range.h', + 'RangedPtr.h', + 'ReentrancyGuard.h', + 'RefPtr.h', + 'Scoped.h', + 'SHA1.h', + 'SplayTree.h', + 'TemplateLib.h', + 'ThreadLocal.h', + 'TypedEnum.h', + 'Types.h', + 'TypeTraits.h', + 'Util.h', + 'Vector.h', + 'WeakPtr.h', +] + +mfbt_sources = [ + 'Compression.cpp', + 'decimal/Decimal.cpp', + 'double-conversion/bignum-dtoa.cc', + 'double-conversion/bignum.cc', + 'double-conversion/cached-powers.cc', + 'double-conversion/diy-fp.cc', + 'double-conversion/double-conversion.cc', + 'double-conversion/fast-dtoa.cc', + 'double-conversion/fixed-dtoa.cc', + 'double-conversion/strtod.cc', + 'FloatingPoint.cpp', + 'HashFunctions.cpp', + 'Poison.cpp', + 'SHA1.cpp', +] + +DEFINES['IMPL_MFBT'] = True + +EXPORTS.mozilla += ['%s/%s' % (mfbt_root, header) for header in mfbt_headers] +SOURCES += ['%s/%s' % (mfbt_root, src) for src in mfbt_sources] diff --git a/mfbt/exported_headers.mk b/mfbt/exported_headers.mk deleted file mode 100644 index c814a92c36a9..000000000000 --- a/mfbt/exported_headers.mk +++ /dev/null @@ -1,61 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# This file defines the headers exported by mfbt. It is included by mfbt -# itself and by the JS engine, which, when built standalone, must install -# mfbt's exported headers itself. - -EXPORTS_mozilla_DEST := $(DIST)/include/mozilla -EXPORTS_mozilla_TARGET := export -INSTALL_TARGETS += EXPORTS_mozilla -EXPORTS_mozilla_FILES += \ - Alignment.h \ - AllocPolicy.h \ - Array.h \ - Assertions.h \ - Atomics.h \ - Attributes.h \ - BloomFilter.h \ - Casting.h \ - Char16.h \ - CheckedInt.h \ - Compiler.h \ - Compression.h \ - Constants.h \ - DebugOnly.h \ - decimal/Decimal.h \ - Endian.h \ - EnumSet.h \ - FloatingPoint.h \ - GuardObjects.h \ - HashFunctions.h \ - IntegerPrintfMacros.h \ - Likely.h \ - LinkedList.h \ - MathAlgorithms.h \ - Maybe.h \ - MemoryChecking.h \ - MemoryReporting.h \ - MSIntTypes.h \ - Move.h \ - NullPtr.h \ - NumericLimits.h \ - PodOperations.h \ - Poison.h \ - Range.h \ - RangedPtr.h \ - ReentrancyGuard.h \ - RefPtr.h \ - Scoped.h \ - SHA1.h \ - SplayTree.h \ - TemplateLib.h \ - ThreadLocal.h \ - TypedEnum.h \ - Types.h \ - TypeTraits.h \ - Util.h \ - Vector.h \ - WeakPtr.h \ - $(NULL) diff --git a/mfbt/moz.build b/mfbt/moz.build index d51d45934f23..fe832a6db404 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -11,3 +11,6 @@ MODULE = 'mozglue' LIBRARY_NAME = 'mfbt' FORCE_STATIC_LIB = True + +mfbt_root = '.' +include('common.mozbuild') diff --git a/mfbt/sources.mk b/mfbt/sources.mk deleted file mode 100644 index 9323d65b0c39..000000000000 --- a/mfbt/sources.mk +++ /dev/null @@ -1,39 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -ifndef MFBT_ROOT -$(error Before including this file, you must define MFBT_ROOT to point to \ -the MFBT source directory) -endif - -CPPSRCS += \ - Compression.cpp \ - FloatingPoint.cpp \ - HashFunctions.cpp \ - Poison.cpp \ - SHA1.cpp \ - $(NULL) - -# Imported double-conversion sources. -VPATH += $(MFBT_ROOT)/double-conversion \ - $(NULL) - -CPPSRCS += \ - bignum-dtoa.cc \ - bignum.cc \ - cached-powers.cc \ - diy-fp.cc \ - double-conversion.cc \ - fast-dtoa.cc \ - fixed-dtoa.cc \ - strtod.cc \ - $(NULL) - -# Imported decimal sources. -VPATH += $(MFBT_ROOT)/decimal \ - $(NULL) - -CPPSRCS += \ - Decimal.cpp - From 4a4be6685edea0751303b52d2f84c735fe4b038c Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Fri, 1 Nov 2013 15:49:55 -0400 Subject: [PATCH 245/795] Bug 933198 - gum_test.html doesn't provide audio on Windows nightly builds. r=jesup --- media/libcubeb/src/cubeb_wasapi.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/media/libcubeb/src/cubeb_wasapi.cpp b/media/libcubeb/src/cubeb_wasapi.cpp index 32058b1d6e85..2524b17c2be5 100644 --- a/media/libcubeb/src/cubeb_wasapi.cpp +++ b/media/libcubeb/src/cubeb_wasapi.cpp @@ -678,12 +678,6 @@ wasapi_stream_init(cubeb * context, cubeb_stream ** stream, return CUBEB_ERROR; } - /* 30ms in shared mode is the minimum we can get when using WASAPI */ - if (latency < 30) { - LOG("Latency too low: got %u (30ms minimum)", latency); - return CUBEB_ERROR_INVALID_PARAMETER; - } - cubeb_stream * stm = (cubeb_stream *)calloc(1, sizeof(cubeb_stream)); assert(stm); From abd473e70fd252917545beada9d0871a14836ba9 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Fri, 1 Nov 2013 15:49:55 -0400 Subject: [PATCH 246/795] Bug 933009 - Warn when drawing to a destination smaller than the viewport. r=bjacob --- content/canvas/src/WebGLContext.cpp | 8 ++++++++ content/canvas/src/WebGLContext.h | 6 ++++++ content/canvas/src/WebGLContextGL.cpp | 5 +++++ content/canvas/src/WebGLContextVertices.cpp | 14 ++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index 52f4c7d82d8e..cbff093c32a7 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -154,6 +154,11 @@ WebGLContext::WebGLContext() mStencilWriteMaskFront = 0xffffffff; mStencilWriteMaskBack = 0xffffffff; + mViewportX = 0; + mViewportY = 0; + mViewportWidth = 0; + mViewportHeight = 0; + mScissorTestEnabled = 0; mDitherEnabled = 1; mRasterizerDiscardEnabled = 0; // OpenGL ES 3.0 spec p244 @@ -191,6 +196,7 @@ WebGLContext::WebGLContext() mAlreadyGeneratedWarnings = 0; mAlreadyWarnedAboutFakeVertexAttrib0 = false; + mAlreadyWarnedAboutViewportLargerThanDest = false; mMaxWarnings = Preferences::GetInt("webgl.max-warnings-per-context", 32); if (mMaxWarnings < -1) { @@ -571,6 +577,8 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) mWidth = width; mHeight = height; + mViewportWidth = width; + mViewportHeight = height; mResetLayer = true; mOptionsFrozen = true; diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 7b3d203522d7..a5635269823c 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -1132,6 +1132,12 @@ protected: GLint mStencilClearValue; GLfloat mDepthClearValue; + GLint mViewportX; + GLint mViewportY; + GLsizei mViewportWidth; + GLsizei mViewportHeight; + bool mAlreadyWarnedAboutViewportLargerThanDest; + nsCOMPtr mContextRestorer; bool mAllowRestore; bool mContextLossTimerRunning; diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 2a3ecf047e4a..fc5dac68a332 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -3062,6 +3062,11 @@ WebGLContext::Viewport(GLint x, GLint y, GLsizei width, GLsizei height) MakeContextCurrent(); gl->fViewport(x, y, width, height); + + mViewportX = x; + mViewportY = y; + mViewportWidth = width; + mViewportHeight = height; } void diff --git a/content/canvas/src/WebGLContextVertices.cpp b/content/canvas/src/WebGLContextVertices.cpp index 421037cea816..5b453ac72548 100644 --- a/content/canvas/src/WebGLContextVertices.cpp +++ b/content/canvas/src/WebGLContextVertices.cpp @@ -733,6 +733,20 @@ void WebGLContext::Draw_cleanup() } } } + + // Let's check the viewport + const WebGLRectangleObject* rect = FramebufferRectangleObject(); + if (rect) { + if (mViewportWidth > rect->Width() || + mViewportHeight > rect->Height()) + { + if (!mAlreadyWarnedAboutViewportLargerThanDest) { + GenerateWarning("Drawing to a destination rect smaller than the viewport rect. " + "(This warning will only be given once)"); + mAlreadyWarnedAboutViewportLargerThanDest = true; + } + } + } } /* From de8ec8b8957f577f801c1e8223a74afbc3cd4f74 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Fri, 1 Nov 2013 16:21:33 -0700 Subject: [PATCH 247/795] Bug 931846 - Change startup cache location for Metro Firefox. r=jimm, aklotz --- startupcache/StartupCache.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 524499836a7e..e5d5a7cdd8b5 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -87,6 +87,10 @@ private: }; static const char sStartupCacheName[] = "startupCache." SC_WORDSIZE "." SC_ENDIAN; +#if defined(XP_WIN) && defined(MOZ_METRO) +static const char sMetroStartupCacheName[] = "metroStartupCache." SC_WORDSIZE "." SC_ENDIAN; +#endif + static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID); StartupCache* @@ -201,7 +205,14 @@ StartupCache::Init() if (NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS) return rv; - rv = file->AppendNative(NS_LITERAL_CSTRING(sStartupCacheName)); +#if defined(XP_WIN) && defined(MOZ_METRO) + if (XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Metro) { + rv = file->AppendNative(NS_LITERAL_CSTRING(sMetroStartupCacheName)); + } else +#endif + { + rv = file->AppendNative(NS_LITERAL_CSTRING(sStartupCacheName)); + } NS_ENSURE_SUCCESS(rv, rv); From 43eb4a008a548a2223bc58208cc8082056f97221 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Fri, 1 Nov 2013 16:30:12 -0400 Subject: [PATCH 248/795] Bug 847714 - Try to resize, and halve the size until it succeeds. r=bjacob --- content/canvas/src/WebGLContext.cpp | 74 ++++++++++++++++++++++++----- content/canvas/src/WebGLContext.h | 3 ++ 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index cbff093c32a7..03aa289a7fe1 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -402,12 +402,16 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) PresentScreenBuffer(); // ResizeOffscreen scraps the current prod buffer before making a new one. - gl->ResizeOffscreen(gfxIntSize(width, height)); // Doesn't matter if it succeeds (soft-fail) - // It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize + if (!ResizeAndWarn(width, height)) { + // Shouldn't matter if it succeeds (soft-fail) + // It's unlikely that we'll get a proper-sized context if we recreate if we didn't on resize + GenerateWarning("Requested size %dx%d was too large, and reduction failed. " + "Using the old backbuffer.", + width, height); + // We should probably consider losing the context in this case. + } // everything's good, we're done here - mWidth = gl->OffscreenSize().width; - mHeight = gl->OffscreenSize().height; mResetLayer = true; ClearScreen(); @@ -538,12 +542,14 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) } #endif - gfxIntSize size(width, height); + mWidth = 1; + mHeight = 1; + gfxIntSize initSize(mWidth, mHeight); #ifdef XP_WIN // if we want EGL, try it now if (!gl && (preferEGL || useANGLE) && !preferOpenGL) { - gl = gl::GLContextProviderEGL::CreateOffscreen(size, caps); + gl = gl::GLContextProviderEGL::CreateOffscreen(initSize, caps); if (!gl || !InitAndValidateGL()) { GenerateWarning("Error during ANGLE OpenGL ES initialization"); return NS_ERROR_FAILURE; @@ -556,7 +562,7 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) gl::ContextFlags flag = useMesaLlvmPipe ? gl::ContextFlagsMesaLLVMPipe : gl::ContextFlagsNone; - gl = gl::GLContextProvider::CreateOffscreen(size, caps, flag); + gl = gl::GLContextProvider::CreateOffscreen(initSize, caps, flag); if (gl && !InitAndValidateGL()) { GenerateWarning("Error during %s initialization", useMesaLlvmPipe ? "Mesa LLVMpipe" : "OpenGL"); @@ -575,10 +581,12 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) } #endif - mWidth = width; - mHeight = height; - mViewportWidth = width; - mViewportHeight = height; + if (!ResizeAndWarn(width, height)) { + GenerateWarning("Can't get a usable WebGL context (initial resize failed)"); + return NS_ERROR_FAILURE; + } + + mResetLayer = true; mOptionsFrozen = true; @@ -595,6 +603,11 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) MakeContextCurrent(); + // Set our initial viewport. + mViewportWidth = mWidth; + mViewportHeight = mHeight; + gl->fViewport(0, 0, mViewportWidth, mViewportHeight); + // Make sure that we clear this out, otherwise // we'll end up displaying random memory gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0); @@ -618,6 +631,45 @@ WebGLContext::SetDimensions(int32_t width, int32_t height) return NS_OK; } +bool +WebGLContext::ResizeAndWarn(size_t width, size_t height) +{ + if (!Resize(width, height)) + return false; + + if (mWidth != width || + mHeight != height) + { + // Requested size was too large. + GenerateWarning("Requested size %dx%d was too large, reduced successfully to %dx%d.", + width, height, + mWidth, mHeight); + } + + return true; +} + +bool +WebGLContext::Resize(size_t width, size_t height) +{ + while (width && height) { + if (!gl->ResizeOffscreen(gfxIntSize(width, height))) { + // Just halve it each time. + width /= 2; + height /= 2; + continue; + } + + MOZ_ASSERT((size_t)gl->OffscreenSize().width == width); + MOZ_ASSERT((size_t)gl->OffscreenSize().height == height); + mWidth = gl->OffscreenSize().width; + mHeight = gl->OffscreenSize().height; + return true; + } + + return false; +} + NS_IMETHODIMP WebGLContext::Render(gfxContext *ctx, GraphicsFilter f, uint32_t aFlags) { diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index a5635269823c..9fff881ee681 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -188,6 +188,9 @@ public: int32_t x, int32_t y, int32_t w, int32_t h) { return NS_ERROR_NOT_IMPLEMENTED; } + bool Resize(size_t width, size_t height); + bool ResizeAndWarn(size_t width, size_t height); + bool LoseContext(); bool RestoreContext(); From 978ba3b1a0b4d21b9229e3edc1a8baed341dda37 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Thu, 10 Oct 2013 15:23:01 -0400 Subject: [PATCH 249/795] Bug 925458 - Fix test_browserGlue_shutdown.js to not fail most of the time. r=mak --- .../tests/unit/test_browserGlue_shutdown.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/browser/components/places/tests/unit/test_browserGlue_shutdown.js b/browser/components/places/tests/unit/test_browserGlue_shutdown.js index e5b875723e77..a1281b59e0f5 100644 --- a/browser/components/places/tests/unit/test_browserGlue_shutdown.js +++ b/browser/components/places/tests/unit/test_browserGlue_shutdown.js @@ -69,8 +69,11 @@ tests.push({ // Create a bookmarks.html in the profile. let profileBookmarksHTMLFile = create_bookmarks_html("bookmarks.glue.html"); - // Get file lastModified and size. - let lastMod = profileBookmarksHTMLFile.lastModifiedTime; + + // set the file's lastModifiedTime to one minute ago and get its size. + let lastMod = Date.now() - 60*1000; + profileBookmarksHTMLFile.lastModifiedTime = lastMod; + let fileSize = profileBookmarksHTMLFile.fileSize; // Force nsBrowserGlue::_shutdownPlaces(). @@ -80,16 +83,8 @@ tests.push({ // Check a new bookmarks.html has been created. let profileBookmarksHTMLFile = check_bookmarks_html(); - //XXX not working on Linux unit boxes. Could be filestats caching issue. - let isLinux = ("@mozilla.org/gnome-gconf-service;1" in Cc); - if (!isLinux) { - //XXX this test does not working on Mac boxes as well. - let isOSX = ("nsILocalFileMac" in Ci); - if (!isOSX) { - do_check_true(profileBookmarksHTMLFile.lastModifiedTime > lastMod); - } - do_check_neq(profileBookmarksHTMLFile.fileSize, fileSize); - } + do_check_true(profileBookmarksHTMLFile.lastModifiedTime > lastMod); + do_check_neq(profileBookmarksHTMLFile.fileSize, fileSize); // Check preferences have not been reverted. do_check_true(ps.getBoolPref(PREF_AUTO_EXPORT_HTML)); From 65699b67e38a7d6d78088157294ef84251305a7c Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 29 Oct 2013 11:26:25 +0000 Subject: [PATCH 250/795] Bug 925722 - Handle touch events in HomeSearchListView with onTouchEvent (r=sriram) --- mobile/android/base/home/BrowserSearch.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/home/BrowserSearch.java b/mobile/android/base/home/BrowserSearch.java index 2ca0df7a7eea..9f70430c919d 100644 --- a/mobile/android/base/home/BrowserSearch.java +++ b/mobile/android/base/home/BrowserSearch.java @@ -877,13 +877,13 @@ public class BrowserSearch extends HomeFragment } @Override - public boolean onInterceptTouchEvent(MotionEvent event) { + public boolean onTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { // Dismiss the soft keyboard. requestFocus(); } - return super.onInterceptTouchEvent(event); + return super.onTouchEvent(event); } } } From 723c1317fc084c7634cc8be057440e4413c32b81 Mon Sep 17 00:00:00 2001 From: Mark Capella Date: Tue, 29 Oct 2013 08:42:37 -0400 Subject: [PATCH 251/795] Bug 906402 - security exception when checking signature of favicon, r=mfinkle --- mobile/android/base/gfx/BitmapUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mobile/android/base/gfx/BitmapUtils.java b/mobile/android/base/gfx/BitmapUtils.java index cd029adbfd29..905a79c29b12 100644 --- a/mobile/android/base/gfx/BitmapUtils.java +++ b/mobile/android/base/gfx/BitmapUtils.java @@ -61,6 +61,11 @@ public final class BitmapUtils { return GeckoJarReader.getBitmapDrawable(context.getResources(), data); } + // Don't attempt to validate the JAR signature when loading an add-on icon + if (data.startsWith("jar:file")) { + return GeckoJarReader.getBitmapDrawable(context.getResources(), Uri.decode(data)); + } + URL url = new URL(data); InputStream is = (InputStream) url.getContent(); try { From b852bba32d5aa9dd6092527e252ac10bbae45c3d Mon Sep 17 00:00:00 2001 From: Robert Strong Date: Tue, 29 Oct 2013 07:55:01 -0700 Subject: [PATCH 252/795] xpcshell test change only - Bug 932022 - xpcshell test downloadResumeForSameAppVersion.js always leaves behind downloadResumeForSameAppVersion_applyToDir ater it finishes. r=bbondy --- .../unit_aus_update/downloadResumeForSameAppVersion.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js b/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js index 03827297bc63..e9e5030be378 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadResumeForSameAppVersion.js @@ -30,7 +30,15 @@ function run_test() { } do_check_eq(gUpdateManager.activeUpdate.state, STATE_DOWNLOADING); - do_test_finished(); + // Pause the download and reload the Update Manager with an empty update so + // the Application Update Service doesn't write the update xml files during + // xpcom-shutdown which will leave behind the test directory. + gAUS.pauseDownload(); + writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), true); + writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false); + reloadUpdateManagerData(); + + do_timeout(TEST_CHECK_TIMEOUT, do_test_finished); } function end_test() { From 0acfb1147acf4eafbc1bd4ec0a4b3be6d4b74b1e Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Thu, 17 Oct 2013 13:32:57 -0700 Subject: [PATCH 253/795] Bug 924480 - Part 1: Make search_container focusable before browser_toolbar. r=bnicholson --- mobile/android/base/BrowserToolbar.java | 1 + .../base/resources/layout/gecko_app.xml | 21 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mobile/android/base/BrowserToolbar.java b/mobile/android/base/BrowserToolbar.java index b1c88879b6ce..f420da4a4bab 100644 --- a/mobile/android/base/BrowserToolbar.java +++ b/mobile/android/base/BrowserToolbar.java @@ -410,6 +410,7 @@ public class BrowserToolbar extends GeckoRelativeLayout } if (keyCode == KeyEvent.KEYCODE_BACK) { + // Drop the virtual keyboard. clearFocus(); return true; } diff --git a/mobile/android/base/resources/layout/gecko_app.xml b/mobile/android/base/resources/layout/gecko_app.xml index 8d3407933c2a..6b9ca9d8df26 100644 --- a/mobile/android/base/resources/layout/gecko_app.xml +++ b/mobile/android/base/resources/layout/gecko_app.xml @@ -55,20 +55,25 @@ android:layout_alignParentBottom="true"> - + + + - - Date: Wed, 23 Oct 2013 12:15:34 -0700 Subject: [PATCH 254/795] Bug 924480 - Part 1.5: Make HomePager focusable. r=lucasr --- mobile/android/base/home/HomePager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/home/HomePager.java b/mobile/android/base/home/HomePager.java index d07debd36d5c..52512320de4d 100644 --- a/mobile/android/base/home/HomePager.java +++ b/mobile/android/base/home/HomePager.java @@ -96,6 +96,13 @@ public class HomePager extends ViewPager { // This is to keep all 4 pages in memory after they are // selected in the pager. setOffscreenPageLimit(3); + + // We can call HomePager.requestFocus to steal focus from the URL bar and drop the soft + // keyboard. However, if there are no focusable views (e.g. an empty reading list), the + // URL bar will be refocused. Therefore, we make the HomePager container focusable to + // ensure there is always a focusable view. This would ordinarily be done via an XML + // attribute, but it is not working properly. + setFocusableInTouchMode(true); } @Override @@ -324,10 +331,7 @@ public class HomePager extends ViewPager { @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { - // XXX: Drop the soft keyboard by stealing focus. Note that the HomePager (via XML - // attr) is focusable after its descendants allowing requestFocus to succeed and drop - // the soft keyboard even if there are no other focusable views on the screen (e.g. - // the Reading List is empty). + // Drop the soft keyboard by stealing focus from the URL bar. requestFocus(); } From 701a3f885da81bb798ecbcf525f56f697414f627 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Fri, 18 Oct 2013 09:40:28 -0700 Subject: [PATCH 255/795] Bug 924480 - Part 2: Disable TalkBack access to Gecko with HomePager displayed. r=eeejay,lucasr --- mobile/android/base/BrowserApp.java | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index cb9183e68bfd..a81c8fa11e8a 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -167,6 +167,12 @@ abstract public class BrowserApp extends GeckoApp private BrowserHealthReporter mBrowserHealthReporter; + // The animator used to toggle HomePager visibility has a race where if the HomePager is shown + // (starting the animation), the HomePager is hidden, and the HomePager animation completes, + // both the web content and the HomePager will be hidden. This flag is used to prevent the + // race by determining if the web content should be hidden at the animation's end. + private boolean mHideWebContentOnAnimationEnd = false; + private SiteIdentityPopup mSiteIdentityPopup; public SiteIdentityPopup getSiteIdentityPopup() { @@ -1574,7 +1580,38 @@ abstract public class BrowserApp extends GeckoApp final ViewStub homePagerStub = (ViewStub) findViewById(R.id.home_pager_stub); mHomePager = (HomePager) homePagerStub.inflate(); } + mHomePager.show(getSupportFragmentManager(), page, animator); + + // Hide the web content so it cannot be focused by screen readers. + hideWebContentOnPropertyAnimationEnd(animator); + } + + private void hideWebContentOnPropertyAnimationEnd(final PropertyAnimator animator) { + if (animator == null) { + hideWebContent(); + return; + } + + animator.addPropertyAnimationListener(new PropertyAnimator.PropertyAnimationListener() { + @Override + public void onPropertyAnimationStart() { + mHideWebContentOnAnimationEnd = true; + } + + @Override + public void onPropertyAnimationEnd() { + if (mHideWebContentOnAnimationEnd) { + hideWebContent(); + } + } + }); + } + + private void hideWebContent() { + // The view is set to INVISIBLE, rather than GONE, to avoid + // the additional requestLayout() call. + mLayerView.setVisibility(View.INVISIBLE); } private void hideHomePager() { @@ -1587,6 +1624,12 @@ abstract public class BrowserApp extends GeckoApp return; } + // Prevent race in hiding web content - see declaration for more info. + mHideWebContentOnAnimationEnd = false; + + // Display the previously hidden web content (which prevented screen reader access). + mLayerView.setVisibility(View.VISIBLE); + if (mHomePager != null) { mHomePager.hide(); } From f716edc0abc7835130baf03d9d378c8158f80aa4 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Mon, 21 Oct 2013 12:11:08 -0700 Subject: [PATCH 256/795] Bug 915918 - Part 1: Select previously selected tab upon editing mode exit. r=lucasr --- mobile/android/base/BrowserApp.java | 31 +++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index a81c8fa11e8a..de313f86922e 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -167,6 +167,9 @@ abstract public class BrowserApp extends GeckoApp private BrowserHealthReporter mBrowserHealthReporter; + // The tab to be selected on editing mode exit. + private Integer mTargetTabForEditingMode = null; + // The animator used to toggle HomePager visibility has a race where if the HomePager is shown // (starting the animation), the HomePager is hidden, and the HomePager animation completes, // both the web content and the HomePager will be hidden. This flag is used to prevent the @@ -487,7 +490,9 @@ abstract public class BrowserApp extends GeckoApp mBrowserToolbar.setOnStopEditingListener(new BrowserToolbar.OnStopEditingListener() { public void onStopEditing() { - // Re-enable doorhanger notifications. + selectTargetTabForEditingMode(); + + // Re-enable doorhanger notifications. They may trigger on the selected tab above. mDoorHangerPopup.enable(); } }); @@ -1311,7 +1316,10 @@ abstract public class BrowserApp extends GeckoApp if (tabs.isSelectedTabId(tabId)) { hideHomePager(); } else { - tabs.selectTab(tabId); + // Set the target tab to null so it does not get selected (on editing + // mode exit) in lieu of the tab we are about to select. + mTargetTabForEditingMode = null; + Tabs.getInstance().selectTab(tabId); } hideBrowserSearch(); @@ -1425,6 +1433,9 @@ abstract public class BrowserApp extends GeckoApp throw new IllegalArgumentException("Cannot handle null URLs in enterEditingMode"); } + final Tab selectedTab = Tabs.getInstance().getSelectedTab(); + mTargetTabForEditingMode = (selectedTab != null ? selectedTab.getId() : null); + final PropertyAnimator animator = new PropertyAnimator(250); animator.setUseHardwareLayer(false); @@ -1537,6 +1548,22 @@ abstract public class BrowserApp extends GeckoApp } } + /** + * Selects the target tab for editing mode. This is expected to be the tab selected on editing + * mode entry, unless it is subsequently overridden. + * + * A background tab may be selected while editing mode is active (e.g. popups), causing the + * new url to load in the newly selected tab. Call this method on editing mode exit to + * mitigate this. + */ + private void selectTargetTabForEditingMode() { + if (mTargetTabForEditingMode != null) { + Tabs.getInstance().selectTab(mTargetTabForEditingMode); + } + + mTargetTabForEditingMode = null; + } + /** * Shows or hides the home pager for the given tab. */ From 770c7a62a5d31b6592eeb95b37363c8a0cb6d3dd Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Wed, 23 Oct 2013 15:18:22 -0700 Subject: [PATCH 257/795] Bug 915918 - Part 1.5: Refactor hiding of BrowserSearch and HomePager into onStopEditing. r=lucasr --- mobile/android/base/BrowserApp.java | 31 +++++++++++------------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index de313f86922e..1c1bb03c0185 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -491,6 +491,8 @@ abstract public class BrowserApp extends GeckoApp mBrowserToolbar.setOnStopEditingListener(new BrowserToolbar.OnStopEditingListener() { public void onStopEditing() { selectTargetTabForEditingMode(); + hideHomePager(); + hideBrowserSearch(); // Re-enable doorhanger notifications. They may trigger on the selected tab above. mDoorHangerPopup.enable(); @@ -1312,17 +1314,11 @@ abstract public class BrowserApp extends GeckoApp return false; } - // If this tab is already selected, just hide the home pager. - if (tabs.isSelectedTabId(tabId)) { - hideHomePager(); - } else { - // Set the target tab to null so it does not get selected (on editing - // mode exit) in lieu of the tab we are about to select. - mTargetTabForEditingMode = null; - Tabs.getInstance().selectTab(tabId); - } + // Set the target tab to null so it does not get selected (on editing + // mode exit) in lieu of the tab we are about to select. + mTargetTabForEditingMode = null; + Tabs.getInstance().selectTab(tabId); - hideBrowserSearch(); mBrowserToolbar.cancelEdit(); return true; @@ -1350,7 +1346,6 @@ abstract public class BrowserApp extends GeckoApp Tabs.getInstance().loadUrl(url, searchEngine, -1, flags); - hideBrowserSearch(); mBrowserToolbar.cancelEdit(); } @@ -1451,8 +1446,6 @@ abstract public class BrowserApp extends GeckoApp } final String url = mBrowserToolbar.commitEdit(); - hideHomePager(); - hideBrowserSearch(); // Don't do anything if the user entered an empty URL. if (TextUtils.isEmpty(url)) { @@ -1526,13 +1519,13 @@ abstract public class BrowserApp extends GeckoApp return false; } - mBrowserToolbar.cancelEdit(); - - // Resetting the visibility of HomePager, which might have been hidden - // by the filterEditingMode(). + // cancelEdit will call hideHomePager. If we're on web content, this is fine. If we're on + // about:home, the HomePager needs to be visible in the end (note that hideHomePager will + // not hide the HomePager on about:home). However, filterEditingMode may have hidden the + // HomePager so we set it visible here. mHomePager.setVisibility(View.VISIBLE); - hideHomePager(); - hideBrowserSearch(); + + mBrowserToolbar.cancelEdit(); return true; } From c09c677beb53f849b3a82a62d81cf232ce639c9a Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Mon, 14 Oct 2013 17:10:27 -0700 Subject: [PATCH 258/795] Bug 915918 - Part 2: openUrl -> openUrlAndExitEditingMode. r=lucasr --- mobile/android/base/BrowserApp.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 1c1bb03c0185..23578fecb666 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -1324,19 +1324,19 @@ abstract public class BrowserApp extends GeckoApp return true; } - private void openUrl(String url) { - openUrl(url, null, false); + private void openUrlAndStopEditing(String url) { + openUrlAndStopEditing(url, null, false); } - private void openUrl(String url, boolean newTab) { - openUrl(url, null, newTab); + private void openUrlAndStopEditing(String url, boolean newTab) { + openUrlAndStopEditing(url, null, newTab); } - private void openUrl(String url, String searchEngine) { - openUrl(url, searchEngine, false); + private void openUrlAndStopEditing(String url, String searchEngine) { + openUrlAndStopEditing(url, searchEngine, false); } - private void openUrl(String url, String searchEngine, boolean newTab) { + private void openUrlAndStopEditing(String url, String searchEngine, boolean newTab) { mBrowserToolbar.setProgressVisibility(true); int flags = Tabs.LOADURL_NONE; @@ -2356,7 +2356,7 @@ abstract public class BrowserApp extends GeckoApp for (String url : urls) { if (!maybeSwitchToTab(url, flags)) { - openUrl(url, true); + openUrlAndStopEditing(url, true); } } } @@ -2365,7 +2365,7 @@ abstract public class BrowserApp extends GeckoApp @Override public void onUrlOpen(String url, EnumSet flags) { if (!maybeSwitchToTab(url, flags)) { - openUrl(url); + openUrlAndStopEditing(url); } } @@ -2373,7 +2373,7 @@ abstract public class BrowserApp extends GeckoApp @Override public void onSearch(String engineId, String text) { recordSearch(engineId, "barsuggest"); - openUrl(text, engineId); + openUrlAndStopEditing(text, engineId); } // BrowserSearch.OnEditSuggestionListener From 4006fc737751d14e016a1a53dafbcadbb4dd4748 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Wed, 16 Oct 2013 16:15:35 +0800 Subject: [PATCH 259/795] Bug 926343 - Part 5: Use default clientId in OperatorApps. r=fabrice --- dom/apps/src/OperatorApps.jsm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/dom/apps/src/OperatorApps.jsm b/dom/apps/src/OperatorApps.jsm index b8784ce180c8..eb4d082f2b4f 100644 --- a/dom/apps/src/OperatorApps.jsm +++ b/dom/apps/src/OperatorApps.jsm @@ -62,11 +62,17 @@ let iccListener = { notifyCardStateChanged: function() {}, notifyIccInfoChanged: function() { - let iccInfo = iccProvider.iccInfo; + // TODO: Bug 927709 - OperatorApps for multi-sim + // In Multi-sim, there is more than one client in iccProvider. Each + // client represents a icc service. To maintain the backward compatibility + // with single sim, we always use client 0 for now. Adding support for + // multiple sim will be addressed in bug 927709, if needed. + let clientId = 0; + let iccInfo = iccProvider.getIccInfo(clientId); if (iccInfo && iccInfo.mcc && iccInfo.mnc) { debug("******* iccListener cardIccInfo MCC-MNC: " + iccInfo.mcc + "-" + iccInfo.mnc); - iccProvider.unregisterIccMsg(this); + iccProvider.unregisterIccMsg(clientId, this); OperatorAppsRegistry._installOperatorApps(iccInfo.mcc, iccInfo.mnc); } } @@ -82,18 +88,25 @@ this.OperatorAppsRegistry = { #ifdef MOZ_B2G_RIL if (isFirstRunWithSIM()) { debug("First Run with SIM"); + // TODO: Bug 927709 - OperatorApps for multi-sim + // In Multi-sim, there is more than one client in iccProvider. Each + // client represents a icc service. To maintain the backward compatibility + // with single sim, we always use client 0 for now. Adding support for + // multiple sim will be addressed in bug 927709, if needed. + let clientId = 0; + let iccInfo = iccProvider.getIccInfo(clientId); let mcc = 0; let mnc = 0; - if (iccProvider.iccInfo && iccProvider.iccInfo.mcc) { - mcc = iccProvider.iccInfo.mcc; + if (iccInfo && iccInfo.mcc) { + mcc = iccInfo.mcc; } - if (iccProvider.iccInfo && iccProvider.iccInfo.mnc) { - mnc = iccProvider.iccInfo.mnc; + if (iccInfo && iccInfo.mnc) { + mnc = iccInfo.mnc; } if (mcc && mnc) { this._installOperatorApps(mcc, mnc); } else { - iccProvider.registerIccMsg(iccListener); + iccProvider.registerIccMsg(clientId, iccListener); } } else { debug("No First Run with SIM"); From 5c7e3fd27dfd4cf3288195507c55081b20ffa68c Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 01:00:24 -0700 Subject: [PATCH 260/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/2fa2d77525c0 Author: Rudy Lu Desc: Merge pull request #13110 from RudyLu/keyboard/Bug925003_greekSMS_master_v1.2 Bug 925003 - Add a new keyboard layout, "Greek SMS" to allow sending mes... r=djf, julienw ======== https://hg.mozilla.org/integration/gaia-central/rev/7413aadf84d5 Author: Rudy Lu Desc: Bug 925003 - Add a new keyboard layout, "Greek SMS" to allow sending messages with GSM 7-bit encoding. - Disable auto crrection for Greek SMS keyboard layout. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 6857235f1106..6ac258a045a8 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "d2dbad943faf566fe36dbe79086127da837af6a3", + "revision": "2fa2d77525c04ac9078f88495c3737e1b7d61a03", "repo_path": "/integration/gaia-central" } From 7e3fbcf13b26b5a2994e1377728b7c108d7b5397 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 01:10:23 -0700 Subject: [PATCH 261/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/1010c4c9abb5 Author: Amir Nissim Desc: Merge pull request #13119 from EverythingMe/912361-eme-banner Bug 912361 - [e.me] Re-use Homescreen Status Banner [r=crdlc, ranbena] ======== https://hg.mozilla.org/integration/gaia-central/rev/07bf317dadbb Author: Amir Nissim Desc: Bug 912361 - [e.me] Re-use Homescreen Status Banner [r=crdlc, ranbena] --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 6ac258a045a8..34fb921c3a44 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "2fa2d77525c04ac9078f88495c3737e1b7d61a03", + "revision": "1010c4c9abb59f2bb54b0dc8f5fbbabc65a0cb45", "repo_path": "/integration/gaia-central" } From d74389b3e3e692addf35c30d5904a9a75799d584 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:36 +0800 Subject: [PATCH 262/795] Bug 920551 - 1/2: Allow building b2g without MOZ_B2G_RIL. r=khuey --- configure.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index c95500cbc8b8..199f2a8f2abd 100644 --- a/configure.in +++ b/configure.in @@ -1941,7 +1941,7 @@ ia64*-hpux*) no_x=yes if test -n "$gonkdir"; then _PLATFORM_DEFAULT_TOOLKIT=cairo-gonk - MOZ_B2G_RIL=1 + _PLATFORM_HAVE_RIL=1 MOZ_B2G_FM=1 MOZ_SYNTH_PICO=1 else @@ -7274,9 +7274,14 @@ dnl ======================================================== MOZ_ARG_ENABLE_BOOL(b2g-ril, [ --enable-b2g-ril Set compile flags necessary for testing B2G Radio Interface Layer via network sockets ], MOZ_B2G_RIL=1, - MOZ_B2G_RIL= ) + MOZ_B2G_RIL=, + MOZ_B2G_RIL=$_PLATFORM_HAVE_RIL ) if test -n "$MOZ_B2G_RIL"; then - AC_DEFINE(MOZ_B2G_RIL) + if test -n "$_PLATFORM_HAVE_RIL"; then + AC_DEFINE(MOZ_B2G_RIL) + else + AC_MSG_ERROR([b2g-ril cannot be enabled because target platform doesn't support it.]) + fi fi AC_SUBST(MOZ_B2G_RIL) From e572c7fe099963a056b03052399b9670778ed781 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:37 +0800 Subject: [PATCH 263/795] Bug 920551 - 2.a/2: fix MobileMessage. r=gene,khuey --- b2g/installer/package-manifest.in | 12 +- dom/mobilemessage/interfaces/moz.build | 2 +- dom/mobilemessage/src/SmsServicesFactory.cpp | 6 +- dom/mobilemessage/src/moz.build | 2 +- dom/mobilemessage/tests/Makefile.in | 6 - .../tests/test_smsdatabaseservice.xul | 876 ------------------ dom/mobilemessage/tests/xpcshell.ini | 1 - 7 files changed, 13 insertions(+), 892 deletions(-) delete mode 100644 dom/mobilemessage/tests/test_smsdatabaseservice.xul diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index cee64eab8d10..c466b5e0c1a5 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -399,6 +399,14 @@ @BINPATH@/components/nsDownloadManagerUI.js @BINPATH@/components/nsSidebar.manifest @BINPATH@/components/nsSidebar.js + +#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) +@BINPATH@/components/MmsService.js +@BINPATH@/components/MmsService.manifest +@BINPATH@/components/MobileMessageDatabaseService.js +@BINPATH@/components/MobileMessageDatabaseService.manifest +#endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL + #ifndef MOZ_WIDGET_GONK @BINPATH@/components/extensions.manifest @BINPATH@/components/addonManager.js @@ -469,11 +477,7 @@ @BINPATH@/components/NetworkManager.js @BINPATH@/components/RadioInterfaceLayer.manifest @BINPATH@/components/RadioInterfaceLayer.js -@BINPATH@/components/MmsService.manifest -@BINPATH@/components/MmsService.js @BINPATH@/components/RILContentHelper.js -@BINPATH@/components/MobileMessageDatabaseService.manifest -@BINPATH@/components/MobileMessageDatabaseService.js @BINPATH@/components/WifiWorker.js @BINPATH@/components/WifiWorker.manifest @BINPATH@/components/DOMWifiManager.js diff --git a/dom/mobilemessage/interfaces/moz.build b/dom/mobilemessage/interfaces/moz.build index 52cc79b9288c..f112aab93ad6 100644 --- a/dom/mobilemessage/interfaces/moz.build +++ b/dom/mobilemessage/interfaces/moz.build @@ -22,7 +22,7 @@ XPIDL_SOURCES += [ 'nsIWapPushApplication.idl', ] -if CONFIG['MOZ_B2G_RIL']: +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']: XPIDL_SOURCES += [ 'nsIRilMobileMessageDatabaseService.idl', ] diff --git a/dom/mobilemessage/src/SmsServicesFactory.cpp b/dom/mobilemessage/src/SmsServicesFactory.cpp index 2410a8102253..db379fb4dbbc 100644 --- a/dom/mobilemessage/src/SmsServicesFactory.cpp +++ b/dom/mobilemessage/src/SmsServicesFactory.cpp @@ -10,7 +10,7 @@ #include "android/MobileMessageDatabaseService.h" #include "android/SmsService.h" #include "android/MmsService.h" -#elif defined(MOZ_B2G_RIL) +#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) #include "gonk/SmsService.h" #else #include "fallback/MmsService.h" @@ -47,7 +47,7 @@ SmsServicesFactory::CreateMobileMessageDatabaseService() if (XRE_GetProcessType() == GeckoProcessType_Content) { mobileMessageDBService = new SmsIPCService(); } else { -#ifdef MOZ_B2G_RIL +#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) mobileMessageDBService = do_GetService(RIL_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID); #else mobileMessageDBService = new MobileMessageDatabaseService(); @@ -65,7 +65,7 @@ SmsServicesFactory::CreateMmsService() if (XRE_GetProcessType() == GeckoProcessType_Content) { mmsService = new SmsIPCService(); } else { -#ifdef MOZ_B2G_RIL +#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) mmsService = do_CreateInstance(RIL_MMSSERVICE_CONTRACTID); #else mmsService = new MmsService(); diff --git a/dom/mobilemessage/src/moz.build b/dom/mobilemessage/src/moz.build index 9f0369c42d2b..b79139f02427 100644 --- a/dom/mobilemessage/src/moz.build +++ b/dom/mobilemessage/src/moz.build @@ -19,7 +19,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': 'android/MobileMessageDatabaseService.cpp', 'android/SmsService.cpp', ] -elif CONFIG['MOZ_B2G_RIL']: +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']: EXTRA_JS_MODULES = [ 'gonk/mms_consts.js', 'gonk/MmsPduHelper.jsm', diff --git a/dom/mobilemessage/tests/Makefile.in b/dom/mobilemessage/tests/Makefile.in index d9c2214d252f..6fbe8159b2db 100644 --- a/dom/mobilemessage/tests/Makefile.in +++ b/dom/mobilemessage/tests/Makefile.in @@ -1,9 +1,3 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. - -ifdef MOZ_B2G_RIL -MOCHITEST_CHROME_FILES = \ - test_smsdatabaseservice.xul \ - $(NULL) -endif diff --git a/dom/mobilemessage/tests/test_smsdatabaseservice.xul b/dom/mobilemessage/tests/test_smsdatabaseservice.xul deleted file mode 100644 index b95de0d7e647..000000000000 --- a/dom/mobilemessage/tests/test_smsdatabaseservice.xul +++ /dev/null @@ -1,876 +0,0 @@ - - - - - - Test MobileMessageDatabaseService by SMS - - -

- -

-  
-
diff --git a/dom/mobilemessage/tests/xpcshell.ini b/dom/mobilemessage/tests/xpcshell.ini index 6af3d261c665..8498ad4deef0 100644 --- a/dom/mobilemessage/tests/xpcshell.ini +++ b/dom/mobilemessage/tests/xpcshell.ini @@ -3,7 +3,6 @@ head = header_helpers.js tail = support-files = test_sms_basics.html - test_smsdatabaseservice.xul test_smsfilter.html [test_smsservice_createsmsmessage.js] From 131eae1652d93bf5a3bb9a6bc615f29b7a4d4475 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:38 +0800 Subject: [PATCH 264/795] Bug 920551 - 2.b/2: fix Telephony. r=hsinyi,khuey --- b2g/app/b2g.js | 3 -- b2g/installer/package-manifest.in | 4 +-- dom/base/Navigator.cpp | 58 +++++++++++++++--------------- dom/base/Navigator.h | 10 +++--- dom/telephony/TelephonyFactory.cpp | 4 +-- dom/telephony/moz.build | 2 +- dom/webidl/Navigator.webidl | 10 +++--- modules/libpref/src/init/all.js | 4 +++ 8 files changed, 48 insertions(+), 47 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 27d8d7e00814..a9b0b7a81848 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -821,9 +821,6 @@ pref("gfx.canvas.skiagl.dynamic-cache", true); // enable fence with readpixels for SurfaceStream pref("gfx.gralloc.fence-with-readpixels", true); -// Enable Telephony API -pref("dom.telephony.enabled", true); - // Cell Broadcast API pref("dom.cellbroadcast.enabled", true); pref("ril.cellbroadcast.disabled", false); diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index c466b5e0c1a5..94a072219d9f 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -405,6 +405,8 @@ @BINPATH@/components/MmsService.manifest @BINPATH@/components/MobileMessageDatabaseService.js @BINPATH@/components/MobileMessageDatabaseService.manifest +@BINPATH@/components/TelephonyProvider.js +@BINPATH@/components/TelephonyProvider.manifest #endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL #ifndef MOZ_WIDGET_GONK @@ -486,8 +488,6 @@ @BINPATH@/components/NetworkStatsManager.manifest @BINPATH@/components/NetworkInterfaceListService.manifest @BINPATH@/components/NetworkInterfaceListService.js -@BINPATH@/components/TelephonyProvider.manifest -@BINPATH@/components/TelephonyProvider.js @BINPATH@/components/NetworkStatsServiceProxy.manifest @BINPATH@/components/NetworkStatsServiceProxy.js #endif diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 6938ea3cea50..966764867f21 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -29,6 +29,7 @@ #include "nsIDOMWakeLock.h" #include "nsIPowerManagerService.h" #include "mozilla/dom/MobileMessageManager.h" +#include "mozilla/dom/Telephony.h" #include "mozilla/Hal.h" #include "nsISiteSpecificUserAgent.h" #include "mozilla/ClearOnShutdown.h" @@ -40,7 +41,6 @@ #include "mozilla/dom/IccManager.h" #include "MobileConnection.h" #include "mozilla/dom/CellBroadcast.h" -#include "mozilla/dom/Telephony.h" #include "mozilla/dom/Voicemail.h" #endif #include "nsIIdleObserver.h" @@ -138,12 +138,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Navigator) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBatteryManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPowerManager) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileMessageManager) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConnection) #ifdef MOZ_B2G_RIL NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMobileConnection) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCellBroadcast) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIccManager) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTelephony) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVoicemail) #endif #ifdef MOZ_B2G_BT @@ -209,6 +209,10 @@ Navigator::Invalidate() mMobileMessageManager = nullptr; } + if (mTelephony) { + mTelephony = nullptr; + } + if (mConnection) { mConnection->Shutdown(); mConnection = nullptr; @@ -229,10 +233,6 @@ Navigator::Invalidate() mIccManager = nullptr; } - if (mTelephony) { - mTelephony = nullptr; - } - if (mVoicemail) { mVoicemail = nullptr; } @@ -1165,6 +1165,20 @@ Navigator::GetMozMobileMessage() return mMobileMessageManager; } +Telephony* +Navigator::GetMozTelephony(ErrorResult& aRv) +{ + if (!mTelephony) { + if (!mWindow) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + mTelephony = Telephony::Create(mWindow, aRv); + } + + return mTelephony; +} + #ifdef MOZ_B2G_RIL CellBroadcast* @@ -1181,20 +1195,6 @@ Navigator::GetMozCellBroadcast(ErrorResult& aRv) return mCellBroadcast; } -Telephony* -Navigator::GetMozTelephony(ErrorResult& aRv) -{ - if (!mTelephony) { - if (!mWindow) { - aRv.Throw(NS_ERROR_UNEXPECTED); - return nullptr; - } - mTelephony = Telephony::Create(mWindow, aRv); - } - - return mTelephony; -} - Voicemail* Navigator::GetMozVoicemail(ErrorResult& aRv) { @@ -1697,15 +1697,6 @@ Navigator::HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal) return true; } -/* static */ -bool -Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal) -{ - nsCOMPtr win = GetWindowFromGlobal(aGlobal); - return win && nsDOMCameraManager::CheckPermission(win); -} - -#ifdef MOZ_B2G_RIL /* static */ bool Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal) @@ -1719,6 +1710,15 @@ Navigator::HasTelephonySupport(JSContext* /* unused */, JSObject* aGlobal) return win && CheckPermission(win, "telephony"); } +/* static */ +bool +Navigator::HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal) +{ + nsCOMPtr win = GetWindowFromGlobal(aGlobal); + return win && nsDOMCameraManager::CheckPermission(win); +} + +#ifdef MOZ_B2G_RIL /* static */ bool Navigator::HasMobileConnectionSupport(JSContext* /* unused */, diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 60c89a3d661b..c35f22af66c3 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -86,11 +86,11 @@ class BluetoothManager; #ifdef MOZ_B2G_RIL class CellBroadcast; class IccManager; -class Telephony; class Voicemail; #endif class PowerManager; +class Telephony; namespace time { class TimeManager; @@ -211,6 +211,7 @@ public: bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline, ErrorResult& aRv); nsIDOMMozMobileMessageManager* GetMozMobileMessage(); + Telephony* GetMozTelephony(ErrorResult& aRv); nsIDOMMozConnection* GetMozConnection(); nsDOMCameraManager* GetMozCameras(ErrorResult& aRv); void MozSetMessageHandler(const nsAString& aType, @@ -218,7 +219,6 @@ public: ErrorResult& aRv); bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv); #ifdef MOZ_B2G_RIL - Telephony* GetMozTelephony(ErrorResult& aRv); nsIDOMMozMobileConnection* GetMozMobileConnection(ErrorResult& aRv); CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv); Voicemail* GetMozVoicemail(ErrorResult& aRv); @@ -268,11 +268,11 @@ public: } static bool HasMobileMessageSupport(JSContext* /* unused */, JSObject* aGlobal); + static bool HasTelephonySupport(JSContext* /* unused */, + JSObject* aGlobal); static bool HasCameraSupport(JSContext* /* unused */, JSObject* aGlobal); #ifdef MOZ_B2G_RIL - static bool HasTelephonySupport(JSContext* /* unused */, - JSObject* aGlobal); static bool HasMobileConnectionSupport(JSContext* /* unused */, JSObject* aGlobal); static bool HasCellBroadcastSupport(JSContext* /* unused */, @@ -326,12 +326,12 @@ private: #endif nsRefPtr mPowerManager; nsRefPtr mMobileMessageManager; + nsRefPtr mTelephony; nsRefPtr mConnection; #ifdef MOZ_B2G_RIL nsRefPtr mMobileConnection; nsRefPtr mCellBroadcast; nsRefPtr mIccManager; - nsRefPtr mTelephony; nsRefPtr mVoicemail; #endif #ifdef MOZ_B2G_BT diff --git a/dom/telephony/TelephonyFactory.cpp b/dom/telephony/TelephonyFactory.cpp index eab2c699185c..593a39d93472 100644 --- a/dom/telephony/TelephonyFactory.cpp +++ b/dom/telephony/TelephonyFactory.cpp @@ -4,7 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/telephony/TelephonyFactory.h" -#ifdef MOZ_WIDGET_GONK +#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) #include "nsIGonkTelephonyProvider.h" #endif #include "nsServiceManagerUtils.h" @@ -20,7 +20,7 @@ TelephonyFactory::CreateTelephonyProvider() if (XRE_GetProcessType() == GeckoProcessType_Content) { provider = new TelephonyIPCProvider(); -#ifdef MOZ_WIDGET_GONK +#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) } else { provider = do_CreateInstance(GONK_TELEPHONY_PROVIDER_CONTRACTID); #endif diff --git a/dom/telephony/moz.build b/dom/telephony/moz.build index d46be04b21ef..8501230bfae1 100644 --- a/dom/telephony/moz.build +++ b/dom/telephony/moz.build @@ -45,7 +45,7 @@ IPDL_SOURCES += [ 'ipc/TelephonyTypes.ipdlh' ] -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']: XPIDL_SOURCES += [ 'nsIGonkTelephonyProvider.idl', ] diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 3220533fcda7..5ccc1aeb67df 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -255,11 +255,6 @@ partial interface Navigator { }; #ifdef MOZ_B2G_RIL -partial interface Navigator { - [Throws, Func="Navigator::HasTelephonySupport"] - readonly attribute Telephony? mozTelephony; -}; - // nsIMozNavigatorMobileConnection interface MozMobileConnection; partial interface Navigator { @@ -285,6 +280,11 @@ partial interface Navigator { }; #endif // MOZ_B2G_RIL +partial interface Navigator { + [Throws, Func="Navigator::HasTelephonySupport"] + readonly attribute Telephony? mozTelephony; +}; + #ifdef MOZ_GAMEPAD // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#navigator-interface-extension partial interface Navigator { diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index ecba0dd30985..7875b700ac08 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4512,7 +4512,11 @@ pref("dom.mozInputMethod.enabled", false); pref("dom.datastore.enabled", false); // Telephony API +#ifdef MOZ_B2G_RIL +pref("dom.telephony.enabled", true); +#else pref("dom.telephony.enabled", false); +#endif // Numeric default service id for WebTelephony API calls with |serviceId| // parameter omitted. pref("dom.telephony.defaultServiceId", 0); From 600a32f491e48dd0ab09c0ddaefdad367b764166 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:39 +0800 Subject: [PATCH 265/795] Bug 920551 - 2.c/2: fix CellBroadcast. r=hsinyi --- b2g/app/b2g.js | 1 - modules/libpref/src/init/all.js | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index a9b0b7a81848..85c3de85398d 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -822,7 +822,6 @@ pref("gfx.canvas.skiagl.dynamic-cache", true); pref("gfx.gralloc.fence-with-readpixels", true); // Cell Broadcast API -pref("dom.cellbroadcast.enabled", true); pref("ril.cellbroadcast.disabled", false); // ICC API diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 7875b700ac08..f59cfb822ef4 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4522,7 +4522,11 @@ pref("dom.telephony.enabled", false); pref("dom.telephony.defaultServiceId", 0); // Cell Broadcast API +#ifdef MOZ_B2G_RIL +pref("dom.cellbroadcast.enabled", true); +#else pref("dom.cellbroadcast.enabled", false); +#endif // ICC API pref("dom.icc.enabled", false); From c6917c2beb631071ea95af4956c739834b32307d Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:40 +0800 Subject: [PATCH 266/795] Bug 920551 - 2.d/2: fix ICC. r=hsinyi,khuey --- b2g/app/b2g.js | 3 --- dom/base/moz.build | 1 - dom/webidl/moz.build | 2 +- modules/libpref/src/init/all.js | 4 ++++ 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 85c3de85398d..a35e6c126187 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -824,9 +824,6 @@ pref("gfx.gralloc.fence-with-readpixels", true); // Cell Broadcast API pref("ril.cellbroadcast.disabled", false); -// ICC API -pref("dom.icc.enabled", true); - // Mobile Connection API pref("dom.mobileconnection.enabled", true); diff --git a/dom/base/moz.build b/dom/base/moz.build index 160c12fcdf62..f2bdb13a288c 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -128,7 +128,6 @@ LIBRARY_NAME = 'jsdombase_s' LOCAL_INCLUDES += [ '../battery', '../bluetooth', - '../icc/src', '../media', '../network/src', '../src/geolocation', diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 4af79c4972d0..1777ab30165c 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -471,7 +471,6 @@ if CONFIG['MOZ_GAMEPAD']: if CONFIG['MOZ_B2G_RIL']: WEBIDL_FILES += [ - 'MozStkCommandEvent.webidl', 'MozVoicemail.webidl', ] @@ -517,6 +516,7 @@ if CONFIG['MOZ_B2G_RIL']: 'MozCellBroadcastEvent.webidl', 'MozEmergencyCbModeEvent.webidl', 'MozOtaStatusEvent.webidl', + 'MozStkCommandEvent.webidl', 'MozVoicemailEvent.webidl', 'MozWifiConnectionInfoEvent.webidl', 'MozWifiStatusChangeEvent.webidl', diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index f59cfb822ef4..f23acaf19a13 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4529,7 +4529,11 @@ pref("dom.cellbroadcast.enabled", false); #endif // ICC API +#ifdef MOZ_B2G_RIL +pref("dom.icc.enabled", true); +#else pref("dom.icc.enabled", false); +#endif // Mobile Connection API pref("dom.mobileconnection.enabled", false); From 812e055581f3b17b6487b3a085398bad983fe1ef Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:41 +0800 Subject: [PATCH 267/795] Bug 920551 - 2.e/2: fix MobileConnection. r=hsinyi,khuey --- b2g/app/b2g.js | 3 --- dom/base/Navigator.cpp | 2 +- dom/network/interfaces/moz.build | 4 ++-- dom/network/src/MobileConnection.cpp | 3 ++- dom/network/src/moz.build | 3 +++ modules/libpref/src/init/all.js | 4 ++++ 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index a35e6c126187..512925b3d421 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -824,9 +824,6 @@ pref("gfx.gralloc.fence-with-readpixels", true); // Cell Broadcast API pref("ril.cellbroadcast.disabled", false); -// Mobile Connection API -pref("dom.mobileconnection.enabled", true); - // Voice Mail API pref("dom.voicemail.enabled", true); diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index 966764867f21..e9940b96eec5 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -39,8 +39,8 @@ #include "nsGlobalWindow.h" #ifdef MOZ_B2G_RIL #include "mozilla/dom/IccManager.h" -#include "MobileConnection.h" #include "mozilla/dom/CellBroadcast.h" +#include "mozilla/dom/network/MobileConnection.h" #include "mozilla/dom/Voicemail.h" #endif #include "nsIIdleObserver.h" diff --git a/dom/network/interfaces/moz.build b/dom/network/interfaces/moz.build index 443b76373806..23d8baa07e57 100644 --- a/dom/network/interfaces/moz.build +++ b/dom/network/interfaces/moz.build @@ -6,10 +6,8 @@ XPIDL_SOURCES += [ 'nsIDOMConnection.idl', - 'nsIDOMDataErrorEvent.idl', 'nsIDOMTCPServerSocket.idl', 'nsIDOMTCPSocket.idl', - 'nsIDOMUSSDReceivedEvent.idl', 'nsIMozNavigatorNetwork.idl', 'nsITCPServerSocketChild.idl', 'nsITCPServerSocketParent.idl', @@ -20,11 +18,13 @@ XPIDL_SOURCES += [ if CONFIG['MOZ_B2G_RIL']: XPIDL_SOURCES += [ 'nsIDOMCFStateChangeEvent.idl', + 'nsIDOMDataErrorEvent.idl', 'nsIDOMMobileConnection.idl', 'nsIDOMMozEmergencyCbModeEvent.idl', 'nsIDOMMozOtaStatusEvent.idl', 'nsIDOMNetworkStats.idl', 'nsIDOMNetworkStatsManager.idl', + 'nsIDOMUSSDReceivedEvent.idl', 'nsIMobileConnectionProvider.idl', 'nsINetworkStatsServiceProxy.idl', ] diff --git a/dom/network/src/MobileConnection.cpp b/dom/network/src/MobileConnection.cpp index e743ea4158ae..f975eea969c4 100644 --- a/dom/network/src/MobileConnection.cpp +++ b/dom/network/src/MobileConnection.cpp @@ -2,7 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "MobileConnection.h" +#include "mozilla/dom/network/MobileConnection.h" + #include "GeneratedEvents.h" #include "mozilla/Preferences.h" #include "nsDOMEvent.h" diff --git a/dom/network/src/moz.build b/dom/network/src/moz.build index be1e8f5e81fa..e945b41d134d 100644 --- a/dom/network/src/moz.build +++ b/dom/network/src/moz.build @@ -22,6 +22,9 @@ SOURCES += [ ] if CONFIG['MOZ_B2G_RIL']: + EXPORTS.mozilla.dom.network += [ + 'MobileConnection.h', + ] SOURCES += [ 'MobileConnection.cpp', ] diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index f23acaf19a13..7828e67abf41 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4536,7 +4536,11 @@ pref("dom.icc.enabled", false); #endif // Mobile Connection API +#ifdef MOZ_B2G_RIL +pref("dom.mobileconnection.enabled", true); +#else pref("dom.mobileconnection.enabled", false); +#endif // Voice Mail API pref("dom.voicemail.enabled", false); From 152523ac25c6e6bbd949f5eacb161b81c7d6d646 Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:42 +0800 Subject: [PATCH 268/795] Bug 920551 - 2.f/2: fix Voicemail. r=hsinyi,khuey --- b2g/app/b2g.js | 3 --- dom/webidl/moz.build | 6 +----- modules/libpref/src/init/all.js | 4 ++++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 512925b3d421..6656c8c9f8df 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -824,9 +824,6 @@ pref("gfx.gralloc.fence-with-readpixels", true); // Cell Broadcast API pref("ril.cellbroadcast.disabled", false); -// Voice Mail API -pref("dom.voicemail.enabled", true); - // The url of the page used to display network error details. pref("b2g.neterror.url", "app://system.gaiamobile.org/net_error.html"); diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 1777ab30165c..0eb3127549da 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -469,11 +469,6 @@ if CONFIG['MOZ_GAMEPAD']: 'Gamepad.webidl', ] -if CONFIG['MOZ_B2G_RIL']: - WEBIDL_FILES += [ - 'MozVoicemail.webidl', - ] - WEBIDL_FILES += [ 'CloseEvent.webidl', 'CustomEvent.webidl', @@ -517,6 +512,7 @@ if CONFIG['MOZ_B2G_RIL']: 'MozEmergencyCbModeEvent.webidl', 'MozOtaStatusEvent.webidl', 'MozStkCommandEvent.webidl', + 'MozVoicemail.webidl', 'MozVoicemailEvent.webidl', 'MozWifiConnectionInfoEvent.webidl', 'MozWifiStatusChangeEvent.webidl', diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 7828e67abf41..8030032ff0ca 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4543,7 +4543,11 @@ pref("dom.mobileconnection.enabled", false); #endif // Voice Mail API +#ifdef MOZ_B2G_RIL +pref("dom.voicemail.enabled", true); +#else pref("dom.voicemail.enabled", false); +#endif // Numeric default service id for Voice Mail API calls with |serviceId| // parameter omitted. pref("dom.voicemail.defaultServiceId", 0); From f42c8bdec043abac933d648a47192204d1ebd03f Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:43 +0800 Subject: [PATCH 269/795] Bug 920551 - 2.g/2: fix WAP Push. r=hsinyi,khuey --- dom/moz.build | 2 +- dom/wappush/moz.build | 2 +- dom/wappush/src/moz.build | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dom/moz.build b/dom/moz.build index 789476ac52d9..546df28c8309 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -72,7 +72,6 @@ PARALLEL_DIRS += [ 'camera', 'audiochannel', 'promise', - 'wappush', 'telephony', 'inputmethod', 'webidl', @@ -87,6 +86,7 @@ if CONFIG['MOZ_B2G_RIL']: 'icc', 'cellbroadcast', 'voicemail', + 'wappush', ] if CONFIG['MOZ_PAY']: diff --git a/dom/wappush/moz.build b/dom/wappush/moz.build index a21f6787c8ec..1f6041d326c0 100644 --- a/dom/wappush/moz.build +++ b/dom/wappush/moz.build @@ -5,5 +5,5 @@ PARALLEL_DIRS += ['interfaces', 'src'] -if CONFIG['MOZ_B2G_RIL'] and CONFIG['ENABLE_TESTS']: +if CONFIG['ENABLE_TESTS']: XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini'] diff --git a/dom/wappush/src/moz.build b/dom/wappush/src/moz.build index 87c35e10f270..39cc0cb151f8 100644 --- a/dom/wappush/src/moz.build +++ b/dom/wappush/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -if CONFIG['MOZ_B2G_RIL']: +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['MOZ_B2G_RIL']: EXTRA_JS_MODULES = [ 'gonk/CpPduHelper.jsm', 'gonk/SiPduHelper.jsm', From 8d3ece0bda5c37432425faceb67aaa06ec5f700f Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:45 +0800 Subject: [PATCH 270/795] Bug 920551 - 2.h/2: fix dom/system/gonk/*. r=hsinyi,khuey --- b2g/app/b2g.js | 2 +- b2g/chrome/content/shell.js | 4 +- b2g/installer/package-manifest.in | 43 +++--- content/events/src/Makefile.in | 2 +- dom/base/moz.build | 2 +- dom/moz.build | 4 +- dom/network/interfaces/moz.build | 8 +- dom/network/src/moz.build | 4 +- dom/network/tests/Makefile.in | 2 +- dom/system/gonk/NetworkManager.js | 48 ++++++- dom/system/gonk/SystemWorkerManager.cpp | 163 ++--------------------- dom/system/gonk/SystemWorkerManager.h | 15 +-- dom/system/gonk/moz.build | 77 ++++++----- dom/system/moz.build | 3 +- dom/webidl/moz.build | 6 +- ipc/moz.build | 6 +- ipc/ril/Ril.cpp | 169 ++++++++++++++++++++++-- ipc/ril/Ril.h | 9 +- js/xpconnect/src/event_impl_gen.conf.in | 6 +- layout/build/Makefile.in | 9 +- layout/build/nsLayoutModule.cpp | 14 +- toolkit/library/Makefile.in | 6 +- 22 files changed, 336 insertions(+), 266 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 6656c8c9f8df..ec91418d73eb 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -430,7 +430,7 @@ pref("services.push.requestTimeout", 10000); pref("services.push.udp.wakeupEnabled", true); // NetworkStats -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK pref("dom.mozNetworkStats.enabled", true); pref("dom.webapps.firstRunWithSIM", true); #endif diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index e80e828aa7f0..9c37aa716cd8 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -18,7 +18,7 @@ Cu.import("resource://gre/modules/AppsUtils.jsm"); Cu.import('resource://gre/modules/UserAgentOverrides.jsm'); Cu.import('resource://gre/modules/Keyboard.jsm'); Cu.import('resource://gre/modules/ErrorPage.jsm'); -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK Cu.import('resource://gre/modules/NetworkStatsService.jsm'); #endif @@ -611,7 +611,7 @@ var shell = { this.sendEvent(window, 'ContentStart'); -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK Cu.import('resource://gre/modules/OperatorApps.jsm'); #endif diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 94a072219d9f..39bd1ee846f0 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -164,10 +164,12 @@ @BINPATH@/components/dom_audiochannel.xpt @BINPATH@/components/dom_base.xpt @BINPATH@/components/dom_system.xpt -#ifdef MOZ_B2G_RIL -@BINPATH@/components/dom_voicemail.xpt +#ifdef MOZ_WIDGET_GONK @BINPATH@/components/dom_wifi.xpt @BINPATH@/components/dom_system_gonk.xpt +#endif +#ifdef MOZ_B2G_RIL +@BINPATH@/components/dom_voicemail.xpt @BINPATH@/components/dom_icc.xpt @BINPATH@/components/dom_cellbroadcast.xpt @BINPATH@/components/dom_wappush.xpt @@ -400,11 +402,31 @@ @BINPATH@/components/nsSidebar.manifest @BINPATH@/components/nsSidebar.js +; WiFi, NetworkManager, NetworkStats +#ifdef MOZ_WIDGET_GONK +@BINPATH@/components/DOMWifiManager.js +@BINPATH@/components/DOMWifiManager.manifest +@BINPATH@/components/NetworkInterfaceListService.js +@BINPATH@/components/NetworkInterfaceListService.manifest +@BINPATH@/components/NetworkManager.js +@BINPATH@/components/NetworkManager.manifest +@BINPATH@/components/NetworkStatsManager.js +@BINPATH@/components/NetworkStatsManager.manifest +@BINPATH@/components/NetworkStatsServiceProxy.js +@BINPATH@/components/NetworkStatsServiceProxy.manifest +@BINPATH@/components/WifiWorker.js +@BINPATH@/components/WifiWorker.manifest +#endif // MOZ_WIDGET_GONK + +; RIL #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) @BINPATH@/components/MmsService.js @BINPATH@/components/MmsService.manifest @BINPATH@/components/MobileMessageDatabaseService.js @BINPATH@/components/MobileMessageDatabaseService.manifest +@BINPATH@/components/RadioInterfaceLayer.js +@BINPATH@/components/RadioInterfaceLayer.manifest +@BINPATH@/components/RILContentHelper.js @BINPATH@/components/TelephonyProvider.js @BINPATH@/components/TelephonyProvider.manifest #endif // MOZ_WIDGET_GONK && MOZ_B2G_RIL @@ -474,23 +496,6 @@ @BINPATH@/components/webvtt.xpt @BINPATH@/components/WebVTT.manifest @BINPATH@/components/WebVTTParserWrapper.js -#ifdef MOZ_B2G_RIL -@BINPATH@/components/NetworkManager.manifest -@BINPATH@/components/NetworkManager.js -@BINPATH@/components/RadioInterfaceLayer.manifest -@BINPATH@/components/RadioInterfaceLayer.js -@BINPATH@/components/RILContentHelper.js -@BINPATH@/components/WifiWorker.js -@BINPATH@/components/WifiWorker.manifest -@BINPATH@/components/DOMWifiManager.js -@BINPATH@/components/DOMWifiManager.manifest -@BINPATH@/components/NetworkStatsManager.js -@BINPATH@/components/NetworkStatsManager.manifest -@BINPATH@/components/NetworkInterfaceListService.manifest -@BINPATH@/components/NetworkInterfaceListService.js -@BINPATH@/components/NetworkStatsServiceProxy.manifest -@BINPATH@/components/NetworkStatsServiceProxy.js -#endif #ifdef MOZ_ENABLE_DBUS @BINPATH@/components/@DLL_PREFIX@dbusservice@DLL_SUFFIX@ #endif diff --git a/content/events/src/Makefile.in b/content/events/src/Makefile.in index 8151c59d263d..ff68d3f060e3 100644 --- a/content/events/src/Makefile.in +++ b/content/events/src/Makefile.in @@ -18,7 +18,7 @@ LOCAL_INCLUDES += \ -I$(srcdir)/../../../layout/xul/tree/ \ $(NULL) -ifdef MOZ_B2G_RIL +ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) LOCAL_INCLUDES += \ -I$(srcdir)/../../../dom/wifi \ $(NULL) diff --git a/dom/base/moz.build b/dom/base/moz.build index f2bdb13a288c..7855232543ed 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -143,7 +143,7 @@ LOCAL_INCLUDES += [ '/layout/xul/base/src', ] -if CONFIG['MOZ_B2G_RIL']: +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': LOCAL_INCLUDES += [ '../fmradio', '../system/gonk', diff --git a/dom/moz.build b/dom/moz.build index 546df28c8309..d0b32a2f0805 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -80,9 +80,11 @@ PARALLEL_DIRS += [ if CONFIG['OS_ARCH'] == 'WINNT': PARALLEL_DIRS += ['plugins/ipc/hangui'] +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + PARALLEL_DIRS += ['wifi'] + if CONFIG['MOZ_B2G_RIL']: PARALLEL_DIRS += [ - 'wifi', 'icc', 'cellbroadcast', 'voicemail', diff --git a/dom/network/interfaces/moz.build b/dom/network/interfaces/moz.build index 23d8baa07e57..48988202d267 100644 --- a/dom/network/interfaces/moz.build +++ b/dom/network/interfaces/moz.build @@ -22,10 +22,14 @@ if CONFIG['MOZ_B2G_RIL']: 'nsIDOMMobileConnection.idl', 'nsIDOMMozEmergencyCbModeEvent.idl', 'nsIDOMMozOtaStatusEvent.idl', - 'nsIDOMNetworkStats.idl', - 'nsIDOMNetworkStatsManager.idl', 'nsIDOMUSSDReceivedEvent.idl', 'nsIMobileConnectionProvider.idl', + ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + XPIDL_SOURCES += [ + 'nsIDOMNetworkStats.idl', + 'nsIDOMNetworkStatsManager.idl', 'nsINetworkStatsServiceProxy.idl', ] diff --git a/dom/network/src/moz.build b/dom/network/src/moz.build index e945b41d134d..a18122a6d083 100644 --- a/dom/network/src/moz.build +++ b/dom/network/src/moz.build @@ -28,6 +28,8 @@ if CONFIG['MOZ_B2G_RIL']: SOURCES += [ 'MobileConnection.cpp', ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': EXTRA_JS_MODULES = [ 'NetworkStatsDB.jsm', 'NetworkStatsService.jsm', @@ -43,7 +45,7 @@ EXTRA_PP_COMPONENTS += [ 'TCPSocket.js', ] -if CONFIG['MOZ_B2G_RIL']: +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': EXTRA_COMPONENTS += [ 'NetworkStatsManager.js', 'NetworkStatsManager.manifest', diff --git a/dom/network/tests/Makefile.in b/dom/network/tests/Makefile.in index 52fcdb65ce1a..cc1bd18cacb1 100644 --- a/dom/network/tests/Makefile.in +++ b/dom/network/tests/Makefile.in @@ -9,7 +9,7 @@ MOCHITEST_FILES = \ test_tcpsocket_enabled_with_perm.html \ $(NULL) -ifdef MOZ_B2G_RIL +ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) MOCHITEST_FILES = \ test_networkstats_basics.html \ test_networkstats_disabled.html \ diff --git a/dom/system/gonk/NetworkManager.js b/dom/system/gonk/NetworkManager.js index 291a20736f52..b2c30e195951 100644 --- a/dom/system/gonk/NetworkManager.js +++ b/dom/system/gonk/NetworkManager.js @@ -133,8 +133,10 @@ function defineLazyRegExp(obj, name, pattern) { function NetworkManager() { this.networkInterfaces = {}; Services.obs.addObserver(this, TOPIC_INTERFACE_STATE_CHANGED, true); +#ifdef MOZ_B2G_RIL Services.obs.addObserver(this, TOPIC_INTERFACE_REGISTERED, true); Services.obs.addObserver(this, TOPIC_INTERFACE_UNREGISTERED, true); +#endif Services.obs.addObserver(this, TOPIC_XPCOM_SHUTDOWN, false); Services.obs.addObserver(this, TOPIC_MOZSETTINGS_CHANGED, false); @@ -229,6 +231,7 @@ NetworkManager.prototype = { debug("Network " + network.name + " changed state to " + network.state); switch (network.state) { case Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED: +#ifdef MOZ_B2G_RIL // Add host route for data calls if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || @@ -238,16 +241,19 @@ NetworkManager.prototype = { } // Add extra host route. For example, mms proxy or mmsc. this.setExtraHostRoute(network); +#endif // Remove pre-created default route and let setAndConfigureActive() // to set default route only on preferred network this.removeDefaultRoute(network.name); this.setAndConfigureActive(); +#ifdef MOZ_B2G_RIL // Update data connection when Wifi connected/disconnected if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { for (let i = 0; i < this.mRIL.numRadioInterfaces; i++) { this.mRIL.getRadioInterface(i).updateRILNetworkInterface(); } } +#endif this.onConnectionChanged(network); @@ -255,6 +261,7 @@ NetworkManager.prototype = { CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_CONNECT, this.active); break; case Ci.nsINetworkInterface.NETWORK_STATE_DISCONNECTED: +#ifdef MOZ_B2G_RIL // Remove host route for data calls if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || @@ -263,24 +270,30 @@ NetworkManager.prototype = { } // Remove extra host route. For example, mms proxy or mmsc. this.removeExtraHostRoute(network); +#endif // Remove routing table in /proc/net/route if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { this.resetRoutingTable(network); +#ifdef MOZ_B2G_RIL } else if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { this.removeDefaultRoute(network.name); +#endif } // Abort ongoing captive portal detection on the wifi interface CaptivePortalDetectionHelper.notify(CaptivePortalDetectionHelper.EVENT_DISCONNECT, network); this.setAndConfigureActive(); +#ifdef MOZ_B2G_RIL // Update data connection when Wifi connected/disconnected if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { for (let i = 0; i < this.mRIL.numRadioInterfaces; i++) { this.mRIL.getRadioInterface(i).updateRILNetworkInterface(); } } +#endif break; } break; +#ifdef MOZ_B2G_RIL case TOPIC_INTERFACE_REGISTERED: let regNetwork = subject.QueryInterface(Ci.nsINetworkInterface); // Add extra host route. For example, mms proxy or mmsc. @@ -291,6 +304,7 @@ NetworkManager.prototype = { // Remove extra host route. For example, mms proxy or mmsc. this.removeExtraHostRoute(unregNetwork); break; +#endif case TOPIC_MOZSETTINGS_CHANGED: let setting = JSON.parse(data); this.handle(setting.key, setting.value); @@ -303,8 +317,10 @@ NetworkManager.prototype = { case TOPIC_XPCOM_SHUTDOWN: Services.obs.removeObserver(this, TOPIC_XPCOM_SHUTDOWN); Services.obs.removeObserver(this, TOPIC_MOZSETTINGS_CHANGED); +#ifdef MOZ_B2G_RIL Services.obs.removeObserver(this, TOPIC_INTERFACE_REGISTERED); Services.obs.removeObserver(this, TOPIC_INTERFACE_UNREGISTERED); +#endif Services.obs.removeObserver(this, TOPIC_INTERFACE_STATE_CHANGED); break; } @@ -313,15 +329,19 @@ NetworkManager.prototype = { receiveMessage: function receiveMessage(aMsg) { switch (aMsg.name) { case "NetworkInterfaceList:ListInterface": { +#ifdef MOZ_B2G_RIL let excludeMms = aMsg.json.exculdeMms; let excludeSupl = aMsg.json.exculdeSupl; +#endif let interfaces = []; for each (let i in this.networkInterfaces) { +#ifdef MOZ_B2G_RIL if ((i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS && excludeMms) || (i.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL && excludeSupl)) { continue; } +#endif interfaces.push({ state: i.state, type: i.type, @@ -353,12 +373,14 @@ NetworkManager.prototype = { Cr.NS_ERROR_INVALID_ARG); } this.networkInterfaces[network.name] = network; +#ifdef MOZ_B2G_RIL // Add host route for data calls if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { this.addHostRoute(network); } +#endif // Remove pre-created default route and let setAndConfigureActive() // to set default route only on preferred network this.removeDefaultRoute(network.name); @@ -377,12 +399,14 @@ NetworkManager.prototype = { Cr.NS_ERROR_INVALID_ARG); } delete this.networkInterfaces[network.name]; +#ifdef MOZ_B2G_RIL // Remove host route for data calls if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { this.removeHostRoute(network); } +#endif this.setAndConfigureActive(); Services.obs.notifyObservers(network, TOPIC_INTERFACE_UNREGISTERED, null); debug("Network '" + network.name + "' unregistered."); @@ -397,8 +421,12 @@ NetworkManager.prototype = { return this._preferredNetworkType; }, set preferredNetworkType(val) { +#ifdef MOZ_B2G_RIL if ([Ci.nsINetworkInterface.NETWORK_TYPE_WIFI, Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE].indexOf(val) == -1) { +#else + if (val != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI) { +#endif throw "Invalid network type"; } this._preferredNetworkType = val; @@ -411,10 +439,12 @@ NetworkManager.prototype = { _activeInfo: null, overrideActive: function overrideActive(network) { +#ifdef MOZ_B2G_RIL if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS || network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { throw "Invalid network type"; } +#endif this._overriddenActive = network; this.setAndConfigureActive(); }, @@ -486,6 +516,7 @@ NetworkManager.prototype = { } }, +#ifdef MOZ_B2G_RIL setExtraHostRoute: function setExtraHostRoute(network) { if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_MMS) { debug("Network '" + network.name + "' registered, adding mmsproxy and/or mmsc route"); @@ -505,6 +536,7 @@ NetworkManager.prototype = { this.removeHostRouteWithResolve(network, mmsHosts); } }, +#endif // MOZ_B2G_RIL /** * Determine the active interface and configure it. @@ -512,7 +544,6 @@ NetworkManager.prototype = { setAndConfigureActive: function setAndConfigureActive() { debug("Evaluating whether active network needs to be changed."); let oldActive = this.active; - let defaultDataNetwork; if (this._overriddenActive) { debug("We have an override for the active network: " + @@ -538,13 +569,18 @@ NetworkManager.prototype = { // Find a suitable network interface to activate. this.active = null; this._activeInfo = Object.create(null); +#ifdef MOZ_B2G_RIL + let defaultDataNetwork; +#endif for each (let network in this.networkInterfaces) { if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { continue; } +#ifdef MOZ_B2G_RIL if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { defaultDataNetwork = network; } +#endif this.active = network; this._activeInfo = {name:network.name, ip:network.ip, netmask:network.netmask}; if (network.type == this.preferredNetworkType) { @@ -553,6 +589,7 @@ NetworkManager.prototype = { } } if (this.active) { +#ifdef MOZ_B2G_RIL // Give higher priority to default data APN than seconary APN. // If default data APN is not connected, we still set default route // and DNS on seconary APN. @@ -567,8 +604,11 @@ NetworkManager.prototype = { this.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_SUPL) { this.setDNS(this.active); } else { +#endif // MOZ_B2G_RIL this.setDefaultRouteAndDNS(oldActive); +#ifdef MOZ_B2G_RIL } +#endif if (this.active != oldActive) { Services.obs.notifyObservers(this.active, TOPIC_ACTIVE_CHANGED, null); } @@ -593,6 +633,7 @@ NetworkManager.prototype = { this.worker.postMessage(options); }, +#ifdef MOZ_B2G_RIL setDNS: function setDNS(networkInterface) { debug("Going DNS to " + networkInterface.name); let options = { @@ -603,6 +644,7 @@ NetworkManager.prototype = { }; this.worker.postMessage(options); }, +#endif setDefaultRouteAndDNS: function setDefaultRouteAndDNS(oldInterface) { debug("Going to change route and DNS to " + this.active.name); @@ -627,6 +669,7 @@ NetworkManager.prototype = { this.worker.postMessage(options); }, +#ifdef MOZ_B2G_RIL addHostRoute: function addHostRoute(network) { debug("Going to add host route on " + network.name); let options = { @@ -706,6 +749,7 @@ NetworkManager.prototype = { }; this.worker.postMessage(options); }, +#endif // MOZ_B2G_RIL setNetworkProxy: function setNetworkProxy(network) { try { @@ -1224,9 +1268,11 @@ let CaptivePortalDetectionHelper = (function() { }; }()); +#ifdef MOZ_B2G_RIL XPCOMUtils.defineLazyServiceGetter(NetworkManager.prototype, "mRIL", "@mozilla.org/ril;1", "nsIRadioInterfaceLayer"); +#endif this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkManager]); diff --git a/dom/system/gonk/SystemWorkerManager.cpp b/dom/system/gonk/SystemWorkerManager.cpp index a3dd23cef4b6..637760689d36 100644 --- a/dom/system/gonk/SystemWorkerManager.cpp +++ b/dom/system/gonk/SystemWorkerManager.cpp @@ -24,13 +24,13 @@ #include "jsfriendapi.h" #include "mozilla/dom/workers/Workers.h" -#ifdef MOZ_WIDGET_GONK #include "mozilla/ipc/Netd.h" #include "AutoMounter.h" #include "TimeZoneSettingObserver.h" #include "AudioManager.h" -#endif +#ifdef MOZ_B2G_RIL #include "mozilla/ipc/Ril.h" +#endif #include "mozilla/ipc/KeyStore.h" #include "nsIObserverService.h" #include "nsCxPusher.h" @@ -44,9 +44,7 @@ USING_WORKERS_NAMESPACE using namespace mozilla::dom::gonk; using namespace mozilla::ipc; -#ifdef MOZ_WIDGET_GONK using namespace mozilla::system; -#endif #define NS_NETWORKMANAGER_CID \ { 0x33901e46, 0x33b8, 0x11e1, \ @@ -60,107 +58,6 @@ NS_DEFINE_CID(kNetworkManagerCID, NS_NETWORKMANAGER_CID); // Doesn't carry a reference, we're owned by services. SystemWorkerManager *gInstance = nullptr; -class ConnectWorkerToRIL : public WorkerTask -{ -public: - ConnectWorkerToRIL() - { } - - virtual bool RunTask(JSContext *aCx); -}; - -class SendRilSocketDataTask : public nsRunnable -{ -public: - SendRilSocketDataTask(unsigned long aClientId, - UnixSocketRawData *aRawData) - : mRawData(aRawData) - , mClientId(aClientId) - { } - - NS_IMETHOD Run() - { - MOZ_ASSERT(NS_IsMainThread()); - SystemWorkerManager::SendRilRawData(mClientId, mRawData); - return NS_OK; - } - -private: - UnixSocketRawData *mRawData; - unsigned long mClientId; -}; - -bool -PostToRIL(JSContext *cx, unsigned argc, JS::Value *vp) -{ - NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread"); - - if (argc != 2) { - JS_ReportError(cx, "Expecting two arguments with the RIL message"); - return false; - } - - JS::Value cv = JS_ARGV(cx, vp)[0]; - int clientId = cv.toInt32(); - - JS::Value v = JS_ARGV(cx, vp)[1]; - - JSAutoByteString abs; - void *data; - size_t size; - if (JSVAL_IS_STRING(v)) { - JSString *str = JSVAL_TO_STRING(v); - if (!abs.encodeUtf8(cx, str)) { - return false; - } - - data = abs.ptr(); - size = abs.length(); - } else if (!JSVAL_IS_PRIMITIVE(v)) { - JSObject *obj = JSVAL_TO_OBJECT(v); - if (!JS_IsTypedArrayObject(obj)) { - JS_ReportError(cx, "Object passed in wasn't a typed array"); - return false; - } - - uint32_t type = JS_GetArrayBufferViewType(obj); - if (type != js::ArrayBufferView::TYPE_INT8 && - type != js::ArrayBufferView::TYPE_UINT8 && - type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) { - JS_ReportError(cx, "Typed array data is not octets"); - return false; - } - - size = JS_GetTypedArrayByteLength(obj); - data = JS_GetArrayBufferViewData(obj); - } else { - JS_ReportError(cx, - "Incorrect argument. Expecting a string or a typed array"); - return false; - } - - UnixSocketRawData* raw = new UnixSocketRawData(data, size); - - nsRefPtr task = new SendRilSocketDataTask(clientId, raw); - NS_DispatchToMainThread(task); - return true; -} - -bool -ConnectWorkerToRIL::RunTask(JSContext *aCx) -{ - // Set up the postRILMessage on the function for worker -> RIL thread - // communication. - NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread"); - NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?"); - JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx); - - return !!JS_DefineFunction(aCx, workerGlobal, "postRILMessage", PostToRIL, 1, - 0); -} - -#ifdef MOZ_WIDGET_GONK - bool DoNetdCommand(JSContext *cx, unsigned argc, JS::Value *vp) { @@ -306,8 +203,6 @@ NetdReceiver::DispatchNetdEvent::RunTask(JSContext *aCx) argv, argv); } -#endif // MOZ_WIDGET_GONK - } // anonymous namespace SystemWorkerManager::SystemWorkerManager() @@ -345,14 +240,12 @@ SystemWorkerManager::Init() InitKeyStore(cx); -#ifdef MOZ_WIDGET_GONK InitAutoMounter(); InitializeTimeZoneSettingObserver(); rv = InitNetd(cx); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr audioManager = do_GetService(NS_AUDIOMANAGER_CONTRACTID); -#endif nsCOMPtr obs = mozilla::services::GetObserverService(); if (!obs) { @@ -376,21 +269,14 @@ SystemWorkerManager::Shutdown() mShutdown = true; -#ifdef MOZ_WIDGET_GONK ShutdownAutoMounter(); + +#ifdef MOZ_B2G_RIL + RilConsumer::Shutdown(); #endif - for (unsigned long i = 0; i < mRilConsumers.Length(); i++) { - if (mRilConsumers[i]) { - mRilConsumers[i]->Shutdown(); - mRilConsumers[i] = nullptr; - } - } - -#ifdef MOZ_WIDGET_GONK StopNetd(); mNetdWorker = nullptr; -#endif nsCOMPtr wifi(do_QueryInterface(mWifiWorker)); if (wifi) { @@ -433,20 +319,6 @@ SystemWorkerManager::GetInterfaceRequestor() return gInstance; } -bool -SystemWorkerManager::SendRilRawData(unsigned long aClientId, - UnixSocketRawData* aRaw) -{ - if ((gInstance->mRilConsumers.Length() <= aClientId) || - !gInstance->mRilConsumers[aClientId] || - gInstance->mRilConsumers[aClientId]->GetConnectionStatus() != SOCKET_CONNECTED) { - // Probably shuting down. - delete aRaw; - return true; - } - return gInstance->mRilConsumers[aClientId]->SendSocketData(aRaw); -} - NS_IMETHODIMP SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult) { @@ -457,12 +329,10 @@ SystemWorkerManager::GetInterface(const nsIID &aIID, void **aResult) reinterpret_cast(aResult)); } -#ifdef MOZ_WIDGET_GONK if (aIID.Equals(NS_GET_IID(nsINetworkManager))) { return CallQueryInterface(mNetdWorker, reinterpret_cast(aResult)); } -#endif NS_WARNING("Got nothing for the requested IID!"); return NS_ERROR_NO_INTERFACE; @@ -473,15 +343,11 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId, const JS::Value& aWorker, JSContext *aCx) { +#ifndef MOZ_B2G_RIL + return NS_ERROR_NOT_IMPLEMENTED; +#else NS_ENSURE_TRUE(!JSVAL_IS_PRIMITIVE(aWorker), NS_ERROR_UNEXPECTED); - mRilConsumers.EnsureLengthAtLeast(aClientId + 1); - - if (mRilConsumers[aClientId]) { - NS_WARNING("RilConsumer already registered"); - return NS_ERROR_FAILURE; - } - JSAutoCompartment ac(aCx, JSVAL_TO_OBJECT(aWorker)); WorkerCrossThreadDispatcher *wctd = @@ -491,18 +357,10 @@ SystemWorkerManager::RegisterRilWorker(unsigned int aClientId, return NS_ERROR_FAILURE; } - nsRefPtr connection = new ConnectWorkerToRIL(); - if (!wctd->PostTask(connection)) { - NS_WARNING("Failed to connect worker to ril"); - return NS_ERROR_UNEXPECTED; - } - - // Now that we're set up, connect ourselves to the RIL thread. - mRilConsumers[aClientId] = new RilConsumer(aClientId, wctd); - return NS_OK; + return RilConsumer::Register(aClientId, wctd); +#endif // MOZ_B2G_RIL } -#ifdef MOZ_WIDGET_GONK nsresult SystemWorkerManager::InitNetd(JSContext *cx) { @@ -535,7 +393,6 @@ SystemWorkerManager::InitNetd(JSContext *cx) mNetdWorker = worker; return NS_OK; } -#endif nsresult SystemWorkerManager::InitWifi(JSContext *cx) diff --git a/dom/system/gonk/SystemWorkerManager.h b/dom/system/gonk/SystemWorkerManager.h index 0198e6584b04..1562a80eb758 100644 --- a/dom/system/gonk/SystemWorkerManager.h +++ b/dom/system/gonk/SystemWorkerManager.h @@ -23,18 +23,13 @@ #include "nsIObserver.h" #include "nsAutoPtr.h" #include "nsCOMPtr.h" -#include "nsDebug.h" -#include "nsDOMEventTargetHelper.h" -#include "nsString.h" -#include "nsTArray.h" +#include "nsXULAppAPI.h" // For XRE_GetProcessType class nsIWorkerHolder; namespace mozilla { namespace ipc { - class RilConsumer; - class UnixSocketRawData; class KeyStore; } @@ -60,25 +55,17 @@ public: static nsIInterfaceRequestor* GetInterfaceRequestor(); - static bool SendRilRawData(unsigned long aClientId, - ipc::UnixSocketRawData* aRaw); - private: SystemWorkerManager(); ~SystemWorkerManager(); -#ifdef MOZ_WIDGET_GONK nsresult InitNetd(JSContext *cx); -#endif nsresult InitWifi(JSContext *cx); nsresult InitKeyStore(JSContext *cx); -#ifdef MOZ_WIDGET_GONK nsCOMPtr mNetdWorker; -#endif nsCOMPtr mWifiWorker; - nsTArray > mRilConsumers; nsRefPtr mKeyStore; bool mShutdown; diff --git a/dom/system/gonk/moz.build b/dom/system/gonk/moz.build index 2e5eebbec690..62691d779805 100644 --- a/dom/system/gonk/moz.build +++ b/dom/system/gonk/moz.build @@ -18,7 +18,6 @@ XPIDL_SOURCES += [ 'nsIAudioManager.idl', 'nsINetworkInterfaceListService.idl', 'nsINetworkManager.idl', - 'nsIRadioInterfaceLayer.idl', 'nsISystemWorkerManager.idl', 'nsIVolume.idl', 'nsIVolumeMountLock.idl', @@ -31,55 +30,61 @@ XPIDL_MODULE = 'dom_system_gonk' MODULE = 'dom' -if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - EXPORTS += [ - 'GonkGPSGeolocationProvider.h', - 'nsVolume.h', - 'nsVolumeService.h', - ] - SOURCES += [ - 'AudioChannelManager.cpp', - 'AudioManager.cpp', - 'AutoMounter.cpp', - 'AutoMounterSetting.cpp', - 'GonkGPSGeolocationProvider.cpp', - 'nsVolume.cpp', - 'nsVolumeMountLock.cpp', - 'nsVolumeService.cpp', - 'nsVolumeStat.cpp', - 'OpenFileFinder.cpp', - 'TimeZoneSettingObserver.cpp', - 'Volume.cpp', - 'VolumeCommand.cpp', - 'VolumeManager.cpp', - 'VolumeServiceIOThread.cpp', - 'VolumeServiceTest.cpp', - ] +EXPORTS += [ + 'GonkGPSGeolocationProvider.h', + 'nsVolume.h', + 'nsVolumeService.h', +] +SOURCES += [ + 'AudioChannelManager.cpp', + 'AudioManager.cpp', + 'AutoMounter.cpp', + 'AutoMounterSetting.cpp', + 'GonkGPSGeolocationProvider.cpp', + 'nsVolume.cpp', + 'nsVolumeMountLock.cpp', + 'nsVolumeService.cpp', + 'nsVolumeStat.cpp', + 'OpenFileFinder.cpp', + 'SystemWorkerManager.cpp', + 'TimeZoneSettingObserver.cpp', + 'Volume.cpp', + 'VolumeCommand.cpp', + 'VolumeManager.cpp', + 'VolumeServiceIOThread.cpp', + 'VolumeServiceTest.cpp', +] if CONFIG['ENABLE_TESTS']: XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell.ini'] -SOURCES += [ - 'SystemWorkerManager.cpp', -] - EXTRA_COMPONENTS += [ 'NetworkInterfaceListService.js', 'NetworkInterfaceListService.manifest', - 'NetworkManager.js', 'NetworkManager.manifest', - 'RadioInterfaceLayer.js', - 'RadioInterfaceLayer.manifest', - 'RILContentHelper.js', ] - +EXTRA_PP_COMPONENTS += [ + 'NetworkManager.js', +] EXTRA_JS_MODULES += [ 'net_worker.js', - 'ril_consts.js', - 'ril_worker.js', 'systemlibs.js', ] +if CONFIG['MOZ_B2G_RIL']: + XPIDL_SOURCES += [ + 'nsIRadioInterfaceLayer.idl', + ] + EXTRA_COMPONENTS += [ + 'RadioInterfaceLayer.js', + 'RadioInterfaceLayer.manifest', + 'RILContentHelper.js', + ] + EXTRA_JS_MODULES += [ + 'ril_consts.js', + 'ril_worker.js', + ] + FAIL_ON_WARNINGS = True LIBXUL_LIBRARY = True diff --git a/dom/system/moz.build b/dom/system/moz.build index af8338848c99..8eaabb305fa4 100644 --- a/dom/system/moz.build +++ b/dom/system/moz.build @@ -14,8 +14,7 @@ elif toolkit == 'cocoa': DIRS += ['mac'] elif toolkit == 'android': DIRS += ['android'] - -if CONFIG['MOZ_B2G_RIL']: +elif toolkit == 'gonk': DIRS += ['gonk'] TEST_DIRS += ['tests'] diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 0eb3127549da..147659dcafeb 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -514,9 +514,13 @@ if CONFIG['MOZ_B2G_RIL']: 'MozStkCommandEvent.webidl', 'MozVoicemail.webidl', 'MozVoicemailEvent.webidl', + 'USSDReceivedEvent.webidl', + ] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + WEBIDL_FILES += [ 'MozWifiConnectionInfoEvent.webidl', 'MozWifiStatusChangeEvent.webidl', - 'USSDReceivedEvent.webidl', ] if CONFIG['MOZ_WEBSPEECH']: diff --git a/ipc/moz.build b/ipc/moz.build index 7b9711ced124..1dc549316dae 100644 --- a/ipc/moz.build +++ b/ipc/moz.build @@ -17,10 +17,10 @@ if CONFIG['MOZ_B2G_RIL']: if CONFIG['MOZ_B2G_BT_BLUEZ']: DIRS += ['dbus'] -if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT']: - DIRS += ['unixsocket', 'keystore'] +if CONFIG['MOZ_B2G_RIL'] or CONFIG['MOZ_B2G_BT'] or CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + DIRS += ['unixsocket'] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - DIRS += ['netd'] + DIRS += ['netd', 'keystore'] TOOL_DIRS += ['app'] diff --git a/ipc/ril/Ril.cpp b/ipc/ril/Ril.cpp index 3dc8e0a8be82..c0bc05446f1d 100644 --- a/ipc/ril/Ril.cpp +++ b/ipc/ril/Ril.cpp @@ -4,6 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "mozilla/ipc/Ril.h" + #include #include #include @@ -18,8 +20,8 @@ #endif #include "jsfriendapi.h" +#include "nsTArray.h" #include "nsThreadUtils.h" // For NS_IsMainThread. -#include "Ril.h" USING_WORKERS_NAMESPACE using namespace mozilla::ipc; @@ -32,17 +34,130 @@ const char* RIL_SOCKET_NAME = "/dev/socket/rilproxy"; // desktop development. const uint32_t RIL_TEST_PORT = 6200; -class DispatchRILEvent : public WorkerTask +nsTArray > sRilConsumers; + +class ConnectWorkerToRIL : public WorkerTask { public: - DispatchRILEvent(UnixSocketRawData* aMessage) - : mMessage(aMessage) + ConnectWorkerToRIL() { } virtual bool RunTask(JSContext *aCx); +}; + +class SendRilSocketDataTask : public nsRunnable +{ +public: + SendRilSocketDataTask(unsigned long aClientId, + UnixSocketRawData *aRawData) + : mRawData(aRawData) + , mClientId(aClientId) + { } + + NS_IMETHOD Run() + { + MOZ_ASSERT(NS_IsMainThread()); + + if (sRilConsumers.Length() <= mClientId || + !sRilConsumers[mClientId] || + sRilConsumers[mClientId]->GetConnectionStatus() != SOCKET_CONNECTED) { + // Probably shuting down. + delete mRawData; + return NS_OK; + } + + sRilConsumers[mClientId]->SendSocketData(mRawData); + return NS_OK; + } private: - nsAutoPtr mMessage; + UnixSocketRawData *mRawData; + unsigned long mClientId; +}; + +bool +PostToRIL(JSContext *aCx, + unsigned aArgc, + JS::Value *aArgv) +{ + NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread"); + + if (aArgc != 2) { + JS_ReportError(aCx, "Expecting two arguments with the RIL message"); + return false; + } + + JS::Value cv = JS_ARGV(aCx, aArgv)[0]; + int clientId = cv.toInt32(); + + JS::Value v = JS_ARGV(aCx, aArgv)[1]; + + JSAutoByteString abs; + void *data; + size_t size; + if (JSVAL_IS_STRING(v)) { + JSString *str = JSVAL_TO_STRING(v); + if (!abs.encodeUtf8(aCx, str)) { + return false; + } + + data = abs.ptr(); + size = abs.length(); + } else if (!JSVAL_IS_PRIMITIVE(v)) { + JSObject *obj = JSVAL_TO_OBJECT(v); + if (!JS_IsTypedArrayObject(obj)) { + JS_ReportError(aCx, "Object passed in wasn't a typed array"); + return false; + } + + uint32_t type = JS_GetArrayBufferViewType(obj); + if (type != js::ArrayBufferView::TYPE_INT8 && + type != js::ArrayBufferView::TYPE_UINT8 && + type != js::ArrayBufferView::TYPE_UINT8_CLAMPED) { + JS_ReportError(aCx, "Typed array data is not octets"); + return false; + } + + size = JS_GetTypedArrayByteLength(obj); + data = JS_GetArrayBufferViewData(obj); + } else { + JS_ReportError(aCx, + "Incorrect argument. Expecting a string or a typed array"); + return false; + } + + UnixSocketRawData* raw = new UnixSocketRawData(data, size); + + nsRefPtr task = + new SendRilSocketDataTask(clientId, raw); + NS_DispatchToMainThread(task); + return true; +} + +bool +ConnectWorkerToRIL::RunTask(JSContext *aCx) +{ + // Set up the postRILMessage on the function for worker -> RIL thread + // communication. + NS_ASSERTION(!NS_IsMainThread(), "Expecting to be on the worker thread"); + NS_ASSERTION(!JS_IsRunning(aCx), "Are we being called somehow?"); + JSObject *workerGlobal = JS::CurrentGlobalOrNull(aCx); + + return !!JS_DefineFunction(aCx, workerGlobal, + "postRILMessage", PostToRIL, 1, 0); +} + +class DispatchRILEvent : public WorkerTask +{ +public: + DispatchRILEvent(UnixSocketRawData* aMessage) + : mMessage(aMessage) + { } + + virtual bool RunTask(JSContext *aCx); + +private: + nsAutoPtr mMessage; }; bool @@ -192,11 +307,45 @@ RilConsumer::RilConsumer(unsigned long aClientId, ConnectSocket(new RilConnector(mClientId), mAddress.get()); } +nsresult +RilConsumer::Register(unsigned int aClientId, + WorkerCrossThreadDispatcher* aDispatcher) +{ + MOZ_ASSERT(NS_IsMainThread()); + + sRilConsumers.EnsureLengthAtLeast(aClientId + 1); + + if (sRilConsumers[aClientId]) { + NS_WARNING("RilConsumer already registered"); + return NS_ERROR_FAILURE; + } + + nsRefPtr connection = new ConnectWorkerToRIL(); + if (!aDispatcher->PostTask(connection)) { + NS_WARNING("Failed to connect worker to ril"); + return NS_ERROR_UNEXPECTED; + } + + // Now that we're set up, connect ourselves to the RIL thread. + sRilConsumers[aClientId] = new RilConsumer(aClientId, aDispatcher); + return NS_OK; +} + void RilConsumer::Shutdown() { - mShutdown = true; - CloseSocket(); + MOZ_ASSERT(NS_IsMainThread()); + + for (unsigned long i = 0; i < sRilConsumers.Length(); i++) { + nsRefPtr& instance = sRilConsumers[i]; + if (!instance) { + continue; + } + + instance->mShutdown = true; + instance->CloseSocket(); + instance = nullptr; + } } void @@ -212,20 +361,20 @@ void RilConsumer::OnConnectSuccess() { // Nothing to do here. - LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__); + LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__); } void RilConsumer::OnConnectError() { - LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__); + LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__); CloseSocket(); } void RilConsumer::OnDisconnect() { - LOG("RIL[%u]: %s\n", mClientId, __FUNCTION__); + LOG("RIL[%lu]: %s\n", mClientId, __FUNCTION__); if (!mShutdown) { ConnectSocket(new RilConnector(mClientId), mAddress.get(), 1000); } diff --git a/ipc/ril/Ril.h b/ipc/ril/Ril.h index bb4d1c7daee6..ce294a412ce9 100644 --- a/ipc/ril/Ril.h +++ b/ipc/ril/Ril.h @@ -16,13 +16,16 @@ namespace ipc { class RilConsumer : public mozilla::ipc::UnixSocketConsumer { public: - RilConsumer(unsigned long aClientId, - mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher); virtual ~RilConsumer() { } - void Shutdown(); + static nsresult Register(unsigned int aClientId, + mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher); + static void Shutdown(); private: + RilConsumer(unsigned long aClientId, + mozilla::dom::workers::WorkerCrossThreadDispatcher* aDispatcher); + virtual void ReceiveSocketData(nsAutoPtr& aMessage); virtual void OnConnectSuccess(); diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index a60017c1f68a..cc93ee6a5880 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -23,6 +23,10 @@ simple_events = [ 'StyleRuleChangeEvent', 'StyleSheetChangeEvent', 'StyleSheetApplicableStateChangeEvent', +#ifdef MOZ_WIDGET_GONK + 'MozWifiStatusChangeEvent', + 'MozWifiConnectionInfoEvent', +#endif #ifdef MOZ_B2G_BT 'BluetoothDeviceEvent', 'BluetoothStatusChangedEvent', @@ -32,8 +36,6 @@ simple_events = [ 'DataErrorEvent', 'MozEmergencyCbModeEvent', 'MozOtaStatusEvent', - 'MozWifiStatusChangeEvent', - 'MozWifiConnectionInfoEvent', 'MozCellBroadcastEvent', 'MozVoicemailEvent', 'USSDReceivedEvent', diff --git a/layout/build/Makefile.in b/layout/build/Makefile.in index 07b22ec4293c..972012f0f2c0 100644 --- a/layout/build/Makefile.in +++ b/layout/build/Makefile.in @@ -127,9 +127,14 @@ endif #} SHARED_LIBRARY_LIBS += $(DEPTH)/dom/camera/$(LIB_PREFIX)domcamera_s.$(LIB_SUFFIX) -ifdef MOZ_B2G_RIL #{ +ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) SHARED_LIBRARY_LIBS += \ $(DEPTH)/dom/system/gonk/$(LIB_PREFIX)domsystemgonk_s.$(LIB_SUFFIX) \ + $(NULL) +endif #} + +ifdef MOZ_B2G_RIL #{ +SHARED_LIBRARY_LIBS += \ $(DEPTH)/dom/icc/src/$(LIB_PREFIX)dom_icc_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/cellbroadcast/src/$(LIB_PREFIX)dom_cellbroadcast_s.$(LIB_SUFFIX) \ $(DEPTH)/dom/voicemail/$(LIB_PREFIX)domvoicemail_s.$(LIB_SUFFIX) \ @@ -326,7 +331,7 @@ ifdef MOZ_GSTREAMER LOCAL_INCLUDES += $(GSTREAMER_CFLAGS) endif -ifdef MOZ_B2G_RIL #{ +ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) LOCAL_INCLUDES += -I$(topsrcdir)/dom/system/gonk endif #} diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 53e33d9b87c6..1c144b0c2191 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -101,7 +101,7 @@ #include "mozilla/dom/nsSynthVoiceRegistry.h" #endif -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK #include "SystemWorkerManager.h" using mozilla::dom::gonk::SystemWorkerManager; #define SYSTEMWORKERMANAGER_CID \ @@ -288,7 +288,7 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService, DOMRequestService::FactoryCreate) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManager, QuotaManager::FactoryCreate) -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager, SystemWorkerManager::FactoryCreate) #endif @@ -754,7 +754,7 @@ NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID); NS_DEFINE_NAMED_CID(INDEXEDDB_MANAGER_CID); NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID); NS_DEFINE_NAMED_CID(QUOTA_MANAGER_CID); -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID); #endif #ifdef MOZ_B2G_BT @@ -1043,7 +1043,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &kINDEXEDDB_MANAGER_CID, false, nullptr, IndexedDatabaseManagerConstructor }, { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor }, { &kQUOTA_MANAGER_CID, false, nullptr, QuotaManagerConstructor }, -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK { &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor }, #endif #ifdef MOZ_B2G_BT @@ -1201,7 +1201,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { INDEXEDDB_MANAGER_CONTRACTID, &kINDEXEDDB_MANAGER_CID }, { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID }, { QUOTA_MANAGER_CONTRACTID, &kQUOTA_MANAGER_CID }, -#ifdef MOZ_B2G_RIL +#ifdef MOZ_WIDGET_GONK { SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID }, #endif #ifdef MOZ_B2G_BT @@ -1286,8 +1286,8 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = { { "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID }, #endif CONTENTDLF_CATEGORIES -#ifdef MOZ_B2G_RIL - { "profile-after-change", "Telephony System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID }, +#ifdef MOZ_WIDGET_GONK + { "profile-after-change", "Gonk System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID }, #endif #ifdef MOZ_B2G_BT { "profile-after-change", "Bluetooth Service", BLUETOOTHSERVICE_CONTRACTID }, diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 7f923e15d782..004f8b7e29c6 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -96,12 +96,12 @@ OS_LIBS += -ldbus endif endif #} -ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)),) #{ -STATIC_LIBS += mozipcunixsocket_s mozkeystore_s +ifneq ($(strip $(MOZ_B2G_RIL)$(MOZ_B2G_BT)$(filter gonk,$(MOZ_WIDGET_TOOLKIT))),) #{ +STATIC_LIBS += mozipcunixsocket_s endif #} ifeq (gonk,$(MOZ_WIDGET_TOOLKIT)) -STATIC_LIBS += moznetd_s +STATIC_LIBS += moznetd_s mozkeystore_s endif ifdef MOZ_B2G_CAMERA #{ From ecd052d94fadba643cfbac9efe35eec347ddf21f Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:46 +0800 Subject: [PATCH 271/795] Bug 920551 - 2.i/2: fix Bluetooth. r=echou --- dom/bluetooth/BluetoothAdapter.cpp | 15 +++++ dom/bluetooth/BluetoothHfpManager.cpp | 65 +++++++++++++++++-- dom/bluetooth/BluetoothHfpManager.h | 29 +++++++++ dom/bluetooth/BluetoothService.h | 2 + dom/bluetooth/ipc/BluetoothParent.cpp | 4 ++ dom/bluetooth/ipc/BluetoothParent.h | 2 + .../ipc/BluetoothServiceChildProcess.cpp | 2 + .../ipc/BluetoothServiceChildProcess.h | 2 + dom/bluetooth/linux/BluetoothDBusService.cpp | 2 + dom/bluetooth/linux/BluetoothDBusService.h | 2 + 10 files changed, 120 insertions(+), 5 deletions(-) diff --git a/dom/bluetooth/BluetoothAdapter.cpp b/dom/bluetooth/BluetoothAdapter.cpp index d12a5e4ce222..f602d2b1f3ab 100644 --- a/dom/bluetooth/BluetoothAdapter.cpp +++ b/dom/bluetooth/BluetoothAdapter.cpp @@ -881,6 +881,7 @@ BluetoothAdapter::IsScoConnected(ErrorResult& aRv) already_AddRefed BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv) { +#ifdef MOZ_B2G_RIL nsCOMPtr win = GetOwner(); if (!win) { aRv.Throw(NS_ERROR_FAILURE); @@ -899,11 +900,16 @@ BluetoothAdapter::AnswerWaitingCall(ErrorResult& aRv) bs->AnswerWaitingCall(results); return request.forget(); +#else + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +#endif // MOZ_B2G_RIL } already_AddRefed BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv) { +#ifdef MOZ_B2G_RIL nsCOMPtr win = GetOwner(); if (!win) { aRv.Throw(NS_ERROR_FAILURE); @@ -922,11 +928,16 @@ BluetoothAdapter::IgnoreWaitingCall(ErrorResult& aRv) bs->IgnoreWaitingCall(results); return request.forget(); +#else + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +#endif // MOZ_B2G_RIL } already_AddRefed BluetoothAdapter::ToggleCalls(ErrorResult& aRv) { +#ifdef MOZ_B2G_RIL nsCOMPtr win = GetOwner(); if (!win) { aRv.Throw(NS_ERROR_FAILURE); @@ -945,6 +956,10 @@ BluetoothAdapter::ToggleCalls(ErrorResult& aRv) bs->ToggleCalls(results); return request.forget(); +#else + aRv.Throw(NS_ERROR_NOT_IMPLEMENTED); + return nullptr; +#endif // MOZ_B2G_RIL } already_AddRefed diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 95e33004ac68..5f3a61e061e2 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -15,19 +15,24 @@ #include "BluetoothUtils.h" #include "BluetoothUuid.h" -#include "MobileConnection.h" +#include "jsapi.h" #include "mozilla/dom/bluetooth/BluetoothTypes.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" #include "nsContentUtils.h" #include "nsIAudioManager.h" -#include "nsIDOMIccInfo.h" -#include "nsIIccProvider.h" #include "nsIObserverService.h" #include "nsISettingsService.h" +#include "nsServiceManagerUtils.h" + +#ifdef MOZ_B2G_RIL +#include "nsIDOMIccInfo.h" +#include "nsIDOMMobileConnection.h" +#include "nsIIccProvider.h" +#include "nsIMobileConnectionProvider.h" #include "nsITelephonyProvider.h" #include "nsRadioInterfaceLayer.h" -#include "nsServiceManagerUtils.h" +#endif /** * BRSF bitmask of AG supported features. See 4.34.1 "Bluetooth Defined AT @@ -44,6 +49,7 @@ #define BRSF_BIT_EXTENDED_ERR_RESULT_CODES (1 << 8) #define BRSF_BIT_CODEC_NEGOTIATION (1 << 9) +#ifdef MOZ_B2G_RIL /** * These constants are used in result code such as +CLIP and +CCWA. The value * of these constants is the same as TOA_INTERNATIONAL/TOA_UNKNOWN defined in @@ -51,6 +57,7 @@ */ #define TOA_UNKNOWN 0x81 #define TOA_INTERNATIONAL 0x91 +#endif #define CR_LF "\xd\xa"; @@ -66,6 +73,7 @@ namespace { bool sInShutdown = false; static const char kHfpCrlf[] = "\xd\xa"; +#ifdef MOZ_B2G_RIL // Sending ringtone related static bool sStopSendingRingFlag = true; static int sRingInterval = 3000; //unit: ms @@ -79,8 +87,10 @@ namespace { // The mechanism should be revised once we know the exact time at which // Dialer stops playing. static int sBusyToneInterval = 3700; //unit: ms +#endif // MOZ_B2G_RIL } // anonymous namespace +#ifdef MOZ_B2G_RIL /* CallState for sCINDItems[CINDType::CALL].value * - NO_CALL: there are no calls in progress * - IN_PROGRESS: at least one call is in progress @@ -113,6 +123,7 @@ enum CallHeldState { ONHOLD_ACTIVE, ONHOLD_NOACTIVE }; +#endif // MOZ_B2G_RIL typedef struct { const char* name; @@ -123,23 +134,27 @@ typedef struct { enum CINDType { BATTCHG = 1, +#ifdef MOZ_B2G_RIL CALL, CALLHELD, CALLSETUP, SERVICE, SIGNAL, ROAM +#endif }; static CINDItem sCINDItems[] = { {}, {"battchg", "0-5", 5, true}, +#ifdef MOZ_B2G_RIL {"call", "0,1", CallState::NO_CALL, true}, {"callheld", "0-2", CallHeldState::NO_CALLHELD, true}, {"callsetup", "0-3", CallSetupState::NO_CALLSETUP, true}, {"service", "0,1", 0, true}, {"signal", "0-5", 0, true}, {"roam", "0,1", 0, true} +#endif }; class BluetoothHfpManager::GetVolumeTask : public nsISettingsServiceCallback @@ -206,6 +221,7 @@ BluetoothHfpManager::Notify(const hal::BatteryInformation& aBatteryInfo) } } +#ifdef MOZ_B2G_RIL class BluetoothHfpManager::RespondToBLDNTask : public Task { private: @@ -265,6 +281,7 @@ private: nsString mNumber; int mType; }; +#endif // MOZ_B2G_RIL class BluetoothHfpManager::CloseScoTask : public Task { @@ -277,6 +294,7 @@ private: } }; +#ifdef MOZ_B2G_RIL static bool IsValidDtmf(const char aChar) { // Valid DTMF: [*#0-9ABCD] @@ -319,6 +337,7 @@ Call::IsActive() { return (mState == nsITelephonyProvider::CALL_STATE_CONNECTED); } +#endif // MOZ_B2G_RIL /** * BluetoothHfpManager @@ -328,6 +347,7 @@ BluetoothHfpManager::BluetoothHfpManager() : mController(nullptr) Reset(); } +#ifdef MOZ_B2G_RIL void BluetoothHfpManager::ResetCallArray() { @@ -341,25 +361,31 @@ BluetoothHfpManager::ResetCallArray() mCdmaSecondCall.Reset(); } } +#endif // MOZ_B2G_RIL void BluetoothHfpManager::Reset() { +#ifdef MOZ_B2G_RIL sStopSendingRingFlag = true; sCINDItems[CINDType::CALL].value = CallState::NO_CALL; sCINDItems[CINDType::CALLSETUP].value = CallSetupState::NO_CALLSETUP; sCINDItems[CINDType::CALLHELD].value = CallHeldState::NO_CALLHELD; +#endif for (uint8_t i = 1; i < ArrayLength(sCINDItems); i++) { sCINDItems[i].activated = true; } +#ifdef MOZ_B2G_RIL mCCWA = false; mCLIP = false; + mDialingRequestProcessed = true; +#endif mCMEE = false; mCMER = false; mReceiveVgsFlag = false; - mDialingRequestProcessed = true; +#ifdef MOZ_B2G_RIL // We disable BSIR by default as it requires OEM implement BT SCO + SPEAKER // output audio path in audio driver. OEM can enable BSIR by setting // mBSIR=true here. @@ -368,6 +394,7 @@ BluetoothHfpManager::Reset() mBSIR = false; ResetCallArray(); +#endif } bool @@ -386,11 +413,13 @@ BluetoothHfpManager::Init() hal::RegisterBatteryObserver(this); +#ifdef MOZ_B2G_RIL mListener = new BluetoothRilListener(); if (!mListener->StartListening()) { BT_WARNING("Failed to start listening RIL"); return false; } +#endif nsCOMPtr settings = do_GetService("@mozilla.org/settingsService;1"); @@ -417,10 +446,12 @@ BluetoothHfpManager::Init() BluetoothHfpManager::~BluetoothHfpManager() { +#ifdef MOZ_B2G_RIL if (!mListener->StopListening()) { BT_WARNING("Failed to stop listening RIL"); } mListener = nullptr; +#endif nsCOMPtr obs = services::GetObserverService(); NS_ENSURE_TRUE_VOID(obs); @@ -486,6 +517,7 @@ BluetoothHfpManager::NotifyConnectionStatusChanged(const nsAString& aType) DispatchStatusChangedEvent(eventName, mDeviceAddress, status); } +#ifdef MOZ_B2G_RIL void BluetoothHfpManager::NotifyDialer(const nsAString& aCommand) { @@ -502,6 +534,7 @@ BluetoothHfpManager::NotifyDialer(const nsAString& aCommand) BT_WARNING("Failed to broadcast system message to dialer"); } } +#endif // MOZ_B2G_RIL void BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData) @@ -551,6 +584,7 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData) } } +#ifdef MOZ_B2G_RIL void BluetoothHfpManager::HandleVoiceConnectionChanged() { @@ -636,6 +670,7 @@ BluetoothHfpManager::HandleIccInfoChanged() NS_ENSURE_TRUE_VOID(gsmIccInfo); gsmIccInfo->GetMsisdn(mMsisdn); } +#endif // MOZ_B2G_RIL void BluetoothHfpManager::HandleShutdown() @@ -663,6 +698,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, // For more information, please refer to 4.34.1 "Bluetooth Defined AT // Capabilities" in Bluetooth hands-free profile 1.6 if (msg.Find("AT+BRSF=") != -1) { +#ifdef MOZ_B2G_RIL uint32_t brsf = BRSF_BIT_ABILITY_TO_REJECT_CALL | BRSF_BIT_ENHANCED_CALL_STATUS; @@ -675,6 +711,9 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, if (mBSIR) { brsf |= BRSF_BIT_IN_BAND_RING_TONE; } +#else + uint32_t brsf = 0; +#endif // MOZ_B2G_RIL SendCommand("+BRSF: ", brsf); } else if (msg.Find("AT+CIND=?") != -1) { @@ -715,6 +754,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, // AT+CMEE = 1: use numeric // AT+CMEE = 2: use verbose mCMEE = !atCommandValues[0].EqualsLiteral("0"); +#ifdef MOZ_B2G_RIL } else if (msg.Find("AT+COPS=") != -1) { ParseAtCommand(msg, 8, atCommandValues); @@ -753,6 +793,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, message += atCommandValues[0].get()[0]; NotifyDialer(NS_ConvertUTF8toUTF16(message)); } +#endif // MOZ_B2G_RIL } else if (msg.Find("AT+VGM=") != -1) { ParseAtCommand(msg, 7, atCommandValues); @@ -770,6 +811,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, NS_ASSERTION(vgm >= 0 && vgm <= 15, "Received invalid VGM value"); mCurrentVgm = vgm; +#ifdef MOZ_B2G_RIL } else if (msg.Find("AT+CHLD=?") != -1) { SendLine("+CHLD: (0,1,2)"); } else if (msg.Find("AT+CHLD=") != -1) { @@ -820,6 +862,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, SendLine("ERROR"); return; } +#endif // MOZ_B2G_RIL } else if (msg.Find("AT+VGS=") != -1) { // Adjust volume by headset mReceiveVgsFlag = true; @@ -847,6 +890,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, nsCOMPtr os = mozilla::services::GetObserverService(); data.AppendInt(newVgs); os->NotifyObservers(nullptr, "bluetooth-volume-change", data.get()); +#ifdef MOZ_B2G_RIL } else if ((msg.Find("AT+BLDN") != -1) || (msg.Find("ATD>") != -1)) { // Dialer app of FFOS v1 does not have plan to support Memory Dailing. // However, in order to pass Bluetooth HFP certification, we still have to @@ -972,6 +1016,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket, // Ignore requests to activate/deactivate mandatory indicators } } +#endif // MOZ_B2G_RIL } else { nsCString warningMsg; warningMsg.Append(NS_LITERAL_CSTRING("Unsupported AT command: ")); @@ -1096,6 +1141,7 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController) mSocket->Disconnect(); } +#ifdef MOZ_B2G_RIL void BluetoothHfpManager::SendCCWA(const nsAString& aNumber, int aType) { @@ -1157,6 +1203,7 @@ BluetoothHfpManager::SendCLCC(const Call& aCall, int aIndex) return SendLine(message.get()); } +#endif // MOZ_B2G_RIL bool BluetoothHfpManager::SendLine(const char* aMessage) @@ -1222,6 +1269,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue) message.AppendLiteral(","); } } +#ifdef MOZ_B2G_RIL } else if (!strcmp(aCommand, "+CLCC: ")) { bool rv = true; uint32_t callNumbers = mCurrentCallArray.Length(); @@ -1238,6 +1286,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue) } return rv; +#endif // MOZ_B2G_RIL } else { message.AppendInt(aValue); } @@ -1245,6 +1294,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue) return SendLine(message.get()); } +#ifdef MOZ_B2G_RIL void BluetoothHfpManager::UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend) { @@ -1525,12 +1575,15 @@ BluetoothHfpManager::ToggleCalls() nsITelephonyProvider::CALL_STATE_HELD : nsITelephonyProvider::CALL_STATE_CONNECTED; } +#endif // MOZ_B2G_RIL void BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket) { MOZ_ASSERT(aSocket); +#ifdef MOZ_B2G_RIL MOZ_ASSERT(mListener); +#endif // Success to create a SCO socket if (aSocket == mScoSocket) { @@ -1559,10 +1612,12 @@ BluetoothHfpManager::OnSocketConnectSuccess(BluetoothSocket* aSocket) mHandsfreeSocket = nullptr; } +#ifdef MOZ_B2G_RIL // Enumerate current calls mListener->EnumerateCalls(); mFirstCKPD = true; +#endif // Cache device path for NotifySettings() since we can't get socket address // when a headset disconnect with us diff --git a/dom/bluetooth/BluetoothHfpManager.h b/dom/bluetooth/BluetoothHfpManager.h index 10eb4542a54f..b62eb8dc2ffc 100644 --- a/dom/bluetooth/BluetoothHfpManager.h +++ b/dom/bluetooth/BluetoothHfpManager.h @@ -9,7 +9,9 @@ #include "BluetoothCommon.h" #include "BluetoothProfileManagerBase.h" +#ifdef MOZ_B2G_RIL #include "BluetoothRilListener.h" +#endif #include "BluetoothSocketObserver.h" #include "mozilla/ipc/UnixSocket.h" #include "mozilla/Hal.h" @@ -18,6 +20,8 @@ BEGIN_BLUETOOTH_NAMESPACE class BluetoothReplyRunnable; class BluetoothSocket; + +#ifdef MOZ_B2G_RIL class Call; /** @@ -67,6 +71,7 @@ public: nsString mNumber; int mType; }; +#endif // MOZ_B2G_RIL class BluetoothHfpManager : public BluetoothSocketObserver , public BluetoothProfileManagerBase @@ -109,6 +114,7 @@ public: bool DisconnectSco(); bool ListenSco(); +#ifdef MOZ_B2G_RIL /** * @param aSend A boolean indicates whether we need to notify headset or not */ @@ -117,26 +123,33 @@ public: const bool aIsOutgoing, bool aSend); void HandleIccInfoChanged(); void HandleVoiceConnectionChanged(); +#endif bool IsConnected(); bool IsScoConnected(); +#ifdef MOZ_B2G_RIL // CDMA-specific functions void UpdateSecondNumber(const nsAString& aNumber); void AnswerWaitingCall(); void IgnoreWaitingCall(); void ToggleCalls(); +#endif private: class CloseScoTask; class GetVolumeTask; +#ifdef MOZ_B2G_RIL class RespondToBLDNTask; class SendRingIndicatorTask; +#endif friend class CloseScoTask; friend class GetVolumeTask; +#ifdef MOZ_B2G_RIL friend class RespondToBLDNTask; friend class SendRingIndicatorTask; +#endif friend class BluetoothHfpManagerObserver; BluetoothHfpManager(); @@ -146,41 +159,55 @@ private: bool Init(); void Notify(const hal::BatteryInformation& aBatteryInfo); void Reset(); +#ifdef MOZ_B2G_RIL void ResetCallArray(); uint32_t FindFirstCall(uint16_t aState); uint32_t GetNumberOfCalls(uint16_t aState); PhoneType GetPhoneType(const nsAString& aType); +#endif void NotifyConnectionStatusChanged(const nsAString& aType); void NotifyDialer(const nsAString& aCommand); +#ifdef MOZ_B2G_RIL void SendCCWA(const nsAString& aNumber, int aType); bool SendCLCC(const Call& aCall, int aIndex); +#endif bool SendCommand(const char* aCommand, uint32_t aValue = 0); bool SendLine(const char* aMessage); +#ifdef MOZ_B2G_RIL void UpdateCIND(uint8_t aType, uint8_t aValue, bool aSend = true); +#endif void OnScoConnectSuccess(); void OnScoConnectError(); void OnScoDisconnect(); int mCurrentVgs; int mCurrentVgm; +#ifdef MOZ_B2G_RIL bool mBSIR; bool mCCWA; bool mCLIP; +#endif bool mCMEE; bool mCMER; +#ifdef MOZ_B2G_RIL bool mFirstCKPD; int mNetworkSelectionMode; PhoneType mPhoneType; +#endif bool mReceiveVgsFlag; +#ifdef MOZ_B2G_RIL bool mDialingRequestProcessed; +#endif nsString mDeviceAddress; +#ifdef MOZ_B2G_RIL nsString mMsisdn; nsString mOperatorName; nsTArray mCurrentCallArray; nsAutoPtr mListener; +#endif nsRefPtr mController; nsRefPtr mScoRunnable; @@ -198,8 +225,10 @@ private: nsRefPtr mScoSocket; SocketConnectionStatus mScoSocketStatus; +#ifdef MOZ_B2G_RIL // CDMA-specific variable Call mCdmaSecondCall; +#endif }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/BluetoothService.h b/dom/bluetooth/BluetoothService.h index 4aa1c4128496..8a798ba84d98 100644 --- a/dom/bluetooth/BluetoothService.h +++ b/dom/bluetooth/BluetoothService.h @@ -266,6 +266,7 @@ public: virtual void IsScoConnected(BluetoothReplyRunnable* aRunnable) = 0; +#ifdef MOZ_B2G_RIL virtual void AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) = 0; @@ -274,6 +275,7 @@ public: virtual void ToggleCalls(BluetoothReplyRunnable* aRunnable) = 0; +#endif virtual void SendMetaData(const nsAString& aTitle, diff --git a/dom/bluetooth/ipc/BluetoothParent.cpp b/dom/bluetooth/ipc/BluetoothParent.cpp index 8116875565e2..057e2a678a29 100644 --- a/dom/bluetooth/ipc/BluetoothParent.cpp +++ b/dom/bluetooth/ipc/BluetoothParent.cpp @@ -226,12 +226,14 @@ BluetoothParent::RecvPBluetoothRequestConstructor( return actor->DoRequest(aRequest.get_DisconnectScoRequest()); case Request::TIsScoConnectedRequest: return actor->DoRequest(aRequest.get_IsScoConnectedRequest()); +#ifdef MOZ_B2G_RIL case Request::TAnswerWaitingCallRequest: return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest()); case Request::TIgnoreWaitingCallRequest: return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest()); case Request::TToggleCallsRequest: return actor->DoRequest(aRequest.get_ToggleCallsRequest()); +#endif case Request::TSendMetaDataRequest: return actor->DoRequest(aRequest.get_SendMetaDataRequest()); case Request::TSendPlayStatusRequest: @@ -581,6 +583,7 @@ BluetoothRequestParent::DoRequest(const IsScoConnectedRequest& aRequest) return true; } +#ifdef MOZ_B2G_RIL bool BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest) { @@ -613,6 +616,7 @@ BluetoothRequestParent::DoRequest(const ToggleCallsRequest& aRequest) return true; } +#endif // MOZ_B2G_RIL bool BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest) diff --git a/dom/bluetooth/ipc/BluetoothParent.h b/dom/bluetooth/ipc/BluetoothParent.h index fc18980f708a..d5ee4a391782 100644 --- a/dom/bluetooth/ipc/BluetoothParent.h +++ b/dom/bluetooth/ipc/BluetoothParent.h @@ -190,6 +190,7 @@ protected: bool DoRequest(const IsScoConnectedRequest& aRequest); +#ifdef MOZ_B2G_RIL bool DoRequest(const AnswerWaitingCallRequest& aRequest); @@ -198,6 +199,7 @@ protected: bool DoRequest(const ToggleCallsRequest& aRequest); +#endif bool DoRequest(const SendMetaDataRequest& aRequest); diff --git a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp index 92f3982eed46..de9b8f164637 100644 --- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp +++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp @@ -328,6 +328,7 @@ BluetoothServiceChildProcess::IsScoConnected(BluetoothReplyRunnable* aRunnable) SendRequest(aRunnable, IsScoConnectedRequest()); } +#ifdef MOZ_B2G_RIL void BluetoothServiceChildProcess::AnswerWaitingCall( BluetoothReplyRunnable* aRunnable) @@ -348,6 +349,7 @@ BluetoothServiceChildProcess::ToggleCalls( { SendRequest(aRunnable, ToggleCallsRequest()); } +#endif // MOZ_B2G_RIL void BluetoothServiceChildProcess::SendMetaData(const nsAString& aTitle, diff --git a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h index 19061c2248ac..ac8298fe6bd3 100644 --- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.h +++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.h @@ -149,6 +149,7 @@ public: virtual void IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; +#ifdef MOZ_B2G_RIL virtual void AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; @@ -157,6 +158,7 @@ public: virtual void ToggleCalls(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; +#endif virtual void SendMetaData(const nsAString& aTitle, diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index 475e406d9c89..0abc47a61b75 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -2627,6 +2627,7 @@ BluetoothDBusService::IsConnected(const uint16_t aServiceUuid) return profile->IsConnected(); } +#ifdef MOZ_B2G_RIL void BluetoothDBusService::AnswerWaitingCall(BluetoothReplyRunnable* aRunnable) { @@ -2659,6 +2660,7 @@ BluetoothDBusService::ToggleCalls(BluetoothReplyRunnable* aRunnable) DispatchBluetoothReply(aRunnable, BluetoothValue(true), EmptyString()); } +#endif // MOZ_B2G_RIL class OnUpdateSdpRecordsRunnable : public nsRunnable { diff --git a/dom/bluetooth/linux/BluetoothDBusService.h b/dom/bluetooth/linux/BluetoothDBusService.h index 2ef61e9b1590..341205a3496d 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.h +++ b/dom/bluetooth/linux/BluetoothDBusService.h @@ -135,6 +135,7 @@ public: virtual void IsScoConnected(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE; +#ifdef MOZ_B2G_RIL virtual void AnswerWaitingCall(BluetoothReplyRunnable* aRunnable); @@ -143,6 +144,7 @@ public: virtual void ToggleCalls(BluetoothReplyRunnable* aRunnable); +#endif virtual void SendMetaData(const nsAString& aTitle, From fe8fbe2947309a02e8c019afa8330ff12df2379f Mon Sep 17 00:00:00 2001 From: Vicamo Yang Date: Tue, 29 Oct 2013 16:12:47 +0800 Subject: [PATCH 272/795] Bug 920551 - 2.j/2: fix GonkGPSGeolocationProvider. r=kanru --- .../gonk/GonkGPSGeolocationProvider.cpp | 39 ++++++++++++++++--- dom/system/gonk/GonkGPSGeolocationProvider.h | 27 ++++++++++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/dom/system/gonk/GonkGPSGeolocationProvider.cpp b/dom/system/gonk/GonkGPSGeolocationProvider.cpp index c215623fc54b..1383e35d28d2 100644 --- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp +++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp @@ -18,19 +18,21 @@ #include #include "GonkGPSGeolocationProvider.h" -#include "SystemWorkerManager.h" #include "mozilla/Preferences.h" #include "nsGeoPosition.h" #include "nsIInterfaceRequestorUtils.h" #include "nsINetworkManager.h" -#include "nsIRadioInterfaceLayer.h" -#include "nsIDOMIccInfo.h" -#include "nsIDOMMobileConnection.h" #include "nsJSUtils.h" #include "nsServiceManagerUtils.h" #include "nsThreadUtils.h" #include "nsContentUtils.h" +#ifdef MOZ_B2G_RIL +#include "nsIDOMIccInfo.h" +#include "nsIDOMMobileConnection.h" +#include "nsIRadioInterfaceLayer.h" +#endif + #ifdef AGPS_TYPE_INVALID #define AGPS_HAVE_DUAL_APN #endif @@ -44,10 +46,15 @@ static const int kDefaultPeriod = 1000; // ms // While most methods of GonkGPSGeolocationProvider should only be // called from main thread, we deliberately put the Init and ShutdownGPS // methods off main thread to avoid blocking. +#ifdef MOZ_B2G_RIL NS_IMPL_ISUPPORTS3(GonkGPSGeolocationProvider, nsIGeolocationProvider, nsIRILDataCallback, nsISettingsServiceCallback) +#else +NS_IMPL_ISUPPORTS1(GonkGPSGeolocationProvider, + nsIGeolocationProvider) +#endif /* static */ GonkGPSGeolocationProvider* GonkGPSGeolocationProvider::sSingleton = nullptr; GpsCallbacks GonkGPSGeolocationProvider::mCallbacks = { @@ -65,6 +72,7 @@ GpsCallbacks GonkGPSGeolocationProvider::mCallbacks = { #endif }; +#ifdef MOZ_B2G_RIL AGpsCallbacks GonkGPSGeolocationProvider::mAGPSCallbacks = { AGPSStatusCallback, @@ -77,6 +85,7 @@ GonkGPSGeolocationProvider::mAGPSRILCallbacks = { AGPSRILRefLocCallback, CreateThreadCallback, }; +#endif // MOZ_B2G_RIL void GonkGPSGeolocationProvider::LocationCallback(GpsLocation* location) @@ -146,8 +155,10 @@ GonkGPSGeolocationProvider::SetCapabilitiesCallback(uint32_t capabilities) GonkGPSGeolocationProvider::GetSingleton(); provider->mSupportsScheduling = mCapabilities & GPS_CAPABILITY_SCHEDULING; +#ifdef MOZ_B2G_RIL provider->mSupportsMSB = mCapabilities & GPS_CAPABILITY_MSB; provider->mSupportsMSA = mCapabilities & GPS_CAPABILITY_MSA; +#endif provider->mSupportsSingleShot = mCapabilities & GPS_CAPABILITY_SINGLE_SHOT; #ifdef GPS_CAPABILITY_ON_DEMAND_TIME provider->mSupportsTimeInjection = mCapabilities & GPS_CAPABILITY_ON_DEMAND_TIME; @@ -196,6 +207,7 @@ GonkGPSGeolocationProvider::RequestUtcTimeCallback() { } +#ifdef MOZ_B2G_RIL void GonkGPSGeolocationProvider::AGPSStatusCallback(AGpsStatus* status) { @@ -267,12 +279,15 @@ GonkGPSGeolocationProvider::AGPSRILRefLocCallback(uint32_t flags) NS_DispatchToMainThread(new RequestRefLocEvent()); } } +#endif // MOZ_B2G_RIL GonkGPSGeolocationProvider::GonkGPSGeolocationProvider() : mStarted(false) , mSupportsScheduling(false) +#ifdef MOZ_B2G_RIL , mSupportsMSB(false) , mSupportsMSA(false) +#endif , mSupportsSingleShot(false) , mSupportsTimeInjection(false) , mGpsInterface(nullptr) @@ -320,6 +335,7 @@ GonkGPSGeolocationProvider::GetGPSInterface() return result; } +#ifdef MOZ_B2G_RIL int32_t GonkGPSGeolocationProvider::GetDataConnectionState() { @@ -507,6 +523,7 @@ GonkGPSGeolocationProvider::SetReferenceLocation() } } } +#endif // MOZ_B2G_RIL void GonkGPSGeolocationProvider::Init() @@ -523,6 +540,7 @@ GonkGPSGeolocationProvider::Init() return; } +#ifdef MOZ_B2G_RIL mAGpsInterface = static_cast(mGpsInterface->get_extension(AGPS_INTERFACE)); if (mAGpsInterface) { @@ -534,6 +552,7 @@ GonkGPSGeolocationProvider::Init() if (mAGpsRilInterface) { mAGpsRilInterface->init(&mAGPSRILCallbacks); } +#endif NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::StartGPS)); } @@ -546,19 +565,23 @@ GonkGPSGeolocationProvider::StartGPS() int32_t update = Preferences::GetInt("geo.default.update", kDefaultPeriod); +#ifdef MOZ_B2G_RIL if (mSupportsMSA || mSupportsMSB) { SetupAGPS(); } +#endif int positionMode = GPS_POSITION_MODE_STANDALONE; bool singleShot = false; +#ifdef MOZ_B2G_RIL // XXX: If we know this is a single shot request, use MSA can be faster. if (singleShot && mSupportsMSA) { positionMode = GPS_POSITION_MODE_MS_ASSISTED; } else if (mSupportsMSB) { positionMode = GPS_POSITION_MODE_MS_BASED; } +#endif if (!mSupportsScheduling) { update = kDefaultPeriod; } @@ -574,6 +597,7 @@ GonkGPSGeolocationProvider::StartGPS() mGpsInterface->start(); } +#ifdef MOZ_B2G_RIL void GonkGPSGeolocationProvider::SetupAGPS() { @@ -599,9 +623,8 @@ GonkGPSGeolocationProvider::SetupAGPS() mRadioInterface->RegisterDataCallCallback(this); } } - - return; } +#endif // MOZ_B2G_RIL NS_IMETHODIMP GonkGPSGeolocationProvider::Startup() @@ -643,9 +666,11 @@ GonkGPSGeolocationProvider::Shutdown() } mStarted = false; +#ifdef MOZ_B2G_RIL if (mRadioInterface) { mRadioInterface->UnregisterDataCallCallback(this); } +#endif mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS), NS_DISPATCH_NORMAL); @@ -670,6 +695,7 @@ GonkGPSGeolocationProvider::SetHighAccuracy(bool) return NS_OK; } +#ifdef MOZ_B2G_RIL /** nsIRILDataCallback interface **/ NS_IMETHODIMP @@ -721,3 +747,4 @@ GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage) { return NS_OK; } +#endif // MOZ_B2G_RIL diff --git a/dom/system/gonk/GonkGPSGeolocationProvider.h b/dom/system/gonk/GonkGPSGeolocationProvider.h index 66f27da8cea4..cc59d8a064e0 100644 --- a/dom/system/gonk/GonkGPSGeolocationProvider.h +++ b/dom/system/gonk/GonkGPSGeolocationProvider.h @@ -20,9 +20,10 @@ #include // for GpsInterface #include "nsCOMPtr.h" #include "nsIGeolocationProvider.h" +#ifdef MOZ_B2G_RIL #include "nsIRadioInterfaceLayer.h" -#include "nsString.h" #include "nsISettingsService.h" +#endif class nsIThread; @@ -33,14 +34,18 @@ class nsIThread; "@mozilla.org/gonk-gps-geolocation-provider;1" class GonkGPSGeolocationProvider : public nsIGeolocationProvider +#ifdef MOZ_B2G_RIL , public nsIRILDataCallback , public nsISettingsServiceCallback +#endif { public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIGEOLOCATIONPROVIDER +#ifdef MOZ_B2G_RIL NS_DECL_NSIRILDATACALLBACK NS_DECL_NSISETTINGSSERVICECALLBACK +#endif static already_AddRefed GetSingleton(); @@ -61,25 +66,31 @@ private: static void ReleaseWakelockCallback(); static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg); static void RequestUtcTimeCallback(); +#ifdef MOZ_B2G_RIL static void AGPSStatusCallback(AGpsStatus* status); static void AGPSRILSetIDCallback(uint32_t flags); static void AGPSRILRefLocCallback(uint32_t flags); +#endif static GpsCallbacks mCallbacks; +#ifdef MOZ_B2G_RIL static AGpsCallbacks mAGPSCallbacks; static AGpsRilCallbacks mAGPSRILCallbacks; +#endif - int32_t GetDataConnectionState(); - void SetAGpsDataConn(nsAString& aApn); - void RequestSettingValue(char* aKey); void Init(); - void SetupAGPS(); void StartGPS(); void ShutdownGPS(); +#ifdef MOZ_B2G_RIL + void SetupAGPS(); + int32_t GetDataConnectionState(); + void SetAGpsDataConn(nsAString& aApn); void RequestDataConnection(); void ReleaseDataConnection(); + void RequestSettingValue(char* aKey); void RequestSetID(uint32_t flags); void SetReferenceLocation(); +#endif const GpsInterface* GetGPSInterface(); @@ -88,17 +99,21 @@ private: bool mStarted; bool mSupportsScheduling; +#ifdef MOZ_B2G_RIL bool mSupportsMSB; bool mSupportsMSA; +#endif bool mSupportsSingleShot; bool mSupportsTimeInjection; const GpsInterface* mGpsInterface; +#ifdef MOZ_B2G_RIL const AGpsInterface* mAGpsInterface; const AGpsRilInterface* mAGpsRilInterface; + nsCOMPtr mRadioInterface; +#endif nsCOMPtr mLocationCallback; nsCOMPtr mInitThread; - nsCOMPtr mRadioInterface; }; #endif /* GonkGPSGeolocationProvider_h */ From 0f1f2b64247888f932bafd468de5819052a2955f Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Tue, 29 Oct 2013 16:13:06 +0800 Subject: [PATCH 273/795] Bug 931699 - SNTP can only update system time when WiFi or Mobile gets connected (not MMS/SUPL). r=skao,echen --- dom/system/gonk/RadioInterfaceLayer.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index f67716bf5645..c0cf46d9c767 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -2200,13 +2200,28 @@ RadioInterface.prototype = { break; case kNetworkInterfaceStateChangedTopic: let network = subject.QueryInterface(Ci.nsINetworkInterface); - if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { - // Check SNTP when we have data connection, this may not take - // effect immediately before the setting get enabled. - if (this._sntp.isExpired()) { - this._sntp.request(); + if (network.state != Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED) { + return; + } + + // SNTP can only update when we have mobile or Wifi connections. + if (network.type != Ci.nsINetworkInterface.NETWORK_TYPE_WIFI && + network.type != Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { + return; + } + + // If the network comes from RIL, make sure the RIL service is matched. + if (subject instanceof Ci.nsIRilNetworkInterface) { + network = subject.QueryInterface(Ci.nsIRilNetworkInterface); + if (network.serviceId != this.clientId) { + return; } } + + // SNTP won't update unless the SNTP is already expired. + if (this._sntp.isExpired()) { + this._sntp.request(); + } break; case kScreenStateChangedTopic: this.workerMessenger.send("setScreenState", { on: (data === "on") }); From 68bfd74e65e957b8dbadcfe89128e0cce9112cff Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 02:20:23 -0700 Subject: [PATCH 274/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/2665fbf148c5 Author: gasolin Desc: Merge pull request #13157 from gasolin/issue-932141 Bug 932141 - [Homescreen] Refactor tablet media query styles, r=crdlc ======== https://hg.mozilla.org/integration/gaia-central/rev/3e8647d84744 Author: gasolin Desc: Bug 932141 - [Homescreen] Refactor tablet media query styles --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 34fb921c3a44..ca174dc26fb9 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "1010c4c9abb59f2bb54b0dc8f5fbbabc65a0cb45", + "revision": "2665fbf148c505a50ab19c3299257af99a03f510", "repo_path": "/integration/gaia-central" } From b2ea54fd35c3b2e89e300b0de60125e9f3dd5a06 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 02:45:32 -0700 Subject: [PATCH 275/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ======== https://hg.mozilla.org/integration/gaia-central/rev/12249906aac3 Author: Salvador de la Puente González Desc: Merge pull request #13166 from lodr/reset-wifi Bug 932009 - Fixing reset for WiFi ======== https://hg.mozilla.org/integration/gaia-central/rev/5e558379ef01 Author: lodr Desc: Bug 932009 - Fixing reset for WiFi --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index ca174dc26fb9..037d8c0a225f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "2665fbf148c505a50ab19c3299257af99a03f510", + "revision": "12249906aac39405601b6224b335f7b671dbbeac", "repo_path": "/integration/gaia-central" } From 4a057a1cc6a775e0aff56b3f539ca51ccedf6b70 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 29 Oct 2013 11:08:16 +0100 Subject: [PATCH 276/795] Bug 931038: Remove blocking DBus interface, r=qdot All blocking calls to DBus have been replaced by non-blocking code. This patch removes the corresponding DBus interfaces. --- ipc/dbus/RawDBusConnection.cpp | 189 +-------------------------------- ipc/dbus/RawDBusConnection.h | 9 -- 2 files changed, 2 insertions(+), 196 deletions(-) diff --git a/ipc/dbus/RawDBusConnection.cpp b/ipc/dbus/RawDBusConnection.cpp index 12d8b5055444..bc13d2e83b68 100644 --- a/ipc/dbus/RawDBusConnection.cpp +++ b/ipc/dbus/RawDBusConnection.cpp @@ -53,59 +53,16 @@ protected: DBusMessageRefPtr mMessage; }; -class DBusConnectionSendSyncRunnable : public DBusConnectionSendRunnableBase -{ -public: - bool WaitForCompletion() - { - MOZ_ASSERT(!NS_IsMainThread()); - - MonitorAutoLock autoLock(mCompletedMonitor); - while (!mCompleted) { - mCompletedMonitor.Wait(); - } - return mSuccess; - } - -protected: - DBusConnectionSendSyncRunnable(DBusConnection* aConnection, - DBusMessage* aMessage) - : DBusConnectionSendRunnableBase(aConnection, aMessage), - mCompletedMonitor("DBusConnectionSendSyncRunnable.mCompleted"), - mCompleted(false), - mSuccess(false) - { } - - virtual ~DBusConnectionSendSyncRunnable() - { } - - // Call this function at the end of Run() to notify waiting - // threads. - void Completed(bool aSuccess) - { - MonitorAutoLock autoLock(mCompletedMonitor); - MOZ_ASSERT(!mCompleted); - mSuccess = aSuccess; - mCompleted = true; - mCompletedMonitor.Notify(); - } - -private: - Monitor mCompletedMonitor; - bool mCompleted; - bool mSuccess; -}; - // // Sends a message and returns the message's serial number to the // disaptching thread. Only run it in DBus thread. // -class DBusConnectionSendRunnable : public DBusConnectionSendSyncRunnable +class DBusConnectionSendRunnable : public DBusConnectionSendRunnableBase { public: DBusConnectionSendRunnable(DBusConnection* aConnection, DBusMessage* aMessage) - : DBusConnectionSendSyncRunnable(aConnection, aMessage) + : DBusConnectionSendRunnableBase(aConnection, aMessage) { } NS_IMETHOD Run() @@ -113,7 +70,6 @@ public: MOZ_ASSERT(!NS_IsMainThread()); dbus_bool_t success = dbus_connection_send(mConnection, mMessage, nullptr); - Completed(success == TRUE); NS_ENSURE_TRUE(success == TRUE, NS_ERROR_FAILURE); @@ -220,95 +176,6 @@ private: int mTimeout; }; -// -// Legacy interface, don't use in new code -// -// Sends a message and waits for the reply. Only run it in DBus thread. -// -class DBusConnectionSendAndBlockRunnable : public DBusConnectionSendSyncRunnable -{ -private: - static void Notify(DBusPendingCall* aCall, void* aData) - { - DBusConnectionSendAndBlockRunnable* runnable( - static_cast(aData)); - - runnable->mReply = dbus_pending_call_steal_reply(aCall); - - bool success = !!runnable->mReply; - - if (runnable->mError) { - success = success && !dbus_error_is_set(runnable->mError); - - if (!dbus_set_error_from_message(runnable->mError, runnable->mReply)) { - dbus_error_init(runnable->mError); - } - } - - dbus_pending_call_cancel(aCall); - dbus_pending_call_unref(aCall); - - runnable->Completed(success); - } - -public: - DBusConnectionSendAndBlockRunnable(DBusConnection* aConnection, - DBusMessage* aMessage, - int aTimeout, - DBusError* aError) - : DBusConnectionSendSyncRunnable(aConnection, aMessage), - mError(aError), - mReply(nullptr), - mTimeout(aTimeout) - { } - - NS_IMETHOD Run() - { - MOZ_ASSERT(!NS_IsMainThread()); - - DBusPendingCall* call = nullptr; - - dbus_bool_t success = dbus_connection_send_with_reply(mConnection, - mMessage, - &call, - mTimeout); - if (success == TRUE) { - success = dbus_pending_call_set_notify(call, Notify, this, nullptr); - } else { - if (mError) { - if (!call) { - dbus_set_error(mError, DBUS_ERROR_DISCONNECTED, "Connection is closed"); - } else { - dbus_error_init(mError); - } - } - } - - dbus_message_unref(mMessage); - - if (!success) { - Completed(false); - NS_ENSURE_TRUE(success == TRUE, NS_ERROR_FAILURE); - } - - return NS_OK; - } - - DBusMessage* GetReply() - { - return mReply; - } - -protected: - ~DBusConnectionSendAndBlockRunnable() - { } - -private: - DBusError* mError; - DBusMessage* mReply; - int mTimeout; -}; - } } @@ -414,58 +281,6 @@ bool RawDBusConnection::SendWithReply(DBusReplyCallback aCallback, return SendWithReply(aCallback, aData, aTimeout, msg); } -bool RawDBusConnection::SendWithError(DBusMessage** aReply, - DBusError* aError, - int aTimeout, - DBusMessage* aMessage) -{ - nsRefPtr t( - new DBusConnectionSendAndBlockRunnable(mConnection, aMessage, - aTimeout, aError)); - MOZ_ASSERT(t); - - nsresult rv = DispatchToDBusThread(t); - - if (NS_FAILED(rv)) { - if (aMessage) { - dbus_message_unref(aMessage); - } - return false; - } - - if (!t->WaitForCompletion()) { - return false; - } - - if (aReply) { - *aReply = t->GetReply(); - } - - return true; -} - -bool RawDBusConnection::SendWithError(DBusMessage** aReply, - DBusError* aError, - int aTimeout, - const char* aPath, - const char* aIntf, - const char* aFunc, - int aFirstArgType, ...) -{ - va_list args; - - va_start(args, aFirstArgType); - DBusMessage* msg = BuildDBusMessage(aPath, aIntf, aFunc, - aFirstArgType, args); - va_end(args); - - if (!msg) { - return false; - } - - return SendWithError(aReply, aError, aTimeout, msg); -} - DBusMessage* RawDBusConnection::BuildDBusMessage(const char* aPath, const char* aIntf, const char* aFunc, diff --git a/ipc/dbus/RawDBusConnection.h b/ipc/dbus/RawDBusConnection.h index 57e5ea838b95..616a964b3e2a 100644 --- a/ipc/dbus/RawDBusConnection.h +++ b/ipc/dbus/RawDBusConnection.h @@ -53,15 +53,6 @@ public: int aTimeout, const char* aPath, const char* aIntf, const char *aFunc, int aFirstArgType, ...); - /* Legacy interface, don't use in new code */ - bool SendWithError(DBusMessage** aReply, DBusError* aError, int aTimeout, - DBusMessage* aMessage); - - /* Legacy interface, don't use in new code */ - bool SendWithError(DBusMessage** aReply, DBusError* aError, int aTimeout, - const char* aPath, const char* aIntf, const char* aFunc, - int aFirstArgType, ...); - protected: DBusMessage* BuildDBusMessage(const char* aPath, const char* aIntf, const char* aFunc, int aFirstArgType, From 40c44faa10d9031b78a56bde1776f978caf21a8b Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 03:20:23 -0700 Subject: [PATCH 277/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/9621d106a3cc Author: Zac Campbell Desc: Python xfail test test_sms_add_contact a=testonly r=me --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 037d8c0a225f..f8fe9d74d7a8 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "12249906aac39405601b6224b335f7b671dbbeac", + "revision": "9621d106a3cc469f2170533edc41fb8c92a9c7bb", "repo_path": "/integration/gaia-central" } From 4c306ee2718efd825450d53b3f89864edd3329cd Mon Sep 17 00:00:00 2001 From: Gene Lian Date: Tue, 29 Oct 2013 16:33:18 +0800 Subject: [PATCH 278/795] Bug 923382 - B2G Multi-SIM: support multiple SIM cards for network metering (a follow-up of bug 887699). r=albert --- dom/network/src/NetworkStatsService.jsm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dom/network/src/NetworkStatsService.jsm b/dom/network/src/NetworkStatsService.jsm index 8e325faa4c42..3a0e15b25e81 100644 --- a/dom/network/src/NetworkStatsService.jsm +++ b/dom/network/src/NetworkStatsService.jsm @@ -46,12 +46,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService", "@mozilla.org/settingsService;1", "nsISettingsService"); -XPCOMUtils.defineLazyGetter(this, "gRadioInterface", function () { - let ril = Cc["@mozilla.org/ril;1"].getService(Ci["nsIRadioInterfaceLayer"]); - // TODO: Bug 923382 - B2G Multi-SIM: support multiple SIM cards for network metering. - return ril.getRadioInterface(0); -}); - this.NetworkStatsService = { init: function() { debug("Service started"); @@ -202,10 +196,13 @@ this.NetworkStatsService = { let id = '0'; if (aNetwork.type == NET_TYPE_MOBILE) { - // Bug 904542 will provide the serviceId to map the iccId with the - // nsINetworkInterface of the NetworkManager. Now, lets assume that - // network is mapped with the current iccId of the single SIM. - id = gRadioInterface.rilContext.iccInfo.iccid; + if (!(aNetwork instanceof Ci.nsIRilNetworkInterface)) { + debug("Error! Mobile network should be an nsIRilNetworkInterface!"); + return null; + } + + let rilNetwork = aNetwork.QueryInterface(Ci.nsIRilNetworkInterface); + id = rilNetwork.iccId; } let netId = this.getNetworkId(id, aNetwork.type); From b1314d3d55cffc519be6895cc9e74334c97f0ef5 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 04:16:24 -0700 Subject: [PATCH 279/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/b9ca53fe9549 Author: Rex KM Lee Desc: Merge pull request #13165 from rexboy7/fix-bug930944 Bug 930944 - [System] Don't turn screen off after poweroff animation ======== https://hg.mozilla.org/integration/gaia-central/rev/9add16ac90f3 Author: Rex Lee Desc: Bug 930944 - [System] Don't turn screen off after poweroff animation --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index f8fe9d74d7a8..d35572b65cc9 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "9621d106a3cc469f2170533edc41fb8c92a9c7bb", + "revision": "b9ca53fe9549d230b666d42852470fce002d21ee", "repo_path": "/integration/gaia-central" } From 240e7c40bedad37f45c16fee65d01efc1e63ed78 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 05:15:28 -0700 Subject: [PATCH 280/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/6d9dda570404 Author: Zac Desc: Merge pull request #13121 from anah/bug921424 Bug 921424 - Replace wait for landing page after unlocking with wait for displayed app to be homescreen ======== https://hg.mozilla.org/integration/gaia-central/rev/ba50c07ee49a Author: Ana Hristova Desc: Bug 921424 - Replace wait for landing page after unlocking with wait for displayed app to be homescreen --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index d35572b65cc9..7da02bf3b9f7 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "b9ca53fe9549d230b666d42852470fce002d21ee", + "revision": "6d9dda570404795a91ed5eccb138fa347e1b84c0", "repo_path": "/integration/gaia-central" } From d7700ffd3996ceb21418753aad32632643d09856 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 05:30:24 -0700 Subject: [PATCH 281/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/c6c75a2e1654 Author: Zac Campbell Desc: Revert "Bug 921424 - Replace wait for landing page after unlocking with wait for displayed app to be homescreen" This reverts commit 381faaba87ebc6c743b3a3ef46d8b5d3b27e05ec. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 7da02bf3b9f7..76970a102b62 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "6d9dda570404795a91ed5eccb138fa347e1b84c0", + "revision": "c6c75a2e1654bf2c2089a746ef73cae81dfa270c", "repo_path": "/integration/gaia-central" } From 015c123469b09cbec8ae966d6abe9e4a75ea97ea Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 07:05:26 -0700 Subject: [PATCH 282/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/57b0fc0c1199 Author: EragonJ Desc: Merge pull request #12213 from EragonJ/bug-911681 Bug 911681 - [FTU] replace tutorial images for large device ======== https://hg.mozilla.org/integration/gaia-central/rev/b30446d3a85b Author: EragonJ Desc: Bug 911681 - [FTU] replace tutorial images for large device - use IAC - add IAC handler for system app - add IAC handler tests - add tablet support - add TutorialSteps for two devices - add Tutorial related tests - update media_playback to use IAC handler --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 76970a102b62..14895207f25c 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "c6c75a2e1654bf2c2089a746ef73cae81dfa270c", + "revision": "57b0fc0c1199b3ee2501069eb2a9de0f15a12c20", "repo_path": "/integration/gaia-central" } From 94b42d22996593428f376d6d476e2409865be4be Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 07:40:24 -0700 Subject: [PATCH 283/795] Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/7b8b98b2b557 Author: Etienne Segonzac Desc: Merge pull request #13090 from etiennesegonzac/bug-917222-dialing-twice Bug 917222 - Making sure we're never dialing the same number twice. r=rik ======== https://hg.mozilla.org/integration/gaia-central/rev/dc0d21d0b8ba Author: Etienne Segonzac Desc: Bug 917222 - Making sure we're never dialing the same number twice. r=rik ======== https://hg.mozilla.org/integration/gaia-central/rev/4bc5d43f27c4 Author: Pavel Ivanov Desc: Merge pull request #13045 from pivanov/bug-929921 Bug 929921 - [Settings-Passcode] Screen Update ======== https://hg.mozilla.org/integration/gaia-central/rev/918886225cbc Author: Pavel Ivanov Desc: Bug 929921 - [Settings-Passcode] Screen Update --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 14895207f25c..c0a80d64eaab 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "57b0fc0c1199b3ee2501069eb2a9de0f15a12c20", + "revision": "7b8b98b2b5575b48ca4e3d9573b203264c8f5d42", "repo_path": "/integration/gaia-central" } From 710cedf85d73eaf79f04367e4a0fda7773774b12 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 07:50:24 -0700 Subject: [PATCH 284/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/744f062af344 Author: Zac Desc: Merge pull request #13067 from AndreiH/bug930042 Bug 930042 - Minor enhancement to test_sms_add_contact ======== https://hg.mozilla.org/integration/gaia-central/rev/ccbd86c0af0f Author: Andrei Hutusoru Desc: Bug 930042 - Minor enhancement to test_sms_add_contact --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c0a80d64eaab..ab1f09bac24e 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "7b8b98b2b5575b48ca4e3d9573b203264c8f5d42", + "revision": "744f062af3441df27e5ae7740482ab42d49ca479", "repo_path": "/integration/gaia-central" } From efb8f2210ee9cdae3c72ae76482e37aea236cfee Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 08:25:24 -0700 Subject: [PATCH 285/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/6930dd1da9f1 Author: Jose M. Cantera Desc: Merge pull request #13138 from jmcanterafonseca/fb_datastore_final Bug 923637 - Use DataStore instead of indexedDB in the fb_data.js module ======== https://hg.mozilla.org/integration/gaia-central/rev/e6e229c2c9ee Author: Jose M. Cantera Desc: Bug 923637 - Use DataStore instead of indexedDB in the fb_data.js module --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index ab1f09bac24e..eb7a1c2f63bd 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "744f062af3441df27e5ae7740482ab42d49ca479", + "revision": "6930dd1da9f19087cd1950402e819550ce669255", "repo_path": "/integration/gaia-central" } From 8c7b3871f220aa358fdc02e850dc9099832f7a4b Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 08:40:25 -0700 Subject: [PATCH 286/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/c97a6a8850ae Author: Ben Kelly Desc: Merge pull request #13043 from wanderview/contacts-size-reflow Bug 921685: Read device geometry info from cookie to avoid sync reflows. r=arcturus ======== https://hg.mozilla.org/integration/gaia-central/rev/1a35f8059551 Author: Ben Kelly Desc: Bug 921685: Read device geometry info from cookie to avoid sync reflows. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index eb7a1c2f63bd..70595f894f18 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "6930dd1da9f19087cd1950402e819550ce669255", + "revision": "c97a6a8850aeacc5bbe7427ae34113132d4b1c78", "repo_path": "/integration/gaia-central" } From f5cff84a26505034299b3ac33183011095e78df6 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 08:50:26 -0700 Subject: [PATCH 287/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/11e6c5916cef Author: Ben Kelly Desc: Merge pull request #13075 from wanderview/contacts-export-search-select Bug 930693: Fix checkbox select in export search mode. +shepherd r=arcturus ======== https://hg.mozilla.org/integration/gaia-central/rev/f5e529a3db8c Author: Ben Kelly Desc: Bug 930693: Fix checkbox select in export search mode. +shepherd --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 70595f894f18..59ee1c2ac5be 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "c97a6a8850aeacc5bbe7427ae34113132d4b1c78", + "revision": "11e6c5916cef94f6094ab90d21a14b49c3b2fd38", "repo_path": "/integration/gaia-central" } From 8fa9db905d7f88367ab9bc580605fc0d0cb46204 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 29 Oct 2013 17:19:02 +0100 Subject: [PATCH 288/795] Bug 930952: Dispatch DBus messages after reading socket, r=qdot DBusWatcher::Poll currently breaks after reading DBus data from the socket. Thus, it never processes the data and dispatches the DBus messages. This patch fixes the code to dispatch DBus messages after reading the DBus socket. --- ipc/dbus/DBusThread.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ipc/dbus/DBusThread.cpp b/ipc/dbus/DBusThread.cpp index 308af52f24c4..bc99586ebd76 100644 --- a/ipc/dbus/DBusThread.cpp +++ b/ipc/dbus/DBusThread.cpp @@ -253,18 +253,19 @@ DBusWatcher::Poll() } } else { short events = mPollData[i].revents; - unsigned int flags = UnixEventsToDBusFlags(events); - dbus_watch_handle(mWatchData[i], flags); mPollData[i].revents = 0; + + dbus_watch_handle(mWatchData[i], UnixEventsToDBusFlags(events)); + + DBusDispatchStatus dbusDispatchStatus; + do { + dbusDispatchStatus = dbus_connection_dispatch(GetConnection()); + } while (dbusDispatchStatus == DBUS_DISPATCH_DATA_REMAINS); + // Break at this point since we don't know if the operation // was destructive break; } - - DBusDispatchStatus dbusDispatchStatus; - do { - dbusDispatchStatus = dbus_connection_dispatch(GetConnection()); - } while (dbusDispatchStatus == DBUS_DISPATCH_DATA_REMAINS); } ++i; From 9b747fbc531cb4cbf1c04fdaff37470ce05749f5 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 10:00:27 -0700 Subject: [PATCH 289/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/1e351fdd67d2 Author: Jose M. Cantera Desc: Merge pull request #13033 from gitmai/bug-928918-export-vcard-phonenumber Bug 928918 -Follow up to Bug 914999 The phone of a contact exported to vCard does not appear when it has certain mobile type assigned ======== https://hg.mozilla.org/integration/gaia-central/rev/e258164f1ec5 Author: mai Desc: Bug 928918 -Follow up to Bug 914999 The phone of a contact exported to vCard does not appear when it has certain mobile type assigned --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 59ee1c2ac5be..7656e11caaf1 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "11e6c5916cef94f6094ab90d21a14b49c3b2fd38", + "revision": "1e351fdd67d230e556ba8f266672a4c817bb4754", "repo_path": "/integration/gaia-central" } From ea6acc9aa248ff2f24042608b094ffe394696b60 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 11:10:26 -0700 Subject: [PATCH 290/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/eab6fd8be409 Author: Gabriele Svelto Desc: Bug 911934 - Honor the expiration date if present in a message r=julienw --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 7656e11caaf1..cc6e26ecb131 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "1e351fdd67d230e556ba8f266672a4c817bb4754", + "revision": "eab6fd8be40975febc4b5b7faae952231f1f49e5", "repo_path": "/integration/gaia-central" } From a67620d24cb0d61fd2419f244822b1110ef34fd5 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 13:55:25 -0700 Subject: [PATCH 291/795] Bumping gaia.json for 3 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/4d431ce17144 Author: Kyle Machulis Desc: Merge pull request #12903 from qdot/927642-more-tests Bug 927642 - Fix dir/lang integration tests for notifications ======== https://hg.mozilla.org/integration/gaia-central/rev/466eb10c49ec Author: Kyle Machulis Desc: Bug 927642 - Fix dir/lang integration tests for notifications ======== https://hg.mozilla.org/integration/gaia-central/rev/e0b66df61173 Author: Michael Henretty Desc: fetch notification items in single roundtrip to marionette server --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index cc6e26ecb131..91155b0528b7 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "eab6fd8be40975febc4b5b7faae952231f1f49e5", + "revision": "4d431ce17144aebfa7554cad59b905a35ac142b0", "repo_path": "/integration/gaia-central" } From b313542a2b7660148dfc3e0814627ece94613c0d Mon Sep 17 00:00:00 2001 From: Blake Kaplan Date: Tue, 29 Oct 2013 13:57:16 -0700 Subject: [PATCH 292/795] Bug 923961 - Force b2g-desktop to composite on OSX. r=mstange --- widget/cocoa/nsCocoaWindow.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index d0fa988654d9..cbbde292727c 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -472,7 +472,14 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect &aRect, } [mWindow setBackgroundColor:[NSColor clearColor]]; +#ifdef MOZ_B2G + // In B2G, we don't create popups and we need OMTC to work (because out of + // process compositing depends on it). Therefore, we don't need our windows + // to be transparent. + [mWindow setOpaque:YES]; +#else [mWindow setOpaque:NO]; +#endif [mWindow setContentMinSize:NSMakeSize(60, 60)]; [mWindow disableCursorRects]; From 27e2e34d105774dd8e3529383f96e2128f09eba8 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 14:05:24 -0700 Subject: [PATCH 293/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/4b0c5028af2d Author: David Flanagan Desc: Merge pull request #13103 from davidflanagan/bug923544 Bug 923544: remove unneeded workaround that was causing problems r=aus ======== https://hg.mozilla.org/integration/gaia-central/rev/0f1335ef559e Author: David Flanagan Desc: Bug 923544: remove unneeded workaround that was causing problems --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 91155b0528b7..8fd4ec0b150c 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "4d431ce17144aebfa7554cad59b905a35ac142b0", + "revision": "4b0c5028af2d2ddf28537a392ec26025696321d4", "repo_path": "/integration/gaia-central" } From 2f465533be9d5bc1c0b99908e2d33988bd73f2b9 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 14:40:24 -0700 Subject: [PATCH 294/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/bec42064814a Author: James Lal Desc: Merge pull request #13194 from lightsofapollo/travis-retry Travis retry ======== https://hg.mozilla.org/integration/gaia-central/rev/6ab8c307ac44 Author: James Lal Desc: Bug 932489 - Travis retry r=me a=test-only +shepherd --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 8fd4ec0b150c..22559040e854 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "4b0c5028af2d2ddf28537a392ec26025696321d4", + "revision": "bec42064814ad2e335ec4aa9cef8013c658623a9", "repo_path": "/integration/gaia-central" } From f099d4b6d0cf2b4a6565b74ed62191f9af0673a3 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 18:01:01 -0700 Subject: [PATCH 295/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump Truncated some number of revisions since the previous bump. ======== https://hg.mozilla.org/integration/gaia-central/rev/6a1167f9fb7b Author: Julien Wajsberg Desc: Merge pull request #13184 from julienw/932318-fix-jshint Bug 932318 - [Messages] jshint fixes from bug 901852 and bug 927783 r=rw... ======== https://hg.mozilla.org/integration/gaia-central/rev/94f2922c99ec Author: Julien Wajsberg Desc: Bug 932318 - [Messages] jshint fixes from bug 901852 and bug 927783 r=rwaldron Fix also a unit test issue. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 22559040e854..adf8fc3c2538 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "bec42064814ad2e335ec4aa9cef8013c658623a9", + "revision": "6a1167f9fb7b32aff1a6d2a2403d7029e7e4c8ab", "repo_path": "/integration/gaia-central" } From 83e3ddb30c6a89e6cb23f200648f419ef3661adb Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Tue, 29 Oct 2013 20:20:24 -0700 Subject: [PATCH 296/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/3709b2421808 Author: Luke Chang Desc: Merge pull request #13172 from luke-chang/932234_pinyin_minor_bugs Bug 932234 - [Keyboard] Minor mistakes in pinyin IME, r=rudylu ======== https://hg.mozilla.org/integration/gaia-central/rev/5b0266678754 Author: Luke Chang Desc: Bug 932234 - [Keyboard] Minor mistakes in pinyin IME --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index adf8fc3c2538..a405afe133ca 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "6a1167f9fb7b32aff1a6d2a2403d7029e7e4c8ab", + "revision": "3709b24218085fe349291fd1b1102cc8b9ba13dc", "repo_path": "/integration/gaia-central" } From b9646289f2970cb161d8e45e8b718e1971143f6f Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Wed, 30 Oct 2013 12:01:51 +0800 Subject: [PATCH 297/795] Bug 818353 - Part 1: idl changes. f=edgar r=hsinyi --- .../nsIMobileConnectionProvider.idl | 81 ++++++++++++------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/dom/network/interfaces/nsIMobileConnectionProvider.idl b/dom/network/interfaces/nsIMobileConnectionProvider.idl index c3e8679e4480..2d054019bc10 100644 --- a/dom/network/interfaces/nsIMobileConnectionProvider.idl +++ b/dom/network/interfaces/nsIMobileConnectionProvider.idl @@ -10,7 +10,7 @@ interface nsIDOMMozMobileConnectionInfo; interface nsIDOMMozMobileNetworkInfo; interface nsIDOMWindow; -[scriptable, uuid(f1878629-4151-4e02-a22a-8cec3d7eddee)] +[scriptable, uuid(f02c50d5-9d34-4f24-80eb-527a280e31fa)] interface nsIMobileConnectionListener : nsISupports { void notifyVoiceChanged(); @@ -27,13 +27,14 @@ interface nsIMobileConnectionListener : nsISupports void notifyEmergencyCbModeChanged(in boolean active, in unsigned long timeoutMs); void notifyOtaStatusChanged(in DOMString status); + void notifyIccChanged(); }; /** * XPCOM component (in the content process) that provides the mobile * network information. */ -[scriptable, uuid(c66652e0-0628-11e3-8ffd-0800200c9a66)] +[scriptable, uuid(84278a49-0f05-4585-b3f4-c74882ae5719)] interface nsIMobileConnectionProvider : nsISupports { /** @@ -41,47 +42,71 @@ interface nsIMobileConnectionProvider : nsISupports * RadioInterfaceLayer in the chrome process. Only a content process that has * the 'mobileconnection' permission is allowed to register. */ - void registerMobileConnectionMsg(in nsIMobileConnectionListener listener); - void unregisterMobileConnectionMsg(in nsIMobileConnectionListener listener); + void registerMobileConnectionMsg(in unsigned long clientId, + in nsIMobileConnectionListener listener); + void unregisterMobileConnectionMsg(in unsigned long clientId, + in nsIMobileConnectionListener listener); - readonly attribute nsIDOMMozMobileConnectionInfo voiceConnectionInfo; - readonly attribute nsIDOMMozMobileConnectionInfo dataConnectionInfo; - readonly attribute DOMString networkSelectionMode; + nsIDOMMozMobileConnectionInfo getVoiceConnectionInfo(in unsigned long clientId); + nsIDOMMozMobileConnectionInfo getDataConnectionInfo(in unsigned long clientId); + DOMString getIccId(in unsigned long clientId); + DOMString getNetworkSelectionMode(in unsigned long clientId); - nsIDOMDOMRequest getNetworks(in nsIDOMWindow window); - nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network); - nsIDOMDOMRequest selectNetworkAutomatically(in nsIDOMWindow window); + nsIDOMDOMRequest getNetworks(in unsigned long clientId, + in nsIDOMWindow window); + nsIDOMDOMRequest selectNetwork(in unsigned long clientId, + in nsIDOMWindow window, + in nsIDOMMozMobileNetworkInfo network); + nsIDOMDOMRequest selectNetworkAutomatically(in unsigned long clientId, + in nsIDOMWindow window); - nsIDOMDOMRequest setRoamingPreference(in nsIDOMWindow window, + nsIDOMDOMRequest setRoamingPreference(in unsigned long clientId, + in nsIDOMWindow window, in DOMString mode); - nsIDOMDOMRequest getRoamingPreference(in nsIDOMWindow window); + nsIDOMDOMRequest getRoamingPreference(in unsigned long clientId, + in nsIDOMWindow window); - nsIDOMDOMRequest setVoicePrivacyMode(in nsIDOMWindow window, + nsIDOMDOMRequest setVoicePrivacyMode(in unsigned long clientId, + in nsIDOMWindow window, in bool enabled); - nsIDOMDOMRequest getVoicePrivacyMode(in nsIDOMWindow window); + nsIDOMDOMRequest getVoicePrivacyMode(in unsigned long clientId, + in nsIDOMWindow window); - nsIDOMDOMRequest sendMMI(in nsIDOMWindow window, in DOMString mmi); - nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window); + nsIDOMDOMRequest sendMMI(in unsigned long clientId, + in nsIDOMWindow window, + in DOMString mmi); + nsIDOMDOMRequest cancelMMI(in unsigned long clientId, + in nsIDOMWindow window); - nsIDOMDOMRequest getCallForwardingOption(in nsIDOMWindow window, + nsIDOMDOMRequest getCallForwardingOption(in unsigned long clientId, + in nsIDOMWindow window, in unsigned short reason); - nsIDOMDOMRequest setCallForwardingOption(in nsIDOMWindow window, + nsIDOMDOMRequest setCallForwardingOption(in unsigned long clientId, + in nsIDOMWindow window, in nsIDOMMozMobileCFInfo CFInfo); - nsIDOMDOMRequest getCallBarringOption(in nsIDOMWindow window, - in jsval option); - nsIDOMDOMRequest setCallBarringOption(in nsIDOMWindow window, - in jsval option); - nsIDOMDOMRequest changeCallBarringPassword(in nsIDOMWindow window, + nsIDOMDOMRequest getCallBarringOption(in unsigned long clientId, + in nsIDOMWindow window, + in jsval option); + nsIDOMDOMRequest setCallBarringOption(in unsigned long clientId, + in nsIDOMWindow window, + in jsval option); + nsIDOMDOMRequest changeCallBarringPassword(in unsigned long clientId, + in nsIDOMWindow window, in jsval info); - nsIDOMDOMRequest setCallWaitingOption(in nsIDOMWindow window, + nsIDOMDOMRequest setCallWaitingOption(in unsigned long clientId, + in nsIDOMWindow window, in bool enabled); - nsIDOMDOMRequest getCallWaitingOption(in nsIDOMWindow window); + nsIDOMDOMRequest getCallWaitingOption(in unsigned long clientId, + in nsIDOMWindow window); - nsIDOMDOMRequest setCallingLineIdRestriction(in nsIDOMWindow window, + nsIDOMDOMRequest setCallingLineIdRestriction(in unsigned long clientId, + in nsIDOMWindow window, in unsigned short clirMode); - nsIDOMDOMRequest getCallingLineIdRestriction(in nsIDOMWindow window); + nsIDOMDOMRequest getCallingLineIdRestriction(in unsigned long clientId, + in nsIDOMWindow window); - nsIDOMDOMRequest exitEmergencyCbMode(in nsIDOMWindow window); + nsIDOMDOMRequest exitEmergencyCbMode(in unsigned long clientId, + in nsIDOMWindow window); }; From 7770bc81859c9d8c5a7116b19c3e56a2b4d49032 Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Wed, 30 Oct 2013 12:02:47 +0800 Subject: [PATCH 298/795] Bug 818353 - Part 2: DOM changes - use default client id (0) in MobileConnection. f=hsinyi,edgar r=smaug --- dom/network/src/MobileConnection.cpp | 59 +++++++++++++++++----------- dom/network/src/MobileConnection.h | 2 + 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/dom/network/src/MobileConnection.cpp b/dom/network/src/MobileConnection.cpp index f975eea969c4..38293074aca2 100644 --- a/dom/network/src/MobileConnection.cpp +++ b/dom/network/src/MobileConnection.cpp @@ -83,6 +83,9 @@ MobileConnection::MobileConnection() mProvider = do_GetService(NS_RILCONTENTHELPER_CONTRACTID); mWindow = nullptr; + // TODO: Bug 814629 - WebMobileConnection API: support multiple sim cards + mClientId = 0; + // Not being able to acquire the provider isn't fatal since we check // for it explicitly below. if (!mProvider) { @@ -101,7 +104,7 @@ MobileConnection::Init(nsPIDOMWindow* aWindow) if (!CheckPermission("mobilenetwork") && CheckPermission("mobileconnection")) { - DebugOnly rv = mProvider->RegisterMobileConnectionMsg(mListener); + DebugOnly rv = mProvider->RegisterMobileConnectionMsg(mClientId, mListener); NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed registering mobile connection messages with provider"); @@ -114,7 +117,7 @@ MobileConnection::Shutdown() { if (mProvider && mListener) { mListener->Disconnect(); - mProvider->UnregisterMobileConnectionMsg(mListener); + mProvider->UnregisterMobileConnectionMsg(mClientId, mListener); mProvider = nullptr; mListener = nullptr; } @@ -173,7 +176,7 @@ MobileConnection::GetVoice(nsIDOMMozMobileConnectionInfo** voice) if (!mProvider || !CheckPermission("mobileconnection")) { return NS_OK; } - return mProvider->GetVoiceConnectionInfo(voice); + return mProvider->GetVoiceConnectionInfo(mClientId, voice); } NS_IMETHODIMP @@ -184,7 +187,7 @@ MobileConnection::GetData(nsIDOMMozMobileConnectionInfo** data) if (!mProvider || !CheckPermission("mobileconnection")) { return NS_OK; } - return mProvider->GetDataConnectionInfo(data); + return mProvider->GetDataConnectionInfo(mClientId, data); } NS_IMETHODIMP @@ -195,7 +198,7 @@ MobileConnection::GetNetworkSelectionMode(nsAString& networkSelectionMode) if (!mProvider || !CheckPermission("mobileconnection")) { return NS_OK; } - return mProvider->GetNetworkSelectionMode(networkSelectionMode); + return mProvider->GetNetworkSelectionMode(mClientId, networkSelectionMode); } NS_IMETHODIMP @@ -211,7 +214,7 @@ MobileConnection::GetNetworks(nsIDOMDOMRequest** request) return NS_ERROR_FAILURE; } - return mProvider->GetNetworks(GetOwner(), request); + return mProvider->GetNetworks(mClientId, GetOwner(), request); } NS_IMETHODIMP @@ -227,7 +230,7 @@ MobileConnection::SelectNetwork(nsIDOMMozMobileNetworkInfo* network, nsIDOMDOMRe return NS_ERROR_FAILURE; } - return mProvider->SelectNetwork(GetOwner(), network, request); + return mProvider->SelectNetwork(mClientId, GetOwner(), network, request); } NS_IMETHODIMP @@ -243,7 +246,7 @@ MobileConnection::SelectNetworkAutomatically(nsIDOMDOMRequest** request) return NS_ERROR_FAILURE; } - return mProvider->SelectNetworkAutomatically(GetOwner(), request); + return mProvider->SelectNetworkAutomatically(mClientId, GetOwner(), request); } NS_IMETHODIMP @@ -259,7 +262,7 @@ MobileConnection::SetRoamingPreference(const nsAString& aMode, nsIDOMDOMRequest* return NS_ERROR_FAILURE; } - return mProvider->SetRoamingPreference(GetOwner(), aMode, aDomRequest); + return mProvider->SetRoamingPreference(mClientId, GetOwner(), aMode, aDomRequest); } NS_IMETHODIMP @@ -275,7 +278,7 @@ MobileConnection::GetRoamingPreference(nsIDOMDOMRequest** aDomRequest) return NS_ERROR_FAILURE; } - return mProvider->GetRoamingPreference(GetOwner(), aDomRequest); + return mProvider->GetRoamingPreference(mClientId, GetOwner(), aDomRequest); } NS_IMETHODIMP @@ -291,7 +294,7 @@ MobileConnection::SetVoicePrivacyMode(bool aEnabled, nsIDOMDOMRequest** aDomRequ return NS_ERROR_FAILURE; } - return mProvider->SetVoicePrivacyMode(GetOwner(), aEnabled, aDomRequest); + return mProvider->SetVoicePrivacyMode(mClientId, GetOwner(), aEnabled, aDomRequest); } NS_IMETHODIMP @@ -307,7 +310,7 @@ MobileConnection::GetVoicePrivacyMode(nsIDOMDOMRequest** aDomRequest) return NS_ERROR_FAILURE; } - return mProvider->GetVoicePrivacyMode(GetOwner(), aDomRequest); + return mProvider->GetVoicePrivacyMode(mClientId, GetOwner(), aDomRequest); } NS_IMETHODIMP @@ -322,7 +325,7 @@ MobileConnection::SendMMI(const nsAString& aMMIString, return NS_ERROR_FAILURE; } - return mProvider->SendMMI(GetOwner(), aMMIString, aRequest); + return mProvider->SendMMI(mClientId, GetOwner(), aMMIString, aRequest); } NS_IMETHODIMP @@ -336,7 +339,7 @@ MobileConnection::CancelMMI(nsIDOMDOMRequest** aRequest) return NS_ERROR_FAILURE; } - return mProvider->CancelMMI(GetOwner(), aRequest); + return mProvider->CancelMMI(mClientId, GetOwner(),aRequest); } NS_IMETHODIMP @@ -353,7 +356,7 @@ MobileConnection::GetCallForwardingOption(uint16_t aReason, return NS_ERROR_FAILURE; } - return mProvider->GetCallForwardingOption(GetOwner(), aReason, aRequest); + return mProvider->GetCallForwardingOption(mClientId, GetOwner(), aReason, aRequest); } NS_IMETHODIMP @@ -370,7 +373,7 @@ MobileConnection::SetCallForwardingOption(nsIDOMMozMobileCFInfo* aCFInfo, return NS_ERROR_FAILURE; } - return mProvider->SetCallForwardingOption(GetOwner(), aCFInfo, aRequest); + return mProvider->SetCallForwardingOption(mClientId, GetOwner(), aCFInfo, aRequest); } NS_IMETHODIMP @@ -387,7 +390,7 @@ MobileConnection::GetCallBarringOption(const JS::Value& aOption, return NS_ERROR_FAILURE; } - return mProvider->GetCallBarringOption(GetOwner(), aOption, aRequest); + return mProvider->GetCallBarringOption(mClientId, GetOwner(), aOption, aRequest); } NS_IMETHODIMP @@ -404,7 +407,7 @@ MobileConnection::SetCallBarringOption(const JS::Value& aOption, return NS_ERROR_FAILURE; } - return mProvider->SetCallBarringOption(GetOwner(), aOption, aRequest); + return mProvider->SetCallBarringOption(mClientId, GetOwner(), aOption, aRequest); } NS_IMETHODIMP @@ -421,7 +424,7 @@ MobileConnection::ChangeCallBarringPassword(const JS::Value& aInfo, return NS_ERROR_FAILURE; } - return mProvider->ChangeCallBarringPassword(GetOwner(), aInfo, aRequest); + return mProvider->ChangeCallBarringPassword(mClientId, GetOwner(), aInfo, aRequest); } NS_IMETHODIMP @@ -437,7 +440,7 @@ MobileConnection::GetCallWaitingOption(nsIDOMDOMRequest** aRequest) return NS_ERROR_FAILURE; } - return mProvider->GetCallWaitingOption(GetOwner(), aRequest); + return mProvider->GetCallWaitingOption(mClientId, GetOwner(), aRequest); } NS_IMETHODIMP @@ -454,7 +457,7 @@ MobileConnection::SetCallWaitingOption(bool aEnabled, return NS_ERROR_FAILURE; } - return mProvider->SetCallWaitingOption(GetOwner(), aEnabled, aRequest); + return mProvider->SetCallWaitingOption(mClientId, GetOwner(), aEnabled, aRequest); } NS_IMETHODIMP @@ -470,7 +473,7 @@ MobileConnection::GetCallingLineIdRestriction(nsIDOMDOMRequest** aRequest) return NS_ERROR_FAILURE; } - return mProvider->GetCallingLineIdRestriction(GetOwner(), aRequest); + return mProvider->GetCallingLineIdRestriction(mClientId, GetOwner(), aRequest); } NS_IMETHODIMP @@ -487,7 +490,7 @@ MobileConnection::SetCallingLineIdRestriction(unsigned short aClirMode, return NS_ERROR_FAILURE; } - return mProvider->SetCallingLineIdRestriction(GetOwner(), aClirMode, aRequest); + return mProvider->SetCallingLineIdRestriction(mClientId, GetOwner(), aClirMode, aRequest); } NS_IMETHODIMP @@ -503,7 +506,7 @@ MobileConnection::ExitEmergencyCbMode(nsIDOMDOMRequest** aRequest) return NS_ERROR_FAILURE; } - return mProvider->ExitEmergencyCbMode(GetOwner(), aRequest); + return mProvider->ExitEmergencyCbMode(mClientId, GetOwner(), aRequest); } // nsIMobileConnectionListener @@ -631,3 +634,11 @@ MobileConnection::NotifyOtaStatusChanged(const nsAString& aStatus) return DispatchTrustedEvent(ce); } + +NS_IMETHODIMP +MobileConnection::NotifyIccChanged() +{ + // TODO: Bug 814629 - WebMobileConnection API: support multiple sim cards + // Return NS_OK for now, will be implemented in Bug 814629. + return NS_OK; +} \ No newline at end of file diff --git a/dom/network/src/MobileConnection.h b/dom/network/src/MobileConnection.h index 549b9aee7680..678ffef5b844 100644 --- a/dom/network/src/MobileConnection.h +++ b/dom/network/src/MobileConnection.h @@ -48,6 +48,8 @@ private: nsRefPtr mListener; nsWeakPtr mWindow; + uint32_t mClientId; + bool CheckPermission(const char* type); }; From 26719c17cadf4d9e5e322d7e2840faebd92a78ea Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Wed, 30 Oct 2013 12:03:25 +0800 Subject: [PATCH 299/795] Bug 818353 - Part 3: DOM changes - use default client id (0) in BT. r=gyeh --- dom/bluetooth/BluetoothHfpManager.cpp | 6 ++++-- dom/bluetooth/BluetoothRilListener.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 5f3a61e061e2..43e901710605 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -593,7 +593,8 @@ BluetoothHfpManager::HandleVoiceConnectionChanged() NS_ENSURE_TRUE_VOID(connection); nsCOMPtr voiceInfo; - connection->GetVoiceConnectionInfo(getter_AddRefs(voiceInfo)); + // TODO: Bug 921991 - B2G BT: support multiple sim cards + connection->GetVoiceConnectionInfo(0, getter_AddRefs(voiceInfo)); NS_ENSURE_TRUE_VOID(voiceInfo); nsString type; @@ -629,7 +630,8 @@ BluetoothHfpManager::HandleVoiceConnectionChanged() * - manual: set mNetworkSelectionMode to 1 (manual) */ nsString mode; - connection->GetNetworkSelectionMode(mode); + // TODO: Bug 921991 - B2G BT: support multiple sim cards + connection->GetNetworkSelectionMode(0, mode); if (mode.EqualsLiteral("manual")) { mNetworkSelectionMode = 1; } else { diff --git a/dom/bluetooth/BluetoothRilListener.cpp b/dom/bluetooth/BluetoothRilListener.cpp index 5de926fbde40..71d731808949 100644 --- a/dom/bluetooth/BluetoothRilListener.cpp +++ b/dom/bluetooth/BluetoothRilListener.cpp @@ -125,6 +125,12 @@ MobileConnectionListener::NotifyOtaStatusChanged(const nsAString & status) return NS_OK; } +NS_IMETHODIMP +MobileConnectionListener::NotifyIccChanged() +{ + return NS_OK; +} + /** * TelephonyListener Implementation */ @@ -292,8 +298,9 @@ BluetoothRilListener::StartMobileConnectionListening() do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE(provider, false); + // TODO: Bug 921991 - B2G BT: support multiple sim cards nsresult rv = provider-> - RegisterMobileConnectionMsg(mMobileConnectionListener); + RegisterMobileConnectionMsg(0, mMobileConnectionListener); return NS_SUCCEEDED(rv); } @@ -304,8 +311,9 @@ BluetoothRilListener::StopMobileConnectionListening() do_GetService(NS_RILCONTENTHELPER_CONTRACTID); NS_ENSURE_TRUE(provider, false); + // TODO: Bug 921991 - B2G BT: support multiple sim cards nsresult rv = provider-> - UnregisterMobileConnectionMsg(mMobileConnectionListener); + UnregisterMobileConnectionMsg(0, mMobileConnectionListener); return NS_SUCCEEDED(rv); } From 521e1d27b6bf3305419473f3dea79c5d69dda60c Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Wed, 30 Oct 2013 12:03:54 +0800 Subject: [PATCH 300/795] Bug 818353 - Part 4: DOM changes - use default client id (0) in PhoneNumberUtils. f=edgar r=gwagner --- dom/phonenumberutils/PhoneNumberUtils.jsm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/phonenumberutils/PhoneNumberUtils.jsm b/dom/phonenumberutils/PhoneNumberUtils.jsm index e2893cd3136c..d7594e212ccf 100644 --- a/dom/phonenumberutils/PhoneNumberUtils.jsm +++ b/dom/phonenumberutils/PhoneNumberUtils.jsm @@ -44,7 +44,8 @@ this.PhoneNumberUtils = { #ifdef MOZ_B2G_RIL // Get network mcc - let voice = mobileConnection.voiceConnectionInfo; + // TODO: Bug 926740 - PhoneNumberUtils for multisim + let voice = mobileConnection.getVoiceConnectionInfo(0); if (voice && voice.network && voice.network.mcc) { mcc = voice.network.mcc; } From 891fbe98433a048daa8957255bb6e12a95598f81 Mon Sep 17 00:00:00 2001 From: Jessica Jong Date: Wed, 30 Oct 2013 12:04:21 +0800 Subject: [PATCH 301/795] Bug 818353 - Part 5: RIL implementation. f=edgar r=hsinyi --- dom/system/gonk/RILContentHelper.js | 426 +++++++++++++++---------- dom/system/gonk/RadioInterfaceLayer.js | 32 +- 2 files changed, 265 insertions(+), 193 deletions(-) diff --git a/dom/system/gonk/RILContentHelper.js b/dom/system/gonk/RILContentHelper.js index 94b3d03cfe0d..7991e858335c 100644 --- a/dom/system/gonk/RILContentHelper.js +++ b/dom/system/gonk/RILContentHelper.js @@ -82,13 +82,13 @@ const RIL_IPC_MSG_NAMES = [ "RIL:StkCommand", "RIL:StkSessionEnd", "RIL:DataError", - "RIL:SetCallForwardingOption", - "RIL:GetCallForwardingOption", - "RIL:SetCallBarringOption", - "RIL:GetCallBarringOption", + "RIL:SetCallForwardingOptions", + "RIL:GetCallForwardingOptions", + "RIL:SetCallBarringOptions", + "RIL:GetCallBarringOptions", "RIL:ChangeCallBarringPassword", - "RIL:SetCallWaitingOption", - "RIL:GetCallWaitingOption", + "RIL:SetCallWaitingOptions", + "RIL:GetCallWaitingOptions", "RIL:SetCallingLineIdRestriction", "RIL:GetCallingLineIdRestriction", "RIL:CellBroadcastReceived", @@ -380,13 +380,13 @@ CellBroadcastEtwsInfo.prototype = { popup: null }; -function CallBarringOption(option) { - this.program = option.program; - this.enabled = option.enabled; - this.password = option.password; - this.serviceClass = option.serviceClass; +function CallBarringOptions(options) { + this.program = options.program; + this.enabled = options.enabled; + this.password = options.password; + this.serviceClass = options.serviceClass; } -CallBarringOption.prototype = { +CallBarringOptions.prototype = { __exposedProps__ : {program: 'r', enabled: 'r', password: 'r', @@ -447,18 +447,30 @@ IccCardLockError.prototype = { function RILContentHelper() { this.updateDebugFlag(); - this.rilContext = { - cardState: RIL.GECKO_CARDSTATE_UNKNOWN, - networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN, - iccInfo: null, - voiceConnectionInfo: new MobileConnectionInfo(), - dataConnectionInfo: new MobileConnectionInfo() - }; + this.numClients = gNumRadioInterfaces; + debug("Number of clients: " + this.numClients); + + this.rilContexts = []; + for (let clientId = 0; clientId < this.numClients; clientId++) { + this.rilContexts[clientId] = { + cardState: RIL.GECKO_CARDSTATE_UNKNOWN, + networkSelectionMode: RIL.GECKO_NETWORK_SELECTION_UNKNOWN, + iccInfo: null, + voiceConnectionInfo: new MobileConnectionInfo(), + dataConnectionInfo: new MobileConnectionInfo() + }; + } + this.voicemailInfo = new VoicemailInfo(); this.voicemailDefaultServiceId = this.getVoicemailDefaultServiceId(); this.initDOMRequestHelper(/* aWindow */ null, RIL_IPC_MSG_NAMES); this._windowsMap = []; + this._selectingNetworks = []; + this._mobileConnectionListeners = []; + this._cellBroadcastListeners = []; + this._voicemailListeners = []; + this._iccListeners = []; Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); @@ -535,88 +547,119 @@ RILContentHelper.prototype = { * 1. Should clear iccInfo to null if there is no card detected. * 2. Need to create corresponding object based on iccType. */ - updateIccInfo: function updateIccInfo(newInfo) { + updateIccInfo: function updateIccInfo(clientId, newInfo) { + let rilContext = this.rilContexts[clientId]; + // Card is not detected, clear iccInfo to null. if (!newInfo || !newInfo.iccType) { - this.rilContext.iccInfo = null; + if (rilContext.iccInfo) { + rilContext.iccInfo = null; + this._deliverEvent(clientId, + "_mobileConnectionListeners", + "notifyIccChanged", + null); + } return; } // If iccInfo is null, new corresponding object based on iccType. - if (!this.rilContext.iccInfo) { + if (!rilContext.iccInfo) { if (newInfo.iccType === "ruim" || newInfo.iccType === "csim") { - this.rilContext.iccInfo = new CdmaIccInfo(); + rilContext.iccInfo = new CdmaIccInfo(); } else { - this.rilContext.iccInfo = new GsmIccInfo(); + rilContext.iccInfo = new GsmIccInfo(); } } + let changed = (rilContext.iccInfo.iccid != newInfo.iccid) ? + true : false; - this.updateInfo(newInfo, this.rilContext.iccInfo); + this.updateInfo(newInfo, rilContext.iccInfo); + + // Deliver event after info is updated. + if (changed) { + this._deliverEvent(clientId, + "_mobileConnectionListeners", + "notifyIccChanged", + null); + } }, _windowsMap: null, - rilContext: null, + rilContexts: null, - getRilContext: function getRilContext() { - // Update ril context by sending IPC message to chrome only when the first + getRilContext: function getRilContext(clientId) { + // Update ril contexts by sending IPC message to chrome only when the first // time we require it. The information will be updated by following info // changed messages. - this.getRilContext = function getRilContext() { - return this.rilContext; + this.getRilContext = function getRilContext(clientId) { + return this.rilContexts[clientId]; }; - let rilContext = - cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: 0})[0]; - if (!rilContext) { - debug("Received null rilContext from chrome process."); - return; + for (let cId = 0; cId < this.numClients; cId++) { + let rilContext = + cpmm.sendSyncMessage("RIL:GetRilContext", {clientId: cId})[0]; + if (!rilContext) { + debug("Received null rilContext from chrome process."); + continue; + } + this.rilContexts[cId].cardState = rilContext.cardState; + this.rilContexts[cId].networkSelectionMode = rilContext.networkSelectionMode; + this.updateIccInfo(cId, rilContext.iccInfo); + this.updateConnectionInfo(rilContext.voice, this.rilContexts[cId].voiceConnectionInfo); + this.updateConnectionInfo(rilContext.data, this.rilContexts[cId].dataConnectionInfo); } - this.rilContext.cardState = rilContext.cardState; - this.rilContext.networkSelectionMode = rilContext.networkSelectionMode; - this.updateIccInfo(rilContext.iccInfo); - this.updateConnectionInfo(rilContext.voice, this.rilContext.voiceConnectionInfo); - this.updateConnectionInfo(rilContext.data, this.rilContext.dataConnectionInfo); - return this.rilContext; + return this.rilContexts[clientId]; + }, + + /** + * nsIIccProvider + */ + + get iccInfo() { + //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. + let context = this.getRilContext(0); + return context && context.iccInfo; + }, + + get cardState() { + //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. + let context = this.getRilContext(0); + return context && context.cardState; }, /** * nsIMobileConnectionProvider */ - get iccInfo() { - let context = this.getRilContext(); - return context && context.iccInfo; - }, - - get voiceConnectionInfo() { - let context = this.getRilContext(); + getVoiceConnectionInfo: function getVoiceConnectionInfo(clientId) { + let context = this.getRilContext(clientId); return context && context.voiceConnectionInfo; }, - get dataConnectionInfo() { - let context = this.getRilContext(); + getDataConnectionInfo: function getDataConnectionInfo(clientId) { + let context = this.getRilContext(clientId); return context && context.dataConnectionInfo; }, - get cardState() { - let context = this.getRilContext(); - return context && context.cardState; + getIccId: function getIccId(clientId) { + let context = this.getRilContext(clientId); + return context && context.iccInfo && context.iccInfo.iccid; }, - get networkSelectionMode() { - let context = this.getRilContext(); + getNetworkSelectionMode: function getNetworkSelectionMode(clientId) { + let context = this.getRilContext(clientId); return context && context.networkSelectionMode; }, /** - * The network that is currently trying to be selected (or "automatic"). - * This helps ensure that only one network is selected at a time. + * The networks that are currently trying to be selected (or "automatic"). + * This helps ensure that only one network per client is selected at a time. */ - _selectingNetwork: null, + _selectingNetworks: null, - getNetworks: function getNetworks(window) { + getNetworks: function getNetworks(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -626,7 +669,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:GetAvailableNetworks", { - clientId: 0, + clientId: clientId, data: { requestId: requestId } @@ -634,14 +677,14 @@ RILContentHelper.prototype = { return request; }, - selectNetwork: function selectNetwork(window, network) { + selectNetwork: function selectNetwork(clientId, window, network) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); } - if (this._selectingNetwork) { - throw new Error("Already selecting a network: " + this._selectingNetwork); + if (this._selectingNetworks[clientId]) { + throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]); } if (!network) { @@ -659,8 +702,8 @@ RILContentHelper.prototype = { let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); - if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL && - this.rilContext.voiceConnectionInfo.network === network) { + if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_MANUAL && + this.rilContexts[clientId].voiceConnectionInfo.network === network) { // Already manually selected this network, so schedule // onsuccess to be fired on the next tick @@ -668,10 +711,10 @@ RILContentHelper.prototype = { return request; } - this._selectingNetwork = network; + this._selectingNetworks[clientId] = network; cpmm.sendAsyncMessage("RIL:SelectNetwork", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, mnc: network.mnc, @@ -682,30 +725,30 @@ RILContentHelper.prototype = { return request; }, - selectNetworkAutomatically: function selectNetworkAutomatically(window) { + selectNetworkAutomatically: function selectNetworkAutomatically(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); } - if (this._selectingNetwork) { - throw new Error("Already selecting a network: " + this._selectingNetwork); + if (this._selectingNetworks[clientId]) { + throw new Error("Already selecting a network: " + this._selectingNetworks[clientId]); } let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); - if (this.rilContext.networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) { + if (this.rilContexts[clientId].networkSelectionMode == RIL.GECKO_NETWORK_SELECTION_AUTOMATIC) { // Already using automatic selection mode, so schedule // onsuccess to be be fired on the next tick this.dispatchFireRequestSuccess(requestId, null); return request; } - this._selectingNetwork = "automatic"; + this._selectingNetworks[clientId] = "automatic"; cpmm.sendAsyncMessage("RIL:SelectNetworkAuto", { - clientId: 0, + clientId: clientId, data: { requestId: requestId } @@ -713,7 +756,7 @@ RILContentHelper.prototype = { return request; }, - setRoamingPreference: function setRoamingPreference(window, mode) { + setRoamingPreference: function setRoamingPreference(clientId, window, mode) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -729,7 +772,7 @@ RILContentHelper.prototype = { } cpmm.sendAsyncMessage("RIL:SetRoamingPreference", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, mode: mode @@ -738,7 +781,7 @@ RILContentHelper.prototype = { return request; }, - getRoamingPreference: function getRoamingPreference(window) { + getRoamingPreference: function getRoamingPreference(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -748,7 +791,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:GetRoamingPreference", { - clientId: 0, + clientId: clientId, data: { requestId: requestId } @@ -756,7 +799,7 @@ RILContentHelper.prototype = { return request; }, - setVoicePrivacyMode: function setVoicePrivacyMode(window, enabled) { + setVoicePrivacyMode: function setVoicePrivacyMode(clientId, window, enabled) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -766,7 +809,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:SetVoicePrivacyMode", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, enabled: enabled @@ -775,7 +818,7 @@ RILContentHelper.prototype = { return request; }, - getVoicePrivacyMode: function getVoicePrivacyMode(window) { + getVoicePrivacyMode: function getVoicePrivacyMode(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -785,7 +828,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:GetVoicePrivacyMode", { - clientId: 0, + clientId: clientId, data: { requestId: requestId } @@ -861,7 +904,7 @@ RILContentHelper.prototype = { return request; }, - sendMMI: function sendMMI(window, mmi) { + sendMMI: function sendMMI(clientId, window, mmi) { debug("Sending MMI " + mmi); if (!window) { throw Components.Exception("Can't get window object", @@ -874,7 +917,7 @@ RILContentHelper.prototype = { this._windowsMap[requestId] = window; cpmm.sendAsyncMessage("RIL:SendMMI", { - clientId: 0, + clientId: clientId, data: { mmi: mmi, requestId: requestId @@ -883,7 +926,7 @@ RILContentHelper.prototype = { return request; }, - cancelMMI: function cancelMMI(window) { + cancelMMI: function cancelMMI(clientId, window) { debug("Cancel MMI"); if (!window) { throw Components.Exception("Can't get window object", @@ -892,7 +935,7 @@ RILContentHelper.prototype = { let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:CancelMMI", { - clientId: 0, + clientId: clientId, data: { requestId: requestId } @@ -1086,7 +1129,7 @@ RILContentHelper.prototype = { return request; }, - getCallForwardingOption: function getCallForwardingOption(window, reason) { + getCallForwardingOption: function getCallForwardingOption(clientId, window, reason) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1100,8 +1143,8 @@ RILContentHelper.prototype = { return request; } - cpmm.sendAsyncMessage("RIL:GetCallForwardingOption", { - clientId: 0, + cpmm.sendAsyncMessage("RIL:GetCallForwardingOptions", { + clientId: clientId, data: { requestId: requestId, reason: reason @@ -1111,7 +1154,7 @@ RILContentHelper.prototype = { return request; }, - setCallForwardingOption: function setCallForwardingOption(window, cfInfo) { + setCallForwardingOption: function setCallForwardingOption(clientId, window, cfInfo) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1127,8 +1170,8 @@ RILContentHelper.prototype = { return request; } - cpmm.sendAsyncMessage("RIL:SetCallForwardingOption", { - clientId: 0, + cpmm.sendAsyncMessage("RIL:SetCallForwardingOptions", { + clientId: clientId, data: { requestId: requestId, active: cfInfo.active, @@ -1142,7 +1185,7 @@ RILContentHelper.prototype = { return request; }, - getCallBarringOption: function getCallBarringOption(window, option) { + getCallBarringOption: function getCallBarringOption(clientId, window, option) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1151,14 +1194,14 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); if (DEBUG) debug("getCallBarringOption: " + JSON.stringify(option)); - if (!this._isValidCallBarringOption(option)) { + if (!this._isValidCallBarringOptions(option)) { this.dispatchFireRequestError(requestId, RIL.GECKO_ERROR_INVALID_PARAMETER); return request; } - cpmm.sendAsyncMessage("RIL:GetCallBarringOption", { - clientId: 0, + cpmm.sendAsyncMessage("RIL:GetCallBarringOptions", { + clientId: clientId, data: { requestId: requestId, program: option.program, @@ -1169,7 +1212,7 @@ RILContentHelper.prototype = { return request; }, - setCallBarringOption: function setCallBarringOption(window, option) { + setCallBarringOption: function setCallBarringOption(clientId, window, option) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1178,14 +1221,14 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); if (DEBUG) debug("setCallBarringOption: " + JSON.stringify(option)); - if (!this._isValidCallBarringOption(option, true)) { + if (!this._isValidCallBarringOptions(option, true)) { this.dispatchFireRequestError(requestId, RIL.GECKO_ERROR_INVALID_PARAMETER); return request; } - cpmm.sendAsyncMessage("RIL:SetCallBarringOption", { - clientId: 0, + cpmm.sendAsyncMessage("RIL:SetCallBarringOptions", { + clientId: clientId, data: { requestId: requestId, program: option.program, @@ -1197,7 +1240,7 @@ RILContentHelper.prototype = { return request; }, - changeCallBarringPassword: function changeCallBarringPassword(window, info) { + changeCallBarringPassword: function changeCallBarringPassword(clientId, window, info) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1215,14 +1258,14 @@ RILContentHelper.prototype = { if (DEBUG) debug("changeCallBarringPassword: " + JSON.stringify(info)); info.requestId = requestId; cpmm.sendAsyncMessage("RIL:ChangeCallBarringPassword", { - clientId: 0, + clientId: clientId, data: info }); return request; }, - getCallWaitingOption: function getCallWaitingOption(window) { + getCallWaitingOption: function getCallWaitingOption(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1230,8 +1273,8 @@ RILContentHelper.prototype = { let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); - cpmm.sendAsyncMessage("RIL:GetCallWaitingOption", { - clientId: 0, + cpmm.sendAsyncMessage("RIL:GetCallWaitingOptions", { + clientId: clientId, data: { requestId: requestId } @@ -1240,7 +1283,7 @@ RILContentHelper.prototype = { return request; }, - setCallWaitingOption: function setCallWaitingOption(window, enabled) { + setCallWaitingOption: function setCallWaitingOption(clientId, window, enabled) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1248,8 +1291,8 @@ RILContentHelper.prototype = { let request = Services.DOMRequest.createRequest(window); let requestId = this.getRequestId(request); - cpmm.sendAsyncMessage("RIL:SetCallWaitingOption", { - clientId: 0, + cpmm.sendAsyncMessage("RIL:SetCallWaitingOptions", { + clientId: clientId, data: { requestId: requestId, enabled: enabled @@ -1259,7 +1302,7 @@ RILContentHelper.prototype = { return request; }, - getCallingLineIdRestriction: function getCallingLineIdRestriction(window) { + getCallingLineIdRestriction: function getCallingLineIdRestriction(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1268,7 +1311,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:GetCallingLineIdRestriction", { - clientId: 0, + clientId: clientId, data: { requestId: requestId } @@ -1278,7 +1321,7 @@ RILContentHelper.prototype = { }, setCallingLineIdRestriction: - function setCallingLineIdRestriction(window, clirMode) { + function setCallingLineIdRestriction(clientId, window, clirMode) { if (window == null) { throw Components.Exception("Can't get window object", @@ -1288,7 +1331,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:SetCallingLineIdRestriction", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, clirMode: clirMode @@ -1298,7 +1341,7 @@ RILContentHelper.prototype = { return request; }, - exitEmergencyCbMode: function exitEmergencyCbMode(window) { + exitEmergencyCbMode: function exitEmergencyCbMode(clientId, window) { if (window == null) { throw Components.Exception("Can't get window object", Cr.NS_ERROR_UNEXPECTED); @@ -1307,7 +1350,7 @@ RILContentHelper.prototype = { let requestId = this.getRequestId(request); cpmm.sendAsyncMessage("RIL:ExitEmergencyCbMode", { - clientId: 0, + clientId: clientId, data: { requestId: requestId, } @@ -1357,10 +1400,13 @@ RILContentHelper.prototype = { return this.getVoicemailInfo().displayName; }, - registerListener: function registerListener(listenerType, listener) { - let listeners = this[listenerType]; + registerListener: function registerListener(listenerType, clientId, listener) { + if (!this[listenerType]) { + return; + } + let listeners = this[listenerType][clientId]; if (!listeners) { - listeners = this[listenerType] = []; + listeners = this[listenerType][clientId] = []; } if (listeners.indexOf(listener) != -1) { @@ -1371,8 +1417,11 @@ RILContentHelper.prototype = { if (DEBUG) debug("Registered " + listenerType + " listener: " + listener); }, - unregisterListener: function unregisterListener(listenerType, listener) { - let listeners = this[listenerType]; + unregisterListener: function unregisterListener(listenerType, clientId, listener) { + if (!this[listenerType]) { + return; + } + let listeners = this[listenerType][clientId]; if (!listeners) { return; } @@ -1384,44 +1433,50 @@ RILContentHelper.prototype = { } }, - registerMobileConnectionMsg: function registerMobileConnectionMsg(listener) { + registerMobileConnectionMsg: function registerMobileConnectionMsg(clientId, listener) { debug("Registering for mobile connection related messages"); - this.registerListener("_mobileConnectionListeners", listener); + this.registerListener("_mobileConnectionListeners", clientId, listener); cpmm.sendAsyncMessage("RIL:RegisterMobileConnectionMsg"); }, - unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(listener) { - this.unregisterListener("_mobileConnectionListeners", listener); + unregisterMobileConnectionMsg: function unregisteMobileConnectionMsg(clientId, listener) { + this.unregisterListener("_mobileConnectionListeners", clientId, listener); }, registerVoicemailMsg: function registerVoicemailMsg(listener) { debug("Registering for voicemail-related messages"); - this.registerListener("_voicemailListeners", listener); + //TODO: Bug 814634 - WebVoicemail API: support multiple sim cards. + this.registerListener("_voicemailListeners", 0, listener); cpmm.sendAsyncMessage("RIL:RegisterVoicemailMsg"); }, unregisterVoicemailMsg: function unregisteVoicemailMsg(listener) { - this.unregisterListener("_voicemailListeners", listener); + //TODO: Bug 814634 - WebVoicemail API: support multiple sim cards. + this.unregisterListener("_voicemailListeners", 0, listener); }, registerCellBroadcastMsg: function registerCellBroadcastMsg(listener) { debug("Registering for Cell Broadcast related messages"); - this.registerListener("_cellBroadcastListeners", listener); + //TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards + this.registerListener("_cellBroadcastListeners", 0, listener); cpmm.sendAsyncMessage("RIL:RegisterCellBroadcastMsg"); }, unregisterCellBroadcastMsg: function unregisterCellBroadcastMsg(listener) { - this.unregisterListener("_cellBroadcastListeners", listener); + //TODO: Bug 921326 - Cellbroadcast API: support multiple sim cards + this.unregisterListener("_cellBroadcastListeners", 0, listener); }, registerIccMsg: function registerIccMsg(listener) { debug("Registering for ICC related messages"); - this.registerListener("_iccListeners", listener); + //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. + this.registerListener("_iccListeners", 0, listener); cpmm.sendAsyncMessage("RIL:RegisterIccMsg"); }, unregisterIccMsg: function unregisterIccMsg(listener) { - this.unregisterListener("_iccListeners", listener); + //TODO: Bug 814637 - WebIccManager API: support multiple sim cards. + this.unregisterListener("_iccListeners", 0, listener); }, // nsIObserver @@ -1511,35 +1566,43 @@ RILContentHelper.prototype = { debug("Received message '" + msg.name + "': " + JSON.stringify(msg.json)); let data = msg.json.data; + let clientId = msg.json.clientId; switch (msg.name) { case "RIL:CardStateChanged": - if (this.rilContext.cardState != data.cardState) { - this.rilContext.cardState = data.cardState; - this._deliverEvent("_iccListeners", + if (this.rilContexts[clientId].cardState != data.cardState) { + this.rilContexts[clientId].cardState = data.cardState; + this._deliverEvent(clientId, + "_iccListeners", "notifyCardStateChanged", null); } break; case "RIL:IccInfoChanged": - this.updateIccInfo(data); - this._deliverEvent("_iccListeners", "notifyIccInfoChanged", null); + this.updateIccInfo(clientId, data); + this._deliverEvent(clientId, + "_iccListeners", + "notifyIccInfoChanged", + null); break; case "RIL:VoiceInfoChanged": this.updateConnectionInfo(data, - this.rilContext.voiceConnectionInfo); - this._deliverEvent("_mobileConnectionListeners", + this.rilContexts[clientId].voiceConnectionInfo); + this._deliverEvent(clientId, + "_mobileConnectionListeners", "notifyVoiceChanged", null); break; case "RIL:DataInfoChanged": this.updateConnectionInfo(data, - this.rilContext.dataConnectionInfo); - this._deliverEvent("_mobileConnectionListeners", + this.rilContexts[clientId].dataConnectionInfo); + this._deliverEvent(clientId, + "_mobileConnectionListeners", "notifyDataChanged", null); break; case "RIL:OtaStatusChanged": - this._deliverEvent("_mobileConnectionListeners", + this._deliverEvent(clientId, + "_mobileConnectionListeners", "notifyOtaStatusChanged", [data]); break; @@ -1547,18 +1610,18 @@ RILContentHelper.prototype = { this.handleGetAvailableNetworks(data); break; case "RIL:NetworkSelectionModeChanged": - this.rilContext.networkSelectionMode = data.mode; + this.rilContexts[clientId].networkSelectionMode = data.mode; break; case "RIL:SelectNetwork": - this.handleSelectNetwork(data, + this.handleSelectNetwork(clientId, data, RIL.GECKO_NETWORK_SELECTION_MANUAL); break; case "RIL:SelectNetworkAuto": - this.handleSelectNetwork(data, + this.handleSelectNetwork(clientId, data, RIL.GECKO_NETWORK_SELECTION_AUTOMATIC); break; case "RIL:VoicemailNotification": - this.handleVoicemailNotification(data); + this.handleVoicemailNotification(clientId, data); break; case "RIL:VoicemailInfoChanged": this.updateInfo(data, this.voicemailInfo); @@ -1593,7 +1656,8 @@ RILContentHelper.prototype = { } break; case "RIL:USSDReceived": - this._deliverEvent("_mobileConnectionListeners", + this._deliverEvent(clientId, + "_mobileConnectionListeners", "notifyUssdReceived", [data.message, data.sessionEnded]); break; @@ -1602,11 +1666,11 @@ RILContentHelper.prototype = { this.handleSendCancelMMI(data); break; case "RIL:StkCommand": - this._deliverEvent("_iccListeners", "notifyStkCommand", + this._deliverEvent(clientId, "_iccListeners", "notifyStkCommand", [JSON.stringify(data)]); break; case "RIL:StkSessionEnd": - this._deliverEvent("_iccListeners", "notifyStkSessionEnd", null); + this._deliverEvent(clientId, "_iccListeners", "notifyStkSessionEnd", null); break; case "RIL:IccOpenChannel": this.handleSimpleRequest(data.requestId, data.errorMsg, @@ -1625,34 +1689,35 @@ RILContentHelper.prototype = { this.handleSimpleRequest(data.requestId, data.errorMsg, null); break; case "RIL:DataError": - this.updateConnectionInfo(data, this.rilContext.dataConnectionInfo); - this._deliverEvent("_mobileConnectionListeners", "notifyDataError", + this.updateConnectionInfo(data, this.rilContexts[clientId].dataConnectionInfo); + this._deliverEvent(clientId, "_mobileConnectionListeners", "notifyDataError", [data.errorMsg]); break; - case "RIL:GetCallForwardingOption": - this.handleGetCallForwardingOption(data); + case "RIL:GetCallForwardingOptions": + this.handleGetCallForwardingOptions(data); break; - case "RIL:SetCallForwardingOption": + case "RIL:SetCallForwardingOptions": this.handleSimpleRequest(data.requestId, data.errorMsg, null); break; - case "RIL:GetCallBarringOption": - this.handleGetCallBarringOption(data); + case "RIL:GetCallBarringOptions": + this.handleGetCallBarringOptions(data); break; - case "RIL:SetCallBarringOption": + case "RIL:SetCallBarringOptions": this.handleSimpleRequest(data.requestId, data.errorMsg, null); break; case "RIL:ChangeCallBarringPassword": this.handleSimpleRequest(data.requestId, data.errorMsg, null); break; - case "RIL:GetCallWaitingOption": + case "RIL:GetCallWaitingOptions": this.handleSimpleRequest(data.requestId, data.errorMsg, data.enabled); break; - case "RIL:SetCallWaitingOption": + case "RIL:SetCallWaitingOptions": this.handleSimpleRequest(data.requestId, data.errorMsg, null); break; case "RIL:CfStateChanged": - this._deliverEvent("_mobileConnectionListeners", + this._deliverEvent(clientId, + "_mobileConnectionListeners", "notifyCFStateChange", [data.success, data.action, data.reason, data.number, @@ -1666,7 +1731,8 @@ RILContentHelper.prototype = { break; case "RIL:CellBroadcastReceived": { let message = new CellBroadcastMessage(data); - this._deliverEvent("_cellBroadcastListeners", + this._deliverEvent(clientId, + "_cellBroadcastListeners", "notifyMessageReceived", [message]); break; @@ -1682,7 +1748,8 @@ RILContentHelper.prototype = { this.handleExitEmergencyCbMode(data); break; case "RIL:EmergencyCbModeChanged": - this._deliverEvent("_mobileConnectionListeners", + this._deliverEvent(clientId, + "_mobileConnectionListeners", "notifyEmergencyCbModeChanged", [data.active, data.timeoutMs]); break; @@ -1723,9 +1790,9 @@ RILContentHelper.prototype = { this.fireRequestSuccess(message.requestId, networks); }, - handleSelectNetwork: function handleSelectNetwork(message, mode) { - this._selectingNetwork = null; - this.rilContext.networkSelectionMode = mode; + handleSelectNetwork: function handleSelectNetwork(clientId, message, mode) { + this._selectingNetworks[clientId] = null; + this.rilContexts[clientId].networkSelectionMode = mode; if (message.errorMsg) { this.fireRequestError(message.requestId, message.errorMsg); @@ -1773,7 +1840,8 @@ RILContentHelper.prototype = { this.fireRequestSuccess(message.requestId, result); }, - handleVoicemailNotification: function handleVoicemailNotification(message) { + handleVoicemailNotification: function handleVoicemailNotification(clientId, message) { + // Bug 814634 - WebVoicemail API: support multiple sim cards let changed = false; if (!this.voicemailStatus) { this.voicemailStatus = new VoicemailStatus(); @@ -1803,7 +1871,8 @@ RILContentHelper.prototype = { } if (changed) { - this._deliverEvent("_voicemailListeners", + this._deliverEvent(clientId, + "_voicemailListeners", "notifyStatusChanged", [this.voicemailStatus]); } @@ -1818,7 +1887,7 @@ RILContentHelper.prototype = { } }, - handleGetCallForwardingOption: function handleGetCallForwardingOption(message) { + handleGetCallForwardingOptions: function handleGetCallForwardingOptions(message) { if (message.errorMsg) { this.fireRequestError(message.requestId, message.errorMsg); return; @@ -1828,12 +1897,12 @@ RILContentHelper.prototype = { this.fireRequestSuccess(message.requestId, message.rules); }, - handleGetCallBarringOption: function handleGetCallBarringOption(message) { + handleGetCallBarringOptions: function handleGetCallBarringOptions(message) { if (!message.success) { this.fireRequestError(message.requestId, message.errorMsg); } else { - let option = new CallBarringOption(message); - this.fireRequestSuccess(message.requestId, option); + let options = new CallBarringOptions(message); + this.fireRequestSuccess(message.requestId, options); } }, @@ -1909,8 +1978,11 @@ RILContentHelper.prototype = { } }, - _deliverEvent: function _deliverEvent(listenerType, name, args) { - let thisListeners = this[listenerType]; + _deliverEvent: function _deliverEvent(clientId, listenerType, name, args) { + if (!this[listenerType]) { + return; + } + let thisListeners = this[listenerType][clientId]; if (!thisListeners) { return; } @@ -1981,18 +2053,18 @@ RILContentHelper.prototype = { }, /** - * Helper for guarding us against invalid option for call barring. + * Helper for guarding us against invalid options for call barring. */ - _isValidCallBarringOption: - function _isValidCallBarringOption(option, usedForSetting) { - if (!option || - option.serviceClass == null || - !this._isValidCallBarringProgram(option.program)) { + _isValidCallBarringOptions: + function _isValidCallBarringOptions(options, usedForSetting) { + if (!options || + options.serviceClass == null || + !this._isValidCallBarringProgram(options.program)) { return false; } - // For setting callbarring option, |enabled| and |password| are required. - if (usedForSetting && (option.enabled == null || option.password == null)) { + // For setting callbarring options, |enabled| and |password| are required. + if (usedForSetting && (options.enabled == null || options.password == null)) { return false; } diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index c0cf46d9c767..a6256789a74f 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -94,13 +94,13 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [ "RIL:SendMMI", "RIL:CancelMMI", "RIL:RegisterMobileConnectionMsg", - "RIL:SetCallForwardingOption", - "RIL:GetCallForwardingOption", - "RIL:SetCallBarringOption", - "RIL:GetCallBarringOption", + "RIL:SetCallForwardingOptions", + "RIL:GetCallForwardingOptions", + "RIL:SetCallBarringOptions", + "RIL:GetCallBarringOptions", "RIL:ChangeCallBarringPassword", - "RIL:SetCallWaitingOption", - "RIL:GetCallWaitingOption", + "RIL:SetCallWaitingOptions", + "RIL:GetCallWaitingOptions", "RIL:SetCallingLineIdRestriction", "RIL:GetCallingLineIdRestriction", "RIL:SetRoamingPreference", @@ -946,25 +946,25 @@ RadioInterface.prototype = { case "RIL:UpdateIccContact": this.workerMessenger.sendWithIPCMessage(msg, "updateICCContact"); break; - case "RIL:SetCallForwardingOption": - this.setCallForwardingOption(msg.target, msg.json.data); + case "RIL:SetCallForwardingOptions": + this.setCallForwardingOptions(msg.target, msg.json.data); break; - case "RIL:GetCallForwardingOption": + case "RIL:GetCallForwardingOptions": this.workerMessenger.sendWithIPCMessage(msg, "queryCallForwardStatus"); break; - case "RIL:SetCallBarringOption": + case "RIL:SetCallBarringOptions": this.workerMessenger.sendWithIPCMessage(msg, "setCallBarring"); break; - case "RIL:GetCallBarringOption": + case "RIL:GetCallBarringOptions": this.workerMessenger.sendWithIPCMessage(msg, "queryCallBarringStatus"); break; case "RIL:ChangeCallBarringPassword": this.workerMessenger.sendWithIPCMessage(msg, "changeCallBarringPassword"); break; - case "RIL:SetCallWaitingOption": + case "RIL:SetCallWaitingOptions": this.workerMessenger.sendWithIPCMessage(msg, "setCallWaiting"); break; - case "RIL:GetCallWaitingOption": + case "RIL:GetCallWaitingOptions": this.workerMessenger.sendWithIPCMessage(msg, "queryCallWaiting"); break; case "RIL:SetCallingLineIdRestriction": @@ -2433,12 +2433,12 @@ RadioInterface.prototype = { }).bind(this)); }, - setCallForwardingOption: function setCallForwardingOption(target, message) { - if (DEBUG) this.debug("setCallForwardingOption: " + JSON.stringify(message)); + setCallForwardingOptions: function setCallForwardingOptions(target, message) { + if (DEBUG) this.debug("setCallForwardingOptions: " + JSON.stringify(message)); message.serviceClass = RIL.ICC_SERVICE_CLASS_VOICE; this.workerMessenger.send("setCallForward", message, (function(response) { this._sendCfStateChanged(response); - target.sendAsyncMessage("RIL:SetCallForwardingOption", { + target.sendAsyncMessage("RIL:SetCallForwardingOptions", { clientId: this.clientId, data: response }); From e9e5f812ec7913cc5b8f0da832fbaf83512cb3e2 Mon Sep 17 00:00:00 2001 From: Shawn Huang Date: Wed, 30 Oct 2013 13:46:03 +0800 Subject: [PATCH 302/795] Bug 929941- Listening bluetooth address, name, scan mode events for bluedroid stack, r=echou --- dom/bluetooth/BluetoothServiceBluedroid.cpp | 94 ++++++++++++++++++++- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/dom/bluetooth/BluetoothServiceBluedroid.cpp b/dom/bluetooth/BluetoothServiceBluedroid.cpp index 63e86dba1f59..4830e878719a 100644 --- a/dom/bluetooth/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/BluetoothServiceBluedroid.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ /* ** Copyright 2006, The Android Open Source Project @@ -31,6 +31,8 @@ using namespace mozilla; using namespace mozilla::ipc; USING_BLUETOOTH_NAMESPACE +typedef char bdstr_t[18]; + /** * Classes only used in this file */ @@ -63,6 +65,10 @@ private: static bluetooth_device_t* sBtDevice; static const bt_interface_t* sBtInterface; static bool sIsBtEnabled = false; +static bool sAdapterDiscoverable = false; +static nsString sAdapterBdAddress; +static nsString sAdapterBdName; +static uint32_t sAdapterDiscoverableTimeout; /** * Static callback functions @@ -72,7 +78,7 @@ AdapterStateChangeCallback(bt_state_t aStatus) { MOZ_ASSERT(!NS_IsMainThread()); - BT_LOGD("Enter: %s, BT_STATE:%d", __FUNCTION__, aStatus); + BT_LOGD("%s, BT_STATE:%d", __FUNCTION__, aStatus); nsAutoString signalName; if (aStatus == BT_STATE_ON) { sIsBtEnabled = true; @@ -90,9 +96,78 @@ AdapterStateChangeCallback(bt_state_t aStatus) } } +static void +BdAddressTypeToString(bt_bdaddr_t* aBdAddressType, nsAString& aRetBdAddress) +{ + uint8_t* addr = aBdAddressType->address; + bdstr_t bdstr; + + sprintf((char*)bdstr, "%02x:%02x:%02x:%02x:%02x:%02x", + (int)addr[0],(int)addr[1],(int)addr[2], + (int)addr[3],(int)addr[4],(int)addr[5]); + + aRetBdAddress = NS_ConvertUTF8toUTF16((char*)bdstr); +} + +static void +AdapterPropertiesChangeCallback(bt_status_t aStatus, int aNumProperties, + bt_property_t *aProperties) +{ + MOZ_ASSERT(!NS_IsMainThread()); + + BluetoothValue propertyValue; + InfallibleTArray propertiesArray; + + for (int i = 0; i < aNumProperties; i++) { + bt_property_t p = aProperties[i]; + + if (p.type == BT_PROPERTY_BDADDR) { + BdAddressTypeToString((bt_bdaddr_t*)p.val, sAdapterBdAddress); + propertyValue = sAdapterBdAddress; + propertiesArray.AppendElement( + BluetoothNamedValue(NS_LITERAL_STRING("Address"), propertyValue)); + } else if (p.type == BT_PROPERTY_BDNAME) { + // Construct nsCString here because Bd name returned from bluedroid + // is missing a null terminated character after SetProperty. + propertyValue = sAdapterBdName = NS_ConvertUTF8toUTF16( + nsCString((char*)p.val, p.len)); + propertiesArray.AppendElement( + BluetoothNamedValue(NS_LITERAL_STRING("Name"), propertyValue)); + } else if (p.type == BT_PROPERTY_ADAPTER_SCAN_MODE) { + propertyValue = sAdapterDiscoverable = *(uint32_t*)p.val; + propertiesArray.AppendElement( + BluetoothNamedValue(NS_LITERAL_STRING("Discoverable"), propertyValue)); + } else if (p.type == BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT) { + propertyValue = sAdapterDiscoverableTimeout = *(uint32_t*)p.val; + propertiesArray.AppendElement( + BluetoothNamedValue(NS_LITERAL_STRING("DiscoverableTimeout"), + propertyValue)); + } else if (p.type == BT_PROPERTY_ADAPTER_BONDED_DEVICES) { + //FIXME: This will be implemented in the later patchset + return; + } else if (p.type == BT_PROPERTY_UUIDS) { + //FIXME: This will be implemented in the later patchset + return; + } else { + BT_LOGR("Unhandled adapter property type: %d", p.type); + return; + } + + BluetoothValue value(propertiesArray); + BluetoothSignal signal(NS_LITERAL_STRING("PropertyChanged"), + NS_LITERAL_STRING(KEY_ADAPTER), value); + nsRefPtr + t = new DistributeBluetoothSignalTask(signal); + if (NS_FAILED(NS_DispatchToMainThread(t))) { + NS_WARNING("Failed to dispatch to main thread!"); + } + } +} + bt_callbacks_t sBluetoothCallbacks = { sizeof(sBluetoothCallbacks), - AdapterStateChangeCallback + AdapterStateChangeCallback, + AdapterPropertiesChangeCallback }; /** @@ -191,6 +266,19 @@ nsresult BluetoothServiceBluedroid::GetDefaultAdapterPathInternal( BluetoothReplyRunnable* aRunnable) { + MOZ_ASSERT(NS_IsMainThread()); + + nsRefPtr runnable(aRunnable); + + BluetoothValue v = InfallibleTArray(); + v.get_ArrayOfBluetoothNamedValue().AppendElement( + BluetoothNamedValue(NS_LITERAL_STRING("Name"), sAdapterBdName)); + + nsAutoString replyError; + DispatchBluetoothReply(runnable.get(), v, replyError); + + runnable.forget(); + return NS_OK; } From 610a31add04a6a575587601289583b69e383bf20 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 01:00:24 -0700 Subject: [PATCH 303/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/6ae4f564465f Author: James Lal Desc: Merge pull request #13211 from lightsofapollo/turn-on-hint-in-ci Bug 932683 - Run jshint per commit but allow it to fail +shepherd ======== https://hg.mozilla.org/integration/gaia-central/rev/bfb1ae49bd7c Author: James Lal Desc: Bug 932683 - Run jshint per commit but allow it to fail +shepherd --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index a405afe133ca..d991fcb94b5f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "3709b24218085fe349291fd1b1102cc8b9ba13dc", + "revision": "6ae4f564465f888d454bc01693e7120c73f8e3a0", "repo_path": "/integration/gaia-central" } From ca147040ba04b926cbd16fed30c7c2fae9f639f2 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 02:25:24 -0700 Subject: [PATCH 304/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/70b0efc9b76e Author: James Lal Desc: Merge pull request #13217 from lissyx/bug931718-v2-gaia Bug 931718 - Introduce a 'print-xulrunner-sdk' make target ======== https://hg.mozilla.org/integration/gaia-central/rev/f471b0e591ed Author: Alexandre Lissy Desc: Bug 931718 - Introduce a 'print-xulrunner-sdk' make target In order to be able to run mochitest-remote, for example on emulator, we need to have a way to get the correct path of the XULRunner SDK. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index d991fcb94b5f..5e5f794548c2 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "6ae4f564465f888d454bc01693e7120c73f8e3a0", + "revision": "70b0efc9b76efa2a8606ad70f88ea01bff77238f", "repo_path": "/integration/gaia-central" } From b1fe3fca5e73f855a1fb65cb83c8f7b0a49188fa Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 02:45:24 -0700 Subject: [PATCH 305/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/fca5b0c5b448 Author: Luke Chang Desc: Merge pull request #13161 from luke-chang/919370_unit_test_for_pinyin Bug 919370 - [Test][Keyboard] Unit test for Pinyin IME, r=rudylu ======== https://hg.mozilla.org/integration/gaia-central/rev/51e3c069e2e2 Author: Luke Chang Desc: Bug 919370 - [Test][Keyboard] Unit test for Pinyin IME --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 5e5f794548c2..2e5b29d13e07 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "70b0efc9b76efa2a8606ad70f88ea01bff77238f", + "revision": "fca5b0c5b44899e1b0d5be42d0cb9ffde891022d", "repo_path": "/integration/gaia-central" } From 468cc02b7cb4e5bf88cb2426bcaeb1299330a26b Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 03:00:24 -0700 Subject: [PATCH 306/795] Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/f6591d2cdd8d Author: gasolin Desc: Merge pull request #12961 from gasolin/issue-905501 Bug 905501 - [FlatFish] Write guideline for multiple resolution device s..., r=timdream ======== https://hg.mozilla.org/integration/gaia-central/rev/2e5857a0496d Author: gasolin Desc: Bug 905501 - [FlatFish] Provide README for tablet customization ======== https://hg.mozilla.org/integration/gaia-central/rev/a7527ea8c8b2 Author: James Lal Desc: Merge pull request #13220 from lightsofapollo/revert-9ab17bf1759b8abd5e1de7e71c98f617a87a7a25 Revert "Merge pull request #13161 from luke-chang/919370_unit_test_for_pinyin" ======== https://hg.mozilla.org/integration/gaia-central/rev/d8f9dd372370 Author: James Lal Desc: Revert "Merge pull request #13161 from luke-chang/919370_unit_test_for_pinyin" This reverts commit 9ab17bf1759b8abd5e1de7e71c98f617a87a7a25, reversing changes made to 1dd8c7d1209cdf23bd8bdfd1878fcdcdc58fb2bc. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 2e5b29d13e07..7640221341ce 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "fca5b0c5b44899e1b0d5be42d0cb9ffde891022d", + "revision": "f6591d2cdd8d12729d50b5b3c0837571b1700f42", "repo_path": "/integration/gaia-central" } From 57819065e8ac90d05ab74666f657d7a6bc3fdfa4 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 03:10:24 -0700 Subject: [PATCH 307/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/17ab3f994cda Author: EragonJ Desc: Merge pull request #13082 from EragonJ/bug-927724 Bug 927724 - [DSDS][Gaia] Voicemail webapi will be changed for DSDS ======== https://hg.mozilla.org/integration/gaia-central/rev/29f86b518cfa Author: EragonJ Desc: Bug 927724 - [DSDS][Gaia] Voicemail webapi will be changed for DSDS - add feature detect for Voicemail webAPI --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 7640221341ce..7f3d35f18f6d 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "f6591d2cdd8d12729d50b5b3c0837571b1700f42", + "revision": "17ab3f994cda1571c8b02abe0abc9861018d3124", "repo_path": "/integration/gaia-central" } From 4a0a6056658d45645b0d20834087db5b85c9d396 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 04:20:24 -0700 Subject: [PATCH 308/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/2c3c40e5eefe Author: Kevin Grandon Desc: Merge pull request #13170 from KevinGrandon/bug_932226_settings_keyboard_scripts Bug 932226 - [Settings] Lazy load keyboard scripts r=arthurcc ======== https://hg.mozilla.org/integration/gaia-central/rev/067fd93de885 Author: Kevin Grandon Desc: Bug 932226 - [Settings] Lazy load keyboard scripts --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 7f3d35f18f6d..6653a68f3332 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "17ab3f994cda1571c8b02abe0abc9861018d3124", + "revision": "2c3c40e5eefe51a21181f3c41ab73ce55c5a1df8", "repo_path": "/integration/gaia-central" } From ee40a658dcb7a8193faa57a32e2838e4c68cf545 Mon Sep 17 00:00:00 2001 From: Shawn Huang Date: Wed, 30 Oct 2013 19:23:39 +0800 Subject: [PATCH 309/795] Bug 930853 - [Bluetooth] Support SetProperty function which enables SetName, SetDiscoverable, SetDiscoveryTimeout, r=echou --- dom/bluetooth/BluetoothServiceBluedroid.cpp | 78 +++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/dom/bluetooth/BluetoothServiceBluedroid.cpp b/dom/bluetooth/BluetoothServiceBluedroid.cpp index 4830e878719a..28035d922068 100644 --- a/dom/bluetooth/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/BluetoothServiceBluedroid.cpp @@ -69,6 +69,7 @@ static bool sAdapterDiscoverable = false; static nsString sAdapterBdAddress; static nsString sAdapterBdName; static uint32_t sAdapterDiscoverableTimeout; +static nsTArray > sSetPropertyRunnableArray; /** * Static callback functions @@ -161,6 +162,13 @@ AdapterPropertiesChangeCallback(bt_status_t aStatus, int aNumProperties, if (NS_FAILED(NS_DispatchToMainThread(t))) { NS_WARNING("Failed to dispatch to main thread!"); } + + // bluedroid BTU task was stored in the task queue, see GKI_send_msg + if (!sSetPropertyRunnableArray.IsEmpty()) { + DispatchBluetoothReply(sSetPropertyRunnableArray[0], BluetoothValue(true), + EmptyString()); + sSetPropertyRunnableArray.RemoveElementAt(0); + } } } @@ -220,6 +228,32 @@ StartStopGonkBluetooth(bool aShouldEnable) return (ret == BT_STATUS_SUCCESS) ? NS_OK : NS_ERROR_FAILURE; } +static void +ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable, + int aStatusCode, const nsAString& aCustomMsg) +{ + MOZ_ASSERT(aBluetoothReplyRunnable, "Reply runnable is nullptr"); + nsAutoString replyError; + + replyError.Assign(aCustomMsg); + if (aStatusCode == BT_STATUS_BUSY) { + replyError.AppendLiteral(":BT_STATUS_BUSY"); + } else if (aStatusCode == BT_STATUS_NOT_READY) { + replyError.AppendLiteral(":BT_STATUS_NOT_READY"); + } else if (aStatusCode == BT_STATUS_DONE) { + replyError.AppendLiteral(":BT_STATUS_DONE"); + } else if (aStatusCode == BT_STATUS_AUTH_FAILURE) { + replyError.AppendLiteral(":BT_STATUS_AUTH_FAILURE"); + } else if (aStatusCode == BT_STATUS_RMT_DEV_DOWN) { + replyError.AppendLiteral(":BT_STATUS_RMT_DEV_DOWN"); + } else if (aStatusCode == BT_STATUS_FAIL) { + replyError.AppendLiteral(":BT_STATUS_FAIL"); + } + + DispatchBluetoothReply(aBluetoothReplyRunnable, BluetoothValue(true), + replyError); +} + /** * Member functions */ @@ -323,6 +357,50 @@ BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType, const BluetoothNamedValue& aValue, BluetoothReplyRunnable* aRunnable) { + MOZ_ASSERT(NS_IsMainThread()); + + const nsString propName = aValue.name(); + bt_property_t prop; + nsString str; + + // For Bluedroid, it's necessary to check property name for SetProperty + if (propName.EqualsLiteral("Name")) { + prop.type = BT_PROPERTY_BDNAME; + } else if (propName.EqualsLiteral("Discoverable")) { + prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE; + } else if (propName.EqualsLiteral("DiscoverableTimeout")) { + prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT; + } else { + BT_LOGR("Warning: Property type is not supported yet, type: %d", prop.type); + } + + if (aValue.value().type() == BluetoothValue::Tuint32_t) { + // Set discoverable timeout + prop.val = (void*)aValue.value().get_uint32_t(); + } else if (aValue.value().type() == BluetoothValue::TnsString) { + // Set name + str = aValue.value().get_nsString(); + const char* name = NS_ConvertUTF16toUTF8(str).get(); + prop.val = (void*)name; + prop.len = strlen(name); + } else if (aValue.value().type() == BluetoothValue::Tbool) { + bt_scan_mode_t mode = aValue.value().get_bool() ? + BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE : + BT_SCAN_MODE_CONNECTABLE; + bt_scan_mode_t* sss = &mode; + prop.val = (void*)sss; + prop.len = sizeof(sss); + } else { + BT_LOGR("SetProperty but the property cannot be recognized correctly."); + return NS_OK; + } + + sSetPropertyRunnableArray.AppendElement(aRunnable); + int ret = sBtInterface->set_adapter_property(&prop); + + if (ret != BT_STATUS_SUCCESS) + ReplyStatusError(aRunnable, ret, NS_LITERAL_STRING("SetProperty")); + return NS_OK; } From f9d5f285120f636f6cf7cb185ffdbd87eca4fe55 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 04:45:25 -0700 Subject: [PATCH 310/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/f29c9a98a5e8 Author: Zac Desc: Merge pull request #13147 from viorelaioia/bug_930932 Bug 930932 - Write a test to use the Keyboard's predictive text ======== https://hg.mozilla.org/integration/gaia-central/rev/fe1318e37992 Author: Viorela Ioia Desc: Bug 930932 - Write a test to use the Keyboard's predictive text --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 6653a68f3332..a240a67e3be6 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "2c3c40e5eefe51a21181f3c41ab73ce55c5a1df8", + "revision": "f29c9a98a5e82c2d825624b1f3eb244e17e14155", "repo_path": "/integration/gaia-central" } From e8bff92750781c1e63526314ff7393ef98320e0f Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 06:05:40 -0700 Subject: [PATCH 311/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/5216bb9e7d38 Author: Corey Frang Desc: Bug 931977 - [Keyboard] Ensure first keyboard shown is properly initialized - r=rudyl - use the `setKeyboardName` during first keyboard load - Renabled TBPL test Closes gh-13192 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index a240a67e3be6..7889c37f39a8 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "f29c9a98a5e82c2d825624b1f3eb244e17e14155", + "revision": "5216bb9e7d387853484253ff88c6b4b6d6a0f1e7", "repo_path": "/integration/gaia-central" } From 3fa29667ada5e5687857938b5e09ab1b6a7a1218 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 06:20:24 -0700 Subject: [PATCH 312/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/85236e28eb17 Author: Ryan VanderMeulen Desc: Merge pull request #13152 from nickdesaulniers/removeStubs Bug 932044 - Remove PackStubTest and HostStubTest ======== https://hg.mozilla.org/integration/gaia-central/rev/d7f48e1f2150 Author: Nick Desaulniers Desc: Bug 932044 - Remove PackStubTest and HostStubTest r=fabrice --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 7889c37f39a8..0b31ff2514b0 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "5216bb9e7d387853484253ff88c6b4b6d6a0f1e7", + "revision": "85236e28eb178d99808b07db7021ffa18c9d8644", "repo_path": "/integration/gaia-central" } From d30ae740d67f699a793d1d91b69765b52a07fcc5 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 06:40:29 -0700 Subject: [PATCH 313/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/128c5d633538 Author: Zac Desc: Merge pull request #13224 from zacc/bug_932355 Bug 923355 - wait for setting to be set after switching dnt toggle ======== https://hg.mozilla.org/integration/gaia-central/rev/3f0e38ffc3af Author: Zac Campbell Desc: Bug 923355 - wait for setting to be set after switching dnt toggle --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 0b31ff2514b0..8636fe6a39e7 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "85236e28eb178d99808b07db7021ffa18c9d8644", + "revision": "128c5d63353892c158823c94d04f42f31976ea62", "repo_path": "/integration/gaia-central" } From 39243debc7a85cc534c8cca5041324c8b2b20ba5 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 06:55:24 -0700 Subject: [PATCH 314/795] Bumping gaia.json for 6 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/d8f6110874fc Author: Jose Antonio Olivera Ortega Desc: Merge pull request #13193 from jaoo/917312 Bug 917312 - [WAP push][Gaia] Support handling client provisioning messages. r=gsvelto ======== https://hg.mozilla.org/integration/gaia-central/rev/6c7d27bf2ebc Author: Jose Antonio Olivera Ortega Desc: Bug 917312 - Part 5: Authenticate server. ======== https://hg.mozilla.org/integration/gaia-central/rev/82d79e7f70b2 Author: Jose Antonio Olivera Ortega Desc: Bug 917312 - Part 4: Store new APNs into the settings database. ======== https://hg.mozilla.org/integration/gaia-central/rev/486699c0cac4 Author: Jose Antonio Olivera Ortega Desc: Bug 917312 - Part 3: Parse WAP provisioning doc. ======== https://hg.mozilla.org/integration/gaia-central/rev/8397f6bcafe8 Author: Jose Antonio Olivera Ortega Desc: Bug 917312 - Part 2: Update UI. ======== https://hg.mozilla.org/integration/gaia-central/rev/7f376431eda3 Author: Jose Antonio Olivera Ortega Desc: Bug 917312 - Part 1: Accept client provisioing messages. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 8636fe6a39e7..a683db494a75 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "128c5d63353892c158823c94d04f42f31976ea62", + "revision": "d8f6110874fc7c8c5a2405f91f208b6384df7d1c", "repo_path": "/integration/gaia-central" } From e0081e8068cfb71cb52e00900086408d34fbfea2 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 07:16:25 -0700 Subject: [PATCH 315/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/413701dedb2e Author: Ben Francis Desc: Bug 914593 - Only show search engine selection if more than one search engine defined --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index a683db494a75..665c1c25e076 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "d8f6110874fc7c8c5a2405f91f208b6384df7d1c", + "revision": "413701dedb2e518210414de4b67b4d8167f2ee67", "repo_path": "/integration/gaia-central" } From 59eebef26b534361dc931007903d010566604d71 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 07:30:24 -0700 Subject: [PATCH 316/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/5289f109a184 Author: Gregor Wagner Desc: Merge pull request #13154 from gregorwagner/settings3 Bug 921721 - Use settingsLock.closed. r=timdream ======== https://hg.mozilla.org/integration/gaia-central/rev/618c9a3727de Author: Gregor Wagner Desc: Bug 921721 - Use settingsLock.closed --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 665c1c25e076..24874b6208fb 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "413701dedb2e518210414de4b67b4d8167f2ee67", + "revision": "5289f109a18470d740c466e3908a9468f39389a1", "repo_path": "/integration/gaia-central" } From f89a61661a116686df531484cd78d3e74cac010d Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 08:05:24 -0700 Subject: [PATCH 317/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/d9521847f177 Author: Jose Antonio Olivera Ortega Desc: Merge pull request #13223 from jaoo/922177 Bug 922177 - [Settings] Need to add the APNs provided by client provisioning messages to the setting app. r=kaze ======== https://hg.mozilla.org/integration/gaia-central/rev/4e5c1a7472d2 Author: Jose Antonio Olivera Ortega Desc: Bug 922177 - [Settings] Need to add the APNs provided by client provisioning messages to the setting app --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 24874b6208fb..53c8626082d9 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "5289f109a18470d740c466e3908a9468f39389a1", + "revision": "d9521847f177eeb78b89688b9e2fcf9734821256", "repo_path": "/integration/gaia-central" } From e4c580542045289935de1bd402d61045828473ad Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 08:15:24 -0700 Subject: [PATCH 318/795] Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/ef0235b883e6 Author: Zac Desc: Merge pull request #13227 from bebef1987/ev.me Bug 932339 - Fix failing test_everythingme_app_install.py ======== https://hg.mozilla.org/integration/gaia-central/rev/e600c68fbf46 Author: Bebe Desc: Bug 932339 - Fix failing test_everythingme_app_install.py ======== https://hg.mozilla.org/integration/gaia-central/rev/b93db0b790c9 Author: Fernando Campo Desc: Merge pull request #13226 from fcampo/lazyloader-dup-932794 Bug 932794 - Duplicate load of LazyLoader (r=jmcf) ======== https://hg.mozilla.org/integration/gaia-central/rev/e2a2fd1ba288 Author: Fernando Campo Desc: Bug 932794 - Duplicate load of LazyLoader --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 53c8626082d9..e49f942cfcd2 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "d9521847f177eeb78b89688b9e2fcf9734821256", + "revision": "ef0235b883e6b6692286f7e7c303cb75329ef0aa", "repo_path": "/integration/gaia-central" } From 7f3f21516268c404d77a93877df6d0f0822133bd Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 08:50:24 -0700 Subject: [PATCH 319/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/63c178476f5c Author: Zac Campbell Desc: Python disable test_call_log_all_calls.py a=testonly r=me --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index e49f942cfcd2..bd00b8465da5 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "ef0235b883e6b6692286f7e7c303cb75329ef0aa", + "revision": "63c178476f5c449232c88caaac97e45b35897de8", "repo_path": "/integration/gaia-central" } From 6a67796bab456ca7133ad9915839dca755a51a56 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 09:40:24 -0700 Subject: [PATCH 320/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/911ffcfec209 Author: Zac Desc: Merge pull request #13221 from AndreiH/bug932492 Bug 932492 - Put [DEFAULT] blocks into each functional test folder's man... ======== https://hg.mozilla.org/integration/gaia-central/rev/b9ed35fea104 Author: Andrei Hutusoru Desc: Bug 932492 - Put [DEFAULT] blocks into each functional test folder's manifest file --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index bd00b8465da5..41a9193d35a8 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "63c178476f5c449232c88caaac97e45b35897de8", + "revision": "911ffcfec2099d6ade676cceadb8162142321cd0", "repo_path": "/integration/gaia-central" } From eabf21ec806b3c55fee723e35306e11714ca9a80 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 10:15:24 -0700 Subject: [PATCH 321/795] Bumping gaia.json for 4 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/7b498cd3256b Author: Fernando Campo Desc: Merge pull request #13189 from fcampo/bt-imported-contacts-925858 Bug 925858 - Received contacts from Bluetooth are not shown on the contact list (r=bkelly) ======== https://hg.mozilla.org/integration/gaia-central/rev/9e1d85783952 Author: Fernando Campo Desc: Bug 925858 - Received contacts from Bluetooth are not shown on the contact list ======== https://hg.mozilla.org/integration/gaia-central/rev/ed718153289c Author: David Flanagan Desc: Merge pull request #13106 from davidflanagan/autocorrect-config2 Bug 884752: make keyboard layouts and autocorrect dictionaries configurable at build time r=rlu,yurneju,pike ======== https://hg.mozilla.org/integration/gaia-central/rev/3cbd02547b17 Author: David Flanagan Desc: Bug 884752: configure keyboard layouts and dictionaries at build time fix test to match move build-time customization to webapp-manifests.js refactor keyboard layout build system address review comments --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 41a9193d35a8..bc0c6af892c9 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "911ffcfec2099d6ade676cceadb8162142321cd0", + "revision": "7b498cd3256b04b2df1047e0f0a0e9a7df9962f1", "repo_path": "/integration/gaia-central" } From 00a9d69ddd6142dc664b332ba6eb958aadcecbd1 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 10:25:23 -0700 Subject: [PATCH 322/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/ebab79baaee5 Author: Fernando Campo Desc: Merge pull request #13228 from fcampo/export-retry-928990 Bug 928990 - Retry on export error takes to wrong screen (r=bkelly) ======== https://hg.mozilla.org/integration/gaia-central/rev/0223eec48f79 Author: Fernando Campo Desc: Bug 928990 - Retry on export error takes to wrong screen --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index bc0c6af892c9..dd2106870ca5 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "7b498cd3256b04b2df1047e0f0a0e9a7df9962f1", + "revision": "ebab79baaee5153a3c660014b3531c0f82adcd24", "repo_path": "/integration/gaia-central" } From 9d84dcadfbf7b49fa05fd360290929aea0b736aa Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 11:00:32 -0700 Subject: [PATCH 323/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/b1e46c451397 Author: GaryChen(pychen) Desc: Merge pull request #13179 from mpizza/Bug_932257_keyboard_not_hidden Bug 932257 - [keyboard] previous InputMethod will not disappear while sw... r=rudyl. ======== https://hg.mozilla.org/integration/gaia-central/rev/1d12f3c48848 Author: mpizza Desc: Bug 932257 - [keyboard] previous InputMethod will not disappear while switching different keyboard app and input type --- while switching different inputType call resetShowingKeyboard first --- add unit test for switching different inputType --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index dd2106870ca5..f8ab243d6abe 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "ebab79baaee5153a3c660014b3531c0f82adcd24", + "revision": "b1e46c451397ae92618166a50f97b1ce1b3d378d", "repo_path": "/integration/gaia-central" } From e362af8fef20236476f655e6050eb8ba2ec9c676 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 11:35:24 -0700 Subject: [PATCH 324/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/947ead64edf6 Author: Francisco Jordano Desc: Merge pull request #13218 from crdlc/bug-927599 Bug 927599 - [Homescreen] Back out greyed out icons when offline ======== https://hg.mozilla.org/integration/gaia-central/rev/5a15a8816f83 Author: crdlc Desc: Bug 927599 - [Homescreen] Back out greyed out icons when offline --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index f8ab243d6abe..80ca1c9b6f12 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "b1e46c451397ae92618166a50f97b1ce1b3d378d", + "revision": "947ead64edf6edd28f4d254546097d919fb12cff", "repo_path": "/integration/gaia-central" } From 7cea42f8d8cb15ea9ba56ecaae445340197d411c Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:06:38 -0400 Subject: [PATCH 325/795] Bug 814625 - Part 1: WebIDL: Code reorder. r=hsinyi, r=khuey --- dom/webidl/Telephony.webidl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dom/webidl/Telephony.webidl b/dom/webidl/Telephony.webidl index cf25b2d3a0d7..d5189558b250 100644 --- a/dom/webidl/Telephony.webidl +++ b/dom/webidl/Telephony.webidl @@ -8,11 +8,19 @@ interface Telephony : EventTarget { [Throws] TelephonyCall dial(DOMString number); + [Throws] TelephonyCall dialEmergency(DOMString number); + [Throws] + void startTone(DOMString tone); + + [Throws] + void stopTone(); + [Throws] attribute boolean muted; + [Throws] attribute boolean speakerEnabled; @@ -22,11 +30,6 @@ interface Telephony : EventTarget { readonly attribute CallsList calls; readonly attribute TelephonyCallGroup conferenceGroup; - [Throws] - void startTone(DOMString tone); - [Throws] - void stopTone(); - attribute EventHandler onincoming; attribute EventHandler oncallschanged; attribute EventHandler onremoteheld; From 14ad5c30872b70ff7ba4fc1833ad9d3062e9669b Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:06:41 -0400 Subject: [PATCH 326/795] Bug 814625 - Part 2: WebIDL: Add multisim support. r=hsinyi, r=khuey --- dom/webidl/Telephony.webidl | 20 +++++++++++++++----- dom/webidl/TelephonyCall.webidl | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dom/webidl/Telephony.webidl b/dom/webidl/Telephony.webidl index d5189558b250..2d4ae7b7d951 100644 --- a/dom/webidl/Telephony.webidl +++ b/dom/webidl/Telephony.webidl @@ -6,17 +6,27 @@ [Pref="dom.telephony.enabled"] interface Telephony : EventTarget { - [Throws] - TelephonyCall dial(DOMString number); + /** + * There are multiple telephony services in multi-sim architecture. We use + * |serviceId| to indicate the target telephony service. If not specified, + * the implementation MUST use the default service. + * + * Possible values of |serviceId| are 0 ~ (number of services - 1), which is + * simply the index of a service. Get number of services by acquiring + * |navigator.mozMobileConnections.length|. + */ [Throws] - TelephonyCall dialEmergency(DOMString number); + TelephonyCall dial(DOMString number, optional unsigned long serviceId); [Throws] - void startTone(DOMString tone); + TelephonyCall dialEmergency(DOMString number, optional unsigned long serviceId); [Throws] - void stopTone(); + void startTone(DOMString tone, optional unsigned long serviceId); + + [Throws] + void stopTone(optional unsigned long serviceId); [Throws] attribute boolean muted; diff --git a/dom/webidl/TelephonyCall.webidl b/dom/webidl/TelephonyCall.webidl index f96c734b4adc..3a83404d6c3c 100644 --- a/dom/webidl/TelephonyCall.webidl +++ b/dom/webidl/TelephonyCall.webidl @@ -6,6 +6,9 @@ [Pref="dom.telephony.enabled"] interface TelephonyCall : EventTarget { + // Indicate which service the call comes from. + readonly attribute unsigned long serviceId; + readonly attribute DOMString number; // In CDMA networks, the 2nd waiting call shares the connection with the 1st From 61452b55ea60224ae74d0c6e2d148c94cbe24bfb Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:06:41 -0400 Subject: [PATCH 327/795] Bug 814625 - Part 3: DOM: Code reorder. r=khuey --- dom/telephony/Telephony.cpp | 96 ++++++++++++++++++------------------- dom/telephony/Telephony.h | 28 +++++------ 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 5d1a050e589c..759de5341616 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -175,32 +175,6 @@ Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv) return telephony.forget(); } -already_AddRefed -Telephony::CreateNewDialingCall(const nsAString& aNumber) -{ - nsRefPtr call = - TelephonyCall::Create(this, aNumber, - nsITelephonyProvider::CALL_STATE_DIALING); - NS_ASSERTION(call, "This should never fail!"); - - NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); - - return call.forget(); -} - -void -Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) -{ - // We don't need to hang on to this call object, it is held alive by mCalls. - nsRefPtr call = CreateNewDialingCall(aNumber); -} - -nsresult -Telephony::NotifyCallsChanged(TelephonyCall* aCall) -{ - return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall); -} - already_AddRefed Telephony::DialInternal(bool isEmergency, const nsAString& aNumber, @@ -243,6 +217,32 @@ Telephony::DialInternal(bool isEmergency, return call.forget(); } +already_AddRefed +Telephony::CreateNewDialingCall(const nsAString& aNumber) +{ + nsRefPtr call = + TelephonyCall::Create(this, aNumber, + nsITelephonyProvider::CALL_STATE_DIALING); + NS_ASSERTION(call, "This should never fail!"); + + NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); + + return call.forget(); +} + +void +Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) +{ + // We don't need to hang on to this call object, it is held alive by mCalls. + nsRefPtr call = CreateNewDialingCall(aNumber); +} + +nsresult +Telephony::NotifyCallsChanged(TelephonyCall* aCall) +{ + return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall); +} + void Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding) { @@ -344,6 +344,28 @@ Telephony::DialEmergency(const nsAString& aNumber, ErrorResult& aRv) return call.forget(); } +void +Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) +{ + if (aDTMFChar.IsEmpty()) { + NS_WARNING("Empty tone string will be ignored"); + return; + } + + if (aDTMFChar.Length() > 1) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return; + } + + aRv = mProvider->StartTone(aDTMFChar); +} + +void +Telephony::StopTone(ErrorResult& aRv) +{ + aRv = mProvider->StopTone(); +} + bool Telephony::GetMuted(ErrorResult& aRv) const { @@ -400,28 +422,6 @@ Telephony::ConferenceGroup() const return group.forget(); } -void -Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) -{ - if (aDTMFChar.IsEmpty()) { - NS_WARNING("Empty tone string will be ignored"); - return; - } - - if (aDTMFChar.Length() > 1) { - aRv.Throw(NS_ERROR_INVALID_ARG); - return; - } - - aRv = mProvider->StartTone(aDTMFChar); -} - -void -Telephony::StopTone(ErrorResult& aRv) -{ - aRv = mProvider->StopTone(); -} - // EventTarget void diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 9ca43da6eab3..28b1b8df4cad 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -71,6 +71,12 @@ public: already_AddRefed DialEmergency(const nsAString& aNumber, ErrorResult& aRv); + void + StartTone(const nsAString& aDTMF, ErrorResult& aRv); + + void + StopTone(ErrorResult& aRv); + bool GetMuted(ErrorResult& aRv) const; @@ -92,12 +98,6 @@ public: already_AddRefed ConferenceGroup() const; - void - StartTone(const nsAString& aDTMF, ErrorResult& aRv); - - void - StopTone(ErrorResult& aRv); - IMPL_EVENT_HANDLER(incoming) IMPL_EVENT_HANDLER(callschanged) IMPL_EVENT_HANDLER(remoteheld) @@ -142,6 +142,14 @@ private: Telephony(); ~Telephony(); + void + Shutdown(); + + already_AddRefed + DialInternal(bool isEmergency, + const nsAString& aNumber, + ErrorResult& aRv); + already_AddRefed CreateNewDialingCall(const nsAString& aNumber); @@ -151,11 +159,6 @@ private: nsresult NotifyCallsChanged(TelephonyCall* aCall); - already_AddRefed - DialInternal(bool isEmergency, - const nsAString& aNumber, - ErrorResult& aRv); - nsresult DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall); @@ -171,9 +174,6 @@ private: bool MoveCall(uint32_t aCallIndex, bool aIsConference); - - void - Shutdown(); }; } // namespace dom From 07ea806dbaf1f32cd9a9a560266e7dc85aa6b71d Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:06:41 -0400 Subject: [PATCH 328/795] Bug 814625 - Part 4: DOM: Refactor. r=khuey --- dom/telephony/Telephony.cpp | 274 ++++++++++++++++-------------------- dom/telephony/Telephony.h | 26 +++- 2 files changed, 144 insertions(+), 156 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 759de5341616..2f52d94cbcec 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -175,26 +175,58 @@ Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv) return telephony.forget(); } +// static +bool +Telephony::IsValidNumber(const nsAString& aNumber) +{ + return !aNumber.IsEmpty(); +} + +// static +bool +Telephony::IsActiveState(uint16_t aCallState) { + return aCallState == nsITelephonyProvider::CALL_STATE_DIALING || + aCallState == nsITelephonyProvider::CALL_STATE_ALERTING || + aCallState == nsITelephonyProvider::CALL_STATE_CONNECTED; +} + +bool +Telephony::HasDialingCall() +{ + for (uint32_t i = 0; i < mCalls.Length(); i++) { + const nsRefPtr& call = mCalls[i]; + if (call->IsOutgoing() && + call->CallState() > nsITelephonyProvider::CALL_STATE_UNKNOWN && + call->CallState() < nsITelephonyProvider::CALL_STATE_CONNECTED) { + return true; + } + } + + return false; +} + +bool +Telephony::MatchActiveCall(TelephonyCall* aCall) +{ + return (mActiveCall && + mActiveCall->CallIndex() == aCall->CallIndex()); +} + already_AddRefed Telephony::DialInternal(bool isEmergency, const nsAString& aNumber, ErrorResult& aRv) { - if (aNumber.IsEmpty()) { + if (!IsValidNumber(aNumber)) { aRv.Throw(NS_ERROR_INVALID_ARG); return nullptr; } - for (uint32_t index = 0; index < mCalls.Length(); index++) { - const nsRefPtr& tempCall = mCalls[index]; - if (tempCall->IsOutgoing() && - tempCall->CallState() < nsITelephonyProvider::CALL_STATE_CONNECTED) { - // One call has been dialed already and we only support one outgoing call - // at a time. - NS_WARNING("Only permitted to dial one call at a time!"); - aRv.Throw(NS_ERROR_NOT_AVAILABLE); - return nullptr; - } + // We only support one outgoing call at a time. + if (HasDialingCall()) { + NS_WARNING("Only permitted to dial one call at a time!"); + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return nullptr; } nsresult rv = mProvider->Dial(aNumber, isEmergency); @@ -206,8 +238,8 @@ Telephony::DialInternal(bool isEmergency, nsRefPtr call = CreateNewDialingCall(aNumber); // Notify other telephony objects that we just dialed. - for (uint32_t index = 0; index < gTelephonyList->Length(); index++) { - Telephony*& telephony = gTelephonyList->ElementAt(index); + for (uint32_t i = 0; i < gTelephonyList->Length(); i++) { + Telephony*& telephony = gTelephonyList->ElementAt(i); if (telephony != this) { nsRefPtr kungFuDeathGrip = telephony; telephony->NoteDialedCallFromOtherInstance(aNumber); @@ -244,16 +276,11 @@ Telephony::NotifyCallsChanged(TelephonyCall* aCall) } void -Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding) +Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsActive) { - if (aIsAdding) { - if (aCall->CallState() == nsITelephonyProvider::CALL_STATE_DIALING || - aCall->CallState() == nsITelephonyProvider::CALL_STATE_ALERTING || - aCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED) { - NS_ASSERTION(!mActiveCall, "Already have an active call!"); - mActiveCall = aCall; - } - } else if (mActiveCall && mActiveCall->CallIndex() == aCall->CallIndex()) { + if (aIsActive) { + mActiveCall = aCall; + } else if (MatchActiveCall(aCall)) { mActiveCall = nullptr; } } @@ -274,32 +301,36 @@ Telephony::GetCall(uint32_t aCallIndex) return call.forget(); } -bool -Telephony::MoveCall(uint32_t aCallIndex, bool aIsConference) +already_AddRefed +Telephony::GetOutgoingCall() { nsRefPtr call; - // Move a call to mGroup. - if (aIsConference) { - call = GetCall(aCallIndex); - if (call) { - RemoveCall(call); - mGroup->AddCall(call); - return true; + for (uint32_t i = 0; i < mCalls.Length(); i++) { + nsRefPtr& tempCall = mCalls[i]; + if (tempCall->CallIndex() == kOutgoingPlaceholderCallIndex) { + NS_ASSERTION(!call, "More than one outgoing call not supported!"); + NS_ASSERTION(tempCall->CallState() == nsITelephonyProvider::CALL_STATE_DIALING, + "Something really wrong here!"); + + call = tempCall; + // No break. We will search entire list to ensure only one outgoing call. } - - return false; } - // Remove a call from mGroup. - call = mGroup->GetCall(aCallIndex); - if (call) { - mGroup->RemoveCall(call); - AddCall(call); - return true; + return call.forget(); +} + +already_AddRefed +Telephony::GetCallFromEverywhere(uint32_t aCallIndex) +{ + nsRefPtr call = GetCall(aCallIndex); + + if (!call) { + call = mGroup->GetCall(aCallIndex); } - return false; + return call.forget(); } NS_IMPL_CYCLE_COLLECTION_CLASS(Telephony) @@ -444,116 +475,70 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, NS_ASSERTION(aCallIndex != kOutgoingPlaceholderCallIndex, "This should never happen!"); - nsRefPtr modifiedCall; - nsRefPtr outgoingCall; + nsRefPtr modifiedCall + = GetCallFromEverywhere(aCallIndex); - // Update calls array first then state of a call in mCalls. + // Try to use the outgoing call if we don't find the modified call. + if (!modifiedCall) { + nsRefPtr outgoingCall = GetOutgoingCall(); - if (aIsConference) { - // Add the call into mGroup if it hasn't been there, otherwise we simply - // update its call state. We don't fire the statechange event on a call in - // conference here. Instead, the event will be fired later in - // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the - // statechange events is guaranteed: first on TelephonyCallGroup then on - // individual TelephonyCall objects. + // If the call state isn't incoming but we do have an outgoing call then + // we must be seeing a status update for our outgoing call. + if (outgoingCall && + aCallState != nsITelephonyProvider::CALL_STATE_INCOMING) { + outgoingCall->UpdateCallIndex(aCallIndex); + outgoingCall->UpdateEmergency(aIsEmergency); + modifiedCall.swap(outgoingCall); + } + } - modifiedCall = mGroup->GetCall(aCallIndex); - if (modifiedCall) { - modifiedCall->ChangeStateInternal(aCallState, false); - return NS_OK; + if (modifiedCall) { + if (!aIsConference) { + UpdateActiveCall(modifiedCall, aIsActive); } - // The call becomes a conference call. Remove it from Telephony::mCalls and - // add it to mGroup. - modifiedCall = GetCall(aCallIndex); - if (modifiedCall) { - modifiedCall->ChangeStateInternal(aCallState, false); + if (modifiedCall->CallState() != aCallState) { + // We don't fire the statechange event on a call in conference here. + // Instead, the event will be fired later in + // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the + // statechange events is guaranteed: first on TelephonyCallGroup then on + // individual TelephonyCall objects. + bool fireEvent = !aIsConference; + modifiedCall->ChangeStateInternal(aCallState, fireEvent); + } + + nsRefPtr group = modifiedCall->GetGroup(); + + if (!group && aIsConference) { + // Add to conference. + NS_ASSERTION(mCalls.Contains(modifiedCall), "Should in mCalls"); mGroup->AddCall(modifiedCall); RemoveCall(modifiedCall); - return NS_OK; - } - - // Didn't find this call in mCalls or mGroup. Create a new call. - nsRefPtr call = - TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, - aIsEmergency, aIsConference); - NS_ASSERTION(call, "This should never fail!"); - - return NS_OK; - } - - // Not a conference call. Remove the call from mGroup if it has been there. - modifiedCall = mGroup->GetCall(aCallIndex); - if (modifiedCall) { - if (aCallState != nsITelephonyProvider::CALL_STATE_DISCONNECTED) { - if (modifiedCall->CallState() != aCallState) { - modifiedCall->ChangeState(aCallState); - } + } else if (group && !aIsConference) { + // Remove from conference. + NS_ASSERTION(mGroup->CallsArray().Contains(modifiedCall), "Should in mGroup"); mGroup->RemoveCall(modifiedCall); AddCall(modifiedCall); - } else { - modifiedCall->ChangeState(aCallState); } - return NS_OK; - } - - // Update calls in mCalls. - for (uint32_t index = 0; index < mCalls.Length(); index++) { - nsRefPtr& tempCall = mCalls[index]; - if (tempCall->CallIndex() == kOutgoingPlaceholderCallIndex) { - NS_ASSERTION(!outgoingCall, "More than one outgoing call not supported!"); - NS_ASSERTION(tempCall->CallState() == - nsITelephonyProvider::CALL_STATE_DIALING, - "Something really wrong here!"); - // Stash this for later, we may need it if aCallIndex doesn't match one of - // our other calls. - outgoingCall = tempCall; - } else if (tempCall->CallIndex() == aCallIndex) { - // We already know about this call so just update its state. - modifiedCall = tempCall; - outgoingCall = nullptr; - break; - } - } - - // If nothing matched above and the call state isn't incoming but we do have - // an outgoing call then we must be seeing a status update for our outgoing - // call. - if (!modifiedCall && - aCallState != nsITelephonyProvider::CALL_STATE_INCOMING && - outgoingCall) { - outgoingCall->UpdateCallIndex(aCallIndex); - outgoingCall->UpdateEmergency(aIsEmergency); - modifiedCall.swap(outgoingCall); - } - - if (modifiedCall) { - // See if this should replace our current active call. - if (aIsActive) { - mActiveCall = modifiedCall; - } else if (mActiveCall && mActiveCall->CallIndex() == aCallIndex) { - mActiveCall = nullptr; - } - - // Change state. - modifiedCall->ChangeState(aCallState); return NS_OK; } - // Didn't know anything about this call before now. - + // Do nothing since we didn't know anything about it before now and it's + // ended already. if (aCallState == nsITelephonyProvider::CALL_STATE_DISCONNECTED) { - // Do nothing since we didn't know anything about it before now and it's - // been ended already. return NS_OK; } + // Didn't find this call in mCalls or mGroup. Create a new call. nsRefPtr call = - TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, aIsEmergency); + TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, + aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); - NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); + NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) : + mCalls.Contains(call), + "Should have auto-added new call!"); if (aCallState == nsITelephonyProvider::CALL_STATE_INCOMING) { nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call); @@ -596,13 +581,8 @@ Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, // However, it is likely to have call state changes, i.e. CallStateChanged() // being called, before the enumeration result comes back. We'd make sure // we don't somehow add duplicates due to the race condition. - call = aIsConference ? mGroup->GetCall(aCallIndex) : GetCall(aCallIndex); + call = GetCallFromEverywhere(aCallIndex); if (call) { - // We have the call either in mCalls or in mGroup. Skip it. - return NS_OK; - } - - if (MoveCall(aCallIndex, aIsConference)) { return NS_OK; } @@ -649,28 +629,22 @@ NS_IMETHODIMP Telephony::NotifyError(int32_t aCallIndex, const nsAString& aError) { - nsRefPtr callToNotify; - if (!mCalls.IsEmpty()) { - // The connection is not established yet. Get the latest dialing call object. - if (aCallIndex == -1) { - nsRefPtr& lastCall = mCalls[mCalls.Length() - 1]; - if (lastCall->CallIndex() == kOutgoingPlaceholderCallIndex) { - callToNotify = lastCall; - } - } else { - // The connection has been established. Get the failed call. - callToNotify = GetCall(aCallIndex); - } + if (mCalls.IsEmpty()) { + NS_ERROR("No existing call!"); + return NS_ERROR_UNEXPECTED; } + nsRefPtr callToNotify; + + callToNotify = (aCallIndex == -1) ? GetOutgoingCall() + : GetCall(aCallIndex); + if (!callToNotify) { NS_ERROR("Don't call me with a bad call index!"); return NS_ERROR_UNEXPECTED; } - if (mActiveCall && mActiveCall->CallIndex() == callToNotify->CallIndex()) { - mActiveCall = nullptr; - } + UpdateActiveCall(callToNotify, false); // Set the call state to 'disconnected' and remove it from the calls list. callToNotify->NotifyError(aError); diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 28b1b8df4cad..8644a35a18b4 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -111,7 +111,7 @@ public: { NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!"); mCalls.AppendElement(aCall); - UpdateActiveCall(aCall, true); + UpdateActiveCall(aCall, IsActiveState(aCall->CallState())); NotifyCallsChanged(aCall); } @@ -145,6 +145,18 @@ private: void Shutdown(); + static bool + IsValidNumber(const nsAString& aNumber); + + static bool + IsActiveState(uint16_t aCallState); + + bool + HasDialingCall(); + + bool + MatchActiveCall(TelephonyCall* aCall); + already_AddRefed DialInternal(bool isEmergency, const nsAString& aNumber, @@ -160,20 +172,22 @@ private: NotifyCallsChanged(TelephonyCall* aCall); nsresult - DispatchCallEvent(const nsAString& aType, - TelephonyCall* aCall); + DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall); void EnqueueEnumerationAck(); void - UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding); + UpdateActiveCall(TelephonyCall* aCall, bool aIsActive); already_AddRefed GetCall(uint32_t aCallIndex); - bool - MoveCall(uint32_t aCallIndex, bool aIsConference); + already_AddRefed + GetOutgoingCall(); + + already_AddRefed + GetCallFromEverywhere(uint32_t aCallIndex); }; } // namespace dom From 524bcd44c7ffafd348de0e79d182132a4e3707dc Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:06:41 -0400 Subject: [PATCH 329/795] Bug 814625 - Part 5: DOM: Add multisim support. r=khuey --- dom/telephony/Telephony.cpp | 132 ++++++++++++++++++--------- dom/telephony/Telephony.h | 35 ++++--- dom/telephony/TelephonyCall.cpp | 17 ++-- dom/telephony/TelephonyCall.h | 10 +- dom/telephony/TelephonyCallGroup.cpp | 37 ++++---- dom/telephony/TelephonyCallGroup.h | 2 +- 6 files changed, 151 insertions(+), 82 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 2f52d94cbcec..b3261d0b7912 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -12,6 +12,7 @@ #include "nsIPermissionManager.h" #include "mozilla/dom/UnionTypes.h" +#include "mozilla/Preferences.h" #include "nsCharSeparatedTokenizer.h" #include "nsContentUtils.h" #include "nsCxPusher.h" @@ -182,6 +183,19 @@ Telephony::IsValidNumber(const nsAString& aNumber) return !aNumber.IsEmpty(); } +// static +uint32_t +Telephony::GetNumServices() { + return mozilla::Preferences::GetInt("ril.numRadioInterfaces", 1); +} + +// static +bool +Telephony::IsValidServiceId(uint32_t aServiceId) +{ + return aServiceId < GetNumServices(); +} + // static bool Telephony::IsActiveState(uint16_t aCallState) { @@ -190,6 +204,14 @@ Telephony::IsActiveState(uint16_t aCallState) { aCallState == nsITelephonyProvider::CALL_STATE_CONNECTED; } +uint32_t +Telephony::ProvidedOrDefaultServiceId(const Optional& aServiceId) +{ + uint32_t serviceId = 0; + return aServiceId.WasPassed() ? aServiceId.Value() + : mProvider->GetDefaultServiceId(&serviceId); +} + bool Telephony::HasDialingCall() { @@ -209,15 +231,15 @@ bool Telephony::MatchActiveCall(TelephonyCall* aCall) { return (mActiveCall && - mActiveCall->CallIndex() == aCall->CallIndex()); + mActiveCall->CallIndex() == aCall->CallIndex() && + mActiveCall->ServiceId() == aCall->ServiceId()); } already_AddRefed -Telephony::DialInternal(bool isEmergency, - const nsAString& aNumber, - ErrorResult& aRv) +Telephony::DialInternal(uint32_t aServiceId, const nsAString& aNumber, + bool aIsEmergency, ErrorResult& aRv) { - if (!IsValidNumber(aNumber)) { + if (!IsValidNumber(aNumber) || !IsValidServiceId(aServiceId)) { aRv.Throw(NS_ERROR_INVALID_ARG); return nullptr; } @@ -229,20 +251,20 @@ Telephony::DialInternal(bool isEmergency, return nullptr; } - nsresult rv = mProvider->Dial(aNumber, isEmergency); + nsresult rv = mProvider->Dial(aServiceId, aNumber, aIsEmergency); if (NS_FAILED(rv)) { aRv.Throw(rv); return nullptr; } - nsRefPtr call = CreateNewDialingCall(aNumber); + nsRefPtr call = CreateNewDialingCall(aServiceId, aNumber); // Notify other telephony objects that we just dialed. for (uint32_t i = 0; i < gTelephonyList->Length(); i++) { Telephony*& telephony = gTelephonyList->ElementAt(i); if (telephony != this) { nsRefPtr kungFuDeathGrip = telephony; - telephony->NoteDialedCallFromOtherInstance(aNumber); + telephony->NoteDialedCallFromOtherInstance(aServiceId, aNumber); } } @@ -250,10 +272,10 @@ Telephony::DialInternal(bool isEmergency, } already_AddRefed -Telephony::CreateNewDialingCall(const nsAString& aNumber) +Telephony::CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber) { nsRefPtr call = - TelephonyCall::Create(this, aNumber, + TelephonyCall::Create(this, aServiceId, aNumber, nsITelephonyProvider::CALL_STATE_DIALING); NS_ASSERTION(call, "This should never fail!"); @@ -263,10 +285,11 @@ Telephony::CreateNewDialingCall(const nsAString& aNumber) } void -Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) +Telephony::NoteDialedCallFromOtherInstance(uint32_t aServiceId, + const nsAString& aNumber) { // We don't need to hang on to this call object, it is held alive by mCalls. - nsRefPtr call = CreateNewDialingCall(aNumber); + nsRefPtr call = CreateNewDialingCall(aServiceId, aNumber); } nsresult @@ -286,13 +309,14 @@ Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsActive) } already_AddRefed -Telephony::GetCall(uint32_t aCallIndex) +Telephony::GetCall(uint32_t aServiceId, uint32_t aCallIndex) { nsRefPtr call; - for (uint32_t index = 0; index < mCalls.Length(); index++) { - nsRefPtr& tempCall = mCalls[index]; - if (tempCall->CallIndex() == aCallIndex) { + for (uint32_t i = 0; i < mCalls.Length(); i++) { + nsRefPtr& tempCall = mCalls[i]; + if (tempCall->ServiceId() == aServiceId && + tempCall->CallIndex() == aCallIndex) { call = tempCall; break; } @@ -322,12 +346,12 @@ Telephony::GetOutgoingCall() } already_AddRefed -Telephony::GetCallFromEverywhere(uint32_t aCallIndex) +Telephony::GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex) { - nsRefPtr call = GetCall(aCallIndex); + nsRefPtr call = GetCall(aServiceId, aCallIndex); if (!call) { - call = mGroup->GetCall(aCallIndex); + call = mGroup->GetCall(aServiceId, aCallIndex); } return call.forget(); @@ -362,39 +386,55 @@ NS_IMPL_ISUPPORTS1(Telephony::Listener, nsITelephonyListener) // Telephony WebIDL already_AddRefed -Telephony::Dial(const nsAString& aNumber, ErrorResult& aRv) +Telephony::Dial(const nsAString& aNumber, const Optional& aServiceId, + ErrorResult& aRv) { - nsRefPtr call = DialInternal(false, aNumber, aRv); + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + nsRefPtr call = DialInternal(serviceId, aNumber, false, aRv); return call.forget(); } already_AddRefed -Telephony::DialEmergency(const nsAString& aNumber, ErrorResult& aRv) +Telephony::DialEmergency(const nsAString& aNumber, + const Optional& aServiceId, + ErrorResult& aRv) { - nsRefPtr call = DialInternal(true, aNumber, aRv); + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + nsRefPtr call = DialInternal(serviceId, aNumber, true, aRv); return call.forget(); } void -Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) +Telephony::StartTone(const nsAString& aDTMFChar, + const Optional& aServiceId, + ErrorResult& aRv) { + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + if (aDTMFChar.IsEmpty()) { NS_WARNING("Empty tone string will be ignored"); return; } - if (aDTMFChar.Length() > 1) { + if (aDTMFChar.Length() > 1 || !IsValidServiceId(serviceId)) { aRv.Throw(NS_ERROR_INVALID_ARG); return; } - aRv = mProvider->StartTone(aDTMFChar); + aRv = mProvider->StartTone(serviceId, aDTMFChar); } void -Telephony::StopTone(ErrorResult& aRv) +Telephony::StopTone(const Optional& aServiceId, ErrorResult& aRv) { - aRv = mProvider->StopTone(); + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + + if (!IsValidServiceId(serviceId)) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return; + } + + aRv = mProvider->StopTone(serviceId); } bool @@ -467,16 +507,16 @@ Telephony::EventListenerAdded(nsIAtom* aType) // nsITelephonyListener NS_IMETHODIMP -Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, - const nsAString& aNumber, bool aIsActive, - bool aIsOutgoing, bool aIsEmergency, +Telephony::CallStateChanged(uint32_t aServiceId, uint32_t aCallIndex, + uint16_t aCallState, const nsAString& aNumber, + bool aIsActive, bool aIsOutgoing, bool aIsEmergency, bool aIsConference) { NS_ASSERTION(aCallIndex != kOutgoingPlaceholderCallIndex, "This should never happen!"); nsRefPtr modifiedCall - = GetCallFromEverywhere(aCallIndex); + = GetCallFromEverywhere(aServiceId, aCallIndex); // Try to use the outgoing call if we don't find the modified call. if (!modifiedCall) { @@ -532,7 +572,7 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, // Didn't find this call in mCalls or mGroup. Create a new call. nsRefPtr call = - TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, + TelephonyCall::Create(this, aServiceId, aNumber, aCallState, aCallIndex, aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); @@ -569,9 +609,9 @@ Telephony::EnumerateCallStateComplete() } NS_IMETHODIMP -Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, - const nsAString& aNumber, bool aIsActive, - bool aIsOutgoing, bool aIsEmergency, +Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex, + uint16_t aCallState, const nsAString& aNumber, + bool aIsActive, bool aIsOutgoing, bool aIsEmergency, bool aIsConference) { nsRefPtr call; @@ -581,15 +621,14 @@ Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, // However, it is likely to have call state changes, i.e. CallStateChanged() // being called, before the enumeration result comes back. We'd make sure // we don't somehow add duplicates due to the race condition. - call = GetCallFromEverywhere(aCallIndex); + call = GetCallFromEverywhere(aServiceId, aCallIndex); if (call) { return NS_OK; } // Didn't know anything about this call before now. - - call = TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, - aIsEmergency, aIsConference); + call = TelephonyCall::Create(this, aServiceId, aNumber, aCallState, + aCallIndex, aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) : @@ -600,12 +639,13 @@ Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, } NS_IMETHODIMP -Telephony::SupplementaryServiceNotification(int32_t aCallIndex, +Telephony::SupplementaryServiceNotification(uint32_t aServiceId, + int32_t aCallIndex, uint16_t aNotification) { nsRefPtr associatedCall; if (!mCalls.IsEmpty() && aCallIndex != -1) { - associatedCall = GetCall(aCallIndex); + associatedCall = GetCall(aServiceId, aCallIndex); } nsresult rv; @@ -626,7 +666,8 @@ Telephony::SupplementaryServiceNotification(int32_t aCallIndex, } NS_IMETHODIMP -Telephony::NotifyError(int32_t aCallIndex, +Telephony::NotifyError(uint32_t aServiceId, + int32_t aCallIndex, const nsAString& aError) { if (mCalls.IsEmpty()) { @@ -637,7 +678,7 @@ Telephony::NotifyError(int32_t aCallIndex, nsRefPtr callToNotify; callToNotify = (aCallIndex == -1) ? GetOutgoingCall() - : GetCall(aCallIndex); + : GetCall(aServiceId, aCallIndex); if (!callToNotify) { NS_ERROR("Don't call me with a bad call index!"); @@ -653,9 +694,10 @@ Telephony::NotifyError(int32_t aCallIndex, } NS_IMETHODIMP -Telephony::NotifyCdmaCallWaiting(const nsAString& aNumber) +Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber) { MOZ_ASSERT(mActiveCall && + mActiveCall->ServiceId() == aServiceId && mActiveCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED); nsRefPtr callToNotify = mActiveCall; diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 8644a35a18b4..0cceb7d612f4 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -7,6 +7,7 @@ #ifndef mozilla_dom_telephony_telephony_h__ #define mozilla_dom_telephony_telephony_h__ +#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/telephony/TelephonyCommon.h" #include "nsITelephonyProvider.h" @@ -66,16 +67,19 @@ public: // WebIDL already_AddRefed - Dial(const nsAString& aNumber, ErrorResult& aRv); + Dial(const nsAString& aNumber, const Optional& aServiceId, + ErrorResult& aRv); already_AddRefed - DialEmergency(const nsAString& aNumber, ErrorResult& aRv); + DialEmergency(const nsAString& aNumber, const Optional& aServiceId, + ErrorResult& aRv); void - StartTone(const nsAString& aDTMF, ErrorResult& aRv); + StartTone(const nsAString& aDTMFChar, const Optional& aServiceId, + ErrorResult& aRv); void - StopTone(ErrorResult& aRv); + StopTone(const Optional& aServiceId, ErrorResult& aRv); bool GetMuted(ErrorResult& aRv) const; @@ -148,9 +152,18 @@ private: static bool IsValidNumber(const nsAString& aNumber); + static uint32_t + GetNumServices(); + + static bool + IsValidServiceId(uint32_t aServiceId); + static bool IsActiveState(uint16_t aCallState); + uint32_t + ProvidedOrDefaultServiceId(const Optional& aServiceId); + bool HasDialingCall(); @@ -158,15 +171,15 @@ private: MatchActiveCall(TelephonyCall* aCall); already_AddRefed - DialInternal(bool isEmergency, - const nsAString& aNumber, - ErrorResult& aRv); + DialInternal(uint32_t aServiceId, const nsAString& aNumber, + bool isEmergency, ErrorResult& aRv); already_AddRefed - CreateNewDialingCall(const nsAString& aNumber); + CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber); void - NoteDialedCallFromOtherInstance(const nsAString& aNumber); + NoteDialedCallFromOtherInstance(uint32_t aServiceId, + const nsAString& aNumber); nsresult NotifyCallsChanged(TelephonyCall* aCall); @@ -181,13 +194,13 @@ private: UpdateActiveCall(TelephonyCall* aCall, bool aIsActive); already_AddRefed - GetCall(uint32_t aCallIndex); + GetCall(uint32_t aServiceId, uint32_t aCallIndex); already_AddRefed GetOutgoingCall(); already_AddRefed - GetCallFromEverywhere(uint32_t aCallIndex); + GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex); }; } // namespace dom diff --git a/dom/telephony/TelephonyCall.cpp b/dom/telephony/TelephonyCall.cpp index dd342cce5379..0a19ee222b86 100644 --- a/dom/telephony/TelephonyCall.cpp +++ b/dom/telephony/TelephonyCall.cpp @@ -19,9 +19,9 @@ using mozilla::dom::telephony::kOutgoingPlaceholderCallIndex; // static already_AddRefed -TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber, - uint16_t aCallState, uint32_t aCallIndex, - bool aEmergency, bool aIsConference) +TelephonyCall::Create(Telephony* aTelephony, uint32_t aServiceId, + const nsAString& aNumber, uint16_t aCallState, + uint32_t aCallIndex, bool aEmergency, bool aIsConference) { NS_ASSERTION(aTelephony, "Null pointer!"); NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!"); @@ -32,6 +32,7 @@ TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber, call->BindToOwner(aTelephony->GetOwner()); call->mTelephony = aTelephony; + call->mServiceId = aServiceId; call->mNumber = aNumber; call->mCallIndex = aCallIndex; call->mError = nullptr; @@ -219,7 +220,7 @@ TelephonyCall::Answer(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->AnswerCall(mCallIndex); + nsresult rv = mTelephony->Provider()->AnswerCall(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -238,8 +239,8 @@ TelephonyCall::HangUp(ErrorResult& aRv) } nsresult rv = mCallState == nsITelephonyProvider::CALL_STATE_INCOMING ? - mTelephony->Provider()->RejectCall(mCallIndex) : - mTelephony->Provider()->HangUp(mCallIndex); + mTelephony->Provider()->RejectCall(mServiceId, mCallIndex) : + mTelephony->Provider()->HangUp(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -261,7 +262,7 @@ TelephonyCall::Hold(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->HoldCall(mCallIndex); + nsresult rv = mTelephony->Provider()->HoldCall(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -290,7 +291,7 @@ TelephonyCall::Resume(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->ResumeCall(mCallIndex); + nsresult rv = mTelephony->Provider()->ResumeCall(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; diff --git a/dom/telephony/TelephonyCall.h b/dom/telephony/TelephonyCall.h index 982e0c419d56..77f40375f89f 100644 --- a/dom/telephony/TelephonyCall.h +++ b/dom/telephony/TelephonyCall.h @@ -21,6 +21,7 @@ class TelephonyCall MOZ_FINAL : public nsDOMEventTargetHelper nsRefPtr mTelephony; nsRefPtr mGroup; + uint32_t mServiceId; nsString mNumber; nsString mSecondNumber; nsString mState; @@ -107,7 +108,8 @@ public: IMPL_EVENT_HANDLER(groupchange) static already_AddRefed - Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState, + Create(Telephony* aTelephony, uint32_t aServiceId, + const nsAString& aNumber, uint16_t aCallState, uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex, bool aEmergency = false, bool aIsConference = false); @@ -117,6 +119,12 @@ public: ChangeStateInternal(aCallState, true); } + uint32_t + ServiceId() const + { + return mServiceId; + } + uint32_t CallIndex() const { diff --git a/dom/telephony/TelephonyCallGroup.cpp b/dom/telephony/TelephonyCallGroup.cpp index a6579f723a17..201988003b3a 100644 --- a/dom/telephony/TelephonyCallGroup.cpp +++ b/dom/telephony/TelephonyCallGroup.cpp @@ -146,6 +146,10 @@ TelephonyCallGroup::CanConference(const TelephonyCall& aCall, MOZ_ASSERT(mCallState == nsITelephonyProvider::CALL_STATE_UNKNOWN); + if (aCall.ServiceId() != aSecondCall->ServiceId()) { + return false; + } + return (aCall.CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED && aSecondCall->CallState() == nsITelephonyProvider::CALL_STATE_HELD) || (aCall.CallState() == nsITelephonyProvider::CALL_STATE_HELD && @@ -153,13 +157,14 @@ TelephonyCallGroup::CanConference(const TelephonyCall& aCall, } already_AddRefed -TelephonyCallGroup::GetCall(uint32_t aCallIndex) +TelephonyCallGroup::GetCall(uint32_t aServiceId, uint32_t aCallIndex) { nsRefPtr call; for (uint32_t index = 0; index < mCalls.Length(); index++) { nsRefPtr& tempCall = mCalls[index]; - if (tempCall->CallIndex() == aCallIndex) { + if (tempCall->ServiceId() == aServiceId && + tempCall->CallIndex() == aCallIndex) { call = tempCall; break; } @@ -207,7 +212,7 @@ TelephonyCallGroup::Add(TelephonyCall& aCall, return; } - aRv = mTelephony->Provider()->ConferenceCall(); + aRv = mTelephony->Provider()->ConferenceCall(aCall.ServiceId()); } void @@ -220,7 +225,7 @@ TelephonyCallGroup::Add(TelephonyCall& aCall, return; } - aRv = mTelephony->Provider()->ConferenceCall(); + aRv = mTelephony->Provider()->ConferenceCall(aCall.ServiceId()); } void @@ -231,18 +236,14 @@ TelephonyCallGroup::Remove(TelephonyCall& aCall, ErrorResult& aRv) return; } + uint32_t serviceId = aCall.ServiceId(); uint32_t callIndex = aCall.CallIndex(); - bool hasCallToRemove = false; - for (uint32_t index = 0; index < mCalls.Length(); index++) { - nsRefPtr& call = mCalls[index]; - if (call->CallIndex() == callIndex) { - hasCallToRemove = true; - break; - } - } - if (hasCallToRemove) { - aRv = mTelephony->Provider()->SeparateCall(callIndex); + nsRefPtr call; + + call = GetCall(serviceId, callIndex); + if (call) { + aRv = mTelephony->Provider()->SeparateCall(serviceId, callIndex); } else { NS_WARNING("Didn't have this call. Ignore!"); } @@ -256,7 +257,9 @@ TelephonyCallGroup::Hold(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->HoldConference(); + MOZ_ASSERT(!mCalls.IsEmpty()); + + nsresult rv = mTelephony->Provider()->HoldConference(mCalls[0]->ServiceId()); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -273,7 +276,9 @@ TelephonyCallGroup::Resume(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->ResumeConference(); + MOZ_ASSERT(!mCalls.IsEmpty()); + + nsresult rv = mTelephony->Provider()->ResumeConference(mCalls[0]->ServiceId()); if (NS_FAILED(rv)) { aRv.Throw(rv); return; diff --git a/dom/telephony/TelephonyCallGroup.h b/dom/telephony/TelephonyCallGroup.h index a668140015c7..806454c4f734 100644 --- a/dom/telephony/TelephonyCallGroup.h +++ b/dom/telephony/TelephonyCallGroup.h @@ -81,7 +81,7 @@ public: RemoveCall(TelephonyCall* aCall); already_AddRefed - GetCall(uint32_t aCallIndex); + GetCall(uint32_t aServiceId, uint32_t aCallIndex); const nsTArray >& CallsArray() const From 0d88291198a080397cdd28efcd75a5512a788287 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:06:55 -0400 Subject: [PATCH 330/795] Bug 814625 - Part 6: Telephony provider and IDL: Add multisim support. r=hsinyi --- dom/telephony/gonk/TelephonyProvider.js | 147 +++++++++++++-------- dom/telephony/nsIGonkTelephonyProvider.idl | 12 +- dom/telephony/nsITelephonyProvider.idl | 52 +++++--- 3 files changed, 130 insertions(+), 81 deletions(-) diff --git a/dom/telephony/gonk/TelephonyProvider.js b/dom/telephony/gonk/TelephonyProvider.js index ce6bf4e77cac..4b235dacba1a 100644 --- a/dom/telephony/gonk/TelephonyProvider.js +++ b/dom/telephony/gonk/TelephonyProvider.js @@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Promise.jsm"); var RIL = {}; Cu.import("resource://gre/modules/ril_consts.js", RIL); @@ -64,6 +65,10 @@ XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() { } }); +XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer", + "@mozilla.org/ril;1", + "nsIRadioInterfaceLayer"); + XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService", "@mozilla.org/power/powermanagerservice;1", "nsIPowerManagerService"); @@ -72,12 +77,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger", "@mozilla.org/system-message-internal;1", "nsISystemMessagesInternal"); -XPCOMUtils.defineLazyGetter(this, "gRadioInterface", function () { - let ril = Cc["@mozilla.org/ril;1"].getService(Ci["nsIRadioInterfaceLayer"]); - // TODO: Bug 854326 - B2G Multi-SIM: support multiple SIM cards for SMS/MMS - return ril.getRadioInterface(0); -}); - XPCOMUtils.defineLazyGetter(this, "gPhoneNumberUtils", function () { let ns = {}; Cu.import("resource://gre/modules/PhoneNumberUtils.jsm", ns); @@ -85,8 +84,8 @@ XPCOMUtils.defineLazyGetter(this, "gPhoneNumberUtils", function () { }); function TelephonyProvider() { + this._numClients = gRadioInterfaceLayer.numRadioInterfaces; this._listeners = []; - this._updateDebugFlag(); this.defaultServiceId = this._getDefaultServiceId(); @@ -140,6 +139,10 @@ TelephonyProvider.prototype = { } }, + _getClient: function _getClient(aClientId) { + return gRadioInterfaceLayer.getRadioInterface(aClientId); + }, + // An array of nsITelephonyListener instances. _listeners: null, _notifyAllListeners: function _notifyAllListeners(aMethodName, aArgs) { @@ -159,6 +162,16 @@ TelephonyProvider.prototype = { } }, + _matchActiveCall: function _matchActiveCall(aCall) { + if (this._activeCall && + this._activeCall.callIndex == aCall.callIndex && + this._activeCall.clientId == aCall.clientId) { + return true; + } + + return false; + }, + /** * Track the active call and update the audio system as its state changes. */ @@ -186,7 +199,7 @@ TelephonyProvider.prototype = { } if (aCall.isConference) { - if (this._activeCall && this._activeCall.callIndex == aCall.callIndex) { + if (this._matchActiveCall(aCall)) { this._activeCall = null; } return; @@ -225,8 +238,7 @@ TelephonyProvider.prototype = { case nsITelephonyProvider.CALL_STATE_HELD: // Fall through... case nsITelephonyProvider.CALL_STATE_DISCONNECTED: aCall.isActive = false; - if (this._activeCall && - this._activeCall.callIndex == aCall.callIndex) { + if (this._matchActiveCall(aCall)) { // Previously active call is not active now. this._activeCall = null; } @@ -332,26 +344,45 @@ TelephonyProvider.prototype = { this._listeners.splice(index, 1); }, - enumerateCalls: function(aListener) { - if (DEBUG) debug("Requesting enumeration of calls for callback"); - gRadioInterface.sendWorkerMessage("enumerateCalls", null, - (function(response) { - for (let call of response.calls) { - call.state = this._convertRILCallState(call.state); - call.isActive = this._activeCall ? - (call.callIndex == this._activeCall.callIndex) : false; + _enumerateCallsForClient: function _enumerateCallsForClient(aClientId, + aListener) { + if (DEBUG) debug("Enumeration of calls for client " + aClientId); - aListener.enumerateCallState(call.callIndex, call.state, call.number, + let deferred = Promise.defer(); + + this._getClient(aClientId).sendWorkerMessage("enumerateCalls", null, + (function(response) { + for (let call of response.calls) { + call.clienId = aClientId; + call.state = this._convertRILCallState(call.state); + call.isActive = this._matchActiveCall(call); + + aListener.enumerateCallState(call.clientId, call.callIndex, + call.state, call.number, call.isActive, call.isOutgoing, call.isEmergency, call.isConference); } - aListener.enumerateCallStateComplete(); + deferred.resolve(); return false; }).bind(this)); + + return deferred.promise; }, - dial: function(aNumber, aIsEmergency) { + enumerateCalls: function(aListener) { + if (DEBUG) debug("Requesting enumeration of calls for callback"); + + let promise = Promise.resolve(); + for (let i = 0; i < this._numClients; ++i) { + promise = promise.then(this._enumerateCallsForClient.bind(this, i, aListener)); + } + promise.then(function() { + aListener.enumerateCallStateComplete(); + }); + }, + + dial: function(aClientId, aNumber, aIsEmergency) { if (DEBUG) debug("Dialing " + (aIsEmergency ? "emergency " : "") + aNumber); // we don't try to be too clever here, as the phone is probably in the // locked state. Let's just check if it's a number without normalizing @@ -359,53 +390,55 @@ TelephonyProvider.prototype = { aNumber = gPhoneNumberUtils.normalize(aNumber); } if (this._validateNumber(aNumber)) { - gRadioInterface.sendWorkerMessage("dial", { number: aNumber, - isDialEmergency: aIsEmergency }); + this._getClient(aClientId).sendWorkerMessage("dial", { + number: aNumber, + isDialEmergency: aIsEmergency + }); } }, - hangUp: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("hangUp", { callIndex: aCallIndex }); + hangUp: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("hangUp", { callIndex: aCallIndex }); }, - startTone: function(aDtmfChar) { - gRadioInterface.sendWorkerMessage("startTone", { dtmfChar: aDtmfChar }); + startTone: function(aClientId, aDtmfChar) { + this._getClient(aClientId).sendWorkerMessage("startTone", { dtmfChar: aDtmfChar }); }, - stopTone: function() { - gRadioInterface.sendWorkerMessage("stopTone"); + stopTone: function(aClientId) { + this._getClient(aClientId).sendWorkerMessage("stopTone"); }, - answerCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("answerCall", { callIndex: aCallIndex }); + answerCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("answerCall", { callIndex: aCallIndex }); }, - rejectCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("rejectCall", { callIndex: aCallIndex }); + rejectCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("rejectCall", { callIndex: aCallIndex }); }, - holdCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("holdCall", { callIndex: aCallIndex }); + holdCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("holdCall", { callIndex: aCallIndex }); }, - resumeCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("resumeCall", { callIndex: aCallIndex }); + resumeCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("resumeCall", { callIndex: aCallIndex }); }, - conferenceCall: function conferenceCall() { - gRadioInterface.sendWorkerMessage("conferenceCall"); + conferenceCall: function conferenceCall(aClientId) { + this._getClient(aClientId).sendWorkerMessage("conferenceCall"); }, - separateCall: function separateCall(aCallIndex) { - gRadioInterface.sendWorkerMessage("separateCall", { callIndex: aCallIndex }); + separateCall: function separateCall(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("separateCall", { callIndex: aCallIndex }); }, - holdConference: function holdConference() { - gRadioInterface.sendWorkerMessage("holdConference"); + holdConference: function holdConference(aClientId) { + this._getClient(aClientId).sendWorkerMessage("holdConference"); }, - resumeConference: function resumeConference() { - gRadioInterface.sendWorkerMessage("resumeConference"); + resumeConference: function resumeConference(aClientId) { + this._getClient(aClientId).sendWorkerMessage("resumeConference"); }, get microphoneMuted() { @@ -448,7 +481,7 @@ TelephonyProvider.prototype = { /** * Handle call disconnects by updating our current state and the audio system. */ - notifyCallDisconnected: function notifyCallDisconnected(aCall) { + notifyCallDisconnected: function notifyCallDisconnected(aClientId, aCall) { if (DEBUG) debug("handleCallDisconnected: " + JSON.stringify(aCall)); aCall.state = nsITelephonyProvider.CALL_STATE_DISCONNECTED; @@ -463,7 +496,8 @@ TelephonyProvider.prototype = { this._updateCallAudioState(aCall, null); - this._notifyAllListeners("callStateChanged", [aCall.callIndex, + this._notifyAllListeners("callStateChanged", [aClientId, + aCall.callIndex, aCall.state, aCall.number, aCall.isActive, @@ -475,8 +509,8 @@ TelephonyProvider.prototype = { /** * Handle call error. */ - notifyCallError: function notifyCallError(aCallIndex, aErrorMsg) { - this._notifyAllListeners("notifyError", [aCallIndex, aErrorMsg]); + notifyCallError: function notifyCallError(aClientId, aCallIndex, aErrorMsg) { + this._notifyAllListeners("notifyError", [aClientId, aCallIndex, aErrorMsg]); }, /** @@ -497,7 +531,7 @@ TelephonyProvider.prototype = { * Handle call state changes by updating our current state and the audio * system. */ - notifyCallStateChanged: function notifyCallStateChanged(aCall) { + notifyCallStateChanged: function notifyCallStateChanged(aClientId, aCall) { if (DEBUG) debug("handleCallStateChange: " + JSON.stringify(aCall)); aCall.state = this._convertRILCallState(aCall.state); @@ -507,7 +541,8 @@ TelephonyProvider.prototype = { this._updateCallAudioState(aCall, null); - this._notifyAllListeners("callStateChanged", [aCall.callIndex, + this._notifyAllListeners("callStateChanged", [aClientId, + aCall.callIndex, aCall.state, aCall.number, aCall.isActive, @@ -516,19 +551,19 @@ TelephonyProvider.prototype = { aCall.isConference]); }, - notifyCdmaCallWaiting: function notifyCdmaCallWaiting(aNumber) { + notifyCdmaCallWaiting: function notifyCdmaCallWaiting(aClientId, aNumber) { // We need to acquire a CPU wake lock to avoid the system falling into // the sleep mode when the RIL handles the incoming call. this._acquireCallRingWakeLock(); - this._notifyAllListeners("notifyCdmaCallWaiting", [aNumber]); + this._notifyAllListeners("notifyCdmaCallWaiting", [aClientId, aNumber]); }, - notifySupplementaryService: function notifySupplementaryService(aCallIndex, - aNotification) { + notifySupplementaryService: + function notifySupplementaryService(aClientId, aCallIndex, aNotification) { let notification = this._convertRILSuppSvcNotification(aNotification); this._notifyAllListeners("supplementaryServiceNotification", - [aCallIndex, notification]); + [aClientId, aCallIndex, notification]); }, notifyConferenceCallStateChanged: function notifyConferenceCallStateChanged(aState) { diff --git a/dom/telephony/nsIGonkTelephonyProvider.idl b/dom/telephony/nsIGonkTelephonyProvider.idl index 43f18581a8e1..f2edd9611be7 100644 --- a/dom/telephony/nsIGonkTelephonyProvider.idl +++ b/dom/telephony/nsIGonkTelephonyProvider.idl @@ -10,21 +10,21 @@ "@mozilla.org/telephony/gonktelephonyprovider;1" %} -[scriptable, uuid(f072f334-e4ea-4754-9929-533da30444a8)] +[scriptable, uuid(fe113e67-5a15-49e6-a555-7f41409f611a)] interface nsIGonkTelephonyProvider : nsITelephonyProvider { - void notifyCallDisconnected(in jsval call); + void notifyCallDisconnected(in unsigned long clientId, in jsval call); - void notifyCallError(in long callIndex, + void notifyCallError(in unsigned long clientId, in long callIndex, in AString error); void notifyCallRing(); - void notifyCallStateChanged(in jsval call); + void notifyCallStateChanged(in unsigned long clientId, in jsval call); - void notifyCdmaCallWaiting(in AString number); + void notifyCdmaCallWaiting(in unsigned long clientId, in AString number); - void notifySupplementaryService(in long callIndex, + void notifySupplementaryService(in unsigned long clientId, in long callIndex, in AString notification); void notifyConferenceCallStateChanged(in short state); diff --git a/dom/telephony/nsITelephonyProvider.idl b/dom/telephony/nsITelephonyProvider.idl index cda5e1ba109e..e73ed97c6944 100644 --- a/dom/telephony/nsITelephonyProvider.idl +++ b/dom/telephony/nsITelephonyProvider.idl @@ -4,12 +4,14 @@ #include "nsISupports.idl" -[scriptable, uuid(3aa42e77-7c2b-43a1-b105-7be094b0817a)] +[scriptable, uuid(707c4c43-a0d7-4093-af52-d4d6a3a333c3)] interface nsITelephonyListener : nsISupports { /** * Notified when a telephony call changes state. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. * @param callState @@ -25,7 +27,8 @@ interface nsITelephonyListener : nsISupports * @param isConference * Indicates whether this call is a conference call. */ - void callStateChanged(in unsigned long callIndex, + void callStateChanged(in unsigned long clientId, + in unsigned long callIndex, in unsigned short callState, in AString number, in boolean isActive, @@ -55,6 +58,8 @@ interface nsITelephonyListener : nsISupports * telephony call state (nsITelephonyProvider::enumerateCalls). This is * called once per call that is currently managed by the RIL. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. * @param callState @@ -68,7 +73,8 @@ interface nsITelephonyListener : nsISupports * @param isConference * Indicates whether this call is a conference call. */ - void enumerateCallState(in unsigned long callIndex, + void enumerateCallState(in unsigned long clientId, + in unsigned long callIndex, in unsigned short callState, in AString number, in boolean isActive, @@ -79,32 +85,40 @@ interface nsITelephonyListener : nsISupports /** * Notify when RIL receives supplementary service notification. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. -1 if not specified * @param notification * One of the nsITelephonyProvider::NOTIFICATION_* values. */ - void supplementaryServiceNotification(in long callIndex, + void supplementaryServiceNotification(in unsigned long clientId, + in long callIndex, in unsigned short notification); /** * Called when RIL error occurs. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. -1 if no connection * @param error * Error from RIL. */ - void notifyError(in long callIndex, + void notifyError(in unsigned long clientId, + in long callIndex, in AString error); /** * Called when a waiting call comes in CDMA networks. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param number * Number of the other party. */ - void notifyCdmaCallWaiting(in AString number); + void notifyCdmaCallWaiting(in unsigned long clientId, in AString number); }; %{C++ @@ -118,7 +132,7 @@ interface nsITelephonyListener : nsISupports * XPCOM component (in the content process) that provides the telephony * information. */ -[scriptable, uuid(f7680b82-53fc-42a7-9adf-bc0f2726425c)] +[scriptable, uuid(4ff3ecb7-b024-4752-9dd6-c3623c6e6b8a)] interface nsITelephonyProvider : nsISupports { const unsigned short CALL_STATE_UNKNOWN = 0; @@ -155,22 +169,22 @@ interface nsITelephonyProvider : nsISupports /** * Functionality for making and managing phone calls. */ - void dial(in DOMString number, + void dial(in unsigned long clientId, in DOMString number, in boolean isEmergency); - void hangUp(in unsigned long callIndex); + void hangUp(in unsigned long clientId, in unsigned long callIndex); - void startTone(in DOMString dtmfChar); - void stopTone(); + void startTone(in unsigned long clientId, in DOMString dtmfChar); + void stopTone(in unsigned long clientId); - void answerCall(in unsigned long callIndex); - void rejectCall(in unsigned long callIndex); - void holdCall(in unsigned long callIndex); - void resumeCall(in unsigned long callIndex); + void answerCall(in unsigned long clientId, in unsigned long callIndex); + void rejectCall(in unsigned long clientId, in unsigned long callIndex); + void holdCall(in unsigned long clientId, in unsigned long callIndex); + void resumeCall(in unsigned long clientId, in unsigned long callIndex); - void conferenceCall(); - void separateCall(in unsigned long callIndex); - void holdConference(); - void resumeConference(); + void conferenceCall(in unsigned long clientId); + void separateCall(in unsigned long clientId, in unsigned long callIndex); + void holdConference(in unsigned long clientId); + void resumeConference(in unsigned long clientId); attribute bool microphoneMuted; attribute bool speakerEnabled; From a1b5b09f9835c69897420dcdc26a5ac1259fcecc Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:07:12 -0400 Subject: [PATCH 331/795] Bug 814625 - Part 7: Telephony IPC: Add multisim support. r=khuey --- dom/telephony/ipc/PTelephony.ipdl | 33 ++++--- dom/telephony/ipc/PTelephonyRequest.ipdl | 2 +- dom/telephony/ipc/TelephonyChild.cpp | 28 ++++-- dom/telephony/ipc/TelephonyChild.h | 14 ++- dom/telephony/ipc/TelephonyIPCProvider.cpp | 101 ++++++++++--------- dom/telephony/ipc/TelephonyParent.cpp | 110 ++++++++++++--------- dom/telephony/ipc/TelephonyParent.h | 25 +++-- 7 files changed, 174 insertions(+), 139 deletions(-) diff --git a/dom/telephony/ipc/PTelephony.ipdl b/dom/telephony/ipc/PTelephony.ipdl index d82044401ef5..9ee105036998 100644 --- a/dom/telephony/ipc/PTelephony.ipdl +++ b/dom/telephony/ipc/PTelephony.ipdl @@ -17,15 +17,16 @@ sync protocol PTelephony { manages PTelephonyRequest; child: - NotifyCallError(int32_t aCallIndex, nsString aError); + NotifyCallError(uint32_t aClientId, int32_t aCallIndex, nsString aError); - NotifyCallStateChanged(IPCCallStateData aData); + NotifyCallStateChanged(uint32_t aClientId, IPCCallStateData aData); - NotifyCdmaCallWaiting(nsString aNumber); + NotifyCdmaCallWaiting(uint32_t aClientId, nsString aNumber); NotifyConferenceCallStateChanged(uint16_t aCallState); - NotifySupplementaryService(int32_t aCallIndex, uint16_t aNotification); + NotifySupplementaryService(uint32_t aClientId, int32_t aCallIndex, + uint16_t aNotification); parent: /** @@ -43,29 +44,29 @@ parent: UnregisterListener(); - DialCall(nsString aNumber, bool aIsEmergency); + DialCall(uint32_t aClientId, nsString aNumber, bool aIsEmergency); - HangUpCall(uint32_t aCallIndex); + HangUpCall(uint32_t aClientId, uint32_t aCallIndex); - AnswerCall(uint32_t aCallIndex); + AnswerCall(uint32_t aClientId, uint32_t aCallIndex); - RejectCall(uint32_t aCallIndex); + RejectCall(uint32_t aClientId, uint32_t aCallIndex); - HoldCall(uint32_t aCallIndex); + HoldCall(uint32_t aClientId, uint32_t aCallIndex); - ResumeCall(uint32_t aCallIndex); + ResumeCall(uint32_t aClientId, uint32_t aCallIndex); - ConferenceCall(); + ConferenceCall(uint32_t aClientId); - SeparateCall(uint32_t aCallIndex); + SeparateCall(uint32_t aClientId, uint32_t aCallIndex); - HoldConference(); + HoldConference(uint32_t aClientId); - ResumeConference(); + ResumeConference(uint32_t aClientId); - StartTone(nsString aTone); + StartTone(uint32_t aClientId, nsString aTone); - StopTone(); + StopTone(uint32_t aClientId); sync GetMicrophoneMuted() returns (bool aMuted); diff --git a/dom/telephony/ipc/PTelephonyRequest.ipdl b/dom/telephony/ipc/PTelephonyRequest.ipdl index 05f708ffc6a0..70ed3bd65f75 100644 --- a/dom/telephony/ipc/PTelephonyRequest.ipdl +++ b/dom/telephony/ipc/PTelephonyRequest.ipdl @@ -16,7 +16,7 @@ protocol PTelephonyRequest manager PTelephony; child: - NotifyEnumerateCallState(IPCCallStateData aData); + NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData); /** * Sent when the asynchronous request has completed. It's currently only for diff --git a/dom/telephony/ipc/TelephonyChild.cpp b/dom/telephony/ipc/TelephonyChild.cpp index 411e3b35f0a7..a84c17febfc8 100644 --- a/dom/telephony/ipc/TelephonyChild.cpp +++ b/dom/telephony/ipc/TelephonyChild.cpp @@ -37,21 +37,24 @@ TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) } bool -TelephonyChild::RecvNotifyCallError(const int32_t& aCallIndex, +TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, + const int32_t& aCallIndex, const nsString& aError) { MOZ_ASSERT(mListener); - mListener->NotifyError(aCallIndex, aError); + mListener->NotifyError(aClientId, aCallIndex, aError); return true; } bool -TelephonyChild::RecvNotifyCallStateChanged(const IPCCallStateData& aData) +TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, + const IPCCallStateData& aData) { MOZ_ASSERT(mListener); - mListener->CallStateChanged(aData.callIndex(), + mListener->CallStateChanged(aClientId, + aData.callIndex(), aData.callState(), aData.number(), aData.isActive(), @@ -62,11 +65,12 @@ TelephonyChild::RecvNotifyCallStateChanged(const IPCCallStateData& aData) } bool -TelephonyChild::RecvNotifyCdmaCallWaiting(const nsString& aNumber) +TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, + const nsString& aNumber) { MOZ_ASSERT(mListener); - mListener->NotifyCdmaCallWaiting(aNumber); + mListener->NotifyCdmaCallWaiting(aClientId, aNumber); return true; } @@ -80,12 +84,14 @@ TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) } bool -TelephonyChild::RecvNotifySupplementaryService(const int32_t& aCallIndex, +TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId, + const int32_t& aCallIndex, const uint16_t& aNotification) { MOZ_ASSERT(mListener); - mListener->SupplementaryServiceNotification(aCallIndex, aNotification); + mListener->SupplementaryServiceNotification(aClientId, aCallIndex, + aNotification); return true; } @@ -115,11 +121,13 @@ TelephonyRequestChild::Recv__delete__() } bool -TelephonyRequestChild::RecvNotifyEnumerateCallState(const IPCCallStateData& aData) +TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, + const IPCCallStateData& aData) { MOZ_ASSERT(mListener); - mListener->EnumerateCallState(aData.callIndex(), + mListener->EnumerateCallState(aClientId, + aData.callIndex(), aData.callState(), aData.number(), aData.isActive(), diff --git a/dom/telephony/ipc/TelephonyChild.h b/dom/telephony/ipc/TelephonyChild.h index 91eb1f8d2a54..ecf2adccdf74 100644 --- a/dom/telephony/ipc/TelephonyChild.h +++ b/dom/telephony/ipc/TelephonyChild.h @@ -31,20 +31,23 @@ protected: DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) MOZ_OVERRIDE; virtual bool - RecvNotifyCallError(const int32_t& aCallIndex, + RecvNotifyCallError(const uint32_t& aClientId, const int32_t& aCallIndex, const nsString& aError) MOZ_OVERRIDE; virtual bool - RecvNotifyCallStateChanged(const IPCCallStateData& aData) MOZ_OVERRIDE; + RecvNotifyCallStateChanged(const uint32_t& aClientId, + const IPCCallStateData& aData) MOZ_OVERRIDE; virtual bool - RecvNotifyCdmaCallWaiting(const nsString& aNumber) MOZ_OVERRIDE; + RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, + const nsString& aNumber) MOZ_OVERRIDE; virtual bool RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) MOZ_OVERRIDE; virtual bool - RecvNotifySupplementaryService(const int32_t& aCallIndex, + RecvNotifySupplementaryService(const uint32_t& aClientId, + const int32_t& aCallIndex, const uint16_t& aNotification) MOZ_OVERRIDE; private: @@ -66,7 +69,8 @@ protected: Recv__delete__() MOZ_OVERRIDE; virtual bool - RecvNotifyEnumerateCallState(const IPCCallStateData& aData) MOZ_OVERRIDE; + RecvNotifyEnumerateCallState(const uint32_t& aClientId, + const IPCCallStateData& aData) MOZ_OVERRIDE; private: nsCOMPtr mListener; diff --git a/dom/telephony/ipc/TelephonyIPCProvider.cpp b/dom/telephony/ipc/TelephonyIPCProvider.cpp index 6da47f8face6..c147fbb47975 100644 --- a/dom/telephony/ipc/TelephonyIPCProvider.cpp +++ b/dom/telephony/ipc/TelephonyIPCProvider.cpp @@ -128,87 +128,87 @@ TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener) } NS_IMETHODIMP -TelephonyIPCProvider::Dial(const nsAString& aNumber, - bool aIsEmergency) +TelephonyIPCProvider::Dial(uint32_t aClientId, const nsAString& aNumber, + bool aIsEmergency) { - mPTelephonyChild->SendDialCall(nsString(aNumber), aIsEmergency); + mPTelephonyChild->SendDialCall(aClientId, nsString(aNumber), aIsEmergency); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HangUp(uint32_t aCallIndex) +TelephonyIPCProvider::HangUp(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendHangUpCall(aCallIndex); + mPTelephonyChild->SendHangUpCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::AnswerCall(uint32_t aCallIndex) +TelephonyIPCProvider::AnswerCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendAnswerCall(aCallIndex); + mPTelephonyChild->SendAnswerCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::RejectCall(uint32_t aCallIndex) +TelephonyIPCProvider::RejectCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendRejectCall(aCallIndex); + mPTelephonyChild->SendRejectCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HoldCall(uint32_t aCallIndex) +TelephonyIPCProvider::HoldCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendHoldCall(aCallIndex); + mPTelephonyChild->SendHoldCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ResumeCall(uint32_t aCallIndex) +TelephonyIPCProvider::ResumeCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendResumeCall(aCallIndex); + mPTelephonyChild->SendResumeCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ConferenceCall() +TelephonyIPCProvider::ConferenceCall(uint32_t aClientId) { - mPTelephonyChild->SendConferenceCall(); + mPTelephonyChild->SendConferenceCall(aClientId); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::SeparateCall(uint32_t aCallIndex) +TelephonyIPCProvider::SeparateCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendSeparateCall(aCallIndex); + mPTelephonyChild->SendSeparateCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HoldConference() +TelephonyIPCProvider::HoldConference(uint32_t aClientId) { - mPTelephonyChild->SendHoldConference(); + mPTelephonyChild->SendHoldConference(aClientId); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ResumeConference() +TelephonyIPCProvider::ResumeConference(uint32_t aClientId) { - mPTelephonyChild->SendResumeConference(); + mPTelephonyChild->SendResumeConference(aClientId); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::StartTone(const nsAString& aDtmfChar) +TelephonyIPCProvider::StartTone(uint32_t aClientId, const nsAString& aDtmfChar) { - mPTelephonyChild->SendStartTone(nsString(aDtmfChar)); + mPTelephonyChild->SendStartTone(aClientId, nsString(aDtmfChar)); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::StopTone() +TelephonyIPCProvider::StopTone(uint32_t aClientId) { - mPTelephonyChild->SendStopTone(); + mPTelephonyChild->SendStopTone(aClientId); return NS_OK; } @@ -243,16 +243,17 @@ TelephonyIPCProvider::SetSpeakerEnabled(bool aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyIPCProvider::CallStateChanged(uint32_t aCallIndex, - uint16_t aCallState, - const nsAString& aNumber, - bool aIsActive, - bool aIsOutgoing, - bool aIsEmergency, - bool aIsConference) +TelephonyIPCProvider::CallStateChanged(uint32_t aClientId, + uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aNumber, + bool aIsActive, + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->CallStateChanged(aCallIndex, aCallState, aNumber, + mListeners[i]->CallStateChanged(aClientId, aCallIndex, aCallState, aNumber, aIsActive, aIsOutgoing, aIsEmergency, aIsConference); } @@ -275,42 +276,46 @@ TelephonyIPCProvider::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyIPCProvider::EnumerateCallState(uint32_t aCallIndex, - uint16_t aCallState, - const nsAString& aNumber, - bool aIsActive, - bool aIsOutgoing, - bool aIsEmergency, - bool aIsConference) +TelephonyIPCProvider::EnumerateCallState(uint32_t aClientId, + uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aNumber, + bool aIsActive, + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference) { MOZ_CRASH("Not a EnumerateCalls request!"); } NS_IMETHODIMP -TelephonyIPCProvider::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyIPCProvider::NotifyCdmaCallWaiting(uint32_t aClientId, + const nsAString& aNumber) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->NotifyCdmaCallWaiting(aNumber); + mListeners[i]->NotifyCdmaCallWaiting(aClientId, aNumber); } return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::NotifyError(int32_t aCallIndex, - const nsAString& aError) +TelephonyIPCProvider::NotifyError(uint32_t aClientId, int32_t aCallIndex, + const nsAString& aError) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->NotifyError(aCallIndex, aError); + mListeners[i]->NotifyError(aClientId, aCallIndex, aError); } return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::SupplementaryServiceNotification(int32_t aCallIndex, - uint16_t aNotification) +TelephonyIPCProvider::SupplementaryServiceNotification(uint32_t aClientId, + int32_t aCallIndex, + uint16_t aNotification) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->SupplementaryServiceNotification(aCallIndex, aNotification); + mListeners[i]->SupplementaryServiceNotification(aClientId, aCallIndex, + aNotification); } return NS_OK; } diff --git a/dom/telephony/ipc/TelephonyParent.cpp b/dom/telephony/ipc/TelephonyParent.cpp index 8db736c390de..a9be3eeaaae4 100644 --- a/dom/telephony/ipc/TelephonyParent.cpp +++ b/dom/telephony/ipc/TelephonyParent.cpp @@ -92,135 +92,142 @@ TelephonyParent::RecvUnregisterListener() } bool -TelephonyParent::RecvDialCall(const nsString& aNumber, +TelephonyParent::RecvDialCall(const uint32_t& aClientId, + const nsString& aNumber, const bool& aIsEmergency) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->Dial(aNumber, aIsEmergency); + provider->Dial(aClientId, aNumber, aIsEmergency); return true; } bool -TelephonyParent::RecvHangUpCall(const uint32_t& aCallIndex) +TelephonyParent::RecvHangUpCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HangUp(aCallIndex); + provider->HangUp(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvAnswerCall(const uint32_t& aCallIndex) +TelephonyParent::RecvAnswerCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->AnswerCall(aCallIndex); + provider->AnswerCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvRejectCall(const uint32_t& aCallIndex) +TelephonyParent::RecvRejectCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->RejectCall(aCallIndex); + provider->RejectCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvHoldCall(const uint32_t& aCallIndex) +TelephonyParent::RecvHoldCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HoldCall(aCallIndex); + provider->HoldCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvResumeCall(const uint32_t& aCallIndex) +TelephonyParent::RecvResumeCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ResumeCall(aCallIndex); + provider->ResumeCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvConferenceCall() +TelephonyParent::RecvConferenceCall(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ConferenceCall(); + provider->ConferenceCall(aClientId); return true; } bool -TelephonyParent::RecvSeparateCall(const uint32_t& aCallState) +TelephonyParent::RecvSeparateCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->SeparateCall(aCallState); + provider->SeparateCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvHoldConference() +TelephonyParent::RecvHoldConference(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HoldConference(); + provider->HoldConference(aClientId); return true; } bool -TelephonyParent::RecvResumeConference() +TelephonyParent::RecvResumeConference(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ResumeConference(); + provider->ResumeConference(aClientId); return true; } bool -TelephonyParent::RecvStartTone(const nsString& aTone) +TelephonyParent::RecvStartTone(const uint32_t& aClientId, const nsString& aTone) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->StartTone(aTone); + provider->StartTone(aClientId, aTone); return true; } bool -TelephonyParent::RecvStopTone() +TelephonyParent::RecvStopTone(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->StopTone(); + provider->StopTone(aClientId); return true; } @@ -275,7 +282,8 @@ TelephonyParent::RecvSetSpeakerEnabled(const bool& aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyParent::CallStateChanged(uint32_t aCallIndex, +TelephonyParent::CallStateChanged(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -285,9 +293,9 @@ TelephonyParent::CallStateChanged(uint32_t aCallIndex, { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), aIsActive, - aIsOutgoing, aIsEmergency, aIsConference); - return SendNotifyCallStateChanged(data) ? NS_OK : NS_ERROR_FAILURE; + IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), + aIsActive, aIsOutgoing, aIsEmergency, aIsConference); + return SendNotifyCallStateChanged(aClientId, data) ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -306,7 +314,8 @@ TelephonyParent::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyParent::EnumerateCallState(uint32_t aCallIndex, +TelephonyParent::EnumerateCallState(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -318,32 +327,35 @@ TelephonyParent::EnumerateCallState(uint32_t aCallIndex, } NS_IMETHODIMP -TelephonyParent::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyParent::NotifyCdmaCallWaiting(uint32_t aClientId, + const nsAString& aNumber) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCdmaCallWaiting(nsString(aNumber)) ? NS_OK - : NS_ERROR_FAILURE; + return SendNotifyCdmaCallWaiting(aClientId, nsString(aNumber)) + ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyParent::NotifyError(int32_t aCallIndex, +TelephonyParent::NotifyError(uint32_t aClientId, + int32_t aCallIndex, const nsAString& aError) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCallError(aCallIndex, nsString(aError)) ? NS_OK - : NS_ERROR_FAILURE; + return SendNotifyCallError(aClientId, aCallIndex, nsString(aError)) + ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyParent::SupplementaryServiceNotification(int32_t aCallIndex, +TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId, + int32_t aCallIndex, uint16_t aNotification) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifySupplementaryService(aCallIndex, aNotification) - ? NS_OK : NS_ERROR_FAILURE; + return SendNotifySupplementaryService(aClientId, aCallIndex, aNotification) + ? NS_OK : NS_ERROR_FAILURE; } /******************************************************************************* @@ -387,7 +399,8 @@ TelephonyRequestParent::DoRequest() // nsITelephonyListener NS_IMETHODIMP -TelephonyRequestParent::CallStateChanged(uint32_t aCallIndex, +TelephonyRequestParent::CallStateChanged(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -413,7 +426,8 @@ TelephonyRequestParent::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyRequestParent::EnumerateCallState(uint32_t aCallIndex, +TelephonyRequestParent::EnumerateCallState(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -423,26 +437,30 @@ TelephonyRequestParent::EnumerateCallState(uint32_t aCallIndex, { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), aIsActive, - aIsOutgoing, aIsEmergency, aIsConference); - return SendNotifyEnumerateCallState(data) ? NS_OK : NS_ERROR_FAILURE; + IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), + aIsActive, aIsOutgoing, aIsEmergency, aIsConference); + return SendNotifyEnumerateCallState(aClientId, data) ? NS_OK + : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyRequestParent::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyRequestParent::NotifyCdmaCallWaiting(uint32_t aClientId, + const nsAString& aNumber) { MOZ_CRASH("Not a TelephonyParent!"); } NS_IMETHODIMP -TelephonyRequestParent::NotifyError(int32_t aCallIndex, +TelephonyRequestParent::NotifyError(uint32_t aClientId, + int32_t aCallIndex, const nsAString& aError) { MOZ_CRASH("Not a TelephonyParent!"); } NS_IMETHODIMP -TelephonyRequestParent::SupplementaryServiceNotification(int32_t aCallIndex, +TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId, + int32_t aCallIndex, uint16_t aNotification) { MOZ_CRASH("Not a TelephonyParent!"); diff --git a/dom/telephony/ipc/TelephonyParent.h b/dom/telephony/ipc/TelephonyParent.h index ac508c264bea..16abf189bbfd 100644 --- a/dom/telephony/ipc/TelephonyParent.h +++ b/dom/telephony/ipc/TelephonyParent.h @@ -47,41 +47,40 @@ protected: RecvUnregisterListener() MOZ_OVERRIDE; virtual bool - RecvDialCall(const nsString& aNumber, - const bool& aIsEmergency) MOZ_OVERRIDE; + RecvDialCall(const uint32_t& aClientId, const nsString& aNumber, const bool& aIsEmergency) MOZ_OVERRIDE; virtual bool - RecvHangUpCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvHangUpCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvAnswerCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvAnswerCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvRejectCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvRejectCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvHoldCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvHoldCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvResumeCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvResumeCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvConferenceCall() MOZ_OVERRIDE; + RecvConferenceCall(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool - RecvSeparateCall(const uint32_t& callIndex) MOZ_OVERRIDE; + RecvSeparateCall(const uint32_t& aClientId, const uint32_t& callIndex) MOZ_OVERRIDE; virtual bool - RecvHoldConference() MOZ_OVERRIDE; + RecvHoldConference(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool - RecvResumeConference() MOZ_OVERRIDE; + RecvResumeConference(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool - RecvStartTone(const nsString& aTone) MOZ_OVERRIDE; + RecvStartTone(const uint32_t& aClientId, const nsString& aTone) MOZ_OVERRIDE; virtual bool - RecvStopTone() MOZ_OVERRIDE; + RecvStopTone(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool RecvGetMicrophoneMuted(bool* aMuted) MOZ_OVERRIDE; From f533368bcd73ee37587e2c9fe83141201169dbee Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:07:14 -0400 Subject: [PATCH 332/795] Bug 814625 - Part 8: RIL: Add multisim support. r=hsinyi --- dom/system/gonk/RadioInterfaceLayer.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index a6256789a74f..e731c1166409 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -1001,22 +1001,24 @@ RadioInterface.prototype = { gTelephonyProvider.notifyCallRing(); break; case "callStateChange": - gTelephonyProvider.notifyCallStateChanged(message.call); + gTelephonyProvider.notifyCallStateChanged(this.clientId, message.call); break; case "callDisconnected": - gTelephonyProvider.notifyCallDisconnected(message.call); + gTelephonyProvider.notifyCallDisconnected(this.clientId, message.call); break; case "conferenceCallStateChanged": gTelephonyProvider.notifyConferenceCallStateChanged(message.state); break; case "cdmaCallWaiting": - gTelephonyProvider.notifyCdmaCallWaiting(message.number); + gTelephonyProvider.notifyCdmaCallWaiting(this.clientId, message.number); break; case "callError": - gTelephonyProvider.notifyCallError(message.callIndex, message.errorMsg); + gTelephonyProvider.notifyCallError(this.clientId, message.callIndex, + message.errorMsg); break; case "suppSvcNotification": - gTelephonyProvider.notifySupplementaryService(message.callIndex, + gTelephonyProvider.notifySupplementaryService(this.clientId, + message.callIndex, message.notification); break; case "emergencyCbModeChange": @@ -3575,4 +3577,3 @@ RILNetworkInterface.prototype = { }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RadioInterfaceLayer]); - From 3ecc273f1b60cb12706935f70e7574674e1151ac Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Wed, 30 Oct 2013 15:07:15 -0400 Subject: [PATCH 333/795] Bug 814625 - Part 9: Bluetooth: Add serviceId in listener. r=gyeh --- dom/bluetooth/BluetoothRilListener.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dom/bluetooth/BluetoothRilListener.cpp b/dom/bluetooth/BluetoothRilListener.cpp index 71d731808949..83f01fa716e2 100644 --- a/dom/bluetooth/BluetoothRilListener.cpp +++ b/dom/bluetooth/BluetoothRilListener.cpp @@ -133,6 +133,8 @@ MobileConnectionListener::NotifyIccChanged() /** * TelephonyListener Implementation + * + * TODO: Bug 921991 - B2G BT: support multiple sim cards */ class TelephonyListener : public nsITelephonyListener { @@ -146,7 +148,8 @@ public: NS_IMPL_ISUPPORTS1(TelephonyListener, nsITelephonyListener) NS_IMETHODIMP -TelephonyListener::CallStateChanged(uint32_t aCallIndex, +TelephonyListener::CallStateChanged(uint32_t aServiceId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -162,7 +165,8 @@ TelephonyListener::CallStateChanged(uint32_t aCallIndex, } NS_IMETHODIMP -TelephonyListener::EnumerateCallState(uint32_t aCallIndex, +TelephonyListener::EnumerateCallState(uint32_t aServiceId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString_internal& aNumber, bool aIsActive, @@ -177,7 +181,8 @@ TelephonyListener::EnumerateCallState(uint32_t aCallIndex, } NS_IMETHODIMP -TelephonyListener::NotifyError(int32_t aCallIndex, +TelephonyListener::NotifyError(uint32_t aServiceId, + int32_t aCallIndex, const nsAString& aError) { BluetoothHfpManager* hfp = BluetoothHfpManager::Get(); @@ -211,14 +216,16 @@ TelephonyListener::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyListener::SupplementaryServiceNotification(int32_t aCallIndex, +TelephonyListener::SupplementaryServiceNotification(uint32_t aServiceId, + int32_t aCallIndex, uint16_t aNotification) { return NS_OK; } NS_IMETHODIMP -TelephonyListener::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyListener::NotifyCdmaCallWaiting(uint32_t aServiceId, + const nsAString& aNumber) { BluetoothHfpManager* hfp = BluetoothHfpManager::Get(); hfp->UpdateSecondNumber(aNumber); @@ -337,4 +344,4 @@ BluetoothRilListener::StopTelephonyListening() nsresult rv = provider->UnregisterListener(mTelephonyListener); return NS_SUCCEEDED(rv); -} \ No newline at end of file +} From a81746a9660f45183a0e17f404637d5a608ac166 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Mon, 28 Oct 2013 20:50:09 +0100 Subject: [PATCH 334/795] Bug 906754 - Ensure that TimeStamp's static fields are initialized only once. r=froydnj --- xpcom/ds/TimeStamp.cpp | 44 +++++++++++++++++++++++++++------- xpcom/ds/TimeStamp.h | 13 ---------- xpcom/ds/TimeStamp_darwin.cpp | 14 ----------- xpcom/ds/TimeStamp_posix.cpp | 13 ---------- xpcom/ds/TimeStamp_windows.cpp | 14 ----------- 5 files changed, 35 insertions(+), 63 deletions(-) diff --git a/xpcom/ds/TimeStamp.cpp b/xpcom/ds/TimeStamp.cpp index c20fa323a3fa..32a1d9dc0e2a 100644 --- a/xpcom/ds/TimeStamp.cpp +++ b/xpcom/ds/TimeStamp.cpp @@ -13,15 +13,41 @@ namespace mozilla { -TimeStamp TimeStamp::sFirstTimeStamp; -TimeStamp TimeStamp::sProcessCreation; +/** + * Wrapper class used to initialize static data used by the TimeStamp class + */ +struct TimeStampInitialization { + /** + * First timestamp taken when the class static initializers are run. This + * timestamp is used to sanitize timestamps coming from different sources. + */ + TimeStamp mFirstTimeStamp; + + /** + * Timestamp representing the time when the process was created. This field + * is populated lazily the first time this information is required and is + * replaced every time the process is restarted. + */ + TimeStamp mProcessCreation; + + TimeStampInitialization() { + TimeStamp::Startup(); + mFirstTimeStamp = TimeStamp::Now(); + }; + + ~TimeStampInitialization() { + TimeStamp::Shutdown(); + }; +}; + +static TimeStampInitialization sInitOnce; TimeStamp TimeStamp::ProcessCreation(bool& aIsInconsistent) { aIsInconsistent = false; - if (sProcessCreation.IsNull()) { + if (sInitOnce.mProcessCreation.IsNull()) { char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART"); TimeStamp ts; @@ -31,32 +57,32 @@ TimeStamp::ProcessCreation(bool& aIsInconsistent) if (mozAppRestart && (strcmp(mozAppRestart, "") != 0)) { /* Firefox was restarted, use the first time-stamp we've taken as the new * process startup time. */ - ts = sFirstTimeStamp; + ts = sInitOnce.mFirstTimeStamp; } else { TimeStamp now = Now(); uint64_t uptime = ComputeProcessUptime(); ts = now - TimeDuration::FromMicroseconds(uptime); - if ((ts > sFirstTimeStamp) || (uptime == 0)) { + if ((ts > sInitOnce.mFirstTimeStamp) || (uptime == 0)) { /* If the process creation timestamp was inconsistent replace it with * the first one instead and notify that a telemetry error was * detected. */ aIsInconsistent = true; - ts = sFirstTimeStamp; + ts = sInitOnce.mFirstTimeStamp; } } - sProcessCreation = ts; + sInitOnce.mProcessCreation = ts; } - return sProcessCreation; + return sInitOnce.mProcessCreation; } void TimeStamp::RecordProcessRestart() { - sProcessCreation = TimeStamp(); + sInitOnce.mProcessCreation = TimeStamp(); } } // namespace mozilla diff --git a/xpcom/ds/TimeStamp.h b/xpcom/ds/TimeStamp.h index 854d091ea5e3..11a137d8ea5b 100644 --- a/xpcom/ds/TimeStamp.h +++ b/xpcom/ds/TimeStamp.h @@ -366,19 +366,6 @@ private: * When using a system clock, a value is system dependent. */ TimeStampValue mValue; - - /** - * First timestamp taken when the class static initializers are run. This - * timestamp is used to sanitize timestamps coming from different sources. - */ - static TimeStamp sFirstTimeStamp; - - /** - * Timestamp representing the time when the process was created. This field - * is populated lazily the first time this information is required and is - * replaced every time the process is restarted. - */ - static TimeStamp sProcessCreation; }; } diff --git a/xpcom/ds/TimeStamp_darwin.cpp b/xpcom/ds/TimeStamp_darwin.cpp index ccea28d40378..7425492f925c 100644 --- a/xpcom/ds/TimeStamp_darwin.cpp +++ b/xpcom/ds/TimeStamp_darwin.cpp @@ -112,18 +112,6 @@ TimeDuration::Resolution() return TimeDuration::FromTicks(int64_t(sResolution)); } -struct TimeStampInitialization -{ - TimeStampInitialization() { - TimeStamp::Startup(); - } - ~TimeStampInitialization() { - TimeStamp::Shutdown(); - } -}; - -static TimeStampInitialization initOnce; - nsresult TimeStamp::Startup() { @@ -150,8 +138,6 @@ TimeStamp::Startup() sResolutionSigDigs *= 10); gInitialized = true; - sFirstTimeStamp = TimeStamp::Now(); - sProcessCreation = TimeStamp(); return NS_OK; } diff --git a/xpcom/ds/TimeStamp_posix.cpp b/xpcom/ds/TimeStamp_posix.cpp index 6f833304c53b..7636cf9bd397 100644 --- a/xpcom/ds/TimeStamp_posix.cpp +++ b/xpcom/ds/TimeStamp_posix.cpp @@ -160,17 +160,6 @@ TimeDuration::Resolution() return TimeDuration::FromTicks(int64_t(sResolution)); } -struct TimeStampInitialization -{ - TimeStampInitialization() { - TimeStamp::Startup(); - } - ~TimeStampInitialization() { - TimeStamp::Shutdown(); - } -}; - -static TimeStampInitialization initOnce; static bool gInitialized = false; nsresult @@ -193,8 +182,6 @@ TimeStamp::Startup() sResolutionSigDigs *= 10); gInitialized = true; - sFirstTimeStamp = TimeStamp::Now(); - sProcessCreation = TimeStamp(); return NS_OK; } diff --git a/xpcom/ds/TimeStamp_windows.cpp b/xpcom/ds/TimeStamp_windows.cpp index ac2c476199be..28ccbf542293 100644 --- a/xpcom/ds/TimeStamp_windows.cpp +++ b/xpcom/ds/TimeStamp_windows.cpp @@ -438,18 +438,6 @@ TimeDuration::Resolution() return TimeDuration::FromTicks(int64_t(sResolution)); } -struct TimeStampInitialization -{ - TimeStampInitialization() { - TimeStamp::Startup(); - } - ~TimeStampInitialization() { - TimeStamp::Shutdown(); - } -}; - -static TimeStampInitialization initOnce; - static bool HasStableTSC() { @@ -515,8 +503,6 @@ TimeStamp::Startup() InitThresholds(); InitResolution(); - sFirstTimeStamp = TimeStamp::Now(); - sProcessCreation = TimeStamp(); return NS_OK; } From 2a868092c9c4e694bddf295b9ffadbaa91a44c90 Mon Sep 17 00:00:00 2001 From: Yuan Xulei Date: Wed, 30 Oct 2013 15:21:02 -0400 Subject: [PATCH 335/795] Bug 914100 - Keep the focused element of forms.js up to date. r=fabrice --- b2g/chrome/content/forms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/chrome/content/forms.js b/b2g/chrome/content/forms.js index 373cf11dc885..bc1c807344e1 100644 --- a/b2g/chrome/content/forms.js +++ b/b2g/chrome/content/forms.js @@ -636,7 +636,7 @@ let FormAssistant = { }, showKeyboard: function fa_showKeyboard(target) { - if (this.isKeyboardOpened) + if (this.focusedElement === target) return; if (target instanceof HTMLOptionElement) From 6fd4d22c47b960e61809d2760d6fedae3956acbc Mon Sep 17 00:00:00 2001 From: Peter Chang Date: Wed, 30 Oct 2013 15:21:22 -0400 Subject: [PATCH 336/795] Bug 915783 - [B2G][Browser][PDF]Graphical fragmentation occurs when viewing a pdf via browser. r=jgilbert --- gfx/gl/SharedSurfaceGralloc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gfx/gl/SharedSurfaceGralloc.cpp b/gfx/gl/SharedSurfaceGralloc.cpp index f17368fd502f..a756ef425e25 100644 --- a/gfx/gl/SharedSurfaceGralloc.cpp +++ b/gfx/gl/SharedSurfaceGralloc.cpp @@ -104,6 +104,12 @@ SharedSurface_Gralloc::Create(GLContext* prodGL, GLuint prodTex = 0; prodGL->fGenTextures(1, &prodTex); ScopedBindTexture autoTex(prodGL, prodTex); + + prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR); + prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR); + prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE); + prodGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE); + prodGL->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, image); egl->fDestroyImage(display, image); From 708d845ac9049faf091f295cc1e6a02061b2f88b Mon Sep 17 00:00:00 2001 From: Ting-Yuan Huang Date: Wed, 30 Oct 2013 15:21:52 -0400 Subject: [PATCH 337/795] Bug 920992 - Specify alignments explicitly in assembly codes. r=derf --- media/libtheora/bug920992.patch | 103 ++++++++++++++++++++++++++++++ media/libtheora/lib/arm/armbits.s | 6 ++ media/libtheora/lib/arm/armfrag.s | 6 ++ media/libtheora/lib/arm/armidct.s | 6 ++ media/libtheora/lib/arm/armloop.s | 6 ++ media/libtheora/update.sh | 1 + 6 files changed, 128 insertions(+) create mode 100644 media/libtheora/bug920992.patch diff --git a/media/libtheora/bug920992.patch b/media/libtheora/bug920992.patch new file mode 100644 index 000000000000..eada85a49b47 --- /dev/null +++ b/media/libtheora/bug920992.patch @@ -0,0 +1,103 @@ +diff --git a/media/libtheora/lib/arm/armbits.s b/media/libtheora/lib/arm/armbits.s +--- a/media/libtheora/lib/arm/armbits.s ++++ b/media/libtheora/lib/arm/armbits.s +@@ -12,16 +12,22 @@ + ; + ; function: + ; last mod: $Id: armbits.s 17481 2010-10-03 22:49:42Z tterribe $ + ; + ;******************************************************************** + + AREA |.text|, CODE, READONLY + ++ ; Explicitly specifying alignment here because some versions of ++ ; gas don't align code correctly. See ++ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html ++ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 ++ ALIGN ++ + EXPORT oc_pack_read_arm + EXPORT oc_pack_read1_arm + EXPORT oc_huff_token_decode_arm + + oc_pack_read1_arm PROC + ; r0 = oc_pack_buf *_b + ADD r12,r0,#8 + LDMIA r12,{r2,r3} ; r2 = window +diff --git a/media/libtheora/lib/arm/armfrag.s b/media/libtheora/lib/arm/armfrag.s +--- a/media/libtheora/lib/arm/armfrag.s ++++ b/media/libtheora/lib/arm/armfrag.s +@@ -11,16 +11,22 @@ + ;******************************************************************** + ; Original implementation: + ; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd + ; last mod: $Id: armfrag.s 17481 2010-10-03 22:49:42Z tterribe $ + ;******************************************************************** + + AREA |.text|, CODE, READONLY + ++ ; Explicitly specifying alignment here because some versions of ++ ; gas don't align code correctly. See ++ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html ++ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 ++ ALIGN ++ + GET armopts.s + + ; Vanilla ARM v4 versions + EXPORT oc_frag_copy_list_arm + EXPORT oc_frag_recon_intra_arm + EXPORT oc_frag_recon_inter_arm + EXPORT oc_frag_recon_inter2_arm + +diff --git a/media/libtheora/lib/arm/armidct.s b/media/libtheora/lib/arm/armidct.s +--- a/media/libtheora/lib/arm/armidct.s ++++ b/media/libtheora/lib/arm/armidct.s +@@ -11,16 +11,22 @@ + ;******************************************************************** + ; Original implementation: + ; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd + ; last mod: $Id: armidct.s 17481 2010-10-03 22:49:42Z tterribe $ + ;******************************************************************** + + AREA |.text|, CODE, READONLY + ++ ; Explicitly specifying alignment here because some versions of ++ ; gas don't align code correctly. See ++ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html ++ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 ++ ALIGN ++ + GET armopts.s + + EXPORT oc_idct8x8_1_arm + EXPORT oc_idct8x8_arm + + oc_idct8x8_1_arm PROC + ; r0 = ogg_int16_t *_y + ; r1 = ogg_uint16_t _dc +diff --git a/media/libtheora/lib/arm/armloop.s b/media/libtheora/lib/arm/armloop.s +--- a/media/libtheora/lib/arm/armloop.s ++++ b/media/libtheora/lib/arm/armloop.s +@@ -11,16 +11,22 @@ + ;******************************************************************** + ; Original implementation: + ; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd + ; last mod: $Id: armloop.s 17481 2010-10-03 22:49:42Z tterribe $ + ;******************************************************************** + + AREA |.text|, CODE, READONLY + ++ ; Explicitly specifying alignment here because some versions of ++ ; gas don't align code correctly. See ++ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html ++ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 ++ ALIGN ++ + GET armopts.s + + EXPORT oc_loop_filter_frag_rows_arm + + ; Which bit this is depends on the order of packing within a bitfield. + ; Hopefully that doesn't change among any of the relevant compilers. + OC_FRAG_CODED_FLAG * 1 diff --git a/media/libtheora/lib/arm/armbits.s b/media/libtheora/lib/arm/armbits.s index a98bad736307..0fdb6fdd3744 100644 --- a/media/libtheora/lib/arm/armbits.s +++ b/media/libtheora/lib/arm/armbits.s @@ -17,6 +17,12 @@ AREA |.text|, CODE, READONLY + ; Explicitly specifying alignment here because some versions of + ; gas don't align code correctly. See + ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html + ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 + ALIGN + EXPORT oc_pack_read_arm EXPORT oc_pack_read1_arm EXPORT oc_huff_token_decode_arm diff --git a/media/libtheora/lib/arm/armfrag.s b/media/libtheora/lib/arm/armfrag.s index 553ccf453f64..e20579eee4b0 100644 --- a/media/libtheora/lib/arm/armfrag.s +++ b/media/libtheora/lib/arm/armfrag.s @@ -16,6 +16,12 @@ AREA |.text|, CODE, READONLY + ; Explicitly specifying alignment here because some versions of + ; gas don't align code correctly. See + ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html + ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 + ALIGN + GET armopts.s ; Vanilla ARM v4 versions diff --git a/media/libtheora/lib/arm/armidct.s b/media/libtheora/lib/arm/armidct.s index c498a893eb32..babd846ecd30 100644 --- a/media/libtheora/lib/arm/armidct.s +++ b/media/libtheora/lib/arm/armidct.s @@ -16,6 +16,12 @@ AREA |.text|, CODE, READONLY + ; Explicitly specifying alignment here because some versions of + ; gas don't align code correctly. See + ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html + ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 + ALIGN + GET armopts.s EXPORT oc_idct8x8_1_arm diff --git a/media/libtheora/lib/arm/armloop.s b/media/libtheora/lib/arm/armloop.s index ce6232354de4..0a1d4705e740 100644 --- a/media/libtheora/lib/arm/armloop.s +++ b/media/libtheora/lib/arm/armloop.s @@ -16,6 +16,12 @@ AREA |.text|, CODE, READONLY + ; Explicitly specifying alignment here because some versions of + ; gas don't align code correctly. See + ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html + ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992 + ALIGN + GET armopts.s EXPORT oc_loop_filter_frag_rows_arm diff --git a/media/libtheora/update.sh b/media/libtheora/update.sh index a8421649a4c4..e1a95425a616 100644 --- a/media/libtheora/update.sh +++ b/media/libtheora/update.sh @@ -83,3 +83,4 @@ patch -p3 < ./bug468275-r18219.patch patch -p3 < ./bug752139-r18031.patch patch -p3 < ./bug752668-r18268.patch patch -p3 < ./bug703135.patch +patch -p3 < ./bug920992.patch From 1228cd0bfe4099618320416391879e1177454368 Mon Sep 17 00:00:00 2001 From: Chia-hung Tai Date: Wed, 30 Oct 2013 11:48:47 +0800 Subject: [PATCH 338/795] Bug 921917 - B2G MMS: Provide a flag to let user be able to request read report or not when sending MMS. r=gene --- b2g/chrome/content/settings.js | 5 +++++ dom/mobilemessage/src/gonk/MmsService.js | 7 ++++++- modules/libpref/src/init/all.js | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/b2g/chrome/content/settings.js b/b2g/chrome/content/settings.js index 8459611668d6..7a182a29bc1a 100644 --- a/b2g/chrome/content/settings.js +++ b/b2g/chrome/content/settings.js @@ -138,6 +138,11 @@ SettingsListener.observe('language.current', 'en-US', function(value) { Services.prefs.setBoolPref('dom.mms.requestStatusReport', value); }); + SettingsListener.observe('ril.mms.requestReadReport.enabled', true, + function(value) { + Services.prefs.setBoolPref('dom.mms.requestReadReport', value); + }); + SettingsListener.observe('ril.cellbroadcast.disabled', false, function(value) { Services.prefs.setBoolPref('ril.cellbroadcast.disabled', value); diff --git a/dom/mobilemessage/src/gonk/MmsService.js b/dom/mobilemessage/src/gonk/MmsService.js index c619043e97e3..9783df0bbc90 100644 --- a/dom/mobilemessage/src/gonk/MmsService.js +++ b/dom/mobilemessage/src/gonk/MmsService.js @@ -952,7 +952,12 @@ function SendTransaction(cancellableId, msg, requestDeliveryReport) { msg.headers["x-mms-message-class"] = "personal"; msg.headers["x-mms-expiry"] = 7 * 24 * 60 * 60; msg.headers["x-mms-priority"] = 129; - msg.headers["x-mms-read-report"] = true; + try { + msg.headers["x-mms-read-report"] = + Services.prefs.getBoolPref("dom.mms.requestReadReport"); + } catch (e) { + msg.headers["x-mms-read-report"] = true; + } msg.headers["x-mms-delivery-report"] = requestDeliveryReport; if (!gMmsTransactionHelper.checkMaxValuesParameters(msg)) { diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index e17ead3078b6..43c32e4970f4 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4476,6 +4476,9 @@ pref("dom.mms.defaultServiceId", 0); // Debug enabler for MMS. pref("mms.debugging.enabled", false); +// Request read report while sending MMS. +pref("dom.mms.requestReadReport", true); + // Number of RadioInterface instances to create. pref("ril.numRadioInterfaces", 0); From fbab4af1ec83c24dd849d1a824905b617eb31e7b Mon Sep 17 00:00:00 2001 From: Bevis Tseng Date: Mon, 28 Oct 2013 16:43:38 +0800 Subject: [PATCH 339/795] Bug 922580 - B2G MMS: Stop downloading MMS immediately when airplane mode is on. r=gene --- dom/mobilemessage/src/gonk/MmsService.js | 93 ++++++++++++++++-------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/dom/mobilemessage/src/gonk/MmsService.js b/dom/mobilemessage/src/gonk/MmsService.js index 9783df0bbc90..53b93a0cec4d 100644 --- a/dom/mobilemessage/src/gonk/MmsService.js +++ b/dom/mobilemessage/src/gonk/MmsService.js @@ -37,21 +37,28 @@ const NS_XPCOM_SHUTDOWN_OBSERVER_ID = "xpcom-shutdown"; const kNetworkInterfaceStateChangedTopic = "network-interface-state-changed"; const kMobileMessageDeletedObserverTopic = "mobile-message-deleted"; +const kPrefRilMmsc = "ril.mms.mmsc"; +const kPrefRilMmsProxy = "ril.mms.mmsproxy"; +const kPrefRilMmsPort = "ril.mms.mmsport"; +const kPrefRilRadioDisabled = "ril.radio.disabled"; + // HTTP status codes: // @see http://tools.ietf.org/html/rfc2616#page-39 const HTTP_STATUS_OK = 200; // Non-standard HTTP status for internal use. -const _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS = 0; -const _HTTP_STATUS_USER_CANCELLED = -1; -const _HTTP_STATUS_RADIO_DISABLED = -2; -const _HTTP_STATUS_NO_SIM_CARD = -3; -const _HTTP_STATUS_ACQUIRE_TIMEOUT = 4; +const _HTTP_STATUS_ACQUIRE_CONNECTION_SUCCESS = 0; +const _HTTP_STATUS_USER_CANCELLED = -1; +const _HTTP_STATUS_RADIO_DISABLED = -2; +const _HTTP_STATUS_NO_SIM_CARD = -3; +const _HTTP_STATUS_ACQUIRE_TIMEOUT = -4; // Non-standard MMS status for internal use. -const _MMS_ERROR_MESSAGE_DELETED = -1; -const _MMS_ERROR_RADIO_DISABLED = -2; -const _MMS_ERROR_NO_SIM_CARD = -3; +const _MMS_ERROR_MESSAGE_DELETED = -1; +const _MMS_ERROR_RADIO_DISABLED = -2; +const _MMS_ERROR_NO_SIM_CARD = -3; +const _MMS_ERROR_SHUTDOWN = -4; +const _MMS_ERROR_USER_CANCELLED_NO_REASON = -5; const CONFIG_SEND_REPORT_NEVER = 0; const CONFIG_SEND_REPORT_DEFAULT_NO = 1; @@ -156,10 +163,10 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () { radioDisabled: false, proxyInfo: null, - settings: ["ril.mms.mmsc", - "ril.mms.mmsproxy", - "ril.mms.mmsport", - "ril.radio.disabled"], + settings: [kPrefRilMmsc, + kPrefRilMmsProxy, + kPrefRilMmsPort, + kPrefRilRadioDisabled], connected: false, //A queue to buffer the MMS HTTP requests when the MMS network @@ -206,9 +213,9 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () { }, this); try { - this.mmsc = Services.prefs.getCharPref("ril.mms.mmsc"); - this.proxy = Services.prefs.getCharPref("ril.mms.mmsproxy"); - this.port = Services.prefs.getIntPref("ril.mms.mmsport"); + this.mmsc = Services.prefs.getCharPref(kPrefRilMmsc); + this.proxy = Services.prefs.getCharPref(kPrefRilMmsProxy); + this.port = Services.prefs.getIntPref(kPrefRilMmsPort); this.updateProxyInfo(); } catch (e) { if (DEBUG) debug("Unable to initialize the MMS proxy settings from " + @@ -218,7 +225,7 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () { } try { - this.radioDisabled = Services.prefs.getBoolPref("ril.radio.disabled"); + this.radioDisabled = Services.prefs.getBoolPref(kPrefRilRadioDisabled); } catch (e) { if (DEBUG) debug("Getting preference 'ril.radio.disabled' fails."); this.radioDisabled = false; @@ -373,9 +380,9 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () { break; } case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID: { - if (data == "ril.radio.disabled") { + if (data == kPrefRilRadioDisabled) { try { - this.radioDisabled = Services.prefs.getBoolPref("ril.radio.disabled"); + this.radioDisabled = Services.prefs.getBoolPref(kPrefRilRadioDisabled); } catch (e) { if (DEBUG) debug("Updating preference 'ril.radio.disabled' fails."); this.radioDisabled = false; @@ -385,15 +392,15 @@ XPCOMUtils.defineLazyGetter(this, "gMmsConnection", function () { try { switch (data) { - case "ril.mms.mmsc": - this.mmsc = Services.prefs.getCharPref("ril.mms.mmsc"); + case kPrefRilMmsc: + this.mmsc = Services.prefs.getCharPref(kPrefRilMmsc); break; - case "ril.mms.mmsproxy": - this.proxy = Services.prefs.getCharPref("ril.mms.mmsproxy"); + case kPrefRilMmsProxy: + this.proxy = Services.prefs.getCharPref(kPrefRilMmsProxy); this.updateProxyInfo(); break; - case "ril.mms.mmsport": - this.port = Services.prefs.getIntPref("ril.mms.mmsport"); + case kPrefRilMmsPort: + this.port = Services.prefs.getIntPref(kPrefRilMmsPort); this.updateProxyInfo(); break; default: @@ -671,10 +678,12 @@ XPCOMUtils.defineLazyGetter(this, "gMmsTransactionHelper", function () { return true; }, - translateHttpStatusToMmsStatus: function translateHttpStatusToMmsStatus(httpStatus, defaultStatus) { + translateHttpStatusToMmsStatus: function translateHttpStatusToMmsStatus(httpStatus, + cancelledReason, + defaultStatus) { switch(httpStatus) { case _HTTP_STATUS_USER_CANCELLED: - return _MMS_ERROR_MESSAGE_DELETED; + return cancelledReason; case _HTTP_STATUS_RADIO_DISABLED: return _MMS_ERROR_RADIO_DISABLED; case _HTTP_STATUS_NO_SIM_CARD: @@ -756,10 +765,13 @@ CancellableTransaction.prototype = { isObserversAdded: false, + cancelledReason: _MMS_ERROR_USER_CANCELLED_NO_REASON, + registerRunCallback: function registerRunCallback(callback) { if (!this.isObserversAdded) { Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); Services.obs.addObserver(this, kMobileMessageDeletedObserverTopic, false); + Services.prefs.addObserver(kPrefRilRadioDisabled, this, false); this.isObserversAdded = true; } @@ -771,6 +783,7 @@ CancellableTransaction.prototype = { if (this.isObserversAdded) { Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); Services.obs.removeObserver(this, kMobileMessageDeletedObserverTopic); + Services.prefs.removeObserver(kPrefRilRadioDisabled, this); this.isObserversAdded = false; } }, @@ -788,15 +801,16 @@ CancellableTransaction.prototype = { // |gMmsTransactionHelper.sendRequest(...)|. cancellable: null, - cancelRunning: function cancelRunning() { + cancelRunning: function cancelRunning(reason) { this.isCancelled = true; + this.cancelledReason = reason; if (this.timer) { // The sending or retrieving process is waiting for the next retry. // What we only need to do is to cancel the timer. this.timer.cancel(); this.timer = null; - this.runCallbackIfValid(_MMS_ERROR_MESSAGE_DELETED, null); + this.runCallbackIfValid(reason, null); return; } @@ -813,7 +827,7 @@ CancellableTransaction.prototype = { observe: function observe(subject, topic, data) { switch (topic) { case NS_XPCOM_SHUTDOWN_OBSERVER_ID: { - this.cancelRunning(); + this.cancelRunning(_MMS_ERROR_SHUTDOWN); break; } case kMobileMessageDeletedObserverTopic: { @@ -822,7 +836,20 @@ CancellableTransaction.prototype = { return; } - this.cancelRunning(); + this.cancelRunning(_MMS_ERROR_MESSAGE_DELETED); + break; + } + case NS_PREFBRANCH_PREFCHANGE_TOPIC_ID: { + if (data == kPrefRilRadioDisabled) { + try { + let radioDisabled = Services.prefs.getBoolPref(kPrefRilRadioDisabled); + if (radioDisabled) { + this.cancelRunning(_MMS_ERROR_RADIO_DISABLED); + } + } catch (e) { + if (DEBUG) debug("Failed to get preference of 'ril.radio.disabled'."); + } + } break; } } @@ -891,6 +918,7 @@ RetrieveTransaction.prototype = Object.create(CancellableTransaction.prototype, (function (httpStatus, data) { let mmsStatus = gMmsTransactionHelper .translateHttpStatusToMmsStatus(httpStatus, + this.cancelledReason, MMS.MMS_PDU_STATUS_DEFERRED); if (mmsStatus != MMS.MMS_PDU_ERROR_OK) { callback(mmsStatus, null); @@ -1125,9 +1153,10 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, { this.cancellable = gMmsTransactionHelper.sendRequest("POST", gMmsConnection.mmsc, this.istream, - function (httpStatus, data) { + (function (httpStatus, data) { let mmsStatus = gMmsTransactionHelper. translateHttpStatusToMmsStatus(httpStatus, + this.cancelledReason, MMS.MMS_PDU_ERROR_TRANSIENT_FAILURE); if (httpStatus != HTTP_STATUS_OK) { callback(mmsStatus, null); @@ -1147,7 +1176,7 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, { let responseStatus = response.headers["x-mms-response-status"]; callback(responseStatus, response); - }); + }).bind(this)); }, enumerable: true, configurable: true, From 240d85fb1df1250c4358400a9dcc4a9244ef3491 Mon Sep 17 00:00:00 2001 From: John Shih Date: Wed, 16 Oct 2013 17:59:07 +0800 Subject: [PATCH 340/795] Bug 927328 - Make sure app stats is updated when retrieving function is called. r=gene --- dom/network/src/NetworkStatsService.jsm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dom/network/src/NetworkStatsService.jsm b/dom/network/src/NetworkStatsService.jsm index 3a0e15b25e81..80115976d436 100644 --- a/dom/network/src/NetworkStatsService.jsm +++ b/dom/network/src/NetworkStatsService.jsm @@ -268,12 +268,13 @@ this.NetworkStatsService = { debug("getstats for network " + network.id + " of type " + network.type); debug("appId: " + appId + " from manifestURL: " + manifestURL); - self._db.find(function onStatsFound(aError, aResult) { - mm.sendAsyncMessage("NetworkStats:Get:Return", - { id: msg.id, error: aError, result: aResult }); - }, network, start, end, appId, manifestURL); - - }); + this.updateCachedAppStats(function onAppStatsUpdated(aResult, aMessage) { + self._db.find(function onStatsFound(aError, aResult) { + mm.sendAsyncMessage("NetworkStats:Get:Return", + { id: msg.id, error: aError, result: aResult }); + }, network, start, end, appId, manifestURL); + }); + }.bind(this)); }, clearInterfaceStats: function clearInterfaceStats(mm, msg) { @@ -561,6 +562,10 @@ this.NetworkStatsService = { let stats = Object.keys(this.cachedAppStats); if (stats.length == 0) { // |cachedAppStats| is empty, no need to update. + if (aCallback) { + aCallback(true, "no need to update"); + } + return; } From dfa3c412c30de9a117c48782bd88869275717652 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Wed, 16 Oct 2013 18:15:55 +0800 Subject: [PATCH 341/795] Bug 926343 - Part 6: Use default clientId in PhoneNumberUtils. r=gwagner --- dom/phonenumberutils/PhoneNumberUtils.jsm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dom/phonenumberutils/PhoneNumberUtils.jsm b/dom/phonenumberutils/PhoneNumberUtils.jsm index d7594e212ccf..377d29bbcfe6 100644 --- a/dom/phonenumberutils/PhoneNumberUtils.jsm +++ b/dom/phonenumberutils/PhoneNumberUtils.jsm @@ -43,15 +43,22 @@ this.PhoneNumberUtils = { let countryName; #ifdef MOZ_B2G_RIL - // Get network mcc // TODO: Bug 926740 - PhoneNumberUtils for multisim - let voice = mobileConnection.getVoiceConnectionInfo(0); + // In Multi-sim, there is more than one client in + // iccProvider/mobileConnectionProvider. Each client represents a + // icc/mobileConnection service. To maintain the backward compatibility with + // single sim, we always use client 0 for now. Adding support for multiple + // sim will be addressed in bug 926740, if needed. + let clientId = 0; + + // Get network mcc + let voice = mobileConnection.getVoiceConnectionInfo(clientId); if (voice && voice.network && voice.network.mcc) { mcc = voice.network.mcc; } // Get SIM mcc - let iccInfo = icc.iccInfo; + let iccInfo = icc.getIccInfo(clientId); if (!mcc && iccInfo && iccInfo.mcc) { mcc = iccInfo.mcc; } From 6fa63f3cd7d56df5a8fdbadadf5603d2f741204b Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Wed, 16 Oct 2013 18:29:36 +0800 Subject: [PATCH 342/795] Bug 926343 - Part 7: Use default clientId in PushService. r=nsm --- dom/push/src/PushService.jsm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dom/push/src/PushService.jsm b/dom/push/src/PushService.jsm index 9ee5c6aeb9ab..da494e8c8a48 100644 --- a/dom/push/src/PushService.jsm +++ b/dom/push/src/PushService.jsm @@ -1480,11 +1480,18 @@ this.PushService = { let nm = Cc["@mozilla.org/network/manager;1"].getService(Ci.nsINetworkManager); if (nm.active && nm.active.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE) { let icc = Cc["@mozilla.org/ril/content-helper;1"].getService(Ci.nsIIccProvider); - if (icc.iccInfo) { + // TODO: Bug 927721 - PushService for multi-sim + // In Multi-sim, there is more than one client in iccProvider. Each + // client represents a icc service. To maintain backward compatibility + // with single sim, we always use client 0 for now. Adding support + // for multiple sim will be addressed in bug 927721, if needed. + let clientId = 0; + let iccInfo = icc.getIccInfo(clientId); + if (iccInfo) { debug("Running on mobile data"); return { - mcc: icc.iccInfo.mcc, - mnc: icc.iccInfo.mnc, + mcc: iccInfo.mcc, + mnc: iccInfo.mnc, ip: nm.active.ip } } From 4ddb510ae232ed3f05820463227104420f128d2f Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 20:50:24 -0700 Subject: [PATCH 343/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/be86ac21caa5 Author: Kevin Grandon Desc: Merge pull request #12801 from KevinGrandon/bug_924274_add_contacts_tests Bug 924274 - [Contacts] Add marionette tests r=arcturus, jmcf ======== https://hg.mozilla.org/integration/gaia-central/rev/6c141a3c6e90 Author: Kevin Grandon Desc: Bug 924274 - [Contacts] Add initial marionette tests --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 12805328c12a..b84a3d402c2f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "4b20ba0aa48d1f26da98e72f8e8f013a6e8d2fe9", + "revision": "be86ac21caa500b81d9580bbaf18ebac2518610c", "repo_path": "/integration/gaia-central" } From ef94e4a84cb560dc138a204918d305bd167898c8 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 22:00:24 -0700 Subject: [PATCH 344/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/e4b8f3ed4be2 Author: Arthur Chen Desc: Merge pull request #13244 from TheoChevalier/bug-906238-master Bug 906238 - [l10n] manual not localized in Cellular & Data >Network ope... r=crh0716 ======== https://hg.mozilla.org/integration/gaia-central/rev/1ad6b42169ca Author: TheoChevalier Desc: Bug 906238 - [l10n] manual not localized in Cellular & Data >Network operator > Automatic selection --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index b84a3d402c2f..304c4992654d 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "be86ac21caa500b81d9580bbaf18ebac2518610c", + "revision": "e4b8f3ed4be2ddbf73af5f683aca85a4d99703db", "repo_path": "/integration/gaia-central" } From ecc47b3df710a063b13811f347fed9e97946f7a3 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 23:00:24 -0700 Subject: [PATCH 345/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/f44b0c133388 Author: Timothy Guan-tin Chien Desc: Revert "Revert "Merge pull request #12892 from comoyo/value_selector_inputcontext"" This reverts commit a8606f77a25fab9497c7130eac6cf7a29a2783ac. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 304c4992654d..c32fbf5905d7 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "e4b8f3ed4be2ddbf73af5f683aca85a4d99703db", + "revision": "f44b0c133388799bcbbab9ac547e494bda867f6b", "repo_path": "/integration/gaia-central" } From 76e8989a579170047517d82705337200fcfc9f58 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 23:55:23 -0700 Subject: [PATCH 346/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/a4bb4b7a207f Author: Jose M. Cantera Desc: Merge pull request #13225 from jmcanterafonseca/fix_932765 Bug 932765 - Dialer / Call log does not recognize incoming / outgoing ca... ======== https://hg.mozilla.org/integration/gaia-central/rev/8d1d7708e789 Author: Jose M. Cantera Desc: Bug 932765 - Dialer / Call log does not recognize incoming / outgoing calls from FB contacts --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c32fbf5905d7..90c9b77ef089 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "f44b0c133388799bcbbab9ac547e494bda867f6b", + "revision": "a4bb4b7a207f12d16ca697ac93946fd11977634c", "repo_path": "/integration/gaia-central" } From 2e30d236f74d9467cda1123298a95d1ca4e8c397 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Thu, 31 Oct 2013 03:40:23 -0700 Subject: [PATCH 347/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/4e0897d8651b Author: GaryChen(pychen) Desc: Merge pull request #13252 from mpizza/Bug_930817_fitText Bug 930817 - [B2G][1.2][l10n][Keyboard] Long words in the Auto Correct ... r=rudyl. ======== https://hg.mozilla.org/integration/gaia-central/rev/58aa6decd41a Author: GaryChen(pychen) Desc: Bug 930817 - [B2G][1.2][l10n][Keyboard] Long words in the Auto Correct suggestion bar cut each other off -- remove docFragment method to generate candidate ele since use docFragment can get cliendwidth and getBoundingClientRect --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 90c9b77ef089..c4e1251e659c 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "a4bb4b7a207f12d16ca697ac93946fd11977634c", + "revision": "4e0897d8651b9833b80793246df03ec885fb463d", "repo_path": "/integration/gaia-central" } From b4d4b8fe5a48fbfc42063c335f15ca9dc86ec78f Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Thu, 31 Oct 2013 04:30:24 -0700 Subject: [PATCH 348/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/4bbc9f71b0e3 Author: Arnau Desc: Merge pull request #13134 from rnowm/931693 Bug 931693 - Confirm [BB] - Fix console warning due to flex property ======== https://hg.mozilla.org/integration/gaia-central/rev/81d3ebe3d0a0 Author: rnowm Desc: Bug 931693 - Confirm [BB] - Fix console warning due to flex property --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c4e1251e659c..ee2a62bf60f3 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "4e0897d8651b9833b80793246df03ec885fb463d", + "revision": "4bbc9f71b0e3b607f53187c4721b2d9086f1d337", "repo_path": "/integration/gaia-central" } From 1a6dab6e960b0c9ec3bedf38f62052a4e216dc96 Mon Sep 17 00:00:00 2001 From: Shao Hang Kao Date: Tue, 22 Oct 2013 16:57:25 +0800 Subject: [PATCH 349/795] Bug 928821 - B2G MMS: put deliveryStatus[] into a more generic structure MmsDeliveryInfo[] sr=gene r=gene --- .../interfaces/nsIDOMMozMmsMessage.idl | 10 +- .../interfaces/nsIMobileMessageService.idl | 4 +- dom/mobilemessage/src/MmsMessage.cpp | 220 +++++++++++------- dom/mobilemessage/src/MmsMessage.h | 6 +- .../src/MobileMessageService.cpp | 4 +- dom/mobilemessage/src/gonk/MmsService.js | 25 +- .../src/gonk/MobileMessageDatabaseService.js | 82 +++++-- dom/mobilemessage/src/ipc/SmsTypes.ipdlh | 30 ++- 8 files changed, 253 insertions(+), 128 deletions(-) diff --git a/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl b/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl index 5d7ed281a10d..ec6d89fc3597 100644 --- a/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl +++ b/dom/mobilemessage/interfaces/nsIDOMMozMmsMessage.idl @@ -15,7 +15,13 @@ dictionary MmsAttachment // for text should always be "utf-8". }; -[scriptable, builtinclass, uuid(2e5e1c16-b7af-11e2-af04-8f4b1610a600)] +dictionary MmsDeliveryInfo +{ + DOMString? receiver; + DOMString? deliveryStatus; +}; + +[scriptable, builtinclass, uuid(494bbca1-ac7c-47d2-9e90-4e7d07e1cb4f)] interface nsIDOMMozMmsMessage : nsISupports { /** @@ -33,7 +39,7 @@ interface nsIDOMMozMmsMessage : nsISupports readonly attribute DOMString delivery; [implicit_jscontext] - readonly attribute jsval deliveryStatus; // DOMString[] + readonly attribute jsval deliveryInfo; // MmsDeliveryInfo[] readonly attribute DOMString sender; diff --git a/dom/mobilemessage/interfaces/nsIMobileMessageService.idl b/dom/mobilemessage/interfaces/nsIMobileMessageService.idl index a5d567aff392..d219071ee276 100644 --- a/dom/mobilemessage/interfaces/nsIMobileMessageService.idl +++ b/dom/mobilemessage/interfaces/nsIMobileMessageService.idl @@ -14,7 +14,7 @@ interface nsIDOMMozSmsSegmentInfo; #define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1" %} -[scriptable, builtinclass, uuid(bea56ecf-472d-4b6b-b462-66753f3c1179)] +[scriptable, builtinclass, uuid(2a231e8d-761d-47a9-8928-93de7b0cbaac)] interface nsIMobileMessageService : nsISupports { [implicit_jscontext] @@ -33,7 +33,7 @@ interface nsIMobileMessageService : nsISupports nsIDOMMozMmsMessage createMmsMessage(in long id, in unsigned long long threadId, in DOMString delivery, - in jsval deliveryStatus, + in jsval deliveryInfo, in DOMString sender, in jsval receivers, in jsval timestamp, diff --git a/dom/mobilemessage/src/MmsMessage.cpp b/dom/mobilemessage/src/MmsMessage.cpp index 3f80de139c29..9f39d062468d 100644 --- a/dom/mobilemessage/src/MmsMessage.cpp +++ b/dom/mobilemessage/src/MmsMessage.cpp @@ -33,22 +33,22 @@ NS_INTERFACE_MAP_END NS_IMPL_ADDREF(MmsMessage) NS_IMPL_RELEASE(MmsMessage) -MmsMessage::MmsMessage(int32_t aId, - const uint64_t aThreadId, - DeliveryState aDelivery, - const nsTArray& aDeliveryStatus, - const nsAString& aSender, - const nsTArray& aReceivers, - uint64_t aTimestamp, - bool aRead, - const nsAString& aSubject, - const nsAString& aSmil, - const nsTArray& aAttachments, - uint64_t aExpiryDate) +MmsMessage::MmsMessage(int32_t aId, + const uint64_t aThreadId, + DeliveryState aDelivery, + const nsTArray& aDeliveryInfo, + const nsAString& aSender, + const nsTArray& aReceivers, + uint64_t aTimestamp, + bool aRead, + const nsAString& aSubject, + const nsAString& aSmil, + const nsTArray& aAttachments, + uint64_t aExpiryDate) : mId(aId), mThreadId(aThreadId), mDelivery(aDelivery), - mDeliveryStatus(aDeliveryStatus), + mDeliveryInfo(aDeliveryInfo), mSender(aSender), mReceivers(aReceivers), mTimestamp(aTimestamp), @@ -64,7 +64,6 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData) : mId(aData.id()) , mThreadId(aData.threadId()) , mDelivery(aData.delivery()) - , mDeliveryStatus(aData.deliveryStatus()) , mSender(aData.sender()) , mReceivers(aData.receivers()) , mTimestamp(aData.timestamp()) @@ -89,6 +88,41 @@ MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData) } mAttachments.AppendElement(att); } + + len = aData.deliveryInfo().Length(); + mDeliveryInfo.SetCapacity(len); + for (uint32_t i = 0; i < len; i++) { + MmsDeliveryInfo info; + const MmsDeliveryInfoData &infoData = aData.deliveryInfo()[i]; + info.receiver = infoData.receiver(); + + nsString statusStr; + switch (infoData.deliveryStatus()) { + case eDeliveryStatus_NotApplicable: + statusStr = DELIVERY_STATUS_NOT_APPLICABLE; + break; + case eDeliveryStatus_Success: + statusStr = DELIVERY_STATUS_SUCCESS; + break; + case eDeliveryStatus_Pending: + statusStr = DELIVERY_STATUS_PENDING; + break; + case eDeliveryStatus_Error: + statusStr = DELIVERY_STATUS_ERROR; + break; + case eDeliveryStatus_Reject: + statusStr = DELIVERY_STATUS_REJECTED; + break; + case eDeliveryStatus_Manual: + statusStr = DELIVERY_STATUS_MANUAL; + break; + case eDeliveryStatus_EndGuard: + default: + MOZ_CRASH("We shouldn't get any other delivery status!"); + } + info.deliveryStatus = statusStr; + mDeliveryInfo.AppendElement(info); + } } /** @@ -128,7 +162,7 @@ convertTimeToInt(JSContext* aCx, const JS::Value& aTime, uint64_t& aReturn) MmsMessage::Create(int32_t aId, const uint64_t aThreadId, const nsAString& aDelivery, - const JS::Value& aDeliveryStatus, + const JS::Value& aDeliveryInfo, const nsAString& aSender, const JS::Value& aReceivers, const JS::Value& aTimestamp, @@ -158,47 +192,31 @@ MmsMessage::Create(int32_t aId, return NS_ERROR_INVALID_ARG; } - // Set |deliveryStatus|. - if (!aDeliveryStatus.isObject()) { + // Set |deliveryInfo|. + if (!aDeliveryInfo.isObject()) { return NS_ERROR_INVALID_ARG; } - JS::Rooted deliveryStatusObj(aCx, &aDeliveryStatus.toObject()); - if (!JS_IsArrayObject(aCx, deliveryStatusObj)) { + JS::Rooted deliveryInfoObj(aCx, &aDeliveryInfo.toObject()); + if (!JS_IsArrayObject(aCx, deliveryInfoObj)) { return NS_ERROR_INVALID_ARG; } uint32_t length; - JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryStatusObj, &length)); + JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, deliveryInfoObj, &length)); - nsTArray deliveryStatus; - JS::Rooted statusJsVal(aCx); + nsTArray deliveryInfo; + JS::Rooted infoJsVal(aCx); for (uint32_t i = 0; i < length; ++i) { - if (!JS_GetElement(aCx, deliveryStatusObj, i, &statusJsVal) || - !statusJsVal.isString()) { + if (!JS_GetElement(aCx, deliveryInfoObj, i, &infoJsVal) || + !infoJsVal.isObject()) { return NS_ERROR_INVALID_ARG; } - nsDependentJSString statusStr; - statusStr.init(aCx, statusJsVal.toString()); + MmsDeliveryInfo info; + nsresult rv = info.Init(aCx, infoJsVal.address()); + NS_ENSURE_SUCCESS(rv, rv); - DeliveryStatus status; - if (statusStr.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) { - status = eDeliveryStatus_NotApplicable; - } else if (statusStr.Equals(DELIVERY_STATUS_SUCCESS)) { - status = eDeliveryStatus_Success; - } else if (statusStr.Equals(DELIVERY_STATUS_PENDING)) { - status = eDeliveryStatus_Pending; - } else if (statusStr.Equals(DELIVERY_STATUS_ERROR)) { - status = eDeliveryStatus_Error; - } else if (statusStr.Equals(DELIVERY_STATUS_REJECTED)) { - status = eDeliveryStatus_Reject; - } else if (statusStr.Equals(DELIVERY_STATUS_MANUAL)) { - status = eDeliveryStatus_Manual; - } else { - return NS_ERROR_INVALID_ARG; - } - - deliveryStatus.AppendElement(status); + deliveryInfo.AppendElement(info); } // Set |receivers|. @@ -263,7 +281,7 @@ MmsMessage::Create(int32_t aId, nsCOMPtr message = new MmsMessage(aId, aThreadId, delivery, - deliveryStatus, + deliveryInfo, aSender, receivers, timestamp, @@ -285,7 +303,6 @@ MmsMessage::GetData(ContentParent* aParent, aData.id() = mId; aData.threadId() = mThreadId; aData.delivery() = mDelivery; - aData.deliveryStatus() = mDeliveryStatus; aData.sender().Assign(mSender); aData.receivers() = mReceivers; aData.timestamp() = mTimestamp; @@ -294,6 +311,32 @@ MmsMessage::GetData(ContentParent* aParent, aData.smil() = mSmil; aData.expiryDate() = mExpiryDate; + aData.deliveryInfo().SetCapacity(mDeliveryInfo.Length()); + for (uint32_t i = 0; i < mDeliveryInfo.Length(); i++) { + MmsDeliveryInfoData infoData; + const MmsDeliveryInfo &info = mDeliveryInfo[i]; + infoData.receiver().Assign(info.receiver); + + DeliveryStatus status; + if (info.deliveryStatus.Equals(DELIVERY_STATUS_NOT_APPLICABLE)) { + status = eDeliveryStatus_NotApplicable; + } else if (info.deliveryStatus.Equals(DELIVERY_STATUS_SUCCESS)) { + status = eDeliveryStatus_Success; + } else if (info.deliveryStatus.Equals(DELIVERY_STATUS_PENDING)) { + status = eDeliveryStatus_Pending; + } else if (info.deliveryStatus.Equals(DELIVERY_STATUS_ERROR)) { + status = eDeliveryStatus_Error; + } else if (info.deliveryStatus.Equals(DELIVERY_STATUS_REJECTED)) { + status = eDeliveryStatus_Reject; + } else if (info.deliveryStatus.Equals(DELIVERY_STATUS_MANUAL)) { + status = eDeliveryStatus_Manual; + } else { + return false; + } + infoData.deliveryStatus() = status; + aData.deliveryInfo().AppendElement(infoData); + } + aData.attachments().SetCapacity(mAttachments.Length()); for (uint32_t i = 0; i < mAttachments.Length(); i++) { MmsAttachmentData mma; @@ -373,51 +416,62 @@ MmsMessage::GetDelivery(nsAString& aDelivery) } NS_IMETHODIMP -MmsMessage::GetDeliveryStatus(JSContext* aCx, JS::Value* aDeliveryStatus) +MmsMessage::GetDeliveryInfo(JSContext* aCx, JS::Value* aDeliveryInfo) { // TODO Bug 850525 It'd be better to depend on the delivery of MmsMessage // to return a more correct value. Ex, if .delivery = 'received', we should - // also make .deliveryStatus = null, since the .deliveryStatus is useless. - uint32_t length = mDeliveryStatus.Length(); + // also make .deliveryInfo = null, since the .deliveryInfo is useless. + uint32_t length = mDeliveryInfo.Length(); if (length == 0) { - *aDeliveryStatus = JSVAL_NULL; + *aDeliveryInfo = JSVAL_NULL; return NS_OK; } - nsTArray tempStrArray; + JS::Rooted deliveryInfo( + aCx, JS_NewArrayObject(aCx, length, nullptr)); + NS_ENSURE_TRUE(deliveryInfo, NS_ERROR_OUT_OF_MEMORY); + for (uint32_t i = 0; i < length; ++i) { - nsString statusStr; - switch (mDeliveryStatus[i]) { - case eDeliveryStatus_NotApplicable: - statusStr = DELIVERY_STATUS_NOT_APPLICABLE; - break; - case eDeliveryStatus_Success: - statusStr = DELIVERY_STATUS_SUCCESS; - break; - case eDeliveryStatus_Pending: - statusStr = DELIVERY_STATUS_PENDING; - break; - case eDeliveryStatus_Error: - statusStr = DELIVERY_STATUS_ERROR; - break; - case eDeliveryStatus_Reject: - statusStr = DELIVERY_STATUS_REJECTED; - break; - case eDeliveryStatus_Manual: - statusStr = DELIVERY_STATUS_MANUAL; - break; - case eDeliveryStatus_EndGuard: - default: - MOZ_CRASH("We shouldn't get any other delivery status!"); + const MmsDeliveryInfo &info = mDeliveryInfo[i]; + + JS::Rooted infoJsObj( + aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr)); + NS_ENSURE_TRUE(infoJsObj, NS_ERROR_OUT_OF_MEMORY); + + JS::Rooted tmpJsVal(aCx); + JSString* tmpJsStr; + + // Get |info.receiver|. + tmpJsStr = JS_NewUCStringCopyN(aCx, + info.receiver.get(), + info.receiver.Length()); + NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY); + + tmpJsVal.setString(tmpJsStr); + if (!JS_DefineProperty(aCx, infoJsObj, "receiver", tmpJsVal, + NULL, NULL, JSPROP_ENUMERATE)) { + return NS_ERROR_FAILURE; + } + + // Get |info.deliveryStatus|. + tmpJsStr = JS_NewUCStringCopyN(aCx, + info.deliveryStatus.get(), + info.deliveryStatus.Length()); + NS_ENSURE_TRUE(tmpJsStr, NS_ERROR_OUT_OF_MEMORY); + + tmpJsVal.setString(tmpJsStr); + if (!JS_DefineProperty(aCx, infoJsObj, "deliveryStatus", tmpJsVal, + NULL, NULL, JSPROP_ENUMERATE)) { + return NS_ERROR_FAILURE; + } + + tmpJsVal = OBJECT_TO_JSVAL(infoJsObj); + if (!JS_SetElement(aCx, deliveryInfo, i, &tmpJsVal)) { + return NS_ERROR_FAILURE; } - tempStrArray.AppendElement(statusStr); } - JS::Rooted deliveryStatusObj(aCx); - nsresult rv = nsTArrayToJSArray(aCx, tempStrArray, deliveryStatusObj.address()); - NS_ENSURE_SUCCESS(rv, rv); - - aDeliveryStatus->setObject(*deliveryStatusObj); + aDeliveryInfo->setObject(*deliveryInfo); return NS_OK; } @@ -475,13 +529,15 @@ MmsMessage::GetAttachments(JSContext* aCx, JS::Value* aAttachments) { uint32_t length = mAttachments.Length(); - JS::Rooted attachments(aCx, JS_NewArrayObject(aCx, length, nullptr)); + JS::Rooted attachments( + aCx, JS_NewArrayObject(aCx, length, nullptr)); NS_ENSURE_TRUE(attachments, NS_ERROR_OUT_OF_MEMORY); for (uint32_t i = 0; i < length; ++i) { const MmsAttachment &attachment = mAttachments[i]; - JS::Rooted attachmentObj(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr)); + JS::Rooted attachmentObj( + aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr)); NS_ENSURE_TRUE(attachmentObj, NS_ERROR_OUT_OF_MEMORY); JS::Rooted tmpJsVal(aCx); diff --git a/dom/mobilemessage/src/MmsMessage.h b/dom/mobilemessage/src/MmsMessage.h index d41cb4d9af14..7ee5706ae5bf 100644 --- a/dom/mobilemessage/src/MmsMessage.h +++ b/dom/mobilemessage/src/MmsMessage.h @@ -30,7 +30,7 @@ public: MmsMessage(int32_t aId, const uint64_t aThreadId, mobilemessage::DeliveryState aDelivery, - const nsTArray& aDeliveryStatus, + const nsTArray& aDeliveryInfo, const nsAString& aSender, const nsTArray& aReceivers, uint64_t aTimestamp, @@ -45,7 +45,7 @@ public: static nsresult Create(int32_t aId, const uint64_t aThreadId, const nsAString& aDelivery, - const JS::Value& aDeliveryStatus, + const JS::Value& aDeliveryInfo, const nsAString& aSender, const JS::Value& aReceivers, const JS::Value& aTimestamp, @@ -65,7 +65,7 @@ private: int32_t mId; uint64_t mThreadId; mobilemessage::DeliveryState mDelivery; - nsTArray mDeliveryStatus; + nsTArray mDeliveryInfo; nsString mSender; nsTArray mReceivers; uint64_t mTimestamp; diff --git a/dom/mobilemessage/src/MobileMessageService.cpp b/dom/mobilemessage/src/MobileMessageService.cpp index 8b66a3732123..0e242ee08763 100644 --- a/dom/mobilemessage/src/MobileMessageService.cpp +++ b/dom/mobilemessage/src/MobileMessageService.cpp @@ -60,7 +60,7 @@ NS_IMETHODIMP MobileMessageService::CreateMmsMessage(int32_t aId, uint64_t aThreadId, const nsAString& aDelivery, - const JS::Value& aDeliveryStatus, + const JS::Value& aDeliveryInfo, const nsAString& aSender, const JS::Value& aReceivers, const JS::Value& aTimestamp, @@ -75,7 +75,7 @@ MobileMessageService::CreateMmsMessage(int32_t aId, return MmsMessage::Create(aId, aThreadId, aDelivery, - aDeliveryStatus, + aDeliveryInfo, aSender, aReceivers, aTimestamp, diff --git a/dom/mobilemessage/src/gonk/MmsService.js b/dom/mobilemessage/src/gonk/MmsService.js index 53b93a0cec4d..97154b76c3f8 100644 --- a/dom/mobilemessage/src/gonk/MmsService.js +++ b/dom/mobilemessage/src/gonk/MmsService.js @@ -1321,22 +1321,26 @@ MmsService.prototype = { retrievalMode) { intermediate.type = "mms"; intermediate.delivery = DELIVERY_NOT_DOWNLOADED; + // As a receiver, we don't need to care about the delivery status of others. + let deliveryInfo = intermediate.deliveryInfo = [{ + receiver: this.getPhoneNumber(), + deliveryStatus: DELIVERY_STATUS_NOT_APPLICABLE }]; - switch(retrievalMode) { + switch (retrievalMode) { case RETRIEVAL_MODE_MANUAL: - intermediate.deliveryStatus = [DELIVERY_STATUS_MANUAL]; + deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_MANUAL; break; case RETRIEVAL_MODE_NEVER: - intermediate.deliveryStatus = [DELIVERY_STATUS_REJECTED]; + deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_REJECTED; break; case RETRIEVAL_MODE_AUTOMATIC: - intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING]; + deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_PENDING; break; case RETRIEVAL_MODE_AUTOMATIC_HOME: if (gMmsConnection.isVoiceRoaming()) { - intermediate.deliveryStatus = [DELIVERY_STATUS_MANUAL]; + deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_MANUAL; } else { - intermediate.deliveryStatus = [DELIVERY_STATUS_PENDING]; + deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_PENDING; } break; } @@ -1377,7 +1381,7 @@ MmsService.prototype = { if (intermediate.headers[type]) { if (intermediate.headers[type] instanceof Array) { for (let index in intermediate.headers[type]) { - savable.receivers.push(intermediate.headers[type][index].address) + savable.receivers.push(intermediate.headers[type][index].address); } } else { savable.receivers.push(intermediate.headers[type].address); @@ -1386,7 +1390,10 @@ MmsService.prototype = { } savable.delivery = DELIVERY_RECEIVED; - savable.deliveryStatus = [DELIVERY_STATUS_SUCCESS]; + // As a receiver, we don't need to care about the delivery status of others. + savable.deliveryInfo = [{ + receiver: this.getPhoneNumber(), + deliveryStatus: DELIVERY_STATUS_SUCCESS }]; for (let field in intermediate.headers) { savable.headers[field] = intermediate.headers[field]; } @@ -1436,7 +1443,7 @@ MmsService.prototype = { id: aDomMessage.id, threadId: aDomMessage.threadId, delivery: aDomMessage.delivery, - deliveryStatus: aDomMessage.deliveryStatus, + deliveryInfo: aDomMessage.deliveryInfo, sender: aDomMessage.sender, receivers: aDomMessage.receivers, timestamp: aDomMessage.timestamp, diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index 1535fada5cef..77a9d5089e48 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -24,7 +24,7 @@ const DISABLE_MMS_GROUPING_FOR_RECEIVING = true; const DB_NAME = "sms"; -const DB_VERSION = 12; +const DB_VERSION = 13; const MESSAGE_STORE_NAME = "sms"; const THREAD_STORE_NAME = "thread"; const PARTICIPANT_STORE_NAME = "participant"; @@ -218,6 +218,10 @@ MobileMessageDatabaseService.prototype = { self.upgradeSchema11(event.target.transaction, next); break; case 12: + if (DEBUG) debug("Upgrade to version 13. Replaced deliveryStatus by deliveryInfo."); + self.upgradeSchema12(event.target.transaction, next); + break; + case 13: // This will need to be moved for each new version if (DEBUG) debug("Upgrade finished."); break; @@ -322,8 +326,8 @@ MobileMessageDatabaseService.prototype = { messageRecord.deliveryStatus = DELIVERY_STATUS_ERROR; } else { // Set delivery status to error. - for (let i = 0; i < messageRecord.deliveryStatus.length; i++) { - messageRecord.deliveryStatus[i] = DELIVERY_STATUS_ERROR; + for (let i = 0; i < messageRecord.deliveryInfo.length; i++) { + messageRecord.deliveryInfo[i].deliveryStatus = DELIVERY_STATUS_ERROR; } } @@ -350,9 +354,10 @@ MobileMessageDatabaseService.prototype = { } // Set delivery status to error. - if (messageRecord.deliveryStatus.length == 1 && - messageRecord.deliveryStatus[0] == DELIVERY_STATUS_PENDING) { - messageRecord.deliveryStatus = [DELIVERY_STATUS_ERROR]; + let deliveryInfo = messageRecord.deliveryInfo; + if (deliveryInfo.length == 1 && + deliveryInfo[0].deliveryStatus == DELIVERY_STATUS_PENDING) { + deliveryInfo[0].deliveryStatus = DELIVERY_STATUS_ERROR; } messageCursor.update(messageRecord); @@ -793,6 +798,43 @@ MobileMessageDatabaseService.prototype = { }; }, + /** + * Replace deliveryStatus by deliveryInfo. + */ + upgradeSchema12: function upgradeSchema12(transaction, next) { + let messageStore = transaction.objectStore(MESSAGE_STORE_NAME); + + messageStore.openCursor().onsuccess = function(event) { + let cursor = event.target.result; + if (!cursor) { + next(); + return; + } + + let messageRecord = cursor.value; + if (messageRecord.type == "mms") { + messageRecord.deliveryInfo = []; + + if (messageRecord.deliveryStatus.length == 1 && + (messageRecord.delivery == DELIVERY_NOT_DOWNLOADED || + messageRecord.delivery == DELIVERY_RECEIVED)) { + messageRecord.deliveryInfo.push({ + receiver: null, + deliveryStatus: messageRecord.deliveryStatus[0] }); + } else { + for (let i = 0; i < messageRecord.deliveryStatus.length; i++) { + messageRecord.deliveryInfo.push({ + receiver: messageRecord.receivers[i], + deliveryStatus: messageRecord.deliveryStatus[i] }); + } + } + delete messageRecord.deliveryStatus; + cursor.update(messageRecord); + } + cursor.continue(); + }; + }, + createDomMessageFromRecord: function createDomMessageFromRecord(aMessageRecord) { if (DEBUG) { debug("createDomMessageFromRecord: " + JSON.stringify(aMessageRecord)); @@ -855,7 +897,7 @@ MobileMessageDatabaseService.prototype = { return gMobileMessageService.createMmsMessage(aMessageRecord.id, aMessageRecord.threadId, aMessageRecord.delivery, - aMessageRecord.deliveryStatus, + aMessageRecord.deliveryInfo, aMessageRecord.sender, aMessageRecord.receivers, aMessageRecord.timestamp, @@ -1246,9 +1288,10 @@ MobileMessageDatabaseService.prototype = { } } else if (messageRecord.type == "mms") { if (!receiver) { - for (let i = 0; i < messageRecord.deliveryStatus.length; i++) { - if (messageRecord.deliveryStatus[i] != deliveryStatus) { - messageRecord.deliveryStatus[i] = deliveryStatus; + let deliveryInfo = messageRecord.deliveryInfo; + for (let i = 0; i < deliveryInfo.length; i++) { + if (deliveryInfo[i].deliveryStatus != deliveryStatus) { + deliveryInfo[i].deliveryStatus = deliveryStatus; isRecordUpdated = true; } } @@ -1296,9 +1339,15 @@ MobileMessageDatabaseService.prototype = { } found = true; - if (messageRecord.deliveryStatus[i] != deliveryStatus) { - messageRecord.deliveryStatus[i] = deliveryStatus; - isRecordUpdated = true; + let deliveryInfo = messageRecord.deliveryInfo; + for (let j = 0; j < deliveryInfo.length; j++) { + if (deliveryInfo[j].receiver != storedReceiver) { + continue; + } + if (deliveryInfo[j].deliveryStatus != deliveryStatus) { + deliveryInfo[j].deliveryStatus = deliveryStatus; + isRecordUpdated = true; + } } } @@ -1345,7 +1394,7 @@ MobileMessageDatabaseService.prototype = { (aMessage.type == "sms" && aMessage.messageClass == undefined) || (aMessage.type == "mms" && (aMessage.delivery == undefined || aMessage.transactionId == undefined || - !Array.isArray(aMessage.deliveryStatus) || + !Array.isArray(aMessage.deliveryInfo) || !Array.isArray(aMessage.receivers))) || aMessage.sender == undefined || aMessage.timestamp == undefined) { @@ -1443,9 +1492,10 @@ MobileMessageDatabaseService.prototype = { } return; } - aMessage.deliveryStatus = []; + aMessage.deliveryInfo = []; for (let i = 0; i < receivers.length; i++) { - aMessage.deliveryStatus.push(deliveryStatus); + aMessage.deliveryInfo.push({ + receiver: receivers[i], deliveryStatus: deliveryStatus }); } } diff --git a/dom/mobilemessage/src/ipc/SmsTypes.ipdlh b/dom/mobilemessage/src/ipc/SmsTypes.ipdlh index b0f17cc79613..fa87cfdfe2aa 100644 --- a/dom/mobilemessage/src/ipc/SmsTypes.ipdlh +++ b/dom/mobilemessage/src/ipc/SmsTypes.ipdlh @@ -45,20 +45,26 @@ struct MmsAttachmentData PBlob content; }; +struct MmsDeliveryInfoData +{ + nsString receiver; + DeliveryStatus deliveryStatus; +}; + struct MmsMessageData { - int32_t id; - uint64_t threadId; - DeliveryState delivery; - DeliveryStatus[] deliveryStatus; - nsString sender; - nsString[] receivers; - uint64_t timestamp; - bool read; - nsString subject; - nsString smil; - MmsAttachmentData[] attachments; - uint64_t expiryDate; + int32_t id; + uint64_t threadId; + DeliveryState delivery; + MmsDeliveryInfoData[] deliveryInfo; + nsString sender; + nsString[] receivers; + uint64_t timestamp; + bool read; + nsString subject; + nsString smil; + MmsAttachmentData[] attachments; + uint64_t expiryDate; }; union MobileMessageData From c62a5fcbe195031a362d0feb1c5bc9093ae06125 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:50 -0400 Subject: [PATCH 350/795] Bug 814625 - Part 1: WebIDL: Code reorder. r=hsinyi, r=khuey --- dom/webidl/Telephony.webidl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dom/webidl/Telephony.webidl b/dom/webidl/Telephony.webidl index cf25b2d3a0d7..d5189558b250 100644 --- a/dom/webidl/Telephony.webidl +++ b/dom/webidl/Telephony.webidl @@ -8,11 +8,19 @@ interface Telephony : EventTarget { [Throws] TelephonyCall dial(DOMString number); + [Throws] TelephonyCall dialEmergency(DOMString number); + [Throws] + void startTone(DOMString tone); + + [Throws] + void stopTone(); + [Throws] attribute boolean muted; + [Throws] attribute boolean speakerEnabled; @@ -22,11 +30,6 @@ interface Telephony : EventTarget { readonly attribute CallsList calls; readonly attribute TelephonyCallGroup conferenceGroup; - [Throws] - void startTone(DOMString tone); - [Throws] - void stopTone(); - attribute EventHandler onincoming; attribute EventHandler oncallschanged; attribute EventHandler onremoteheld; From b4627dd4592ed8b5e53ed3f34a35854cb6769467 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:50 -0400 Subject: [PATCH 351/795] Bug 814625 - Part 2: WebIDL: Add multisim support. r=hsinyi, r=khuey --- dom/webidl/Telephony.webidl | 20 +++++++++++++++----- dom/webidl/TelephonyCall.webidl | 3 +++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dom/webidl/Telephony.webidl b/dom/webidl/Telephony.webidl index d5189558b250..2d4ae7b7d951 100644 --- a/dom/webidl/Telephony.webidl +++ b/dom/webidl/Telephony.webidl @@ -6,17 +6,27 @@ [Pref="dom.telephony.enabled"] interface Telephony : EventTarget { - [Throws] - TelephonyCall dial(DOMString number); + /** + * There are multiple telephony services in multi-sim architecture. We use + * |serviceId| to indicate the target telephony service. If not specified, + * the implementation MUST use the default service. + * + * Possible values of |serviceId| are 0 ~ (number of services - 1), which is + * simply the index of a service. Get number of services by acquiring + * |navigator.mozMobileConnections.length|. + */ [Throws] - TelephonyCall dialEmergency(DOMString number); + TelephonyCall dial(DOMString number, optional unsigned long serviceId); [Throws] - void startTone(DOMString tone); + TelephonyCall dialEmergency(DOMString number, optional unsigned long serviceId); [Throws] - void stopTone(); + void startTone(DOMString tone, optional unsigned long serviceId); + + [Throws] + void stopTone(optional unsigned long serviceId); [Throws] attribute boolean muted; diff --git a/dom/webidl/TelephonyCall.webidl b/dom/webidl/TelephonyCall.webidl index f96c734b4adc..3a83404d6c3c 100644 --- a/dom/webidl/TelephonyCall.webidl +++ b/dom/webidl/TelephonyCall.webidl @@ -6,6 +6,9 @@ [Pref="dom.telephony.enabled"] interface TelephonyCall : EventTarget { + // Indicate which service the call comes from. + readonly attribute unsigned long serviceId; + readonly attribute DOMString number; // In CDMA networks, the 2nd waiting call shares the connection with the 1st From b9396ba2d7ea7e185318bf8be8693304c5fa8495 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:51 -0400 Subject: [PATCH 352/795] Bug 814625 - Part 3: DOM: Code reorder. r=khuey --- dom/telephony/Telephony.cpp | 96 ++++++++++++++++++------------------- dom/telephony/Telephony.h | 28 +++++------ 2 files changed, 62 insertions(+), 62 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 5d1a050e589c..759de5341616 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -175,32 +175,6 @@ Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv) return telephony.forget(); } -already_AddRefed -Telephony::CreateNewDialingCall(const nsAString& aNumber) -{ - nsRefPtr call = - TelephonyCall::Create(this, aNumber, - nsITelephonyProvider::CALL_STATE_DIALING); - NS_ASSERTION(call, "This should never fail!"); - - NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); - - return call.forget(); -} - -void -Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) -{ - // We don't need to hang on to this call object, it is held alive by mCalls. - nsRefPtr call = CreateNewDialingCall(aNumber); -} - -nsresult -Telephony::NotifyCallsChanged(TelephonyCall* aCall) -{ - return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall); -} - already_AddRefed Telephony::DialInternal(bool isEmergency, const nsAString& aNumber, @@ -243,6 +217,32 @@ Telephony::DialInternal(bool isEmergency, return call.forget(); } +already_AddRefed +Telephony::CreateNewDialingCall(const nsAString& aNumber) +{ + nsRefPtr call = + TelephonyCall::Create(this, aNumber, + nsITelephonyProvider::CALL_STATE_DIALING); + NS_ASSERTION(call, "This should never fail!"); + + NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); + + return call.forget(); +} + +void +Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) +{ + // We don't need to hang on to this call object, it is held alive by mCalls. + nsRefPtr call = CreateNewDialingCall(aNumber); +} + +nsresult +Telephony::NotifyCallsChanged(TelephonyCall* aCall) +{ + return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall); +} + void Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding) { @@ -344,6 +344,28 @@ Telephony::DialEmergency(const nsAString& aNumber, ErrorResult& aRv) return call.forget(); } +void +Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) +{ + if (aDTMFChar.IsEmpty()) { + NS_WARNING("Empty tone string will be ignored"); + return; + } + + if (aDTMFChar.Length() > 1) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return; + } + + aRv = mProvider->StartTone(aDTMFChar); +} + +void +Telephony::StopTone(ErrorResult& aRv) +{ + aRv = mProvider->StopTone(); +} + bool Telephony::GetMuted(ErrorResult& aRv) const { @@ -400,28 +422,6 @@ Telephony::ConferenceGroup() const return group.forget(); } -void -Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) -{ - if (aDTMFChar.IsEmpty()) { - NS_WARNING("Empty tone string will be ignored"); - return; - } - - if (aDTMFChar.Length() > 1) { - aRv.Throw(NS_ERROR_INVALID_ARG); - return; - } - - aRv = mProvider->StartTone(aDTMFChar); -} - -void -Telephony::StopTone(ErrorResult& aRv) -{ - aRv = mProvider->StopTone(); -} - // EventTarget void diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 9ca43da6eab3..28b1b8df4cad 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -71,6 +71,12 @@ public: already_AddRefed DialEmergency(const nsAString& aNumber, ErrorResult& aRv); + void + StartTone(const nsAString& aDTMF, ErrorResult& aRv); + + void + StopTone(ErrorResult& aRv); + bool GetMuted(ErrorResult& aRv) const; @@ -92,12 +98,6 @@ public: already_AddRefed ConferenceGroup() const; - void - StartTone(const nsAString& aDTMF, ErrorResult& aRv); - - void - StopTone(ErrorResult& aRv); - IMPL_EVENT_HANDLER(incoming) IMPL_EVENT_HANDLER(callschanged) IMPL_EVENT_HANDLER(remoteheld) @@ -142,6 +142,14 @@ private: Telephony(); ~Telephony(); + void + Shutdown(); + + already_AddRefed + DialInternal(bool isEmergency, + const nsAString& aNumber, + ErrorResult& aRv); + already_AddRefed CreateNewDialingCall(const nsAString& aNumber); @@ -151,11 +159,6 @@ private: nsresult NotifyCallsChanged(TelephonyCall* aCall); - already_AddRefed - DialInternal(bool isEmergency, - const nsAString& aNumber, - ErrorResult& aRv); - nsresult DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall); @@ -171,9 +174,6 @@ private: bool MoveCall(uint32_t aCallIndex, bool aIsConference); - - void - Shutdown(); }; } // namespace dom From 7a698c9040d1456a2eeee2217bcd1f566ccbf7bd Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:51 -0400 Subject: [PATCH 353/795] Bug 814625 - Part 4: DOM: Refactor. r=khuey --- dom/telephony/Telephony.cpp | 274 ++++++++++++++++-------------------- dom/telephony/Telephony.h | 26 +++- 2 files changed, 144 insertions(+), 156 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 759de5341616..2f52d94cbcec 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -175,26 +175,58 @@ Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv) return telephony.forget(); } +// static +bool +Telephony::IsValidNumber(const nsAString& aNumber) +{ + return !aNumber.IsEmpty(); +} + +// static +bool +Telephony::IsActiveState(uint16_t aCallState) { + return aCallState == nsITelephonyProvider::CALL_STATE_DIALING || + aCallState == nsITelephonyProvider::CALL_STATE_ALERTING || + aCallState == nsITelephonyProvider::CALL_STATE_CONNECTED; +} + +bool +Telephony::HasDialingCall() +{ + for (uint32_t i = 0; i < mCalls.Length(); i++) { + const nsRefPtr& call = mCalls[i]; + if (call->IsOutgoing() && + call->CallState() > nsITelephonyProvider::CALL_STATE_UNKNOWN && + call->CallState() < nsITelephonyProvider::CALL_STATE_CONNECTED) { + return true; + } + } + + return false; +} + +bool +Telephony::MatchActiveCall(TelephonyCall* aCall) +{ + return (mActiveCall && + mActiveCall->CallIndex() == aCall->CallIndex()); +} + already_AddRefed Telephony::DialInternal(bool isEmergency, const nsAString& aNumber, ErrorResult& aRv) { - if (aNumber.IsEmpty()) { + if (!IsValidNumber(aNumber)) { aRv.Throw(NS_ERROR_INVALID_ARG); return nullptr; } - for (uint32_t index = 0; index < mCalls.Length(); index++) { - const nsRefPtr& tempCall = mCalls[index]; - if (tempCall->IsOutgoing() && - tempCall->CallState() < nsITelephonyProvider::CALL_STATE_CONNECTED) { - // One call has been dialed already and we only support one outgoing call - // at a time. - NS_WARNING("Only permitted to dial one call at a time!"); - aRv.Throw(NS_ERROR_NOT_AVAILABLE); - return nullptr; - } + // We only support one outgoing call at a time. + if (HasDialingCall()) { + NS_WARNING("Only permitted to dial one call at a time!"); + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return nullptr; } nsresult rv = mProvider->Dial(aNumber, isEmergency); @@ -206,8 +238,8 @@ Telephony::DialInternal(bool isEmergency, nsRefPtr call = CreateNewDialingCall(aNumber); // Notify other telephony objects that we just dialed. - for (uint32_t index = 0; index < gTelephonyList->Length(); index++) { - Telephony*& telephony = gTelephonyList->ElementAt(index); + for (uint32_t i = 0; i < gTelephonyList->Length(); i++) { + Telephony*& telephony = gTelephonyList->ElementAt(i); if (telephony != this) { nsRefPtr kungFuDeathGrip = telephony; telephony->NoteDialedCallFromOtherInstance(aNumber); @@ -244,16 +276,11 @@ Telephony::NotifyCallsChanged(TelephonyCall* aCall) } void -Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding) +Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsActive) { - if (aIsAdding) { - if (aCall->CallState() == nsITelephonyProvider::CALL_STATE_DIALING || - aCall->CallState() == nsITelephonyProvider::CALL_STATE_ALERTING || - aCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED) { - NS_ASSERTION(!mActiveCall, "Already have an active call!"); - mActiveCall = aCall; - } - } else if (mActiveCall && mActiveCall->CallIndex() == aCall->CallIndex()) { + if (aIsActive) { + mActiveCall = aCall; + } else if (MatchActiveCall(aCall)) { mActiveCall = nullptr; } } @@ -274,32 +301,36 @@ Telephony::GetCall(uint32_t aCallIndex) return call.forget(); } -bool -Telephony::MoveCall(uint32_t aCallIndex, bool aIsConference) +already_AddRefed +Telephony::GetOutgoingCall() { nsRefPtr call; - // Move a call to mGroup. - if (aIsConference) { - call = GetCall(aCallIndex); - if (call) { - RemoveCall(call); - mGroup->AddCall(call); - return true; + for (uint32_t i = 0; i < mCalls.Length(); i++) { + nsRefPtr& tempCall = mCalls[i]; + if (tempCall->CallIndex() == kOutgoingPlaceholderCallIndex) { + NS_ASSERTION(!call, "More than one outgoing call not supported!"); + NS_ASSERTION(tempCall->CallState() == nsITelephonyProvider::CALL_STATE_DIALING, + "Something really wrong here!"); + + call = tempCall; + // No break. We will search entire list to ensure only one outgoing call. } - - return false; } - // Remove a call from mGroup. - call = mGroup->GetCall(aCallIndex); - if (call) { - mGroup->RemoveCall(call); - AddCall(call); - return true; + return call.forget(); +} + +already_AddRefed +Telephony::GetCallFromEverywhere(uint32_t aCallIndex) +{ + nsRefPtr call = GetCall(aCallIndex); + + if (!call) { + call = mGroup->GetCall(aCallIndex); } - return false; + return call.forget(); } NS_IMPL_CYCLE_COLLECTION_CLASS(Telephony) @@ -444,116 +475,70 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, NS_ASSERTION(aCallIndex != kOutgoingPlaceholderCallIndex, "This should never happen!"); - nsRefPtr modifiedCall; - nsRefPtr outgoingCall; + nsRefPtr modifiedCall + = GetCallFromEverywhere(aCallIndex); - // Update calls array first then state of a call in mCalls. + // Try to use the outgoing call if we don't find the modified call. + if (!modifiedCall) { + nsRefPtr outgoingCall = GetOutgoingCall(); - if (aIsConference) { - // Add the call into mGroup if it hasn't been there, otherwise we simply - // update its call state. We don't fire the statechange event on a call in - // conference here. Instead, the event will be fired later in - // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the - // statechange events is guaranteed: first on TelephonyCallGroup then on - // individual TelephonyCall objects. + // If the call state isn't incoming but we do have an outgoing call then + // we must be seeing a status update for our outgoing call. + if (outgoingCall && + aCallState != nsITelephonyProvider::CALL_STATE_INCOMING) { + outgoingCall->UpdateCallIndex(aCallIndex); + outgoingCall->UpdateEmergency(aIsEmergency); + modifiedCall.swap(outgoingCall); + } + } - modifiedCall = mGroup->GetCall(aCallIndex); - if (modifiedCall) { - modifiedCall->ChangeStateInternal(aCallState, false); - return NS_OK; + if (modifiedCall) { + if (!aIsConference) { + UpdateActiveCall(modifiedCall, aIsActive); } - // The call becomes a conference call. Remove it from Telephony::mCalls and - // add it to mGroup. - modifiedCall = GetCall(aCallIndex); - if (modifiedCall) { - modifiedCall->ChangeStateInternal(aCallState, false); + if (modifiedCall->CallState() != aCallState) { + // We don't fire the statechange event on a call in conference here. + // Instead, the event will be fired later in + // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the + // statechange events is guaranteed: first on TelephonyCallGroup then on + // individual TelephonyCall objects. + bool fireEvent = !aIsConference; + modifiedCall->ChangeStateInternal(aCallState, fireEvent); + } + + nsRefPtr group = modifiedCall->GetGroup(); + + if (!group && aIsConference) { + // Add to conference. + NS_ASSERTION(mCalls.Contains(modifiedCall), "Should in mCalls"); mGroup->AddCall(modifiedCall); RemoveCall(modifiedCall); - return NS_OK; - } - - // Didn't find this call in mCalls or mGroup. Create a new call. - nsRefPtr call = - TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, - aIsEmergency, aIsConference); - NS_ASSERTION(call, "This should never fail!"); - - return NS_OK; - } - - // Not a conference call. Remove the call from mGroup if it has been there. - modifiedCall = mGroup->GetCall(aCallIndex); - if (modifiedCall) { - if (aCallState != nsITelephonyProvider::CALL_STATE_DISCONNECTED) { - if (modifiedCall->CallState() != aCallState) { - modifiedCall->ChangeState(aCallState); - } + } else if (group && !aIsConference) { + // Remove from conference. + NS_ASSERTION(mGroup->CallsArray().Contains(modifiedCall), "Should in mGroup"); mGroup->RemoveCall(modifiedCall); AddCall(modifiedCall); - } else { - modifiedCall->ChangeState(aCallState); } - return NS_OK; - } - - // Update calls in mCalls. - for (uint32_t index = 0; index < mCalls.Length(); index++) { - nsRefPtr& tempCall = mCalls[index]; - if (tempCall->CallIndex() == kOutgoingPlaceholderCallIndex) { - NS_ASSERTION(!outgoingCall, "More than one outgoing call not supported!"); - NS_ASSERTION(tempCall->CallState() == - nsITelephonyProvider::CALL_STATE_DIALING, - "Something really wrong here!"); - // Stash this for later, we may need it if aCallIndex doesn't match one of - // our other calls. - outgoingCall = tempCall; - } else if (tempCall->CallIndex() == aCallIndex) { - // We already know about this call so just update its state. - modifiedCall = tempCall; - outgoingCall = nullptr; - break; - } - } - - // If nothing matched above and the call state isn't incoming but we do have - // an outgoing call then we must be seeing a status update for our outgoing - // call. - if (!modifiedCall && - aCallState != nsITelephonyProvider::CALL_STATE_INCOMING && - outgoingCall) { - outgoingCall->UpdateCallIndex(aCallIndex); - outgoingCall->UpdateEmergency(aIsEmergency); - modifiedCall.swap(outgoingCall); - } - - if (modifiedCall) { - // See if this should replace our current active call. - if (aIsActive) { - mActiveCall = modifiedCall; - } else if (mActiveCall && mActiveCall->CallIndex() == aCallIndex) { - mActiveCall = nullptr; - } - - // Change state. - modifiedCall->ChangeState(aCallState); return NS_OK; } - // Didn't know anything about this call before now. - + // Do nothing since we didn't know anything about it before now and it's + // ended already. if (aCallState == nsITelephonyProvider::CALL_STATE_DISCONNECTED) { - // Do nothing since we didn't know anything about it before now and it's - // been ended already. return NS_OK; } + // Didn't find this call in mCalls or mGroup. Create a new call. nsRefPtr call = - TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, aIsEmergency); + TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, + aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); - NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); + NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) : + mCalls.Contains(call), + "Should have auto-added new call!"); if (aCallState == nsITelephonyProvider::CALL_STATE_INCOMING) { nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call); @@ -596,13 +581,8 @@ Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, // However, it is likely to have call state changes, i.e. CallStateChanged() // being called, before the enumeration result comes back. We'd make sure // we don't somehow add duplicates due to the race condition. - call = aIsConference ? mGroup->GetCall(aCallIndex) : GetCall(aCallIndex); + call = GetCallFromEverywhere(aCallIndex); if (call) { - // We have the call either in mCalls or in mGroup. Skip it. - return NS_OK; - } - - if (MoveCall(aCallIndex, aIsConference)) { return NS_OK; } @@ -649,28 +629,22 @@ NS_IMETHODIMP Telephony::NotifyError(int32_t aCallIndex, const nsAString& aError) { - nsRefPtr callToNotify; - if (!mCalls.IsEmpty()) { - // The connection is not established yet. Get the latest dialing call object. - if (aCallIndex == -1) { - nsRefPtr& lastCall = mCalls[mCalls.Length() - 1]; - if (lastCall->CallIndex() == kOutgoingPlaceholderCallIndex) { - callToNotify = lastCall; - } - } else { - // The connection has been established. Get the failed call. - callToNotify = GetCall(aCallIndex); - } + if (mCalls.IsEmpty()) { + NS_ERROR("No existing call!"); + return NS_ERROR_UNEXPECTED; } + nsRefPtr callToNotify; + + callToNotify = (aCallIndex == -1) ? GetOutgoingCall() + : GetCall(aCallIndex); + if (!callToNotify) { NS_ERROR("Don't call me with a bad call index!"); return NS_ERROR_UNEXPECTED; } - if (mActiveCall && mActiveCall->CallIndex() == callToNotify->CallIndex()) { - mActiveCall = nullptr; - } + UpdateActiveCall(callToNotify, false); // Set the call state to 'disconnected' and remove it from the calls list. callToNotify->NotifyError(aError); diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 28b1b8df4cad..8644a35a18b4 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -111,7 +111,7 @@ public: { NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!"); mCalls.AppendElement(aCall); - UpdateActiveCall(aCall, true); + UpdateActiveCall(aCall, IsActiveState(aCall->CallState())); NotifyCallsChanged(aCall); } @@ -145,6 +145,18 @@ private: void Shutdown(); + static bool + IsValidNumber(const nsAString& aNumber); + + static bool + IsActiveState(uint16_t aCallState); + + bool + HasDialingCall(); + + bool + MatchActiveCall(TelephonyCall* aCall); + already_AddRefed DialInternal(bool isEmergency, const nsAString& aNumber, @@ -160,20 +172,22 @@ private: NotifyCallsChanged(TelephonyCall* aCall); nsresult - DispatchCallEvent(const nsAString& aType, - TelephonyCall* aCall); + DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall); void EnqueueEnumerationAck(); void - UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding); + UpdateActiveCall(TelephonyCall* aCall, bool aIsActive); already_AddRefed GetCall(uint32_t aCallIndex); - bool - MoveCall(uint32_t aCallIndex, bool aIsConference); + already_AddRefed + GetOutgoingCall(); + + already_AddRefed + GetCallFromEverywhere(uint32_t aCallIndex); }; } // namespace dom From ee0ff1ecd54824286989e05f95c9bafa20132a3a Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:51 -0400 Subject: [PATCH 354/795] Bug 814625 - Part 5: DOM: Add multisim support. r=khuey --- dom/telephony/Telephony.cpp | 136 ++++++++++++++++++--------- dom/telephony/Telephony.h | 35 ++++--- dom/telephony/TelephonyCall.cpp | 17 ++-- dom/telephony/TelephonyCall.h | 10 +- dom/telephony/TelephonyCallGroup.cpp | 37 ++++---- dom/telephony/TelephonyCallGroup.h | 2 +- 6 files changed, 155 insertions(+), 82 deletions(-) diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 2f52d94cbcec..5455748df9ad 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -12,6 +12,7 @@ #include "nsIPermissionManager.h" #include "mozilla/dom/UnionTypes.h" +#include "mozilla/Preferences.h" #include "nsCharSeparatedTokenizer.h" #include "nsContentUtils.h" #include "nsCxPusher.h" @@ -182,6 +183,19 @@ Telephony::IsValidNumber(const nsAString& aNumber) return !aNumber.IsEmpty(); } +// static +uint32_t +Telephony::GetNumServices() { + return mozilla::Preferences::GetInt("ril.numRadioInterfaces", 1); +} + +// static +bool +Telephony::IsValidServiceId(uint32_t aServiceId) +{ + return aServiceId < GetNumServices(); +} + // static bool Telephony::IsActiveState(uint16_t aCallState) { @@ -190,6 +204,18 @@ Telephony::IsActiveState(uint16_t aCallState) { aCallState == nsITelephonyProvider::CALL_STATE_CONNECTED; } +uint32_t +Telephony::ProvidedOrDefaultServiceId(const Optional& aServiceId) +{ + if (aServiceId.WasPassed()) { + return aServiceId.Value(); + } else { + uint32_t serviceId = 0; + mProvider->GetDefaultServiceId(&serviceId); + return serviceId; + } +} + bool Telephony::HasDialingCall() { @@ -209,15 +235,15 @@ bool Telephony::MatchActiveCall(TelephonyCall* aCall) { return (mActiveCall && - mActiveCall->CallIndex() == aCall->CallIndex()); + mActiveCall->CallIndex() == aCall->CallIndex() && + mActiveCall->ServiceId() == aCall->ServiceId()); } already_AddRefed -Telephony::DialInternal(bool isEmergency, - const nsAString& aNumber, - ErrorResult& aRv) +Telephony::DialInternal(uint32_t aServiceId, const nsAString& aNumber, + bool aIsEmergency, ErrorResult& aRv) { - if (!IsValidNumber(aNumber)) { + if (!IsValidNumber(aNumber) || !IsValidServiceId(aServiceId)) { aRv.Throw(NS_ERROR_INVALID_ARG); return nullptr; } @@ -229,20 +255,20 @@ Telephony::DialInternal(bool isEmergency, return nullptr; } - nsresult rv = mProvider->Dial(aNumber, isEmergency); + nsresult rv = mProvider->Dial(aServiceId, aNumber, aIsEmergency); if (NS_FAILED(rv)) { aRv.Throw(rv); return nullptr; } - nsRefPtr call = CreateNewDialingCall(aNumber); + nsRefPtr call = CreateNewDialingCall(aServiceId, aNumber); // Notify other telephony objects that we just dialed. for (uint32_t i = 0; i < gTelephonyList->Length(); i++) { Telephony*& telephony = gTelephonyList->ElementAt(i); if (telephony != this) { nsRefPtr kungFuDeathGrip = telephony; - telephony->NoteDialedCallFromOtherInstance(aNumber); + telephony->NoteDialedCallFromOtherInstance(aServiceId, aNumber); } } @@ -250,10 +276,10 @@ Telephony::DialInternal(bool isEmergency, } already_AddRefed -Telephony::CreateNewDialingCall(const nsAString& aNumber) +Telephony::CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber) { nsRefPtr call = - TelephonyCall::Create(this, aNumber, + TelephonyCall::Create(this, aServiceId, aNumber, nsITelephonyProvider::CALL_STATE_DIALING); NS_ASSERTION(call, "This should never fail!"); @@ -263,10 +289,11 @@ Telephony::CreateNewDialingCall(const nsAString& aNumber) } void -Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) +Telephony::NoteDialedCallFromOtherInstance(uint32_t aServiceId, + const nsAString& aNumber) { // We don't need to hang on to this call object, it is held alive by mCalls. - nsRefPtr call = CreateNewDialingCall(aNumber); + nsRefPtr call = CreateNewDialingCall(aServiceId, aNumber); } nsresult @@ -286,13 +313,14 @@ Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsActive) } already_AddRefed -Telephony::GetCall(uint32_t aCallIndex) +Telephony::GetCall(uint32_t aServiceId, uint32_t aCallIndex) { nsRefPtr call; - for (uint32_t index = 0; index < mCalls.Length(); index++) { - nsRefPtr& tempCall = mCalls[index]; - if (tempCall->CallIndex() == aCallIndex) { + for (uint32_t i = 0; i < mCalls.Length(); i++) { + nsRefPtr& tempCall = mCalls[i]; + if (tempCall->ServiceId() == aServiceId && + tempCall->CallIndex() == aCallIndex) { call = tempCall; break; } @@ -322,12 +350,12 @@ Telephony::GetOutgoingCall() } already_AddRefed -Telephony::GetCallFromEverywhere(uint32_t aCallIndex) +Telephony::GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex) { - nsRefPtr call = GetCall(aCallIndex); + nsRefPtr call = GetCall(aServiceId, aCallIndex); if (!call) { - call = mGroup->GetCall(aCallIndex); + call = mGroup->GetCall(aServiceId, aCallIndex); } return call.forget(); @@ -362,39 +390,55 @@ NS_IMPL_ISUPPORTS1(Telephony::Listener, nsITelephonyListener) // Telephony WebIDL already_AddRefed -Telephony::Dial(const nsAString& aNumber, ErrorResult& aRv) +Telephony::Dial(const nsAString& aNumber, const Optional& aServiceId, + ErrorResult& aRv) { - nsRefPtr call = DialInternal(false, aNumber, aRv); + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + nsRefPtr call = DialInternal(serviceId, aNumber, false, aRv); return call.forget(); } already_AddRefed -Telephony::DialEmergency(const nsAString& aNumber, ErrorResult& aRv) +Telephony::DialEmergency(const nsAString& aNumber, + const Optional& aServiceId, + ErrorResult& aRv) { - nsRefPtr call = DialInternal(true, aNumber, aRv); + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + nsRefPtr call = DialInternal(serviceId, aNumber, true, aRv); return call.forget(); } void -Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) +Telephony::StartTone(const nsAString& aDTMFChar, + const Optional& aServiceId, + ErrorResult& aRv) { + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + if (aDTMFChar.IsEmpty()) { NS_WARNING("Empty tone string will be ignored"); return; } - if (aDTMFChar.Length() > 1) { + if (aDTMFChar.Length() > 1 || !IsValidServiceId(serviceId)) { aRv.Throw(NS_ERROR_INVALID_ARG); return; } - aRv = mProvider->StartTone(aDTMFChar); + aRv = mProvider->StartTone(serviceId, aDTMFChar); } void -Telephony::StopTone(ErrorResult& aRv) +Telephony::StopTone(const Optional& aServiceId, ErrorResult& aRv) { - aRv = mProvider->StopTone(); + uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); + + if (!IsValidServiceId(serviceId)) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return; + } + + aRv = mProvider->StopTone(serviceId); } bool @@ -467,16 +511,16 @@ Telephony::EventListenerAdded(nsIAtom* aType) // nsITelephonyListener NS_IMETHODIMP -Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, - const nsAString& aNumber, bool aIsActive, - bool aIsOutgoing, bool aIsEmergency, +Telephony::CallStateChanged(uint32_t aServiceId, uint32_t aCallIndex, + uint16_t aCallState, const nsAString& aNumber, + bool aIsActive, bool aIsOutgoing, bool aIsEmergency, bool aIsConference) { NS_ASSERTION(aCallIndex != kOutgoingPlaceholderCallIndex, "This should never happen!"); nsRefPtr modifiedCall - = GetCallFromEverywhere(aCallIndex); + = GetCallFromEverywhere(aServiceId, aCallIndex); // Try to use the outgoing call if we don't find the modified call. if (!modifiedCall) { @@ -532,7 +576,7 @@ Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, // Didn't find this call in mCalls or mGroup. Create a new call. nsRefPtr call = - TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, + TelephonyCall::Create(this, aServiceId, aNumber, aCallState, aCallIndex, aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); @@ -569,9 +613,9 @@ Telephony::EnumerateCallStateComplete() } NS_IMETHODIMP -Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, - const nsAString& aNumber, bool aIsActive, - bool aIsOutgoing, bool aIsEmergency, +Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex, + uint16_t aCallState, const nsAString& aNumber, + bool aIsActive, bool aIsOutgoing, bool aIsEmergency, bool aIsConference) { nsRefPtr call; @@ -581,15 +625,14 @@ Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, // However, it is likely to have call state changes, i.e. CallStateChanged() // being called, before the enumeration result comes back. We'd make sure // we don't somehow add duplicates due to the race condition. - call = GetCallFromEverywhere(aCallIndex); + call = GetCallFromEverywhere(aServiceId, aCallIndex); if (call) { return NS_OK; } // Didn't know anything about this call before now. - - call = TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, - aIsEmergency, aIsConference); + call = TelephonyCall::Create(this, aServiceId, aNumber, aCallState, + aCallIndex, aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) : @@ -600,12 +643,13 @@ Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, } NS_IMETHODIMP -Telephony::SupplementaryServiceNotification(int32_t aCallIndex, +Telephony::SupplementaryServiceNotification(uint32_t aServiceId, + int32_t aCallIndex, uint16_t aNotification) { nsRefPtr associatedCall; if (!mCalls.IsEmpty() && aCallIndex != -1) { - associatedCall = GetCall(aCallIndex); + associatedCall = GetCall(aServiceId, aCallIndex); } nsresult rv; @@ -626,7 +670,8 @@ Telephony::SupplementaryServiceNotification(int32_t aCallIndex, } NS_IMETHODIMP -Telephony::NotifyError(int32_t aCallIndex, +Telephony::NotifyError(uint32_t aServiceId, + int32_t aCallIndex, const nsAString& aError) { if (mCalls.IsEmpty()) { @@ -637,7 +682,7 @@ Telephony::NotifyError(int32_t aCallIndex, nsRefPtr callToNotify; callToNotify = (aCallIndex == -1) ? GetOutgoingCall() - : GetCall(aCallIndex); + : GetCall(aServiceId, aCallIndex); if (!callToNotify) { NS_ERROR("Don't call me with a bad call index!"); @@ -653,9 +698,10 @@ Telephony::NotifyError(int32_t aCallIndex, } NS_IMETHODIMP -Telephony::NotifyCdmaCallWaiting(const nsAString& aNumber) +Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber) { MOZ_ASSERT(mActiveCall && + mActiveCall->ServiceId() == aServiceId && mActiveCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED); nsRefPtr callToNotify = mActiveCall; diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 8644a35a18b4..0cceb7d612f4 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -7,6 +7,7 @@ #ifndef mozilla_dom_telephony_telephony_h__ #define mozilla_dom_telephony_telephony_h__ +#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/telephony/TelephonyCommon.h" #include "nsITelephonyProvider.h" @@ -66,16 +67,19 @@ public: // WebIDL already_AddRefed - Dial(const nsAString& aNumber, ErrorResult& aRv); + Dial(const nsAString& aNumber, const Optional& aServiceId, + ErrorResult& aRv); already_AddRefed - DialEmergency(const nsAString& aNumber, ErrorResult& aRv); + DialEmergency(const nsAString& aNumber, const Optional& aServiceId, + ErrorResult& aRv); void - StartTone(const nsAString& aDTMF, ErrorResult& aRv); + StartTone(const nsAString& aDTMFChar, const Optional& aServiceId, + ErrorResult& aRv); void - StopTone(ErrorResult& aRv); + StopTone(const Optional& aServiceId, ErrorResult& aRv); bool GetMuted(ErrorResult& aRv) const; @@ -148,9 +152,18 @@ private: static bool IsValidNumber(const nsAString& aNumber); + static uint32_t + GetNumServices(); + + static bool + IsValidServiceId(uint32_t aServiceId); + static bool IsActiveState(uint16_t aCallState); + uint32_t + ProvidedOrDefaultServiceId(const Optional& aServiceId); + bool HasDialingCall(); @@ -158,15 +171,15 @@ private: MatchActiveCall(TelephonyCall* aCall); already_AddRefed - DialInternal(bool isEmergency, - const nsAString& aNumber, - ErrorResult& aRv); + DialInternal(uint32_t aServiceId, const nsAString& aNumber, + bool isEmergency, ErrorResult& aRv); already_AddRefed - CreateNewDialingCall(const nsAString& aNumber); + CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber); void - NoteDialedCallFromOtherInstance(const nsAString& aNumber); + NoteDialedCallFromOtherInstance(uint32_t aServiceId, + const nsAString& aNumber); nsresult NotifyCallsChanged(TelephonyCall* aCall); @@ -181,13 +194,13 @@ private: UpdateActiveCall(TelephonyCall* aCall, bool aIsActive); already_AddRefed - GetCall(uint32_t aCallIndex); + GetCall(uint32_t aServiceId, uint32_t aCallIndex); already_AddRefed GetOutgoingCall(); already_AddRefed - GetCallFromEverywhere(uint32_t aCallIndex); + GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex); }; } // namespace dom diff --git a/dom/telephony/TelephonyCall.cpp b/dom/telephony/TelephonyCall.cpp index dd342cce5379..0a19ee222b86 100644 --- a/dom/telephony/TelephonyCall.cpp +++ b/dom/telephony/TelephonyCall.cpp @@ -19,9 +19,9 @@ using mozilla::dom::telephony::kOutgoingPlaceholderCallIndex; // static already_AddRefed -TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber, - uint16_t aCallState, uint32_t aCallIndex, - bool aEmergency, bool aIsConference) +TelephonyCall::Create(Telephony* aTelephony, uint32_t aServiceId, + const nsAString& aNumber, uint16_t aCallState, + uint32_t aCallIndex, bool aEmergency, bool aIsConference) { NS_ASSERTION(aTelephony, "Null pointer!"); NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!"); @@ -32,6 +32,7 @@ TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber, call->BindToOwner(aTelephony->GetOwner()); call->mTelephony = aTelephony; + call->mServiceId = aServiceId; call->mNumber = aNumber; call->mCallIndex = aCallIndex; call->mError = nullptr; @@ -219,7 +220,7 @@ TelephonyCall::Answer(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->AnswerCall(mCallIndex); + nsresult rv = mTelephony->Provider()->AnswerCall(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -238,8 +239,8 @@ TelephonyCall::HangUp(ErrorResult& aRv) } nsresult rv = mCallState == nsITelephonyProvider::CALL_STATE_INCOMING ? - mTelephony->Provider()->RejectCall(mCallIndex) : - mTelephony->Provider()->HangUp(mCallIndex); + mTelephony->Provider()->RejectCall(mServiceId, mCallIndex) : + mTelephony->Provider()->HangUp(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -261,7 +262,7 @@ TelephonyCall::Hold(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->HoldCall(mCallIndex); + nsresult rv = mTelephony->Provider()->HoldCall(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -290,7 +291,7 @@ TelephonyCall::Resume(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->ResumeCall(mCallIndex); + nsresult rv = mTelephony->Provider()->ResumeCall(mServiceId, mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; diff --git a/dom/telephony/TelephonyCall.h b/dom/telephony/TelephonyCall.h index 982e0c419d56..77f40375f89f 100644 --- a/dom/telephony/TelephonyCall.h +++ b/dom/telephony/TelephonyCall.h @@ -21,6 +21,7 @@ class TelephonyCall MOZ_FINAL : public nsDOMEventTargetHelper nsRefPtr mTelephony; nsRefPtr mGroup; + uint32_t mServiceId; nsString mNumber; nsString mSecondNumber; nsString mState; @@ -107,7 +108,8 @@ public: IMPL_EVENT_HANDLER(groupchange) static already_AddRefed - Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState, + Create(Telephony* aTelephony, uint32_t aServiceId, + const nsAString& aNumber, uint16_t aCallState, uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex, bool aEmergency = false, bool aIsConference = false); @@ -117,6 +119,12 @@ public: ChangeStateInternal(aCallState, true); } + uint32_t + ServiceId() const + { + return mServiceId; + } + uint32_t CallIndex() const { diff --git a/dom/telephony/TelephonyCallGroup.cpp b/dom/telephony/TelephonyCallGroup.cpp index a6579f723a17..201988003b3a 100644 --- a/dom/telephony/TelephonyCallGroup.cpp +++ b/dom/telephony/TelephonyCallGroup.cpp @@ -146,6 +146,10 @@ TelephonyCallGroup::CanConference(const TelephonyCall& aCall, MOZ_ASSERT(mCallState == nsITelephonyProvider::CALL_STATE_UNKNOWN); + if (aCall.ServiceId() != aSecondCall->ServiceId()) { + return false; + } + return (aCall.CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED && aSecondCall->CallState() == nsITelephonyProvider::CALL_STATE_HELD) || (aCall.CallState() == nsITelephonyProvider::CALL_STATE_HELD && @@ -153,13 +157,14 @@ TelephonyCallGroup::CanConference(const TelephonyCall& aCall, } already_AddRefed -TelephonyCallGroup::GetCall(uint32_t aCallIndex) +TelephonyCallGroup::GetCall(uint32_t aServiceId, uint32_t aCallIndex) { nsRefPtr call; for (uint32_t index = 0; index < mCalls.Length(); index++) { nsRefPtr& tempCall = mCalls[index]; - if (tempCall->CallIndex() == aCallIndex) { + if (tempCall->ServiceId() == aServiceId && + tempCall->CallIndex() == aCallIndex) { call = tempCall; break; } @@ -207,7 +212,7 @@ TelephonyCallGroup::Add(TelephonyCall& aCall, return; } - aRv = mTelephony->Provider()->ConferenceCall(); + aRv = mTelephony->Provider()->ConferenceCall(aCall.ServiceId()); } void @@ -220,7 +225,7 @@ TelephonyCallGroup::Add(TelephonyCall& aCall, return; } - aRv = mTelephony->Provider()->ConferenceCall(); + aRv = mTelephony->Provider()->ConferenceCall(aCall.ServiceId()); } void @@ -231,18 +236,14 @@ TelephonyCallGroup::Remove(TelephonyCall& aCall, ErrorResult& aRv) return; } + uint32_t serviceId = aCall.ServiceId(); uint32_t callIndex = aCall.CallIndex(); - bool hasCallToRemove = false; - for (uint32_t index = 0; index < mCalls.Length(); index++) { - nsRefPtr& call = mCalls[index]; - if (call->CallIndex() == callIndex) { - hasCallToRemove = true; - break; - } - } - if (hasCallToRemove) { - aRv = mTelephony->Provider()->SeparateCall(callIndex); + nsRefPtr call; + + call = GetCall(serviceId, callIndex); + if (call) { + aRv = mTelephony->Provider()->SeparateCall(serviceId, callIndex); } else { NS_WARNING("Didn't have this call. Ignore!"); } @@ -256,7 +257,9 @@ TelephonyCallGroup::Hold(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->HoldConference(); + MOZ_ASSERT(!mCalls.IsEmpty()); + + nsresult rv = mTelephony->Provider()->HoldConference(mCalls[0]->ServiceId()); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -273,7 +276,9 @@ TelephonyCallGroup::Resume(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->ResumeConference(); + MOZ_ASSERT(!mCalls.IsEmpty()); + + nsresult rv = mTelephony->Provider()->ResumeConference(mCalls[0]->ServiceId()); if (NS_FAILED(rv)) { aRv.Throw(rv); return; diff --git a/dom/telephony/TelephonyCallGroup.h b/dom/telephony/TelephonyCallGroup.h index a668140015c7..806454c4f734 100644 --- a/dom/telephony/TelephonyCallGroup.h +++ b/dom/telephony/TelephonyCallGroup.h @@ -81,7 +81,7 @@ public: RemoveCall(TelephonyCall* aCall); already_AddRefed - GetCall(uint32_t aCallIndex); + GetCall(uint32_t aServiceId, uint32_t aCallIndex); const nsTArray >& CallsArray() const From 0576683f0f8785324477d1ec983fdd06ad1bb4e2 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:51 -0400 Subject: [PATCH 355/795] Bug 814625 - Part 6: Telephony provider and IDL: Add multisim support. r=hsinyi --- dom/telephony/gonk/TelephonyProvider.js | 147 +++++++++++++-------- dom/telephony/nsIGonkTelephonyProvider.idl | 12 +- dom/telephony/nsITelephonyProvider.idl | 52 +++++--- 3 files changed, 130 insertions(+), 81 deletions(-) diff --git a/dom/telephony/gonk/TelephonyProvider.js b/dom/telephony/gonk/TelephonyProvider.js index ce6bf4e77cac..4b235dacba1a 100644 --- a/dom/telephony/gonk/TelephonyProvider.js +++ b/dom/telephony/gonk/TelephonyProvider.js @@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/Promise.jsm"); var RIL = {}; Cu.import("resource://gre/modules/ril_consts.js", RIL); @@ -64,6 +65,10 @@ XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() { } }); +XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer", + "@mozilla.org/ril;1", + "nsIRadioInterfaceLayer"); + XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService", "@mozilla.org/power/powermanagerservice;1", "nsIPowerManagerService"); @@ -72,12 +77,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger", "@mozilla.org/system-message-internal;1", "nsISystemMessagesInternal"); -XPCOMUtils.defineLazyGetter(this, "gRadioInterface", function () { - let ril = Cc["@mozilla.org/ril;1"].getService(Ci["nsIRadioInterfaceLayer"]); - // TODO: Bug 854326 - B2G Multi-SIM: support multiple SIM cards for SMS/MMS - return ril.getRadioInterface(0); -}); - XPCOMUtils.defineLazyGetter(this, "gPhoneNumberUtils", function () { let ns = {}; Cu.import("resource://gre/modules/PhoneNumberUtils.jsm", ns); @@ -85,8 +84,8 @@ XPCOMUtils.defineLazyGetter(this, "gPhoneNumberUtils", function () { }); function TelephonyProvider() { + this._numClients = gRadioInterfaceLayer.numRadioInterfaces; this._listeners = []; - this._updateDebugFlag(); this.defaultServiceId = this._getDefaultServiceId(); @@ -140,6 +139,10 @@ TelephonyProvider.prototype = { } }, + _getClient: function _getClient(aClientId) { + return gRadioInterfaceLayer.getRadioInterface(aClientId); + }, + // An array of nsITelephonyListener instances. _listeners: null, _notifyAllListeners: function _notifyAllListeners(aMethodName, aArgs) { @@ -159,6 +162,16 @@ TelephonyProvider.prototype = { } }, + _matchActiveCall: function _matchActiveCall(aCall) { + if (this._activeCall && + this._activeCall.callIndex == aCall.callIndex && + this._activeCall.clientId == aCall.clientId) { + return true; + } + + return false; + }, + /** * Track the active call and update the audio system as its state changes. */ @@ -186,7 +199,7 @@ TelephonyProvider.prototype = { } if (aCall.isConference) { - if (this._activeCall && this._activeCall.callIndex == aCall.callIndex) { + if (this._matchActiveCall(aCall)) { this._activeCall = null; } return; @@ -225,8 +238,7 @@ TelephonyProvider.prototype = { case nsITelephonyProvider.CALL_STATE_HELD: // Fall through... case nsITelephonyProvider.CALL_STATE_DISCONNECTED: aCall.isActive = false; - if (this._activeCall && - this._activeCall.callIndex == aCall.callIndex) { + if (this._matchActiveCall(aCall)) { // Previously active call is not active now. this._activeCall = null; } @@ -332,26 +344,45 @@ TelephonyProvider.prototype = { this._listeners.splice(index, 1); }, - enumerateCalls: function(aListener) { - if (DEBUG) debug("Requesting enumeration of calls for callback"); - gRadioInterface.sendWorkerMessage("enumerateCalls", null, - (function(response) { - for (let call of response.calls) { - call.state = this._convertRILCallState(call.state); - call.isActive = this._activeCall ? - (call.callIndex == this._activeCall.callIndex) : false; + _enumerateCallsForClient: function _enumerateCallsForClient(aClientId, + aListener) { + if (DEBUG) debug("Enumeration of calls for client " + aClientId); - aListener.enumerateCallState(call.callIndex, call.state, call.number, + let deferred = Promise.defer(); + + this._getClient(aClientId).sendWorkerMessage("enumerateCalls", null, + (function(response) { + for (let call of response.calls) { + call.clienId = aClientId; + call.state = this._convertRILCallState(call.state); + call.isActive = this._matchActiveCall(call); + + aListener.enumerateCallState(call.clientId, call.callIndex, + call.state, call.number, call.isActive, call.isOutgoing, call.isEmergency, call.isConference); } - aListener.enumerateCallStateComplete(); + deferred.resolve(); return false; }).bind(this)); + + return deferred.promise; }, - dial: function(aNumber, aIsEmergency) { + enumerateCalls: function(aListener) { + if (DEBUG) debug("Requesting enumeration of calls for callback"); + + let promise = Promise.resolve(); + for (let i = 0; i < this._numClients; ++i) { + promise = promise.then(this._enumerateCallsForClient.bind(this, i, aListener)); + } + promise.then(function() { + aListener.enumerateCallStateComplete(); + }); + }, + + dial: function(aClientId, aNumber, aIsEmergency) { if (DEBUG) debug("Dialing " + (aIsEmergency ? "emergency " : "") + aNumber); // we don't try to be too clever here, as the phone is probably in the // locked state. Let's just check if it's a number without normalizing @@ -359,53 +390,55 @@ TelephonyProvider.prototype = { aNumber = gPhoneNumberUtils.normalize(aNumber); } if (this._validateNumber(aNumber)) { - gRadioInterface.sendWorkerMessage("dial", { number: aNumber, - isDialEmergency: aIsEmergency }); + this._getClient(aClientId).sendWorkerMessage("dial", { + number: aNumber, + isDialEmergency: aIsEmergency + }); } }, - hangUp: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("hangUp", { callIndex: aCallIndex }); + hangUp: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("hangUp", { callIndex: aCallIndex }); }, - startTone: function(aDtmfChar) { - gRadioInterface.sendWorkerMessage("startTone", { dtmfChar: aDtmfChar }); + startTone: function(aClientId, aDtmfChar) { + this._getClient(aClientId).sendWorkerMessage("startTone", { dtmfChar: aDtmfChar }); }, - stopTone: function() { - gRadioInterface.sendWorkerMessage("stopTone"); + stopTone: function(aClientId) { + this._getClient(aClientId).sendWorkerMessage("stopTone"); }, - answerCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("answerCall", { callIndex: aCallIndex }); + answerCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("answerCall", { callIndex: aCallIndex }); }, - rejectCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("rejectCall", { callIndex: aCallIndex }); + rejectCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("rejectCall", { callIndex: aCallIndex }); }, - holdCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("holdCall", { callIndex: aCallIndex }); + holdCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("holdCall", { callIndex: aCallIndex }); }, - resumeCall: function(aCallIndex) { - gRadioInterface.sendWorkerMessage("resumeCall", { callIndex: aCallIndex }); + resumeCall: function(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("resumeCall", { callIndex: aCallIndex }); }, - conferenceCall: function conferenceCall() { - gRadioInterface.sendWorkerMessage("conferenceCall"); + conferenceCall: function conferenceCall(aClientId) { + this._getClient(aClientId).sendWorkerMessage("conferenceCall"); }, - separateCall: function separateCall(aCallIndex) { - gRadioInterface.sendWorkerMessage("separateCall", { callIndex: aCallIndex }); + separateCall: function separateCall(aClientId, aCallIndex) { + this._getClient(aClientId).sendWorkerMessage("separateCall", { callIndex: aCallIndex }); }, - holdConference: function holdConference() { - gRadioInterface.sendWorkerMessage("holdConference"); + holdConference: function holdConference(aClientId) { + this._getClient(aClientId).sendWorkerMessage("holdConference"); }, - resumeConference: function resumeConference() { - gRadioInterface.sendWorkerMessage("resumeConference"); + resumeConference: function resumeConference(aClientId) { + this._getClient(aClientId).sendWorkerMessage("resumeConference"); }, get microphoneMuted() { @@ -448,7 +481,7 @@ TelephonyProvider.prototype = { /** * Handle call disconnects by updating our current state and the audio system. */ - notifyCallDisconnected: function notifyCallDisconnected(aCall) { + notifyCallDisconnected: function notifyCallDisconnected(aClientId, aCall) { if (DEBUG) debug("handleCallDisconnected: " + JSON.stringify(aCall)); aCall.state = nsITelephonyProvider.CALL_STATE_DISCONNECTED; @@ -463,7 +496,8 @@ TelephonyProvider.prototype = { this._updateCallAudioState(aCall, null); - this._notifyAllListeners("callStateChanged", [aCall.callIndex, + this._notifyAllListeners("callStateChanged", [aClientId, + aCall.callIndex, aCall.state, aCall.number, aCall.isActive, @@ -475,8 +509,8 @@ TelephonyProvider.prototype = { /** * Handle call error. */ - notifyCallError: function notifyCallError(aCallIndex, aErrorMsg) { - this._notifyAllListeners("notifyError", [aCallIndex, aErrorMsg]); + notifyCallError: function notifyCallError(aClientId, aCallIndex, aErrorMsg) { + this._notifyAllListeners("notifyError", [aClientId, aCallIndex, aErrorMsg]); }, /** @@ -497,7 +531,7 @@ TelephonyProvider.prototype = { * Handle call state changes by updating our current state and the audio * system. */ - notifyCallStateChanged: function notifyCallStateChanged(aCall) { + notifyCallStateChanged: function notifyCallStateChanged(aClientId, aCall) { if (DEBUG) debug("handleCallStateChange: " + JSON.stringify(aCall)); aCall.state = this._convertRILCallState(aCall.state); @@ -507,7 +541,8 @@ TelephonyProvider.prototype = { this._updateCallAudioState(aCall, null); - this._notifyAllListeners("callStateChanged", [aCall.callIndex, + this._notifyAllListeners("callStateChanged", [aClientId, + aCall.callIndex, aCall.state, aCall.number, aCall.isActive, @@ -516,19 +551,19 @@ TelephonyProvider.prototype = { aCall.isConference]); }, - notifyCdmaCallWaiting: function notifyCdmaCallWaiting(aNumber) { + notifyCdmaCallWaiting: function notifyCdmaCallWaiting(aClientId, aNumber) { // We need to acquire a CPU wake lock to avoid the system falling into // the sleep mode when the RIL handles the incoming call. this._acquireCallRingWakeLock(); - this._notifyAllListeners("notifyCdmaCallWaiting", [aNumber]); + this._notifyAllListeners("notifyCdmaCallWaiting", [aClientId, aNumber]); }, - notifySupplementaryService: function notifySupplementaryService(aCallIndex, - aNotification) { + notifySupplementaryService: + function notifySupplementaryService(aClientId, aCallIndex, aNotification) { let notification = this._convertRILSuppSvcNotification(aNotification); this._notifyAllListeners("supplementaryServiceNotification", - [aCallIndex, notification]); + [aClientId, aCallIndex, notification]); }, notifyConferenceCallStateChanged: function notifyConferenceCallStateChanged(aState) { diff --git a/dom/telephony/nsIGonkTelephonyProvider.idl b/dom/telephony/nsIGonkTelephonyProvider.idl index 43f18581a8e1..f2edd9611be7 100644 --- a/dom/telephony/nsIGonkTelephonyProvider.idl +++ b/dom/telephony/nsIGonkTelephonyProvider.idl @@ -10,21 +10,21 @@ "@mozilla.org/telephony/gonktelephonyprovider;1" %} -[scriptable, uuid(f072f334-e4ea-4754-9929-533da30444a8)] +[scriptable, uuid(fe113e67-5a15-49e6-a555-7f41409f611a)] interface nsIGonkTelephonyProvider : nsITelephonyProvider { - void notifyCallDisconnected(in jsval call); + void notifyCallDisconnected(in unsigned long clientId, in jsval call); - void notifyCallError(in long callIndex, + void notifyCallError(in unsigned long clientId, in long callIndex, in AString error); void notifyCallRing(); - void notifyCallStateChanged(in jsval call); + void notifyCallStateChanged(in unsigned long clientId, in jsval call); - void notifyCdmaCallWaiting(in AString number); + void notifyCdmaCallWaiting(in unsigned long clientId, in AString number); - void notifySupplementaryService(in long callIndex, + void notifySupplementaryService(in unsigned long clientId, in long callIndex, in AString notification); void notifyConferenceCallStateChanged(in short state); diff --git a/dom/telephony/nsITelephonyProvider.idl b/dom/telephony/nsITelephonyProvider.idl index cda5e1ba109e..e73ed97c6944 100644 --- a/dom/telephony/nsITelephonyProvider.idl +++ b/dom/telephony/nsITelephonyProvider.idl @@ -4,12 +4,14 @@ #include "nsISupports.idl" -[scriptable, uuid(3aa42e77-7c2b-43a1-b105-7be094b0817a)] +[scriptable, uuid(707c4c43-a0d7-4093-af52-d4d6a3a333c3)] interface nsITelephonyListener : nsISupports { /** * Notified when a telephony call changes state. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. * @param callState @@ -25,7 +27,8 @@ interface nsITelephonyListener : nsISupports * @param isConference * Indicates whether this call is a conference call. */ - void callStateChanged(in unsigned long callIndex, + void callStateChanged(in unsigned long clientId, + in unsigned long callIndex, in unsigned short callState, in AString number, in boolean isActive, @@ -55,6 +58,8 @@ interface nsITelephonyListener : nsISupports * telephony call state (nsITelephonyProvider::enumerateCalls). This is * called once per call that is currently managed by the RIL. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. * @param callState @@ -68,7 +73,8 @@ interface nsITelephonyListener : nsISupports * @param isConference * Indicates whether this call is a conference call. */ - void enumerateCallState(in unsigned long callIndex, + void enumerateCallState(in unsigned long clientId, + in unsigned long callIndex, in unsigned short callState, in AString number, in boolean isActive, @@ -79,32 +85,40 @@ interface nsITelephonyListener : nsISupports /** * Notify when RIL receives supplementary service notification. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. -1 if not specified * @param notification * One of the nsITelephonyProvider::NOTIFICATION_* values. */ - void supplementaryServiceNotification(in long callIndex, + void supplementaryServiceNotification(in unsigned long clientId, + in long callIndex, in unsigned short notification); /** * Called when RIL error occurs. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. -1 if no connection * @param error * Error from RIL. */ - void notifyError(in long callIndex, + void notifyError(in unsigned long clientId, + in long callIndex, in AString error); /** * Called when a waiting call comes in CDMA networks. * + * @param clientId + Indicate the RIL client, 0 ~ (number of client - 1). * @param number * Number of the other party. */ - void notifyCdmaCallWaiting(in AString number); + void notifyCdmaCallWaiting(in unsigned long clientId, in AString number); }; %{C++ @@ -118,7 +132,7 @@ interface nsITelephonyListener : nsISupports * XPCOM component (in the content process) that provides the telephony * information. */ -[scriptable, uuid(f7680b82-53fc-42a7-9adf-bc0f2726425c)] +[scriptable, uuid(4ff3ecb7-b024-4752-9dd6-c3623c6e6b8a)] interface nsITelephonyProvider : nsISupports { const unsigned short CALL_STATE_UNKNOWN = 0; @@ -155,22 +169,22 @@ interface nsITelephonyProvider : nsISupports /** * Functionality for making and managing phone calls. */ - void dial(in DOMString number, + void dial(in unsigned long clientId, in DOMString number, in boolean isEmergency); - void hangUp(in unsigned long callIndex); + void hangUp(in unsigned long clientId, in unsigned long callIndex); - void startTone(in DOMString dtmfChar); - void stopTone(); + void startTone(in unsigned long clientId, in DOMString dtmfChar); + void stopTone(in unsigned long clientId); - void answerCall(in unsigned long callIndex); - void rejectCall(in unsigned long callIndex); - void holdCall(in unsigned long callIndex); - void resumeCall(in unsigned long callIndex); + void answerCall(in unsigned long clientId, in unsigned long callIndex); + void rejectCall(in unsigned long clientId, in unsigned long callIndex); + void holdCall(in unsigned long clientId, in unsigned long callIndex); + void resumeCall(in unsigned long clientId, in unsigned long callIndex); - void conferenceCall(); - void separateCall(in unsigned long callIndex); - void holdConference(); - void resumeConference(); + void conferenceCall(in unsigned long clientId); + void separateCall(in unsigned long clientId, in unsigned long callIndex); + void holdConference(in unsigned long clientId); + void resumeConference(in unsigned long clientId); attribute bool microphoneMuted; attribute bool speakerEnabled; From f842d8f210912d5df22ecbe9da8749df585557d7 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:51 -0400 Subject: [PATCH 356/795] Bug 814625 - Part 7: Telephony IPC: Add multisim support. r=khuey --- dom/telephony/ipc/PTelephony.ipdl | 33 ++++--- dom/telephony/ipc/PTelephonyRequest.ipdl | 2 +- dom/telephony/ipc/TelephonyChild.cpp | 28 ++++-- dom/telephony/ipc/TelephonyChild.h | 14 ++- dom/telephony/ipc/TelephonyIPCProvider.cpp | 101 ++++++++++--------- dom/telephony/ipc/TelephonyParent.cpp | 110 ++++++++++++--------- dom/telephony/ipc/TelephonyParent.h | 25 +++-- 7 files changed, 174 insertions(+), 139 deletions(-) diff --git a/dom/telephony/ipc/PTelephony.ipdl b/dom/telephony/ipc/PTelephony.ipdl index d82044401ef5..9ee105036998 100644 --- a/dom/telephony/ipc/PTelephony.ipdl +++ b/dom/telephony/ipc/PTelephony.ipdl @@ -17,15 +17,16 @@ sync protocol PTelephony { manages PTelephonyRequest; child: - NotifyCallError(int32_t aCallIndex, nsString aError); + NotifyCallError(uint32_t aClientId, int32_t aCallIndex, nsString aError); - NotifyCallStateChanged(IPCCallStateData aData); + NotifyCallStateChanged(uint32_t aClientId, IPCCallStateData aData); - NotifyCdmaCallWaiting(nsString aNumber); + NotifyCdmaCallWaiting(uint32_t aClientId, nsString aNumber); NotifyConferenceCallStateChanged(uint16_t aCallState); - NotifySupplementaryService(int32_t aCallIndex, uint16_t aNotification); + NotifySupplementaryService(uint32_t aClientId, int32_t aCallIndex, + uint16_t aNotification); parent: /** @@ -43,29 +44,29 @@ parent: UnregisterListener(); - DialCall(nsString aNumber, bool aIsEmergency); + DialCall(uint32_t aClientId, nsString aNumber, bool aIsEmergency); - HangUpCall(uint32_t aCallIndex); + HangUpCall(uint32_t aClientId, uint32_t aCallIndex); - AnswerCall(uint32_t aCallIndex); + AnswerCall(uint32_t aClientId, uint32_t aCallIndex); - RejectCall(uint32_t aCallIndex); + RejectCall(uint32_t aClientId, uint32_t aCallIndex); - HoldCall(uint32_t aCallIndex); + HoldCall(uint32_t aClientId, uint32_t aCallIndex); - ResumeCall(uint32_t aCallIndex); + ResumeCall(uint32_t aClientId, uint32_t aCallIndex); - ConferenceCall(); + ConferenceCall(uint32_t aClientId); - SeparateCall(uint32_t aCallIndex); + SeparateCall(uint32_t aClientId, uint32_t aCallIndex); - HoldConference(); + HoldConference(uint32_t aClientId); - ResumeConference(); + ResumeConference(uint32_t aClientId); - StartTone(nsString aTone); + StartTone(uint32_t aClientId, nsString aTone); - StopTone(); + StopTone(uint32_t aClientId); sync GetMicrophoneMuted() returns (bool aMuted); diff --git a/dom/telephony/ipc/PTelephonyRequest.ipdl b/dom/telephony/ipc/PTelephonyRequest.ipdl index 05f708ffc6a0..70ed3bd65f75 100644 --- a/dom/telephony/ipc/PTelephonyRequest.ipdl +++ b/dom/telephony/ipc/PTelephonyRequest.ipdl @@ -16,7 +16,7 @@ protocol PTelephonyRequest manager PTelephony; child: - NotifyEnumerateCallState(IPCCallStateData aData); + NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData); /** * Sent when the asynchronous request has completed. It's currently only for diff --git a/dom/telephony/ipc/TelephonyChild.cpp b/dom/telephony/ipc/TelephonyChild.cpp index 411e3b35f0a7..a84c17febfc8 100644 --- a/dom/telephony/ipc/TelephonyChild.cpp +++ b/dom/telephony/ipc/TelephonyChild.cpp @@ -37,21 +37,24 @@ TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) } bool -TelephonyChild::RecvNotifyCallError(const int32_t& aCallIndex, +TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, + const int32_t& aCallIndex, const nsString& aError) { MOZ_ASSERT(mListener); - mListener->NotifyError(aCallIndex, aError); + mListener->NotifyError(aClientId, aCallIndex, aError); return true; } bool -TelephonyChild::RecvNotifyCallStateChanged(const IPCCallStateData& aData) +TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, + const IPCCallStateData& aData) { MOZ_ASSERT(mListener); - mListener->CallStateChanged(aData.callIndex(), + mListener->CallStateChanged(aClientId, + aData.callIndex(), aData.callState(), aData.number(), aData.isActive(), @@ -62,11 +65,12 @@ TelephonyChild::RecvNotifyCallStateChanged(const IPCCallStateData& aData) } bool -TelephonyChild::RecvNotifyCdmaCallWaiting(const nsString& aNumber) +TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, + const nsString& aNumber) { MOZ_ASSERT(mListener); - mListener->NotifyCdmaCallWaiting(aNumber); + mListener->NotifyCdmaCallWaiting(aClientId, aNumber); return true; } @@ -80,12 +84,14 @@ TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) } bool -TelephonyChild::RecvNotifySupplementaryService(const int32_t& aCallIndex, +TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId, + const int32_t& aCallIndex, const uint16_t& aNotification) { MOZ_ASSERT(mListener); - mListener->SupplementaryServiceNotification(aCallIndex, aNotification); + mListener->SupplementaryServiceNotification(aClientId, aCallIndex, + aNotification); return true; } @@ -115,11 +121,13 @@ TelephonyRequestChild::Recv__delete__() } bool -TelephonyRequestChild::RecvNotifyEnumerateCallState(const IPCCallStateData& aData) +TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, + const IPCCallStateData& aData) { MOZ_ASSERT(mListener); - mListener->EnumerateCallState(aData.callIndex(), + mListener->EnumerateCallState(aClientId, + aData.callIndex(), aData.callState(), aData.number(), aData.isActive(), diff --git a/dom/telephony/ipc/TelephonyChild.h b/dom/telephony/ipc/TelephonyChild.h index 91eb1f8d2a54..ecf2adccdf74 100644 --- a/dom/telephony/ipc/TelephonyChild.h +++ b/dom/telephony/ipc/TelephonyChild.h @@ -31,20 +31,23 @@ protected: DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) MOZ_OVERRIDE; virtual bool - RecvNotifyCallError(const int32_t& aCallIndex, + RecvNotifyCallError(const uint32_t& aClientId, const int32_t& aCallIndex, const nsString& aError) MOZ_OVERRIDE; virtual bool - RecvNotifyCallStateChanged(const IPCCallStateData& aData) MOZ_OVERRIDE; + RecvNotifyCallStateChanged(const uint32_t& aClientId, + const IPCCallStateData& aData) MOZ_OVERRIDE; virtual bool - RecvNotifyCdmaCallWaiting(const nsString& aNumber) MOZ_OVERRIDE; + RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, + const nsString& aNumber) MOZ_OVERRIDE; virtual bool RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) MOZ_OVERRIDE; virtual bool - RecvNotifySupplementaryService(const int32_t& aCallIndex, + RecvNotifySupplementaryService(const uint32_t& aClientId, + const int32_t& aCallIndex, const uint16_t& aNotification) MOZ_OVERRIDE; private: @@ -66,7 +69,8 @@ protected: Recv__delete__() MOZ_OVERRIDE; virtual bool - RecvNotifyEnumerateCallState(const IPCCallStateData& aData) MOZ_OVERRIDE; + RecvNotifyEnumerateCallState(const uint32_t& aClientId, + const IPCCallStateData& aData) MOZ_OVERRIDE; private: nsCOMPtr mListener; diff --git a/dom/telephony/ipc/TelephonyIPCProvider.cpp b/dom/telephony/ipc/TelephonyIPCProvider.cpp index 6da47f8face6..c147fbb47975 100644 --- a/dom/telephony/ipc/TelephonyIPCProvider.cpp +++ b/dom/telephony/ipc/TelephonyIPCProvider.cpp @@ -128,87 +128,87 @@ TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener) } NS_IMETHODIMP -TelephonyIPCProvider::Dial(const nsAString& aNumber, - bool aIsEmergency) +TelephonyIPCProvider::Dial(uint32_t aClientId, const nsAString& aNumber, + bool aIsEmergency) { - mPTelephonyChild->SendDialCall(nsString(aNumber), aIsEmergency); + mPTelephonyChild->SendDialCall(aClientId, nsString(aNumber), aIsEmergency); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HangUp(uint32_t aCallIndex) +TelephonyIPCProvider::HangUp(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendHangUpCall(aCallIndex); + mPTelephonyChild->SendHangUpCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::AnswerCall(uint32_t aCallIndex) +TelephonyIPCProvider::AnswerCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendAnswerCall(aCallIndex); + mPTelephonyChild->SendAnswerCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::RejectCall(uint32_t aCallIndex) +TelephonyIPCProvider::RejectCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendRejectCall(aCallIndex); + mPTelephonyChild->SendRejectCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HoldCall(uint32_t aCallIndex) +TelephonyIPCProvider::HoldCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendHoldCall(aCallIndex); + mPTelephonyChild->SendHoldCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ResumeCall(uint32_t aCallIndex) +TelephonyIPCProvider::ResumeCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendResumeCall(aCallIndex); + mPTelephonyChild->SendResumeCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ConferenceCall() +TelephonyIPCProvider::ConferenceCall(uint32_t aClientId) { - mPTelephonyChild->SendConferenceCall(); + mPTelephonyChild->SendConferenceCall(aClientId); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::SeparateCall(uint32_t aCallIndex) +TelephonyIPCProvider::SeparateCall(uint32_t aClientId, uint32_t aCallIndex) { - mPTelephonyChild->SendSeparateCall(aCallIndex); + mPTelephonyChild->SendSeparateCall(aClientId, aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HoldConference() +TelephonyIPCProvider::HoldConference(uint32_t aClientId) { - mPTelephonyChild->SendHoldConference(); + mPTelephonyChild->SendHoldConference(aClientId); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ResumeConference() +TelephonyIPCProvider::ResumeConference(uint32_t aClientId) { - mPTelephonyChild->SendResumeConference(); + mPTelephonyChild->SendResumeConference(aClientId); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::StartTone(const nsAString& aDtmfChar) +TelephonyIPCProvider::StartTone(uint32_t aClientId, const nsAString& aDtmfChar) { - mPTelephonyChild->SendStartTone(nsString(aDtmfChar)); + mPTelephonyChild->SendStartTone(aClientId, nsString(aDtmfChar)); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::StopTone() +TelephonyIPCProvider::StopTone(uint32_t aClientId) { - mPTelephonyChild->SendStopTone(); + mPTelephonyChild->SendStopTone(aClientId); return NS_OK; } @@ -243,16 +243,17 @@ TelephonyIPCProvider::SetSpeakerEnabled(bool aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyIPCProvider::CallStateChanged(uint32_t aCallIndex, - uint16_t aCallState, - const nsAString& aNumber, - bool aIsActive, - bool aIsOutgoing, - bool aIsEmergency, - bool aIsConference) +TelephonyIPCProvider::CallStateChanged(uint32_t aClientId, + uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aNumber, + bool aIsActive, + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->CallStateChanged(aCallIndex, aCallState, aNumber, + mListeners[i]->CallStateChanged(aClientId, aCallIndex, aCallState, aNumber, aIsActive, aIsOutgoing, aIsEmergency, aIsConference); } @@ -275,42 +276,46 @@ TelephonyIPCProvider::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyIPCProvider::EnumerateCallState(uint32_t aCallIndex, - uint16_t aCallState, - const nsAString& aNumber, - bool aIsActive, - bool aIsOutgoing, - bool aIsEmergency, - bool aIsConference) +TelephonyIPCProvider::EnumerateCallState(uint32_t aClientId, + uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aNumber, + bool aIsActive, + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference) { MOZ_CRASH("Not a EnumerateCalls request!"); } NS_IMETHODIMP -TelephonyIPCProvider::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyIPCProvider::NotifyCdmaCallWaiting(uint32_t aClientId, + const nsAString& aNumber) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->NotifyCdmaCallWaiting(aNumber); + mListeners[i]->NotifyCdmaCallWaiting(aClientId, aNumber); } return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::NotifyError(int32_t aCallIndex, - const nsAString& aError) +TelephonyIPCProvider::NotifyError(uint32_t aClientId, int32_t aCallIndex, + const nsAString& aError) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->NotifyError(aCallIndex, aError); + mListeners[i]->NotifyError(aClientId, aCallIndex, aError); } return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::SupplementaryServiceNotification(int32_t aCallIndex, - uint16_t aNotification) +TelephonyIPCProvider::SupplementaryServiceNotification(uint32_t aClientId, + int32_t aCallIndex, + uint16_t aNotification) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->SupplementaryServiceNotification(aCallIndex, aNotification); + mListeners[i]->SupplementaryServiceNotification(aClientId, aCallIndex, + aNotification); } return NS_OK; } diff --git a/dom/telephony/ipc/TelephonyParent.cpp b/dom/telephony/ipc/TelephonyParent.cpp index 8db736c390de..a9be3eeaaae4 100644 --- a/dom/telephony/ipc/TelephonyParent.cpp +++ b/dom/telephony/ipc/TelephonyParent.cpp @@ -92,135 +92,142 @@ TelephonyParent::RecvUnregisterListener() } bool -TelephonyParent::RecvDialCall(const nsString& aNumber, +TelephonyParent::RecvDialCall(const uint32_t& aClientId, + const nsString& aNumber, const bool& aIsEmergency) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->Dial(aNumber, aIsEmergency); + provider->Dial(aClientId, aNumber, aIsEmergency); return true; } bool -TelephonyParent::RecvHangUpCall(const uint32_t& aCallIndex) +TelephonyParent::RecvHangUpCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HangUp(aCallIndex); + provider->HangUp(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvAnswerCall(const uint32_t& aCallIndex) +TelephonyParent::RecvAnswerCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->AnswerCall(aCallIndex); + provider->AnswerCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvRejectCall(const uint32_t& aCallIndex) +TelephonyParent::RecvRejectCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->RejectCall(aCallIndex); + provider->RejectCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvHoldCall(const uint32_t& aCallIndex) +TelephonyParent::RecvHoldCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HoldCall(aCallIndex); + provider->HoldCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvResumeCall(const uint32_t& aCallIndex) +TelephonyParent::RecvResumeCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ResumeCall(aCallIndex); + provider->ResumeCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvConferenceCall() +TelephonyParent::RecvConferenceCall(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ConferenceCall(); + provider->ConferenceCall(aClientId); return true; } bool -TelephonyParent::RecvSeparateCall(const uint32_t& aCallState) +TelephonyParent::RecvSeparateCall(const uint32_t& aClientId, + const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->SeparateCall(aCallState); + provider->SeparateCall(aClientId, aCallIndex); return true; } bool -TelephonyParent::RecvHoldConference() +TelephonyParent::RecvHoldConference(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HoldConference(); + provider->HoldConference(aClientId); return true; } bool -TelephonyParent::RecvResumeConference() +TelephonyParent::RecvResumeConference(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ResumeConference(); + provider->ResumeConference(aClientId); return true; } bool -TelephonyParent::RecvStartTone(const nsString& aTone) +TelephonyParent::RecvStartTone(const uint32_t& aClientId, const nsString& aTone) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->StartTone(aTone); + provider->StartTone(aClientId, aTone); return true; } bool -TelephonyParent::RecvStopTone() +TelephonyParent::RecvStopTone(const uint32_t& aClientId) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->StopTone(); + provider->StopTone(aClientId); return true; } @@ -275,7 +282,8 @@ TelephonyParent::RecvSetSpeakerEnabled(const bool& aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyParent::CallStateChanged(uint32_t aCallIndex, +TelephonyParent::CallStateChanged(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -285,9 +293,9 @@ TelephonyParent::CallStateChanged(uint32_t aCallIndex, { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), aIsActive, - aIsOutgoing, aIsEmergency, aIsConference); - return SendNotifyCallStateChanged(data) ? NS_OK : NS_ERROR_FAILURE; + IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), + aIsActive, aIsOutgoing, aIsEmergency, aIsConference); + return SendNotifyCallStateChanged(aClientId, data) ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -306,7 +314,8 @@ TelephonyParent::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyParent::EnumerateCallState(uint32_t aCallIndex, +TelephonyParent::EnumerateCallState(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -318,32 +327,35 @@ TelephonyParent::EnumerateCallState(uint32_t aCallIndex, } NS_IMETHODIMP -TelephonyParent::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyParent::NotifyCdmaCallWaiting(uint32_t aClientId, + const nsAString& aNumber) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCdmaCallWaiting(nsString(aNumber)) ? NS_OK - : NS_ERROR_FAILURE; + return SendNotifyCdmaCallWaiting(aClientId, nsString(aNumber)) + ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyParent::NotifyError(int32_t aCallIndex, +TelephonyParent::NotifyError(uint32_t aClientId, + int32_t aCallIndex, const nsAString& aError) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCallError(aCallIndex, nsString(aError)) ? NS_OK - : NS_ERROR_FAILURE; + return SendNotifyCallError(aClientId, aCallIndex, nsString(aError)) + ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyParent::SupplementaryServiceNotification(int32_t aCallIndex, +TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId, + int32_t aCallIndex, uint16_t aNotification) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifySupplementaryService(aCallIndex, aNotification) - ? NS_OK : NS_ERROR_FAILURE; + return SendNotifySupplementaryService(aClientId, aCallIndex, aNotification) + ? NS_OK : NS_ERROR_FAILURE; } /******************************************************************************* @@ -387,7 +399,8 @@ TelephonyRequestParent::DoRequest() // nsITelephonyListener NS_IMETHODIMP -TelephonyRequestParent::CallStateChanged(uint32_t aCallIndex, +TelephonyRequestParent::CallStateChanged(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -413,7 +426,8 @@ TelephonyRequestParent::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyRequestParent::EnumerateCallState(uint32_t aCallIndex, +TelephonyRequestParent::EnumerateCallState(uint32_t aClientId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -423,26 +437,30 @@ TelephonyRequestParent::EnumerateCallState(uint32_t aCallIndex, { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), aIsActive, - aIsOutgoing, aIsEmergency, aIsConference); - return SendNotifyEnumerateCallState(data) ? NS_OK : NS_ERROR_FAILURE; + IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), + aIsActive, aIsOutgoing, aIsEmergency, aIsConference); + return SendNotifyEnumerateCallState(aClientId, data) ? NS_OK + : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyRequestParent::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyRequestParent::NotifyCdmaCallWaiting(uint32_t aClientId, + const nsAString& aNumber) { MOZ_CRASH("Not a TelephonyParent!"); } NS_IMETHODIMP -TelephonyRequestParent::NotifyError(int32_t aCallIndex, +TelephonyRequestParent::NotifyError(uint32_t aClientId, + int32_t aCallIndex, const nsAString& aError) { MOZ_CRASH("Not a TelephonyParent!"); } NS_IMETHODIMP -TelephonyRequestParent::SupplementaryServiceNotification(int32_t aCallIndex, +TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId, + int32_t aCallIndex, uint16_t aNotification) { MOZ_CRASH("Not a TelephonyParent!"); diff --git a/dom/telephony/ipc/TelephonyParent.h b/dom/telephony/ipc/TelephonyParent.h index ac508c264bea..16abf189bbfd 100644 --- a/dom/telephony/ipc/TelephonyParent.h +++ b/dom/telephony/ipc/TelephonyParent.h @@ -47,41 +47,40 @@ protected: RecvUnregisterListener() MOZ_OVERRIDE; virtual bool - RecvDialCall(const nsString& aNumber, - const bool& aIsEmergency) MOZ_OVERRIDE; + RecvDialCall(const uint32_t& aClientId, const nsString& aNumber, const bool& aIsEmergency) MOZ_OVERRIDE; virtual bool - RecvHangUpCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvHangUpCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvAnswerCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvAnswerCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvRejectCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvRejectCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvHoldCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvHoldCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvResumeCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvResumeCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvConferenceCall() MOZ_OVERRIDE; + RecvConferenceCall(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool - RecvSeparateCall(const uint32_t& callIndex) MOZ_OVERRIDE; + RecvSeparateCall(const uint32_t& aClientId, const uint32_t& callIndex) MOZ_OVERRIDE; virtual bool - RecvHoldConference() MOZ_OVERRIDE; + RecvHoldConference(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool - RecvResumeConference() MOZ_OVERRIDE; + RecvResumeConference(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool - RecvStartTone(const nsString& aTone) MOZ_OVERRIDE; + RecvStartTone(const uint32_t& aClientId, const nsString& aTone) MOZ_OVERRIDE; virtual bool - RecvStopTone() MOZ_OVERRIDE; + RecvStopTone(const uint32_t& aClientId) MOZ_OVERRIDE; virtual bool RecvGetMicrophoneMuted(bool* aMuted) MOZ_OVERRIDE; From 1ccbe812aa36bd3dd8bb747c9ab38ea61db5300d Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:05:52 -0400 Subject: [PATCH 357/795] Bug 814625 - Part 8: RIL: Add multisim support. r=hsinyi --- dom/system/gonk/RadioInterfaceLayer.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index a6256789a74f..e731c1166409 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -1001,22 +1001,24 @@ RadioInterface.prototype = { gTelephonyProvider.notifyCallRing(); break; case "callStateChange": - gTelephonyProvider.notifyCallStateChanged(message.call); + gTelephonyProvider.notifyCallStateChanged(this.clientId, message.call); break; case "callDisconnected": - gTelephonyProvider.notifyCallDisconnected(message.call); + gTelephonyProvider.notifyCallDisconnected(this.clientId, message.call); break; case "conferenceCallStateChanged": gTelephonyProvider.notifyConferenceCallStateChanged(message.state); break; case "cdmaCallWaiting": - gTelephonyProvider.notifyCdmaCallWaiting(message.number); + gTelephonyProvider.notifyCdmaCallWaiting(this.clientId, message.number); break; case "callError": - gTelephonyProvider.notifyCallError(message.callIndex, message.errorMsg); + gTelephonyProvider.notifyCallError(this.clientId, message.callIndex, + message.errorMsg); break; case "suppSvcNotification": - gTelephonyProvider.notifySupplementaryService(message.callIndex, + gTelephonyProvider.notifySupplementaryService(this.clientId, + message.callIndex, message.notification); break; case "emergencyCbModeChange": @@ -3575,4 +3577,3 @@ RILNetworkInterface.prototype = { }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RadioInterfaceLayer]); - From bbf2d765ec7af52c8848a0cee129ac919d6244c0 Mon Sep 17 00:00:00 2001 From: "Szu-Yu Chen [:aknow]" Date: Thu, 31 Oct 2013 08:06:28 -0400 Subject: [PATCH 358/795] Bug 814625 - Part 9: Bluetooth: Add serviceId in listener. r=gyeh --- dom/bluetooth/BluetoothRilListener.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dom/bluetooth/BluetoothRilListener.cpp b/dom/bluetooth/BluetoothRilListener.cpp index acbb4f719135..bc251c0eb634 100644 --- a/dom/bluetooth/BluetoothRilListener.cpp +++ b/dom/bluetooth/BluetoothRilListener.cpp @@ -133,6 +133,8 @@ MobileConnectionListener::NotifyIccChanged() /** * TelephonyListener Implementation + * + * TODO: Bug 921991 - B2G BT: support multiple sim cards */ class TelephonyListener : public nsITelephonyListener { @@ -146,7 +148,8 @@ public: NS_IMPL_ISUPPORTS1(TelephonyListener, nsITelephonyListener) NS_IMETHODIMP -TelephonyListener::CallStateChanged(uint32_t aCallIndex, +TelephonyListener::CallStateChanged(uint32_t aServiceId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -162,7 +165,8 @@ TelephonyListener::CallStateChanged(uint32_t aCallIndex, } NS_IMETHODIMP -TelephonyListener::EnumerateCallState(uint32_t aCallIndex, +TelephonyListener::EnumerateCallState(uint32_t aServiceId, + uint32_t aCallIndex, uint16_t aCallState, const nsAString_internal& aNumber, bool aIsActive, @@ -177,7 +181,8 @@ TelephonyListener::EnumerateCallState(uint32_t aCallIndex, } NS_IMETHODIMP -TelephonyListener::NotifyError(int32_t aCallIndex, +TelephonyListener::NotifyError(uint32_t aServiceId, + int32_t aCallIndex, const nsAString& aError) { BluetoothHfpManager* hfp = BluetoothHfpManager::Get(); @@ -211,14 +216,16 @@ TelephonyListener::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyListener::SupplementaryServiceNotification(int32_t aCallIndex, +TelephonyListener::SupplementaryServiceNotification(uint32_t aServiceId, + int32_t aCallIndex, uint16_t aNotification) { return NS_OK; } NS_IMETHODIMP -TelephonyListener::NotifyCdmaCallWaiting(const nsAString& aNumber) +TelephonyListener::NotifyCdmaCallWaiting(uint32_t aServiceId, + const nsAString& aNumber) { BluetoothHfpManager* hfp = BluetoothHfpManager::Get(); hfp->UpdateSecondNumber(aNumber); @@ -339,4 +346,4 @@ BluetoothRilListener::StopTelephonyListening() nsresult rv = provider->UnregisterListener(mTelephonyListener); return NS_SUCCEEDED(rv); -} \ No newline at end of file +} From 1f29b1a1022d650b13776b9f93a95086e9a6a000 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Thu, 31 Oct 2013 05:30:24 -0700 Subject: [PATCH 359/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ======== https://hg.mozilla.org/integration/gaia-central/rev/d38b2bb59bec Author: Germán Toro del Valle Desc: Merge pull request #13231 from gtorodelvalle/contacts-bug-925665-deleting-custom-tag Bug 925665 - [Contacts] Not possible to delete text in a custom tag by tapping on 'x' icon (r=jmcanterafonseca) ======== https://hg.mozilla.org/integration/gaia-central/rev/d1cd551d00ab Author: Germán Toro del Valle Desc: Bug 925665 - [Contacts] Not possible to delete text in a custom tag by tapping on 'x' icon --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index ee2a62bf60f3..41b51e52b9ef 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "4bbc9f71b0e3b607f53187c4721b2d9086f1d337", + "revision": "d38b2bb59bec025ae2ebd725e8a87d6dc9498275", "repo_path": "/integration/gaia-central" } From 625305d8503c0b469f619e604428ebc5f0818db6 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Thu, 31 Oct 2013 05:40:24 -0700 Subject: [PATCH 360/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ======== https://hg.mozilla.org/integration/gaia-central/rev/1d4331977842 Author: Germán Toro del Valle Desc: Merge pull request #13257 from gtorodelvalle/contacts-bug-930929-no-postal-address-information Bug 930929 - [Contacts] Contact's address information is not shown in the contact details view ======== https://hg.mozilla.org/integration/gaia-central/rev/fb40b71841dc Author: Germán Toro del Valle Desc: Bug 930929 - [Contacts] Contact's address information is not shown in the contact details view. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 41b51e52b9ef..69bb00de3090 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "d38b2bb59bec025ae2ebd725e8a87d6dc9498275", + "revision": "1d433197784273159488c3f049b3e77930bdfc86", "repo_path": "/integration/gaia-central" } From 69718ecf8d26c2acc261e1f791a56fd5692eecaa Mon Sep 17 00:00:00 2001 From: Rail Aliiev Date: Thu, 31 Oct 2013 09:35:02 -0400 Subject: [PATCH 361/795] Bug 917642 - [Helix] Please update the helix blobs. r=nhirata --- b2g/config/helix/releng-helix.tt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/b2g/config/helix/releng-helix.tt b/b2g/config/helix/releng-helix.tt index f5e92ae73b59..06b5e4966597 100644 --- a/b2g/config/helix/releng-helix.tt +++ b/b2g/config/helix/releng-helix.tt @@ -1,7 +1,7 @@ [ { -"size": 86149048, -"digest": "4ff723d8a372e2af95e62efb8739517943f362b515b4cee78006137a8dbc97f3b42edbd2e17429eaa7fa16b7f24594ed058b7032bcb7aa2ecfe9788a212dda4d", +"size": 60007364, +"digest": "c98228772525301a1ef0a149e6d235a6a854358e9673e37ff9b1cc1fa707c770292481abde24b5e193adb1a0b1f1f00da8f0df241644db3656777aba9fd7b216", "algorithm": "sha512", "filename": "helix-ics.tar.xz" }, From 142869965210a90656f59452a90fc28fe6763e06 Mon Sep 17 00:00:00 2001 From: John Shih Date: Thu, 24 Oct 2013 12:04:44 +0800 Subject: [PATCH 362/795] Bug 855948 - Network Per-App Metering on FTP Layer. r=mcmanus --- .../protocol/ftp/nsFtpConnectionThread.cpp | 82 ++++++++++++++++++- netwerk/protocol/ftp/nsFtpConnectionThread.h | 25 +++++- 2 files changed, 102 insertions(+), 5 deletions(-) diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index 0f1db60cbf2b..62af781d5b01 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -43,6 +43,10 @@ #include "nsIURI.h" #include "nsICacheSession.h" +#ifdef MOZ_WIDGET_GONK +#include "nsINetworkStatsServiceProxy.h" +#endif + #if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; #endif @@ -1684,9 +1688,12 @@ nsFtpState::Init(nsFtpChannel *channel) mChannel = channel; // a straight ref ptr to the channel + // initialize counter for network metering + mCountRecv = 0; + mKeepRunning = true; mSuppliedEntityID = channel->EntityID(); - + if (channel->UploadStream()) mAction = PUT; @@ -2176,13 +2183,79 @@ nsFtpState::ReadSegments(nsWriteSegmentFun writer, void *closure, if (mDataStream) { nsWriteSegmentThunk thunk = { this, writer, closure }; - return mDataStream->ReadSegments(NS_WriteSegmentThunk, &thunk, count, - result); + nsresult rv; + rv = mDataStream->ReadSegments(NS_WriteSegmentThunk, &thunk, count, + result); + if (NS_SUCCEEDED(rv)) { + CountRecvBytes(*result); + } + return rv; } return nsBaseContentStream::ReadSegments(writer, closure, count, result); } +nsresult +nsFtpState::SaveNetworkStats(bool enforce) +{ +#ifdef MOZ_WIDGET_GONK + MOZ_ASSERT(NS_IsMainThread()); + + // Obtain active network + nsresult rv; + if (!mActiveNetwork) { + nsCOMPtr networkManager = + do_GetService("@mozilla.org/network/manager;1", &rv); + + if (NS_FAILED(rv) || !networkManager) { + mActiveNetwork = nullptr; + return rv; + } + + networkManager->GetActive(getter_AddRefs(mActiveNetwork)); + } + + // Obtain app id + uint32_t appId; + bool isInBrowser; + NS_GetAppInfo(mChannel, &appId, &isInBrowser); + + // Check if active network and appid are valid. + if (!mActiveNetwork || appId == NECKO_NO_APP_ID) { + return NS_OK; + } + + if (mCountRecv <= 0) { + // There is no traffic, no need to save. + return NS_OK; + } + + // If |enforce| is false, the traffic amount is saved + // only when the total amount exceeds the predefined + // threshold. + if (!enforce && mCountRecv < NETWORK_STATS_THRESHOLD) { + return NS_OK; + } + + nsCOMPtr networkStatsServiceProxy = + do_GetService("@mozilla.org/networkstatsServiceProxy;1", &rv); + if (NS_FAILED(rv)) { + return rv; + } + + networkStatsServiceProxy->SaveAppStats(appId, mActiveNetwork, + PR_Now() / 1000, mCountRecv, + 0, nullptr); + + // Reset the counters after saving. + mCountRecv = 0; + + return NS_OK; +#else + return NS_ERROR_NOT_IMPLEMENTED; +#endif +} + NS_IMETHODIMP nsFtpState::CloseWithStatus(nsresult status) { @@ -2202,6 +2275,9 @@ nsFtpState::CloseWithStatus(nsresult status) } if (mDataTransport) { + // Save the network stats before data transport is closing. + SaveNetworkStats(true); + // Shutdown the data transport. mDataTransport->Close(NS_ERROR_ABORT); mDataTransport = nullptr; diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.h b/netwerk/protocol/ftp/nsFtpConnectionThread.h index 0d90c74b3bb6..ccb6a392f78f 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.h @@ -18,6 +18,10 @@ #include "nsFtpControlConnection.h" #include "nsIProtocolProxyCallback.h" +#ifdef MOZ_WIDGET_GONK +#include "nsINetworkManager.h" +#endif + // ftp server types #define FTP_GENERIC_TYPE 0 #define FTP_UNIX_TYPE 1 @@ -239,7 +243,7 @@ private: nsCOMPtr mUploadRequest; bool mAddressChecked; bool mServerIsIPv6; - + static uint32_t mSessionStartTime; mozilla::net::NetAddr mServerAddress; @@ -250,11 +254,28 @@ private: nsCOMPtr mCacheEntry; bool mDoomCache; - + nsCString mSuppliedEntityID; nsCOMPtr mProxyRequest; bool mDeferredCallbackPending; + +// These members are used for network per-app metering (bug 855948) +// Currently, they are only available on gonk. +public: + const static uint64_t NETWORK_STATS_THRESHOLD = 65536; + +private: + uint64_t mCountRecv; +#ifdef MOZ_WIDGET_GONK + nsCOMPtr mActiveNetwork; +#endif + nsresult SaveNetworkStats(bool); + void CountRecvBytes(uint64_t recvBytes) + { + mCountRecv += recvBytes; + SaveNetworkStats(false); + } }; #endif //__nsFtpState__h_ From 6ce9a87ec5cc5b8c4d3d2dd6e1bac6ed006c9e1b Mon Sep 17 00:00:00 2001 From: Chia-hung Tai Date: Thu, 31 Oct 2013 17:20:00 +0800 Subject: [PATCH 363/795] Bug 914060 - [B2G][Helix][message][zhaotao] Wired combination algorithm when handling sending sms to different phone numbers:phonebook digits match not work. r=vyang --- .../src/gonk/MobileMessageDatabaseService.js | 334 +++++++++++++++--- .../tests/marionette/test_getthreads.js | 30 ++ dom/phonenumberutils/PhoneNumberUtils.jsm | 4 + 3 files changed, 310 insertions(+), 58 deletions(-) diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index 77a9d5089e48..2b0a55b974a5 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -24,7 +24,7 @@ const DISABLE_MMS_GROUPING_FOR_RECEIVING = true; const DB_NAME = "sms"; -const DB_VERSION = 13; +const DB_VERSION = 14; const MESSAGE_STORE_NAME = "sms"; const THREAD_STORE_NAME = "thread"; const PARTICIPANT_STORE_NAME = "participant"; @@ -222,6 +222,10 @@ MobileMessageDatabaseService.prototype = { self.upgradeSchema12(event.target.transaction, next); break; case 13: + if (DEBUG) debug("Upgrade to version 14. Fix the wrong participants."); + self.upgradeSchema13(event.target.transaction, next); + break; + case 14: // This will need to be moved for each new version if (DEBUG) debug("Upgrade finished."); break; @@ -835,6 +839,233 @@ MobileMessageDatabaseService.prototype = { }; }, + /** + * Fix the wrong participants. + */ + upgradeSchema13: function upgradeSchema13(transaction, next) { + let participantStore = transaction.objectStore(PARTICIPANT_STORE_NAME); + let threadStore = transaction.objectStore(THREAD_STORE_NAME); + let messageStore = transaction.objectStore(MESSAGE_STORE_NAME); + let self = this; + + let isInvalid = function (participantRecord) { + let entries = []; + for (let addr of participantRecord.addresses) { + entries.push({ + normalized: addr, + parsed: PhoneNumberUtils.parseWithMCC(addr, null) + }) + } + for (let ix = 0 ; ix < entries.length - 1; ix++) { + let entry1 = entries[ix]; + for (let iy = ix + 1 ; iy < entries.length; iy ++) { + let entry2 = entries[iy]; + if (!self.matchPhoneNumbers(entry1.normalized, entry1.parsed, + entry2.normalized, entry2.parsed)) { + return true; + } + } + } + return false; + }; + + let invalidParticipantIds = []; + participantStore.openCursor().onsuccess = function(event) { + let cursor = event.target.result; + if (cursor) { + let participantRecord = cursor.value; + // Check if this participant record is valid + if (isInvalid(participantRecord)) { + invalidParticipantIds.push(participantRecord.id); + cursor.delete(); + } + cursor.continue(); + return; + } + + // Participant store cursor iteration done. + if (!invalidParticipantIds.length) { + next(); + } + + // Find affected thread. + let wrongThreads = []; + threadStore.openCursor().onsuccess = function(event) { + let threadCursor = event.target.result; + if (threadCursor) { + let threadRecord = threadCursor.value; + let participantIds = threadRecord.participantIds; + let foundInvalid = false; + for (let invalidParticipantId of invalidParticipantIds) { + if (participantIds.indexOf(invalidParticipantId) != -1) { + foundInvalid = true; + break; + } + } + if (foundInvalid) { + wrongThreads.push(threadRecord.id); + threadCursor.delete(); + } + threadCursor.continue(); + return; + } + + if (!wrongThreads.length) { + next(); + return; + } + // Use recursive function to avoid we add participant twice. + (function createUpdateThreadAndParticipant(ix) { + let threadId = wrongThreads[ix]; + let range = IDBKeyRange.bound([threadId, 0], [threadId, ""]); + messageStore.index("threadId").openCursor(range).onsuccess = function(event) { + let messageCursor = event.target.result; + if (!messageCursor) { + ix++; + if (ix === wrongThreads.length) { + next(); + return; + } + createUpdateThreadAndParticipant(ix); + return; + } + + let messageRecord = messageCursor.value; + let timestamp = messageRecord.timestamp; + let threadParticipants = []; + // Recaculate the thread participants of received message. + if (messageRecord.delivery === DELIVERY_RECEIVED || + messageRecord.delivery === DELIVERY_NOT_DOWNLOADED) { + threadParticipants.push(messageRecord.sender); + if (messageRecord.type == "mms") { + this.fillReceivedMmsThreadParticipants(messageRecord, threadParticipants); + } + } + // Recaculate the thread participants of sent messages and error + // messages. In error sms messages, we don't have error received sms. + // In received MMS, we don't update the error to deliver field but + // deliverStatus. So we only consider sent message in DELIVERY_ERROR. + else if (messageRecord.delivery === DELIVERY_SENT || + messageRecord.delivery === DELIVERY_ERROR) { + if (messageRecord.type == "sms") { + threadParticipants = [messageRecord.receiver]; + } else if (messageRecord.type == "mms") { + threadParticipants = messageRecord.receivers; + } + } + self.findThreadRecordByParticipants(threadStore, participantStore, + threadParticipants, true, + function (threadRecord, + participantIds) { + if (!participantIds) { + debug("participantIds is empty!"); + return; + } + + let timestamp = messageRecord.timestamp; + // Setup participantIdsIndex. + messageRecord.participantIdsIndex = []; + for each (let id in participantIds) { + messageRecord.participantIdsIndex.push([id, timestamp]); + } + if (threadRecord) { + let needsUpdate = false; + + if (threadRecord.lastTimestamp <= timestamp) { + threadRecord.lastTimestamp = timestamp; + threadRecord.subject = messageRecord.body; + threadRecord.lastMessageId = messageRecord.id; + threadRecord.lastMessageType = messageRecord.type; + needsUpdate = true; + } + + if (!messageRecord.read) { + threadRecord.unreadCount++; + needsUpdate = true; + } + + if (needsUpdate) { + threadStore.put(threadRecord); + } + messageRecord.threadId = threadRecord.id; + messageRecord.threadIdIndex = [threadRecord.id, timestamp]; + messageCursor.update(messageRecord); + messageCursor.continue(); + return; + } + + let threadRecord = { + participantIds: participantIds, + participantAddresses: threadParticipants, + lastMessageId: messageRecord.id, + lastTimestamp: timestamp, + subject: messageRecord.body, + unreadCount: messageRecord.read ? 0 : 1, + lastMessageType: messageRecord.type + }; + threadStore.add(threadRecord).onsuccess = function (event) { + let threadId = event.target.result; + // Setup threadId & threadIdIndex. + messageRecord.threadId = threadId; + messageRecord.threadIdIndex = [threadId, timestamp]; + messageCursor.update(messageRecord); + messageCursor.continue(); + }; + }); + }; + })(0); + }; + }; + }, + + matchParsedPhoneNumbers: function matchParsedPhoneNumbers(addr1, parsedAddr1, + addr2, parsedAddr2) { + if ((parsedAddr1.internationalNumber && + parsedAddr1.internationalNumber === parsedAddr2.internationalNumber) || + (parsedAddr1.nationalNumber && + parsedAddr1.nationalNumber === parsedAddr2.nationalNumber)) { + return true; + } + + if (parsedAddr1.countryName != parsedAddr2.countryName) { + return false; + } + + let ssPref = "dom.phonenumber.substringmatching." + parsedAddr1.countryName; + if (Services.prefs.getPrefType(ssPref) != Ci.nsIPrefBranch.PREF_INT) { + return false; + } + + let val = Services.prefs.getIntPref(ssPref); + return addr1.length > val && + addr2.length > val && + addr1.slice(-val) === addr2.slice(-val); + }, + + matchPhoneNumbers: function matchPhoneNumbers(addr1, parsedAddr1, addr2, parsedAddr2) { + if (parsedAddr1 && parsedAddr2) { + return this.matchParsedPhoneNumbers(addr1, parsedAddr1, addr2, parsedAddr2); + } + + if (parsedAddr1) { + parsedAddr2 = PhoneNumberUtils.parseWithCountryName(addr2, parsedAddr1.countryName); + if (parsedAddr2) { + return this.matchParsedPhoneNumbers(addr1, parsedAddr1, addr2, parsedAddr2); + } + + return false; + } + + if (parsedAddr2) { + parsedAddr1 = PhoneNumberUtils.parseWithCountryName(addr1, parsedAddr2.countryName); + if (parsedAddr1) { + return this.matchParsedPhoneNumbers(addr1, parsedAddr1, addr2, parsedAddr2); + } + } + + return false; + }, + createDomMessageFromRecord: function createDomMessageFromRecord(aMessageRecord) { if (DEBUG) { debug("createDomMessageFromRecord: " + JSON.stringify(aMessageRecord)); @@ -984,31 +1215,13 @@ MobileMessageDatabaseService.prototype = { let participantRecord = cursor.value; for (let storedAddress of participantRecord.addresses) { - let match = false; - if (parsedAddress) { - // 2-1) If input number is an international one, then a potential - // participant must be stored as local type. Then just check - // if stored number ends with the national number(987654321) of - // the input number. - if (storedAddress.endsWith(parsedAddress.nationalNumber)) { - match = true; - } - } else { - // 2-2) Else if the stored number is an international one, then the - // input number must be local type. Then just check whether - // does it ends with the national number of the stored number. - let parsedStoredAddress = - PhoneNumberUtils.parseWithMCC(storedAddress, null); - if (parsedStoredAddress - && normalizedAddress.endsWith(parsedStoredAddress.nationalNumber)) { - match = true; - } - } + let parsedStoredAddress = PhoneNumberUtils.parseWithMCC(storedAddress, null); + let match = this.matchPhoneNumbers(normalizedAddress, parsedAddress, + storedAddress, parsedStoredAddress); if (!match) { // 3) Else we fail to match current stored participant record. continue; } - // Match! if (aCreate) { // In a READ-WRITE transaction, append one more possible address for @@ -1017,6 +1230,7 @@ MobileMessageDatabaseService.prototype = { participantRecord.addresses.concat(allPossibleAddresses); cursor.update(participantRecord); } + if (DEBUG) { debug("findParticipantRecordByAddress: match " + JSON.stringify(cursor.value)); @@ -1385,6 +1599,44 @@ MobileMessageDatabaseService.prototype = { }); }, + fillReceivedMmsThreadParticipants: function fillReceivedMmsThreadParticipants(aMessage, threadParticipants) { + let receivers = aMessage.receivers; + // If we don't want to disable the MMS grouping for receiving, we need to + // add the receivers (excluding the user's own number) to the participants + // for creating the thread. Some cases might be investigated as below: + // + // 1. receivers.length == 0 + // This usually happens when receiving an MMS notification indication + // which doesn't carry any receivers. + // 2. receivers.length == 1 + // If the receivers contain single phone number, we don't need to + // add it into participants because we know that number is our own. + // 3. receivers.length >= 2 + // If the receivers contain multiple phone numbers, we need to add all + // of them but not the user's own number into participants. + if (DISABLE_MMS_GROUPING_FOR_RECEIVING || receivers.length < 2) { + return; + } + let isSuccess = false; + let slicedReceivers = receivers.slice(); + if (aMessage.msisdn) { + let found = slicedReceivers.indexOf(aMessage.msisdn); + if (found !== -1) { + isSuccess = true; + slicedReceivers.splice(found, 1); + } + } + + if (!isSuccess) { + // For some SIMs we cannot retrieve the vaild MSISDN (i.e. the user's + // own phone number), so we cannot correcly exclude the user's own + // number from the receivers, thus wrongly building the thread index. + if (DEBUG) debug("Error! Cannot strip out user's own phone number!"); + } + + threadParticipants = threadParticipants.concat(slicedReceivers); + }, + /** * nsIRilMobileMessageDatabaseService API */ @@ -1404,42 +1656,8 @@ MobileMessageDatabaseService.prototype = { return; } let threadParticipants = [aMessage.sender]; - if (aMessage.type == "mms" && !DISABLE_MMS_GROUPING_FOR_RECEIVING) { - let receivers = aMessage.receivers; - // If we don't want to disable the MMS grouping for receiving, we need to - // add the receivers (excluding the user's own number) to the participants - // for creating the thread. Some cases might be investigated as below: - // - // 1. receivers.length == 0 - // This usually happens when receiving an MMS notification indication - // which doesn't carry any receivers. - // 2. receivers.length == 1 - // If the receivers contain single phone number, we don't need to - // add it into participants because we know that number is our own. - // 3. receivers.length >= 2 - // If the receivers contain multiple phone numbers, we need to add all - // of them but not the user's own number into participants. - if (receivers.length >= 2) { - let isSuccess = false; - let slicedReceivers = receivers.slice(); - if (aMessage.phoneNumber) { - let found = slicedReceivers.indexOf(aMessage.phoneNumber); - if (found !== -1) { - isSuccess = true; - slicedReceivers.splice(found, 1); - } - } - - if (!isSuccess) { - // For some SIMs we cannot retrieve the vaild MSISDN or MDN (i.e. the - // user's own phone number), so we cannot correcly exclude the user's - // own number from the receivers, thus wrongly building the thread - // index. - if (DEBUG) debug("Error! Cannot strip out user's own phone number!"); - } - - threadParticipants = threadParticipants.concat(slicedReceivers); - } + if (aMessage.type == "mms") { + this.fillReceivedMmsThreadParticipants(aMessage, threadParticipants); } let timestamp = aMessage.timestamp; diff --git a/dom/mobilemessage/tests/marionette/test_getthreads.js b/dom/mobilemessage/tests/marionette/test_getthreads.js index 82c28a1409f5..737667bbb316 100644 --- a/dom/mobilemessage/tests/marionette/test_getthreads.js +++ b/dom/mobilemessage/tests/marionette/test_getthreads.js @@ -344,6 +344,36 @@ checkFuncs.push(checkThread.bind(null, ["thread 14-1", "thread 14-2", "thread 14-3"], "thread 14-3", 0, ["5555211014"])); +//[Thread 15] +//Three sent message, unreadCount = 0; +//One participant but might be merged to 555211015, participants = ["5555211015"]. +tasks.push(sendMessage.bind(null, "5555211015", "thread 15-1")); +checkFuncs.push(checkThread.bind(null, ["thread 15-1"], + "thread 15-1", 0, ["5555211015"])); + +//[Thread 16] +//Three sent message, unreadCount = 0; +//One participant but might be merged to 5555211015, participants = ["555211015"]. +tasks.push(sendMessage.bind(null, "555211015", "thread 16-1")); +checkFuncs.push(checkThread.bind(null, ["thread 16-1"], + "thread 16-1", 0, ["555211015"])); + +//[Thread 17] +//Three sent message, unreadCount = 0; +//One participant with two aliased addresses, participants = ["555211017"]. +tasks.push(sendMessage.bind(null, "+5511555211017", "thread 17-1")); +tasks.push(sendMessage.bind(null, "555211017", "thread 17-2")); +checkFuncs.push(checkThread.bind(null, ["thread 17-1", "thread 17-2"], + "thread 17-2", 0, ["+5511555211017"])); + +//[Thread 18] +//Three sent message, unreadCount = 0; +//One participant with two aliased addresses, participants = ["555211018"]. +tasks.push(sendMessage.bind(null, "555211018", "thread 18-1")); +tasks.push(sendMessage.bind(null, "+5511555211018", "thread 18-2")); +checkFuncs.push(checkThread.bind(null, ["thread 18-1", "thread 18-2"], + "thread 18-2", 0, ["555211018"])); + // Check threads. tasks.push(getAllThreads.bind(null, function (threads) { is(threads.length, checkFuncs.length, "number of threads got"); diff --git a/dom/phonenumberutils/PhoneNumberUtils.jsm b/dom/phonenumberutils/PhoneNumberUtils.jsm index 377d29bbcfe6..7bccca3c0d16 100644 --- a/dom/phonenumberutils/PhoneNumberUtils.jsm +++ b/dom/phonenumberutils/PhoneNumberUtils.jsm @@ -132,6 +132,10 @@ this.PhoneNumberUtils = { return PhoneNumber.Parse(aNumber, countryName); }, + parseWithCountryName: function(aNumber, countryName) { + return PhoneNumber.Parse(aNumber, countryName); + }, + isPlainPhoneNumber: function isPlainPhoneNumber(aNumber) { var isPlain = PhoneNumber.IsPlain(aNumber); if (DEBUG) debug("isPlain(" + aNumber + ") " + isPlain); From 416a53a647e776c5d96c1a917dc920d78a539ae2 Mon Sep 17 00:00:00 2001 From: Kai-Zhen Li Date: Thu, 31 Oct 2013 20:05:08 +0800 Subject: [PATCH 364/795] Bug 916033 - Add a new status 'applied-os' for nsIUpdateService. r=rstrong --- b2g/components/UpdatePrompt.js | 41 ++------------ toolkit/mozapps/update/nsIUpdateService.idl | 11 +++- toolkit/mozapps/update/nsUpdateService.js | 62 +++++++++++++++++++++ 3 files changed, 77 insertions(+), 37 deletions(-) diff --git a/b2g/components/UpdatePrompt.js b/b2g/components/UpdatePrompt.js index e41a6e6b5bf2..aa736c196ceb 100644 --- a/b2g/components/UpdatePrompt.js +++ b/b2g/components/UpdatePrompt.js @@ -353,26 +353,14 @@ UpdatePrompt.prototype = { this.restartProcess(); return; } - - let osApplyToDir; + try { - this._update.QueryInterface(Ci.nsIWritablePropertyBag); - osApplyToDir = this._update.getProperty("osApplyToDir"); - } catch (e) {} - - if (!osApplyToDir) { - log("Error: Update has no osApplyToDir"); - return; + Services.aus.applyOsUpdate(this._update); } - - let updateFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); - updateFile.initWithPath(osApplyToDir + "/update.zip"); - if (!updateFile.exists()) { - log("Error: FOTA update not found at " + updateFile.path); - return; + catch (e) { + this._update.errorCode = Cr.NS_ERROR_FAILURE; + this.showUpdateError(this._update); } - - this.finishOSUpdate(updateFile.path); }, restartProcess: function UP_restartProcess() { @@ -390,25 +378,6 @@ UpdatePrompt.prototype = { #endif }, - finishOSUpdate: function UP_finishOSUpdate(aOsUpdatePath) { - log("Rebooting into recovery to apply FOTA update: " + aOsUpdatePath); - - try { - let recoveryService = Cc["@mozilla.org/recovery-service;1"] - .getService(Ci.nsIRecoveryService); - recoveryService.installFotaUpdate(aOsUpdatePath); - } catch(e) { - log("Error: Couldn't reboot into recovery to apply FOTA update " + - aOsUpdatePath); - aUpdate = Services.um.activeUpdate; - if (aUpdate) { - aUpdate.errorCode = Cr.NS_ERROR_FAILURE; - aUpdate.statusText = "fota-reboot-failed"; - this.showUpdateError(aUpdate); - } - } - }, - forceUpdateCheck: function UP_forceUpdateCheck() { log("Forcing update check"); diff --git a/toolkit/mozapps/update/nsIUpdateService.idl b/toolkit/mozapps/update/nsIUpdateService.idl index 9123c539f2a2..5e05dfd06975 100644 --- a/toolkit/mozapps/update/nsIUpdateService.idl +++ b/toolkit/mozapps/update/nsIUpdateService.idl @@ -231,6 +231,7 @@ interface nsIUpdate : nsISupports * "pending-service" The update is ready to be applied with the service. * "applying" The update is being applied. * "applied" The update is ready to be switched to. + * "applied-os" The update is OS update and to be installed. * "applied-service" The update is ready to be switched to with the service. * "succeeded" The update was successfully applied. * "download-failed" The update failed to be downloaded. @@ -351,7 +352,7 @@ interface nsIUpdateChecker : nsISupports * background update checks and provides utilities for selecting and * downloading update patches. */ -[scriptable, uuid(579ef84b-3e66-46fb-aeb4-799db5ade506)] +[scriptable, uuid(9f9b51f5-340e-47ce-85ae-9eb077c6cd39)] interface nsIApplicationUpdateService : nsISupports { /** @@ -399,6 +400,14 @@ interface nsIApplicationUpdateService : nsISupports */ AString downloadUpdate(in nsIUpdate update, in boolean background); + /** + * Apply the OS update which has been downloaded and staged as applied. + * @param update + * The update has been downloaded and staged as applied. + * @throws if the update object is not an OS update. + */ + void applyOsUpdate(in nsIUpdate update); + /** * Get the Active Updates directory * @returns An nsIFile for the active updates directory. diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index 319d36aaf6e6..e6475389e9d2 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -118,6 +118,7 @@ const STATE_PENDING = "pending"; const STATE_PENDING_SVC = "pending-service"; const STATE_APPLYING = "applying"; const STATE_APPLIED = "applied"; +const STATE_APPLIED_OS = "applied-os"; const STATE_APPLIED_SVC = "applied-service"; const STATE_SUCCEEDED = "succeeded"; const STATE_DOWNLOAD_FAILED = "download-failed"; @@ -155,6 +156,8 @@ const FOTA_UNKNOWN_ERROR = 45; const WRITE_ERROR_SHARING_VIOLATION_SIGNALED = 46; const WRITE_ERROR_SHARING_VIOLATION_NOPROCESSFORPID = 47; const WRITE_ERROR_SHARING_VIOLATION_NOPID = 48; +const FOTA_FILE_OPERATION_ERROR = 49; +const FOTA_RECOVERY_ERROR = 50; const CERT_ATTR_CHECK_FAILED_NO_UPDATE = 100; const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101; @@ -1418,6 +1421,8 @@ function readStringFromFile(file) { function handleUpdateFailure(update, errorCode) { update.errorCode = parseInt(errorCode); if (update.errorCode == FOTA_GENERAL_ERROR || + update.errorCode == FOTA_FILE_OPERATION_ERROR || + update.errorCode == FOTA_RECOVERY_ERROR || update.errorCode == FOTA_UNKNOWN_ERROR) { // In the case of FOTA update errors, don't reset the state to pending. This // causes the FOTA update path to try again, which is not necessarily what @@ -2171,7 +2176,13 @@ UpdateService.prototype = { } #ifdef MOZ_WIDGET_GONK + // The update is only applied but not selected to be installed if (status == STATE_APPLIED && update && update.isOSUpdate) { + LOG("UpdateService:_postUpdateProcessing - update staged as applied found"); + return; + } + + if (status == STATE_APPLIED_OS && update && update.isOSUpdate) { // In gonk, we need to check for OS update status after startup, since // the recovery partition won't write to update.status for us var recoveryService = Cc["@mozilla.org/recovery-service;1"]. @@ -3139,6 +3150,52 @@ UpdateService.prototype = { return this._downloader && this._downloader.isBusy; }, + /** + * See nsIUpdateService.idl + */ + applyOsUpdate: function AUS_applyOsUpdate(aUpdate) { + if (!aUpdate.isOSUpdate || aUpdate.state != STATE_APPLIED) { + aUpdate.statusText = "fota-state-error"; + throw Cr.NS_ERROR_FAILURE; + } + + let osApplyToDir; + try { + aUpdate.QueryInterface(Ci.nsIWritablePropertyBag); + osApplyToDir = aUpdate.getProperty("osApplyToDir"); + } catch (e) {} + + if (!osApplyToDir) { + LOG("UpdateService:applyOsUpdate - Error: osApplyToDir is not defined" + + "in the nsIUpdate!"); + handleUpdateFailure(aUpdate, FOTA_FILE_OPERATION_ERROR); + return; + } + + let updateFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); + updateFile.initWithPath(osApplyToDir + "/update.zip"); + if (!updateFile.exists()) { + LOG("UpdateService:applyOsUpdate - Error: OS update is not found at " + + updateFile.path); + handleUpdateFailure(aUpdate, FOTA_FILE_OPERATION_ERROR); + return; + } + + writeStatusFile(getUpdatesDir(), aUpdate.state = STATE_APPLIED_OS); + LOG("UpdateService:applyOsUpdate - Rebooting into recovery to apply " + + "FOTA update: " + updateFile.path); + try { + let recoveryService = Cc["@mozilla.org/recovery-service;1"] + .getService(Ci.nsIRecoveryService); + recoveryService.installFotaUpdate(updateFile.path); + } catch (e) { + LOG("UpdateService:applyOsUpdate - Error: Couldn't reboot into recovery" + + " to apply FOTA update " + updateFile.path); + writeStatusFile(getUpdatesDir(), aUpdate.state = STATE_APPLIED); + handleUpdateFailure(aUpdate, FOTA_RECOVERY_ERROR); + } + }, + classID: UPDATESERVICE_CID, classInfo: XPCOMUtils.generateCI({classID: UPDATESERVICE_CID, contractID: UPDATESERVICE_CONTRACTID, @@ -3948,6 +4005,9 @@ Downloader.prototype = { case STATE_APPLYING: LOG("Downloader:_selectPatch - resuming interrupted apply"); return selectedPatch; + case STATE_APPLIED: + LOG("Downloader:_selectPatch - already downloaded and staged"); + return null; #else case STATE_PENDING_SVC: case STATE_PENDING: @@ -4633,6 +4693,8 @@ UpdatePrompt.prototype = { update.errorCode == WRITE_ERROR_CALLBACK_APP || update.errorCode == FILESYSTEM_MOUNT_READWRITE_ERROR || update.errorCode == FOTA_GENERAL_ERROR || + update.errorCode == FOTA_FILE_OPERATION_ERROR || + update.errorCode == FOTA_RECOVERY_ERROR || update.errorCode == FOTA_UNKNOWN_ERROR)) { var title = gUpdateBundle.GetStringFromName("updaterIOErrorTitle"); var text = gUpdateBundle.formatStringFromName("updaterIOErrorMsg", From 843eb7bd764ac3ce917edc3f11017a7e1fcb2620 Mon Sep 17 00:00:00 2001 From: Tim Chien Date: Thu, 31 Oct 2013 09:46:42 -0400 Subject: [PATCH 365/795] Bug 920977 - Limit the usage of the deprecated mozKeyboard API to certified apps only. r=yxl --- dom/inputmethod/MozKeyboard.js | 5 +++-- dom/permission/tests/test_keyboard.html | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/dom/inputmethod/MozKeyboard.js b/dom/inputmethod/MozKeyboard.js index a6db8548b3e0..2621c6445d19 100644 --- a/dom/inputmethod/MozKeyboard.js +++ b/dom/inputmethod/MozKeyboard.js @@ -42,8 +42,9 @@ MozKeyboard.prototype = { init: function mozKeyboardInit(win) { let principal = win.document.nodePrincipal; - let perm = Services.perms - .testExactPermissionFromPrincipal(principal, "keyboard"); + // Limited the deprecated mozKeyboard API to certified apps only + let perm = Services.perms.testExactPermissionFromPrincipal(principal, + "inputmethod-manage"); if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) { dump("No permission to use the keyboard API for " + principal.origin + "\n"); diff --git a/dom/permission/tests/test_keyboard.html b/dom/permission/tests/test_keyboard.html index bb089edc4afb..09be6f1cc958 100644 --- a/dom/permission/tests/test_keyboard.html +++ b/dom/permission/tests/test_keyboard.html @@ -1,16 +1,16 @@ - Test for Bug 815105 + Test for Bug 920977 -Mozilla Bug 815105 +Mozilla Bug 920977

@@ -19,9 +19,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=815105
 var gData = [
   {
     perm: ["keyboard"],
+    obj: "mozInputMethod",
+    webidl: "MozInputMethod",
+    settings: [["dom.mozInputMethod.enabled", true]],
+  },
+  {
+    perm: ["inputmethod-manage"],
     obj: "mozKeyboard",
     idl: "nsIB2GKeyboard",
-  },
+  }
 ]
 
 
From 28ac01918e5bce8887f2b964218644b4dac454e7 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Thu, 31 Oct 2013 06:50:26 -0700 Subject: [PATCH 366/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/64a10d91715c Author: Zac Desc: Merge pull request #13256 from bebef1987/fix_char Bug 933181 - UnicodeDecodeError in XML report generation ======== https://hg.mozilla.org/integration/gaia-central/rev/68113826d60d Author: Bebe Desc: Bug 933181 - UnicodeDecodeError in XML report generation --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 69bb00de3090..8ee05ae09ced 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "1d433197784273159488c3f049b3e77930bdfc86", + "revision": "64a10d91715c2839b7cb45c92d9a9638dbf086cf", "repo_path": "/integration/gaia-central" } From 1c10dcc0683941bcdf52af8db5a48f39475f18f7 Mon Sep 17 00:00:00 2001 From: Jeff Gilbert Date: Thu, 31 Oct 2013 09:51:47 -0400 Subject: [PATCH 367/795] Bug 922368 - Check for features instead of framebuffer_blit extensions. r=bjacob --- gfx/gl/GLContextUtils.cpp | 17 +++++------------ gfx/gl/GLScreenBuffer.cpp | 3 +-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/gfx/gl/GLContextUtils.cpp b/gfx/gl/GLContextUtils.cpp index 1166d3a5c0d6..81ed1828da0f 100644 --- a/gfx/gl/GLContextUtils.cpp +++ b/gfx/gl/GLContextUtils.cpp @@ -280,8 +280,7 @@ GLContext::BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB, MOZ_ASSERT(!srcFB || fIsFramebuffer(srcFB)); MOZ_ASSERT(!destFB || fIsFramebuffer(destFB)); - MOZ_ASSERT(IsExtensionSupported(EXT_framebuffer_blit) || - IsExtensionSupported(ANGLE_framebuffer_blit)); + MOZ_ASSERT(IsSupported(GLFeature::framebuffer_blit)); ScopedBindFramebuffer boundFB(this); ScopedGLState scissor(this, LOCAL_GL_SCISSOR_TEST, false); @@ -303,10 +302,8 @@ GLContext::BlitFramebufferToFramebuffer(GLuint srcFB, GLuint destFB, { MOZ_ASSERT(!srcFB || fIsFramebuffer(srcFB)); MOZ_ASSERT(!destFB || fIsFramebuffer(destFB)); - - if (IsExtensionSupported(EXT_framebuffer_blit) || - IsExtensionSupported(ANGLE_framebuffer_blit)) - { + + if (IsSupported(GLFeature::framebuffer_blit)) { BlitFramebufferToFramebuffer(srcFB, destFB, srcSize, destSize); return; @@ -330,9 +327,7 @@ GLContext::BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB, MOZ_ASSERT(fIsTexture(srcTex)); MOZ_ASSERT(!destFB || fIsFramebuffer(destFB)); - if (IsExtensionSupported(EXT_framebuffer_blit) || - IsExtensionSupported(ANGLE_framebuffer_blit)) - { + if (IsSupported(GLFeature::framebuffer_blit)) { ScopedFramebufferForTexture srcWrapper(this, srcTex, srcTarget); MOZ_ASSERT(srcWrapper.IsComplete()); @@ -452,9 +447,7 @@ GLContext::BlitFramebufferToTexture(GLuint srcFB, GLuint destTex, MOZ_ASSERT(!srcFB || fIsFramebuffer(srcFB)); MOZ_ASSERT(fIsTexture(destTex)); - if (IsExtensionSupported(EXT_framebuffer_blit) || - IsExtensionSupported(ANGLE_framebuffer_blit)) - { + if (IsSupported(GLFeature::framebuffer_blit)) { ScopedFramebufferForTexture destWrapper(this, destTex, destTarget); BlitFramebufferToFramebuffer(srcFB, destWrapper.FB(), diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp index 6e0b64d6a046..015f63a1afc0 100644 --- a/gfx/gl/GLScreenBuffer.cpp +++ b/gfx/gl/GLScreenBuffer.cpp @@ -336,8 +336,7 @@ GLScreenBuffer::AssureBlitted() MOZ_ASSERT(drawFB != 0); MOZ_ASSERT(drawFB != readFB); - MOZ_ASSERT(mGL->IsExtensionSupported(GLContext::EXT_framebuffer_blit) || - mGL->IsExtensionSupported(GLContext::ANGLE_framebuffer_blit)); + MOZ_ASSERT(mGL->IsSupported(GLFeature::framebuffer_blit)); MOZ_ASSERT(mDraw->Size() == mRead->Size()); ScopedBindFramebuffer boundFB(mGL); From 7c73e41e2de1b2f8a94f746e572259c38e96b3a6 Mon Sep 17 00:00:00 2001 From: Milan Sreckovic Date: Wed, 16 Oct 2013 16:49:27 -0400 Subject: [PATCH 368/795] Bug 922600 - Avoid integer overflow. r=bjacob --- gfx/thebes/gfxXlibSurface.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index b8a62c065795..611d26636b4e 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -17,6 +17,7 @@ #include "nsAlgorithm.h" #include "mozilla/Preferences.h" #include +#include "mozilla/CheckedInt.h" using namespace mozilla; @@ -121,10 +122,22 @@ gfxXlibSurface::TakePixmap() NS_ASSERTION(!mPixmapTaken, "I already own the Pixmap!"); mPixmapTaken = true; + // The bit depth returned from Cairo is technically int, but this is + // the last place we'd be worried about that scenario. + unsigned int bitDepth = cairo_xlib_surface_get_depth(CairoSurface()); + MOZ_ASSERT((bitDepth % 8) == 0, "Memory used not recorded correctly"); + // Divide by 8 because surface_get_depth gives us the number of *bits* per // pixel. - RecordMemoryUsed(mSize.width * mSize.height * - cairo_xlib_surface_get_depth(CairoSurface()) / 8); + CheckedInt32 totalBytes = CheckedInt32(mSize.width) * CheckedInt32(mSize.height) * (bitDepth/8); + + // Don't do anything in the "else" case. We could add INT32_MAX, but that + // would overflow the memory used counter. It would also mean we tried for + // a 2G image. For now, we'll just assert, + MOZ_ASSERT(totalBytes.isValid(),"Did not expect to exceed 2Gb image"); + if (totalBytes.isValid()) { + RecordMemoryUsed(totalBytes.value()); + } } Drawable From f1248858ee81464d84678feaacbc81c791f40baa Mon Sep 17 00:00:00 2001 From: Sam Foster Date: Fri, 1 Nov 2013 15:50:01 -0700 Subject: [PATCH 369/795] Bug 931120 - ease in the tile colors. r=rsilveira --- browser/metro/theme/tiles.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/metro/theme/tiles.css b/browser/metro/theme/tiles.css index af40365ddd1b..a5e7de6efc6c 100644 --- a/browser/metro/theme/tiles.css +++ b/browser/metro/theme/tiles.css @@ -69,7 +69,8 @@ richgriditem { top: 2px; right: @tile_side_margin@; bottom: 10px; left: @tile_side_margin@; border: @metro_border_thin@ solid @tile_border_color@; box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.1); - transition: 150ms transform ease-out; + transition: 150ms transform ease-out, + @metro_animation_duration@ background-color @metro_animation_easing@; } .tile-start-container { @@ -135,6 +136,7 @@ richgriditem[iconsize="large"] .tile-icon-box > image, overflow: hidden; white-space: nowrap; text-overflow: ellipsis; + transition: @metro_animation_duration@ background-color @metro_animation_easing@; } richgriditem:not([tiletype="thumbnail"]) .tile-desc { From 592636cf4eec2b40c39eac7d1fc8e1fb650f1774 Mon Sep 17 00:00:00 2001 From: Rodrigo Silveira Date: Wed, 16 Oct 2013 14:41:42 -0700 Subject: [PATCH 370/795] Bug 919232 - arrow keys not working in form autofill popup r=mbrubeck --HG-- extra : rebase_source : 7cfde9462e86869e032d07b21726c247b1f33f82 --- .../base/content/contenthandlers/Content.js | 13 ++--- .../content/contenthandlers/FormHelper.js | 46 ++++++++++-------- browser/metro/base/content/helperui/MenuUI.js | 47 +++++++++++++++++-- .../base/content/helperui/SelectHelperUI.js | 12 +++-- .../mochitest/browser_form_auto_complete.js | 39 ++++++++++++++- browser/metro/theme/platform.css | 31 +++--------- 6 files changed, 124 insertions(+), 64 deletions(-) diff --git a/browser/metro/base/content/contenthandlers/Content.js b/browser/metro/base/content/contenthandlers/Content.js index 1846e10bd5cf..39fa20c9350d 100644 --- a/browser/metro/base/content/contenthandlers/Content.js +++ b/browser/metro/base/content/contenthandlers/Content.js @@ -169,18 +169,15 @@ let Content = { break; } - case "keydown": - if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) - this.formAssistant.close(); - break; - case "keyup": // If after a key is pressed we still have no input, then close - // the autocomplete. Perhaps the user used backspace or delete. - if (!aEvent.target.value) + // the autocomplete. Perhaps the user used backspace or delete. + // Allow down arrow to trigger autofill popup on empty input. + if ((!aEvent.target.value && aEvent.keyCode != aEvent.DOM_VK_DOWN) + || aEvent.keyCode == aEvent.DOM_VK_ESCAPE) this.formAssistant.close(); else - this.formAssistant.open(aEvent.target); + this.formAssistant.open(aEvent.target, aEvent); break; case "click": diff --git a/browser/metro/base/content/contenthandlers/FormHelper.js b/browser/metro/base/content/contenthandlers/FormHelper.js index f50b92029cce..54337ebb91f2 100644 --- a/browser/metro/base/content/contenthandlers/FormHelper.js +++ b/browser/metro/base/content/contenthandlers/FormHelper.js @@ -35,14 +35,12 @@ function FormAssistant() { * a key is entered on device */ addEventListener("text", this, false); - addEventListener("keypress", this, true); - addEventListener("keyup", this, false); addEventListener("focus", this, true); addEventListener("blur", this, true); addEventListener("pageshow", this, false); addEventListener("pagehide", this, false); addEventListener("submit", this, false); -}; +} FormAssistant.prototype = { _els: Cc["@mozilla.org/eventlistenerservice;1"].getService(Ci.nsIEventListenerService), @@ -103,8 +101,8 @@ FormAssistant.prototype = { return false; } // Don't fire mouse events on selects; see bug 685197. - aEvent.preventDefault() - aEvent.stopPropagation() + aEvent.preventDefault(); + aEvent.stopPropagation(); } // The form assistant will close if a click happen: @@ -130,6 +128,11 @@ FormAssistant.prototype = { return this.close(); } + // Don't re-open when navigating to avoid repopulating list when changing selection. + if (this._isAutocomplete(aElement) && this._open && this._isNavigationKey(aEvent)) { + return false; + } + // Enable the assistant this.currentElement = aElement; return this._open = true; @@ -167,6 +170,7 @@ FormAssistant.prototype = { case "FormAssist:ChoiceChange": { // ChoiceChange could happened once we have move to another element or // to nothing, so we should keep the used wrapper in mind. + this._selectWrapper = getWrapperForElement(currentElement); this._selectWrapper.fireOnChange(); // New elements can be shown when a select is updated so we need to @@ -286,23 +290,25 @@ FormAssistant.prototype = { this._sendJsonMsgWrapper("FormAssist:AutoComplete"); } break; - - case "keyup": - // There is no need to handle keys if there is not element currently - // used by the form assistant - if (!currentElement) - return; - - if (this._isAutocomplete(aEvent.target)) { - this._sendJsonMsgWrapper("FormAssist:AutoComplete"); - } - - let caretRect = this._getCaretRect(); - if (!caretRect.isEmpty()) - sendAsyncMessage("FormAssist:Update", { caretRect: caretRect }); } }, + _isNavigationKey: function (aEvent) { + // Ignore navigation keys + if (aEvent.keyCode) { + let navigationKeys = [ + aEvent.DOM_VK_DOWN, + aEvent.DOM_VK_UP, + aEvent.DOM_VK_LEFT, + aEvent.DOM_VK_RIGHT, + aEvent.DOM_VK_PAGE_UP, + aEvent.DOM_VK_PAGE_DOWN]; + + return navigationKeys.indexOf(aEvent.keyCode) != -1; + } + return false; + }, + _executeDelayed: function formHelperExecuteSoon(aCallback) { let self = this; let timer = new Util.Timeout(function() { @@ -640,7 +646,7 @@ function getListForElement(aElement) { } return result; -}; +} function SelectWrapper(aControl) { diff --git a/browser/metro/base/content/helperui/MenuUI.js b/browser/metro/base/content/helperui/MenuUI.js index e1fcdb38d11b..b98028cbf17d 100644 --- a/browser/metro/base/content/helperui/MenuUI.js +++ b/browser/metro/base/content/helperui/MenuUI.js @@ -49,17 +49,20 @@ var AutofillMenuUI = { }, show: function show(aAnchorRect, aSuggestionsList) { + this.commands.addEventListener("select", this, true); + window.addEventListener("keypress", this, true); + this._anchorRect = aAnchorRect; this._emptyCommands(); for (let idx = 0; idx < aSuggestionsList.length; idx++) { let item = document.createElement("richlistitem"); let label = document.createElement("label"); label.setAttribute("value", aSuggestionsList[idx].label); + item.setAttribute("value", aSuggestionsList[idx].value); item.setAttribute("data", aSuggestionsList[idx].value); item.appendChild(label); this.commands.appendChild(item); } - this._menuPopup.show(this._positionOptions()); }, @@ -69,7 +72,42 @@ var AutofillMenuUI = { }, hide: function hide () { + window.removeEventListener("keypress", this, true); + this.commands.removeEventListener("select", this, true); + this._menuPopup.hide(); + }, + + handleEvent: function (aEvent) { + switch (aEvent.type) { + case "keypress": + switch (aEvent.keyCode) { + case aEvent.DOM_VK_ESCAPE: + this.hide(); + break; + + case aEvent.DOM_VK_DOWN: + this.commands.moveByOffset(1, true, false); + break; + + case aEvent.DOM_VK_UP: + this.commands.moveByOffset(-1, true, false); + break; + + case aEvent.DOM_VK_PAGE_DOWN: + this.commands.moveByOffset(this.commands.scrollOnePage(1), true, false); + break; + + case aEvent.DOM_VK_PAGE_UP: + this.commands.moveByOffset(this.commands.scrollOnePage(-1), true, false); + break; + } + break; + + case "select": + FormHelperUI.doAutoComplete(this.commands.value); + break; + } } }; @@ -346,9 +384,7 @@ MenuPopup.prototype = { get commands() { return this._popup.childNodes[0]; }, show: function (aPositionOptions) { - if (this.visible) { - this._animateHide().then(() => this._animateShow(aPositionOptions)); - } else { + if (!this.visible) { this._animateShow(aPositionOptions); } }, @@ -428,6 +464,7 @@ MenuPopup.prototype = { window.addEventListener("mousedown", this, true); window.addEventListener("touchstart", this, true); window.addEventListener("scroll", this, true); + window.addEventListener("blur", this, true); Elements.stack.addEventListener("PopupChanged", this, false); this._panel.hidden = false; @@ -458,6 +495,7 @@ MenuPopup.prototype = { window.removeEventListener("mousedown", this, true); window.removeEventListener("touchstart", this, true); window.removeEventListener("scroll", this, true); + window.removeEventListener("blur", this, true); Elements.stack.removeEventListener("PopupChanged", this, false); let self = this; @@ -494,6 +532,7 @@ MenuPopup.prototype = { this.hide(); } break; + case "blur": case "mousedown": case "touchstart": case "scroll": diff --git a/browser/metro/base/content/helperui/SelectHelperUI.js b/browser/metro/base/content/helperui/SelectHelperUI.js index 3fa455ec55d2..c6d541a6b6b2 100644 --- a/browser/metro/base/content/helperui/SelectHelperUI.js +++ b/browser/metro/base/content/helperui/SelectHelperUI.js @@ -43,15 +43,17 @@ var SelectHelperUI = { let choices = aList.choices; for (let i = 0; i < choices.length; i++) { let choice = choices[i]; - let item = document.createElement("listitem"); + let item = document.createElement("richlistitem"); + let label = document.createElement("label"); - item.setAttribute("class", "option-command listitem-iconic action-button"); + item.setAttribute("class", "option-command listitem-iconic"); item.setAttribute("flex", "1"); item.setAttribute("crop", "center"); - item.setAttribute("label", choice.text); + label.setAttribute("value", choice.text); + item.appendChild(label); - choice.selected ? item.classList.add("selected") - : item.classList.remove("selected"); + choice.selected ? item.setAttribute("selected", "true") + : item.removeAttribute("selected"); choice.disabled ? item.setAttribute("disabled", "true") : item.removeAttribute("disabled"); diff --git a/browser/metro/base/tests/mochitest/browser_form_auto_complete.js b/browser/metro/base/tests/mochitest/browser_form_auto_complete.js index f61a48f7f407..14587e2fe5ab 100644 --- a/browser/metro/base/tests/mochitest/browser_form_auto_complete.js +++ b/browser/metro/base/tests/mochitest/browser_form_auto_complete.js @@ -10,12 +10,12 @@ function clearFormHistory() { } function test() { - clearFormHistory(); runTests(); clearFormHistory(); } function setUp() { + clearFormHistory(); PanelUI.hide(); yield hideContextUI(); } @@ -84,4 +84,39 @@ gTests.push({ checkAutofillMenuItemContents(["hellothere", "one", "two", "three", "four", "five"]); } -}); \ No newline at end of file +}); + +gTests.push({ + desc: "Test autocomplete selection with arrow key.", + setUp: setUp, + tearDown: tearDown, + run: function () { + + let newTab = yield addTab(chromeRoot + "browser_form_auto_complete.html"); + yield waitForCondition(function () { + return !Browser.selectedTab.isLoading(); + }); + + let tabDocument = newTab.browser.contentWindow.document; + let input = tabDocument.getElementById("textedit1"); + input.focus(); + + let shownPromise = waitForEvent(document, "popupshown"); + EventUtils.synthesizeKey("o", {}, window); + yield shownPromise; + + EventUtils.synthesizeKey("VK_DOWN", {}, window); + + yield waitForCondition(() => input.value == "one"); + + is(input.value, "one", "Input updated correctly"); + + EventUtils.synthesizeKey("VK_DOWN", {}, window); + + yield waitForCondition(() => input.value == "two"); + + is(input.value, "two", "Input updated correctly"); + + Browser.closeTab(newTab, { forceClose: true }); + } +}); diff --git a/browser/metro/theme/platform.css b/browser/metro/theme/platform.css index 5137dd7ebdef..e792321c7de6 100644 --- a/browser/metro/theme/platform.css +++ b/browser/metro/theme/platform.css @@ -197,16 +197,6 @@ menulist { font-weight: 600; } -.menu-popup richlistitem:not([disabled]):hover { - background-color: #ccc; - color: black; -} - -.menu-popup richlistitem:not([disabled]):active { - background-color: black; - color: white; -} - .menu-popup > richlistbox > richlistitem { padding-right: 50px; } @@ -251,16 +241,6 @@ menulist { pointer-events: none; } -.option-command:not([disabled]):hover { - background-color: #f0f0f0; - color: black; -} - -.option-command:not([disabled]):active { - background-color: #d3d3d3; - color: black; -} - .select-popup > richlistbox > scrollbox { width: 100%; overflow-x: hidden !important; @@ -404,13 +384,14 @@ richlistitem description.normal-bold { font-weight: bold; } -richlistitem[selected] { - color: black; - background-color: white; +richlistitem[selected], +richlistitem:not([disabled]):not([selected]):active { + background-color: @metro_orange@; + color: #fff; } -richlistitem:hover:active:not([selected]) { - background-color: #8db8d8; +richlistitem:not([disabled]):not([selected]):hover { + background-color: #ccc; } richlistitem.section-header, From 91224f89574810c974d2d1db88cc84186c2d1f19 Mon Sep 17 00:00:00 2001 From: Chris Manchester Date: Tue, 29 Oct 2013 17:35:31 -0400 Subject: [PATCH 371/795] Bug 885480 - Set becauseNoSuchFile on windows for osfile errors produced as a result of no such directory. r=yoric --- .../osfile/modules/osfile_win_allthreads.jsm | 3 +- .../tests/mochi/main_test_osfile_async.js | 45 ----------- .../osfile/tests/xpcshell/test_open.js | 75 +++++++++++++++++++ .../osfile/tests/xpcshell/xpcshell.ini | 1 + 4 files changed, 78 insertions(+), 46 deletions(-) create mode 100644 toolkit/components/osfile/tests/xpcshell/test_open.js diff --git a/toolkit/components/osfile/modules/osfile_win_allthreads.jsm b/toolkit/components/osfile/modules/osfile_win_allthreads.jsm index 65eab49fa7c5..a1f4bbb11758 100644 --- a/toolkit/components/osfile/modules/osfile_win_allthreads.jsm +++ b/toolkit/components/osfile/modules/osfile_win_allthreads.jsm @@ -134,7 +134,8 @@ Object.defineProperty(OSError.prototype, "becauseExists", { */ Object.defineProperty(OSError.prototype, "becauseNoSuchFile", { get: function becauseNoSuchFile() { - return this.winLastError == Const.ERROR_FILE_NOT_FOUND; + return this.winLastError == Const.ERROR_FILE_NOT_FOUND || + this.winLastError == Const.ERROR_PATH_NOT_FOUND; } }); /** diff --git a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js index 59ceddf36ae3..b363caae4fd1 100644 --- a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js +++ b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js @@ -151,7 +151,6 @@ let test = maketest("Main", function main(test) { SimpleTest.waitForExplicitFinish(); yield test_constants(); yield test_path(); - yield test_open(); yield test_stat(); yield test_debug(); yield test_info_features_detect(); @@ -199,50 +198,6 @@ let test_path = maketest("path", function path(test) { }); }); -/** - * Test OS.File.open for reading: - * - with an existing file (should succeed); - * - with a non-existing file (should fail); - * - with inconsistent arguments (should fail). - */ -let test_open = maketest("open", function open(test) { - return Task.spawn(function() { - // Attempt to open a file that does not exist, ensure that it yields the - // appropriate error. - try { - let fd = yield OS.File.open(OS.Path.join(".", "This file does not exist")); - test.ok(false, "File opening 1 succeeded (it should fail)" + fd); - } catch (err) { - test.ok(true, "File opening 1 failed " + err); - test.ok(err instanceof OS.File.Error, "File opening 1 returned a file error"); - test.ok(err.becauseNoSuchFile, "File opening 1 informed that the file does not exist"); - } - - // Attempt to open a file with the wrong args, so that it fails before - // serialization, ensure that it yields the appropriate error. - test.info("Attempting to open a file with wrong arguments"); - try { - let fd = yield OS.File.open(1, 2, 3); - test.ok(false, "File opening 2 succeeded (it should fail)" + fd); - } catch (err) { - test.ok(true, "File opening 2 failed " + err); - test.ok(!(err instanceof OS.File.Error), "File opening 2 returned something that is not a file error"); - test.ok(err.constructor.name == "TypeError", "File opening 2 returned a TypeError"); - } - - // Attempt to open a file correctly - test.info("Attempting to open a file correctly"); - let openedFile = yield OS.File.open(EXISTING_FILE); - test.ok(true, "File opened correctly"); - - test.info("Attempting to close a file correctly"); - yield openedFile.close(); - - test.info("Attempting to close a file again"); - yield openedFile.close(); - }); -}); - /** * Test OS.File.stat and OS.File.prototype.stat */ diff --git a/toolkit/components/osfile/tests/xpcshell/test_open.js b/toolkit/components/osfile/tests/xpcshell/test_open.js new file mode 100644 index 000000000000..8d5470eab3bd --- /dev/null +++ b/toolkit/components/osfile/tests/xpcshell/test_open.js @@ -0,0 +1,75 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +Components.utils.import("resource://gre/modules/osfile.jsm"); + +function run_test() { + do_test_pending(); + run_next_test(); +} + +/** + * Test OS.File.open for reading: + * - with an existing file (should succeed); + * - with a non-existing file (should fail); + * - with inconsistent arguments (should fail). + */ +add_task(function() { + // Attempt to open a file that does not exist, ensure that it yields the + // appropriate error. + try { + let fd = yield OS.File.open(OS.Path.join(".", "This file does not exist")); + do_check_true(false, "File opening 1 succeeded (it should fail)"); + } catch (err if err instanceof OS.File.Error && err.becauseNoSuchFile) { + do_print("File opening 1 failed " + err); + } + + // Attempt to open a file with the wrong args, so that it fails before + // serialization, ensure that it yields the appropriate error. + do_print("Attempting to open a file with wrong arguments"); + try { + let fd = yield OS.File.open(1, 2, 3); + do_check_true(false, "File opening 2 succeeded (it should fail)" + fd); + } catch (err) { + do_print("File opening 2 failed " + err); + do_check_false(err instanceof OS.File.Error, + "File opening 2 returned something that is not a file error"); + do_check_true(err.constructor.name == "TypeError", + "File opening 2 returned a TypeError"); + } + + // Attempt to open a file correctly + do_print("Attempting to open a file correctly"); + let openedFile = yield OS.File.open(OS.Path.join(do_get_cwd().path, "test_open.js")); + do_print("File opened correctly"); + + do_print("Attempting to close a file correctly"); + yield openedFile.close(); + + do_print("Attempting to close a file again"); + yield openedFile.close(); +}); + +/** + * Test the error thrown by OS.File.open when attempting to open a directory + * that does not exist. + */ +add_task(function test_error_attributes () { + + let dir = OS.Path.join(do_get_profile().path, "test_osfileErrorAttrs"); + let fpath = OS.Path.join(dir, "test_error_attributes.txt"); + + try { + yield OS.File.open(fpath, {truncate: true}, {}); + do_check_true(false, "Opening path suceeded (it should fail) " + fpath); + } catch (err) { + do_check_true(err instanceof OS.File.Error); + do_check_true(err.becauseNoSuchFile); + } +}); + +add_task(function() { + do_test_finished(); +}); diff --git a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini index dd0f67ff7efb..1c6933cdf1bc 100644 --- a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini +++ b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini @@ -19,3 +19,4 @@ tail = [test_reset.js] [test_shutdown.js] [test_unique.js] +[test_open.js] From 00921477be98b58eabe549d41532e32a8da75565 Mon Sep 17 00:00:00 2001 From: Will Nayes Date: Thu, 31 Oct 2013 22:51:48 -0400 Subject: [PATCH 372/795] Bug 909249 - Fix checkmark in Netmonitor Header. r=robcee --- browser/devtools/netmonitor/netmonitor.xul | 2 +- browser/locales/en-US/chrome/browser/devtools/netmonitor.dtd | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/browser/devtools/netmonitor/netmonitor.xul b/browser/devtools/netmonitor/netmonitor.xul index c373577fdefb..47d12b7d08ce 100644 --- a/browser/devtools/netmonitor/netmonitor.xul +++ b/browser/devtools/netmonitor/netmonitor.xul @@ -49,7 +49,7 @@
+
+ +

acorn License

+ +

This license applies to all files in + toolkit/devtools/acorn. +

+
+Copyright (C) 2012 by Marijn Haverbeke <marijnh@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+Please note that some subdirectories of the CodeMirror distribution
+include their own LICENSE files, and are released under different
+licences.
+
+
diff --git a/toolkit/devtools/Loader.jsm b/toolkit/devtools/Loader.jsm index 64e6f644690b..6b68aeae508b 100644 --- a/toolkit/devtools/Loader.jsm +++ b/toolkit/devtools/Loader.jsm @@ -65,6 +65,7 @@ var BuiltinProvider = { "devtools/touch-events": "resource://gre/modules/devtools/touch-events", "devtools/client": "resource://gre/modules/devtools/client", + "acorn": "resource://gre/modules/devtools/acorn", "escodegen": "resource://gre/modules/devtools/escodegen", "estraverse": "resource://gre/modules/devtools/escodegen/estraverse", @@ -108,6 +109,7 @@ var SrcdirProvider = { let outputParserURI = this.fileURI(OS.Path.join(toolkitDir, "output-parser")); let touchEventsURI = this.fileURI(OS.Path.join(toolkitDir, "touch-events")); let clientURI = this.fileURI(OS.Path.join(toolkitDir, "client")); + let acornURI = this.fileURI(OS.Path.join(toolkitDir, "acorn")); let escodegenURI = this.fileURI(OS.Path.join(toolkitDir, "escodegen")); let estraverseURI = this.fileURI(OS.Path.join(toolkitDir, "escodegen", "estraverse")); this.loader = new loader.Loader({ @@ -127,6 +129,7 @@ var SrcdirProvider = { "devtools/output-parser": outputParserURI, "devtools/touch-events": touchEventsURI, "devtools/client": clientURI, + "acorn": acornURI, "escodegen": escodegenURI, "estraverse": estraverseURI }, diff --git a/toolkit/devtools/acorn/LICENSE b/toolkit/devtools/acorn/LICENSE new file mode 100644 index 000000000000..af7fab615d5f --- /dev/null +++ b/toolkit/devtools/acorn/LICENSE @@ -0,0 +1,23 @@ +Copyright (C) 2012 by Marijn Haverbeke + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Please note that some subdirectories of the CodeMirror distribution +include their own LICENSE files, and are released under different +licences. diff --git a/toolkit/devtools/acorn/UPGRADING.md b/toolkit/devtools/acorn/UPGRADING.md new file mode 100644 index 000000000000..52ec0699fd90 --- /dev/null +++ b/toolkit/devtools/acorn/UPGRADING.md @@ -0,0 +1,24 @@ +Assuming that acorn's dependencies have not changed, to upgrade our tree's +acorn to a new version: + +1. Clone the acorn repository, and check out the version you want to upgrade +to: + + $ git clone https://github.com/marijnh/acorn.git + $ cd acorn + $ git checkout + +2. Make sure that all tests pass: + + $ npm install . + $ npm test + + If there are any test failures, do not upgrade to that version of acorn! + +3. Copy acorn.js to our tree: + + $ cp acorn.js /path/to/mozilla-central/toolkit/devtools/acorn/acorn.js + +4. Copy acorn_loose.js to our tree: + + $ cp acorn_loose.js /path/to/mozilla-central/toolkit/devtools/acorn/acorn_loose.js diff --git a/toolkit/devtools/acorn/acorn.js b/toolkit/devtools/acorn/acorn.js new file mode 100644 index 000000000000..95975578d2d6 --- /dev/null +++ b/toolkit/devtools/acorn/acorn.js @@ -0,0 +1,1719 @@ +// Acorn is a tiny, fast JavaScript parser written in JavaScript. +// +// Acorn was written by Marijn Haverbeke and released under an MIT +// license. The Unicode regexps (for identifiers and whitespace) were +// taken from [Esprima](http://esprima.org) by Ariya Hidayat. +// +// Git repositories for Acorn are available at +// +// http://marijnhaverbeke.nl/git/acorn +// https://github.com/marijnh/acorn.git +// +// Please use the [github bug tracker][ghbt] to report issues. +// +// [ghbt]: https://github.com/marijnh/acorn/issues +// +// This file defines the main parser interface. The library also comes +// with a [error-tolerant parser][dammit] and an +// [abstract syntax tree walker][walk], defined in other files. +// +// [dammit]: acorn_loose.js +// [walk]: util/walk.js + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") return mod(exports); // CommonJS + if (typeof define == "function" && define.amd) return define(["exports"], mod); // AMD + mod(self.acorn || (self.acorn = {})); // Plain browser env +})(function(exports) { + "use strict"; + + exports.version = "0.1.01"; + + // The main exported interface (under `self.acorn` when in the + // browser) is a `parse` function that takes a code string and + // returns an abstract syntax tree as specified by [Mozilla parser + // API][api], with the caveat that the SpiderMonkey-specific syntax + // (`let`, `yield`, inline XML, etc) is not recognized. + // + // [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API + + var options, input, inputLen, sourceFile; + + exports.parse = function(inpt, opts) { + input = String(inpt); inputLen = input.length; + setOptions(opts); + initTokenState(); + return parseTopLevel(options.program); + }; + + // A second optional argument can be given to further configure + // the parser process. These options are recognized: + + var defaultOptions = exports.defaultOptions = { + // `ecmaVersion` indicates the ECMAScript version to parse. Must + // be either 3 or 5. This + // influences support for strict mode, the set of reserved words, and + // support for getters and setter. + ecmaVersion: 5, + // Turn on `strictSemicolons` to prevent the parser from doing + // automatic semicolon insertion. + strictSemicolons: false, + // When `allowTrailingCommas` is false, the parser will not allow + // trailing commas in array and object literals. + allowTrailingCommas: true, + // By default, reserved words are not enforced. Enable + // `forbidReserved` to enforce them. + forbidReserved: false, + // When `locations` is on, `loc` properties holding objects with + // `start` and `end` properties in `{line, column}` form (with + // line being 1-based and column 0-based) will be attached to the + // nodes. + locations: false, + // A function can be passed as `onComment` option, which will + // cause Acorn to call that function with `(block, text, start, + // end)` parameters whenever a comment is skipped. `block` is a + // boolean indicating whether this is a block (`/* */`) comment, + // `text` is the content of the comment, and `start` and `end` are + // character offsets that denote the start and end of the comment. + // When the `locations` option is on, two more parameters are + // passed, the full `{line, column}` locations of the start and + // end of the comments. + onComment: null, + // Nodes have their start and end characters offsets recorded in + // `start` and `end` properties (directly on the node, rather than + // the `loc` object, which holds line/column data. To also add a + // [semi-standardized][range] `range` property holding a `[start, + // end]` array with the same numbers, set the `ranges` option to + // `true`. + // + // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 + ranges: false, + // It is possible to parse multiple files into a single AST by + // passing the tree produced by parsing the first file as + // `program` option in subsequent parses. This will add the + // toplevel forms of the parsed file to the `Program` (top) node + // of an existing parse tree. + program: null, + // When `location` is on, you can pass this to record the source + // file in every node's `loc` object. + sourceFile: null + }; + + function setOptions(opts) { + options = opts || {}; + for (var opt in defaultOptions) if (!options.hasOwnProperty(opt)) + options[opt] = defaultOptions[opt]; + sourceFile = options.sourceFile || null; + } + + // The `getLineInfo` function is mostly useful when the + // `locations` option is off (for performance reasons) and you + // want to find the line/column position for a given character + // offset. `input` should be the code string that the offset refers + // into. + + var getLineInfo = exports.getLineInfo = function(input, offset) { + for (var line = 1, cur = 0;;) { + lineBreak.lastIndex = cur; + var match = lineBreak.exec(input); + if (match && match.index < offset) { + ++line; + cur = match.index + match[0].length; + } else break; + } + return {line: line, column: offset - cur}; + }; + + // Acorn is organized as a tokenizer and a recursive-descent parser. + // The `tokenize` export provides an interface to the tokenizer. + // Because the tokenizer is optimized for being efficiently used by + // the Acorn parser itself, this interface is somewhat crude and not + // very modular. Performing another parse or call to `tokenize` will + // reset the internal state, and invalidate existing tokenizers. + + exports.tokenize = function(inpt, opts) { + input = String(inpt); inputLen = input.length; + setOptions(opts); + initTokenState(); + + var t = {}; + function getToken(forceRegexp) { + readToken(forceRegexp); + t.start = tokStart; t.end = tokEnd; + t.startLoc = tokStartLoc; t.endLoc = tokEndLoc; + t.type = tokType; t.value = tokVal; + return t; + } + getToken.jumpTo = function(pos, reAllowed) { + tokPos = pos; + if (options.locations) { + tokCurLine = tokLineStart = lineBreak.lastIndex = 0; + var match; + while ((match = lineBreak.exec(input)) && match.index < pos) { + ++tokCurLine; + tokLineStart = match.index + match[0].length; + } + } + var ch = input.charAt(pos - 1); + tokRegexpAllowed = reAllowed; + skipSpace(); + }; + return getToken; + }; + + // State is kept in (closure-)global variables. We already saw the + // `options`, `input`, and `inputLen` variables above. + + // The current position of the tokenizer in the input. + + var tokPos; + + // The start and end offsets of the current token. + + var tokStart, tokEnd; + + // When `options.locations` is true, these hold objects + // containing the tokens start and end line/column pairs. + + var tokStartLoc, tokEndLoc; + + // The type and value of the current token. Token types are objects, + // named by variables against which they can be compared, and + // holding properties that describe them (indicating, for example, + // the precedence of an infix operator, and the original name of a + // keyword token). The kind of value that's held in `tokVal` depends + // on the type of the token. For literals, it is the literal value, + // for operators, the operator name, and so on. + + var tokType, tokVal; + + // Interal state for the tokenizer. To distinguish between division + // operators and regular expressions, it remembers whether the last + // token was one that is allowed to be followed by an expression. + // (If it is, a slash is probably a regexp, if it isn't it's a + // division operator. See the `parseStatement` function for a + // caveat.) + + var tokRegexpAllowed; + + // When `options.locations` is true, these are used to keep + // track of the current line, and know when a new line has been + // entered. + + var tokCurLine, tokLineStart; + + // These store the position of the previous token, which is useful + // when finishing a node and assigning its `end` position. + + var lastStart, lastEnd, lastEndLoc; + + // This is the parser's state. `inFunction` is used to reject + // `return` statements outside of functions, `labels` to verify that + // `break` and `continue` have somewhere to jump to, and `strict` + // indicates whether strict mode is on. + + var inFunction, labels, strict; + + // This function is used to raise exceptions on parse errors. It + // takes an offset integer (into the current `input`) to indicate + // the location of the error, attaches the position to the end + // of the error message, and then raises a `SyntaxError` with that + // message. + + function raise(pos, message) { + var loc = getLineInfo(input, pos); + message += " (" + loc.line + ":" + loc.column + ")"; + var err = new SyntaxError(message); + err.pos = pos; err.loc = loc; err.raisedAt = tokPos; + throw err; + } + + // ## Token types + + // The assignment of fine-grained, information-carrying type objects + // allows the tokenizer to store the information it has about a + // token in a way that is very cheap for the parser to look up. + + // All token type variables start with an underscore, to make them + // easy to recognize. + + // These are the general types. The `type` property is only used to + // make them recognizeable when debugging. + + var _num = {type: "num"}, _regexp = {type: "regexp"}, _string = {type: "string"}; + var _name = {type: "name"}, _eof = {type: "eof"}; + + // Keyword tokens. The `keyword` property (also used in keyword-like + // operators) indicates that the token originated from an + // identifier-like word, which is used when parsing property names. + // + // The `beforeExpr` property is used to disambiguate between regular + // expressions and divisions. It is set on all token types that can + // be followed by an expression (thus, a slash after them would be a + // regular expression). + // + // `isLoop` marks a keyword as starting a loop, which is important + // to know when parsing a label, in order to allow or disallow + // continue jumps to that label. + + var _break = {keyword: "break"}, _case = {keyword: "case", beforeExpr: true}, _catch = {keyword: "catch"}; + var _continue = {keyword: "continue"}, _debugger = {keyword: "debugger"}, _default = {keyword: "default"}; + var _do = {keyword: "do", isLoop: true}, _else = {keyword: "else", beforeExpr: true}; + var _finally = {keyword: "finally"}, _for = {keyword: "for", isLoop: true}, _function = {keyword: "function"}; + var _if = {keyword: "if"}, _return = {keyword: "return", beforeExpr: true}, _switch = {keyword: "switch"}; + var _throw = {keyword: "throw", beforeExpr: true}, _try = {keyword: "try"}, _var = {keyword: "var"}; + var _while = {keyword: "while", isLoop: true}, _with = {keyword: "with"}, _new = {keyword: "new", beforeExpr: true}; + var _this = {keyword: "this"}; + + // The keywords that denote values. + + var _null = {keyword: "null", atomValue: null}, _true = {keyword: "true", atomValue: true}; + var _false = {keyword: "false", atomValue: false}; + + // Some keywords are treated as regular operators. `in` sometimes + // (when parsing `for`) needs to be tested against specifically, so + // we assign a variable name to it for quick comparing. + + var _in = {keyword: "in", binop: 7, beforeExpr: true}; + + // Map keyword names to token types. + + var keywordTypes = {"break": _break, "case": _case, "catch": _catch, + "continue": _continue, "debugger": _debugger, "default": _default, + "do": _do, "else": _else, "finally": _finally, "for": _for, + "function": _function, "if": _if, "return": _return, "switch": _switch, + "throw": _throw, "try": _try, "var": _var, "while": _while, "with": _with, + "null": _null, "true": _true, "false": _false, "new": _new, "in": _in, + "instanceof": {keyword: "instanceof", binop: 7, beforeExpr: true}, "this": _this, + "typeof": {keyword: "typeof", prefix: true, beforeExpr: true}, + "void": {keyword: "void", prefix: true, beforeExpr: true}, + "delete": {keyword: "delete", prefix: true, beforeExpr: true}}; + + // Punctuation token types. Again, the `type` property is purely for debugging. + + var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true}; + var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"}; + var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true}; + var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true}; + + // Operators. These carry several kinds of properties to help the + // parser use them properly (the presence of these properties is + // what categorizes them as operators). + // + // `binop`, when present, specifies that this operator is a binary + // operator, and will refer to its precedence. + // + // `prefix` and `postfix` mark the operator as a prefix or postfix + // unary operator. `isUpdate` specifies that the node produced by + // the operator should be of type UpdateExpression rather than + // simply UnaryExpression (`++` and `--`). + // + // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as + // binary operators with a very low precedence, that should result + // in AssignmentExpression nodes. + + var _slash = {binop: 10, beforeExpr: true}, _eq = {isAssign: true, beforeExpr: true}; + var _assign = {isAssign: true, beforeExpr: true}, _plusmin = {binop: 9, prefix: true, beforeExpr: true}; + var _incdec = {postfix: true, prefix: true, isUpdate: true}, _prefix = {prefix: true, beforeExpr: true}; + var _bin1 = {binop: 1, beforeExpr: true}, _bin2 = {binop: 2, beforeExpr: true}; + var _bin3 = {binop: 3, beforeExpr: true}, _bin4 = {binop: 4, beforeExpr: true}; + var _bin5 = {binop: 5, beforeExpr: true}, _bin6 = {binop: 6, beforeExpr: true}; + var _bin7 = {binop: 7, beforeExpr: true}, _bin8 = {binop: 8, beforeExpr: true}; + var _bin10 = {binop: 10, beforeExpr: true}; + + // Provide access to the token types for external users of the + // tokenizer. + + exports.tokTypes = {bracketL: _bracketL, bracketR: _bracketR, braceL: _braceL, braceR: _braceR, + parenL: _parenL, parenR: _parenR, comma: _comma, semi: _semi, colon: _colon, + dot: _dot, question: _question, slash: _slash, eq: _eq, name: _name, eof: _eof, + num: _num, regexp: _regexp, string: _string}; + for (var kw in keywordTypes) exports.tokTypes[kw] = keywordTypes[kw]; + + // This is a trick taken from Esprima. It turns out that, on + // non-Chrome browsers, to check whether a string is in a set, a + // predicate containing a big ugly `switch` statement is faster than + // a regular expression, and on Chrome the two are about on par. + // This function uses `eval` (non-lexical) to produce such a + // predicate from a space-separated string of words. + // + // It starts by sorting the words by length. + + function makePredicate(words) { + words = words.split(" "); + var f = "", cats = []; + out: for (var i = 0; i < words.length; ++i) { + for (var j = 0; j < cats.length; ++j) + if (cats[j][0].length == words[i].length) { + cats[j].push(words[i]); + continue out; + } + cats.push([words[i]]); + } + function compareTo(arr) { + if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";"; + f += "switch(str){"; + for (var i = 0; i < arr.length; ++i) f += "case " + JSON.stringify(arr[i]) + ":"; + f += "return true}return false;"; + } + + // When there are more than three length categories, an outer + // switch first dispatches on the lengths, to save on comparisons. + + if (cats.length > 3) { + cats.sort(function(a, b) {return b.length - a.length;}); + f += "switch(str.length){"; + for (var i = 0; i < cats.length; ++i) { + var cat = cats[i]; + f += "case " + cat[0].length + ":"; + compareTo(cat); + } + f += "}"; + + // Otherwise, simply generate a flat `switch` statement. + + } else { + compareTo(words); + } + return new Function("str", f); + } + + // The ECMAScript 3 reserved word list. + + var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile"); + + // ECMAScript 5 reserved words. + + var isReservedWord5 = makePredicate("class enum extends super const export import"); + + // The additional reserved words in strict mode. + + var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield"); + + // The forbidden variable names in strict mode. + + var isStrictBadIdWord = makePredicate("eval arguments"); + + // And the keywords. + + var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"); + + // ## Character categories + + // Big ugly regular expressions that match characters in the + // whitespace, identifier, and identifier-start categories. These + // are only applied when a character is found to actually have a + // code point above 128. + + var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/; + var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; + var nonASCIIidentifierChars = "\u0371-\u0374\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u0620-\u0649\u0672-\u06d3\u06e7-\u06e8\u06fb-\u06fc\u0730-\u074a\u0800-\u0814\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0840-\u0857\u08e4-\u08fe\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962-\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09d7\u09df-\u09e0\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5f-\u0b60\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2-\u0ce3\u0ce6-\u0cef\u0d02\u0d03\u0d46-\u0d48\u0d57\u0d62-\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e34-\u0e3a\u0e40-\u0e45\u0e50-\u0e59\u0eb4-\u0eb9\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f41-\u0f47\u0f71-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1029\u1040-\u1049\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u170e-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17b2\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1920-\u192b\u1930-\u193b\u1951-\u196d\u19b0-\u19c0\u19c8-\u19c9\u19d0-\u19d9\u1a00-\u1a15\u1a20-\u1a53\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1b46-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1bb0-\u1bb9\u1be6-\u1bf3\u1c00-\u1c22\u1c40-\u1c49\u1c5b-\u1c7d\u1cd0-\u1cd2\u1d00-\u1dbe\u1e01-\u1f15\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2d81-\u2d96\u2de0-\u2dff\u3021-\u3028\u3099\u309a\ua640-\ua66d\ua674-\ua67d\ua69f\ua6f0-\ua6f1\ua7f8-\ua800\ua806\ua80b\ua823-\ua827\ua880-\ua881\ua8b4-\ua8c4\ua8d0-\ua8d9\ua8f3-\ua8f7\ua900-\ua909\ua926-\ua92d\ua930-\ua945\ua980-\ua983\ua9b3-\ua9c0\uaa00-\uaa27\uaa40-\uaa41\uaa4c-\uaa4d\uaa50-\uaa59\uaa7b\uaae0-\uaae9\uaaf2-\uaaf3\uabc0-\uabe1\uabec\uabed\uabf0-\uabf9\ufb20-\ufb28\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; + var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); + var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); + + // Whether a single character denotes a newline. + + var newline = /[\n\r\u2028\u2029]/; + + // Matches a whole line break (where CRLF is considered a single + // line break). Used to count lines. + + var lineBreak = /\r\n|[\n\r\u2028\u2029]/g; + + // Test whether a given character code starts an identifier. + + function isIdentifierStart(code) { + if (code < 65) return code === 36; + if (code < 91) return true; + if (code < 97) return code === 95; + if (code < 123)return true; + return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)); + } + + // Test whether a given character is part of an identifier. + + function isIdentifierChar(code) { + if (code < 48) return code === 36; + if (code < 58) return true; + if (code < 65) return false; + if (code < 91) return true; + if (code < 97) return code === 95; + if (code < 123)return true; + return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)); + } + + // ## Tokenizer + + // These are used when `options.locations` is on, for the + // `tokStartLoc` and `tokEndLoc` properties. + + function line_loc_t() { + this.line = tokCurLine; + this.column = tokPos - tokLineStart; + } + + // Reset the token state. Used at the start of a parse. + + function initTokenState() { + tokCurLine = 1; + tokPos = tokLineStart = 0; + tokRegexpAllowed = true; + skipSpace(); + } + + // Called at the end of every token. Sets `tokEnd`, `tokVal`, and + // `tokRegexpAllowed`, and skips the space after the token, so that + // the next one's `tokStart` will point at the right position. + + function finishToken(type, val) { + tokEnd = tokPos; + if (options.locations) tokEndLoc = new line_loc_t; + tokType = type; + skipSpace(); + tokVal = val; + tokRegexpAllowed = type.beforeExpr; + } + + function skipBlockComment() { + var startLoc = options.onComment && options.locations && new line_loc_t; + var start = tokPos, end = input.indexOf("*/", tokPos += 2); + if (end === -1) raise(tokPos - 2, "Unterminated comment"); + tokPos = end + 2; + if (options.locations) { + lineBreak.lastIndex = start; + var match; + while ((match = lineBreak.exec(input)) && match.index < tokPos) { + ++tokCurLine; + tokLineStart = match.index + match[0].length; + } + } + if (options.onComment) + options.onComment(true, input.slice(start + 2, end), start, tokPos, + startLoc, options.locations && new line_loc_t); + } + + function skipLineComment() { + var start = tokPos; + var startLoc = options.onComment && options.locations && new line_loc_t; + var ch = input.charCodeAt(tokPos+=2); + while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8329) { + ++tokPos; + ch = input.charCodeAt(tokPos); + } + if (options.onComment) + options.onComment(false, input.slice(start + 2, tokPos), start, tokPos, + startLoc, options.locations && new line_loc_t); + } + + // Called at the start of the parse and after every token. Skips + // whitespace and comments, and. + + function skipSpace() { + while (tokPos < inputLen) { + var ch = input.charCodeAt(tokPos); + if (ch === 32) { // ' ' + ++tokPos; + } else if(ch === 13) { + ++tokPos; + var next = input.charCodeAt(tokPos); + if(next === 10) { + ++tokPos; + } + if(options.locations) { + ++tokCurLine; + tokLineStart = tokPos; + } + } else if (ch === 10) { + ++tokPos; + ++tokCurLine; + tokLineStart = tokPos; + } else if(ch < 14 && ch > 8) { + ++tokPos; + } else if (ch === 47) { // '/' + var next = input.charCodeAt(tokPos+1); + if (next === 42) { // '*' + skipBlockComment(); + } else if (next === 47) { // '/' + skipLineComment(); + } else break; + } else if ((ch < 14 && ch > 8) || ch === 32 || ch === 160) { // ' ', '\xa0' + ++tokPos; + } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { + ++tokPos; + } else { + break; + } + } + } + + // ### Token reading + + // This is the function that is called to fetch the next token. It + // is somewhat obscure, because it works in character codes rather + // than characters, and because operator parsing has been inlined + // into it. + // + // All in the name of speed. + // + // The `forceRegexp` parameter is used in the one case where the + // `tokRegexpAllowed` trick does not work. See `parseStatement`. + + function readToken_dot() { + var next = input.charCodeAt(tokPos+1); + if (next >= 48 && next <= 57) return readNumber(true); + ++tokPos; + return finishToken(_dot); + } + + function readToken_slash() { // '/' + var next = input.charCodeAt(tokPos+1); + if (tokRegexpAllowed) {++tokPos; return readRegexp();} + if (next === 61) return finishOp(_assign, 2); + return finishOp(_slash, 1); + } + + function readToken_mult_modulo() { // '%*' + var next = input.charCodeAt(tokPos+1); + if (next === 61) return finishOp(_assign, 2); + return finishOp(_bin10, 1); + } + + function readToken_pipe_amp(code) { // '|&' + var next = input.charCodeAt(tokPos+1); + if (next === code) return finishOp(code === 124 ? _bin1 : _bin2, 2); + if (next === 61) return finishOp(_assign, 2); + return finishOp(code === 124 ? _bin3 : _bin5, 1); + } + + function readToken_caret() { // '^' + var next = input.charCodeAt(tokPos+1); + if (next === 61) return finishOp(_assign, 2); + return finishOp(_bin4, 1); + } + + function readToken_plus_min(code) { // '+-' + var next = input.charCodeAt(tokPos+1); + if (next === code) return finishOp(_incdec, 2); + if (next === 61) return finishOp(_assign, 2); + return finishOp(_plusmin, 1); + } + + function readToken_lt_gt(code) { // '<>' + var next = input.charCodeAt(tokPos+1); + var size = 1; + if (next === code) { + size = code === 62 && input.charCodeAt(tokPos+2) === 62 ? 3 : 2; + if (input.charCodeAt(tokPos + size) === 61) return finishOp(_assign, size + 1); + return finishOp(_bin8, size); + } + if (next === 61) + size = input.charCodeAt(tokPos+2) === 61 ? 3 : 2; + return finishOp(_bin7, size); + } + + function readToken_eq_excl(code) { // '=!' + var next = input.charCodeAt(tokPos+1); + if (next === 61) return finishOp(_bin6, input.charCodeAt(tokPos+2) === 61 ? 3 : 2); + return finishOp(code === 61 ? _eq : _prefix, 1); + } + + function getTokenFromCode(code) { + switch(code) { + // The interpretation of a dot depends on whether it is followed + // by a digit. + case 46: // '.' + return readToken_dot(); + + // Punctuation tokens. + case 40: ++tokPos; return finishToken(_parenL); + case 41: ++tokPos; return finishToken(_parenR); + case 59: ++tokPos; return finishToken(_semi); + case 44: ++tokPos; return finishToken(_comma); + case 91: ++tokPos; return finishToken(_bracketL); + case 93: ++tokPos; return finishToken(_bracketR); + case 123: ++tokPos; return finishToken(_braceL); + case 125: ++tokPos; return finishToken(_braceR); + case 58: ++tokPos; return finishToken(_colon); + case 63: ++tokPos; return finishToken(_question); + + // '0x' is a hexadecimal number. + case 48: // '0' + var next = input.charCodeAt(tokPos+1); + if (next === 120 || next === 88) return readHexNumber(); + // Anything else beginning with a digit is an integer, octal + // number, or float. + case 49: case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: // 1-9 + return readNumber(false); + + // Quotes produce strings. + case 34: case 39: // '"', "'" + return readString(code); + + // Operators are parsed inline in tiny state machines. '=' (61) is + // often referred to. `finishOp` simply skips the amount of + // characters it is given as second argument, and returns a token + // of the type given by its first argument. + + case 47: // '/' + return readToken_slash(code); + + case 37: case 42: // '%*' + return readToken_mult_modulo(); + + case 124: case 38: // '|&' + return readToken_pipe_amp(code); + + case 94: // '^' + return readToken_caret(); + + case 43: case 45: // '+-' + return readToken_plus_min(code); + + case 60: case 62: // '<>' + return readToken_lt_gt(code); + + case 61: case 33: // '=!' + return readToken_eq_excl(code); + + case 126: // '~' + return finishOp(_prefix, 1); + } + + return false; + } + + function readToken(forceRegexp) { + if (!forceRegexp) tokStart = tokPos; + else tokPos = tokStart + 1; + if (options.locations) tokStartLoc = new line_loc_t; + if (forceRegexp) return readRegexp(); + if (tokPos >= inputLen) return finishToken(_eof); + + var code = input.charCodeAt(tokPos); + // Identifier or keyword. '\uXXXX' sequences are allowed in + // identifiers, so '\' also dispatches to that. + if (isIdentifierStart(code) || code === 92 /* '\' */) return readWord(); + + var tok = getTokenFromCode(code); + + if (tok === false) { + // If we are here, we either found a non-ASCII identifier + // character, or something that's entirely disallowed. + var ch = String.fromCharCode(code); + if (ch === "\\" || nonASCIIidentifierStart.test(ch)) return readWord(); + raise(tokPos, "Unexpected character '" + ch + "'"); + } + return tok; + } + + function finishOp(type, size) { + var str = input.slice(tokPos, tokPos + size); + tokPos += size; + finishToken(type, str); + } + + // Parse a regular expression. Some context-awareness is necessary, + // since a '/' inside a '[]' set does not end the expression. + + function readRegexp() { + var content = "", escaped, inClass, start = tokPos; + for (;;) { + if (tokPos >= inputLen) raise(start, "Unterminated regular expression"); + var ch = input.charAt(tokPos); + if (newline.test(ch)) raise(start, "Unterminated regular expression"); + if (!escaped) { + if (ch === "[") inClass = true; + else if (ch === "]" && inClass) inClass = false; + else if (ch === "/" && !inClass) break; + escaped = ch === "\\"; + } else escaped = false; + ++tokPos; + } + var content = input.slice(start, tokPos); + ++tokPos; + // Need to use `readWord1` because '\uXXXX' sequences are allowed + // here (don't ask). + var mods = readWord1(); + if (mods && !/^[gmsiy]*$/.test(mods)) raise(start, "Invalid regexp flag"); + return finishToken(_regexp, new RegExp(content, mods)); + } + + // Read an integer in the given radix. Return null if zero digits + // were read, the integer value otherwise. When `len` is given, this + // will return `null` unless the integer has exactly `len` digits. + + function readInt(radix, len) { + var start = tokPos, total = 0; + for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) { + var code = input.charCodeAt(tokPos), val; + if (code >= 97) val = code - 97 + 10; // a + else if (code >= 65) val = code - 65 + 10; // A + else if (code >= 48 && code <= 57) val = code - 48; // 0-9 + else val = Infinity; + if (val >= radix) break; + ++tokPos; + total = total * radix + val; + } + if (tokPos === start || len != null && tokPos - start !== len) return null; + + return total; + } + + function readHexNumber() { + tokPos += 2; // 0x + var val = readInt(16); + if (val == null) raise(tokStart + 2, "Expected hexadecimal number"); + if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number"); + return finishToken(_num, val); + } + + // Read an integer, octal integer, or floating-point number. + + function readNumber(startsWithDot) { + var start = tokPos, isFloat = false, octal = input.charCodeAt(tokPos) === 48; + if (!startsWithDot && readInt(10) === null) raise(start, "Invalid number"); + if (input.charCodeAt(tokPos) === 46) { + ++tokPos; + readInt(10); + isFloat = true; + } + var next = input.charCodeAt(tokPos); + if (next === 69 || next === 101) { // 'eE' + next = input.charCodeAt(++tokPos); + if (next === 43 || next === 45) ++tokPos; // '+-' + if (readInt(10) === null) raise(start, "Invalid number") + isFloat = true; + } + if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number"); + + var str = input.slice(start, tokPos), val; + if (isFloat) val = parseFloat(str); + else if (!octal || str.length === 1) val = parseInt(str, 10); + else if (/[89]/.test(str) || strict) raise(start, "Invalid number"); + else val = parseInt(str, 8); + return finishToken(_num, val); + } + + // Read a string value, interpreting backslash-escapes. + + function readString(quote) { + tokPos++; + var out = ""; + for (;;) { + if (tokPos >= inputLen) raise(tokStart, "Unterminated string constant"); + var ch = input.charCodeAt(tokPos); + if (ch === quote) { + ++tokPos; + return finishToken(_string, out); + } + if (ch === 92) { // '\' + ch = input.charCodeAt(++tokPos); + var octal = /^[0-7]+/.exec(input.slice(tokPos, tokPos + 3)); + if (octal) octal = octal[0]; + while (octal && parseInt(octal, 8) > 255) octal = octal.slice(0, octal.length - 1); + if (octal === "0") octal = null; + ++tokPos; + if (octal) { + if (strict) raise(tokPos - 2, "Octal literal in strict mode"); + out += String.fromCharCode(parseInt(octal, 8)); + tokPos += octal.length - 1; + } else { + switch (ch) { + case 110: out += "\n"; break; // 'n' -> '\n' + case 114: out += "\r"; break; // 'r' -> '\r' + case 120: out += String.fromCharCode(readHexChar(2)); break; // 'x' + case 117: out += String.fromCharCode(readHexChar(4)); break; // 'u' + case 85: out += String.fromCharCode(readHexChar(8)); break; // 'U' + case 116: out += "\t"; break; // 't' -> '\t' + case 98: out += "\b"; break; // 'b' -> '\b' + case 118: out += "\u000b"; break; // 'v' -> '\u000b' + case 102: out += "\f"; break; // 'f' -> '\f' + case 48: out += "\0"; break; // 0 -> '\0' + case 13: if (input.charCodeAt(tokPos) === 10) ++tokPos; // '\r\n' + case 10: // ' \n' + if (options.locations) { tokLineStart = tokPos; ++tokCurLine; } + break; + default: out += String.fromCharCode(ch); break; + } + } + } else { + if (ch === 13 || ch === 10 || ch === 8232 || ch === 8329) raise(tokStart, "Unterminated string constant"); + out += String.fromCharCode(ch); // '\' + ++tokPos; + } + } + } + + // Used to read character escape sequences ('\x', '\u', '\U'). + + function readHexChar(len) { + var n = readInt(16, len); + if (n === null) raise(tokStart, "Bad character escape sequence"); + return n; + } + + // Used to signal to callers of `readWord1` whether the word + // contained any escape sequences. This is needed because words with + // escape sequences must not be interpreted as keywords. + + var containsEsc; + + // Read an identifier, and return it as a string. Sets `containsEsc` + // to whether the word contained a '\u' escape. + // + // Only builds up the word character-by-character when it actually + // containeds an escape, as a micro-optimization. + + function readWord1() { + containsEsc = false; + var word, first = true, start = tokPos; + for (;;) { + var ch = input.charCodeAt(tokPos); + if (isIdentifierChar(ch)) { + if (containsEsc) word += input.charAt(tokPos); + ++tokPos; + } else if (ch === 92) { // "\" + if (!containsEsc) word = input.slice(start, tokPos); + containsEsc = true; + if (input.charCodeAt(++tokPos) != 117) // "u" + raise(tokPos, "Expecting Unicode escape sequence \\uXXXX"); + ++tokPos; + var esc = readHexChar(4); + var escStr = String.fromCharCode(esc); + if (!escStr) raise(tokPos - 1, "Invalid Unicode escape"); + if (!(first ? isIdentifierStart(esc) : isIdentifierChar(esc))) + raise(tokPos - 4, "Invalid Unicode escape"); + word += escStr; + } else { + break; + } + first = false; + } + return containsEsc ? word : input.slice(start, tokPos); + } + + // Read an identifier or keyword token. Will check for reserved + // words when necessary. + + function readWord() { + var word = readWord1(); + var type = _name; + if (!containsEsc) { + if (isKeyword(word)) type = keywordTypes[word]; + else if (options.forbidReserved && + (options.ecmaVersion === 3 ? isReservedWord3 : isReservedWord5)(word) || + strict && isStrictReservedWord(word)) + raise(tokStart, "The keyword '" + word + "' is reserved"); + } + return finishToken(type, word); + } + + // ## Parser + + // A recursive descent parser operates by defining functions for all + // syntactic elements, and recursively calling those, each function + // advancing the input stream and returning an AST node. Precedence + // of constructs (for example, the fact that `!x[1]` means `!(x[1])` + // instead of `(!x)[1]` is handled by the fact that the parser + // function that parses unary prefix operators is called first, and + // in turn calls the function that parses `[]` subscripts — that + // way, it'll receive the node for `x[1]` already parsed, and wraps + // *that* in the unary operator node. + // + // Acorn uses an [operator precedence parser][opp] to handle binary + // operator precedence, because it is much more compact than using + // the technique outlined above, which uses different, nesting + // functions to specify precedence, for all of the ten binary + // precedence levels that JavaScript defines. + // + // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser + + // ### Parser utilities + + // Continue to the next token. + + function next() { + lastStart = tokStart; + lastEnd = tokEnd; + lastEndLoc = tokEndLoc; + readToken(); + } + + // Enter strict mode. Re-reads the next token to please pedantic + // tests ("use strict"; 010; -- should fail). + + function setStrict(strct) { + strict = strct; + tokPos = lastEnd; + while (tokPos < tokLineStart) { + tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1; + --tokCurLine; + } + skipSpace(); + readToken(); + } + + // Start an AST node, attaching a start offset. + + function node_t() { + this.type = null; + this.start = tokStart; + this.end = null; + } + + function node_loc_t() { + this.start = tokStartLoc; + this.end = null; + if (sourceFile !== null) this.source = sourceFile; + } + + function startNode() { + var node = new node_t(); + if (options.locations) + node.loc = new node_loc_t(); + if (options.ranges) + node.range = [tokStart, 0]; + return node; + } + + // Start a node whose start offset information should be based on + // the start of another node. For example, a binary operator node is + // only started after its left-hand side has already been parsed. + + function startNodeFrom(other) { + var node = new node_t(); + node.start = other.start; + if (options.locations) { + node.loc = new node_loc_t(); + node.loc.start = other.loc.start; + } + if (options.ranges) + node.range = [other.range[0], 0]; + + return node; + } + + // Finish an AST node, adding `type` and `end` properties. + + function finishNode(node, type) { + node.type = type; + node.end = lastEnd; + if (options.locations) + node.loc.end = lastEndLoc; + if (options.ranges) + node.range[1] = lastEnd; + return node; + } + + // Test whether a statement node is the string literal `"use strict"`. + + function isUseStrict(stmt) { + return options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && + stmt.expression.type === "Literal" && stmt.expression.value === "use strict"; + } + + // Predicate that tests whether the next token is of the given + // type, and if yes, consumes it as a side effect. + + function eat(type) { + if (tokType === type) { + next(); + return true; + } + } + + // Test whether a semicolon can be inserted at the current position. + + function canInsertSemicolon() { + return !options.strictSemicolons && + (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart))); + } + + // Consume a semicolon, or, failing that, see if we are allowed to + // pretend that there is a semicolon at this position. + + function semicolon() { + if (!eat(_semi) && !canInsertSemicolon()) unexpected(); + } + + // Expect a token of a given type. If found, consume it, otherwise, + // raise an unexpected token error. + + function expect(type) { + if (tokType === type) next(); + else unexpected(); + } + + // Raise an unexpected token error. + + function unexpected() { + raise(tokStart, "Unexpected token"); + } + + // Verify that a node is an lval — something that can be assigned + // to. + + function checkLVal(expr) { + if (expr.type !== "Identifier" && expr.type !== "MemberExpression") + raise(expr.start, "Assigning to rvalue"); + if (strict && expr.type === "Identifier" && isStrictBadIdWord(expr.name)) + raise(expr.start, "Assigning to " + expr.name + " in strict mode"); + } + + // ### Statement parsing + + // Parse a program. Initializes the parser, reads any number of + // statements, and wraps them in a Program node. Optionally takes a + // `program` argument. If present, the statements will be appended + // to its body instead of creating a new node. + + function parseTopLevel(program) { + lastStart = lastEnd = tokPos; + if (options.locations) lastEndLoc = new line_loc_t; + inFunction = strict = null; + labels = []; + readToken(); + + var node = program || startNode(), first = true; + if (!program) node.body = []; + while (tokType !== _eof) { + var stmt = parseStatement(); + node.body.push(stmt); + if (first && isUseStrict(stmt)) setStrict(true); + first = false; + } + return finishNode(node, "Program"); + } + + var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"}; + + // Parse a single statement. + // + // If expecting a statement and finding a slash operator, parse a + // regular expression literal. This is to handle cases like + // `if (foo) /blah/.exec(foo);`, where looking at the previous token + // does not help. + + function parseStatement() { + if (tokType === _slash) + readToken(true); + + var starttype = tokType, node = startNode(); + + // Most types of statements are recognized by the keyword they + // start with. Many are trivial to parse, some require a bit of + // complexity. + + switch (starttype) { + case _break: case _continue: + next(); + var isBreak = starttype === _break; + if (eat(_semi) || canInsertSemicolon()) node.label = null; + else if (tokType !== _name) unexpected(); + else { + node.label = parseIdent(); + semicolon(); + } + + // Verify that there is an actual destination to break or + // continue to. + for (var i = 0; i < labels.length; ++i) { + var lab = labels[i]; + if (node.label == null || lab.name === node.label.name) { + if (lab.kind != null && (isBreak || lab.kind === "loop")) break; + if (node.label && isBreak) break; + } + } + if (i === labels.length) raise(node.start, "Unsyntactic " + starttype.keyword); + return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement"); + + case _debugger: + next(); + semicolon(); + return finishNode(node, "DebuggerStatement"); + + case _do: + next(); + labels.push(loopLabel); + node.body = parseStatement(); + labels.pop(); + expect(_while); + node.test = parseParenExpression(); + semicolon(); + return finishNode(node, "DoWhileStatement"); + + // Disambiguating between a `for` and a `for`/`in` loop is + // non-trivial. Basically, we have to parse the init `var` + // statement or expression, disallowing the `in` operator (see + // the second parameter to `parseExpression`), and then check + // whether the next token is `in`. When there is no init part + // (semicolon immediately after the opening parenthesis), it is + // a regular `for` loop. + + case _for: + next(); + labels.push(loopLabel); + expect(_parenL); + if (tokType === _semi) return parseFor(node, null); + if (tokType === _var) { + var init = startNode(); + next(); + parseVar(init, true); + if (init.declarations.length === 1 && eat(_in)) + return parseForIn(node, init); + return parseFor(node, init); + } + var init = parseExpression(false, true); + if (eat(_in)) {checkLVal(init); return parseForIn(node, init);} + return parseFor(node, init); + + case _function: + next(); + return parseFunction(node, true); + + case _if: + next(); + node.test = parseParenExpression(); + node.consequent = parseStatement(); + node.alternate = eat(_else) ? parseStatement() : null; + return finishNode(node, "IfStatement"); + + case _return: + if (!inFunction) raise(tokStart, "'return' outside of function"); + next(); + + // In `return` (and `break`/`continue`), the keywords with + // optional arguments, we eagerly look for a semicolon or the + // possibility to insert one. + + if (eat(_semi) || canInsertSemicolon()) node.argument = null; + else { node.argument = parseExpression(); semicolon(); } + return finishNode(node, "ReturnStatement"); + + case _switch: + next(); + node.discriminant = parseParenExpression(); + node.cases = []; + expect(_braceL); + labels.push(switchLabel); + + // Statements under must be grouped (by label) in SwitchCase + // nodes. `cur` is used to keep the node that we are currently + // adding statements to. + + for (var cur, sawDefault; tokType != _braceR;) { + if (tokType === _case || tokType === _default) { + var isCase = tokType === _case; + if (cur) finishNode(cur, "SwitchCase"); + node.cases.push(cur = startNode()); + cur.consequent = []; + next(); + if (isCase) cur.test = parseExpression(); + else { + if (sawDefault) raise(lastStart, "Multiple default clauses"); sawDefault = true; + cur.test = null; + } + expect(_colon); + } else { + if (!cur) unexpected(); + cur.consequent.push(parseStatement()); + } + } + if (cur) finishNode(cur, "SwitchCase"); + next(); // Closing brace + labels.pop(); + return finishNode(node, "SwitchStatement"); + + case _throw: + next(); + if (newline.test(input.slice(lastEnd, tokStart))) + raise(lastEnd, "Illegal newline after throw"); + node.argument = parseExpression(); + semicolon(); + return finishNode(node, "ThrowStatement"); + + case _try: + next(); + node.block = parseBlock(); + node.handler = null; + if (tokType === _catch) { + var clause = startNode(); + next(); + expect(_parenL); + clause.param = parseIdent(); + if (strict && isStrictBadIdWord(clause.param.name)) + raise(clause.param.start, "Binding " + clause.param.name + " in strict mode"); + expect(_parenR); + clause.guard = null; + clause.body = parseBlock(); + node.handler = finishNode(clause, "CatchClause"); + } + node.finalizer = eat(_finally) ? parseBlock() : null; + if (!node.handler && !node.finalizer) + raise(node.start, "Missing catch or finally clause"); + return finishNode(node, "TryStatement"); + + case _var: + next(); + node = parseVar(node); + semicolon(); + return node; + + case _while: + next(); + node.test = parseParenExpression(); + labels.push(loopLabel); + node.body = parseStatement(); + labels.pop(); + return finishNode(node, "WhileStatement"); + + case _with: + if (strict) raise(tokStart, "'with' in strict mode"); + next(); + node.object = parseParenExpression(); + node.body = parseStatement(); + return finishNode(node, "WithStatement"); + + case _braceL: + return parseBlock(); + + case _semi: + next(); + return finishNode(node, "EmptyStatement"); + + // If the statement does not start with a statement keyword or a + // brace, it's an ExpressionStatement or LabeledStatement. We + // simply start parsing an expression, and afterwards, if the + // next token is a colon and the expression was a simple + // Identifier node, we switch to interpreting it as a label. + + default: + var maybeName = tokVal, expr = parseExpression(); + if (starttype === _name && expr.type === "Identifier" && eat(_colon)) { + for (var i = 0; i < labels.length; ++i) + if (labels[i].name === maybeName) raise(expr.start, "Label '" + maybeName + "' is already declared"); + var kind = tokType.isLoop ? "loop" : tokType === _switch ? "switch" : null; + labels.push({name: maybeName, kind: kind}); + node.body = parseStatement(); + labels.pop(); + node.label = expr; + return finishNode(node, "LabeledStatement"); + } else { + node.expression = expr; + semicolon(); + return finishNode(node, "ExpressionStatement"); + } + } + } + + // Used for constructs like `switch` and `if` that insist on + // parentheses around their expression. + + function parseParenExpression() { + expect(_parenL); + var val = parseExpression(); + expect(_parenR); + return val; + } + + // Parse a semicolon-enclosed block of statements, handling `"use + // strict"` declarations when `allowStrict` is true (used for + // function bodies). + + function parseBlock(allowStrict) { + var node = startNode(), first = true, strict = false, oldStrict; + node.body = []; + expect(_braceL); + while (!eat(_braceR)) { + var stmt = parseStatement(); + node.body.push(stmt); + if (first && isUseStrict(stmt)) { + oldStrict = strict; + setStrict(strict = true); + } + first = false + } + if (strict && !oldStrict) setStrict(false); + return finishNode(node, "BlockStatement"); + } + + // Parse a regular `for` loop. The disambiguation code in + // `parseStatement` will already have parsed the init statement or + // expression. + + function parseFor(node, init) { + node.init = init; + expect(_semi); + node.test = tokType === _semi ? null : parseExpression(); + expect(_semi); + node.update = tokType === _parenR ? null : parseExpression(); + expect(_parenR); + node.body = parseStatement(); + labels.pop(); + return finishNode(node, "ForStatement"); + } + + // Parse a `for`/`in` loop. + + function parseForIn(node, init) { + node.left = init; + node.right = parseExpression(); + expect(_parenR); + node.body = parseStatement(); + labels.pop(); + return finishNode(node, "ForInStatement"); + } + + // Parse a list of variable declarations. + + function parseVar(node, noIn) { + node.declarations = []; + node.kind = "var"; + for (;;) { + var decl = startNode(); + decl.id = parseIdent(); + if (strict && isStrictBadIdWord(decl.id.name)) + raise(decl.id.start, "Binding " + decl.id.name + " in strict mode"); + decl.init = eat(_eq) ? parseExpression(true, noIn) : null; + node.declarations.push(finishNode(decl, "VariableDeclarator")); + if (!eat(_comma)) break; + } + return finishNode(node, "VariableDeclaration"); + } + + // ### Expression parsing + + // These nest, from the most general expression type at the top to + // 'atomic', nondivisible expression types at the bottom. Most of + // the functions will simply let the function(s) below them parse, + // and, *if* the syntactic construct they handle is present, wrap + // the AST node that the inner parser gave them in another node. + + // Parse a full expression. The arguments are used to forbid comma + // sequences (in argument lists, array literals, or object literals) + // or the `in` operator (in for loops initalization expressions). + + function parseExpression(noComma, noIn) { + var expr = parseMaybeAssign(noIn); + if (!noComma && tokType === _comma) { + var node = startNodeFrom(expr); + node.expressions = [expr]; + while (eat(_comma)) node.expressions.push(parseMaybeAssign(noIn)); + return finishNode(node, "SequenceExpression"); + } + return expr; + } + + // Parse an assignment expression. This includes applications of + // operators like `+=`. + + function parseMaybeAssign(noIn) { + var left = parseMaybeConditional(noIn); + if (tokType.isAssign) { + var node = startNodeFrom(left); + node.operator = tokVal; + node.left = left; + next(); + node.right = parseMaybeAssign(noIn); + checkLVal(left); + return finishNode(node, "AssignmentExpression"); + } + return left; + } + + // Parse a ternary conditional (`?:`) operator. + + function parseMaybeConditional(noIn) { + var expr = parseExprOps(noIn); + if (eat(_question)) { + var node = startNodeFrom(expr); + node.test = expr; + node.consequent = parseExpression(true); + expect(_colon); + node.alternate = parseExpression(true, noIn); + return finishNode(node, "ConditionalExpression"); + } + return expr; + } + + // Start the precedence parser. + + function parseExprOps(noIn) { + return parseExprOp(parseMaybeUnary(noIn), -1, noIn); + } + + // Parse binary operators with the operator precedence parsing + // algorithm. `left` is the left-hand side of the operator. + // `minPrec` provides context that allows the function to stop and + // defer further parser to one of its callers when it encounters an + // operator that has a lower precedence than the set it is parsing. + + function parseExprOp(left, minPrec, noIn) { + var prec = tokType.binop; + if (prec != null && (!noIn || tokType !== _in)) { + if (prec > minPrec) { + var node = startNodeFrom(left); + node.left = left; + node.operator = tokVal; + next(); + node.right = parseExprOp(parseMaybeUnary(noIn), prec, noIn); + var node = finishNode(node, /&&|\|\|/.test(node.operator) ? "LogicalExpression" : "BinaryExpression"); + return parseExprOp(node, minPrec, noIn); + } + } + return left; + } + + // Parse unary operators, both prefix and postfix. + + function parseMaybeUnary(noIn) { + if (tokType.prefix) { + var node = startNode(), update = tokType.isUpdate; + node.operator = tokVal; + node.prefix = true; + next(); + node.argument = parseMaybeUnary(noIn); + if (update) checkLVal(node.argument); + else if (strict && node.operator === "delete" && + node.argument.type === "Identifier") + raise(node.start, "Deleting local variable in strict mode"); + return finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); + } + var expr = parseExprSubscripts(); + while (tokType.postfix && !canInsertSemicolon()) { + var node = startNodeFrom(expr); + node.operator = tokVal; + node.prefix = false; + node.argument = expr; + checkLVal(expr); + next(); + expr = finishNode(node, "UpdateExpression"); + } + return expr; + } + + // Parse call, dot, and `[]`-subscript expressions. + + function parseExprSubscripts() { + return parseSubscripts(parseExprAtom()); + } + + function parseSubscripts(base, noCalls) { + if (eat(_dot)) { + var node = startNodeFrom(base); + node.object = base; + node.property = parseIdent(true); + node.computed = false; + return parseSubscripts(finishNode(node, "MemberExpression"), noCalls); + } else if (eat(_bracketL)) { + var node = startNodeFrom(base); + node.object = base; + node.property = parseExpression(); + node.computed = true; + expect(_bracketR); + return parseSubscripts(finishNode(node, "MemberExpression"), noCalls); + } else if (!noCalls && eat(_parenL)) { + var node = startNodeFrom(base); + node.callee = base; + node.arguments = parseExprList(_parenR, false); + return parseSubscripts(finishNode(node, "CallExpression"), noCalls); + } else return base; + } + + // Parse an atomic expression — either a single token that is an + // expression, an expression started by a keyword like `function` or + // `new`, or an expression wrapped in punctuation like `()`, `[]`, + // or `{}`. + + function parseExprAtom() { + switch (tokType) { + case _this: + var node = startNode(); + next(); + return finishNode(node, "ThisExpression"); + case _name: + return parseIdent(); + case _num: case _string: case _regexp: + var node = startNode(); + node.value = tokVal; + node.raw = input.slice(tokStart, tokEnd); + next(); + return finishNode(node, "Literal"); + + case _null: case _true: case _false: + var node = startNode(); + node.value = tokType.atomValue; + node.raw = tokType.keyword + next(); + return finishNode(node, "Literal"); + + case _parenL: + var tokStartLoc1 = tokStartLoc, tokStart1 = tokStart; + next(); + var val = parseExpression(); + val.start = tokStart1; + val.end = tokEnd; + if (options.locations) { + val.loc.start = tokStartLoc1; + val.loc.end = tokEndLoc; + } + if (options.ranges) + val.range = [tokStart1, tokEnd]; + expect(_parenR); + return val; + + case _bracketL: + var node = startNode(); + next(); + node.elements = parseExprList(_bracketR, true, true); + return finishNode(node, "ArrayExpression"); + + case _braceL: + return parseObj(); + + case _function: + var node = startNode(); + next(); + return parseFunction(node, false); + + case _new: + return parseNew(); + + default: + unexpected(); + } + } + + // New's precedence is slightly tricky. It must allow its argument + // to be a `[]` or dot subscript expression, but not a call — at + // least, not without wrapping it in parentheses. Thus, it uses the + + function parseNew() { + var node = startNode(); + next(); + node.callee = parseSubscripts(parseExprAtom(), true); + if (eat(_parenL)) node.arguments = parseExprList(_parenR, false); + else node.arguments = []; + return finishNode(node, "NewExpression"); + } + + // Parse an object literal. + + function parseObj() { + var node = startNode(), first = true, sawGetSet = false; + node.properties = []; + next(); + while (!eat(_braceR)) { + if (!first) { + expect(_comma); + if (options.allowTrailingCommas && eat(_braceR)) break; + } else first = false; + + var prop = {key: parsePropertyName()}, isGetSet = false, kind; + if (eat(_colon)) { + prop.value = parseExpression(true); + kind = prop.kind = "init"; + } else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" && + (prop.key.name === "get" || prop.key.name === "set")) { + isGetSet = sawGetSet = true; + kind = prop.kind = prop.key.name; + prop.key = parsePropertyName(); + if (tokType !== _parenL) unexpected(); + prop.value = parseFunction(startNode(), false); + } else unexpected(); + + // getters and setters are not allowed to clash — either with + // each other or with an init property — and in strict mode, + // init properties are also not allowed to be repeated. + + if (prop.key.type === "Identifier" && (strict || sawGetSet)) { + for (var i = 0; i < node.properties.length; ++i) { + var other = node.properties[i]; + if (other.key.name === prop.key.name) { + var conflict = kind == other.kind || isGetSet && other.kind === "init" || + kind === "init" && (other.kind === "get" || other.kind === "set"); + if (conflict && !strict && kind === "init" && other.kind === "init") conflict = false; + if (conflict) raise(prop.key.start, "Redefinition of property"); + } + } + } + node.properties.push(prop); + } + return finishNode(node, "ObjectExpression"); + } + + function parsePropertyName() { + if (tokType === _num || tokType === _string) return parseExprAtom(); + return parseIdent(true); + } + + // Parse a function declaration or literal (depending on the + // `isStatement` parameter). + + function parseFunction(node, isStatement) { + if (tokType === _name) node.id = parseIdent(); + else if (isStatement) unexpected(); + else node.id = null; + node.params = []; + var first = true; + expect(_parenL); + while (!eat(_parenR)) { + if (!first) expect(_comma); else first = false; + node.params.push(parseIdent()); + } + + // Start a new scope with regard to labels and the `inFunction` + // flag (restore them to their old value afterwards). + var oldInFunc = inFunction, oldLabels = labels; + inFunction = true; labels = []; + node.body = parseBlock(true); + inFunction = oldInFunc; labels = oldLabels; + + // If this is a strict mode function, verify that argument names + // are not repeated, and it does not try to bind the words `eval` + // or `arguments`. + if (strict || node.body.body.length && isUseStrict(node.body.body[0])) { + for (var i = node.id ? -1 : 0; i < node.params.length; ++i) { + var id = i < 0 ? node.id : node.params[i]; + if (isStrictReservedWord(id.name) || isStrictBadIdWord(id.name)) + raise(id.start, "Defining '" + id.name + "' in strict mode"); + if (i >= 0) for (var j = 0; j < i; ++j) if (id.name === node.params[j].name) + raise(id.start, "Argument name clash in strict mode"); + } + } + + return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression"); + } + + // Parses a comma-separated list of expressions, and returns them as + // an array. `close` is the token type that ends the list, and + // `allowEmpty` can be turned on to allow subsequent commas with + // nothing in between them to be parsed as `null` (which is needed + // for array literals). + + function parseExprList(close, allowTrailingComma, allowEmpty) { + var elts = [], first = true; + while (!eat(close)) { + if (!first) { + expect(_comma); + if (allowTrailingComma && options.allowTrailingCommas && eat(close)) break; + } else first = false; + + if (allowEmpty && tokType === _comma) elts.push(null); + else elts.push(parseExpression(true)); + } + return elts; + } + + // Parse the next token as an identifier. If `liberal` is true (used + // when parsing properties), it will also convert keywords into + // identifiers. + + function parseIdent(liberal) { + var node = startNode(); + node.name = tokType === _name ? tokVal : (liberal && !options.forbidReserved && tokType.keyword) || unexpected(); + next(); + return finishNode(node, "Identifier"); + } + +}); diff --git a/toolkit/devtools/acorn/acorn_loose.js b/toolkit/devtools/acorn/acorn_loose.js new file mode 100644 index 000000000000..cc398f39e12e --- /dev/null +++ b/toolkit/devtools/acorn/acorn_loose.js @@ -0,0 +1,774 @@ +// Acorn: Loose parser +// +// This module provides an alternative parser (`parse_dammit`) that +// exposes that same interface as `parse`, but will try to parse +// anything as JavaScript, repairing syntax error the best it can. +// There are circumstances in which it will raise an error and give +// up, but they are very rare. The resulting AST will be a mostly +// valid JavaScript AST (as per the [Mozilla parser API][api], except +// that: +// +// - Return outside functions is allowed +// +// - Label consistency (no conflicts, break only to existing labels) +// is not enforced. +// +// - Bogus Identifier nodes with a name of `"✖"` are inserted whenever +// the parser got too confused to return anything meaningful. +// +// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API +// +// The expected use for this is to *first* try `acorn.parse`, and only +// if that fails switch to `parse_dammit`. The loose parser might +// parse badly indented code incorrectly, so **don't** use it as +// your default parser. +// +// Quite a lot of acorn.js is duplicated here. The alternative was to +// add a *lot* of extra cruft to that file, making it less readable +// and slower. Copying and editing the code allowed me to make +// invasive changes and simplifications without creating a complicated +// tangle. + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") return mod(exports, require("./acorn")); // CommonJS + if (typeof define == "function" && define.amd) return define(["exports", "./acorn"], mod); // AMD + mod(self.acorn || (self.acorn = {}), self.acorn); // Plain browser env +})(function(exports, acorn) { + "use strict"; + + var tt = acorn.tokTypes; + + var options, input, fetchToken, context; + + exports.parse_dammit = function(inpt, opts) { + if (!opts) opts = {}; + input = String(inpt); + options = opts; + if (!opts.tabSize) opts.tabSize = 4; + fetchToken = acorn.tokenize(inpt, opts); + sourceFile = options.sourceFile || null; + context = []; + nextLineStart = 0; + ahead.length = 0; + next(); + return parseTopLevel(); + }; + + var lastEnd, token = {start: 0, end: 0}, ahead = []; + var curLineStart, nextLineStart, curIndent, lastEndLoc, sourceFile; + + function next() { + lastEnd = token.end; + if (options.locations) + lastEndLoc = token.endLoc; + + if (ahead.length) + token = ahead.shift(); + else + token = readToken(); + + if (token.start >= nextLineStart) { + while (token.start >= nextLineStart) { + curLineStart = nextLineStart; + nextLineStart = lineEnd(curLineStart) + 1; + } + curIndent = indentationAfter(curLineStart); + } + } + + function readToken() { + for (;;) { + try { + return fetchToken(); + } catch(e) { + if (!(e instanceof SyntaxError)) throw e; + + // Try to skip some text, based on the error message, and then continue + var msg = e.message, pos = e.raisedAt, replace = true; + if (/unterminated/i.test(msg)) { + pos = lineEnd(e.pos); + if (/string/.test(msg)) { + replace = {start: e.pos, end: pos, type: tt.string, value: input.slice(e.pos + 1, pos)}; + } else if (/regular expr/i.test(msg)) { + var re = input.slice(e.pos, pos); + try { re = new RegExp(re); } catch(e) {} + replace = {start: e.pos, end: pos, type: tt.regexp, value: re}; + } else { + replace = false; + } + } else if (/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number/i.test(msg)) { + while (pos < input.length && !isSpace(input.charCodeAt(pos))) ++pos; + } else if (/character escape|expected hexadecimal/i.test(msg)) { + while (pos < input.length) { + var ch = input.charCodeAt(pos++); + if (ch === 34 || ch === 39 || isNewline(ch)) break; + } + } else if (/unexpected character/i.test(msg)) { + pos++; + replace = false; + } else { + throw e; + } + resetTo(pos); + if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖"}; + if (replace) { + if (options.locations) { + replace.startLoc = acorn.getLineInfo(input, replace.start); + replace.endLoc = acorn.getLineInfo(input, replace.end); + } + return replace; + } + } + } + } + + function resetTo(pos) { + var ch = input.charAt(pos - 1); + var reAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) || + /[enwfd]/.test(ch) && /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(input.slice(pos - 10, pos)); + fetchToken.jumpTo(pos, reAllowed); + } + + function copyToken(token) { + var copy = {start: token.start, end: token.end, type: token.type, value: token.value}; + if (options.locations) { + copy.startLoc = token.startLoc; + copy.endLoc = token.endLoc; + } + return copy; + } + + function lookAhead(n) { + // Copy token objects, because fetchToken will overwrite the one + // it returns, and in this case we still need it + if (!ahead.length) + token = copyToken(token); + while (n > ahead.length) + ahead.push(copyToken(readToken())); + return ahead[n-1]; + } + + var newline = /[\n\r\u2028\u2029]/; + + function isNewline(ch) { + return ch === 10 || ch === 13 || ch === 8232 || ch === 8329; + } + function isSpace(ch) { + return (ch < 14 && ch > 8) || ch === 32 || ch === 160 || isNewline(ch); + } + + function pushCx() { + context.push(curIndent); + } + function popCx() { + curIndent = context.pop(); + } + + function lineEnd(pos) { + while (pos < input.length && !isNewline(input.charCodeAt(pos))) ++pos; + return pos; + } + function lineStart(pos) { + while (pos > 0 && !isNewline(input.charCodeAt(pos - 1))) --pos; + return pos; + } + function indentationAfter(pos) { + for (var count = 0;; ++pos) { + var ch = input.charCodeAt(pos); + if (ch === 32) ++count; + else if (ch === 9) count += options.tabSize; + else return count; + } + } + + function closesBlock(closeTok, indent, line) { + if (token.type === closeTok || token.type === tt.eof) return true; + if (line != curLineStart && curIndent < indent && tokenStartsLine() && + (nextLineStart >= input.length || + indentationAfter(nextLineStart) < indent)) return true; + return false; + } + + function tokenStartsLine() { + for (var p = token.start - 1; p > curLineStart; --p) { + var ch = input.charCodeAt(p); + if (ch !== 9 && ch !== 32) return false; + } + return true; + } + + function node_t(start) { + this.type = null; + this.start = start; + this.end = null; + } + + function node_loc_t(start) { + this.start = start || token.startLoc || {line: 1, column: 0}; + this.end = null; + if (sourceFile !== null) this.source = sourceFile; + } + + function startNode() { + var node = new node_t(token.start); + if (options.locations) + node.loc = new node_loc_t(); + return node + } + + function startNodeFrom(other) { + var node = new node_t(other.start); + if (options.locations) + node.loc = new node_loc_t(other.loc.start); + return node; + } + + function finishNode(node, type) { + node.type = type; + node.end = lastEnd; + if (options.locations) + node.loc.end = lastEndLoc; + return node; + } + + function getDummyLoc() { + if (options.locations) { + var loc = new node_loc_t(); + loc.end = loc.start; + return loc; + } + }; + + function dummyIdent() { + var dummy = new node_t(token.start); + dummy.type = "Identifier"; + dummy.end = token.start; + dummy.name = "✖"; + dummy.loc = getDummyLoc(); + return dummy; + } + function isDummy(node) { return node.name == "✖"; } + + function eat(type) { + if (token.type === type) { + next(); + return true; + } + } + + function canInsertSemicolon() { + return (token.type === tt.eof || token.type === tt.braceR || newline.test(input.slice(lastEnd, token.start))); + } + function semicolon() { + eat(tt.semi); + } + + function expect(type) { + if (eat(type)) return true; + if (lookAhead(1).type == type) { + next(); next(); + return true; + } + if (lookAhead(2).type == type) { + next(); next(); next(); + return true; + } + } + + function checkLVal(expr) { + if (expr.type === "Identifier" || expr.type === "MemberExpression") return expr; + return dummyIdent(); + } + + function parseTopLevel() { + var node = startNode(); + node.body = []; + while (token.type !== tt.eof) node.body.push(parseStatement()); + return finishNode(node, "Program"); + } + + function parseStatement() { + var starttype = token.type, node = startNode(); + + switch (starttype) { + case tt.break: case tt.continue: + next(); + var isBreak = starttype === tt.break; + node.label = token.type === tt.name ? parseIdent() : null; + semicolon(); + return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement"); + + case tt.debugger: + next(); + semicolon(); + return finishNode(node, "DebuggerStatement"); + + case tt.do: + next(); + node.body = parseStatement(); + node.test = eat(tt.while) ? parseParenExpression() : dummyIdent(); + semicolon(); + return finishNode(node, "DoWhileStatement"); + + case tt.for: + next(); + pushCx(); + expect(tt.parenL); + if (token.type === tt.semi) return parseFor(node, null); + if (token.type === tt.var) { + var init = startNode(); + next(); + parseVar(init, true); + if (init.declarations.length === 1 && eat(tt.in)) + return parseForIn(node, init); + return parseFor(node, init); + } + var init = parseExpression(false, true); + if (eat(tt.in)) {return parseForIn(node, checkLVal(init));} + return parseFor(node, init); + + case tt.function: + next(); + return parseFunction(node, true); + + case tt.if: + next(); + node.test = parseParenExpression(); + node.consequent = parseStatement(); + node.alternate = eat(tt.else) ? parseStatement() : null; + return finishNode(node, "IfStatement"); + + case tt.return: + next(); + if (eat(tt.semi) || canInsertSemicolon()) node.argument = null; + else { node.argument = parseExpression(); semicolon(); } + return finishNode(node, "ReturnStatement"); + + case tt.switch: + var blockIndent = curIndent, line = curLineStart; + next(); + node.discriminant = parseParenExpression(); + node.cases = []; + pushCx(); + expect(tt.braceL); + + for (var cur; !closesBlock(tt.braceR, blockIndent, line);) { + if (token.type === tt.case || token.type === tt.default) { + var isCase = token.type === tt.case; + if (cur) finishNode(cur, "SwitchCase"); + node.cases.push(cur = startNode()); + cur.consequent = []; + next(); + if (isCase) cur.test = parseExpression(); + else cur.test = null; + expect(tt.colon); + } else { + if (!cur) { + node.cases.push(cur = startNode()); + cur.consequent = []; + cur.test = null; + } + cur.consequent.push(parseStatement()); + } + } + if (cur) finishNode(cur, "SwitchCase"); + popCx(); + eat(tt.braceR); + return finishNode(node, "SwitchStatement"); + + case tt.throw: + next(); + node.argument = parseExpression(); + semicolon(); + return finishNode(node, "ThrowStatement"); + + case tt.try: + next(); + node.block = parseBlock(); + node.handler = null; + if (token.type === tt.catch) { + var clause = startNode(); + next(); + expect(tt.parenL); + clause.param = parseIdent(); + expect(tt.parenR); + clause.guard = null; + clause.body = parseBlock(); + node.handler = finishNode(clause, "CatchClause"); + } + node.finalizer = eat(tt.finally) ? parseBlock() : null; + if (!node.handler && !node.finalizer) return node.block; + return finishNode(node, "TryStatement"); + + case tt.var: + next(); + node = parseVar(node); + semicolon(); + return node; + + case tt.while: + next(); + node.test = parseParenExpression(); + node.body = parseStatement(); + return finishNode(node, "WhileStatement"); + + case tt.with: + next(); + node.object = parseParenExpression(); + node.body = parseStatement(); + return finishNode(node, "WithStatement"); + + case tt.braceL: + return parseBlock(); + + case tt.semi: + next(); + return finishNode(node, "EmptyStatement"); + + default: + var maybeName = token.value, expr = parseExpression(); + if (isDummy(expr)) { + next(); + if (token.type === tt.eof) return finishNode(node, "EmptyStatement"); + return parseStatement(); + } else if (starttype === tt.name && expr.type === "Identifier" && eat(tt.colon)) { + node.body = parseStatement(); + node.label = expr; + return finishNode(node, "LabeledStatement"); + } else { + node.expression = expr; + semicolon(); + return finishNode(node, "ExpressionStatement"); + } + } + } + + function parseBlock() { + var node = startNode(); + pushCx(); + expect(tt.braceL); + var blockIndent = curIndent, line = curLineStart; + node.body = []; + while (!closesBlock(tt.braceR, blockIndent, line)) + node.body.push(parseStatement()); + popCx(); + eat(tt.braceR); + return finishNode(node, "BlockStatement"); + } + + function parseFor(node, init) { + node.init = init; + node.test = node.update = null; + if (eat(tt.semi) && token.type !== tt.semi) node.test = parseExpression(); + if (eat(tt.semi) && token.type !== tt.parenR) node.update = parseExpression(); + popCx(); + expect(tt.parenR); + node.body = parseStatement(); + return finishNode(node, "ForStatement"); + } + + function parseForIn(node, init) { + node.left = init; + node.right = parseExpression(); + popCx(); + expect(tt.parenR); + node.body = parseStatement(); + return finishNode(node, "ForInStatement"); + } + + function parseVar(node, noIn) { + node.declarations = []; + node.kind = "var"; + while (token.type === tt.name) { + var decl = startNode(); + decl.id = parseIdent(); + decl.init = eat(tt.eq) ? parseExpression(true, noIn) : null; + node.declarations.push(finishNode(decl, "VariableDeclarator")); + if (!eat(tt.comma)) break; + } + return finishNode(node, "VariableDeclaration"); + } + + function parseExpression(noComma, noIn) { + var expr = parseMaybeAssign(noIn); + if (!noComma && token.type === tt.comma) { + var node = startNodeFrom(expr); + node.expressions = [expr]; + while (eat(tt.comma)) node.expressions.push(parseMaybeAssign(noIn)); + return finishNode(node, "SequenceExpression"); + } + return expr; + } + + function parseParenExpression() { + pushCx(); + expect(tt.parenL); + var val = parseExpression(); + popCx(); + expect(tt.parenR); + return val; + } + + function parseMaybeAssign(noIn) { + var left = parseMaybeConditional(noIn); + if (token.type.isAssign) { + var node = startNodeFrom(left); + node.operator = token.value; + node.left = checkLVal(left); + next(); + node.right = parseMaybeAssign(noIn); + return finishNode(node, "AssignmentExpression"); + } + return left; + } + + function parseMaybeConditional(noIn) { + var expr = parseExprOps(noIn); + if (eat(tt.question)) { + var node = startNodeFrom(expr); + node.test = expr; + node.consequent = parseExpression(true); + node.alternate = expect(tt.colon) ? parseExpression(true, noIn) : dummyIdent(); + return finishNode(node, "ConditionalExpression"); + } + return expr; + } + + function parseExprOps(noIn) { + var indent = curIndent, line = curLineStart; + return parseExprOp(parseMaybeUnary(noIn), -1, noIn, indent, line); + } + + function parseExprOp(left, minPrec, noIn, indent, line) { + if (curLineStart != line && curIndent < indent && tokenStartsLine()) return left; + var prec = token.type.binop; + if (prec != null && (!noIn || token.type !== tt.in)) { + if (prec > minPrec) { + var node = startNodeFrom(left); + node.left = left; + node.operator = token.value; + next(); + if (curLineStart != line && curIndent < indent && tokenStartsLine()) + node.right = dummyIdent(); + else + node.right = parseExprOp(parseMaybeUnary(noIn), prec, noIn, indent, line); + var node = finishNode(node, /&&|\|\|/.test(node.operator) ? "LogicalExpression" : "BinaryExpression"); + return parseExprOp(node, minPrec, noIn, indent, line); + } + } + return left; + } + + function parseMaybeUnary(noIn) { + if (token.type.prefix) { + var node = startNode(), update = token.type.isUpdate; + node.operator = token.value; + node.prefix = true; + next(); + node.argument = parseMaybeUnary(noIn); + if (update) node.argument = checkLVal(node.argument); + return finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); + } + var expr = parseExprSubscripts(); + while (token.type.postfix && !canInsertSemicolon()) { + var node = startNodeFrom(expr); + node.operator = token.value; + node.prefix = false; + node.argument = checkLVal(expr); + next(); + expr = finishNode(node, "UpdateExpression"); + } + return expr; + } + + function parseExprSubscripts() { + var indent = curIndent, line = curLineStart; + return parseSubscripts(parseExprAtom(), false, curIndent, line); + } + + function parseSubscripts(base, noCalls, startIndent, line) { + for (;;) { + if (curLineStart != line && curIndent <= startIndent && tokenStartsLine()) { + if (token.type == tt.dot && curIndent == startIndent) + --startIndent; + else + return base; + } + + if (eat(tt.dot)) { + var node = startNodeFrom(base); + node.object = base; + if (curLineStart != line && curIndent <= startIndent && tokenStartsLine()) + node.property = dummyIdent(); + else + node.property = parsePropertyName() || dummyIdent(); + node.computed = false; + base = finishNode(node, "MemberExpression"); + } else if (token.type == tt.bracketL) { + pushCx(); + next(); + var node = startNodeFrom(base); + node.object = base; + node.property = parseExpression(); + node.computed = true; + popCx(); + expect(tt.bracketR); + base = finishNode(node, "MemberExpression"); + } else if (!noCalls && token.type == tt.parenL) { + pushCx(); + var node = startNodeFrom(base); + node.callee = base; + node.arguments = parseExprList(tt.parenR); + base = finishNode(node, "CallExpression"); + } else { + return base; + } + } + } + + function parseExprAtom() { + switch (token.type) { + case tt.this: + var node = startNode(); + next(); + return finishNode(node, "ThisExpression"); + case tt.name: + return parseIdent(); + case tt.num: case tt.string: case tt.regexp: + var node = startNode(); + node.value = token.value; + node.raw = input.slice(token.start, token.end); + next(); + return finishNode(node, "Literal"); + + case tt.null: case tt.true: case tt.false: + var node = startNode(); + node.value = token.type.atomValue; + node.raw = token.type.keyword + next(); + return finishNode(node, "Literal"); + + case tt.parenL: + var tokStart1 = token.start; + next(); + var val = parseExpression(); + val.start = tokStart1; + val.end = token.end; + expect(tt.parenR); + return val; + + case tt.bracketL: + var node = startNode(); + pushCx(); + node.elements = parseExprList(tt.bracketR); + return finishNode(node, "ArrayExpression"); + + case tt.braceL: + return parseObj(); + + case tt.function: + var node = startNode(); + next(); + return parseFunction(node, false); + + case tt.new: + return parseNew(); + + default: + return dummyIdent(); + } + } + + function parseNew() { + var node = startNode(), startIndent = curIndent, line = curLineStart; + next(); + node.callee = parseSubscripts(parseExprAtom(), true, startIndent, line); + if (token.type == tt.parenL) { + pushCx(); + node.arguments = parseExprList(tt.parenR); + } else { + node.arguments = []; + } + return finishNode(node, "NewExpression"); + } + + function parseObj() { + var node = startNode(); + node.properties = []; + pushCx(); + next(); + var propIndent = curIndent, line = curLineStart; + while (!closesBlock(tt.braceR, propIndent, line)) { + var name = parsePropertyName(); + if (!name) { if (isDummy(parseExpression(true))) next(); eat(tt.comma); continue; } + var prop = {key: name}, isGetSet = false, kind; + if (eat(tt.colon)) { + prop.value = parseExpression(true); + kind = prop.kind = "init"; + } else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" && + (prop.key.name === "get" || prop.key.name === "set")) { + isGetSet = true; + kind = prop.kind = prop.key.name; + prop.key = parsePropertyName() || dummyIdent(); + prop.value = parseFunction(startNode(), false); + } else { + next(); + eat(tt.comma); + continue; + } + + node.properties.push(prop); + eat(tt.comma); + } + popCx(); + eat(tt.braceR); + return finishNode(node, "ObjectExpression"); + } + + function parsePropertyName() { + if (token.type === tt.num || token.type === tt.string) return parseExprAtom(); + if (token.type === tt.name || token.type.keyword) return parseIdent(); + } + + function parseIdent() { + var node = startNode(); + node.name = token.type === tt.name ? token.value : token.type.keyword; + next(); + return finishNode(node, "Identifier"); + } + + function parseFunction(node, isStatement) { + if (token.type === tt.name) node.id = parseIdent(); + else if (isStatement) node.id = dummyIdent(); + else node.id = null; + node.params = []; + pushCx(); + expect(tt.parenL); + while (token.type == tt.name) { + node.params.push(parseIdent()); + eat(tt.comma); + } + popCx(); + eat(tt.parenR); + node.body = parseBlock(); + return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression"); + } + + function parseExprList(close) { + var indent = curIndent + 1, line = curLineStart, elts = []; + next(); // Opening bracket + while (!closesBlock(close, indent, line)) { + var elt = parseExpression(true); + if (isDummy(elt)) { + if (closesBlock(close, indent, line)) break; + next(); + } else { + elts.push(elt); + } + while (eat(tt.comma)) {} + } + popCx(); + eat(close); + return elts; + } +}); diff --git a/toolkit/devtools/acorn/moz.build b/toolkit/devtools/acorn/moz.build new file mode 100644 index 000000000000..1eafb9bc9250 --- /dev/null +++ b/toolkit/devtools/acorn/moz.build @@ -0,0 +1,14 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini'] + +JS_MODULES_PATH = 'modules/devtools/acorn' + +EXTRA_JS_MODULES += [ + 'acorn.js', + 'acorn_loose.js', +] diff --git a/toolkit/devtools/acorn/tests/unit/head_acorn.js b/toolkit/devtools/acorn/tests/unit/head_acorn.js new file mode 100644 index 000000000000..933cfd63acdd --- /dev/null +++ b/toolkit/devtools/acorn/tests/unit/head_acorn.js @@ -0,0 +1,71 @@ +"use strict"; +const { classes: Cc, interfaces: Ci, utils: Cu } = Components; +const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); +const { require } = devtools; + + +function isObject(value) { + return typeof value === "object" && value !== null; +} + +function intersect(a, b) { + const seen = new Set(a); + return b.filter(value => seen.has(value)); +} + +function checkEquivalentASTs(expected, actual, prop = []) { + do_print("Checking: " + prop.join(" ")); + + if (!isObject(expected)) { + return void do_check_eq(expected, actual); + } + + do_check_true(isObject(actual)); + + if (Array.isArray(expected)) { + do_check_true(Array.isArray(actual)); + do_check_eq(expected.length, actual.length); + for (let i = 0; i < expected.length; i++) { + checkEquivalentASTs(expected[i], actual[i], prop.concat(i)); + } + } else { + // We must intersect the keys since acorn and Reflect have different + // extraneous properties on their AST nodes. + const keys = intersect(Object.keys(expected), Object.keys(actual)); + for (let key of keys) { + checkEquivalentASTs(expected[key], actual[key], prop.concat(key)); + } + } +} + + +// Register a console listener, so console messages don't just disappear +// into the ether. +let errorCount = 0; +let listener = { + observe: function (aMessage) { + errorCount++; + try { + // If we've been given an nsIScriptError, then we can print out + // something nicely formatted, for tools like Emacs to pick up. + var scriptError = aMessage.QueryInterface(Ci.nsIScriptError); + dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " + + scriptErrorFlagsToKind(aMessage.flags) + ": " + + aMessage.errorMessage + "\n"); + var string = aMessage.errorMessage; + } catch (x) { + // Be a little paranoid with message, as the whole goal here is to lose + // no information. + try { + var string = "" + aMessage.message; + } catch (x) { + var string = ""; + } + } + + do_throw("head_acorn.js got console message: " + string + "\n"); + } +}; + +let consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); +consoleService.registerListener(listener); \ No newline at end of file diff --git a/toolkit/devtools/acorn/tests/unit/test_import_acorn.js b/toolkit/devtools/acorn/tests/unit/test_import_acorn.js new file mode 100644 index 000000000000..d9d72ef2684a --- /dev/null +++ b/toolkit/devtools/acorn/tests/unit/test_import_acorn.js @@ -0,0 +1,15 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that we can require acorn. + */ + +function run_test() { + const acorn = require("acorn/acorn"); + const acorn_loose = require("acorn/acorn_loose"); + do_check_true(isObject(acorn)); + do_check_true(isObject(acorn_loose)); + do_check_eq(typeof acorn.parse, "function"); + do_check_eq(typeof acorn_loose.parse_dammit, "function"); +} diff --git a/toolkit/devtools/acorn/tests/unit/test_lenient_parser.js b/toolkit/devtools/acorn/tests/unit/test_lenient_parser.js new file mode 100644 index 000000000000..794918b6357e --- /dev/null +++ b/toolkit/devtools/acorn/tests/unit/test_lenient_parser.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that acorn's lenient parser gives something usable. + */ + +const acorn_loose = require("acorn/acorn_loose"); + +function run_test() { + let actualAST = acorn_loose.parse_dammit("let x = 10"); + + do_print("Actual AST:"); + do_print(JSON.stringify(actualAST, null, 2)); + do_print("Expected AST:"); + do_print(JSON.stringify(expectedAST, null, 2)); + + checkEquivalentASTs(expectedAST, actualAST); +} + +const expectedAST = { + "type": "Program", + "start": 0, + "end": 10, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 3, + "expression": { + "type": "Identifier", + "start": 0, + "end": 3, + "name": "let" + } + }, + { + "type": "ExpressionStatement", + "start": 4, + "end": 10, + "expression": { + "type": "AssignmentExpression", + "start": 4, + "end": 10, + "operator": "=", + "left": { + "type": "Identifier", + "start": 4, + "end": 5, + "name": "x" + }, + "right": { + "type": "Literal", + "start": 8, + "end": 10, + "value": 10, + "raw": "10" + } + } + } + ] +}; diff --git a/toolkit/devtools/acorn/tests/unit/test_same_ast.js b/toolkit/devtools/acorn/tests/unit/test_same_ast.js new file mode 100644 index 000000000000..ce2de6076d77 --- /dev/null +++ b/toolkit/devtools/acorn/tests/unit/test_same_ast.js @@ -0,0 +1,37 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Test that Reflect and acorn create the same AST for ES5. + */ + +const acorn = require("acorn/acorn"); +Cu.import("resource://gre/modules/reflect.jsm"); + +const testCode = "" + function main () { + function makeAcc(n) { + return function () { + return ++n; + }; + } + + var acc = makeAcc(10); + + for (var i = 0; i < 10; i++) { + acc(); + } + + console.log(acc()); +}; + +function run_test() { + const reflectAST = Reflect.parse(testCode); + const acornAST = acorn.parse(testCode); + + do_print("Reflect AST:"); + do_print(JSON.stringify(reflectAST, null, 2)); + do_print("acorn AST:"); + do_print(JSON.stringify(acornAST, null, 2)); + + checkEquivalentASTs(reflectAST, acornAST); +} diff --git a/toolkit/devtools/acorn/tests/unit/xpcshell.ini b/toolkit/devtools/acorn/tests/unit/xpcshell.ini new file mode 100644 index 000000000000..57b9ce8c2074 --- /dev/null +++ b/toolkit/devtools/acorn/tests/unit/xpcshell.ini @@ -0,0 +1,7 @@ +[DEFAULT] +head = head_acorn.js +tail = + +[test_import_acorn.js] +[test_same_ast.js] +[test_lenient_parser.js] diff --git a/toolkit/devtools/moz.build b/toolkit/devtools/moz.build index 18610e613ccb..16897d5e427d 100644 --- a/toolkit/devtools/moz.build +++ b/toolkit/devtools/moz.build @@ -14,5 +14,6 @@ PARALLEL_DIRS += [ 'webconsole', 'apps', 'styleinspector', - 'escodegen' + 'escodegen', + 'acorn' ] From 351dc76914631bd2495188d0ba77678183feaba6 Mon Sep 17 00:00:00 2001 From: Sam Foster Date: Thu, 31 Oct 2013 14:00:28 -0700 Subject: [PATCH 560/795] Bug 931115 - Cache color info for favicon urls on colorUtils. r=mbrubeck --HG-- extra : rebase_source : d6147e13fac276f0552dfab40275d69a680635ab --- .../base/content/startui/TopSitesView.js | 1 - .../tests/mochitest/browser_colorUtils.js | 49 +++++++++ browser/metro/base/tests/mochitest/metro.ini | 1 + browser/metro/modules/View.jsm | 15 ++- browser/metro/modules/colorUtils.jsm | 101 ++++++++++++++---- 5 files changed, 140 insertions(+), 27 deletions(-) create mode 100644 browser/metro/base/tests/mochitest/browser_colorUtils.js diff --git a/browser/metro/base/content/startui/TopSitesView.js b/browser/metro/base/content/startui/TopSitesView.js index d3996e57d5e0..b3e20ababc61 100644 --- a/browser/metro/base/content/startui/TopSitesView.js +++ b/browser/metro/base/content/startui/TopSitesView.js @@ -8,7 +8,6 @@ let prefs = Components.classes["@mozilla.org/preferences-service;1"]. getService(Components.interfaces.nsIPrefBranch); Cu.import("resource://gre/modules/PageThumbs.jsm"); -Cu.import("resource:///modules/colorUtils.jsm"); function TopSitesView(aGrid, aMaxSites) { View.call(this, aGrid); diff --git a/browser/metro/base/tests/mochitest/browser_colorUtils.js b/browser/metro/base/tests/mochitest/browser_colorUtils.js new file mode 100644 index 000000000000..32149b71a757 --- /dev/null +++ b/browser/metro/base/tests/mochitest/browser_colorUtils.js @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +function test() { + runTests(); +} + +gTests.push({ + desc: "iconColorCache purges stale entries", + setUp: function() { + Components.utils.import("resource:///modules/colorUtils.jsm", this); + let dayMs = 86400000; + let ColorUtils = this.ColorUtils; + this.ColorUtils.init(); + + // add a stale cache entry + ColorUtils.iconColorCache.set('http://test.old/favicon.ico', { + "foreground":"rgb(255,255,255)", + "background":"rgb(78,78,84)", + "timestamp":Date.now() - (2*dayMs) + }); + // add a fresh cache entry + ColorUtils.iconColorCache.set('http://test.new/favicon.ico', { + "foreground":"rgb(255,255,255)", + "background":"rgb(78,78,84)", + "timestamp":Date.now() + }); + }, + run: function testIconColorCachePurge() { + let dayMs = 86400000; + let ColorUtils = this.ColorUtils; + let cachePurgeSpy = spyOnMethod(ColorUtils.iconColorCache, 'purge'); + + // notify observers, indicating a day has passed since last notification + Services.obs.notifyObservers(null, "idle-daily", dayMs); + is(cachePurgeSpy.callCount, 1); + cachePurgeSpy.restore(); + + ok(ColorUtils.iconColorCache.has('http://test.new/favicon.ico'), + "fresh cache entry was not removed in the purge"); + + ok(!ColorUtils.iconColorCache.has('http://test.old/favicon.ico'), + "stale cache entry was removed in the purge"); + } +}); diff --git a/browser/metro/base/tests/mochitest/metro.ini b/browser/metro/base/tests/mochitest/metro.ini index 8e75310614e4..c31d70aefb14 100644 --- a/browser/metro/base/tests/mochitest/metro.ini +++ b/browser/metro/base/tests/mochitest/metro.ini @@ -33,6 +33,7 @@ support-files = [browser_bookmarks.js] [browser_canonizeURL.js] [browser_circular_progress_indicator.js] +[browser_colorUtils.js] [browser_crashprompt.js] [browser_context_menu_tests.js] [browser_context_ui.js] diff --git a/browser/metro/modules/View.jsm b/browser/metro/modules/View.jsm index ee4201de97d2..d2e771856583 100644 --- a/browser/metro/modules/View.jsm +++ b/browser/metro/modules/View.jsm @@ -8,6 +8,7 @@ this.EXPORTED_SYMBOLS = ["View"]; Components.utils.import("resource://gre/modules/PlacesUtils.jsm"); Components.utils.import("resource:///modules/colorUtils.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/Task.jsm"); // -------------------------------- // module helpers @@ -31,7 +32,7 @@ function View(aSet) { observe: (aSubject, aTopic, aData) => this._adjustDOMforViewState(aData) }; Services.obs.addObserver(this.viewStateObserver, "metro_viewstate_changed", false); - + ColorUtils.init(); this._adjustDOMforViewState(); } @@ -87,7 +88,13 @@ View.prototype = { aItem.iconSrc = aIconUri.spec; let faviconURL = (PlacesUtils.favicons.getFaviconLinkForIcon(aIconUri)).spec; let xpFaviconURI = makeURI(faviconURL.replace("moz-anno:favicon:","")); - let successAction = function(foreground, background) { + + Task.spawn(function() { + let colorInfo = yield ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI); + if (!(colorInfo && colorInfo.background && colorInfo.foreground)) { + return; + } + let { background, foreground } = colorInfo; aItem.style.color = foreground; //color text aItem.setAttribute("customColor", background); let matteColor = 0xffffff; // white @@ -100,9 +107,7 @@ View.prototype = { if ('color' in aItem) { aItem.color = background; } - }; - let failureAction = function() {}; - ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI, successAction, failureAction); + }); } }; diff --git a/browser/metro/modules/colorUtils.jsm b/browser/metro/modules/colorUtils.jsm index cc887295a995..ffffe940446d 100644 --- a/browser/metro/modules/colorUtils.jsm +++ b/browser/metro/modules/colorUtils.jsm @@ -4,32 +4,91 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict'; Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/commonjs/sdk/core/promise.js"); + const ColorAnalyzer = Components.classes["@mozilla.org/places/colorAnalyzer;1"] .getService(Components.interfaces.mozIColorAnalyzer); this.EXPORTED_SYMBOLS = ["ColorUtils"]; let ColorUtils = { - /** Takes an icon and a success callback (who is expected to handle foreground color - * & background color as is desired) The first argument to the callback is - * the foreground/contrast color, the second is the background/primary/dominant one - */ - getForegroundAndBackgroundIconColors: function getForegroundAndBackgroundIconColors(aIconURI, aSuccessCallback, aErrorCallback) { - if (!aIconURI) { - return; - } - let that = this; - let wrappedIcon = aIconURI; - ColorAnalyzer.findRepresentativeColor(wrappedIcon, function (success, color) { - if (!success) { - aErrorCallback(); - } else { - let foregroundColor = that.bestTextColorForContrast(color); - let backgroundColor = that.convertDecimalToRgbColor(color); - aSuccessCallback(foregroundColor, backgroundColor); - } - }, this); + _initialized: false, + init: function() { + if (this._initialized) + return; + Services.obs.addObserver(this, "idle-daily", false); + Services.obs.addObserver(this, "quit-application", false); + this._initialized = true; }, + uninit: function() { + Services.obs.removeObserver(this, "idle-daily"); + Services.obs.removeObserver(this, "quit-application"); + }, + + // default to keeping icon colorInfo for max 1 day + iconColorCacheMaxAge: 86400000, + + // in-memory store for favicon color data + _uriColorsMap: (function() { + let cache = new Map(); + // remove stale entries + cache.purge = function(maxAgeMs = 0) { + let cuttoff = Date.now() - (maxAgeMs || ColorUtils.iconColorCacheMaxAge); + for (let [key, value] of this) { + if (value.timestamp && value.timestamp >= cuttoff) { + continue; + } + this.delete(key); + } + } + return cache; + })(), + get iconColorCache() { + return ColorUtils._uriColorsMap; + }, + + observe: function (aSubject, aTopic, aData) { + switch (aTopic) { + case "idle-daily": + this.iconColorCache.purge(); + break; + case "quit-application": + this.uninit(); + break; + } + }, + + /** Takes an icon and returns either an object with foreground and background color properties + * or a promise for the same. + * The foreground is the contrast color, the background is the primary/dominant one + */ + getForegroundAndBackgroundIconColors: function getForegroundAndBackgroundIconColors(aIconURI) { + let colorKey = aIconURI.spec; + let colorInfo = this._uriColorsMap.get(colorKey); + if (colorInfo) { + return colorInfo; + } + + let deferred = Promise.defer(); + let wrappedIcon = aIconURI; + this._uriColorsMap.set(colorKey, deferred.promise); + + ColorAnalyzer.findRepresentativeColor(wrappedIcon, (success, color) => { + if (!success) { + this._uriColorsMap.delete(colorKey); + deferred.reject(); + } else { + colorInfo = { + foreground: this.bestTextColorForContrast(color), + background: this.convertDecimalToRgbColor(color), + timestamp: Date.now() + }; + deferred.resolve(colorInfo); + } + }); + return deferred.promise; + }, + /** returns the best color for text readability on top of aColor * return color is in rgb(r,g,b) format, suitable to csss * The color bightness algorithm is currently: http://www.w3.org/TR/AERT#color-contrast @@ -52,7 +111,7 @@ let ColorUtils = { toCSSRgbColor: function toCSSRgbColor(r, g, b, a) { var values = [Math.round(r), Math.round(g), Math.round(b)]; - if(undefined !== a && a < 1) { + if (undefined !== a && a < 1) { values.push(a); return 'rgba('+values.join(',')+')'; } @@ -88,7 +147,7 @@ let ColorUtils = { rgb |= (g << 8); rgb |= (r << 16); // pack alpha value if one is given - if(undefined !== a && a < 1) + if (undefined !== a && a < 1) rgb |= (Math.round(a*255) << 24); return rgb; }, From a991caf336d837b2e4d9da3d82d66ea5468fde42 Mon Sep 17 00:00:00 2001 From: Rodrigo Silveira Date: Tue, 29 Oct 2013 21:29:07 -0700 Subject: [PATCH 561/795] Bug 927172 - Can't touch scroll when second monitor is attached r=jimm --- widget/windows/winrt/FrameworkView.cpp | 34 +++++++++++++++++--------- widget/windows/winrt/FrameworkView.h | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/widget/windows/winrt/FrameworkView.cpp b/widget/windows/winrt/FrameworkView.cpp index 9405006befb3..d5a383728bce 100644 --- a/widget/windows/winrt/FrameworkView.cpp +++ b/widget/windows/winrt/FrameworkView.cpp @@ -258,6 +258,7 @@ FrameworkView::UpdateWidgetSizeAndPosition() NS_ASSERTION(mWindow, "SetWindow must be called before UpdateWidgetSizeAndPosition!"); NS_ASSERTION(mWidget, "SetWidget must be called before UpdateWidgetSizeAndPosition!"); + UpdateBounds(); mWidget->Move(0, 0); mWidget->Resize(0, 0, mWindowBounds.width, mWindowBounds.height, true); mWidget->SizeModeChanged(); @@ -284,21 +285,34 @@ void FrameworkView::SetDpi(float aDpi) LogFunction(); mDPI = aDpi; - // Often a DPI change implies a window size change. - NS_ASSERTION(mWindow, "SetWindow must be called before SetDpi!"); - Rect logicalBounds; - mWindow->get_Bounds(&logicalBounds); - - // convert to physical (device) pixels - mWindowBounds = MetroUtils::LogToPhys(logicalBounds); // notify the widget that dpi has changed if (mWidget) { mWidget->ChangedDPI(); + UpdateBounds(); } } } +void +FrameworkView::UpdateBounds() +{ + if (!mWidget) + return; + + RECT winRect; + GetClientRect(mWidget->GetICoreWindowHWND(), &winRect); + + Rect logicalBounds; + logicalBounds.X = winRect.left; + logicalBounds.Y = winRect.top; + logicalBounds.Width = winRect.right - winRect.left; + logicalBounds.Height = winRect.bottom - winRect.top; + + // convert to physical (device) pixels + mWindowBounds = MetroUtils::LogToPhys(logicalBounds); +} + void FrameworkView::SetWidget(MetroWidget* aWidget) { @@ -307,6 +321,7 @@ FrameworkView::SetWidget(MetroWidget* aWidget) LogFunction(); mWidget = aWidget; mWidget->FindMetroWindow(); + UpdateBounds(); } //////////////////////////////////////////////////// @@ -394,11 +409,6 @@ FrameworkView::OnWindowSizeChanged(ICoreWindow* aSender, IWindowSizeChangedEvent return S_OK; } - NS_ASSERTION(mWindow, "SetWindow must be called before OnWindowSizeChanged!"); - Rect logicalBounds; - mWindow->get_Bounds(&logicalBounds); - mWindowBounds = MetroUtils::LogToPhys(logicalBounds); - UpdateWidgetSizeAndPosition(); return S_OK; } diff --git a/widget/windows/winrt/FrameworkView.h b/widget/windows/winrt/FrameworkView.h index 8b50ef74fae2..ea0139160e3d 100644 --- a/widget/windows/winrt/FrameworkView.h +++ b/widget/windows/winrt/FrameworkView.h @@ -150,6 +150,7 @@ protected: void UpdateLogicalDPI(); void FireViewStateObservers(); void ProcessLaunchArguments(); + void UpdateBounds(); // Printing and preview void CreatePrintControl(IPrintDocumentPackageTarget* aDocPackageTarget, From c3bf301e4f84a282189fa8da972fd49c61d5b65e Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Wed, 30 Oct 2013 08:57:05 -0700 Subject: [PATCH 562/795] Bug 932637 - mach build-backend should invoke config.status with explicit python; r=glandium DONTBUILD (NPOTB) CLOSED TREE --- python/mozbuild/mozbuild/mach_commands.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index af33d4502bf3..69b3ff5ff2da 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -508,8 +508,9 @@ class Build(MachCommandBase): def build_backend(self): # When we support multiple build backends (Tup, Visual Studio, etc), # this command will be expanded to support choosing what to generate. + python = self.virtualenv_manager.python_path config_status = os.path.join(self.topobjdir, 'config.status') - return self._run_command_in_objdir(args=[config_status], + return self._run_command_in_objdir(args=[python, config_status], pass_thru=True, ensure_exit_code=False) From dc57aaff101464693fffb1050d642b6fbb882ede Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 30 Oct 2013 15:41:07 -0400 Subject: [PATCH 563/795] Bug 931307 - Remove "!aTitle.IsEmpty()" assertion. r=mhenretty --- dom/src/notification/Notification.cpp | 1 - .../mochitest/notification/mochitest.ini | 1 + .../notification/test_bug931307.html | 31 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 dom/tests/mochitest/notification/test_bug931307.html diff --git a/dom/src/notification/Notification.cpp b/dom/src/notification/Notification.cpp index afbfa08363d5..3dc15e093e6a 100644 --- a/dom/src/notification/Notification.cpp +++ b/dom/src/notification/Notification.cpp @@ -61,7 +61,6 @@ public: JSContext* aCx) { MOZ_ASSERT(!aID.IsEmpty()); - MOZ_ASSERT(!aTitle.IsEmpty()); NotificationOptions options; options.mDir = Notification::StringToDirection(nsString(aDir)); diff --git a/dom/tests/mochitest/notification/mochitest.ini b/dom/tests/mochitest/notification/mochitest.ini index a3b5890d5947..bf60b668ea6a 100644 --- a/dom/tests/mochitest/notification/mochitest.ini +++ b/dom/tests/mochitest/notification/mochitest.ini @@ -5,3 +5,4 @@ support-files = [test_notification_basics.html] [test_notification_storage.html] +[test_bug931307.html] diff --git a/dom/tests/mochitest/notification/test_bug931307.html b/dom/tests/mochitest/notification/test_bug931307.html new file mode 100644 index 000000000000..9477b1ea6210 --- /dev/null +++ b/dom/tests/mochitest/notification/test_bug931307.html @@ -0,0 +1,31 @@ + + + + Bug 931307 + + + + +
+
+
+ + From 723dc24f51fb599ff33aaac0e7e51fde82bf5ebf Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Wed, 30 Oct 2013 15:41:07 -0400 Subject: [PATCH 564/795] Bug 932076 - Add check for MediaExtractor creation failure. r=doublec --- content/media/omx/MediaOmxReader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/media/omx/MediaOmxReader.cpp b/content/media/omx/MediaOmxReader.cpp index 34b542507e44..9442e0f93140 100644 --- a/content/media/omx/MediaOmxReader.cpp +++ b/content/media/omx/MediaOmxReader.cpp @@ -87,7 +87,9 @@ nsresult MediaOmxReader::InitOmxDecoder() dataSource->initCheck(); sp extractor = MediaExtractor::Create(dataSource); - + if (!extractor.get()) { + return NS_ERROR_FAILURE; + } mOmxDecoder = new OmxDecoder(mDecoder->GetResource(), mDecoder); if (!mOmxDecoder->Init(extractor)) { return NS_ERROR_FAILURE; From 01d4c2e813673a59de0e2b2bb4d4e1cd083b9167 Mon Sep 17 00:00:00 2001 From: Mike Habicher Date: Wed, 30 Oct 2013 15:41:08 -0400 Subject: [PATCH 565/795] Bug 807058 - Expose thumbnail size capability and control properties. r=sotaro, r=jst --- dom/camera/CameraCommon.h | 4 +- dom/camera/CameraControlImpl.cpp | 16 +- dom/camera/CameraControlImpl.h | 8 +- dom/camera/DOMCameraCapabilities.cpp | 7 + dom/camera/DOMCameraControl.cpp | 78 ++++++++ dom/camera/DOMCameraControl.h | 4 + dom/camera/FallbackCameraControl.cpp | 12 ++ dom/camera/GonkCameraControl.cpp | 261 ++++++++++++++++++++++----- dom/camera/GonkCameraControl.h | 8 +- dom/camera/ICameraControl.h | 5 +- dom/camera/nsIDOMCameraManager.idl | 7 +- dom/webidl/CameraControl.webidl | 16 ++ 12 files changed, 367 insertions(+), 59 deletions(-) diff --git a/dom/camera/CameraCommon.h b/dom/camera/CameraCommon.h index 1f2d418da891..f5a3428d3bf5 100644 --- a/dom/camera/CameraCommon.h +++ b/dom/camera/CameraCommon.h @@ -76,8 +76,8 @@ enum { CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, CAMERA_PARAM_FOCUSDISTANCEFAR, CAMERA_PARAM_EXPOSURECOMPENSATION, - CAMERA_PARAM_THUMBNAILWIDTH, - CAMERA_PARAM_THUMBNAILHEIGHT, + CAMERA_PARAM_PICTURESIZE, + CAMERA_PARAM_THUMBNAILSIZE, CAMERA_PARAM_THUMBNAILQUALITY, CAMERA_PARAM_SUPPORTED_PREVIEWSIZES, diff --git a/dom/camera/CameraControlImpl.cpp b/dom/camera/CameraControlImpl.cpp index fa8b41848d75..20bd6b337643 100644 --- a/dom/camera/CameraControlImpl.cpp +++ b/dom/camera/CameraControlImpl.cpp @@ -254,6 +254,20 @@ CameraControlImpl::Get(nsICameraPreviewStateChange** aOnPreviewStateChange) return NS_OK; } +nsresult +CameraControlImpl::Set(uint32_t aKey, const idl::CameraSize& aSize) +{ + SetParameter(aKey, aSize); + return NS_OK; +} + +nsresult +CameraControlImpl::Get(uint32_t aKey, idl::CameraSize& aSize) +{ + GetParameter(aKey, aSize); + return NS_OK; +} + already_AddRefed CameraControlImpl::GetRecorderProfileManager() { @@ -407,7 +421,7 @@ CameraControlImpl::AutoFocus(nsICameraAutoFocusCallback* onSuccess, nsICameraErr } nsresult -CameraControlImpl::TakePicture(CameraSize aSize, int32_t aRotation, const nsAString& aFileFormat, CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError) +CameraControlImpl::TakePicture(const CameraSize& aSize, int32_t aRotation, const nsAString& aFileFormat, CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError) { MOZ_ASSERT(NS_IsMainThread()); bool cancel = false; diff --git a/dom/camera/CameraControlImpl.h b/dom/camera/CameraControlImpl.h index 54511116b618..c3ac6dca3b1d 100644 --- a/dom/camera/CameraControlImpl.h +++ b/dom/camera/CameraControlImpl.h @@ -53,7 +53,7 @@ public: nsresult StartPreview(DOMCameraPreview* aDOMPreview); void StopPreview(); nsresult AutoFocus(nsICameraAutoFocusCallback* onSuccess, nsICameraErrorCallback* onError); - nsresult TakePicture(idl::CameraSize aSize, int32_t aRotation, const nsAString& aFileFormat, idl::CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError); + nsresult TakePicture(const idl::CameraSize& aSize, int32_t aRotation, const nsAString& aFileFormat, idl::CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError); nsresult StartRecording(idl::CameraStartRecordingOptions* aOptions, nsIFile* aFolder, const nsAString& aFilename, nsICameraStartRecordingCallback* onSuccess, nsICameraErrorCallback* onError); nsresult StopRecording(); nsresult GetPreviewStreamVideoMode(idl::CameraRecorderOptions* aOptions, nsICameraPreviewStreamCallback* onSuccess, nsICameraErrorCallback* onError); @@ -73,6 +73,8 @@ public: nsresult Get(nsICameraRecorderStateChange** aOnRecorderStateChange); nsresult Set(nsICameraPreviewStateChange* aOnPreviewStateChange); nsresult Get(nsICameraPreviewStateChange** aOnPreviewStateChange); + nsresult Set(uint32_t aKey, const idl::CameraSize& aSize); + nsresult Get(uint32_t aKey, idl::CameraSize& aSize); nsresult SetFocusAreas(JSContext* aCx, const JS::Value& aValue) { @@ -91,10 +93,12 @@ public: virtual const char* GetParameterConstChar(uint32_t aKey) = 0; virtual double GetParameterDouble(uint32_t aKey) = 0; virtual void GetParameter(uint32_t aKey, nsTArray& aRegions) = 0; + virtual void GetParameter(uint32_t aKey, idl::CameraSize& aSize) = 0; virtual void SetParameter(const char* aKey, const char* aValue) = 0; virtual void SetParameter(uint32_t aKey, const char* aValue) = 0; virtual void SetParameter(uint32_t aKey, double aValue) = 0; virtual void SetParameter(uint32_t aKey, const nsTArray& aRegions) = 0; + virtual void SetParameter(uint32_t aKey, const idl::CameraSize& aSize) = 0; virtual nsresult GetVideoSizes(nsTArray& aVideoSizes) = 0; virtual nsresult PushParameters() = 0; virtual void Shutdown(); @@ -372,7 +376,7 @@ protected: class TakePictureTask : public nsRunnable { public: - TakePictureTask(CameraControlImpl* aCameraControl, bool aCancel, idl::CameraSize aSize, int32_t aRotation, const nsAString& aFileFormat, idl::CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError) + TakePictureTask(CameraControlImpl* aCameraControl, bool aCancel, const idl::CameraSize& aSize, int32_t aRotation, const nsAString& aFileFormat, idl::CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError) : mCameraControl(aCameraControl) , mCancel(aCancel) , mSize(aSize) diff --git a/dom/camera/DOMCameraCapabilities.cpp b/dom/camera/DOMCameraCapabilities.cpp index abe01c828d7c..4dcab576c090 100644 --- a/dom/camera/DOMCameraCapabilities.cpp +++ b/dom/camera/DOMCameraCapabilities.cpp @@ -199,6 +199,13 @@ DOMCameraCapabilities::GetPictureSizes(JSContext* cx, JS::Value* aPictureSizes) return DimensionListToNewObject(cx, aPictureSizes, CAMERA_PARAM_SUPPORTED_PICTURESIZES); } +/* readonly attribute jsval thumbnailSizes; */ +NS_IMETHODIMP +DOMCameraCapabilities::GetThumbnailSizes(JSContext* cx, JS::Value* aThumbnailSizes) +{ + return DimensionListToNewObject(cx, aThumbnailSizes, CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES); +} + /* readonly attribute jsval fileFormats; */ NS_IMETHODIMP DOMCameraCapabilities::GetFileFormats(JSContext* cx, JS::Value* aFileFormats) diff --git a/dom/camera/DOMCameraControl.cpp b/dom/camera/DOMCameraControl.cpp index bf7b790cc582..df8987711ea4 100644 --- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -26,6 +26,7 @@ using namespace mozilla; using namespace mozilla::dom; +using namespace mozilla::idl; NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsDOMCameraControl, mDOMCapabilities, mWindow) @@ -155,6 +156,83 @@ nsDOMCameraControl::SetFocusAreas(JSContext* cx, JS::Handle aFocusAre aRv = mCameraControl->SetFocusAreas(cx, aFocusAreas); } +static nsresult +GetSize(JSContext* aCx, JS::Value* aValue, const CameraSize& aSize) +{ + JS::Rooted o(aCx, JS_NewObject(aCx, nullptr, nullptr, nullptr)); + if (!o) { + return NS_ERROR_OUT_OF_MEMORY; + } + + JS::Rooted v(aCx); + + v = INT_TO_JSVAL(aSize.width); + if (!JS_SetProperty(aCx, o, "width", v)) { + return NS_ERROR_FAILURE; + } + v = INT_TO_JSVAL(aSize.height); + if (!JS_SetProperty(aCx, o, "height", v)) { + return NS_ERROR_FAILURE; + } + + *aValue = JS::ObjectValue(*o); + return NS_OK; +} + +/* attribute any pictureSize */ +JS::Value +nsDOMCameraControl::GetPictureSize(JSContext* cx, ErrorResult& aRv) +{ + JS::Rooted value(cx); + + CameraSize size; + aRv = mCameraControl->Get(CAMERA_PARAM_PICTURESIZE, size); + if (aRv.Failed()) { + return value; + } + + aRv = GetSize(cx, value.address(), size); + return value; +} +void +nsDOMCameraControl::SetPictureSize(JSContext* cx, JS::Handle aSize, ErrorResult& aRv) +{ + CameraSize size; + aRv = size.Init(cx, aSize.address()); + if (aRv.Failed()) { + return; + } + + aRv = mCameraControl->Set(CAMERA_PARAM_PICTURESIZE, size); +} + +/* attribute any thumbnailSize */ +JS::Value +nsDOMCameraControl::GetThumbnailSize(JSContext* cx, ErrorResult& aRv) +{ + JS::Rooted value(cx); + + CameraSize size; + aRv = mCameraControl->Get(CAMERA_PARAM_THUMBNAILSIZE, size); + if (aRv.Failed()) { + return value; + } + + aRv = GetSize(cx, value.address(), size); + return value; +} +void +nsDOMCameraControl::SetThumbnailSize(JSContext* cx, JS::Handle aSize, ErrorResult& aRv) +{ + CameraSize size; + aRv = size.Init(cx, aSize.address()); + if (aRv.Failed()) { + return; + } + + aRv = mCameraControl->Set(CAMERA_PARAM_THUMBNAILSIZE, size); +} + double nsDOMCameraControl::GetFocalLength(ErrorResult& aRv) { diff --git a/dom/camera/DOMCameraControl.h b/dom/camera/DOMCameraControl.h index ea39430b5457..6e0954a264b4 100644 --- a/dom/camera/DOMCameraControl.h +++ b/dom/camera/DOMCameraControl.h @@ -66,6 +66,10 @@ public: void SetMeteringAreas(JSContext* aCx, JS::Handle aAreas, ErrorResult& aRv); JS::Value GetFocusAreas(JSContext* aCx, ErrorResult& aRv); void SetFocusAreas(JSContext* aCx, JS::Handle aAreas, ErrorResult& aRv); + JS::Value GetPictureSize(JSContext* aCx, ErrorResult& aRv); + void SetPictureSize(JSContext* aCx, JS::Handle aSize, ErrorResult& aRv); + JS::Value GetThumbnailSize(JSContext* aCx, ErrorResult& aRv); + void SetThumbnailSize(JSContext* aCx, JS::Handle aSize, ErrorResult& aRv); double GetFocalLength(ErrorResult& aRv); double GetFocusDistanceNear(ErrorResult& aRv); double GetFocusDistanceOptimum(ErrorResult& aRv); diff --git a/dom/camera/FallbackCameraControl.cpp b/dom/camera/FallbackCameraControl.cpp index 56006b763cb8..1da6e6effd28 100644 --- a/dom/camera/FallbackCameraControl.cpp +++ b/dom/camera/FallbackCameraControl.cpp @@ -25,10 +25,12 @@ public: const char* GetParameterConstChar(uint32_t aKey); double GetParameterDouble(uint32_t aKey); void GetParameter(uint32_t aKey, nsTArray& aRegions); + void GetParameter(uint32_t aKey, idl::CameraSize& aSize); void SetParameter(const char* aKey, const char* aValue); void SetParameter(uint32_t aKey, const char* aValue); void SetParameter(uint32_t aKey, double aValue); void SetParameter(uint32_t aKey, const nsTArray& aRegions); + void SetParameter(uint32_t aKey, const idl::CameraSize& aSize); nsresult GetVideoSizes(nsTArray& aVideoSizes); nsresult PushParameters(); @@ -104,6 +106,11 @@ nsFallbackCameraControl::GetParameter(uint32_t aKey, nsTArray { } +void +nsFallbackCameraControl::GetParameter(uint32_t aKey, idl::CameraSize& aSize) +{ +} + void nsFallbackCameraControl::SetParameter(const char* aKey, const char* aValue) { @@ -124,6 +131,11 @@ nsFallbackCameraControl::SetParameter(uint32_t aKey, const nsTArray 0 && h > 0); // make sure the driver returns sane values + mLastPictureWidth = static_cast(w); + mLastPictureHeight = static_cast(h); DOM_CAMERA_LOGI(" - minimum exposure compensation: %f\n", mExposureCompensationMin); DOM_CAMERA_LOGI(" - exposure compensation step: %f\n", mExposureCompensationStep); DOM_CAMERA_LOGI(" - maximum metering areas: %d\n", mMaxMeteringAreas); DOM_CAMERA_LOGI(" - maximum focus areas: %d\n", mMaxFocusAreas); + DOM_CAMERA_LOGI(" - default picture size: %u x %u\n", mLastPictureWidth, mLastPictureHeight); + DOM_CAMERA_LOGI(" - default thumbnail size: %u x %u\n", mLastThumbnailWidth, mLastThumbnailHeight); return NS_OK; } @@ -507,6 +518,40 @@ nsGonkCameraControl::GetParameter(uint32_t aKey, return; } +void +nsGonkCameraControl::GetParameter(uint32_t aKey, idl::CameraSize& aSize) +{ + if (aKey == CAMERA_PARAM_THUMBNAILSIZE) { + // This is a special case--for some reason the thumbnail size + // is accessed as two separate values instead of a tuple. + RwAutoLockRead lock(mRwLock); + + aSize.width = mParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); + aSize.height = mParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); + DOM_CAMERA_LOGI("thumbnail size --> value='%ux%u'\n", aSize.width, aSize.height); + return; + } + + const char* key = getKeyText(aKey); + if (!key) { + return; + } + + RwAutoLockRead lock(mRwLock); + + const char* value = mParams.get(key); + DOM_CAMERA_LOGI("key='%s' --> value='%s'\n", key, value); + if (!value) { + return; + } + + if (sscanf(value, "%ux%u", &aSize.width, &aSize.height) != 2) { + DOM_CAMERA_LOGE("%s:%d : size tuple has bad format: '%s'\n", __func__, __LINE__, value); + aSize.width = 0; + aSize.height = 0; + } +} + nsresult nsGonkCameraControl::PushParameters() { @@ -522,7 +567,7 @@ nsGonkCameraControl::PushParameters() * we can proceed. */ if (NS_IsMainThread()) { - DOM_CAMERA_LOGT("%s:%d - dispatching to main thread\n", __func__, __LINE__); + DOM_CAMERA_LOGT("%s:%d - dispatching to camera thread\n", __func__, __LINE__); nsCOMPtr pushParametersTask = NS_NewRunnableMethod(this, &nsGonkCameraControl::PushParametersImpl); return mCameraThread->Dispatch(pushParametersTask, NS_DISPATCH_NORMAL); } @@ -634,6 +679,39 @@ nsGonkCameraControl::SetParameter(uint32_t aKey, int aValue) PushParameters(); } +void +nsGonkCameraControl::SetParameter(uint32_t aKey, const idl::CameraSize& aSize) +{ + switch (aKey) { + case CAMERA_PARAM_PICTURESIZE: + DOM_CAMERA_LOGI("setting picture size to %ux%u\n", aSize.width, aSize.height); + SetPictureSize(aSize.width, aSize.height); + break; + + case CAMERA_PARAM_THUMBNAILSIZE: + DOM_CAMERA_LOGI("setting thumbnail size to %ux%u\n", aSize.width, aSize.height); + SetThumbnailSize(aSize.width, aSize.height); + break; + + default: + { + const char* key = getKeyText(aKey); + if (!key) { + return; + } + + nsCString s; + s.AppendPrintf("%ux%u", aSize.width, aSize.height); + DOM_CAMERA_LOGI("setting '%s' to %s\n", key, s.get()); + + RwAutoLockWrite lock(mRwLock); + mParams.set(key, s.get()); + } + break; + } + PushParameters(); +} + nsresult nsGonkCameraControl::GetPreviewStreamImpl(GetPreviewStreamTask* aGetPreviewStream) { @@ -727,42 +805,143 @@ nsGonkCameraControl::AutoFocusImpl(AutoFocusTask* aAutoFocus) } void -nsGonkCameraControl::SetupThumbnail(uint32_t aPictureWidth, uint32_t aPictureHeight, uint32_t aPercentQuality) +nsGonkCameraControl::SetThumbnailSize(uint32_t aWidth, uint32_t aHeight) { /** - * Use the smallest non-0x0 thumbnail size that matches - * the aspect ratio of our parameters... + * We keep a copy of the specified size so that if the picture size + * changes, we can choose a new thumbnail size close to what was asked for + * last time. */ - uint32_t smallestArea = UINT_MAX; - uint32_t smallestIndex = UINT_MAX; - nsAutoTArray thumbnailSizes; - GetParameter(CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizes); + mLastThumbnailWidth = aWidth; + mLastThumbnailHeight = aHeight; + + /** + * If either of width or height is zero, set the other to zero as well. + * This should disable inclusion of a thumbnail in the final picture. + */ + if (!aWidth || !aHeight) { + DOM_CAMERA_LOGW("Requested thumbnail size %ux%u, disabling thumbnail\n", aWidth, aHeight); + RwAutoLockWrite write(mRwLock); + mParams.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, 0); + mParams.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, 0); + return; + } + + /** + * Choose the supported thumbnail size that is closest to the specified size. + * Some drivers will fail to take a picture if the thumbnail does not have + * the same aspect ratio as the set picture size, so we need to enforce that + * too. + */ + int smallestDelta = INT_MAX; + uint32_t smallestDeltaIndex = UINT32_MAX; + int targetArea = aWidth * aHeight; + + nsAutoTArray supportedSizes; + GetParameter(CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES, supportedSizes); + + for (uint32_t i = 0; i < supportedSizes.Length(); ++i) { + int area = supportedSizes[i].width * supportedSizes[i].height; + int delta = abs(area - targetArea); - for (uint32_t i = 0; i < thumbnailSizes.Length(); ++i) { - uint32_t area = thumbnailSizes[i].width * thumbnailSizes[i].height; if (area != 0 - && area < smallestArea - && thumbnailSizes[i].width * aPictureHeight / thumbnailSizes[i].height == aPictureWidth + && delta < smallestDelta + && supportedSizes[i].width * mLastPictureHeight / supportedSizes[i].height == mLastPictureWidth ) { - smallestArea = area; - smallestIndex = i; + smallestDelta = delta; + smallestDeltaIndex = i; } } - aPercentQuality = clamped(aPercentQuality, 1, 100); - SetParameter(CAMERA_PARAM_THUMBNAILQUALITY, static_cast(aPercentQuality)); - - if (smallestIndex != UINT_MAX) { - uint32_t w = thumbnailSizes[smallestIndex].width; - uint32_t h = thumbnailSizes[smallestIndex].height; - DOM_CAMERA_LOGI("Using thumbnail size: %ux%u, quality: %u %%\n", w, h, aPercentQuality); - if (w > INT_MAX || h > INT_MAX) { - DOM_CAMERA_LOGE("Thumbnail dimension is too big, will use defaults\n"); - return; - } - SetParameter(CAMERA_PARAM_THUMBNAILWIDTH, static_cast(w)); - SetParameter(CAMERA_PARAM_THUMBNAILHEIGHT, static_cast(h)); + if (smallestDeltaIndex == UINT32_MAX) { + DOM_CAMERA_LOGW("Unable to find a thumbnail size close to %ux%u\n", aWidth, aHeight); + return; } + + uint32_t w = supportedSizes[smallestDeltaIndex].width; + uint32_t h = supportedSizes[smallestDeltaIndex].height; + DOM_CAMERA_LOGI("Requested thumbnail size %ux%u --> using supported size %ux%u\n", aWidth, aHeight, w, h); + if (w > INT32_MAX || h > INT32_MAX) { + DOM_CAMERA_LOGE("Supported thumbnail size is too big, no change\n"); + return; + } + + RwAutoLockWrite write(mRwLock); + mParams.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH, static_cast(w)); + mParams.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT, static_cast(h)); +} + +void +nsGonkCameraControl::UpdateThumbnailSize() +{ + SetThumbnailSize(mLastThumbnailWidth, mLastThumbnailHeight); +} + +void +nsGonkCameraControl::SetPictureSize(uint32_t aWidth, uint32_t aHeight) +{ + /** + * Some drivers are less friendly about getting one of these set to zero, + * so if either is not specified, ignore both and go with current or + * default settings. + */ + if (!aWidth || !aHeight) { + DOM_CAMERA_LOGW("Ignoring requested picture size of %ux%u\n", aWidth, aHeight); + return; + } + + if (aWidth == mLastPictureWidth && aHeight == mLastPictureHeight) { + DOM_CAMERA_LOGI("Requested picture size %ux%u unchanged\n", aWidth, aHeight); + return; + } + + /** + * Choose the supported picture size that is closest in area to the + * specified size. Some drivers will fail to take a picture if the + * thumbnail size is not the same aspect ratio, so we update that + * as well to a size closest to the last user-requested one. + */ + int smallestDelta = INT_MAX; + uint32_t smallestDeltaIndex = UINT32_MAX; + int targetArea = aWidth * aHeight; + + nsAutoTArray supportedSizes; + GetParameter(CAMERA_PARAM_SUPPORTED_PICTURESIZES, supportedSizes); + + for (uint32_t i = 0; i < supportedSizes.Length(); ++i) { + int area = supportedSizes[i].width * supportedSizes[i].height; + int delta = abs(area - targetArea); + + if (area != 0 && delta < smallestDelta) { + smallestDelta = delta; + smallestDeltaIndex = i; + } + } + + if (smallestDeltaIndex == UINT32_MAX) { + DOM_CAMERA_LOGW("Unable to find a picture size close to %ux%u\n", aWidth, aHeight); + return; + } + + uint32_t w = supportedSizes[smallestDeltaIndex].width; + uint32_t h = supportedSizes[smallestDeltaIndex].height; + DOM_CAMERA_LOGI("Requested picture size %ux%u --> using supported size %ux%u\n", aWidth, aHeight, w, h); + if (w > INT32_MAX || h > INT32_MAX) { + DOM_CAMERA_LOGE("Supported picture size is too big, no change\n"); + return; + } + + mLastPictureWidth = w; + mLastPictureHeight = h; + + { + // We must release the write-lock before updating the thumbnail size + RwAutoLockWrite write(mRwLock); + mParams.setPictureSize(static_cast(w), static_cast(h)); + } + + // Finally, update the thumbnail size + UpdateThumbnailSize(); } nsresult @@ -782,25 +961,7 @@ nsGonkCameraControl::TakePictureImpl(TakePictureTask* aTakePicture) // batch-update camera configuration mDeferConfigUpdate = true; - if (aTakePicture->mSize.width != mLastPictureWidth || aTakePicture->mSize.height != mLastPictureHeight) { - /** - * height and width: some drivers are less friendly about getting one of - * these set to zero, so if either is not specified, ignore both and go - * with current or default settings. - */ - if (aTakePicture->mSize.width && aTakePicture->mSize.height) { - nsCString s; - s.AppendPrintf("%ux%u", aTakePicture->mSize.width, aTakePicture->mSize.height); - DOM_CAMERA_LOGI("setting picture size to '%s'\n", s.get()); - SetParameter(CameraParameters::KEY_PICTURE_SIZE, s.get()); - - // Choose an appropriate thumbnail size and quality (from 1..100) - SetupThumbnail(aTakePicture->mSize.width, aTakePicture->mSize.height, 60); - } - - mLastPictureWidth = aTakePicture->mSize.width; - mLastPictureHeight = aTakePicture->mSize.height; - } + SetPictureSize(aTakePicture->mSize.width, aTakePicture->mSize.height); // Picture format -- need to keep it for the callback. mFileFormat = aTakePicture->mFileFormat; diff --git a/dom/camera/GonkCameraControl.h b/dom/camera/GonkCameraControl.h index afcbc9acbeb7..de1ad78e6019 100644 --- a/dom/camera/GonkCameraControl.h +++ b/dom/camera/GonkCameraControl.h @@ -55,11 +55,13 @@ public: double GetParameterDouble(uint32_t aKey); void GetParameter(uint32_t aKey, nsTArray& aRegions); void GetParameter(uint32_t aKey, nsTArray& aSizes); + void GetParameter(uint32_t aKey, idl::CameraSize& aSize); void SetParameter(const char* aKey, const char* aValue); void SetParameter(uint32_t aKey, const char* aValue); void SetParameter(uint32_t aKey, double aValue); void SetParameter(uint32_t aKey, const nsTArray& aRegions); void SetParameter(uint32_t aKey, int aValue); + void SetParameter(uint32_t aKey, const idl::CameraSize& aSize); nsresult GetVideoSizes(nsTArray& aVideoSizes); nsresult PushParameters(); @@ -89,7 +91,9 @@ protected: nsresult SetupRecording(int aFd, int aRotation, int64_t aMaxFileSizeBytes, int64_t aMaxVideoLengthMs); nsresult SetupVideoMode(const nsAString& aProfile); void SetPreviewSize(uint32_t aWidth, uint32_t aHeight); - void SetupThumbnail(uint32_t aPictureWidth, uint32_t aPictureHeight, uint32_t aPercentQuality); + void SetThumbnailSize(uint32_t aWidth, uint32_t aHeight); + void UpdateThumbnailSize(); + void SetPictureSize(uint32_t aWidth, uint32_t aHeight); android::sp mCameraHw; double mExposureCompensationMin; @@ -101,6 +105,8 @@ protected: uint32_t mHeight; uint32_t mLastPictureWidth; uint32_t mLastPictureHeight; + uint32_t mLastThumbnailWidth; + uint32_t mLastThumbnailHeight; enum { PREVIEW_FORMAT_UNKNOWN, diff --git a/dom/camera/ICameraControl.h b/dom/camera/ICameraControl.h index 2af0a9510f38..99eeb358f1ea 100644 --- a/dom/camera/ICameraControl.h +++ b/dom/camera/ICameraControl.h @@ -12,7 +12,6 @@ namespace mozilla { - class DOMCameraPreview; class RecorderProfileManager; @@ -25,7 +24,7 @@ public: virtual nsresult StartPreview(DOMCameraPreview* aDOMPreview) = 0; virtual void StopPreview() = 0; virtual nsresult AutoFocus(nsICameraAutoFocusCallback* onSuccess, nsICameraErrorCallback* onError) = 0; - virtual nsresult TakePicture(idl::CameraSize aSize, int32_t aRotation, const nsAString& aFileFormat, idl::CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError) = 0; + virtual nsresult TakePicture(const idl::CameraSize& aSize, int32_t aRotation, const nsAString& aFileFormat, idl::CameraPosition aPosition, uint64_t aDateTime, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError) = 0; virtual nsresult StartRecording(idl::CameraStartRecordingOptions* aOptions, nsIFile* aFolder, const nsAString& aFilename, nsICameraStartRecordingCallback* onSuccess, nsICameraErrorCallback* onError) = 0; virtual nsresult StopRecording() = 0; virtual nsresult GetPreviewStreamVideoMode(idl::CameraRecorderOptions* aOptions, nsICameraPreviewStreamCallback* onSuccess, nsICameraErrorCallback* onError) = 0; @@ -45,6 +44,8 @@ public: virtual nsresult Get(nsICameraRecorderStateChange** aOnRecorderStateChange) = 0; virtual nsresult Set(nsICameraPreviewStateChange* aOnPreviewStateChange) = 0; virtual nsresult Get(nsICameraPreviewStateChange** aOnPreviewStateChange) = 0; + virtual nsresult Set(uint32_t aKey, const idl::CameraSize& aSize) = 0; + virtual nsresult Get(uint32_t aKey, idl::CameraSize& aSize) = 0; virtual nsresult SetFocusAreas(JSContext* aCx, const JS::Value& aValue) = 0; virtual nsresult SetMeteringAreas(JSContext* aCx, const JS::Value& aValue) = 0; virtual nsresult GetVideoSizes(nsTArray& aVideoSizes) = 0; diff --git a/dom/camera/nsIDOMCameraManager.idl b/dom/camera/nsIDOMCameraManager.idl index 417f135bc22a..803ffea5ed07 100644 --- a/dom/camera/nsIDOMCameraManager.idl +++ b/dom/camera/nsIDOMCameraManager.idl @@ -36,7 +36,7 @@ dictionary CameraPosition { double timestamp; }; -[scriptable, uuid(177472c9-f83d-48b5-8782-03b43b27f25d)] +[scriptable, uuid(0711a4af-73c2-481d-85bc-0ba3ec36c004)] interface nsICameraCapabilities : nsISupports { /* an array of objects with 'height' and 'width' properties @@ -49,6 +49,11 @@ interface nsICameraCapabilities : nsISupports [implicit_jscontext] readonly attribute jsval pictureSizes; + /* an array of objects with 'height' and 'width' properties + supported for thumbnail sizes in taken pictures */ + [implicit_jscontext] + readonly attribute jsval thumbnailSizes; + /* an array of strings, e.g. [ "jpeg", "rgb565" ] */ [implicit_jscontext] readonly attribute jsval fileFormats; diff --git a/dom/webidl/CameraControl.webidl b/dom/webidl/CameraControl.webidl index 73b021ff1509..a831c59cb648 100644 --- a/dom/webidl/CameraControl.webidl +++ b/dom/webidl/CameraControl.webidl @@ -136,6 +136,22 @@ interface CameraControl { attribute CameraRecorderStateChange? onRecorderStateChange; attribute CameraPreviewStateChange? onPreviewStateChange; + /* the size of the picture to be returned by a call to takePicture(); + an object with 'height' and 'width' properties that corresponds to + one of the options returned by capabilities.pictureSizes. */ + [Throws] + attribute any pictureSize; + + /* the size of the thumbnail to be included in the picture returned + by a call to takePicture(), assuming the chose fileFormat supports + one; an object with 'height' and 'width' properties that corresponds + to one of the options returned by capabilities.pictureSizes. + + this setting should be considered a hint: the implementation will + respect it when possible, and override it if necessary. */ + [Throws] + attribute any thumbnailSize; + /* tell the camera to attempt to focus the image */ [Throws] void autoFocus(CameraAutoFocusCallback onSuccess, optional CameraErrorCallback onError); From c5d90671d14c545681761b9b530f472bd7b5799c Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 30 Oct 2013 15:48:39 -0400 Subject: [PATCH 566/795] Backed out 9 changesets (bug 814625) for desktop build bustage. Backed out changeset a107de5616a0 (bug 814625) Backed out changeset 416665a419f4 (bug 814625) Backed out changeset b6fc8734864f (bug 814625) Backed out changeset 9f5e2e44a914 (bug 814625) Backed out changeset 17b3050df362 (bug 814625) Backed out changeset 43a047c081c8 (bug 814625) Backed out changeset 90bdcd099320 (bug 814625) Backed out changeset 8957cc31cce2 (bug 814625) Backed out changeset de45eb7a8d16 (bug 814625) --- dom/bluetooth/BluetoothRilListener.cpp | 19 +- dom/system/gonk/RadioInterfaceLayer.js | 13 +- dom/telephony/Telephony.cpp | 474 ++++++++++----------- dom/telephony/Telephony.h | 75 ++-- dom/telephony/TelephonyCall.cpp | 17 +- dom/telephony/TelephonyCall.h | 10 +- dom/telephony/TelephonyCallGroup.cpp | 37 +- dom/telephony/TelephonyCallGroup.h | 2 +- dom/telephony/gonk/TelephonyProvider.js | 143 +++---- dom/telephony/ipc/PTelephony.ipdl | 33 +- dom/telephony/ipc/PTelephonyRequest.ipdl | 2 +- dom/telephony/ipc/TelephonyChild.cpp | 28 +- dom/telephony/ipc/TelephonyChild.h | 14 +- dom/telephony/ipc/TelephonyIPCProvider.cpp | 101 +++-- dom/telephony/ipc/TelephonyParent.cpp | 110 ++--- dom/telephony/ipc/TelephonyParent.h | 25 +- dom/telephony/nsIGonkTelephonyProvider.idl | 12 +- dom/telephony/nsITelephonyProvider.idl | 52 +-- dom/webidl/Telephony.webidl | 27 +- dom/webidl/TelephonyCall.webidl | 3 - 20 files changed, 516 insertions(+), 681 deletions(-) diff --git a/dom/bluetooth/BluetoothRilListener.cpp b/dom/bluetooth/BluetoothRilListener.cpp index 83f01fa716e2..71d731808949 100644 --- a/dom/bluetooth/BluetoothRilListener.cpp +++ b/dom/bluetooth/BluetoothRilListener.cpp @@ -133,8 +133,6 @@ MobileConnectionListener::NotifyIccChanged() /** * TelephonyListener Implementation - * - * TODO: Bug 921991 - B2G BT: support multiple sim cards */ class TelephonyListener : public nsITelephonyListener { @@ -148,8 +146,7 @@ public: NS_IMPL_ISUPPORTS1(TelephonyListener, nsITelephonyListener) NS_IMETHODIMP -TelephonyListener::CallStateChanged(uint32_t aServiceId, - uint32_t aCallIndex, +TelephonyListener::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -165,8 +162,7 @@ TelephonyListener::CallStateChanged(uint32_t aServiceId, } NS_IMETHODIMP -TelephonyListener::EnumerateCallState(uint32_t aServiceId, - uint32_t aCallIndex, +TelephonyListener::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, const nsAString_internal& aNumber, bool aIsActive, @@ -181,8 +177,7 @@ TelephonyListener::EnumerateCallState(uint32_t aServiceId, } NS_IMETHODIMP -TelephonyListener::NotifyError(uint32_t aServiceId, - int32_t aCallIndex, +TelephonyListener::NotifyError(int32_t aCallIndex, const nsAString& aError) { BluetoothHfpManager* hfp = BluetoothHfpManager::Get(); @@ -216,16 +211,14 @@ TelephonyListener::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyListener::SupplementaryServiceNotification(uint32_t aServiceId, - int32_t aCallIndex, +TelephonyListener::SupplementaryServiceNotification(int32_t aCallIndex, uint16_t aNotification) { return NS_OK; } NS_IMETHODIMP -TelephonyListener::NotifyCdmaCallWaiting(uint32_t aServiceId, - const nsAString& aNumber) +TelephonyListener::NotifyCdmaCallWaiting(const nsAString& aNumber) { BluetoothHfpManager* hfp = BluetoothHfpManager::Get(); hfp->UpdateSecondNumber(aNumber); @@ -344,4 +337,4 @@ BluetoothRilListener::StopTelephonyListening() nsresult rv = provider->UnregisterListener(mTelephonyListener); return NS_SUCCEEDED(rv); -} +} \ No newline at end of file diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index e731c1166409..a6256789a74f 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -1001,24 +1001,22 @@ RadioInterface.prototype = { gTelephonyProvider.notifyCallRing(); break; case "callStateChange": - gTelephonyProvider.notifyCallStateChanged(this.clientId, message.call); + gTelephonyProvider.notifyCallStateChanged(message.call); break; case "callDisconnected": - gTelephonyProvider.notifyCallDisconnected(this.clientId, message.call); + gTelephonyProvider.notifyCallDisconnected(message.call); break; case "conferenceCallStateChanged": gTelephonyProvider.notifyConferenceCallStateChanged(message.state); break; case "cdmaCallWaiting": - gTelephonyProvider.notifyCdmaCallWaiting(this.clientId, message.number); + gTelephonyProvider.notifyCdmaCallWaiting(message.number); break; case "callError": - gTelephonyProvider.notifyCallError(this.clientId, message.callIndex, - message.errorMsg); + gTelephonyProvider.notifyCallError(message.callIndex, message.errorMsg); break; case "suppSvcNotification": - gTelephonyProvider.notifySupplementaryService(this.clientId, - message.callIndex, + gTelephonyProvider.notifySupplementaryService(message.callIndex, message.notification); break; case "emergencyCbModeChange": @@ -3577,3 +3575,4 @@ RILNetworkInterface.prototype = { }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RadioInterfaceLayer]); + diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index b3261d0b7912..5d1a050e589c 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -12,7 +12,6 @@ #include "nsIPermissionManager.h" #include "mozilla/dom/UnionTypes.h" -#include "mozilla/Preferences.h" #include "nsCharSeparatedTokenizer.h" #include "nsContentUtils.h" #include "nsCxPusher.h" @@ -176,106 +175,11 @@ Telephony::Create(nsPIDOMWindow* aOwner, ErrorResult& aRv) return telephony.forget(); } -// static -bool -Telephony::IsValidNumber(const nsAString& aNumber) -{ - return !aNumber.IsEmpty(); -} - -// static -uint32_t -Telephony::GetNumServices() { - return mozilla::Preferences::GetInt("ril.numRadioInterfaces", 1); -} - -// static -bool -Telephony::IsValidServiceId(uint32_t aServiceId) -{ - return aServiceId < GetNumServices(); -} - -// static -bool -Telephony::IsActiveState(uint16_t aCallState) { - return aCallState == nsITelephonyProvider::CALL_STATE_DIALING || - aCallState == nsITelephonyProvider::CALL_STATE_ALERTING || - aCallState == nsITelephonyProvider::CALL_STATE_CONNECTED; -} - -uint32_t -Telephony::ProvidedOrDefaultServiceId(const Optional& aServiceId) -{ - uint32_t serviceId = 0; - return aServiceId.WasPassed() ? aServiceId.Value() - : mProvider->GetDefaultServiceId(&serviceId); -} - -bool -Telephony::HasDialingCall() -{ - for (uint32_t i = 0; i < mCalls.Length(); i++) { - const nsRefPtr& call = mCalls[i]; - if (call->IsOutgoing() && - call->CallState() > nsITelephonyProvider::CALL_STATE_UNKNOWN && - call->CallState() < nsITelephonyProvider::CALL_STATE_CONNECTED) { - return true; - } - } - - return false; -} - -bool -Telephony::MatchActiveCall(TelephonyCall* aCall) -{ - return (mActiveCall && - mActiveCall->CallIndex() == aCall->CallIndex() && - mActiveCall->ServiceId() == aCall->ServiceId()); -} - already_AddRefed -Telephony::DialInternal(uint32_t aServiceId, const nsAString& aNumber, - bool aIsEmergency, ErrorResult& aRv) -{ - if (!IsValidNumber(aNumber) || !IsValidServiceId(aServiceId)) { - aRv.Throw(NS_ERROR_INVALID_ARG); - return nullptr; - } - - // We only support one outgoing call at a time. - if (HasDialingCall()) { - NS_WARNING("Only permitted to dial one call at a time!"); - aRv.Throw(NS_ERROR_NOT_AVAILABLE); - return nullptr; - } - - nsresult rv = mProvider->Dial(aServiceId, aNumber, aIsEmergency); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return nullptr; - } - - nsRefPtr call = CreateNewDialingCall(aServiceId, aNumber); - - // Notify other telephony objects that we just dialed. - for (uint32_t i = 0; i < gTelephonyList->Length(); i++) { - Telephony*& telephony = gTelephonyList->ElementAt(i); - if (telephony != this) { - nsRefPtr kungFuDeathGrip = telephony; - telephony->NoteDialedCallFromOtherInstance(aServiceId, aNumber); - } - } - - return call.forget(); -} - -already_AddRefed -Telephony::CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber) +Telephony::CreateNewDialingCall(const nsAString& aNumber) { nsRefPtr call = - TelephonyCall::Create(this, aServiceId, aNumber, + TelephonyCall::Create(this, aNumber, nsITelephonyProvider::CALL_STATE_DIALING); NS_ASSERTION(call, "This should never fail!"); @@ -285,11 +189,10 @@ Telephony::CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber) } void -Telephony::NoteDialedCallFromOtherInstance(uint32_t aServiceId, - const nsAString& aNumber) +Telephony::NoteDialedCallFromOtherInstance(const nsAString& aNumber) { // We don't need to hang on to this call object, it is held alive by mCalls. - nsRefPtr call = CreateNewDialingCall(aServiceId, aNumber); + nsRefPtr call = CreateNewDialingCall(aNumber); } nsresult @@ -298,25 +201,71 @@ Telephony::NotifyCallsChanged(TelephonyCall* aCall) return DispatchCallEvent(NS_LITERAL_STRING("callschanged"), aCall); } -void -Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsActive) +already_AddRefed +Telephony::DialInternal(bool isEmergency, + const nsAString& aNumber, + ErrorResult& aRv) { - if (aIsActive) { - mActiveCall = aCall; - } else if (MatchActiveCall(aCall)) { + if (aNumber.IsEmpty()) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return nullptr; + } + + for (uint32_t index = 0; index < mCalls.Length(); index++) { + const nsRefPtr& tempCall = mCalls[index]; + if (tempCall->IsOutgoing() && + tempCall->CallState() < nsITelephonyProvider::CALL_STATE_CONNECTED) { + // One call has been dialed already and we only support one outgoing call + // at a time. + NS_WARNING("Only permitted to dial one call at a time!"); + aRv.Throw(NS_ERROR_NOT_AVAILABLE); + return nullptr; + } + } + + nsresult rv = mProvider->Dial(aNumber, isEmergency); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + return nullptr; + } + + nsRefPtr call = CreateNewDialingCall(aNumber); + + // Notify other telephony objects that we just dialed. + for (uint32_t index = 0; index < gTelephonyList->Length(); index++) { + Telephony*& telephony = gTelephonyList->ElementAt(index); + if (telephony != this) { + nsRefPtr kungFuDeathGrip = telephony; + telephony->NoteDialedCallFromOtherInstance(aNumber); + } + } + + return call.forget(); +} + +void +Telephony::UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding) +{ + if (aIsAdding) { + if (aCall->CallState() == nsITelephonyProvider::CALL_STATE_DIALING || + aCall->CallState() == nsITelephonyProvider::CALL_STATE_ALERTING || + aCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED) { + NS_ASSERTION(!mActiveCall, "Already have an active call!"); + mActiveCall = aCall; + } + } else if (mActiveCall && mActiveCall->CallIndex() == aCall->CallIndex()) { mActiveCall = nullptr; } } already_AddRefed -Telephony::GetCall(uint32_t aServiceId, uint32_t aCallIndex) +Telephony::GetCall(uint32_t aCallIndex) { nsRefPtr call; - for (uint32_t i = 0; i < mCalls.Length(); i++) { - nsRefPtr& tempCall = mCalls[i]; - if (tempCall->ServiceId() == aServiceId && - tempCall->CallIndex() == aCallIndex) { + for (uint32_t index = 0; index < mCalls.Length(); index++) { + nsRefPtr& tempCall = mCalls[index]; + if (tempCall->CallIndex() == aCallIndex) { call = tempCall; break; } @@ -325,36 +274,32 @@ Telephony::GetCall(uint32_t aServiceId, uint32_t aCallIndex) return call.forget(); } -already_AddRefed -Telephony::GetOutgoingCall() +bool +Telephony::MoveCall(uint32_t aCallIndex, bool aIsConference) { nsRefPtr call; - for (uint32_t i = 0; i < mCalls.Length(); i++) { - nsRefPtr& tempCall = mCalls[i]; - if (tempCall->CallIndex() == kOutgoingPlaceholderCallIndex) { - NS_ASSERTION(!call, "More than one outgoing call not supported!"); - NS_ASSERTION(tempCall->CallState() == nsITelephonyProvider::CALL_STATE_DIALING, - "Something really wrong here!"); - - call = tempCall; - // No break. We will search entire list to ensure only one outgoing call. + // Move a call to mGroup. + if (aIsConference) { + call = GetCall(aCallIndex); + if (call) { + RemoveCall(call); + mGroup->AddCall(call); + return true; } + + return false; } - return call.forget(); -} - -already_AddRefed -Telephony::GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex) -{ - nsRefPtr call = GetCall(aServiceId, aCallIndex); - - if (!call) { - call = mGroup->GetCall(aServiceId, aCallIndex); + // Remove a call from mGroup. + call = mGroup->GetCall(aCallIndex); + if (call) { + mGroup->RemoveCall(call); + AddCall(call); + return true; } - return call.forget(); + return false; } NS_IMPL_CYCLE_COLLECTION_CLASS(Telephony) @@ -386,57 +331,19 @@ NS_IMPL_ISUPPORTS1(Telephony::Listener, nsITelephonyListener) // Telephony WebIDL already_AddRefed -Telephony::Dial(const nsAString& aNumber, const Optional& aServiceId, - ErrorResult& aRv) +Telephony::Dial(const nsAString& aNumber, ErrorResult& aRv) { - uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); - nsRefPtr call = DialInternal(serviceId, aNumber, false, aRv); + nsRefPtr call = DialInternal(false, aNumber, aRv); return call.forget(); } already_AddRefed -Telephony::DialEmergency(const nsAString& aNumber, - const Optional& aServiceId, - ErrorResult& aRv) +Telephony::DialEmergency(const nsAString& aNumber, ErrorResult& aRv) { - uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); - nsRefPtr call = DialInternal(serviceId, aNumber, true, aRv); + nsRefPtr call = DialInternal(true, aNumber, aRv); return call.forget(); } -void -Telephony::StartTone(const nsAString& aDTMFChar, - const Optional& aServiceId, - ErrorResult& aRv) -{ - uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); - - if (aDTMFChar.IsEmpty()) { - NS_WARNING("Empty tone string will be ignored"); - return; - } - - if (aDTMFChar.Length() > 1 || !IsValidServiceId(serviceId)) { - aRv.Throw(NS_ERROR_INVALID_ARG); - return; - } - - aRv = mProvider->StartTone(serviceId, aDTMFChar); -} - -void -Telephony::StopTone(const Optional& aServiceId, ErrorResult& aRv) -{ - uint32_t serviceId = ProvidedOrDefaultServiceId(aServiceId); - - if (!IsValidServiceId(serviceId)) { - aRv.Throw(NS_ERROR_INVALID_ARG); - return; - } - - aRv = mProvider->StopTone(serviceId); -} - bool Telephony::GetMuted(ErrorResult& aRv) const { @@ -493,6 +400,28 @@ Telephony::ConferenceGroup() const return group.forget(); } +void +Telephony::StartTone(const nsAString& aDTMFChar, ErrorResult& aRv) +{ + if (aDTMFChar.IsEmpty()) { + NS_WARNING("Empty tone string will be ignored"); + return; + } + + if (aDTMFChar.Length() > 1) { + aRv.Throw(NS_ERROR_INVALID_ARG); + return; + } + + aRv = mProvider->StartTone(aDTMFChar); +} + +void +Telephony::StopTone(ErrorResult& aRv) +{ + aRv = mProvider->StopTone(); +} + // EventTarget void @@ -507,78 +436,124 @@ Telephony::EventListenerAdded(nsIAtom* aType) // nsITelephonyListener NS_IMETHODIMP -Telephony::CallStateChanged(uint32_t aServiceId, uint32_t aCallIndex, - uint16_t aCallState, const nsAString& aNumber, - bool aIsActive, bool aIsOutgoing, bool aIsEmergency, +Telephony::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, + const nsAString& aNumber, bool aIsActive, + bool aIsOutgoing, bool aIsEmergency, bool aIsConference) { NS_ASSERTION(aCallIndex != kOutgoingPlaceholderCallIndex, "This should never happen!"); - nsRefPtr modifiedCall - = GetCallFromEverywhere(aServiceId, aCallIndex); + nsRefPtr modifiedCall; + nsRefPtr outgoingCall; - // Try to use the outgoing call if we don't find the modified call. - if (!modifiedCall) { - nsRefPtr outgoingCall = GetOutgoingCall(); + // Update calls array first then state of a call in mCalls. - // If the call state isn't incoming but we do have an outgoing call then - // we must be seeing a status update for our outgoing call. - if (outgoingCall && - aCallState != nsITelephonyProvider::CALL_STATE_INCOMING) { - outgoingCall->UpdateCallIndex(aCallIndex); - outgoingCall->UpdateEmergency(aIsEmergency); - modifiedCall.swap(outgoingCall); + if (aIsConference) { + // Add the call into mGroup if it hasn't been there, otherwise we simply + // update its call state. We don't fire the statechange event on a call in + // conference here. Instead, the event will be fired later in + // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the + // statechange events is guaranteed: first on TelephonyCallGroup then on + // individual TelephonyCall objects. + + modifiedCall = mGroup->GetCall(aCallIndex); + if (modifiedCall) { + modifiedCall->ChangeStateInternal(aCallState, false); + return NS_OK; } + + // The call becomes a conference call. Remove it from Telephony::mCalls and + // add it to mGroup. + modifiedCall = GetCall(aCallIndex); + if (modifiedCall) { + modifiedCall->ChangeStateInternal(aCallState, false); + mGroup->AddCall(modifiedCall); + RemoveCall(modifiedCall); + return NS_OK; + } + + // Didn't find this call in mCalls or mGroup. Create a new call. + nsRefPtr call = + TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, + aIsEmergency, aIsConference); + NS_ASSERTION(call, "This should never fail!"); + + return NS_OK; + } + + // Not a conference call. Remove the call from mGroup if it has been there. + modifiedCall = mGroup->GetCall(aCallIndex); + if (modifiedCall) { + if (aCallState != nsITelephonyProvider::CALL_STATE_DISCONNECTED) { + if (modifiedCall->CallState() != aCallState) { + modifiedCall->ChangeState(aCallState); + } + mGroup->RemoveCall(modifiedCall); + AddCall(modifiedCall); + } else { + modifiedCall->ChangeState(aCallState); + } + return NS_OK; + } + + // Update calls in mCalls. + for (uint32_t index = 0; index < mCalls.Length(); index++) { + nsRefPtr& tempCall = mCalls[index]; + if (tempCall->CallIndex() == kOutgoingPlaceholderCallIndex) { + NS_ASSERTION(!outgoingCall, "More than one outgoing call not supported!"); + NS_ASSERTION(tempCall->CallState() == + nsITelephonyProvider::CALL_STATE_DIALING, + "Something really wrong here!"); + // Stash this for later, we may need it if aCallIndex doesn't match one of + // our other calls. + outgoingCall = tempCall; + } else if (tempCall->CallIndex() == aCallIndex) { + // We already know about this call so just update its state. + modifiedCall = tempCall; + outgoingCall = nullptr; + break; + } + } + + // If nothing matched above and the call state isn't incoming but we do have + // an outgoing call then we must be seeing a status update for our outgoing + // call. + if (!modifiedCall && + aCallState != nsITelephonyProvider::CALL_STATE_INCOMING && + outgoingCall) { + outgoingCall->UpdateCallIndex(aCallIndex); + outgoingCall->UpdateEmergency(aIsEmergency); + modifiedCall.swap(outgoingCall); } if (modifiedCall) { - if (!aIsConference) { - UpdateActiveCall(modifiedCall, aIsActive); + // See if this should replace our current active call. + if (aIsActive) { + mActiveCall = modifiedCall; + } else if (mActiveCall && mActiveCall->CallIndex() == aCallIndex) { + mActiveCall = nullptr; } - if (modifiedCall->CallState() != aCallState) { - // We don't fire the statechange event on a call in conference here. - // Instead, the event will be fired later in - // TelephonyCallGroup::ChangeState(). Thus the sequence of firing the - // statechange events is guaranteed: first on TelephonyCallGroup then on - // individual TelephonyCall objects. - bool fireEvent = !aIsConference; - modifiedCall->ChangeStateInternal(aCallState, fireEvent); - } - - nsRefPtr group = modifiedCall->GetGroup(); - - if (!group && aIsConference) { - // Add to conference. - NS_ASSERTION(mCalls.Contains(modifiedCall), "Should in mCalls"); - mGroup->AddCall(modifiedCall); - RemoveCall(modifiedCall); - } else if (group && !aIsConference) { - // Remove from conference. - NS_ASSERTION(mGroup->CallsArray().Contains(modifiedCall), "Should in mGroup"); - mGroup->RemoveCall(modifiedCall); - AddCall(modifiedCall); - } + // Change state. + modifiedCall->ChangeState(aCallState); return NS_OK; } - // Do nothing since we didn't know anything about it before now and it's - // ended already. + // Didn't know anything about this call before now. + if (aCallState == nsITelephonyProvider::CALL_STATE_DISCONNECTED) { + // Do nothing since we didn't know anything about it before now and it's + // been ended already. return NS_OK; } - // Didn't find this call in mCalls or mGroup. Create a new call. nsRefPtr call = - TelephonyCall::Create(this, aServiceId, aNumber, aCallState, aCallIndex, - aIsEmergency, aIsConference); + TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, aIsEmergency); NS_ASSERTION(call, "This should never fail!"); - NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) : - mCalls.Contains(call), - "Should have auto-added new call!"); + NS_ASSERTION(mCalls.Contains(call), "Should have auto-added new call!"); if (aCallState == nsITelephonyProvider::CALL_STATE_INCOMING) { nsresult rv = DispatchCallEvent(NS_LITERAL_STRING("incoming"), call); @@ -609,9 +584,9 @@ Telephony::EnumerateCallStateComplete() } NS_IMETHODIMP -Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex, - uint16_t aCallState, const nsAString& aNumber, - bool aIsActive, bool aIsOutgoing, bool aIsEmergency, +Telephony::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, + const nsAString& aNumber, bool aIsActive, + bool aIsOutgoing, bool aIsEmergency, bool aIsConference) { nsRefPtr call; @@ -621,14 +596,20 @@ Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex, // However, it is likely to have call state changes, i.e. CallStateChanged() // being called, before the enumeration result comes back. We'd make sure // we don't somehow add duplicates due to the race condition. - call = GetCallFromEverywhere(aServiceId, aCallIndex); + call = aIsConference ? mGroup->GetCall(aCallIndex) : GetCall(aCallIndex); if (call) { + // We have the call either in mCalls or in mGroup. Skip it. + return NS_OK; + } + + if (MoveCall(aCallIndex, aIsConference)) { return NS_OK; } // Didn't know anything about this call before now. - call = TelephonyCall::Create(this, aServiceId, aNumber, aCallState, - aCallIndex, aIsEmergency, aIsConference); + + call = TelephonyCall::Create(this, aNumber, aCallState, aCallIndex, + aIsEmergency, aIsConference); NS_ASSERTION(call, "This should never fail!"); NS_ASSERTION(aIsConference ? mGroup->CallsArray().Contains(call) : @@ -639,13 +620,12 @@ Telephony::EnumerateCallState(uint32_t aServiceId, uint32_t aCallIndex, } NS_IMETHODIMP -Telephony::SupplementaryServiceNotification(uint32_t aServiceId, - int32_t aCallIndex, +Telephony::SupplementaryServiceNotification(int32_t aCallIndex, uint16_t aNotification) { nsRefPtr associatedCall; if (!mCalls.IsEmpty() && aCallIndex != -1) { - associatedCall = GetCall(aServiceId, aCallIndex); + associatedCall = GetCall(aCallIndex); } nsresult rv; @@ -666,26 +646,31 @@ Telephony::SupplementaryServiceNotification(uint32_t aServiceId, } NS_IMETHODIMP -Telephony::NotifyError(uint32_t aServiceId, - int32_t aCallIndex, +Telephony::NotifyError(int32_t aCallIndex, const nsAString& aError) { - if (mCalls.IsEmpty()) { - NS_ERROR("No existing call!"); - return NS_ERROR_UNEXPECTED; - } - nsRefPtr callToNotify; - - callToNotify = (aCallIndex == -1) ? GetOutgoingCall() - : GetCall(aServiceId, aCallIndex); + if (!mCalls.IsEmpty()) { + // The connection is not established yet. Get the latest dialing call object. + if (aCallIndex == -1) { + nsRefPtr& lastCall = mCalls[mCalls.Length() - 1]; + if (lastCall->CallIndex() == kOutgoingPlaceholderCallIndex) { + callToNotify = lastCall; + } + } else { + // The connection has been established. Get the failed call. + callToNotify = GetCall(aCallIndex); + } + } if (!callToNotify) { NS_ERROR("Don't call me with a bad call index!"); return NS_ERROR_UNEXPECTED; } - UpdateActiveCall(callToNotify, false); + if (mActiveCall && mActiveCall->CallIndex() == callToNotify->CallIndex()) { + mActiveCall = nullptr; + } // Set the call state to 'disconnected' and remove it from the calls list. callToNotify->NotifyError(aError); @@ -694,10 +679,9 @@ Telephony::NotifyError(uint32_t aServiceId, } NS_IMETHODIMP -Telephony::NotifyCdmaCallWaiting(uint32_t aServiceId, const nsAString& aNumber) +Telephony::NotifyCdmaCallWaiting(const nsAString& aNumber) { MOZ_ASSERT(mActiveCall && - mActiveCall->ServiceId() == aServiceId && mActiveCall->CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED); nsRefPtr callToNotify = mActiveCall; diff --git a/dom/telephony/Telephony.h b/dom/telephony/Telephony.h index 0cceb7d612f4..9ca43da6eab3 100644 --- a/dom/telephony/Telephony.h +++ b/dom/telephony/Telephony.h @@ -7,7 +7,6 @@ #ifndef mozilla_dom_telephony_telephony_h__ #define mozilla_dom_telephony_telephony_h__ -#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/telephony/TelephonyCommon.h" #include "nsITelephonyProvider.h" @@ -67,19 +66,10 @@ public: // WebIDL already_AddRefed - Dial(const nsAString& aNumber, const Optional& aServiceId, - ErrorResult& aRv); + Dial(const nsAString& aNumber, ErrorResult& aRv); already_AddRefed - DialEmergency(const nsAString& aNumber, const Optional& aServiceId, - ErrorResult& aRv); - - void - StartTone(const nsAString& aDTMFChar, const Optional& aServiceId, - ErrorResult& aRv); - - void - StopTone(const Optional& aServiceId, ErrorResult& aRv); + DialEmergency(const nsAString& aNumber, ErrorResult& aRv); bool GetMuted(ErrorResult& aRv) const; @@ -102,6 +92,12 @@ public: already_AddRefed ConferenceGroup() const; + void + StartTone(const nsAString& aDTMF, ErrorResult& aRv); + + void + StopTone(ErrorResult& aRv); + IMPL_EVENT_HANDLER(incoming) IMPL_EVENT_HANDLER(callschanged) IMPL_EVENT_HANDLER(remoteheld) @@ -115,7 +111,7 @@ public: { NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!"); mCalls.AppendElement(aCall); - UpdateActiveCall(aCall, IsActiveState(aCall->CallState())); + UpdateActiveCall(aCall, true); NotifyCallsChanged(aCall); } @@ -146,61 +142,38 @@ private: Telephony(); ~Telephony(); - void - Shutdown(); - - static bool - IsValidNumber(const nsAString& aNumber); - - static uint32_t - GetNumServices(); - - static bool - IsValidServiceId(uint32_t aServiceId); - - static bool - IsActiveState(uint16_t aCallState); - - uint32_t - ProvidedOrDefaultServiceId(const Optional& aServiceId); - - bool - HasDialingCall(); - - bool - MatchActiveCall(TelephonyCall* aCall); - already_AddRefed - DialInternal(uint32_t aServiceId, const nsAString& aNumber, - bool isEmergency, ErrorResult& aRv); - - already_AddRefed - CreateNewDialingCall(uint32_t aServiceId, const nsAString& aNumber); + CreateNewDialingCall(const nsAString& aNumber); void - NoteDialedCallFromOtherInstance(uint32_t aServiceId, - const nsAString& aNumber); + NoteDialedCallFromOtherInstance(const nsAString& aNumber); nsresult NotifyCallsChanged(TelephonyCall* aCall); + already_AddRefed + DialInternal(bool isEmergency, + const nsAString& aNumber, + ErrorResult& aRv); + nsresult - DispatchCallEvent(const nsAString& aType, TelephonyCall* aCall); + DispatchCallEvent(const nsAString& aType, + TelephonyCall* aCall); void EnqueueEnumerationAck(); void - UpdateActiveCall(TelephonyCall* aCall, bool aIsActive); + UpdateActiveCall(TelephonyCall* aCall, bool aIsAdding); already_AddRefed - GetCall(uint32_t aServiceId, uint32_t aCallIndex); + GetCall(uint32_t aCallIndex); - already_AddRefed - GetOutgoingCall(); + bool + MoveCall(uint32_t aCallIndex, bool aIsConference); - already_AddRefed - GetCallFromEverywhere(uint32_t aServiceId, uint32_t aCallIndex); + void + Shutdown(); }; } // namespace dom diff --git a/dom/telephony/TelephonyCall.cpp b/dom/telephony/TelephonyCall.cpp index 0a19ee222b86..dd342cce5379 100644 --- a/dom/telephony/TelephonyCall.cpp +++ b/dom/telephony/TelephonyCall.cpp @@ -19,9 +19,9 @@ using mozilla::dom::telephony::kOutgoingPlaceholderCallIndex; // static already_AddRefed -TelephonyCall::Create(Telephony* aTelephony, uint32_t aServiceId, - const nsAString& aNumber, uint16_t aCallState, - uint32_t aCallIndex, bool aEmergency, bool aIsConference) +TelephonyCall::Create(Telephony* aTelephony, const nsAString& aNumber, + uint16_t aCallState, uint32_t aCallIndex, + bool aEmergency, bool aIsConference) { NS_ASSERTION(aTelephony, "Null pointer!"); NS_ASSERTION(!aNumber.IsEmpty(), "Empty number!"); @@ -32,7 +32,6 @@ TelephonyCall::Create(Telephony* aTelephony, uint32_t aServiceId, call->BindToOwner(aTelephony->GetOwner()); call->mTelephony = aTelephony; - call->mServiceId = aServiceId; call->mNumber = aNumber; call->mCallIndex = aCallIndex; call->mError = nullptr; @@ -220,7 +219,7 @@ TelephonyCall::Answer(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->AnswerCall(mServiceId, mCallIndex); + nsresult rv = mTelephony->Provider()->AnswerCall(mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -239,8 +238,8 @@ TelephonyCall::HangUp(ErrorResult& aRv) } nsresult rv = mCallState == nsITelephonyProvider::CALL_STATE_INCOMING ? - mTelephony->Provider()->RejectCall(mServiceId, mCallIndex) : - mTelephony->Provider()->HangUp(mServiceId, mCallIndex); + mTelephony->Provider()->RejectCall(mCallIndex) : + mTelephony->Provider()->HangUp(mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -262,7 +261,7 @@ TelephonyCall::Hold(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->HoldCall(mServiceId, mCallIndex); + nsresult rv = mTelephony->Provider()->HoldCall(mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -291,7 +290,7 @@ TelephonyCall::Resume(ErrorResult& aRv) return; } - nsresult rv = mTelephony->Provider()->ResumeCall(mServiceId, mCallIndex); + nsresult rv = mTelephony->Provider()->ResumeCall(mCallIndex); if (NS_FAILED(rv)) { aRv.Throw(rv); return; diff --git a/dom/telephony/TelephonyCall.h b/dom/telephony/TelephonyCall.h index 77f40375f89f..982e0c419d56 100644 --- a/dom/telephony/TelephonyCall.h +++ b/dom/telephony/TelephonyCall.h @@ -21,7 +21,6 @@ class TelephonyCall MOZ_FINAL : public nsDOMEventTargetHelper nsRefPtr mTelephony; nsRefPtr mGroup; - uint32_t mServiceId; nsString mNumber; nsString mSecondNumber; nsString mState; @@ -108,8 +107,7 @@ public: IMPL_EVENT_HANDLER(groupchange) static already_AddRefed - Create(Telephony* aTelephony, uint32_t aServiceId, - const nsAString& aNumber, uint16_t aCallState, + Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState, uint32_t aCallIndex = telephony::kOutgoingPlaceholderCallIndex, bool aEmergency = false, bool aIsConference = false); @@ -119,12 +117,6 @@ public: ChangeStateInternal(aCallState, true); } - uint32_t - ServiceId() const - { - return mServiceId; - } - uint32_t CallIndex() const { diff --git a/dom/telephony/TelephonyCallGroup.cpp b/dom/telephony/TelephonyCallGroup.cpp index 201988003b3a..a6579f723a17 100644 --- a/dom/telephony/TelephonyCallGroup.cpp +++ b/dom/telephony/TelephonyCallGroup.cpp @@ -146,10 +146,6 @@ TelephonyCallGroup::CanConference(const TelephonyCall& aCall, MOZ_ASSERT(mCallState == nsITelephonyProvider::CALL_STATE_UNKNOWN); - if (aCall.ServiceId() != aSecondCall->ServiceId()) { - return false; - } - return (aCall.CallState() == nsITelephonyProvider::CALL_STATE_CONNECTED && aSecondCall->CallState() == nsITelephonyProvider::CALL_STATE_HELD) || (aCall.CallState() == nsITelephonyProvider::CALL_STATE_HELD && @@ -157,14 +153,13 @@ TelephonyCallGroup::CanConference(const TelephonyCall& aCall, } already_AddRefed -TelephonyCallGroup::GetCall(uint32_t aServiceId, uint32_t aCallIndex) +TelephonyCallGroup::GetCall(uint32_t aCallIndex) { nsRefPtr call; for (uint32_t index = 0; index < mCalls.Length(); index++) { nsRefPtr& tempCall = mCalls[index]; - if (tempCall->ServiceId() == aServiceId && - tempCall->CallIndex() == aCallIndex) { + if (tempCall->CallIndex() == aCallIndex) { call = tempCall; break; } @@ -212,7 +207,7 @@ TelephonyCallGroup::Add(TelephonyCall& aCall, return; } - aRv = mTelephony->Provider()->ConferenceCall(aCall.ServiceId()); + aRv = mTelephony->Provider()->ConferenceCall(); } void @@ -225,7 +220,7 @@ TelephonyCallGroup::Add(TelephonyCall& aCall, return; } - aRv = mTelephony->Provider()->ConferenceCall(aCall.ServiceId()); + aRv = mTelephony->Provider()->ConferenceCall(); } void @@ -236,14 +231,18 @@ TelephonyCallGroup::Remove(TelephonyCall& aCall, ErrorResult& aRv) return; } - uint32_t serviceId = aCall.ServiceId(); uint32_t callIndex = aCall.CallIndex(); + bool hasCallToRemove = false; + for (uint32_t index = 0; index < mCalls.Length(); index++) { + nsRefPtr& call = mCalls[index]; + if (call->CallIndex() == callIndex) { + hasCallToRemove = true; + break; + } + } - nsRefPtr call; - - call = GetCall(serviceId, callIndex); - if (call) { - aRv = mTelephony->Provider()->SeparateCall(serviceId, callIndex); + if (hasCallToRemove) { + aRv = mTelephony->Provider()->SeparateCall(callIndex); } else { NS_WARNING("Didn't have this call. Ignore!"); } @@ -257,9 +256,7 @@ TelephonyCallGroup::Hold(ErrorResult& aRv) return; } - MOZ_ASSERT(!mCalls.IsEmpty()); - - nsresult rv = mTelephony->Provider()->HoldConference(mCalls[0]->ServiceId()); + nsresult rv = mTelephony->Provider()->HoldConference(); if (NS_FAILED(rv)) { aRv.Throw(rv); return; @@ -276,9 +273,7 @@ TelephonyCallGroup::Resume(ErrorResult& aRv) return; } - MOZ_ASSERT(!mCalls.IsEmpty()); - - nsresult rv = mTelephony->Provider()->ResumeConference(mCalls[0]->ServiceId()); + nsresult rv = mTelephony->Provider()->ResumeConference(); if (NS_FAILED(rv)) { aRv.Throw(rv); return; diff --git a/dom/telephony/TelephonyCallGroup.h b/dom/telephony/TelephonyCallGroup.h index 806454c4f734..a668140015c7 100644 --- a/dom/telephony/TelephonyCallGroup.h +++ b/dom/telephony/TelephonyCallGroup.h @@ -81,7 +81,7 @@ public: RemoveCall(TelephonyCall* aCall); already_AddRefed - GetCall(uint32_t aServiceId, uint32_t aCallIndex); + GetCall(uint32_t aCallIndex); const nsTArray >& CallsArray() const diff --git a/dom/telephony/gonk/TelephonyProvider.js b/dom/telephony/gonk/TelephonyProvider.js index 4b235dacba1a..ce6bf4e77cac 100644 --- a/dom/telephony/gonk/TelephonyProvider.js +++ b/dom/telephony/gonk/TelephonyProvider.js @@ -9,7 +9,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/Promise.jsm"); var RIL = {}; Cu.import("resource://gre/modules/ril_consts.js", RIL); @@ -65,10 +64,6 @@ XPCOMUtils.defineLazyGetter(this, "gAudioManager", function getAudioManager() { } }); -XPCOMUtils.defineLazyServiceGetter(this, "gRadioInterfaceLayer", - "@mozilla.org/ril;1", - "nsIRadioInterfaceLayer"); - XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService", "@mozilla.org/power/powermanagerservice;1", "nsIPowerManagerService"); @@ -77,6 +72,12 @@ XPCOMUtils.defineLazyServiceGetter(this, "gSystemMessenger", "@mozilla.org/system-message-internal;1", "nsISystemMessagesInternal"); +XPCOMUtils.defineLazyGetter(this, "gRadioInterface", function () { + let ril = Cc["@mozilla.org/ril;1"].getService(Ci["nsIRadioInterfaceLayer"]); + // TODO: Bug 854326 - B2G Multi-SIM: support multiple SIM cards for SMS/MMS + return ril.getRadioInterface(0); +}); + XPCOMUtils.defineLazyGetter(this, "gPhoneNumberUtils", function () { let ns = {}; Cu.import("resource://gre/modules/PhoneNumberUtils.jsm", ns); @@ -84,8 +85,8 @@ XPCOMUtils.defineLazyGetter(this, "gPhoneNumberUtils", function () { }); function TelephonyProvider() { - this._numClients = gRadioInterfaceLayer.numRadioInterfaces; this._listeners = []; + this._updateDebugFlag(); this.defaultServiceId = this._getDefaultServiceId(); @@ -139,10 +140,6 @@ TelephonyProvider.prototype = { } }, - _getClient: function _getClient(aClientId) { - return gRadioInterfaceLayer.getRadioInterface(aClientId); - }, - // An array of nsITelephonyListener instances. _listeners: null, _notifyAllListeners: function _notifyAllListeners(aMethodName, aArgs) { @@ -162,16 +159,6 @@ TelephonyProvider.prototype = { } }, - _matchActiveCall: function _matchActiveCall(aCall) { - if (this._activeCall && - this._activeCall.callIndex == aCall.callIndex && - this._activeCall.clientId == aCall.clientId) { - return true; - } - - return false; - }, - /** * Track the active call and update the audio system as its state changes. */ @@ -199,7 +186,7 @@ TelephonyProvider.prototype = { } if (aCall.isConference) { - if (this._matchActiveCall(aCall)) { + if (this._activeCall && this._activeCall.callIndex == aCall.callIndex) { this._activeCall = null; } return; @@ -238,7 +225,8 @@ TelephonyProvider.prototype = { case nsITelephonyProvider.CALL_STATE_HELD: // Fall through... case nsITelephonyProvider.CALL_STATE_DISCONNECTED: aCall.isActive = false; - if (this._matchActiveCall(aCall)) { + if (this._activeCall && + this._activeCall.callIndex == aCall.callIndex) { // Previously active call is not active now. this._activeCall = null; } @@ -344,45 +332,26 @@ TelephonyProvider.prototype = { this._listeners.splice(index, 1); }, - _enumerateCallsForClient: function _enumerateCallsForClient(aClientId, - aListener) { - if (DEBUG) debug("Enumeration of calls for client " + aClientId); - - let deferred = Promise.defer(); - - this._getClient(aClientId).sendWorkerMessage("enumerateCalls", null, - (function(response) { + enumerateCalls: function(aListener) { + if (DEBUG) debug("Requesting enumeration of calls for callback"); + gRadioInterface.sendWorkerMessage("enumerateCalls", null, + (function(response) { for (let call of response.calls) { - call.clienId = aClientId; call.state = this._convertRILCallState(call.state); - call.isActive = this._matchActiveCall(call); + call.isActive = this._activeCall ? + (call.callIndex == this._activeCall.callIndex) : false; - aListener.enumerateCallState(call.clientId, call.callIndex, - call.state, call.number, + aListener.enumerateCallState(call.callIndex, call.state, call.number, call.isActive, call.isOutgoing, call.isEmergency, call.isConference); } - deferred.resolve(); + aListener.enumerateCallStateComplete(); return false; }).bind(this)); - - return deferred.promise; }, - enumerateCalls: function(aListener) { - if (DEBUG) debug("Requesting enumeration of calls for callback"); - - let promise = Promise.resolve(); - for (let i = 0; i < this._numClients; ++i) { - promise = promise.then(this._enumerateCallsForClient.bind(this, i, aListener)); - } - promise.then(function() { - aListener.enumerateCallStateComplete(); - }); - }, - - dial: function(aClientId, aNumber, aIsEmergency) { + dial: function(aNumber, aIsEmergency) { if (DEBUG) debug("Dialing " + (aIsEmergency ? "emergency " : "") + aNumber); // we don't try to be too clever here, as the phone is probably in the // locked state. Let's just check if it's a number without normalizing @@ -390,55 +359,53 @@ TelephonyProvider.prototype = { aNumber = gPhoneNumberUtils.normalize(aNumber); } if (this._validateNumber(aNumber)) { - this._getClient(aClientId).sendWorkerMessage("dial", { - number: aNumber, - isDialEmergency: aIsEmergency - }); + gRadioInterface.sendWorkerMessage("dial", { number: aNumber, + isDialEmergency: aIsEmergency }); } }, - hangUp: function(aClientId, aCallIndex) { - this._getClient(aClientId).sendWorkerMessage("hangUp", { callIndex: aCallIndex }); + hangUp: function(aCallIndex) { + gRadioInterface.sendWorkerMessage("hangUp", { callIndex: aCallIndex }); }, - startTone: function(aClientId, aDtmfChar) { - this._getClient(aClientId).sendWorkerMessage("startTone", { dtmfChar: aDtmfChar }); + startTone: function(aDtmfChar) { + gRadioInterface.sendWorkerMessage("startTone", { dtmfChar: aDtmfChar }); }, - stopTone: function(aClientId) { - this._getClient(aClientId).sendWorkerMessage("stopTone"); + stopTone: function() { + gRadioInterface.sendWorkerMessage("stopTone"); }, - answerCall: function(aClientId, aCallIndex) { - this._getClient(aClientId).sendWorkerMessage("answerCall", { callIndex: aCallIndex }); + answerCall: function(aCallIndex) { + gRadioInterface.sendWorkerMessage("answerCall", { callIndex: aCallIndex }); }, - rejectCall: function(aClientId, aCallIndex) { - this._getClient(aClientId).sendWorkerMessage("rejectCall", { callIndex: aCallIndex }); + rejectCall: function(aCallIndex) { + gRadioInterface.sendWorkerMessage("rejectCall", { callIndex: aCallIndex }); }, - holdCall: function(aClientId, aCallIndex) { - this._getClient(aClientId).sendWorkerMessage("holdCall", { callIndex: aCallIndex }); + holdCall: function(aCallIndex) { + gRadioInterface.sendWorkerMessage("holdCall", { callIndex: aCallIndex }); }, - resumeCall: function(aClientId, aCallIndex) { - this._getClient(aClientId).sendWorkerMessage("resumeCall", { callIndex: aCallIndex }); + resumeCall: function(aCallIndex) { + gRadioInterface.sendWorkerMessage("resumeCall", { callIndex: aCallIndex }); }, - conferenceCall: function conferenceCall(aClientId) { - this._getClient(aClientId).sendWorkerMessage("conferenceCall"); + conferenceCall: function conferenceCall() { + gRadioInterface.sendWorkerMessage("conferenceCall"); }, - separateCall: function separateCall(aClientId, aCallIndex) { - this._getClient(aClientId).sendWorkerMessage("separateCall", { callIndex: aCallIndex }); + separateCall: function separateCall(aCallIndex) { + gRadioInterface.sendWorkerMessage("separateCall", { callIndex: aCallIndex }); }, - holdConference: function holdConference(aClientId) { - this._getClient(aClientId).sendWorkerMessage("holdConference"); + holdConference: function holdConference() { + gRadioInterface.sendWorkerMessage("holdConference"); }, - resumeConference: function resumeConference(aClientId) { - this._getClient(aClientId).sendWorkerMessage("resumeConference"); + resumeConference: function resumeConference() { + gRadioInterface.sendWorkerMessage("resumeConference"); }, get microphoneMuted() { @@ -481,7 +448,7 @@ TelephonyProvider.prototype = { /** * Handle call disconnects by updating our current state and the audio system. */ - notifyCallDisconnected: function notifyCallDisconnected(aClientId, aCall) { + notifyCallDisconnected: function notifyCallDisconnected(aCall) { if (DEBUG) debug("handleCallDisconnected: " + JSON.stringify(aCall)); aCall.state = nsITelephonyProvider.CALL_STATE_DISCONNECTED; @@ -496,8 +463,7 @@ TelephonyProvider.prototype = { this._updateCallAudioState(aCall, null); - this._notifyAllListeners("callStateChanged", [aClientId, - aCall.callIndex, + this._notifyAllListeners("callStateChanged", [aCall.callIndex, aCall.state, aCall.number, aCall.isActive, @@ -509,8 +475,8 @@ TelephonyProvider.prototype = { /** * Handle call error. */ - notifyCallError: function notifyCallError(aClientId, aCallIndex, aErrorMsg) { - this._notifyAllListeners("notifyError", [aClientId, aCallIndex, aErrorMsg]); + notifyCallError: function notifyCallError(aCallIndex, aErrorMsg) { + this._notifyAllListeners("notifyError", [aCallIndex, aErrorMsg]); }, /** @@ -531,7 +497,7 @@ TelephonyProvider.prototype = { * Handle call state changes by updating our current state and the audio * system. */ - notifyCallStateChanged: function notifyCallStateChanged(aClientId, aCall) { + notifyCallStateChanged: function notifyCallStateChanged(aCall) { if (DEBUG) debug("handleCallStateChange: " + JSON.stringify(aCall)); aCall.state = this._convertRILCallState(aCall.state); @@ -541,8 +507,7 @@ TelephonyProvider.prototype = { this._updateCallAudioState(aCall, null); - this._notifyAllListeners("callStateChanged", [aClientId, - aCall.callIndex, + this._notifyAllListeners("callStateChanged", [aCall.callIndex, aCall.state, aCall.number, aCall.isActive, @@ -551,19 +516,19 @@ TelephonyProvider.prototype = { aCall.isConference]); }, - notifyCdmaCallWaiting: function notifyCdmaCallWaiting(aClientId, aNumber) { + notifyCdmaCallWaiting: function notifyCdmaCallWaiting(aNumber) { // We need to acquire a CPU wake lock to avoid the system falling into // the sleep mode when the RIL handles the incoming call. this._acquireCallRingWakeLock(); - this._notifyAllListeners("notifyCdmaCallWaiting", [aClientId, aNumber]); + this._notifyAllListeners("notifyCdmaCallWaiting", [aNumber]); }, - notifySupplementaryService: - function notifySupplementaryService(aClientId, aCallIndex, aNotification) { + notifySupplementaryService: function notifySupplementaryService(aCallIndex, + aNotification) { let notification = this._convertRILSuppSvcNotification(aNotification); this._notifyAllListeners("supplementaryServiceNotification", - [aClientId, aCallIndex, notification]); + [aCallIndex, notification]); }, notifyConferenceCallStateChanged: function notifyConferenceCallStateChanged(aState) { diff --git a/dom/telephony/ipc/PTelephony.ipdl b/dom/telephony/ipc/PTelephony.ipdl index 9ee105036998..d82044401ef5 100644 --- a/dom/telephony/ipc/PTelephony.ipdl +++ b/dom/telephony/ipc/PTelephony.ipdl @@ -17,16 +17,15 @@ sync protocol PTelephony { manages PTelephonyRequest; child: - NotifyCallError(uint32_t aClientId, int32_t aCallIndex, nsString aError); + NotifyCallError(int32_t aCallIndex, nsString aError); - NotifyCallStateChanged(uint32_t aClientId, IPCCallStateData aData); + NotifyCallStateChanged(IPCCallStateData aData); - NotifyCdmaCallWaiting(uint32_t aClientId, nsString aNumber); + NotifyCdmaCallWaiting(nsString aNumber); NotifyConferenceCallStateChanged(uint16_t aCallState); - NotifySupplementaryService(uint32_t aClientId, int32_t aCallIndex, - uint16_t aNotification); + NotifySupplementaryService(int32_t aCallIndex, uint16_t aNotification); parent: /** @@ -44,29 +43,29 @@ parent: UnregisterListener(); - DialCall(uint32_t aClientId, nsString aNumber, bool aIsEmergency); + DialCall(nsString aNumber, bool aIsEmergency); - HangUpCall(uint32_t aClientId, uint32_t aCallIndex); + HangUpCall(uint32_t aCallIndex); - AnswerCall(uint32_t aClientId, uint32_t aCallIndex); + AnswerCall(uint32_t aCallIndex); - RejectCall(uint32_t aClientId, uint32_t aCallIndex); + RejectCall(uint32_t aCallIndex); - HoldCall(uint32_t aClientId, uint32_t aCallIndex); + HoldCall(uint32_t aCallIndex); - ResumeCall(uint32_t aClientId, uint32_t aCallIndex); + ResumeCall(uint32_t aCallIndex); - ConferenceCall(uint32_t aClientId); + ConferenceCall(); - SeparateCall(uint32_t aClientId, uint32_t aCallIndex); + SeparateCall(uint32_t aCallIndex); - HoldConference(uint32_t aClientId); + HoldConference(); - ResumeConference(uint32_t aClientId); + ResumeConference(); - StartTone(uint32_t aClientId, nsString aTone); + StartTone(nsString aTone); - StopTone(uint32_t aClientId); + StopTone(); sync GetMicrophoneMuted() returns (bool aMuted); diff --git a/dom/telephony/ipc/PTelephonyRequest.ipdl b/dom/telephony/ipc/PTelephonyRequest.ipdl index 70ed3bd65f75..05f708ffc6a0 100644 --- a/dom/telephony/ipc/PTelephonyRequest.ipdl +++ b/dom/telephony/ipc/PTelephonyRequest.ipdl @@ -16,7 +16,7 @@ protocol PTelephonyRequest manager PTelephony; child: - NotifyEnumerateCallState(uint32_t aClientId, IPCCallStateData aData); + NotifyEnumerateCallState(IPCCallStateData aData); /** * Sent when the asynchronous request has completed. It's currently only for diff --git a/dom/telephony/ipc/TelephonyChild.cpp b/dom/telephony/ipc/TelephonyChild.cpp index a84c17febfc8..411e3b35f0a7 100644 --- a/dom/telephony/ipc/TelephonyChild.cpp +++ b/dom/telephony/ipc/TelephonyChild.cpp @@ -37,24 +37,21 @@ TelephonyChild::DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) } bool -TelephonyChild::RecvNotifyCallError(const uint32_t& aClientId, - const int32_t& aCallIndex, +TelephonyChild::RecvNotifyCallError(const int32_t& aCallIndex, const nsString& aError) { MOZ_ASSERT(mListener); - mListener->NotifyError(aClientId, aCallIndex, aError); + mListener->NotifyError(aCallIndex, aError); return true; } bool -TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, - const IPCCallStateData& aData) +TelephonyChild::RecvNotifyCallStateChanged(const IPCCallStateData& aData) { MOZ_ASSERT(mListener); - mListener->CallStateChanged(aClientId, - aData.callIndex(), + mListener->CallStateChanged(aData.callIndex(), aData.callState(), aData.number(), aData.isActive(), @@ -65,12 +62,11 @@ TelephonyChild::RecvNotifyCallStateChanged(const uint32_t& aClientId, } bool -TelephonyChild::RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, - const nsString& aNumber) +TelephonyChild::RecvNotifyCdmaCallWaiting(const nsString& aNumber) { MOZ_ASSERT(mListener); - mListener->NotifyCdmaCallWaiting(aClientId, aNumber); + mListener->NotifyCdmaCallWaiting(aNumber); return true; } @@ -84,14 +80,12 @@ TelephonyChild::RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) } bool -TelephonyChild::RecvNotifySupplementaryService(const uint32_t& aClientId, - const int32_t& aCallIndex, +TelephonyChild::RecvNotifySupplementaryService(const int32_t& aCallIndex, const uint16_t& aNotification) { MOZ_ASSERT(mListener); - mListener->SupplementaryServiceNotification(aClientId, aCallIndex, - aNotification); + mListener->SupplementaryServiceNotification(aCallIndex, aNotification); return true; } @@ -121,13 +115,11 @@ TelephonyRequestChild::Recv__delete__() } bool -TelephonyRequestChild::RecvNotifyEnumerateCallState(const uint32_t& aClientId, - const IPCCallStateData& aData) +TelephonyRequestChild::RecvNotifyEnumerateCallState(const IPCCallStateData& aData) { MOZ_ASSERT(mListener); - mListener->EnumerateCallState(aClientId, - aData.callIndex(), + mListener->EnumerateCallState(aData.callIndex(), aData.callState(), aData.number(), aData.isActive(), diff --git a/dom/telephony/ipc/TelephonyChild.h b/dom/telephony/ipc/TelephonyChild.h index ecf2adccdf74..91eb1f8d2a54 100644 --- a/dom/telephony/ipc/TelephonyChild.h +++ b/dom/telephony/ipc/TelephonyChild.h @@ -31,23 +31,20 @@ protected: DeallocPTelephonyRequestChild(PTelephonyRequestChild* aActor) MOZ_OVERRIDE; virtual bool - RecvNotifyCallError(const uint32_t& aClientId, const int32_t& aCallIndex, + RecvNotifyCallError(const int32_t& aCallIndex, const nsString& aError) MOZ_OVERRIDE; virtual bool - RecvNotifyCallStateChanged(const uint32_t& aClientId, - const IPCCallStateData& aData) MOZ_OVERRIDE; + RecvNotifyCallStateChanged(const IPCCallStateData& aData) MOZ_OVERRIDE; virtual bool - RecvNotifyCdmaCallWaiting(const uint32_t& aClientId, - const nsString& aNumber) MOZ_OVERRIDE; + RecvNotifyCdmaCallWaiting(const nsString& aNumber) MOZ_OVERRIDE; virtual bool RecvNotifyConferenceCallStateChanged(const uint16_t& aCallState) MOZ_OVERRIDE; virtual bool - RecvNotifySupplementaryService(const uint32_t& aClientId, - const int32_t& aCallIndex, + RecvNotifySupplementaryService(const int32_t& aCallIndex, const uint16_t& aNotification) MOZ_OVERRIDE; private: @@ -69,8 +66,7 @@ protected: Recv__delete__() MOZ_OVERRIDE; virtual bool - RecvNotifyEnumerateCallState(const uint32_t& aClientId, - const IPCCallStateData& aData) MOZ_OVERRIDE; + RecvNotifyEnumerateCallState(const IPCCallStateData& aData) MOZ_OVERRIDE; private: nsCOMPtr mListener; diff --git a/dom/telephony/ipc/TelephonyIPCProvider.cpp b/dom/telephony/ipc/TelephonyIPCProvider.cpp index c147fbb47975..6da47f8face6 100644 --- a/dom/telephony/ipc/TelephonyIPCProvider.cpp +++ b/dom/telephony/ipc/TelephonyIPCProvider.cpp @@ -128,87 +128,87 @@ TelephonyIPCProvider::EnumerateCalls(nsITelephonyListener *aListener) } NS_IMETHODIMP -TelephonyIPCProvider::Dial(uint32_t aClientId, const nsAString& aNumber, - bool aIsEmergency) +TelephonyIPCProvider::Dial(const nsAString& aNumber, + bool aIsEmergency) { - mPTelephonyChild->SendDialCall(aClientId, nsString(aNumber), aIsEmergency); + mPTelephonyChild->SendDialCall(nsString(aNumber), aIsEmergency); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HangUp(uint32_t aClientId, uint32_t aCallIndex) +TelephonyIPCProvider::HangUp(uint32_t aCallIndex) { - mPTelephonyChild->SendHangUpCall(aClientId, aCallIndex); + mPTelephonyChild->SendHangUpCall(aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::AnswerCall(uint32_t aClientId, uint32_t aCallIndex) +TelephonyIPCProvider::AnswerCall(uint32_t aCallIndex) { - mPTelephonyChild->SendAnswerCall(aClientId, aCallIndex); + mPTelephonyChild->SendAnswerCall(aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::RejectCall(uint32_t aClientId, uint32_t aCallIndex) +TelephonyIPCProvider::RejectCall(uint32_t aCallIndex) { - mPTelephonyChild->SendRejectCall(aClientId, aCallIndex); + mPTelephonyChild->SendRejectCall(aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HoldCall(uint32_t aClientId, uint32_t aCallIndex) +TelephonyIPCProvider::HoldCall(uint32_t aCallIndex) { - mPTelephonyChild->SendHoldCall(aClientId, aCallIndex); + mPTelephonyChild->SendHoldCall(aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ResumeCall(uint32_t aClientId, uint32_t aCallIndex) +TelephonyIPCProvider::ResumeCall(uint32_t aCallIndex) { - mPTelephonyChild->SendResumeCall(aClientId, aCallIndex); + mPTelephonyChild->SendResumeCall(aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ConferenceCall(uint32_t aClientId) +TelephonyIPCProvider::ConferenceCall() { - mPTelephonyChild->SendConferenceCall(aClientId); + mPTelephonyChild->SendConferenceCall(); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::SeparateCall(uint32_t aClientId, uint32_t aCallIndex) +TelephonyIPCProvider::SeparateCall(uint32_t aCallIndex) { - mPTelephonyChild->SendSeparateCall(aClientId, aCallIndex); + mPTelephonyChild->SendSeparateCall(aCallIndex); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::HoldConference(uint32_t aClientId) +TelephonyIPCProvider::HoldConference() { - mPTelephonyChild->SendHoldConference(aClientId); + mPTelephonyChild->SendHoldConference(); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::ResumeConference(uint32_t aClientId) +TelephonyIPCProvider::ResumeConference() { - mPTelephonyChild->SendResumeConference(aClientId); + mPTelephonyChild->SendResumeConference(); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::StartTone(uint32_t aClientId, const nsAString& aDtmfChar) +TelephonyIPCProvider::StartTone(const nsAString& aDtmfChar) { - mPTelephonyChild->SendStartTone(aClientId, nsString(aDtmfChar)); + mPTelephonyChild->SendStartTone(nsString(aDtmfChar)); return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::StopTone(uint32_t aClientId) +TelephonyIPCProvider::StopTone() { - mPTelephonyChild->SendStopTone(aClientId); + mPTelephonyChild->SendStopTone(); return NS_OK; } @@ -243,17 +243,16 @@ TelephonyIPCProvider::SetSpeakerEnabled(bool aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyIPCProvider::CallStateChanged(uint32_t aClientId, - uint32_t aCallIndex, - uint16_t aCallState, - const nsAString& aNumber, - bool aIsActive, - bool aIsOutgoing, - bool aIsEmergency, - bool aIsConference) +TelephonyIPCProvider::CallStateChanged(uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aNumber, + bool aIsActive, + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->CallStateChanged(aClientId, aCallIndex, aCallState, aNumber, + mListeners[i]->CallStateChanged(aCallIndex, aCallState, aNumber, aIsActive, aIsOutgoing, aIsEmergency, aIsConference); } @@ -276,46 +275,42 @@ TelephonyIPCProvider::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyIPCProvider::EnumerateCallState(uint32_t aClientId, - uint32_t aCallIndex, - uint16_t aCallState, - const nsAString& aNumber, - bool aIsActive, - bool aIsOutgoing, - bool aIsEmergency, - bool aIsConference) +TelephonyIPCProvider::EnumerateCallState(uint32_t aCallIndex, + uint16_t aCallState, + const nsAString& aNumber, + bool aIsActive, + bool aIsOutgoing, + bool aIsEmergency, + bool aIsConference) { MOZ_CRASH("Not a EnumerateCalls request!"); } NS_IMETHODIMP -TelephonyIPCProvider::NotifyCdmaCallWaiting(uint32_t aClientId, - const nsAString& aNumber) +TelephonyIPCProvider::NotifyCdmaCallWaiting(const nsAString& aNumber) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->NotifyCdmaCallWaiting(aClientId, aNumber); + mListeners[i]->NotifyCdmaCallWaiting(aNumber); } return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::NotifyError(uint32_t aClientId, int32_t aCallIndex, - const nsAString& aError) +TelephonyIPCProvider::NotifyError(int32_t aCallIndex, + const nsAString& aError) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->NotifyError(aClientId, aCallIndex, aError); + mListeners[i]->NotifyError(aCallIndex, aError); } return NS_OK; } NS_IMETHODIMP -TelephonyIPCProvider::SupplementaryServiceNotification(uint32_t aClientId, - int32_t aCallIndex, - uint16_t aNotification) +TelephonyIPCProvider::SupplementaryServiceNotification(int32_t aCallIndex, + uint16_t aNotification) { for (uint32_t i = 0; i < mListeners.Length(); i++) { - mListeners[i]->SupplementaryServiceNotification(aClientId, aCallIndex, - aNotification); + mListeners[i]->SupplementaryServiceNotification(aCallIndex, aNotification); } return NS_OK; } diff --git a/dom/telephony/ipc/TelephonyParent.cpp b/dom/telephony/ipc/TelephonyParent.cpp index a9be3eeaaae4..8db736c390de 100644 --- a/dom/telephony/ipc/TelephonyParent.cpp +++ b/dom/telephony/ipc/TelephonyParent.cpp @@ -92,142 +92,135 @@ TelephonyParent::RecvUnregisterListener() } bool -TelephonyParent::RecvDialCall(const uint32_t& aClientId, - const nsString& aNumber, +TelephonyParent::RecvDialCall(const nsString& aNumber, const bool& aIsEmergency) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->Dial(aClientId, aNumber, aIsEmergency); + provider->Dial(aNumber, aIsEmergency); return true; } bool -TelephonyParent::RecvHangUpCall(const uint32_t& aClientId, - const uint32_t& aCallIndex) +TelephonyParent::RecvHangUpCall(const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HangUp(aClientId, aCallIndex); + provider->HangUp(aCallIndex); return true; } bool -TelephonyParent::RecvAnswerCall(const uint32_t& aClientId, - const uint32_t& aCallIndex) +TelephonyParent::RecvAnswerCall(const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->AnswerCall(aClientId, aCallIndex); + provider->AnswerCall(aCallIndex); return true; } bool -TelephonyParent::RecvRejectCall(const uint32_t& aClientId, - const uint32_t& aCallIndex) +TelephonyParent::RecvRejectCall(const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->RejectCall(aClientId, aCallIndex); + provider->RejectCall(aCallIndex); return true; } bool -TelephonyParent::RecvHoldCall(const uint32_t& aClientId, - const uint32_t& aCallIndex) +TelephonyParent::RecvHoldCall(const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HoldCall(aClientId, aCallIndex); + provider->HoldCall(aCallIndex); return true; } bool -TelephonyParent::RecvResumeCall(const uint32_t& aClientId, - const uint32_t& aCallIndex) +TelephonyParent::RecvResumeCall(const uint32_t& aCallIndex) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ResumeCall(aClientId, aCallIndex); + provider->ResumeCall(aCallIndex); return true; } bool -TelephonyParent::RecvConferenceCall(const uint32_t& aClientId) +TelephonyParent::RecvConferenceCall() { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ConferenceCall(aClientId); + provider->ConferenceCall(); return true; } bool -TelephonyParent::RecvSeparateCall(const uint32_t& aClientId, - const uint32_t& aCallIndex) +TelephonyParent::RecvSeparateCall(const uint32_t& aCallState) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->SeparateCall(aClientId, aCallIndex); + provider->SeparateCall(aCallState); return true; } bool -TelephonyParent::RecvHoldConference(const uint32_t& aClientId) +TelephonyParent::RecvHoldConference() { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->HoldConference(aClientId); + provider->HoldConference(); return true; } bool -TelephonyParent::RecvResumeConference(const uint32_t& aClientId) +TelephonyParent::RecvResumeConference() { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->ResumeConference(aClientId); + provider->ResumeConference(); return true; } bool -TelephonyParent::RecvStartTone(const uint32_t& aClientId, const nsString& aTone) +TelephonyParent::RecvStartTone(const nsString& aTone) { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->StartTone(aClientId, aTone); + provider->StartTone(aTone); return true; } bool -TelephonyParent::RecvStopTone(const uint32_t& aClientId) +TelephonyParent::RecvStopTone() { nsCOMPtr provider = do_GetService(TELEPHONY_PROVIDER_CONTRACTID); NS_ENSURE_TRUE(provider, true); - provider->StopTone(aClientId); + provider->StopTone(); return true; } @@ -282,8 +275,7 @@ TelephonyParent::RecvSetSpeakerEnabled(const bool& aEnabled) // nsITelephonyListener NS_IMETHODIMP -TelephonyParent::CallStateChanged(uint32_t aClientId, - uint32_t aCallIndex, +TelephonyParent::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -293,9 +285,9 @@ TelephonyParent::CallStateChanged(uint32_t aClientId, { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), - aIsActive, aIsOutgoing, aIsEmergency, aIsConference); - return SendNotifyCallStateChanged(aClientId, data) ? NS_OK : NS_ERROR_FAILURE; + IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), aIsActive, + aIsOutgoing, aIsEmergency, aIsConference); + return SendNotifyCallStateChanged(data) ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP @@ -314,8 +306,7 @@ TelephonyParent::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyParent::EnumerateCallState(uint32_t aClientId, - uint32_t aCallIndex, +TelephonyParent::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -327,35 +318,32 @@ TelephonyParent::EnumerateCallState(uint32_t aClientId, } NS_IMETHODIMP -TelephonyParent::NotifyCdmaCallWaiting(uint32_t aClientId, - const nsAString& aNumber) +TelephonyParent::NotifyCdmaCallWaiting(const nsAString& aNumber) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCdmaCallWaiting(aClientId, nsString(aNumber)) - ? NS_OK : NS_ERROR_FAILURE; + return SendNotifyCdmaCallWaiting(nsString(aNumber)) ? NS_OK + : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyParent::NotifyError(uint32_t aClientId, - int32_t aCallIndex, +TelephonyParent::NotifyError(int32_t aCallIndex, const nsAString& aError) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifyCallError(aClientId, aCallIndex, nsString(aError)) - ? NS_OK : NS_ERROR_FAILURE; + return SendNotifyCallError(aCallIndex, nsString(aError)) ? NS_OK + : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyParent::SupplementaryServiceNotification(uint32_t aClientId, - int32_t aCallIndex, +TelephonyParent::SupplementaryServiceNotification(int32_t aCallIndex, uint16_t aNotification) { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - return SendNotifySupplementaryService(aClientId, aCallIndex, aNotification) - ? NS_OK : NS_ERROR_FAILURE; + return SendNotifySupplementaryService(aCallIndex, aNotification) + ? NS_OK : NS_ERROR_FAILURE; } /******************************************************************************* @@ -399,8 +387,7 @@ TelephonyRequestParent::DoRequest() // nsITelephonyListener NS_IMETHODIMP -TelephonyRequestParent::CallStateChanged(uint32_t aClientId, - uint32_t aCallIndex, +TelephonyRequestParent::CallStateChanged(uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -426,8 +413,7 @@ TelephonyRequestParent::EnumerateCallStateComplete() } NS_IMETHODIMP -TelephonyRequestParent::EnumerateCallState(uint32_t aClientId, - uint32_t aCallIndex, +TelephonyRequestParent::EnumerateCallState(uint32_t aCallIndex, uint16_t aCallState, const nsAString& aNumber, bool aIsActive, @@ -437,30 +423,26 @@ TelephonyRequestParent::EnumerateCallState(uint32_t aClientId, { NS_ENSURE_TRUE(!mActorDestroyed, NS_ERROR_FAILURE); - IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), - aIsActive, aIsOutgoing, aIsEmergency, aIsConference); - return SendNotifyEnumerateCallState(aClientId, data) ? NS_OK - : NS_ERROR_FAILURE; + IPCCallStateData data(aCallIndex, aCallState, nsString(aNumber), aIsActive, + aIsOutgoing, aIsEmergency, aIsConference); + return SendNotifyEnumerateCallState(data) ? NS_OK : NS_ERROR_FAILURE; } NS_IMETHODIMP -TelephonyRequestParent::NotifyCdmaCallWaiting(uint32_t aClientId, - const nsAString& aNumber) +TelephonyRequestParent::NotifyCdmaCallWaiting(const nsAString& aNumber) { MOZ_CRASH("Not a TelephonyParent!"); } NS_IMETHODIMP -TelephonyRequestParent::NotifyError(uint32_t aClientId, - int32_t aCallIndex, +TelephonyRequestParent::NotifyError(int32_t aCallIndex, const nsAString& aError) { MOZ_CRASH("Not a TelephonyParent!"); } NS_IMETHODIMP -TelephonyRequestParent::SupplementaryServiceNotification(uint32_t aClientId, - int32_t aCallIndex, +TelephonyRequestParent::SupplementaryServiceNotification(int32_t aCallIndex, uint16_t aNotification) { MOZ_CRASH("Not a TelephonyParent!"); diff --git a/dom/telephony/ipc/TelephonyParent.h b/dom/telephony/ipc/TelephonyParent.h index 16abf189bbfd..ac508c264bea 100644 --- a/dom/telephony/ipc/TelephonyParent.h +++ b/dom/telephony/ipc/TelephonyParent.h @@ -47,40 +47,41 @@ protected: RecvUnregisterListener() MOZ_OVERRIDE; virtual bool - RecvDialCall(const uint32_t& aClientId, const nsString& aNumber, const bool& aIsEmergency) MOZ_OVERRIDE; + RecvDialCall(const nsString& aNumber, + const bool& aIsEmergency) MOZ_OVERRIDE; virtual bool - RecvHangUpCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvHangUpCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvAnswerCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvAnswerCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvRejectCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvRejectCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvHoldCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvHoldCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvResumeCall(const uint32_t& aClientId, const uint32_t& aCallIndex) MOZ_OVERRIDE; + RecvResumeCall(const uint32_t& aCallIndex) MOZ_OVERRIDE; virtual bool - RecvConferenceCall(const uint32_t& aClientId) MOZ_OVERRIDE; + RecvConferenceCall() MOZ_OVERRIDE; virtual bool - RecvSeparateCall(const uint32_t& aClientId, const uint32_t& callIndex) MOZ_OVERRIDE; + RecvSeparateCall(const uint32_t& callIndex) MOZ_OVERRIDE; virtual bool - RecvHoldConference(const uint32_t& aClientId) MOZ_OVERRIDE; + RecvHoldConference() MOZ_OVERRIDE; virtual bool - RecvResumeConference(const uint32_t& aClientId) MOZ_OVERRIDE; + RecvResumeConference() MOZ_OVERRIDE; virtual bool - RecvStartTone(const uint32_t& aClientId, const nsString& aTone) MOZ_OVERRIDE; + RecvStartTone(const nsString& aTone) MOZ_OVERRIDE; virtual bool - RecvStopTone(const uint32_t& aClientId) MOZ_OVERRIDE; + RecvStopTone() MOZ_OVERRIDE; virtual bool RecvGetMicrophoneMuted(bool* aMuted) MOZ_OVERRIDE; diff --git a/dom/telephony/nsIGonkTelephonyProvider.idl b/dom/telephony/nsIGonkTelephonyProvider.idl index f2edd9611be7..43f18581a8e1 100644 --- a/dom/telephony/nsIGonkTelephonyProvider.idl +++ b/dom/telephony/nsIGonkTelephonyProvider.idl @@ -10,21 +10,21 @@ "@mozilla.org/telephony/gonktelephonyprovider;1" %} -[scriptable, uuid(fe113e67-5a15-49e6-a555-7f41409f611a)] +[scriptable, uuid(f072f334-e4ea-4754-9929-533da30444a8)] interface nsIGonkTelephonyProvider : nsITelephonyProvider { - void notifyCallDisconnected(in unsigned long clientId, in jsval call); + void notifyCallDisconnected(in jsval call); - void notifyCallError(in unsigned long clientId, in long callIndex, + void notifyCallError(in long callIndex, in AString error); void notifyCallRing(); - void notifyCallStateChanged(in unsigned long clientId, in jsval call); + void notifyCallStateChanged(in jsval call); - void notifyCdmaCallWaiting(in unsigned long clientId, in AString number); + void notifyCdmaCallWaiting(in AString number); - void notifySupplementaryService(in unsigned long clientId, in long callIndex, + void notifySupplementaryService(in long callIndex, in AString notification); void notifyConferenceCallStateChanged(in short state); diff --git a/dom/telephony/nsITelephonyProvider.idl b/dom/telephony/nsITelephonyProvider.idl index e73ed97c6944..cda5e1ba109e 100644 --- a/dom/telephony/nsITelephonyProvider.idl +++ b/dom/telephony/nsITelephonyProvider.idl @@ -4,14 +4,12 @@ #include "nsISupports.idl" -[scriptable, uuid(707c4c43-a0d7-4093-af52-d4d6a3a333c3)] +[scriptable, uuid(3aa42e77-7c2b-43a1-b105-7be094b0817a)] interface nsITelephonyListener : nsISupports { /** * Notified when a telephony call changes state. * - * @param clientId - Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. * @param callState @@ -27,8 +25,7 @@ interface nsITelephonyListener : nsISupports * @param isConference * Indicates whether this call is a conference call. */ - void callStateChanged(in unsigned long clientId, - in unsigned long callIndex, + void callStateChanged(in unsigned long callIndex, in unsigned short callState, in AString number, in boolean isActive, @@ -58,8 +55,6 @@ interface nsITelephonyListener : nsISupports * telephony call state (nsITelephonyProvider::enumerateCalls). This is * called once per call that is currently managed by the RIL. * - * @param clientId - Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. * @param callState @@ -73,8 +68,7 @@ interface nsITelephonyListener : nsISupports * @param isConference * Indicates whether this call is a conference call. */ - void enumerateCallState(in unsigned long clientId, - in unsigned long callIndex, + void enumerateCallState(in unsigned long callIndex, in unsigned short callState, in AString number, in boolean isActive, @@ -85,40 +79,32 @@ interface nsITelephonyListener : nsISupports /** * Notify when RIL receives supplementary service notification. * - * @param clientId - Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. -1 if not specified * @param notification * One of the nsITelephonyProvider::NOTIFICATION_* values. */ - void supplementaryServiceNotification(in unsigned long clientId, - in long callIndex, + void supplementaryServiceNotification(in long callIndex, in unsigned short notification); /** * Called when RIL error occurs. * - * @param clientId - Indicate the RIL client, 0 ~ (number of client - 1). * @param callIndex * Call identifier assigned by the RIL. -1 if no connection * @param error * Error from RIL. */ - void notifyError(in unsigned long clientId, - in long callIndex, + void notifyError(in long callIndex, in AString error); /** * Called when a waiting call comes in CDMA networks. * - * @param clientId - Indicate the RIL client, 0 ~ (number of client - 1). * @param number * Number of the other party. */ - void notifyCdmaCallWaiting(in unsigned long clientId, in AString number); + void notifyCdmaCallWaiting(in AString number); }; %{C++ @@ -132,7 +118,7 @@ interface nsITelephonyListener : nsISupports * XPCOM component (in the content process) that provides the telephony * information. */ -[scriptable, uuid(4ff3ecb7-b024-4752-9dd6-c3623c6e6b8a)] +[scriptable, uuid(f7680b82-53fc-42a7-9adf-bc0f2726425c)] interface nsITelephonyProvider : nsISupports { const unsigned short CALL_STATE_UNKNOWN = 0; @@ -169,22 +155,22 @@ interface nsITelephonyProvider : nsISupports /** * Functionality for making and managing phone calls. */ - void dial(in unsigned long clientId, in DOMString number, + void dial(in DOMString number, in boolean isEmergency); - void hangUp(in unsigned long clientId, in unsigned long callIndex); + void hangUp(in unsigned long callIndex); - void startTone(in unsigned long clientId, in DOMString dtmfChar); - void stopTone(in unsigned long clientId); + void startTone(in DOMString dtmfChar); + void stopTone(); - void answerCall(in unsigned long clientId, in unsigned long callIndex); - void rejectCall(in unsigned long clientId, in unsigned long callIndex); - void holdCall(in unsigned long clientId, in unsigned long callIndex); - void resumeCall(in unsigned long clientId, in unsigned long callIndex); + void answerCall(in unsigned long callIndex); + void rejectCall(in unsigned long callIndex); + void holdCall(in unsigned long callIndex); + void resumeCall(in unsigned long callIndex); - void conferenceCall(in unsigned long clientId); - void separateCall(in unsigned long clientId, in unsigned long callIndex); - void holdConference(in unsigned long clientId); - void resumeConference(in unsigned long clientId); + void conferenceCall(); + void separateCall(in unsigned long callIndex); + void holdConference(); + void resumeConference(); attribute bool microphoneMuted; attribute bool speakerEnabled; diff --git a/dom/webidl/Telephony.webidl b/dom/webidl/Telephony.webidl index 2d4ae7b7d951..cf25b2d3a0d7 100644 --- a/dom/webidl/Telephony.webidl +++ b/dom/webidl/Telephony.webidl @@ -6,31 +6,13 @@ [Pref="dom.telephony.enabled"] interface Telephony : EventTarget { - /** - * There are multiple telephony services in multi-sim architecture. We use - * |serviceId| to indicate the target telephony service. If not specified, - * the implementation MUST use the default service. - * - * Possible values of |serviceId| are 0 ~ (number of services - 1), which is - * simply the index of a service. Get number of services by acquiring - * |navigator.mozMobileConnections.length|. - */ - [Throws] - TelephonyCall dial(DOMString number, optional unsigned long serviceId); - + TelephonyCall dial(DOMString number); [Throws] - TelephonyCall dialEmergency(DOMString number, optional unsigned long serviceId); - - [Throws] - void startTone(DOMString tone, optional unsigned long serviceId); - - [Throws] - void stopTone(optional unsigned long serviceId); + TelephonyCall dialEmergency(DOMString number); [Throws] attribute boolean muted; - [Throws] attribute boolean speakerEnabled; @@ -40,6 +22,11 @@ interface Telephony : EventTarget { readonly attribute CallsList calls; readonly attribute TelephonyCallGroup conferenceGroup; + [Throws] + void startTone(DOMString tone); + [Throws] + void stopTone(); + attribute EventHandler onincoming; attribute EventHandler oncallschanged; attribute EventHandler onremoteheld; diff --git a/dom/webidl/TelephonyCall.webidl b/dom/webidl/TelephonyCall.webidl index 3a83404d6c3c..f96c734b4adc 100644 --- a/dom/webidl/TelephonyCall.webidl +++ b/dom/webidl/TelephonyCall.webidl @@ -6,9 +6,6 @@ [Pref="dom.telephony.enabled"] interface TelephonyCall : EventTarget { - // Indicate which service the call comes from. - readonly attribute unsigned long serviceId; - readonly attribute DOMString number; // In CDMA networks, the 2nd waiting call shares the connection with the 1st From c24f344dbbad3a968454a89fbb92cce4b8ec1356 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 30 Oct 2013 18:22:16 -0200 Subject: [PATCH 567/795] Bug 932763 - Setting mozContact's array properties to an empty array should work. r=gwagner --- dom/contacts/ContactManager.js | 18 +++++++++--------- dom/contacts/tests/test_contacts_basics.html | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dom/contacts/ContactManager.js b/dom/contacts/ContactManager.js index 5d64d1e51e85..5cc196d3ce6b 100644 --- a/dom/contacts/ContactManager.js +++ b/dom/contacts/ContactManager.js @@ -176,18 +176,18 @@ function validateArrayField(data, createCb) { } }; - if (data) { - data = Array.isArray(data) ? data : [data]; - let filtered = []; - for (let i = 0, n = data.length; i < n; ++i) { + if (data === null || data === undefined) { + return undefined; + } + + data = Array.isArray(data) ? data : [data]; + let filtered = []; + for (let i = 0, n = data.length; i < n; ++i) { + if (data[i]) { filtered.push(createCb(data[i])); } - if (filtered.length === 0) { - return undefined; - } - return new Proxy(filtered, ArrayPropertyHandler); } - return undefined; + return new Proxy(filtered, ArrayPropertyHandler); } // We need this to create a copy of the mozContact object in ContactManager.save diff --git a/dom/contacts/tests/test_contacts_basics.html b/dom/contacts/tests/test_contacts_basics.html index 04fca7806cc5..5e19a7b4b500 100644 --- a/dom/contacts/tests/test_contacts_basics.html +++ b/dom/contacts/tests/test_contacts_basics.html @@ -1668,6 +1668,22 @@ var steps = [ } next(); }, + function() { + ok(true, "Setting array properties to an empty array should work"); + var c = new mozContact(); + function testArrayProp(prop) { + is(c[prop], null, "property is initially null"); + c[prop] = []; + ok(Array.isArray(c[prop]), "property is an array after setting"); + is(c[prop].length, 0, "property has length 0 after setting"); + } + testArrayProp("email"); + testArrayProp("adr"); + testArrayProp("tel"); + testArrayProp("impp"); + testArrayProp("url"); + next(); + }, function () { ok(true, "all done!\n"); clearTemps(); From e08ba777b17f964227141823b8f5f13290d30f50 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 30 Oct 2013 17:06:15 -0400 Subject: [PATCH 568/795] Bug 906877 - Remove code obsoleted by multi-apzc. r=BenWa, vingtetun Now that we have multi-APZC landed, we don't need BrowserElementPanning to detect when it's about to scroll a subframe and let APZC know. So the two messages involved in this can be completely removed. --- dom/browser-element/BrowserElementPanning.js | 60 ++------------------ dom/ipc/TabChild.cpp | 24 +------- gfx/layers/composite/APZCTreeManager.cpp | 18 ------ gfx/layers/composite/APZCTreeManager.h | 16 ------ gfx/layers/ipc/AsyncPanZoomController.cpp | 55 +----------------- gfx/layers/ipc/AsyncPanZoomController.h | 26 --------- layout/ipc/PRenderFrame.ipdl | 3 - layout/ipc/RenderFrameChild.cpp | 12 ---- layout/ipc/RenderFrameChild.h | 3 - layout/ipc/RenderFrameParent.cpp | 18 ------ layout/ipc/RenderFrameParent.h | 3 - 11 files changed, 9 insertions(+), 229 deletions(-) diff --git a/dom/browser-element/BrowserElementPanning.js b/dom/browser-element/BrowserElementPanning.js index 26accaf83263..6282a97edd21 100644 --- a/dom/browser-element/BrowserElementPanning.js +++ b/dom/browser-element/BrowserElementPanning.js @@ -48,7 +48,7 @@ const ContentPanning = { // If we are using an AsyncPanZoomController for the parent frame, // it will handle subframe scrolling too. We don't need to listen for // these events. - if (!this._asyncPanZoomForViewportFrame) { + if (!docShell.asyncPanZoomEnabled) { let els = Cc["@mozilla.org/eventlistenerservice;1"] .getService(Ci.nsIEventListenerService); @@ -155,23 +155,11 @@ const ContentPanning = { let oldTarget = this.target; [this.target, this.scrollCallback] = this.getPannable(this.pointerDownTarget); - // If we found a target, that means we have found a scrollable subframe. In - // this case, and if we are using async panning and zooming on the parent - // frame, inform the pan/zoom controller that it should not attempt to - // handle any touch events it gets until the next batch (meaning the next - // time we get a touch end). - if (this.target != null && this._asyncPanZoomForViewportFrame) { - this.detectingScrolling = true; - var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); - os.notifyObservers(docShell, 'detect-scrollable-subframe', null); - } - - // If we have a pointer down target and we're not async - // pan/zooming, we may need to fill in for EventStateManager in - // setting the active state on the target element. Set a timer to + // If we have a pointer down target, we may need to fill in for EventStateManager + // in setting the active state on the target element. Set a timer to // ensure the pointer-down target is active. (If it's already // active, the timer is a no-op.) - if (this.pointerDownTarget !== null && !this.detectingScrolling) { + if (this.pointerDownTarget !== null) { // If there's no possibility this is a drag/pan, activate now. // Otherwise wait a little bit to see if the gesture isn't a // tap. @@ -262,12 +250,6 @@ const ContentPanning = { this.pointerDownTarget = null; }, - // True when there's an async pan-zoom controll watching the - // outermost scrollable frame, and we're waiting to see whether - // we're going to take over from it and synchronously scroll an - // inner scrollable frame. - detectingScrolling: false, - onTouchMove: function cp_onTouchMove(evt) { if (!this.dragging) return; @@ -296,27 +278,7 @@ const ContentPanning = { } let isPan = KineticPanning.isPan(); - if (!isPan && this.detectingScrolling) { - // If panning distance is not large enough and we're waiting to - // see whether we should use the sync scroll fallback or not, - // don't attempt scrolling. - return; - } - - let isScroll = this.scrollCallback(delta.scale(-1)); - - if (this.detectingScrolling) { - this.detectingScrolling = false; - // Stop async-pan-zooming if the user is panning the subframe. - if (isScroll) { - // We're going to drive synchronously scrolling an inner frame. - Services.obs.notifyObservers(docShell, 'cancel-default-pan-zoom', null); - } else { - // Let AsyncPanZoomController handle the scrolling gesture. - this.scrollCallback = null; - return; - } - } + this.scrollCallback(delta.scale(-1)); // If we've detected a pan gesture, cancel the active state of the // current target. @@ -392,13 +354,6 @@ const ContentPanning = { node = node.parentNode; } - if (ContentPanning._asyncPanZoomForViewportFrame && - nodeContent === content) { - // The parent context is asynchronously panning and zooming our - // root scrollable frame, so don't use our synchronous fallback. - return null; - } - if (nodeContent.scrollMaxX || nodeContent.scrollMaxY) { return nodeContent; } @@ -515,10 +470,6 @@ const ContentPanning = { this._domUtils.setContentState(elt, kStateActive); }, - get _asyncPanZoomForViewportFrame() { - return docShell.asyncPanZoomEnabled; - }, - _recvViewportChange: function(data) { let metrics = data.json; this._viewport = new Rect(metrics.x, metrics.y, @@ -637,7 +588,6 @@ const ContentPanning = { _finishPanning: function() { this._resetActive(); this.dragging = false; - this.detectingScrolling = false; delete this.primaryPointerId; this._activationTimer.cancel(); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index c376ff6ab2c9..86f4074cb0d7 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -88,10 +88,8 @@ NS_IMPL_ISUPPORTS1(ContentListener, nsIDOMEventListener) static const CSSSize kDefaultViewportSize(980, 480); -static const char CANCEL_DEFAULT_PAN_ZOOM[] = "cancel-default-pan-zoom"; static const char BROWSER_ZOOM_TO_RECT[] = "browser-zoom-to-rect"; static const char BEFORE_FIRST_PAINT[] = "before-first-paint"; -static const char DETECT_SCROLLABLE_SUBFRAME[] = "detect-scrollable-subframe"; static bool sCpowsEnabled = false; @@ -354,13 +352,7 @@ TabChild::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { - if (!strcmp(aTopic, CANCEL_DEFAULT_PAN_ZOOM)) { - nsCOMPtr docShell(do_QueryInterface(aSubject)); - nsCOMPtr tabChild(TabChild::GetFrom(docShell)); - if (tabChild == this) { - mRemoteFrame->CancelDefaultPanZoom(); - } - } else if (!strcmp(aTopic, BROWSER_ZOOM_TO_RECT)) { + if (!strcmp(aTopic, BROWSER_ZOOM_TO_RECT)) { nsCOMPtr docShell(do_QueryInterface(aSubject)); nsCOMPtr tabChild(TabChild::GetFrom(docShell)); if (tabChild == this) { @@ -409,12 +401,6 @@ TabChild::Observe(nsISupports *aSubject, HandlePossibleViewportChange(); } } - } else if (!strcmp(aTopic, DETECT_SCROLLABLE_SUBFRAME)) { - nsCOMPtr docShell(do_QueryInterface(aSubject)); - nsCOMPtr tabChild(TabChild::GetFrom(docShell)); - if (tabChild == this) { - mRemoteFrame->DetectScrollableSubframe(); - } } return NS_OK; @@ -2120,10 +2106,8 @@ TabChild::RecvDestroy() nsCOMPtr observerService = mozilla::services::GetObserverService(); - observerService->RemoveObserver(this, CANCEL_DEFAULT_PAN_ZOOM); observerService->RemoveObserver(this, BROWSER_ZOOM_TO_RECT); observerService->RemoveObserver(this, BEFORE_FIRST_PAINT); - observerService->RemoveObserver(this, DETECT_SCROLLABLE_SUBFRAME); const InfallibleTArray& idbActors = ManagedPIndexedDBChild(); @@ -2258,18 +2242,12 @@ TabChild::InitRenderingState() mozilla::services::GetObserverService(); if (observerService) { - observerService->AddObserver(this, - CANCEL_DEFAULT_PAN_ZOOM, - false); observerService->AddObserver(this, BROWSER_ZOOM_TO_RECT, false); observerService->AddObserver(this, BEFORE_FIRST_PAINT, false); - observerService->AddObserver(this, - DETECT_SCROLLABLE_SUBFRAME, - false); } // This state can't really change during the lifetime of the child. diff --git a/gfx/layers/composite/APZCTreeManager.cpp b/gfx/layers/composite/APZCTreeManager.cpp index 9cc3277481e9..56ba7d6942c4 100644 --- a/gfx/layers/composite/APZCTreeManager.cpp +++ b/gfx/layers/composite/APZCTreeManager.cpp @@ -467,24 +467,6 @@ APZCTreeManager::UpdateCompositionBounds(const ScrollableLayerGuid& aGuid, } } -void -APZCTreeManager::CancelDefaultPanZoom(const ScrollableLayerGuid& aGuid) -{ - nsRefPtr apzc = GetTargetAPZC(aGuid); - if (apzc) { - apzc->CancelDefaultPanZoom(); - } -} - -void -APZCTreeManager::DetectScrollableSubframe(const ScrollableLayerGuid& aGuid) -{ - nsRefPtr apzc = GetTargetAPZC(aGuid); - if (apzc) { - apzc->DetectScrollableSubframe(); - } -} - void APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid, const CSSRect& aRect) diff --git a/gfx/layers/composite/APZCTreeManager.h b/gfx/layers/composite/APZCTreeManager.h index 16033d5f73b6..a7a2e185da23 100644 --- a/gfx/layers/composite/APZCTreeManager.h +++ b/gfx/layers/composite/APZCTreeManager.h @@ -181,22 +181,6 @@ public: void UpdateCompositionBounds(const ScrollableLayerGuid& aGuid, const ScreenIntRect& aCompositionBounds); - /** - * We are scrolling a subframe, so disable our machinery until we hit - * a touch end or a new touch start. This prevents us from accidentally - * panning both the subframe and the parent frame. - * - * XXX/bug 775452: We should eventually be supporting async scrollable - * subframes. - */ - void CancelDefaultPanZoom(const ScrollableLayerGuid& aGuid); - - /** - * We have found a scrollable subframe, so we need to delay the scrolling - * gesture executed and let subframe do the scrolling first. - */ - void DetectScrollableSubframe(const ScrollableLayerGuid& aGuid); - /** * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom * in. The actual animation is done on the compositor thread after being set diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index a82b0b299a96..3ca882d186d7 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -279,9 +279,7 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId, mLastAsyncScrollOffset(0, 0), mCurrentAsyncScrollOffset(0, 0), mAsyncScrollTimeoutTask(nullptr), - mDisableNextTouchBatch(false), mHandlingTouchQueue(false), - mDelayPanning(false), mTreeManager(aTreeManager) { MOZ_COUNT_CTOR(AsyncPanZoomController); @@ -395,29 +393,12 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent) nsEventStatus rv = nsEventStatus_eIgnore; nsRefPtr listener = GetGestureEventListener(); - if (listener && !mDisableNextTouchBatch) { + if (listener) { rv = listener->HandleInputEvent(aEvent); if (rv == nsEventStatus_eConsumeNoDefault) return rv; } - if (mDelayPanning && aEvent.mInputType == MULTITOUCH_INPUT) { - const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); - if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_MOVE) { - // Let BrowserElementScrolling perform panning gesture first. - SetState(WAITING_LISTENERS); - mTouchQueue.AppendElement(multiTouchInput); - - if (!mTouchListenerTimeoutTask) { - mTouchListenerTimeoutTask = - NewRunnableMethod(this, &AsyncPanZoomController::TimeoutTouchListeners); - - PostDelayedTask(mTouchListenerTimeoutTask, gTouchListenerTimeout); - } - return nsEventStatus_eConsumeNoDefault; - } - } - switch (aEvent.mInputType) { case MULTITOUCH_INPUT: { const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); @@ -503,10 +484,6 @@ nsEventStatus AsyncPanZoomController::OnTouchStart(const MultiTouchInput& aEvent nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent) { APZC_LOG("%p got a touch-move in state %d\n", this, mState); - if (mDisableNextTouchBatch) { - return nsEventStatus_eIgnore; - } - switch (mState) { case FLING: case NOTHING: @@ -553,11 +530,6 @@ nsEventStatus AsyncPanZoomController::OnTouchMove(const MultiTouchInput& aEvent) nsEventStatus AsyncPanZoomController::OnTouchEnd(const MultiTouchInput& aEvent) { APZC_LOG("%p got a touch-end in state %d\n", this, mState); - if (mDisableNextTouchBatch) { - mDisableNextTouchBatch = false; - return nsEventStatus_eIgnore; - } - { ReentrantMonitorAutoEnter lock(mMonitor); SendAsyncScrollEvent(); @@ -1364,18 +1336,6 @@ void AsyncPanZoomController::UpdateCompositionBounds(const ScreenIntRect& aCompo } } -void AsyncPanZoomController::CancelDefaultPanZoom() { - mDisableNextTouchBatch = true; - nsRefPtr listener = GetGestureEventListener(); - if (listener) { - listener->CancelGesture(); - } -} - -void AsyncPanZoomController::DetectScrollableSubframe() { - mDelayPanning = true; -} - void AsyncPanZoomController::ZoomToRect(CSSRect aRect) { SetState(ANIMATING_ZOOM); @@ -1455,7 +1415,7 @@ void AsyncPanZoomController::ZoomToRect(CSSRect aRect) { } void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) { - if (!mFrameMetrics.mMayHaveTouchListeners && !mDelayPanning) { + if (!mFrameMetrics.mMayHaveTouchListeners) { mTouchQueue.Clear(); return; } @@ -1467,21 +1427,12 @@ void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) { if (mState == WAITING_LISTENERS) { if (!aPreventDefault) { - // Delayed scrolling gesture is pending at TOUCHING state. - if (mDelayPanning) { - SetState(TOUCHING); - } else { - SetState(NOTHING); - } + SetState(NOTHING); } mHandlingTouchQueue = true; while (!mTouchQueue.IsEmpty()) { - // we need to reset mDelayPanning before handling scrolling gesture. - if (!aPreventDefault && mTouchQueue[0].mType == MultiTouchInput::MULTITOUCH_MOVE) { - mDelayPanning = false; - } if (!aPreventDefault) { HandleInputEvent(mTouchQueue[0]); } diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h index 0937147f7382..4c1906a4c4cd 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.h +++ b/gfx/layers/ipc/AsyncPanZoomController.h @@ -111,22 +111,6 @@ public: */ void UpdateCompositionBounds(const ScreenIntRect& aCompositionBounds); - /** - * We are scrolling a subframe, so disable our machinery until we hit - * a touch end or a new touch start. This prevents us from accidentally - * panning both the subframe and the parent frame. - * - * XXX/bug 775452: We should eventually be supporting async scrollable - * subframes. - */ - void CancelDefaultPanZoom(); - - /** - * We have found a scrollable subframe, so we need to delay the scrolling - * gesture executed and let subframe do the scrolling first. - */ - void DetectScrollableSubframe(); - /** * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom * in. The actual animation is done on the compositor thread after being set @@ -615,22 +599,12 @@ private: // ensures the last mozbrowserasyncscroll event is always been fired. CancelableTask* mAsyncScrollTimeoutTask; - // Flag used to determine whether or not we should disable handling of the - // next batch of touch events. This is used for sync scrolling of subframes. - bool mDisableNextTouchBatch; - // Flag used to determine whether or not we should try to enter the // WAITING_LISTENERS state. This is used in the case that we are processing a // queued up event block. If set, this means that we are handling this queue // and we don't want to queue the events back up again. bool mHandlingTouchQueue; - // Flag used to determine whether or not we should try scrolling by - // BrowserElementScrolling first. If set, we delay delivering - // touchmove events to GestureListener until BrowserElementScrolling - // decides whether it wants to handle panning for this touch series. - bool mDelayPanning; - friend class Axis; /* The functions and members in this section are used to build a tree diff --git a/layout/ipc/PRenderFrame.ipdl b/layout/ipc/PRenderFrame.ipdl index f0f5ce6b2c88..cc6e57a24c30 100644 --- a/layout/ipc/PRenderFrame.ipdl +++ b/layout/ipc/PRenderFrame.ipdl @@ -45,9 +45,6 @@ parent: async NotifyCompositorTransaction(); - async CancelDefaultPanZoom(); - async DetectScrollableSubframe(); - async UpdateHitRegion(nsRegion aRegion); async __delete__(); diff --git a/layout/ipc/RenderFrameChild.cpp b/layout/ipc/RenderFrameChild.cpp index 5130fcc4f6ef..7e091338b05b 100644 --- a/layout/ipc/RenderFrameChild.cpp +++ b/layout/ipc/RenderFrameChild.cpp @@ -32,18 +32,6 @@ RenderFrameChild::Destroy() // WARNING: |this| is dead, hands off } -void -RenderFrameChild::CancelDefaultPanZoom() -{ - SendCancelDefaultPanZoom(); -} - -void -RenderFrameChild::DetectScrollableSubframe() -{ - SendDetectScrollableSubframe(); -} - PLayerTransactionChild* RenderFrameChild::AllocPLayerTransactionChild() { diff --git a/layout/ipc/RenderFrameChild.h b/layout/ipc/RenderFrameChild.h index 55cd1fd80a4c..aa63b32bfd8a 100644 --- a/layout/ipc/RenderFrameChild.h +++ b/layout/ipc/RenderFrameChild.h @@ -19,9 +19,6 @@ public: RenderFrameChild() {} virtual ~RenderFrameChild() {} - void CancelDefaultPanZoom(); - void DetectScrollableSubframe(); - void Destroy(); protected: diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 151245d1c1fc..06e9048697d9 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -875,24 +875,6 @@ RenderFrameParent::RecvNotifyCompositorTransaction() return true; } -bool -RenderFrameParent::RecvCancelDefaultPanZoom() -{ - if (GetApzcTreeManager()) { - GetApzcTreeManager()->CancelDefaultPanZoom(ScrollableLayerGuid(mLayersId)); - } - return true; -} - -bool -RenderFrameParent::RecvDetectScrollableSubframe() -{ - if (GetApzcTreeManager()) { - GetApzcTreeManager()->DetectScrollableSubframe(ScrollableLayerGuid(mLayersId)); - } - return true; -} - bool RenderFrameParent::RecvUpdateHitRegion(const nsRegion& aRegion) { diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index fc26f4931e9e..47be692fad59 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -117,9 +117,6 @@ protected: virtual bool RecvNotifyCompositorTransaction() MOZ_OVERRIDE; - virtual bool RecvCancelDefaultPanZoom() MOZ_OVERRIDE; - virtual bool RecvDetectScrollableSubframe() MOZ_OVERRIDE; - virtual bool RecvUpdateHitRegion(const nsRegion& aRegion) MOZ_OVERRIDE; virtual PLayerTransactionParent* AllocPLayerTransactionParent() MOZ_OVERRIDE; From 7be5760ac19396da6065a6c77bcc657f6383f027 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 30 Oct 2013 19:48:46 -0200 Subject: [PATCH 569/795] Backed out changeset 3e4f6dd35a2b (bug 932763) --- dom/contacts/ContactManager.js | 18 +++++++++--------- dom/contacts/tests/test_contacts_basics.html | 16 ---------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/dom/contacts/ContactManager.js b/dom/contacts/ContactManager.js index 5cc196d3ce6b..5d64d1e51e85 100644 --- a/dom/contacts/ContactManager.js +++ b/dom/contacts/ContactManager.js @@ -176,18 +176,18 @@ function validateArrayField(data, createCb) { } }; - if (data === null || data === undefined) { - return undefined; - } - - data = Array.isArray(data) ? data : [data]; - let filtered = []; - for (let i = 0, n = data.length; i < n; ++i) { - if (data[i]) { + if (data) { + data = Array.isArray(data) ? data : [data]; + let filtered = []; + for (let i = 0, n = data.length; i < n; ++i) { filtered.push(createCb(data[i])); } + if (filtered.length === 0) { + return undefined; + } + return new Proxy(filtered, ArrayPropertyHandler); } - return new Proxy(filtered, ArrayPropertyHandler); + return undefined; } // We need this to create a copy of the mozContact object in ContactManager.save diff --git a/dom/contacts/tests/test_contacts_basics.html b/dom/contacts/tests/test_contacts_basics.html index 5e19a7b4b500..04fca7806cc5 100644 --- a/dom/contacts/tests/test_contacts_basics.html +++ b/dom/contacts/tests/test_contacts_basics.html @@ -1668,22 +1668,6 @@ var steps = [ } next(); }, - function() { - ok(true, "Setting array properties to an empty array should work"); - var c = new mozContact(); - function testArrayProp(prop) { - is(c[prop], null, "property is initially null"); - c[prop] = []; - ok(Array.isArray(c[prop]), "property is an array after setting"); - is(c[prop].length, 0, "property has length 0 after setting"); - } - testArrayProp("email"); - testArrayProp("adr"); - testArrayProp("tel"); - testArrayProp("impp"); - testArrayProp("url"); - next(); - }, function () { ok(true, "all done!\n"); clearTemps(); From 8527041483b5658029b5d1df6f9dbacd97c32291 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 15:10:24 -0700 Subject: [PATCH 570/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/9ff5a808a765 Author: Adam Hyland Desc: Bug 927588 - [clock] Timer - Remove seconds from timer r=jugglinmike --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 80ca1c9b6f12..835a8e262367 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "947ead64edf6edd28f4d254546097d919fb12cff", + "revision": "9ff5a808a765e3b1f151a1093e1bb61f67227916", "repo_path": "/integration/gaia-central" } From 6641d2bb236cb708e8d43a94cb857ebfb792e5f5 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 15:45:24 -0700 Subject: [PATCH 571/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/664f22134229 Author: Eric O'Connor Desc: 927583 - [clock] Stop watch and Timer - Use fixed width font to avoid shifting r=jugglinmike --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 835a8e262367..c6deca7e192f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "9ff5a808a765e3b1f151a1093e1bb61f67227916", + "revision": "664f2213422984fda80c771890848eeb087b7962", "repo_path": "/integration/gaia-central" } From aad2637450e4fc52b2262b2ce7d13e6127fe98d0 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 16:10:24 -0700 Subject: [PATCH 572/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/9c7d1d03141c Author: James Lal Desc: Merge pull request #13241 from Rik/verbose-travis-932917 Bug 932917 - Less verbose travis bot on IRC ======== https://hg.mozilla.org/integration/gaia-central/rev/c5d38d785183 Author: Anthony Ricaud Desc: Bug 932917 - Less verbose travis bot on IRC --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index c6deca7e192f..fd2b766faf92 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "664f2213422984fda80c771890848eeb087b7962", + "revision": "9c7d1d03141cc727438b2c5c1695259d4bbf11ed", "repo_path": "/integration/gaia-central" } From 1bdb4601f2ce23f9667f66d234977a7766b94a95 Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 16:20:24 -0700 Subject: [PATCH 573/795] Bumping gaia.json for 1 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/2cf15a320486 Author: Eric O'Connor Desc: Bug 927581 - [clock] Stop watch - Add 1/100th of a second time intervals r=jugglinmike --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index fd2b766faf92..aff2de225c2c 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "9c7d1d03141cc727438b2c5c1695259d4bbf11ed", + "revision": "2cf15a32048656b8b71c56ed5c5468c9644caf17", "repo_path": "/integration/gaia-central" } From 841a7458ad42e1c72d5ffa13e4c24678960b3fd7 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Wed, 30 Oct 2013 10:47:05 -0700 Subject: [PATCH 574/795] Bug 932878 - Allow zero-length blobs. r=khuey. --- dom/ipc/Blob.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index 70274948f919..90ecf6ab40a4 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -1233,7 +1233,6 @@ Blob::SetMysteryBlobInfo(const nsString& aName, MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mBlob); MOZ_ASSERT(mRemoteBlob); - MOZ_ASSERT(aLength); MOZ_ASSERT(aLastModifiedDate != UINT64_MAX); ToConcreteBlob(mBlob)->SetLazyData(aName, aContentType, @@ -1252,7 +1251,6 @@ Blob::SetMysteryBlobInfo(const nsString& aContentType, MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mBlob); MOZ_ASSERT(mRemoteBlob); - MOZ_ASSERT(aLength); nsString voidString; voidString.SetIsVoid(true); From 5cb5fbcbed32ac7b6858e2d98000abc4aa9eb301 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Wed, 30 Oct 2013 10:56:55 -0700 Subject: [PATCH 575/795] Bug 932867 - FrameWorker should remove the iframe not the browser. r=smaug CLOSED TREE --- toolkit/components/social/FrameWorker.jsm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toolkit/components/social/FrameWorker.jsm b/toolkit/components/social/FrameWorker.jsm index 5e8e01767a3a..014dc51fea8f 100644 --- a/toolkit/components/social/FrameWorker.jsm +++ b/toolkit/components/social/FrameWorker.jsm @@ -128,7 +128,8 @@ WorkerHandle.prototype = { this._worker.ports.clear(); this._worker.ports = null; this._worker.browserPromise.then(browser => { - browser.parentNode.removeChild(browser); + let iframe = browser.ownerDocument.defaultView.frameElement; + iframe.parentNode.removeChild(iframe); }); // wipe things out just incase other reference have snuck out somehow... this._worker.browserPromise = null; From 7c0017a83ed64f5636237b66935c00dff8bbbb7d Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Wed, 30 Oct 2013 15:58:25 -0400 Subject: [PATCH 576/795] Bug 932525 - Do APZC hit testing using the layer's screen coordinates rather than layer coordinates. r=kats --- gfx/layers/composite/APZCTreeManager.cpp | 44 ++-- gfx/layers/ipc/AsyncPanZoomController.h | 13 +- .../gtest/TestAsyncPanZoomController.cpp | 219 ++++++++++++------ 3 files changed, 181 insertions(+), 95 deletions(-) diff --git a/gfx/layers/composite/APZCTreeManager.cpp b/gfx/layers/composite/APZCTreeManager.cpp index 56ba7d6942c4..974c16e35de7 100644 --- a/gfx/layers/composite/APZCTreeManager.cpp +++ b/gfx/layers/composite/APZCTreeManager.cpp @@ -141,7 +141,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor, apzc->NotifyLayersUpdated(container->GetFrameMetrics(), aIsFirstPaint && (aLayersId == aFirstPaintLayersId)); - LayerRect visible = ScreenRect(container->GetFrameMetrics().mCompositionBounds) * ScreenToLayerScale(1.0); + ScreenRect visible(container->GetFrameMetrics().mCompositionBounds); apzc->SetLayerHitTestData(visible, aTransform, aLayer->GetTransform()); APZC_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y, visible.width, visible.height, @@ -629,30 +629,42 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPanZoomController* aApzc, const gfxPoint& a // comments explain what values are stored in the variables at these two levels. All the comments // use standard matrix notation where the leftmost matrix in a multiplication is applied first. - // ancestorUntransform is OC.Inverse() * NC.Inverse() * MC.Inverse() at recursion level for L, - // and RC.Inverse() * QC.Inverse() at recursion level for P. + // ancestorUntransform takes points from aApzc's parent APZC's screen coordinates + // to aApzc's screen coordinates. + // It is OC.Inverse() * NC.Inverse() * MC.Inverse() at recursion level for L, + // and RC.Inverse() * QC.Inverse() at recursion level for P. gfx3DMatrix ancestorUntransform = aApzc->GetAncestorTransform().Inverse(); - // asyncUntransform is LA.Inverse() at recursion level for L, - // and PA.Inverse() at recursion level for P. - gfx3DMatrix asyncUntransform = gfx3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse(); - // untransformSinceLastApzc is OC.Inverse() * NC.Inverse() * MC.Inverse() * LA.Inverse() * LC.Inverse() at L, - // and RC.Inverse() * QC.Inverse() * PA.Inverse() * PC.Inverse() at P. - gfx3DMatrix untransformSinceLastApzc = ancestorUntransform * asyncUntransform * aApzc->GetCSSTransform().Inverse(); - // untransformed is the user input in L's layer space at L, - // and in P's layer space at P. - gfxPoint untransformed = untransformSinceLastApzc.ProjectPoint(aHitTestPoint); - APZC_LOG("Untransformed %f %f to %f %f for APZC %p\n", aHitTestPoint.x, aHitTestPoint.y, untransformed.x, untransformed.y, aApzc); + + // Hit testing for this layer is performed in aApzc's screen coordinates. + gfxPoint hitTestPointForThisLayer = ancestorUntransform.ProjectPoint(aHitTestPoint); + APZC_LOG("Untransformed %f %f to screen coordinates %f %f for hit-testing APZC %p\n", + aHitTestPoint.x, aHitTestPoint.y, + hitTestPointForThisLayer.x, hitTestPointForThisLayer.y, aApzc); + + // myUntransform takes points from aApzc's screen coordinates + // to aApzc's layer coordinates (which are aApzc's children's screen coordinates). + // It is LA.Inverse() * LC.Inverse() at L + // and PA.Inverse() * PC.Inverse() at P. + gfx3DMatrix myUntransform = gfx3DMatrix(aApzc->GetCurrentAsyncTransform()).Inverse() + * aApzc->GetCSSTransform().Inverse(); + + // Hit testing for child layers is performed in aApzc's layer coordinates. + gfxPoint hitTestPointForChildLayers = myUntransform.ProjectPoint(hitTestPointForThisLayer); + APZC_LOG("Untransformed %f %f to layer coordinates %f %f for APZC %p\n", + aHitTestPoint.x, aHitTestPoint.y, + hitTestPointForChildLayers.x, hitTestPointForChildLayers.y, aApzc); // This walks the tree in depth-first, reverse order, so that it encounters // APZCs front-to-back on the screen. for (AsyncPanZoomController* child = aApzc->GetLastChild(); child; child = child->GetPrevSibling()) { - AsyncPanZoomController* match = GetAPZCAtPoint(child, untransformed); + AsyncPanZoomController* match = GetAPZCAtPoint(child, hitTestPointForChildLayers); if (match) { return match; } } - if (aApzc->VisibleRegionContains(LayerPoint(untransformed.x, untransformed.y))) { - APZC_LOG("Successfully matched untransformed point %f %f to visible region for APZC %p\n", untransformed.x, untransformed.y, aApzc); + if (aApzc->VisibleRegionContains(ScreenPoint(hitTestPointForThisLayer.x, hitTestPointForThisLayer.y))) { + APZC_LOG("Successfully matched untransformed point %f %f to visible region for APZC %p\n", + hitTestPointForThisLayer.x, hitTestPointForThisLayer.y, aApzc); return aApzc; } return nullptr; diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h index 4c1906a4c4cd..82c6be9b25d6 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.h +++ b/gfx/layers/ipc/AsyncPanZoomController.h @@ -655,7 +655,7 @@ private: * hit-testing to see which APZC instance should handle touch events. */ public: - void SetLayerHitTestData(const LayerRect& aRect, const gfx3DMatrix& aTransformToLayer, + void SetLayerHitTestData(const ScreenRect& aRect, const gfx3DMatrix& aTransformToLayer, const gfx3DMatrix& aTransformForLayer) { mVisibleRect = aRect; mAncestorTransform = aTransformToLayer; @@ -670,16 +670,15 @@ public: return mCSSTransform; } - bool VisibleRegionContains(const LayerPoint& aPoint) const { + bool VisibleRegionContains(const ScreenPoint& aPoint) const { return mVisibleRect.Contains(aPoint); } private: - /* This is the viewport of the layer that this APZC corresponds to, in - * layer pixels. It position here does not account for any transformations - * applied to any layers, whether they are CSS transforms or async - * transforms. */ - LayerRect mVisibleRect; + /* This is the visible region of the layer that this APZC corresponds to, in + * that layer's screen pixels (the same coordinate system in which this APZC + * receives events in ReceiveInputEvent()). */ + ScreenRect mVisibleRect; /* This is the cumulative CSS transform for all the layers between the parent * APZC and this one (not inclusive) */ gfx3DMatrix mAncestorTransform; diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index e1ec6477760a..6283afa66386 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -433,19 +433,17 @@ TEST(AsyncPanZoomController, OverScrollPanning) { EXPECT_EQ(pointOut, ScreenPoint(0, 90)); } +// Layer tree for HitTesting1 static already_AddRefed -CreateTestLayerTree(nsRefPtr& aLayerManager, nsTArray >& aLayers) { - const char* layerTreeSyntax = "c(ttccc(c(c)))"; - // LayerID 0 12345 6 7 +CreateTestLayerTree1(nsRefPtr& aLayerManager, nsTArray >& aLayers) { + const char* layerTreeSyntax = "c(ttcc)"; + // LayerID 0 1234 nsIntRegion layerVisibleRegion[] = { nsIntRegion(nsIntRect(0,0,100,100)), nsIntRegion(nsIntRect(0,0,100,100)), nsIntRegion(nsIntRect(10,10,20,20)), nsIntRegion(nsIntRect(10,10,20,20)), nsIntRegion(nsIntRect(5,5,20,20)), - nsIntRegion(nsIntRect(10,10,40,40)), - nsIntRegion(nsIntRect(10,10,40,40)), - nsIntRegion(nsIntRect(10,10,40,40)), }; gfx3DMatrix transforms[] = { gfx3DMatrix(), @@ -453,15 +451,35 @@ CreateTestLayerTree(nsRefPtr& aLayerManager, nsTArray +CreateTestLayerTree2(nsRefPtr& aLayerManager, nsTArray >& aLayers) { + const char* layerTreeSyntax = "c(cc(c))"; + // LayerID 0 12 3 + nsIntRegion layerVisibleRegion[] = { + nsIntRegion(nsIntRect(0,0,100,100)), + nsIntRegion(nsIntRect(10,10,40,40)), + nsIntRegion(nsIntRect(10,60,40,40)), + nsIntRegion(nsIntRect(10,60,40,40)), + }; + gfx3DMatrix transforms[] = { + gfx3DMatrix(), + gfx3DMatrix(), + gfx3DMatrix(), + gfx3DMatrix(), }; return CreateLayerTree(layerTreeSyntax, layerVisibleRegion, transforms, aLayerManager, aLayers); } static void -SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId, MockContentController* mcc) +SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId, + // The scrollable rect is only used in HitTesting2, + // HitTesting1 doesn't care about it. + CSSRect aScrollableRect = CSSRect(-1, -1, -1, -1)) { ContainerLayer* container = aLayer->AsContainerLayer(); FrameMetrics metrics; @@ -469,8 +487,8 @@ SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId, MockCon nsIntRect layerBound = aLayer->GetVisibleRegion().GetBounds(); metrics.mCompositionBounds = ScreenIntRect(layerBound.x, layerBound.y, layerBound.width, layerBound.height); - metrics.mViewport = CSSRect(layerBound.x, layerBound.y, - layerBound.width, layerBound.height); + metrics.mScrollableRect = aScrollableRect; + metrics.mScrollOffset = CSSPoint(0, 0); container->SetFrameMetrics(metrics); } @@ -499,10 +517,11 @@ GetTargetAPZC(APZCTreeManager* manager, const ScreenPoint& aPoint, return hit.forget(); } -TEST(APZCTreeManager, GetAPZCAtPoint) { +// A simple hit testing test that doesn't involve any transforms on layers. +TEST(APZCTreeManager, HitTesting1) { nsTArray > layers; nsRefPtr lm; - nsRefPtr root = CreateTestLayerTree(lm, layers); + nsRefPtr root = CreateTestLayerTree1(lm, layers); TimeStamp testStartTime = TimeStamp::Now(); AsyncPanZoomController::SetFrameTime(testStartTime); @@ -521,8 +540,8 @@ TEST(APZCTreeManager, GetAPZCAtPoint) { EXPECT_EQ(gfx3DMatrix(), transformToScreen); // Now we have a root APZC that will match the page - SetScrollableFrameMetrics(root, FrameMetrics::ROOT_SCROLL_ID, mcc); - manager->UpdatePanZoomControllerTree(nullptr, root, 0, false); + SetScrollableFrameMetrics(root, FrameMetrics::ROOT_SCROLL_ID); + manager->UpdatePanZoomControllerTree(nullptr, root, false, 0); hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToScreen); EXPECT_EQ(root->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); // expect hit point at LayerIntPoint(15, 15) @@ -530,8 +549,8 @@ TEST(APZCTreeManager, GetAPZCAtPoint) { EXPECT_EQ(gfxPoint(15, 15), transformToScreen.Transform(gfxPoint(15, 15))); // Now we have a sub APZC with a better fit - SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID, mcc); - manager->UpdatePanZoomControllerTree(nullptr, root, 0, false); + SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID); + manager->UpdatePanZoomControllerTree(nullptr, root, false, 0); EXPECT_NE(root->AsContainerLayer()->GetAsyncPanZoomController(), layers[3]->AsContainerLayer()->GetAsyncPanZoomController()); hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToScreen); EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); @@ -542,8 +561,8 @@ TEST(APZCTreeManager, GetAPZCAtPoint) { // Now test hit testing when we have two scrollable layers hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToScreen); EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); - SetScrollableFrameMetrics(layers[4], FrameMetrics::START_SCROLL_ID + 1, mcc); - manager->UpdatePanZoomControllerTree(nullptr, root, 0, false); + SetScrollableFrameMetrics(layers[4], FrameMetrics::START_SCROLL_ID + 1); + manager->UpdatePanZoomControllerTree(nullptr, root, false, 0); hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToScreen); EXPECT_EQ(layers[4]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); // expect hit point at LayerIntPoint(15, 15) @@ -567,59 +586,115 @@ TEST(APZCTreeManager, GetAPZCAtPoint) { EXPECT_EQ(gfx3DMatrix(), transformToApzc); EXPECT_EQ(gfx3DMatrix(), transformToScreen); - // Test layer transform - gfx3DMatrix transform; - transform.ScalePost(0.1, 0.1, 1); - root->SetBaseTransform(transform); - manager->UpdatePanZoomControllerTree(nullptr, root, 0, false); - hit = GetTargetAPZC(manager, ScreenPoint(50, 50), transformToApzc, transformToScreen); // This point is now outside the root layer - EXPECT_EQ(nullAPZC, hit.get()); - EXPECT_EQ(gfx3DMatrix(), transformToApzc); - EXPECT_EQ(gfx3DMatrix(), transformToScreen); - - // This hit test will hit both layers[3] and layers[4]; layers[4] is later in the tree so - // it is a better match - hit = GetTargetAPZC(manager, ScreenPoint(2, 2), transformToApzc, transformToScreen); - EXPECT_EQ(layers[4]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); - // expect hit point at LayerPoint(20, 20) - EXPECT_EQ(gfxPoint(20, 20), NudgeToIntegers(transformToApzc.Transform(gfxPoint(2, 2)))); - EXPECT_EQ(gfxPoint(2, 2), NudgeToIntegers(transformToScreen.Transform(gfxPoint(20, 20)))); - - // Scale layer[4] outside the range - layers[4]->SetBaseTransform(transform); - // layer 4 effective visible screenrect: (0.05, 0.05, 0.2, 0.2) - // Does not contain (2, 2) - manager->UpdatePanZoomControllerTree(nullptr, root, 0, false); - hit = GetTargetAPZC(manager, ScreenPoint(2, 2), transformToApzc, transformToScreen); - EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); - // expect hit point at LayerPoint(20, 20) - EXPECT_EQ(gfxPoint(20, 20), NudgeToIntegers(transformToApzc.Transform(gfxPoint(2, 2)))); - EXPECT_EQ(gfxPoint(2, 2), NudgeToIntegers(transformToScreen.Transform(gfxPoint(20, 20)))); - - // Transformation chain to layer 7 - SetScrollableFrameMetrics(layers[7], FrameMetrics::START_SCROLL_ID + 2, mcc); - - gfx3DMatrix translateTransform; - translateTransform.Translate(gfxPoint3D(10, 10, 0)); - layers[5]->SetBaseTransform(translateTransform); - - gfx3DMatrix translateTransform2; - translateTransform2.Translate(gfxPoint3D(-20, 0, 0)); - layers[6]->SetBaseTransform(translateTransform2); - - gfx3DMatrix translateTransform3; - translateTransform3.ScalePost(1,15,1); - layers[7]->SetBaseTransform(translateTransform3); - - manager->UpdatePanZoomControllerTree(nullptr, root, 0, false); - // layer 7 effective visible screenrect (0,16,4,60) but clipped by parent layers - hit = GetTargetAPZC(manager, ScreenPoint(1, 45), transformToApzc, transformToScreen); - EXPECT_EQ(layers[7]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get()); - // expect hit point at LayerPoint(20, 440), which is CSSPoint(20, 29) - EXPECT_EQ(gfxPoint(20, 440), NudgeToIntegers(transformToApzc.Transform(gfxPoint(1, 45)))); - EXPECT_EQ(gfxPoint(1, 45), NudgeToIntegers(transformToScreen.Transform(gfxPoint(20, 440)))); - manager->ClearTree(); } +// A more involved hit testing test that involves css and async transforms. +TEST(APZCTreeManager, HitTesting2) { + nsTArray > layers; + nsRefPtr lm; + nsRefPtr root = CreateTestLayerTree2(lm, layers); + TimeStamp testStartTime = TimeStamp::Now(); + AsyncPanZoomController::SetFrameTime(testStartTime); + nsRefPtr mcc = new MockContentController(); + ScopedLayerTreeRegistration controller(0, root, mcc); + + nsRefPtr manager = new TestAPZCTreeManager(); + nsRefPtr hit; + gfx3DMatrix transformToApzc; + gfx3DMatrix transformToScreen; + + // Set a CSS transform on one of the layers. + gfx3DMatrix transform; + transform.ScalePost(2, 1, 1); + layers[2]->SetBaseTransform(transform); + + // Make some other layers scrollable. + SetScrollableFrameMetrics(root, FrameMetrics::ROOT_SCROLL_ID, CSSRect(0, 0, 200, 200)); + SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID, CSSRect(0, 0, 80, 80)); + SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 80, 80)); + + manager->UpdatePanZoomControllerTree(nullptr, root, false, 0); + + // At this point, the following holds (all coordinates in screen pixels): + // layers[0] has content from (0,0)-(200,200), clipped by composition bounds (0,0)-(100,100) + // layers[1] has content from (10,10)-(90,90), clipped by composition bounds (10,10)-(50,50) + // layers[2] has content from (20,60)-(100,100). no clipping as it's not a scrollable layer + // layers[3] has content from (20,60)-(180,140), clipped by composition bounds (20,60)-(100,100) + + AsyncPanZoomController* apzcroot = root->AsContainerLayer()->GetAsyncPanZoomController(); + AsyncPanZoomController* apzc1 = layers[1]->AsContainerLayer()->GetAsyncPanZoomController(); + AsyncPanZoomController* apzc3 = layers[3]->AsContainerLayer()->GetAsyncPanZoomController(); + + // Hit an area that's clearly on the root layer but not any of the child layers. + hit = GetTargetAPZC(manager, ScreenPoint(75, 25), transformToApzc, transformToScreen); + EXPECT_EQ(apzcroot, hit.get()); + EXPECT_EQ(gfxPoint(75, 25), transformToApzc.Transform(gfxPoint(75, 25))); + EXPECT_EQ(gfxPoint(75, 25), transformToScreen.Transform(gfxPoint(75, 25))); + + // Hit an area on the root that would be on layers[3] if layers[2] + // weren't transformed. + // Note that if layers[2] were scrollable, then this would hit layers[2] + // because its composition bounds would be at (10,60)-(50,100) (and the + // scale-only transform that we set on layers[2] would be invalid because + // it would place the layer into overscroll, as its composition bounds + // start at x=10 but its content at x=20). + hit = GetTargetAPZC(manager, ScreenPoint(15, 75), transformToApzc, transformToScreen); + EXPECT_EQ(apzcroot, hit.get()); + EXPECT_EQ(gfxPoint(15, 75), transformToApzc.Transform(gfxPoint(15, 75))); + EXPECT_EQ(gfxPoint(15, 75), transformToScreen.Transform(gfxPoint(15, 75))); + + // Hit an area on layers[1]. + hit = GetTargetAPZC(manager, ScreenPoint(25, 25), transformToApzc, transformToScreen); + EXPECT_EQ(apzc1, hit.get()); + EXPECT_EQ(gfxPoint(25, 25), transformToApzc.Transform(gfxPoint(25, 25))); + EXPECT_EQ(gfxPoint(25, 25), transformToScreen.Transform(gfxPoint(25, 25))); + + // Hit an area on layers[3]. + hit = GetTargetAPZC(manager, ScreenPoint(25, 75), transformToApzc, transformToScreen); + EXPECT_EQ(apzc3, hit.get()); + // transformToApzc should unapply layers[2]'s transform + EXPECT_EQ(gfxPoint(12.5, 75), transformToApzc.Transform(gfxPoint(25, 75))); + // and transformToScreen should reapply it + EXPECT_EQ(gfxPoint(25, 75), transformToScreen.Transform(gfxPoint(12.5, 75))); + + // Hit an area on layers[3] that would be on the root if layers[2] + // weren't transformed. + hit = GetTargetAPZC(manager, ScreenPoint(75, 75), transformToApzc, transformToScreen); + EXPECT_EQ(apzc3, hit.get()); + // transformToApzc should unapply layers[2]'s transform + EXPECT_EQ(gfxPoint(37.5, 75), transformToApzc.Transform(gfxPoint(75, 75))); + // and transformToScreen should reapply it + EXPECT_EQ(gfxPoint(75, 75), transformToScreen.Transform(gfxPoint(37.5, 75))); + + // Pan the root layer upward by 50 pixels. + // This causes layers[1] to scroll out of view, and an async transform + // of -50 to be set on the root layer. + int time = 0; + // Silence GMock warnings about "uninteresting mock function calls". + EXPECT_CALL(*mcc, PostDelayedTask(_,_)).Times(1); + EXPECT_CALL(*mcc, SendAsyncScrollDOMEvent(_,_,_)).Times(2); + EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(1); + ApzcPan(apzcroot, time, 100, 50); + + // Hit where layers[3] used to be. It should now hit the root. + hit = GetTargetAPZC(manager, ScreenPoint(75, 75), transformToApzc, transformToScreen); + EXPECT_EQ(apzcroot, hit.get()); + // transformToApzc doesn't unapply the root's own async transform + EXPECT_EQ(gfxPoint(75, 75), transformToApzc.Transform(gfxPoint(75, 75))); + // but transformToScreen does + EXPECT_EQ(gfxPoint(75, 125), transformToScreen.Transform(gfxPoint(75, 75))); + + // Hit where layers[1] used to be and where layers[3] should now be. + hit = GetTargetAPZC(manager, ScreenPoint(25, 25), transformToApzc, transformToScreen); + EXPECT_EQ(apzc3, hit.get()); + // transformToApzc unapplies both layers[2]'s css transform and the root's + // async trasnform + EXPECT_EQ(gfxPoint(12.5, 75), transformToApzc.Transform(gfxPoint(25, 25))); + // transformToScreen reapplies the css transform only (since Gecko doesn't + // know about async transforms) + EXPECT_EQ(gfxPoint(25, 75), transformToScreen.Transform(gfxPoint(12.5, 75))); + + manager->ClearTree(); +} \ No newline at end of file From ffe224c10174d3703f8ad086762a9acf379bc4dc Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Wed, 30 Oct 2013 16:54:50 -0500 Subject: [PATCH 577/795] Backed out changeset 0191d92d4f42 (bug 918273) because it conflicts with bug 906877 which just landed on b2g. r=RyanVM, CLOSED TREE --- gfx/layers/ipc/AsyncPanZoomController.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 9b3ca59f1337..a82b0b299a96 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -369,9 +369,6 @@ nsEventStatus AsyncPanZoomController::ReceiveInputEvent(const InputData& aEvent) (mState == NOTHING || mState == TOUCHING || IsPanningState(mState))) { const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_START) { - // Wait for a set timeout or preventDefault info via ContentReceivedTouch - // before interacting with content. In the mean time we queue up events - // for processing later. SetState(WAITING_LISTENERS); } } @@ -407,7 +404,7 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent) if (mDelayPanning && aEvent.mInputType == MULTITOUCH_INPUT) { const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_MOVE) { - // Wait for a set timeout or preventDefault info via ContentReceivedTouch. + // Let BrowserElementScrolling perform panning gesture first. SetState(WAITING_LISTENERS); mTouchQueue.AppendElement(multiTouchInput); @@ -1369,9 +1366,6 @@ void AsyncPanZoomController::UpdateCompositionBounds(const ScreenIntRect& aCompo void AsyncPanZoomController::CancelDefaultPanZoom() { mDisableNextTouchBatch = true; - mDelayPanning = false; - mTouchQueue.Clear(); - SetState(NOTHING); nsRefPtr listener = GetGestureEventListener(); if (listener) { listener->CancelGesture(); @@ -1472,12 +1466,7 @@ void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) { } if (mState == WAITING_LISTENERS) { - if (aPreventDefault) { - // We're being told that this touch block will be consumed by content, - // reset state and block processing until the next touch block. - CancelDefaultPanZoom(); - return; - } else { + if (!aPreventDefault) { // Delayed scrolling gesture is pending at TOUCHING state. if (mDelayPanning) { SetState(TOUCHING); From c2194944f94b1bba60418c5227bb6cb2f31230b6 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Wed, 30 Oct 2013 16:17:36 -0700 Subject: [PATCH 578/795] Bug 933010 - AsyncErrorReporter takes bool isChromeError. r=bz --- dom/base/nsJSEnvironment.cpp | 10 +++++----- dom/base/nsJSEnvironment.h | 2 +- dom/promise/Promise.cpp | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index b2576ffe4fd1..bcff242366f1 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -337,7 +337,7 @@ namespace dom { AsyncErrorReporter::AsyncErrorReporter(JSRuntime* aRuntime, JSErrorReport* aErrorReport, const char* aFallbackMessage, - nsIPrincipal* aGlobalPrincipal, + bool aIsChromeError, nsPIDOMWindow* aWindow) : mSourceLine(static_cast(aErrorReport->uclinebuf)) , mLineNumber(aErrorReport->lineno) @@ -365,9 +365,8 @@ AsyncErrorReporter::AsyncErrorReporter(JSRuntime* aRuntime, mErrorMsg.AssignWithConversion(aFallbackMessage); } - mCategory = nsContentUtils::IsSystemPrincipal(aGlobalPrincipal) ? - NS_LITERAL_CSTRING("chrome javascript") : - NS_LITERAL_CSTRING("content javascript"); + mCategory = aIsChromeError ? NS_LITERAL_CSTRING("chrome javascript") : + NS_LITERAL_CSTRING("content javascript"); mInnerWindowID = 0; if (aWindow && aWindow->IsOuterWindow()) { @@ -421,7 +420,8 @@ public: bool aDispatchEvent) // Pass an empty category, then compute ours : AsyncErrorReporter(aRuntime, aErrorReport, aFallbackMessage, - aGlobalPrincipal, aWindow) + nsContentUtils::IsSystemPrincipal(aGlobalPrincipal), + aWindow) , mScriptGlobal(aScriptGlobal) , mOriginPrincipal(aScriptOriginPrincipal) , mDispatchEvent(aDispatchEvent) diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h index fcf12c075a5e..80f03077f8b2 100644 --- a/dom/base/nsJSEnvironment.h +++ b/dom/base/nsJSEnvironment.h @@ -208,7 +208,7 @@ public: AsyncErrorReporter(JSRuntime* aRuntime, JSErrorReport* aErrorReport, const char* aFallbackMessage, - nsIPrincipal* aGlobalPrincipal, // To determine category + bool aIsChromeError, // To determine category nsPIDOMWindow* aWindow); NS_IMETHOD Run() diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp index 0af9a6202efa..49879e478ff5 100644 --- a/dom/promise/Promise.cpp +++ b/dom/promise/Promise.cpp @@ -445,12 +445,13 @@ Promise::MaybeReportRejected() nsCOMPtr win = do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(&mResult.toObject())); + nsIPrincipal* principal = nsContentUtils::GetObjectPrincipal(&mResult.toObject()); // Now post an event to do the real reporting async NS_DispatchToCurrentThread( new AsyncErrorReporter(JS_GetObjectRuntime(&mResult.toObject()), report, nullptr, - nsContentUtils::GetObjectPrincipal(&mResult.toObject()), + nsContentUtils::IsSystemPrincipal(principal), win)); } From c90e808628707bddebed519cf34d64c4cf887b52 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 30 Oct 2013 17:15:50 -0500 Subject: [PATCH 579/795] Bug 933025 - Only reload apps when connected. r=ochameau --- browser/devtools/app-manager/content/projects.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/browser/devtools/app-manager/content/projects.js b/browser/devtools/app-manager/content/projects.js index 1ccbc4caded7..a2bcae5a67c5 100644 --- a/browser/devtools/app-manager/content/projects.js +++ b/browser/devtools/app-manager/content/projects.js @@ -72,6 +72,8 @@ let UI = { } }, + get connected() { return !!this.listTabsResponse; }, + _selectFolder: function() { let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); fp.init(window, Utils.l10n("project.filePickerTitle"), Ci.nsIFilePicker.modeGetFolder); @@ -172,14 +174,16 @@ let UI = { .then(() => { // Install the app to the device if we are connected, // and there is no error - if (project.errorsCount == 0 && this.listTabsResponse) { + if (project.errorsCount == 0 && this.connected) { return this.install(project); } }) .then(() => { button.disabled = false; // Finally try to reload the app if it is already opened - this.reload(project); + if (this.connected) { + this.reload(project); + } }, (res) => { button.disabled = false; From 627a599f2d7bdb0acbe560f8a300a6ae0d546c98 Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 30 Oct 2013 21:16:45 -0200 Subject: [PATCH 580/795] Bug 929435 - Treat undefined as null in Contacts API strings. r=gwagner --HG-- extra : rebase_source : a838d31f1d1f7fbff04bdebc865d2234a5e958d5 --- dom/contacts/tests/test_contacts_basics.html | 16 +++++++++++ dom/webidl/Contacts.webidl | 30 ++++++++++---------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/dom/contacts/tests/test_contacts_basics.html b/dom/contacts/tests/test_contacts_basics.html index 04fca7806cc5..c8040b5da412 100644 --- a/dom/contacts/tests/test_contacts_basics.html +++ b/dom/contacts/tests/test_contacts_basics.html @@ -1668,6 +1668,22 @@ var steps = [ } next(); }, + function() { + ok(true, "Undefined strings should be treated as null"); + var c = new mozContact({ + adr: [{value: undefined}], + email: [{value: undefined}], + url: [{value: undefined}], + impp: [{value: undefined}], + tel: [{value: undefined}], + }); + is(c.adr[0].type, null, "adr is null"); + is(c.email[0].type, null, "email is null"); + is(c.url[0].type, null, "url is null"); + is(c.impp[0].type, null, "impp is null"); + is(c.tel[0].type, null, "tel is null"); + next(); + }, function () { ok(true, "all done!\n"); clearTemps(); diff --git a/dom/webidl/Contacts.webidl b/dom/webidl/Contacts.webidl index 6f594ba29212..f236e9ccff92 100644 --- a/dom/webidl/Contacts.webidl +++ b/dom/webidl/Contacts.webidl @@ -7,11 +7,11 @@ [ChromeOnly, Constructor, JSImplementation="@mozilla.org/contactAddress;1"] interface ContactAddress { attribute object? type; // DOMString[] - attribute DOMString? streetAddress; - attribute DOMString? locality; - attribute DOMString? region; - attribute DOMString? postalCode; - attribute DOMString? countryName; + [TreatUndefinedAs=Null] attribute DOMString? streetAddress; + [TreatUndefinedAs=Null] attribute DOMString? locality; + [TreatUndefinedAs=Null] attribute DOMString? region; + [TreatUndefinedAs=Null] attribute DOMString? postalCode; + [TreatUndefinedAs=Null] attribute DOMString? countryName; attribute boolean? pref; [ChromeOnly] @@ -26,19 +26,19 @@ interface ContactAddress { dictionary ContactAddressInit { sequence? type; - DOMString? streetAddress; - DOMString? locality; - DOMString? region; - DOMString? postalCode; - DOMString? countryName; - boolean? pref; + DOMString? streetAddress; + DOMString? locality; + DOMString? region; + DOMString? postalCode; + DOMString? countryName; + boolean? pref; }; [ChromeOnly, Constructor, JSImplementation="@mozilla.org/contactField;1"] interface ContactField { attribute object? type; // DOMString[] - attribute DOMString? value; + [TreatUndefinedAs=Null] attribute DOMString? value; attribute boolean? pref; [ChromeOnly] @@ -56,7 +56,7 @@ dictionary ContactFieldInit { [ChromeOnly, Constructor, JSImplementation="@mozilla.org/contactTelField;1"] interface ContactTelField : ContactField { - attribute DOMString? carrier; + [TreatUndefinedAs=Null] attribute DOMString? carrier; [ChromeOnly] void initialize(optional sequence? type, @@ -111,8 +111,8 @@ interface mozContact { attribute Date? bday; attribute Date? anniversary; - attribute DOMString? sex; - attribute DOMString? genderIdentity; + [TreatUndefinedAs=Null] attribute DOMString? sex; + [TreatUndefinedAs=Null] attribute DOMString? genderIdentity; attribute object? photo; From aa85d95ccf4b8994859c6608de080aad936aa03a Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Wed, 30 Oct 2013 21:39:05 -0200 Subject: [PATCH 581/795] Bug 932763 - Setting mozContact's array properties to an empty array should work. r=gwagner --HG-- extra : rebase_source : bdc09f04d31e72fafce8b8ef5726d1d0288c8efd --- dom/contacts/ContactManager.js | 18 +++++++------- dom/contacts/tests/test_contacts_basics.html | 26 ++++++++++++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/dom/contacts/ContactManager.js b/dom/contacts/ContactManager.js index 5d64d1e51e85..5cc196d3ce6b 100644 --- a/dom/contacts/ContactManager.js +++ b/dom/contacts/ContactManager.js @@ -176,18 +176,18 @@ function validateArrayField(data, createCb) { } }; - if (data) { - data = Array.isArray(data) ? data : [data]; - let filtered = []; - for (let i = 0, n = data.length; i < n; ++i) { + if (data === null || data === undefined) { + return undefined; + } + + data = Array.isArray(data) ? data : [data]; + let filtered = []; + for (let i = 0, n = data.length; i < n; ++i) { + if (data[i]) { filtered.push(createCb(data[i])); } - if (filtered.length === 0) { - return undefined; - } - return new Proxy(filtered, ArrayPropertyHandler); } - return undefined; + return new Proxy(filtered, ArrayPropertyHandler); } // We need this to create a copy of the mozContact object in ContactManager.save diff --git a/dom/contacts/tests/test_contacts_basics.html b/dom/contacts/tests/test_contacts_basics.html index c8040b5da412..f5a6b2c46bfc 100644 --- a/dom/contacts/tests/test_contacts_basics.html +++ b/dom/contacts/tests/test_contacts_basics.html @@ -264,7 +264,7 @@ function removeAndroidDefaultCategory(category) { function checkArrayField(array1, array2, func, msg) { if (!!array1 ^ !!array2) { - ok(false, "Expected both arrays to be either present or absent"); + ok(false, "Expected both arrays to be either present or absent: " + JSON.stringify(array1) + " vs. " + JSON.stringify(array2) + ". (" + msg + ")"); return; } if (!array1 && !array2) { @@ -1523,17 +1523,11 @@ var steps = [ }, function () { ok(true, "Adding contact with invalid data"); - var input = document.createElement("input"); var obj = { honorificPrefix: [], honorificSuffix: [{foo: "bar"}], sex: 17, - genderIdentity: 18, - email: input, - adr: input, - tel: input, - impp: input, - url: input + genderIdentity: 18 }; obj.honorificPrefix.__defineGetter__('0',(function() { var c = 0; @@ -1684,6 +1678,22 @@ var steps = [ is(c.tel[0].type, null, "tel is null"); next(); }, + function() { + ok(true, "Setting array properties to an empty array should work"); + var c = new mozContact(); + function testArrayProp(prop) { + is(c[prop], null, "property is initially null"); + c[prop] = []; + ok(Array.isArray(c[prop]), "property is an array after setting"); + is(c[prop].length, 0, "property has length 0 after setting"); + } + testArrayProp("email"); + testArrayProp("adr"); + testArrayProp("tel"); + testArrayProp("impp"); + testArrayProp("url"); + next(); + }, function () { ok(true, "all done!\n"); clearTemps(); From d10640b99be7d821ca4d57ec061b289d8ddd878b Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Wed, 30 Oct 2013 17:21:09 -0700 Subject: [PATCH 582/795] Bug 875585 - re-disable test_Range-surroundContents for pushing us off the OOM cliff by holding alive many iframes on this CLOSED TREE. rs=RyanVM --- dom/imptests/html/dom/ranges/Makefile.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dom/imptests/html/dom/ranges/Makefile.in b/dom/imptests/html/dom/ranges/Makefile.in index ac38262f3fff..b7e7e5a25929 100644 --- a/dom/imptests/html/dom/ranges/Makefile.in +++ b/dom/imptests/html/dom/ranges/Makefile.in @@ -20,6 +20,12 @@ MOCHITEST_FILES := \ test_Range-mutations.html \ test_Range-selectNode.html \ test_Range-set.html \ - test_Range-surroundContents.html \ Range-test-iframe.html \ $(NULL) + +# Temporarily disable on Windows for bug 875585 and deps +ifneq (windows,$(MOZ_WIDGET_TOOLKIT)) +MOCHITEST_FILES += \ + test_Range-surroundContents.html \ + $(NULL) +endif From a5735c07d08f8fa7b2e60dc3a6ff07b9476ad52d Mon Sep 17 00:00:00 2001 From: Gaia Pushbot Date: Wed, 30 Oct 2013 17:55:24 -0700 Subject: [PATCH 583/795] Bumping gaia.json for 2 gaia-central revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/aa1ebd9c0116 Author: evanxd Desc: Merge pull request #13028 from evanxd/bug-925961 Bug 925961 - [B2G][Email] Receiver's email address displays as "null" after saving, editing, and then saving the draft again ======== https://hg.mozilla.org/integration/gaia-central/rev/22c91d39b070 Author: Evan Xd Desc: Bug 925961 - Use the email address parser for showing bubble properly. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index aff2de225c2c..e433075777d7 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -1,4 +1,4 @@ { - "revision": "2cf15a32048656b8b71c56ed5c5468c9644caf17", + "revision": "aa1ebd9c011628a4e1a9802fd552ec853610b2f5", "repo_path": "/integration/gaia-central" } From ec0adfacf73a687ceef543d690f6fe3170eae43e Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 31 Oct 2013 15:16:27 +1300 Subject: [PATCH 584/795] Bug 933072. Make all Range tests only create 1 or 2 iframes instead of one or two per subtest. r=khuey (CLOSED TREE) --- .../dom/ranges/test_Range-cloneContents.html | 121 +++++++++++------- .../dom/ranges/test_Range-deleteContents.html | 115 +++++++++++------ .../ranges/test_Range-extractContents.html | 121 +++++++++++------- .../dom/ranges/test_Range-insertNode.html | 8 +- .../ranges/test_Range-surroundContents.html | 8 +- 5 files changed, 236 insertions(+), 137 deletions(-) diff --git a/dom/imptests/html/dom/ranges/test_Range-cloneContents.html b/dom/imptests/html/dom/ranges/test_Range-cloneContents.html index a08c9194822a..1a6646638ad4 100644 --- a/dom/imptests/html/dom/ranges/test_Range-cloneContents.html +++ b/dom/imptests/html/dom/ranges/test_Range-cloneContents.html @@ -1,9 +1,9 @@ Range.cloneContents() tests -

To debug test failures, look at the URL of the hidden iframes corresponding -to the test at the end of the document, load those individually, and use your -browser's debugging tools. +

To debug test failures, add a query parameter "subtest" with the test id (like +"?subtest=5"). Only that test will be run. Then you can look at the resulting +iframe in the DOM.

@@ -13,6 +13,14 @@ browser's debugging tools. testDiv.parentNode.removeChild(testDiv); +var actualIframe = document.createElement("iframe"); +actualIframe.style.display = "none"; +document.body.appendChild(actualIframe); + +var expectedIframe = document.createElement("iframe"); +expectedIframe.style.display = "none"; +document.body.appendChild(expectedIframe); + function myCloneContents(range) { // "Let frag be a new DocumentFragment whose ownerDocument is the same as // the ownerDocument of the context object's start node." @@ -221,35 +229,48 @@ function myCloneContents(range) { return frag; } +function restoreIframe(iframe, i) { + // Most of this function is designed to work around the fact that Opera + // doesn't let you add a doctype to a document that no longer has one, in + // any way I can figure out. I eventually compromised on something that + // will still let Opera pass most tests that don't actually involve + // doctypes. + while (iframe.contentDocument.firstChild + && iframe.contentDocument.firstChild.nodeType != Node.DOCUMENT_TYPE_NODE) { + iframe.contentDocument.removeChild(iframe.contentDocument.firstChild); + } + + while (iframe.contentDocument.lastChild + && iframe.contentDocument.lastChild.nodeType != Node.DOCUMENT_TYPE_NODE) { + iframe.contentDocument.removeChild(iframe.contentDocument.lastChild); + } + + if (!iframe.contentDocument.firstChild) { + // This will throw an exception in Opera if we reach here, which is why + // I try to avoid it. It will never happen in a browser that obeys the + // spec, so it's really just insurance. I don't think it actually gets + // hit by anything. + iframe.contentDocument.appendChild(iframe.contentDocument.implementation.createDocumentType("html", "", "")); + } + iframe.contentDocument.appendChild(referenceDoc.documentElement.cloneNode(true)); + iframe.contentWindow.setupRangeTests(); + iframe.contentWindow.testRangeInput = testRanges[i]; + iframe.contentWindow.run(); +} + function testCloneContents(i) { - // We only load the expected once the actual is finished, to avoid race - // conditions. First set the onload to null and the src to the empty - // string, so that when we set the src for real we're not just changing the - // hash -- otherwise the load event won't fire. We never do anything after - // a src set except in an onload handler, to avoid race conditions. - var actual = actualIframes[i]; - actual.id = i + "-actual"; - actual.onload = function() { onLoadActual(i); }; - actual.src = "Range-test-iframe.html#" + testRanges[i]; -} + restoreIframe(actualIframe, i); + restoreIframe(expectedIframe, i); -function onLoadActual(i) { - var expected = expectedIframes[i]; - expected.id = i + "-expected"; - expected.onload = function() { onLoadExpected(i); }; - expected.src = "Range-test-iframe.html#" + testRanges[i]; -} - -function onLoadExpected(i) { - var actualRange = actualIframes[i].contentWindow.testRange; - var expectedRange = expectedIframes[i].contentWindow.testRange; + var actualRange = actualIframe.contentWindow.testRange; + var expectedRange = expectedIframe.contentWindow.testRange; var actualFrag, expectedFrag; var actualRoots, expectedRoots; domTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual cloneContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated cloneContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -324,9 +345,9 @@ function onLoadExpected(i) { domTests[i].done(); positionTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual cloneContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated cloneContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -371,9 +392,9 @@ function onLoadExpected(i) { positionTests[i].done(); fragTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual cloneContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated cloneContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -399,24 +420,36 @@ test(function() { assert_array_equals(range.cloneContents().childNodes, []); }, "Range.detach()"); +var iStart = 0; +var iStop = testRanges.length; + +if (/subtest=[0-9]+/.test(location.search)) { + var matches = /subtest=([0-9]+)/.exec(location.search); + iStart = Number(matches[1]); + iStop = Number(matches[1]) + 1; +} + var domTests = []; var positionTests = []; var fragTests = []; -var actualIframes = []; -var expectedIframes = []; -for (var i = 0; i < testRanges.length; i++) { - domTests.push(async_test("Resulting DOM for range " + i + " " + testRanges[i])); - positionTests.push(async_test("Resulting cursor position for range " + i + " " + testRanges[i])); - fragTests.push(async_test("Returned fragment for range " + i + " " + testRanges[i])); - actualIframes.push(document.createElement("iframe")); - actualIframes[i].style.display = "none"; - document.body.appendChild(actualIframes[i]); - - expectedIframes.push(document.createElement("iframe")); - expectedIframes[i].style.display = "none"; - document.body.appendChild(expectedIframes[i]); - - testCloneContents(i); +for (var i = iStart; i < iStop; i++) { + domTests[i] = async_test("Resulting DOM for range " + i + " " + testRanges[i]); + positionTests[i] = async_test("Resulting cursor position for range " + i + " " + testRanges[i]); + fragTests[i] = async_test("Returned fragment for range " + i + " " + testRanges[i]); } + +var referenceDoc = document.implementation.createHTMLDocument(""); +referenceDoc.removeChild(referenceDoc.documentElement); + +actualIframe.onload = function() { + expectedIframe.onload = function() { + for (var i = iStart; i < iStop; i++) { + testCloneContents(i); + } + } + expectedIframe.src = "Range-test-iframe.html"; + referenceDoc.appendChild(actualIframe.contentDocument.documentElement.cloneNode(true)); +} +actualIframe.src = "Range-test-iframe.html"; diff --git a/dom/imptests/html/dom/ranges/test_Range-deleteContents.html b/dom/imptests/html/dom/ranges/test_Range-deleteContents.html index 602a1cbf0c4d..653f99020bf1 100644 --- a/dom/imptests/html/dom/ranges/test_Range-deleteContents.html +++ b/dom/imptests/html/dom/ranges/test_Range-deleteContents.html @@ -1,9 +1,9 @@ Range.deleteContents() tests -

To debug test failures, look at the URL of the hidden iframes corresponding -to the test at the end of the document, load those individually, and use your -browser's debugging tools. +

To debug test failures, add a query parameter "subtest" with the test id (like +"?subtest=5"). Only that test will be run. Then you can look at the resulting +iframe in the DOM.

@@ -13,6 +13,43 @@ browser's debugging tools. testDiv.parentNode.removeChild(testDiv); +var actualIframe = document.createElement("iframe"); +actualIframe.style.display = "none"; +document.body.appendChild(actualIframe); + +var expectedIframe = document.createElement("iframe"); +expectedIframe.style.display = "none"; +document.body.appendChild(expectedIframe); + +function restoreIframe(iframe, i) { + // Most of this function is designed to work around the fact that Opera + // doesn't let you add a doctype to a document that no longer has one, in + // any way I can figure out. I eventually compromised on something that + // will still let Opera pass most tests that don't actually involve + // doctypes. + while (iframe.contentDocument.firstChild + && iframe.contentDocument.firstChild.nodeType != Node.DOCUMENT_TYPE_NODE) { + iframe.contentDocument.removeChild(iframe.contentDocument.firstChild); + } + + while (iframe.contentDocument.lastChild + && iframe.contentDocument.lastChild.nodeType != Node.DOCUMENT_TYPE_NODE) { + iframe.contentDocument.removeChild(iframe.contentDocument.lastChild); + } + + if (!iframe.contentDocument.firstChild) { + // This will throw an exception in Opera if we reach here, which is why + // I try to avoid it. It will never happen in a browser that obeys the + // spec, so it's really just insurance. I don't think it actually gets + // hit by anything. + iframe.contentDocument.appendChild(iframe.contentDocument.implementation.createDocumentType("html", "", "")); + } + iframe.contentDocument.appendChild(referenceDoc.documentElement.cloneNode(true)); + iframe.contentWindow.setupRangeTests(); + iframe.contentWindow.testRangeInput = testRanges[i]; + iframe.contentWindow.run(); +} + function myDeleteContents(range) { // "If the context object's start and end are the same, abort this method." if (range.startContainer == range.endContainer @@ -109,33 +146,17 @@ function myDeleteContents(range) { } function testDeleteContents(i) { - // We only load the expected once the actual is finished, to avoid race - // conditions. First set the onload to null and the src to the empty - // string, so that when we set the src for real we're not just changing the - // hash -- otherwise the load event won't fire. We never do anything after - // a src set except in an onload handler, to avoid race conditions. - var actual = actualIframes[i]; - actual.id = i + "-actual"; - actual.onload = function() { onLoadActual(i); }; - actual.src = "Range-test-iframe.html#" + testRanges[i]; -} + restoreIframe(actualIframe, i); + restoreIframe(expectedIframe, i); -function onLoadActual(i) { - var expected = expectedIframes[i]; - expected.id = i + "-expected"; - expected.onload = function() { onLoadExpected(i); }; - expected.src = "Range-test-iframe.html#" + testRanges[i]; -} - -function onLoadExpected(i) { - var actualRange = actualIframes[i].contentWindow.testRange; - var expectedRange = expectedIframes[i].contentWindow.testRange; + var actualRange = actualIframe.contentWindow.testRange; + var expectedRange = expectedIframe.contentWindow.testRange; var actualRoots, expectedRoots; domTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual deleteContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated deleteContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -220,9 +241,9 @@ function onLoadExpected(i) { domTests[i].done(); positionTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual deleteContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated deleteContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -278,22 +299,34 @@ test(function() { range.deleteContents(); }, "Detached Range"); +var iStart = 0; +var iStop = testRanges.length; + +if (/subtest=[0-9]+/.test(location.search)) { + var matches = /subtest=([0-9]+)/.exec(location.search); + iStart = Number(matches[1]); + iStop = Number(matches[1]) + 1; +} + var domTests = []; var positionTests = []; -var actualIframes = []; -var expectedIframes = []; -for (var i = 0; i < testRanges.length; i++) { - domTests.push(async_test("Resulting DOM for range " + i + " " + testRanges[i])); - positionTests.push(async_test("Resulting cursor position for range " + i + " " + testRanges[i])); - actualIframes.push(document.createElement("iframe")); - actualIframes[i].style.display = "none"; - document.body.appendChild(actualIframes[i]); - - expectedIframes.push(document.createElement("iframe")); - expectedIframes[i].style.display = "none"; - document.body.appendChild(expectedIframes[i]); - - testDeleteContents(i); +for (var i = iStart; i < iStop; i++) { + domTests[i] = async_test("Resulting DOM for range " + i + " " + testRanges[i]); + positionTests[i] = async_test("Resulting cursor position for range " + i + " " + testRanges[i]); } + +var referenceDoc = document.implementation.createHTMLDocument(""); +referenceDoc.removeChild(referenceDoc.documentElement); + +actualIframe.onload = function() { + expectedIframe.onload = function() { + for (var i = iStart; i < iStop; i++) { + testDeleteContents(i); + } + } + expectedIframe.src = "Range-test-iframe.html"; + referenceDoc.appendChild(actualIframe.contentDocument.documentElement.cloneNode(true)); +} +actualIframe.src = "Range-test-iframe.html"; diff --git a/dom/imptests/html/dom/ranges/test_Range-extractContents.html b/dom/imptests/html/dom/ranges/test_Range-extractContents.html index 66b56d4454f2..465ff9b7e569 100644 --- a/dom/imptests/html/dom/ranges/test_Range-extractContents.html +++ b/dom/imptests/html/dom/ranges/test_Range-extractContents.html @@ -1,9 +1,9 @@ Range.extractContents() tests -

To debug test failures, look at the URL of the hidden iframes corresponding -to the test at the end of the document, load those individually, and use your -browser's debugging tools. +

To debug test failures, add a query parameter "subtest" with the test id (like +"?subtest=5"). Only that test will be run. Then you can look at the resulting +iframe in the DOM.

@@ -13,35 +13,56 @@ browser's debugging tools. testDiv.parentNode.removeChild(testDiv); +var actualIframe = document.createElement("iframe"); +actualIframe.style.display = "none"; +document.body.appendChild(actualIframe); + +var expectedIframe = document.createElement("iframe"); +expectedIframe.style.display = "none"; +document.body.appendChild(expectedIframe); + +function restoreIframe(iframe, i) { + // Most of this function is designed to work around the fact that Opera + // doesn't let you add a doctype to a document that no longer has one, in + // any way I can figure out. I eventually compromised on something that + // will still let Opera pass most tests that don't actually involve + // doctypes. + while (iframe.contentDocument.firstChild + && iframe.contentDocument.firstChild.nodeType != Node.DOCUMENT_TYPE_NODE) { + iframe.contentDocument.removeChild(iframe.contentDocument.firstChild); + } + + while (iframe.contentDocument.lastChild + && iframe.contentDocument.lastChild.nodeType != Node.DOCUMENT_TYPE_NODE) { + iframe.contentDocument.removeChild(iframe.contentDocument.lastChild); + } + + if (!iframe.contentDocument.firstChild) { + // This will throw an exception in Opera if we reach here, which is why + // I try to avoid it. It will never happen in a browser that obeys the + // spec, so it's really just insurance. I don't think it actually gets + // hit by anything. + iframe.contentDocument.appendChild(iframe.contentDocument.implementation.createDocumentType("html", "", "")); + } + iframe.contentDocument.appendChild(referenceDoc.documentElement.cloneNode(true)); + iframe.contentWindow.setupRangeTests(); + iframe.contentWindow.testRangeInput = testRanges[i]; + iframe.contentWindow.run(); +} + function testExtractContents(i) { - // We only load the expected once the actual is finished, to avoid race - // conditions. First set the onload to null and the src to the empty - // string, so that when we set the src for real we're not just changing the - // hash -- otherwise the load event won't fire. We never do anything after - // a src set except in an onload handler, to avoid race conditions. - var actual = actualIframes[i]; - actual.id = i + "-actual"; - actual.onload = function() { onLoadActual(i); }; - actual.src = "Range-test-iframe.html#" + testRanges[i]; -} + restoreIframe(actualIframe, i); + restoreIframe(expectedIframe, i); -function onLoadActual(i) { - var expected = expectedIframes[i]; - expected.id = i + "-expected"; - expected.onload = function() { onLoadExpected(i); }; - expected.src = "Range-test-iframe.html#" + testRanges[i]; -} - -function onLoadExpected(i) { - var actualRange = actualIframes[i].contentWindow.testRange; - var expectedRange = expectedIframes[i].contentWindow.testRange; + var actualRange = actualIframe.contentWindow.testRange; + var expectedRange = expectedIframe.contentWindow.testRange; var actualFrag, expectedFrag; var actualRoots, expectedRoots; domTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual extractContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated extractContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -110,9 +131,9 @@ function onLoadExpected(i) { domTests[i].done(); positionTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual extractContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated extractContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -165,9 +186,9 @@ function onLoadExpected(i) { positionTests[i].done(); fragTests[i].step(function() { - assert_equals(actualIframes[i].contentWindow.unexpectedException, null, + assert_equals(actualIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for actual extractContents()"); - assert_equals(expectedIframes[i].contentWindow.unexpectedException, null, + assert_equals(expectedIframe.contentWindow.unexpectedException, null, "Unexpected exception thrown when setting up Range for simulated extractContents()"); assert_equals(typeof actualRange, "object", "typeof Range produced in actual iframe"); @@ -193,24 +214,36 @@ test(function() { assert_array_equals(range.extractContents().childNodes, []); }, "Detached Range"); +var iStart = 0; +var iStop = testRanges.length; + +if (/subtest=[0-9]+/.test(location.search)) { + var matches = /subtest=([0-9]+)/.exec(location.search); + iStart = Number(matches[1]); + iStop = Number(matches[1]) + 1; +} + var domTests = []; var positionTests = []; var fragTests = []; -var actualIframes = []; -var expectedIframes = []; -for (var i = 0; i < testRanges.length; i++) { - domTests.push(async_test("Resulting DOM for range " + i + " " + testRanges[i])); - positionTests.push(async_test("Resulting cursor position for range " + i + " " + testRanges[i])); - fragTests.push(async_test("Returned fragment for range " + i + " " + testRanges[i])); - actualIframes.push(document.createElement("iframe")); - actualIframes[i].style.display = "none"; - document.body.appendChild(actualIframes[i]); - - expectedIframes.push(document.createElement("iframe")); - expectedIframes[i].style.display = "none"; - document.body.appendChild(expectedIframes[i]); - - testExtractContents(i); +for (var i = iStart; i < iStop; i++) { + domTests[i] = async_test("Resulting DOM for range " + i + " " + testRanges[i]); + positionTests[i] = async_test("Resulting cursor position for range " + i + " " + testRanges[i]); + fragTests[i] = async_test("Returned fragment for range " + i + " " + testRanges[i]); } + +var referenceDoc = document.implementation.createHTMLDocument(""); +referenceDoc.removeChild(referenceDoc.documentElement); + +actualIframe.onload = function() { + expectedIframe.onload = function() { + for (var i = iStart; i < iStop; i++) { + testExtractContents(i); + } + } + expectedIframe.src = "Range-test-iframe.html"; + referenceDoc.appendChild(actualIframe.contentDocument.documentElement.cloneNode(true)); +} +actualIframe.src = "Range-test-iframe.html"; diff --git a/dom/imptests/html/dom/ranges/test_Range-insertNode.html b/dom/imptests/html/dom/ranges/test_Range-insertNode.html index fac556026f6d..8b97a6578b82 100644 --- a/dom/imptests/html/dom/ranges/test_Range-insertNode.html +++ b/dom/imptests/html/dom/ranges/test_Range-insertNode.html @@ -1,8 +1,8 @@ Range.insertNode() tests -

To debug test failures, add a query parameter with the test id (like -"?5,16"). Only that test will be run. Then you can look at the resulting +

To debug test failures, add a query parameter "subtest" with the test id (like +"?subtest=5,16"). Only that test will be run. Then you can look at the resulting iframes in the DOM.

@@ -240,8 +240,8 @@ var iStop = testRangesShort.length; var jStart = 0; var jStop = testNodesShort.length; -if (/[0-9]+,[0-9]+/.test(location.search)) { - var matches = /([0-9]+),([0-9]+)/.exec(location.search); +if (/subtest=[0-9]+,[0-9]+/.test(location.search)) { + var matches = /subtest=([0-9]+),([0-9]+)/.exec(location.search); iStart = Number(matches[1]); iStop = Number(matches[1]) + 1; jStart = Number(matches[2]) + 0; diff --git a/dom/imptests/html/dom/ranges/test_Range-surroundContents.html b/dom/imptests/html/dom/ranges/test_Range-surroundContents.html index fdb0bf1980f4..84e985bffc08 100644 --- a/dom/imptests/html/dom/ranges/test_Range-surroundContents.html +++ b/dom/imptests/html/dom/ranges/test_Range-surroundContents.html @@ -2,8 +2,8 @@ Range.surroundContents() tests -

To debug test failures, add a query parameter with the test id (like -"?5,16"). Only that test will be run. Then you can look at the resulting +

To debug test failures, add a query parameter "subtest" with the test id (like +"?subtest=5,16"). Only that test will be run. Then you can look at the resulting iframes in the DOM.

@@ -306,8 +306,8 @@ var iStop = testRangesShort.length; var jStart = 0; var jStop = testNodesShort.length; -if (/[0-9]+,[0-9]+/.test(location.search)) { - var matches = /([0-9]+),([0-9]+)/.exec(location.search); +if (/subtest=[0-9]+,[0-9]+/.test(location.search)) { + var matches = /subtest=([0-9]+),([0-9]+)/.exec(location.search); iStart = Number(matches[1]); iStop = Number(matches[1]) + 1; jStart = Number(matches[2]) + 0; From d38b80587bc33f6d4dcc69fcd515ae9dbb644e41 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 30 Oct 2013 23:18:24 -0400 Subject: [PATCH 585/795] Backed out changeset 33c9ee1b4564 (bug 875585) cuz thats how we roll when it's a CLOSED TREE. --- dom/imptests/html/dom/ranges/Makefile.in | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/dom/imptests/html/dom/ranges/Makefile.in b/dom/imptests/html/dom/ranges/Makefile.in index b7e7e5a25929..ac38262f3fff 100644 --- a/dom/imptests/html/dom/ranges/Makefile.in +++ b/dom/imptests/html/dom/ranges/Makefile.in @@ -20,12 +20,6 @@ MOCHITEST_FILES := \ test_Range-mutations.html \ test_Range-selectNode.html \ test_Range-set.html \ + test_Range-surroundContents.html \ Range-test-iframe.html \ $(NULL) - -# Temporarily disable on Windows for bug 875585 and deps -ifneq (windows,$(MOZ_WIDGET_TOOLKIT)) -MOCHITEST_FILES += \ - test_Range-surroundContents.html \ - $(NULL) -endif From d0fd1688662ebb7cf1e10a787831fc653dd0eda6 Mon Sep 17 00:00:00 2001 From: Brian Grinstead Date: Wed, 30 Oct 2013 20:29:06 -0500 Subject: [PATCH 586/795] Bug 932880: Developer tools leak many windows until shutdown in browser-chrome tests. r=anton CLOSED TREE --- browser/devtools/framework/toolbox.js | 3 ++- browser/devtools/inspector/inspector-panel.js | 3 +++ browser/devtools/inspector/test/head.js | 5 +++++ toolkit/devtools/server/actors/inspector.js | 5 +++++ toolkit/devtools/server/protocol.js | 13 ++++++++++++- 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/browser/devtools/framework/toolbox.js b/browser/devtools/framework/toolbox.js index 8ec4d9579082..f226ea5da61d 100644 --- a/browser/devtools/framework/toolbox.js +++ b/browser/devtools/framework/toolbox.js @@ -908,6 +908,7 @@ Toolbox.prototype = { // Free _host after the call to destroyed in order to let a chance // to destroyed listeners to still query toolbox attributes this._host = null; - }); + this._toolPanels.clear(); + }).then(null, console.error); } }; diff --git a/browser/devtools/inspector/inspector-panel.js b/browser/devtools/inspector/inspector-panel.js index c6fb0b7c8fb8..5c6f4ab06d70 100644 --- a/browser/devtools/inspector/inspector-panel.js +++ b/browser/devtools/inspector/inspector-panel.js @@ -496,6 +496,8 @@ InspectorPanel.prototype = { this.highlighter.destroy(); } + delete this.onLockStateChanged; + if (this.walker) { this.walker.off("new-root", this.onNewRoot); this._destroyPromise = this.walker.release().then(null, console.error); @@ -529,6 +531,7 @@ InspectorPanel.prototype = { this.nodemenu.removeEventListener("popuphiding", this._resetNodeMenu, true); this.breadcrumbs.destroy(); this.searchSuggestions.destroy(); + delete this.searchBox; this.selection.off("new-node-front", this.onNewSelection); this.selection.off("before-new-node", this.onBeforeNewSelection); this.selection.off("before-new-node-front", this.onBeforeNewSelection); diff --git a/browser/devtools/inspector/test/head.js b/browser/devtools/inspector/test/head.js index 7ee59911afb7..bec99c7563a0 100644 --- a/browser/devtools/inspector/test/head.js +++ b/browser/devtools/inspector/test/head.js @@ -188,3 +188,8 @@ function getComputedPropertyValue(aName) } } } + +SimpleTest.registerCleanupFunction(function () { + let target = TargetFactory.forTab(gBrowser.selectedTab); + gDevTools.closeToolbox(target); +}); diff --git a/toolkit/devtools/server/actors/inspector.js b/toolkit/devtools/server/actors/inspector.js index b4202cf24dd2..c49ed041235a 100644 --- a/toolkit/devtools/server/actors/inspector.js +++ b/toolkit/devtools/server/actors/inspector.js @@ -2367,6 +2367,11 @@ var InspectorFront = exports.InspectorFront = protocol.FrontClass(InspectorActor this.manage(this); }, + destroy: function() { + delete this.walker; + protocol.Front.prototype.destroy.call(this); + }, + getWalker: protocol.custom(function() { return this._getWalker().then(walker => { this.walker = walker; diff --git a/toolkit/devtools/server/protocol.js b/toolkit/devtools/server/protocol.js index 067f2307af02..4bfe63ba2240 100644 --- a/toolkit/devtools/server/protocol.js +++ b/toolkit/devtools/server/protocol.js @@ -915,7 +915,12 @@ let actorProto = function(actorProto) { response.from = this.actorID; // If spec.release has been specified, destroy the object. if (spec.release) { - this.destroy(); + try { + this.destroy(); + } catch(e) { + this.writeError(e); + return; + } } conn.send(response); @@ -988,6 +993,12 @@ let Front = Class({ }, destroy: function() { + // Reject all outstanding requests, they won't make sense after + // the front is destroyed. + while (this._requests && this._requests.length > 0) { + let deferred = this._requests.shift(); + deferred.reject(new Error("Connection closed")); + } Pool.prototype.destroy.call(this); this.actorID = null; }, From 68c065a82ff2c514db84bad6d8eaf6a1bebed265 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Thu, 31 Oct 2013 02:30:00 +0000 Subject: [PATCH 587/795] Bug 932898 - Fix leaks in DOM tests; r=smaug CLOSED TREE --- dom/indexedDB/test/browser_bug839193.js | 12 ++++++------ dom/tests/browser/browser_xhr_sandbox.js | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/dom/indexedDB/test/browser_bug839193.js b/dom/indexedDB/test/browser_bug839193.js index b809132ff67e..94872434b304 100644 --- a/dom/indexedDB/test/browser_bug839193.js +++ b/dom/indexedDB/test/browser_bug839193.js @@ -12,6 +12,10 @@ function onLoad() { function onUnload() { if (!gIterations) { + gBugWindow = null; + Services.obs.removeObserver(onLoad, "bug839193-loaded"); + Services.obs.removeObserver(onUnload, "bug839193-unloaded"); + window.focus(); finish(); } else { @@ -25,12 +29,8 @@ function onUnload() { // will be apparent by the checks the harness performs. function test() { waitForExplicitFinish(); - Components.classes["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService) - .addObserver(onLoad, "bug839193-loaded", false); - Components.classes["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService) - .addObserver(onUnload, "bug839193-unloaded", false); + Services.obs.addObserver(onLoad, "bug839193-loaded", false); + Services.obs.addObserver(onUnload, "bug839193-unloaded", false); gBugWindow = window.openDialog(gTestRoot + "bug839193.xul"); } diff --git a/dom/tests/browser/browser_xhr_sandbox.js b/dom/tests/browser/browser_xhr_sandbox.js index a8b7933dd679..2d9db429c962 100644 --- a/dom/tests/browser/browser_xhr_sandbox.js +++ b/dom/tests/browser/browser_xhr_sandbox.js @@ -34,6 +34,7 @@ function test() { let workerWindow = frame.contentWindow; workerWindow.addEventListener("message", function(evt) { is(evt.data.result, "ok", "check the sandbox code was happy"); + frame.remove(); finish(); }, true); let sandbox = new Cu.Sandbox(workerWindow); From 664273bbcd7a9c25f81ab20aa05ae5bc746daa9b Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 31 Oct 2013 09:37:27 -0400 Subject: [PATCH 588/795] Bug 933231 - don't |unset| variables after configuring NSPR; r=ted --- configure.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.in b/configure.in index 997f89ad77b0..e63c0a728c39 100644 --- a/configure.in +++ b/configure.in @@ -9069,9 +9069,6 @@ if test -z "$MOZ_NATIVE_NSPR"; then AC_OUTPUT_SUBDIRS(nsprpub) # .. and restore them - unset CFLAGS - unset CPPFLAGS - unset LDFLAGS CFLAGS="$_SAVE_CFLAGS" CPPFLAGS="$_SAVE_CPPFLAGS" LDFLAGS="$_SAVE_LDFLAGS" From 401d6b3706e47df6bd22820dc3685352cf5f70b1 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 31 Oct 2013 09:50:26 -0400 Subject: [PATCH 589/795] Bug 933071 - add --with-macos-private-frameworks to support cross-compiling; r=mshal --- configure.in | 17 +++++++++++++++++ media/webrtc/signaling/test/Makefile.in | 2 +- toolkit/library/Makefile.in | 2 +- widget/cocoa/Makefile.in | 6 ------ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/configure.in b/configure.in index e63c0a728c39..181b9a1ebb53 100644 --- a/configure.in +++ b/configure.in @@ -810,9 +810,26 @@ MOZ_ARG_WITH_STRING(macos-sdk, [ --with-macos-sdk=dir Location of platform SDK to use (Mac OS X only)], MACOS_SDK_DIR=$withval) +MACOS_PRIVATE_FRAMEWORKS_DIR_DEFAULTED= +MOZ_ARG_WITH_STRING(macos-private-frameworks, +[ --with-macos-private-frameworks=dir Location of private frameworks to use (Mac OS X only)], + MACOS_PRIVATE_FRAMEWORKS_DIR=$withval, + MACOS_PRIVATE_FRAMEWORKS_DIR=/System/Library/PrivateFrameworks + MACOS_PRIVATE_FRAMEWORKS_DEFAULTED=1) + +if test -z "${MACOS_PRIVATE_FRAMEWORKS_DEFAULTED}"; then + if test -z "$CROSS_COMPILE"; then + AC_MSG_WARN([You should only be using --with-macos-private-frameworks when cross-compiling.]) + fi + if test ! -d "$MACOS_PRIVATE_FRAMEWORKS_DIR"; then + AC_MSG_ERROR([PrivateFrameworks directory not found.]) + fi +fi + dnl MACOS_SDK_DIR will be set to the SDK location whenever one is in use. dnl NEXT_ROOT will be set and exported only if it's needed. AC_SUBST(MACOS_SDK_DIR) +AC_SUBST(MACOS_PRIVATE_FRAMEWORKS_DIR) AC_SUBST(NEXT_ROOT) if test "$MACOS_SDK_DIR"; then diff --git a/media/webrtc/signaling/test/Makefile.in b/media/webrtc/signaling/test/Makefile.in index 252a8e02af3a..9deb69678171 100644 --- a/media/webrtc/signaling/test/Makefile.in +++ b/media/webrtc/signaling/test/Makefile.in @@ -102,7 +102,7 @@ LIBS += \ -framework Security \ -framework SystemConfiguration \ -framework IOKit \ - -F/System/Library/PrivateFrameworks -framework CoreUI \ + -F$(MACOS_PRIVATE_FRAMEWORKS_DIR) -framework CoreUI \ $(TK_LIBS) \ $(NULL) endif diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 6dffaba2843c..060f2c719162 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -506,7 +506,7 @@ OS_LIBS += \ -framework SystemConfiguration \ -framework QTKit \ -framework IOKit \ - -F/System/Library/PrivateFrameworks -framework CoreUI \ + -F$(MACOS_PRIVATE_FRAMEWORKS_DIR) -framework CoreUI \ $(TK_LIBS) \ $(NULL) endif diff --git a/widget/cocoa/Makefile.in b/widget/cocoa/Makefile.in index 7f7eba87a9ae..861ea021fb9d 100644 --- a/widget/cocoa/Makefile.in +++ b/widget/cocoa/Makefile.in @@ -40,9 +40,3 @@ LOCAL_INCLUDES = \ -I$(topsrcdir)/layout/generic \ -I$(topsrcdir)/layout/xul/base/src \ $(NULL) - -LDFLAGS += \ - -framework QuickTime \ - -framework IOKit \ - -F/System/Library/PrivateFrameworks -framework CoreUI \ - $(NULL) From 252b6230ffded243143dd29010ced5a80c5cd601 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Fri, 1 Nov 2013 05:09:32 -0500 Subject: [PATCH 590/795] Bug 907635 - Move metro utils logging functions over to WinUtils. r=masayuki --- widget/windows/WinUtils.cpp | 89 +++++++++++++++++++++++++ widget/windows/WinUtils.h | 14 ++++ widget/windows/nsWindow.cpp | 8 +-- widget/windows/winrt/FrameworkView.cpp | 5 +- widget/windows/winrt/MetroApp.cpp | 17 ++--- widget/windows/winrt/MetroAppShell.cpp | 6 +- widget/windows/winrt/MetroContracts.cpp | 16 ++--- widget/windows/winrt/MetroUtils.cpp | 78 ---------------------- widget/windows/winrt/MetroUtils.h | 10 +-- widget/windows/winrt/MetroWidget.cpp | 36 +++++----- widget/windows/winrt/UIABridge.cpp | 88 ++++++++++++------------ 11 files changed, 187 insertions(+), 180 deletions(-) diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 97848a35065b..054a297db944 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -11,6 +11,11 @@ #include "nsIDOMMouseEvent.h" #include "mozilla/Preferences.h" +#ifdef MOZ_LOGGING +#define FORCE_PR_LOG /* Allow logging in the release build */ +#endif // MOZ_LOGGING +#include "prlog.h" + #include "nsString.h" #include "nsDirectoryServiceUtils.h" #include "imgIContainer.h" @@ -35,6 +40,10 @@ #include "nsTextStore.h" #endif // #ifdef NS_ENABLE_TSF +#ifdef PR_LOGGING +PRLogModuleInfo* gWindowsLog = nullptr; +#endif + namespace mozilla { namespace widget { @@ -75,6 +84,11 @@ WinUtils::DwmGetCompositionTimingInfoProc WinUtils::dwmGetCompositionTimingInfoP void WinUtils::Initialize() { +#ifdef PR_LOGGING + if (!gWindowsLog) { + gWindowsLog = PR_NewLogModule("Widget"); + } +#endif if (!sDwmDll && WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) { sDwmDll = ::LoadLibraryW(kDwmLibraryName); @@ -128,6 +142,81 @@ WinUtils::GetWindowsServicePackVersion(UINT& aOutMajor, UINT& aOutMinor) return true; } +// static +void +WinUtils::LogW(const wchar_t *fmt, ...) +{ + va_list args = NULL; + if(!lstrlenW(fmt)) { + return; + } + va_start(args, fmt); + int buflen = _vscwprintf(fmt, args); + wchar_t* buffer = new wchar_t[buflen+1]; + if (!buffer) { + va_end(args); + return; + } + vswprintf(buffer, buflen, fmt, args); + va_end(args); + + // MSVC, including remote debug sessions + OutputDebugStringW(buffer); + OutputDebugStringW(L"\n"); + + int len = wcslen(buffer); + if (len) { + char* utf8 = new char[len+1]; + memset(utf8, 0, sizeof(utf8)); + if (WideCharToMultiByte(CP_ACP, 0, buffer, + -1, utf8, len+1, NULL, + NULL) > 0) { + // desktop console + printf("%s\n", utf8); +#ifdef PR_LOGGING + NS_ASSERTION(gWindowsLog, "Called WinUtils Log() but Widget " + "log module doesn't exist!"); + PR_LOG(gWindowsLog, PR_LOG_ALWAYS, (utf8)); +#endif + } + delete[] utf8; + } + delete[] buffer; +} + +// static +void +WinUtils::Log(const char *fmt, ...) +{ + va_list args = NULL; + if(!strlen(fmt)) { + return; + } + va_start(args, fmt); + int buflen = _vscprintf(fmt, args); + char* buffer = new char[buflen+1]; + if (!buffer) { + va_end(args); + return; + } + vsprintf(buffer, fmt, args); + va_end(args); + + // MSVC, including remote debug sessions + OutputDebugStringA(buffer); + OutputDebugStringW(L"\n"); + + // desktop console + printf("%s\n", buffer); + +#ifdef PR_LOGGING + NS_ASSERTION(gWindowsLog, "Called WinUtils Log() but Widget " + "log module doesn't exist!"); + PR_LOG(gWindowsLog, PR_LOG_ALWAYS, (buffer)); +#endif + delete[] buffer; +} + /* static */ bool WinUtils::PeekMessage(LPMSG aMsg, HWND aWnd, UINT aFirstMessage, diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 67294c40644c..b985fcd3d684 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -53,6 +53,13 @@ namespace widget { QS_ALLPOSTMESSAGE | QS_RAWINPUT | \ QS_TOUCH | QS_POINTER) +// Logging macros +#define LogFunction() mozilla::widget::WinUtils::Log(__FUNCTION__) +#define LogThread() mozilla::widget::WinUtils::Log("%s: IsMainThread:%d ThreadId:%X", __FUNCTION__, NS_IsMainThread(), GetCurrentThreadId()) +#define LogThis() mozilla::widget::WinUtils::Log("[%X] %s", this, __FUNCTION__) +#define LogException(e) mozilla::widget::WinUtils::Log("%s Exception:%s", __FUNCTION__, e->ToString()->Data()) +#define LogHRESULT(hr) mozilla::widget::WinUtils::Log("%s hr=%X", __FUNCTION__, hr) + class myDownloadObserver MOZ_FINAL : public nsIDownloadObserver { public: @@ -76,6 +83,13 @@ public: // Returns true on success, false on failure. static bool GetWindowsServicePackVersion(UINT& aOutMajor, UINT& aOutMinor); + /** + * Logging helpers that dump output to prlog module 'Widget', console, and + * OutputDebugString. Note these output in both debug and release builds. + */ + static void Log(const char *fmt, ...); + static void LogW(const wchar_t *fmt, ...); + /** * PeekMessage() and GetMessage() are wrapper methods for PeekMessageW(), * GetMessageW(), ITfMessageMgr::PeekMessageW() and diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 5ba6269f02a7..8fa6cda508de 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -253,7 +253,7 @@ uint32_t nsWindow::sOOPPPluginFocusEvent = static const char *sScreenManagerContractID = "@mozilla.org/gfx/screenmanager;1"; #ifdef PR_LOGGING -PRLogModuleInfo* gWindowsLog = nullptr; +extern PRLogModuleInfo* gWindowsLog; #endif // Global used in Show window enumerations. @@ -311,12 +311,6 @@ static const int32_t kResizableBorderMinSize = 3; nsWindow::nsWindow() : nsWindowBase() { -#ifdef PR_LOGGING - if (!gWindowsLog) { - gWindowsLog = PR_NewLogModule("nsWindow"); - } -#endif - mIconSmall = nullptr; mIconBig = nullptr; mWnd = nullptr; diff --git a/widget/windows/winrt/FrameworkView.cpp b/widget/windows/winrt/FrameworkView.cpp index 34358ed52921..9405006befb3 100644 --- a/widget/windows/winrt/FrameworkView.cpp +++ b/widget/windows/winrt/FrameworkView.cpp @@ -98,7 +98,7 @@ FrameworkView::Run() mMetroApp->Run(); // Gecko is completely shut down at this point. - Log("Exiting FrameworkView::Run()"); + WinUtils::Log("Exiting FrameworkView::Run()"); return S_OK; } @@ -463,10 +463,9 @@ FrameworkView::OnAutomationProviderRequested(ICoreWindow* aSender, LogFunction(); if (!EnsureAutomationProviderCreated()) return E_FAIL; - Log("OnAutomationProviderRequested %X", mAutomationProvider.Get()); HRESULT hr = aArgs->put_AutomationProvider(mAutomationProvider.Get()); if (FAILED(hr)) { - Log("put failed? %X", hr); + WinUtils::Log("put failed? %X", hr); } return S_OK; } diff --git a/widget/windows/winrt/MetroApp.cpp b/widget/windows/winrt/MetroApp.cpp index fe81656a6e8a..3469bcff5312 100644 --- a/widget/windows/winrt/MetroApp.cpp +++ b/widget/windows/winrt/MetroApp.cpp @@ -22,6 +22,7 @@ using namespace ABI::Windows::System; using namespace ABI::Windows::Foundation; using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; +using namespace mozilla::widget; // Metro specific XRE methods we call from here on an // appropriate thread. @@ -83,11 +84,11 @@ MetroApp::Run() this, &MetroApp::OnResuming).Get(), &mResumeEvent); AssertHRESULT(hr); - Log("XPCOM startup initialization began"); + WinUtils::Log("XPCOM startup initialization began"); nsresult rv = XRE_metroStartup(true); - Log("XPCOM startup initialization complete"); + WinUtils::Log("XPCOM startup initialization complete"); if (NS_FAILED(rv)) { - Log("XPCOM startup initialization failed, bailing. rv=%X", rv); + WinUtils::Log("XPCOM startup initialization failed, bailing. rv=%X", rv); CoreExit(); } } @@ -153,7 +154,7 @@ HRESULT MetroApp::OnAsyncTileCreated(ABI::Windows::Foundation::IAsyncOperation* aOperation, AsyncStatus aStatus) { - Log("Async operation status: %d", aStatus); + WinUtils::Log("Async operation status: %d", aStatus); return S_OK; } @@ -217,12 +218,6 @@ XRE_MetroCoreApplicationRun() using namespace mozilla::widget::winrt; -#ifdef PR_LOGGING - if (!gWindowsLog) { - gWindowsLog = PR_NewLogModule("nsWindow"); - } -#endif - sMetroApp = Make(); HStringReference className(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication); @@ -256,7 +251,7 @@ XRE_MetroCoreApplicationRun() hr = sCoreApp->Run(sMetroApp.Get()); sFrameworkView = nullptr; - Log("Exiting CoreApplication::Run"); + WinUtils::Log("Exiting CoreApplication::Run"); sCoreApp = nullptr; sMetroApp = nullptr; diff --git a/widget/windows/winrt/MetroAppShell.cpp b/widget/windows/winrt/MetroAppShell.cpp index 166d07c744f8..da5cd13d11e6 100644 --- a/widget/windows/winrt/MetroAppShell.cpp +++ b/widget/windows/winrt/MetroAppShell.cpp @@ -281,7 +281,7 @@ MetroAppShell::ProcessOneNativeEventIfPresent() // Calling into ProcessNativeEvents is harmless, but won't actually process any // native events. So we log here so we can spot this and get a handle on the // corner cases where this can happen. - Log("WARNING: Reentrant call into process events detected, returning early."); + WinUtils::Log("WARNING: Reentrant call into process events detected, returning early."); return false; } @@ -395,7 +395,7 @@ MetroAppShell::Observe(nsISupports *subject, const char *topic, NS_ENSURE_ARG_POINTER(topic); if (!strcmp(topic, "dl-start")) { if (mPowerRequestCount++ == 0) { - Log("Download started - Disallowing suspend"); + WinUtils::Log("Download started - Disallowing suspend"); REASON_CONTEXT context; context.Version = POWER_REQUEST_CONTEXT_VERSION; context.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING; @@ -408,7 +408,7 @@ MetroAppShell::Observe(nsISupports *subject, const char *topic, !strcmp(topic, "dl-cancel") || !strcmp(topic, "dl-failed")) { if (--mPowerRequestCount == 0 && mPowerRequest) { - Log("All downloads ended - Allowing suspend"); + WinUtils::Log("All downloads ended - Allowing suspend"); PowerClearRequestDyn(mPowerRequest, PowerRequestExecutionRequired); mPowerRequest.reset(); } diff --git a/widget/windows/winrt/MetroContracts.cpp b/widget/windows/winrt/MetroContracts.cpp index b72c9a3008fd..23f751843e2d 100644 --- a/widget/windows/winrt/MetroContracts.cpp +++ b/widget/windows/winrt/MetroContracts.cpp @@ -59,7 +59,7 @@ FrameworkView::SearchActivated(ComPtr& aArgs, bool aS return; unsigned int length; - LogW(L"SearchActivated text=%s", data.GetRawBuffer(&length)); + WinUtils::LogW(L"SearchActivated text=%s", data.GetRawBuffer(&length)); if (aStartup) { mActivationURI = data.GetRawBuffer(&length); } else { @@ -136,7 +136,7 @@ FrameworkView::ProcessLaunchArguments() NS_ConvertUTF16toUTF8 arg(argv[i]); argvUTF8[i] = new char[arg.Length() + 1]; strcpy(argvUTF8[i], const_cast(arg.BeginReading())); - LogW(L"Launch arg[%d]: '%s'", i, argv[i]); + WinUtils::LogW(L"Launch arg[%d]: '%s'", i, argv[i]); } nsresult rv = cmdLine->Init(argc, @@ -163,7 +163,7 @@ FrameworkView::ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup) return; ComPtr args(aArgs); if (kind == ActivationKind::ActivationKind_Protocol) { - Log("Activation argument kind: Protocol"); + WinUtils::Log("Activation argument kind: Protocol"); ComPtr protoArgs; AssertHRESULT(args.As(&protoArgs)); ComPtr uri; @@ -183,17 +183,17 @@ FrameworkView::ProcessActivationArgs(IActivatedEventArgs* aArgs, bool aStartup) PerformURILoad(data); } } else if (kind == ActivationKind::ActivationKind_Search) { - Log("Activation argument kind: Search"); + WinUtils::Log("Activation argument kind: Search"); ComPtr searchArgs; args.As(&searchArgs); SearchActivated(searchArgs, aStartup); } else if (kind == ActivationKind::ActivationKind_File) { - Log("Activation argument kind: File"); + WinUtils::Log("Activation argument kind: File"); ComPtr fileArgs; args.As(&fileArgs); FileActivated(fileArgs, aStartup); } else if (kind == ActivationKind::ActivationKind_Launch) { - Log("Activation argument kind: Launch"); + WinUtils::Log("Activation argument kind: Launch"); ComPtr launchArgs; args.As(&launchArgs); LaunchActivated(launchArgs, aStartup); @@ -263,7 +263,7 @@ FrameworkView::PerformURILoad(HString& aURI) LogFunction(); unsigned int length; - LogW(L"PerformURILoad uri=%s", aURI.GetRawBuffer(&length)); + WinUtils::LogW(L"PerformURILoad uri=%s", aURI.GetRawBuffer(&length)); nsCOMPtr cmdLine = (do_CreateInstance("@mozilla.org/toolkit/command-line;1")); @@ -323,7 +323,7 @@ FrameworkView::PerformURILoadOrSearch(HString& aString) LogFunction(); if (WindowsIsStringEmpty(aString.Get())) { - Log("Emptry string passed to PerformURILoadOrSearch"); + WinUtils::Log("Emptry string passed to PerformURILoadOrSearch"); return; } diff --git a/widget/windows/winrt/MetroUtils.cpp b/widget/windows/winrt/MetroUtils.cpp index 6ccdb84c4d3a..9d518124d601 100644 --- a/widget/windows/winrt/MetroUtils.cpp +++ b/widget/windows/winrt/MetroUtils.cpp @@ -3,11 +3,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifdef MOZ_LOGGING -// so we can get logging even in release builds -#define FORCE_PR_LOG 1 -#endif - #include "MetroUtils.h" #include #include "nsICommandLineRunner.h" @@ -39,10 +34,6 @@ using namespace ABI::Windows::Graphics::Display; // File-scoped statics (unnamed namespace) namespace { -#ifdef PR_LOGGING - PRLogModuleInfo* metroWidgetLog = PR_NewLogModule("MetroWidget"); -#endif - FLOAT LogToPhysFactor() { ComPtr dispProps; if (SUCCEEDED(GetActivationFactory(HStringReference(RuntimeClass_Windows_Graphics_Display_DisplayProperties).Get(), @@ -68,75 +59,6 @@ namespace { } }; -void LogW(const wchar_t *fmt, ...) -{ - va_list args = nullptr; - if(!lstrlenW(fmt)) - return; - va_start(args, fmt); - int buflen = _vscwprintf(fmt, args); - wchar_t* buffer = new wchar_t[buflen+1]; - if (!buffer) { - va_end(args); - return; - } - vswprintf(buffer, buflen, fmt, args); - va_end(args); - - // MSVC, including remote debug sessions - OutputDebugStringW(buffer); - OutputDebugStringW(L"\n"); - - int len = wcslen(buffer); - if (len) { - char* utf8 = new char[len+1]; - memset(utf8, 0, sizeof(utf8)); - if (WideCharToMultiByte(CP_ACP, 0, buffer, - -1, utf8, len+1, nullptr, - nullptr) > 0) { - // desktop console - printf("%s\n", utf8); -#ifdef PR_LOGGING - NS_ASSERTION(metroWidgetLog, "Called MetroUtils Log() but MetroWidget " - "log module doesn't exist!"); - PR_LOG(metroWidgetLog, PR_LOG_ALWAYS, (utf8)); -#endif - } - delete[] utf8; - } - delete[] buffer; -} - -void Log(const char *fmt, ...) -{ - va_list args = nullptr; - if(!strlen(fmt)) - return; - va_start(args, fmt); - int buflen = _vscprintf(fmt, args); - char* buffer = new char[buflen+1]; - if (!buffer) { - va_end(args); - return; - } - vsprintf(buffer, fmt, args); - va_end(args); - - // MSVC, including remote debug sessions - OutputDebugStringA(buffer); - OutputDebugStringW(L"\n"); - - // desktop console - printf("%s\n", buffer); - -#ifdef PR_LOGGING - NS_ASSERTION(metroWidgetLog, "Called MetroUtils Log() but MetroWidget " - "log module doesn't exist!"); - PR_LOG(metroWidgetLog, PR_LOG_ALWAYS, (buffer)); -#endif - delete[] buffer; -} - // Conversion between logical and physical coordinates int32_t MetroUtils::LogToPhys(FLOAT aValue) diff --git a/widget/windows/winrt/MetroUtils.h b/widget/windows/winrt/MetroUtils.h index cdb7a0788a11..9b6fb9446e92 100644 --- a/widget/windows/winrt/MetroUtils.h +++ b/widget/windows/winrt/MetroUtils.h @@ -9,6 +9,7 @@ #include "nsThreadUtils.h" #include "nsString.h" #include "nsPoint.h" +#include "WinUtils.h" #include "mozwrlbase.h" @@ -16,15 +17,6 @@ #include #include -void Log(const char *fmt, ...); -void LogW(const wchar_t *fmt, ...); - -#define LogFunction() Log(__FUNCTION__) -#define LogThread() Log("%s: IsMainThread:%d ThreadId:%X", __FUNCTION__, NS_IsMainThread(), GetCurrentThreadId()) -#define LogThis() Log("[%X] %s", this, __FUNCTION__) -#define LogException(e) Log("%s Exception:%s", __FUNCTION__, e->ToString()->Data()) -#define LogHRESULT(hr) Log("%s hr=%X", __FUNCTION__, hr) - // HRESULT checkers, these warn on failure in debug builds #ifdef DEBUG #define DebugLogHR(hr) LogHRESULT(hr) diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp index 7194b3aefabf..cdf9cb09922f 100644 --- a/widget/windows/winrt/MetroWidget.cpp +++ b/widget/windows/winrt/MetroWidget.cpp @@ -61,6 +61,7 @@ extern PRLogModuleInfo* gWindowsLog; static uint32_t gInstanceCount = 0; const PRUnichar* kMetroSubclassThisProp = L"MetroSubclassThisProp"; HWND MetroWidget::sICoreHwnd = nullptr; +nsRefPtr MetroWidget::sAPZC; namespace mozilla { namespace widget { @@ -120,20 +121,20 @@ namespace { for (uint32_t i = 0; i < aExtraInputsLen; i++) { inputs[keySequence.Length()+i] = aExtraInputs[i]; } - Log(" Sending inputs"); + WinUtils::Log(" Sending inputs"); for (uint32_t i = 0; i < len; i++) { if (inputs[i].type == INPUT_KEYBOARD) { - Log(" Key press: 0x%x %s", + WinUtils::Log(" Key press: 0x%x %s", inputs[i].ki.wVk, inputs[i].ki.dwFlags & KEYEVENTF_KEYUP ? "UP" : "DOWN"); } else if(inputs[i].type == INPUT_MOUSE) { - Log(" Mouse input: 0x%x 0x%x", + WinUtils::Log(" Mouse input: 0x%x 0x%x", inputs[i].mi.dwFlags, inputs[i].mi.mouseData); } else { - Log(" Unknown input type!"); + WinUtils::Log(" Unknown input type!"); } } ::SendInput(len, inputs, sizeof(INPUT)); @@ -143,7 +144,7 @@ namespace { // waiting to be processed by our event loop. Now we manually pump // those messages so that, upon our return, all the inputs have been // processed. - Log(" Inputs sent. Waiting for input messages to clear"); + WinUtils::Log(" Inputs sent. Waiting for input messages to clear"); MSG msg; while (WinUtils::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { if (nsTextStore::ProcessRawKeyMessage(msg)) { @@ -151,17 +152,14 @@ namespace { } ::TranslateMessage(&msg); ::DispatchMessage(&msg); - Log(" Dispatched 0x%x 0x%x 0x%x", msg.message, msg.wParam, msg.lParam); + WinUtils::Log(" Dispatched 0x%x 0x%x 0x%x", msg.message, msg.wParam, msg.lParam); } - Log(" No more input messages"); + WinUtils::Log(" No more input messages"); } } NS_IMPL_ISUPPORTS_INHERITED0(MetroWidget, nsBaseWidget) - -nsRefPtr MetroWidget::sAPZC; - MetroWidget::MetroWidget() : mTransparencyMode(eTransparencyOpaque), mWnd(nullptr), @@ -217,20 +215,20 @@ MetroWidget::Create(nsIWidget *aParent, if (mWindowType != eWindowType_toplevel) { switch(mWindowType) { case eWindowType_dialog: - Log("eWindowType_dialog window requested, returning failure."); + WinUtils::Log("eWindowType_dialog window requested, returning failure."); break; case eWindowType_child: - Log("eWindowType_child window requested, returning failure."); + WinUtils::Log("eWindowType_child window requested, returning failure."); break; case eWindowType_popup: - Log("eWindowType_popup window requested, returning failure."); + WinUtils::Log("eWindowType_popup window requested, returning failure."); break; case eWindowType_plugin: - Log("eWindowType_plugin window requested, returning failure."); + WinUtils::Log("eWindowType_plugin window requested, returning failure."); break; // we should support toolkit's eWindowType_invisible at some point. case eWindowType_invisible: - Log("eWindowType_invisible window requested, this doesn't actually exist!"); + WinUtils::Log("eWindowType_invisible window requested, this doesn't actually exist!"); return NS_OK; } NS_WARNING("Invalid window type requested."); @@ -271,7 +269,7 @@ MetroWidget::Destroy() { if (mOnDestroyCalled) return NS_OK; - Log("[%X] %s mWnd=%X type=%d", this, __FUNCTION__, mWnd, mWindowType); + WinUtils::Log("[%X] %s mWnd=%X type=%d", this, __FUNCTION__, mWnd, mWindowType); mOnDestroyCalled = true; nsCOMPtr kungFuDeathGrip(this); @@ -520,7 +518,7 @@ MetroWidget::SynthesizeNativeMouseEvent(nsIntPoint aPoint, uint32_t aNativeMessage, uint32_t aModifierFlags) { - Log("ENTERED SynthesizeNativeMouseEvent"); + WinUtils::Log("ENTERED SynthesizeNativeMouseEvent"); INPUT inputs[2]; memset(inputs, 0, 2*sizeof(INPUT)); @@ -535,7 +533,7 @@ MetroWidget::SynthesizeNativeMouseEvent(nsIntPoint aPoint, inputs[1].mi.dwFlags = aNativeMessage; SendInputs(aModifierFlags, inputs, 2); - Log("Exiting SynthesizeNativeMouseEvent"); + WinUtils::Log("Exiting SynthesizeNativeMouseEvent"); return NS_OK; } @@ -814,7 +812,7 @@ MetroWidget::WindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParam, LPARAM aLPara return res; } NS_ASSERTION(res, "UiaReturnRawElementProvider failed!"); - Log("UiaReturnRawElementProvider failed! GetLastError=%X", GetLastError()); + WinUtils::Log("UiaReturnRawElementProvider failed! GetLastError=%X", GetLastError()); } } break; diff --git a/widget/windows/winrt/UIABridge.cpp b/widget/windows/winrt/UIABridge.cpp index 30510deeec05..403e82c6a225 100644 --- a/widget/windows/winrt/UIABridge.cpp +++ b/widget/windows/winrt/UIABridge.cpp @@ -7,6 +7,7 @@ #include "MetroUtils.h" #include "UIABridgePrivate.h" #include "MetroWidget.h" +#include "WinUtils.h" #include #include @@ -15,6 +16,7 @@ #ifdef ACCESSIBILITY using namespace mozilla::a11y; #endif +using namespace mozilla::widget; using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::UI; @@ -26,10 +28,11 @@ using namespace ABI::Windows::System; #if !defined(DEBUG_BRIDGE) #undef LogThread #undef LogFunction -#undef Log #define LogThread() #define LogFunction() -#define Log(...) +#define BridgeLog(...) +#else +#define BridgeLog(...) WinUtils::Log(__VA_ARGS__) #endif #define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ @@ -49,7 +52,6 @@ static ComPtr gElement = nullptr; HRESULT UIABridge_CreateInstance(IInspectable **retVal) { - LogFunction(); HRESULT hr = E_OUTOFMEMORY; *retVal = nullptr; ComPtr spProvider = Make(); @@ -129,12 +131,14 @@ UIABridge::Connected() HRESULT UIABridge::SetFocusInternal(LONG_PTR aAccessible) { + LogFunction(); return S_OK; } HRESULT UIABridge::ClearFocus() { + LogFunction(); return S_OK; } @@ -147,9 +151,9 @@ DumpChildInfo(nsCOMPtr& aChild) } nsString str; aChild->GetName(str); - Log("name: %ls", str.BeginReading()); + BridgeLog("name: %ls", str.BeginReading()); aChild->GetDescription(str); - Log("description: %ls", str.BeginReading()); + BridgeLog("description: %ls", str.BeginReading()); #endif } @@ -157,7 +161,7 @@ static bool ChildHasFocus(nsCOMPtr& aChild) { Accessible* access = (Accessible*)aChild.get(); - Log("Focus element flags: editable:%d focusable:%d readonly:%d", + BridgeLog("Focus element flags: editable:%d focusable:%d readonly:%d", ((access->NativeState() & mozilla::a11y::states::EDITABLE) > 0), ((access->NativeState() & mozilla::a11y::states::FOCUSABLE) > 0), ((access->NativeState() & mozilla::a11y::states::READONLY) > 0)); @@ -207,7 +211,7 @@ UIABridge::ElementProviderFromPoint(double x, double y, IRawElementProviderFragm } // Windows calls this looking for the current focus element. Windows -// will call here before accessible sends up any observer events through +// will call here before accessible sends us any observer events through // the accessibility bridge, so update child focus information. HRESULT UIABridge::GetFocus(IRawElementProviderFragment ** retVal) @@ -220,7 +224,7 @@ UIABridge::GetFocus(IRawElementProviderFragment ** retVal) nsCOMPtr child; nsresult rv = mAccessible->GetFocusedChild(getter_AddRefs(child)); if (!child) { - Log("mAccessible->GetFocusedChild failed."); + BridgeLog("mAccessible->GetFocusedChild failed."); return S_OK; } @@ -229,7 +233,7 @@ UIABridge::GetFocus(IRawElementProviderFragment ** retVal) ComPtr element; gElement.As(&element); if (!element) { - Log("gElement as IUIAElement failed."); + BridgeLog("gElement as IUIAElement failed."); return S_OK; } @@ -256,20 +260,20 @@ UIABridge::Navigate(NavigateDirection direction, IRawElementProviderFragment ** switch(direction) { case NavigateDirection_Parent: - Log("UIABridge::Navigate NavigateDirection_Parent"); + BridgeLog("UIABridge::Navigate NavigateDirection_Parent"); break; case NavigateDirection_NextSibling: - Log("UIABridge::Navigate NavigateDirection_NextSibling"); + BridgeLog("UIABridge::Navigate NavigateDirection_NextSibling"); break; case NavigateDirection_PreviousSibling: - Log("UIABridge::Navigate NavigateDirection_PreviousSibling"); + BridgeLog("UIABridge::Navigate NavigateDirection_PreviousSibling"); break; case NavigateDirection_FirstChild: - Log("UIABridge::Navigate NavigateDirection_FirstChild"); + BridgeLog("UIABridge::Navigate NavigateDirection_FirstChild"); gElement.Get()->QueryInterface(IID_PPV_ARGS(retVal)); break; case NavigateDirection_LastChild: - Log("UIABridge::Navigate NavigateDirection_LastChild"); + BridgeLog("UIABridge::Navigate NavigateDirection_LastChild"); gElement.Get()->QueryInterface(IID_PPV_ARGS(retVal)); break; } @@ -366,7 +370,7 @@ HRESULT UIABridge::GetPatternProvider(PATTERNID patternId, IUnknown **ppRetVal) { LogFunction(); - Log("UIABridge::GetPatternProvider=%d", patternId); + BridgeLog("UIABridge::GetPatternProvider=%d", patternId); // The root window doesn't support any specific pattern *ppRetVal = nullptr; @@ -381,37 +385,37 @@ UIABridge::GetPropertyValue(PROPERTYID idProp, VARIANT * pRetVal) switch (idProp) { case UIA_AutomationIdPropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_AutomationIdPropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_AutomationIdPropertyId"); break; case UIA_ControlTypePropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_ControlTypePropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_ControlTypePropertyId"); break; case UIA_IsKeyboardFocusablePropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_IsKeyboardFocusablePropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsKeyboardFocusablePropertyId"); break; case UIA_IsContentElementPropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_IsContentElementPropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsContentElementPropertyId"); break; case UIA_IsControlElementPropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_IsControlElementPropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsControlElementPropertyId"); break; case UIA_IsEnabledPropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_IsEnabledPropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsEnabledPropertyId"); break; case UIA_HasKeyboardFocusPropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_HasKeyboardFocusPropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_HasKeyboardFocusPropertyId"); break; case UIA_NamePropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_NamePropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_NamePropertyId"); break; case UIA_IsPasswordPropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_IsPasswordPropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_IsPasswordPropertyId"); break; case UIA_NativeWindowHandlePropertyId: - Log("UIABridge::GetPropertyValue: idProp=UIA_NativeWindowHandlePropertyId"); + BridgeLog("UIABridge::GetPropertyValue: idProp=UIA_NativeWindowHandlePropertyId"); break; default: - Log("UIABridge::GetPropertyValue: idProp=%d", idProp); + BridgeLog("UIABridge::GetPropertyValue: idProp=%d", idProp); break; } @@ -459,7 +463,7 @@ UIABridge::GetPropertyValue(PROPERTYID idProp, VARIANT * pRetVal) break; default: - Log("UIABridge: Unhandled property"); + BridgeLog("UIABridge: Unhandled property"); break; } return S_OK; @@ -564,7 +568,7 @@ UIATextElement::get_BoundingRectangle(UiaRect * retVal) retVal->width = (float)docWidth; retVal->height = (float)docHeight; - Log("get_BoundingRectangle: left=%d top=%d right=%d bottom=%d", docX, docY, docX + docWidth, docY + docHeight); + BridgeLog("get_BoundingRectangle: left=%d top=%d right=%d bottom=%d", docX, docY, docX + docWidth, docY + docHeight); return S_OK; } @@ -603,7 +607,7 @@ HRESULT UIATextElement::GetPatternProvider(PATTERNID patternId, IUnknown **ppRetVal) { LogFunction(); - Log("UIATextElement::GetPatternProvider=%d", patternId); + BridgeLog("UIATextElement::GetPatternProvider=%d", patternId); // UIA_ValuePatternId - 10002 // UIA_TextPatternId - 10014 @@ -611,12 +615,12 @@ UIATextElement::GetPatternProvider(PATTERNID patternId, IUnknown **ppRetVal) *ppRetVal = nullptr; if (patternId == UIA_TextPatternId) { - Log("** TextPattern requested from element."); + BridgeLog("** TextPattern requested from element."); *ppRetVal = static_cast(this); AddRef(); return S_OK; } else if (patternId == UIA_ValuePatternId) { - Log("** ValuePattern requested from element."); + BridgeLog("** ValuePattern requested from element."); *ppRetVal = static_cast(this); AddRef(); return S_OK; @@ -637,34 +641,34 @@ UIATextElement::GetPropertyValue(PROPERTYID idProp, VARIANT * pRetVal) switch (idProp) { case UIA_AutomationIdPropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_AutomationIdPropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_AutomationIdPropertyId"); break; case UIA_ControlTypePropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_ControlTypePropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_ControlTypePropertyId"); break; case UIA_IsKeyboardFocusablePropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_IsKeyboardFocusablePropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsKeyboardFocusablePropertyId"); break; case UIA_IsContentElementPropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_IsContentElementPropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsContentElementPropertyId"); break; case UIA_IsControlElementPropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_IsControlElementPropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsControlElementPropertyId"); break; case UIA_IsEnabledPropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_IsEnabledPropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsEnabledPropertyId"); break; case UIA_HasKeyboardFocusPropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_HasKeyboardFocusPropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_HasKeyboardFocusPropertyId"); break; case UIA_NamePropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_NamePropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_NamePropertyId"); break; case UIA_IsPasswordPropertyId: - Log("UIATextElement::GetPropertyValue: idProp=UIA_IsPasswordPropertyId"); + BridgeLog("UIATextElement::GetPropertyValue: idProp=UIA_IsPasswordPropertyId"); break; default: - Log("UIATextElement::GetPropertyValue: idProp=%d", idProp); + BridgeLog("UIATextElement::GetPropertyValue: idProp=%d", idProp); break; } @@ -719,7 +723,7 @@ UIATextElement::GetPropertyValue(PROPERTYID idProp, VARIANT * pRetVal) break; default: - Log("UIATextElement: Unhandled property"); + BridgeLog("UIATextElement: Unhandled property"); break; } return S_OK; From 45e93927a0e77694b2d6afda8aafb0160929cbc2 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Fri, 1 Nov 2013 05:09:37 -0500 Subject: [PATCH 591/795] Bug 930995 - Display port should be set sync when the apz requests a repaint. r=kats --- browser/metro/base/content/apzc.js | 48 +--- .../metro/base/content/bindings/browser.js | 72 +----- widget/windows/winrt/APZController.cpp | 236 +++++++++++++++--- widget/windows/winrt/APZController.h | 17 +- widget/windows/winrt/MetroWidget.cpp | 55 ++-- widget/windows/winrt/MetroWidget.h | 6 +- 6 files changed, 263 insertions(+), 171 deletions(-) diff --git a/browser/metro/base/content/apzc.js b/browser/metro/base/content/apzc.js index 705fe01fce89..59b26775f22f 100644 --- a/browser/metro/base/content/apzc.js +++ b/browser/metro/base/content/apzc.js @@ -9,8 +9,7 @@ let Cu = Components.utils; let Cr = Components.results; /** - * Handler for APZC display port and pan begin/end notifications. - * These notifications are only sent by widget/windows/winrt code when + * Misc. front end utilities for apzc management. * the pref: layers.async-pan-zoom.enabled is true. */ @@ -29,7 +28,6 @@ var APZCObserver = { } let os = Services.obs; - os.addObserver(this, "apzc-request-content-repaint", false); os.addObserver(this, "apzc-handle-pan-begin", false); os.addObserver(this, "apzc-handle-pan-end", false); @@ -42,6 +40,10 @@ var APZCObserver = { switch (aEvent.type) { case 'pageshow': case 'TabSelect': + // ROOT_ID doesn't really identify the view we want. When we call + // this on a content document (tab), findElementWithViewId will + // always return the root content document associated with the + // scrollable frame. const ROOT_ID = 1; let windowUtils = Browser.selectedBrowser.contentWindow. QueryInterface(Ci.nsIInterfaceRequestor). @@ -73,6 +75,7 @@ var APZCObserver = { } } }, + shutdown: function shutdown() { if (!this._enabled) { return; @@ -82,45 +85,12 @@ var APZCObserver = { Elements.tabList.removeEventListener("TabClose", this, true); let os = Services.obs; - os.removeObserver(this, "apzc-request-content-repaint"); os.removeObserver(this, "apzc-handle-pan-begin"); os.removeObserver(this, "apzc-handle-pan-end"); }, + observe: function ao_observe(aSubject, aTopic, aData) { - if (aTopic == "apzc-request-content-repaint") { - let frameMetrics = JSON.parse(aData); - let scrollId = frameMetrics.scrollId; - let scrollTo = frameMetrics.scrollTo; - let displayPort = frameMetrics.displayPort; - let resolution = frameMetrics.resolution; - let compositedRect = frameMetrics.compositedRect; - - let windowUtils = Browser.selectedBrowser.contentWindow. - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIDOMWindowUtils); - windowUtils.setScrollPositionClampingScrollPortSize(compositedRect.width, - compositedRect.height); - Browser.selectedBrowser.messageManager.sendAsyncMessage("Content:SetDisplayPort", { - scrollX: scrollTo.x, - scrollY: scrollTo.y, - x: displayPort.x + scrollTo.x, - y: displayPort.y + scrollTo.y, - w: displayPort.width, - h: displayPort.height, - scale: resolution, - id: scrollId - }); - - if (this._debugEvents) { - Util.dumpLn("APZC scrollId: " + scrollId); - Util.dumpLn("APZC scrollTo.x: " + scrollTo.x + ", scrollTo.y: " + scrollTo.y); - Util.dumpLn("APZC setResolution: " + resolution); - Util.dumpLn("APZC setDisplayPortForElement: displayPort.x: " + - displayPort.x + ", displayPort.y: " + displayPort.y + - ", displayPort.width: " + displayPort.width + - ", displayort.height: " + displayPort.height); - } - } else if (aTopic == "apzc-handle-pan-begin") { + if (aTopic == "apzc-handle-pan-begin") { // When we're panning, hide the main scrollbars by setting imprecise // input (which sets a property on the browser which hides the scrollbar // via CSS). This reduces jittering from left to right. We may be able @@ -141,7 +111,7 @@ var APZCObserver = { // its scroll offset data. case "Browser:ContentScroll": { let data = json.viewId + " " + json.presShellId + " (" + json.scrollOffset.x + ", " + json.scrollOffset.y + ")"; - Services.obs.notifyObservers(null, "scroll-offset-changed", data); + Services.obs.notifyObservers(null, "apzc-scroll-offset-changed", data); break; } } diff --git a/browser/metro/base/content/bindings/browser.js b/browser/metro/base/content/bindings/browser.js index 846c3aa0da97..aa0e070aac55 100644 --- a/browser/metro/base/content/bindings/browser.js +++ b/browser/metro/base/content/bindings/browser.js @@ -552,7 +552,6 @@ let ContentScroll = { _scrollOffset: { x: 0, y: 0 }, init: function() { - addMessageListener("Content:SetDisplayPort", this); addMessageListener("Content:SetWindowSize", this); if (Services.prefs.getBoolPref("layers.async-pan-zoom.enabled")) { @@ -575,77 +574,9 @@ let ContentScroll = { return { x: aElement.scrollLeft, y: aElement.scrollTop }; }, - setScrollOffsetForElement: function(aElement, aLeft, aTop) { - if (aElement.parentNode == aElement.ownerDocument) { - aElement.ownerDocument.defaultView.scrollTo(aLeft, aTop); - } else { - aElement.scrollLeft = aLeft; - aElement.scrollTop = aTop; - } - }, - receiveMessage: function(aMessage) { let json = aMessage.json; switch (aMessage.name) { - // Sent to us from chrome when the the apz has requested that the - // display port be updated and that content should repaint. - case "Content:SetDisplayPort": { - // Set resolution for root view - let rootCwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); - if (json.id == 1) { - rootCwu.setResolution(json.scale, json.scale); - if (!WebProgressListener._firstPaint) - break; - } - - let displayport = new Rect(json.x, json.y, json.w, json.h); - if (displayport.isEmpty()) - break; - - // Map ID to element - let element = null; - try { - element = rootCwu.findElementWithViewId(json.id); - } catch(e) { - // This could give NS_ERROR_NOT_AVAILABLE. In that case, the - // presshell is not available because the page is reloading. - } - - if (!element) - break; - - let binding = element.ownerDocument.getBindingParent(element); - if (binding instanceof Ci.nsIDOMHTMLInputElement && binding.mozIsTextField(false)) - break; - - // Set the scroll offset for this element if specified - if (json.scrollX >= 0 || json.scrollY >= 0) { - this.setScrollOffsetForElement(element, json.scrollX, json.scrollY); - if (element == content.document.documentElement) { - // scrollTo can make some small adjustments to the offset before - // actually scrolling the document. To ensure that _scrollOffset - // actually matches the offset stored in the window, re-query it. - this._scrollOffset = this.getScrollOffset(content); - } - } - - // Set displayport. We want to set this after setting the scroll offset, because - // it is calculated based on the scroll offset. - let scrollOffset = this.getScrollOffsetForElement(element); - let x = displayport.x - scrollOffset.x; - let y = displayport.y - scrollOffset.y; - - if (json.id == 1) { - x = Math.round(x * json.scale) / json.scale; - y = Math.round(y * json.scale) / json.scale; - } - - let win = element.ownerDocument.defaultView; - let winCwu = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); - winCwu.setDisplayPortForElement(x, y, displayport.width, displayport.height, element); - break; - } - case "Content:SetWindowSize": { let cwu = content.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils); cwu.setCSSViewport(json.width, json.height); @@ -704,8 +635,7 @@ let ContentScroll = { if (target == content.document) { if (this._scrollOffset.x == scrollOffset.x && this._scrollOffset.y == scrollOffset.y) { // Don't send a scroll message back to APZC if it's the same as the - // last one set by APZC. We use this to avoid sending APZC back an - // event that it originally triggered. + // last one. return; } this._scrollOffset = scrollOffset; diff --git a/widget/windows/winrt/APZController.cpp b/widget/windows/winrt/APZController.cpp index a9bad89671ab..8853471d0b7d 100644 --- a/widget/windows/winrt/APZController.cpp +++ b/widget/windows/winrt/APZController.cpp @@ -8,57 +8,201 @@ #include "nsThreadUtils.h" #include "MetroUtils.h" #include "nsPrintfCString.h" +#include "nsIWidgetListener.h" +#include "APZCCallbackHelper.h" +#include "nsIDocument.h" +#include "nsPresContext.h" +#include "nsIDOMElement.h" +#include "mozilla/dom/Element.h" +#include "nsIDOMWindowUtils.h" +#include "nsIInterfaceRequestorUtils.h" + +//#define DEBUG_CONTROLLER 1 + +#ifdef DEBUG_CONTROLLER +#include "WinUtils.h" +using namespace mozilla::widget; +#endif namespace mozilla { namespace widget { namespace winrt { +nsRefPtr APZController::sAPZC; + +/* + * Metro layout specific - test to see if a sub document is a + * tab. + */ +static bool +IsTab(nsCOMPtr& aSubDocument) +{ + nsRefPtr parent = aSubDocument->GetParentDocument(); + if (!parent) { + NS_WARNING("huh? IsTab should always get a sub document for a parameter"); + return false; + } + return parent->IsRootDisplayDocument(); +} + +/* + * Returns the sub document associated with the scroll id. + */ +static bool +GetDOMTargets(nsIPresShell* aPresShell, uint64_t aScrollId, + nsCOMPtr& aSubDocument, + nsCOMPtr& aTargetElement) +{ + MOZ_ASSERT(aPresShell); + nsRefPtr rootDocument = aPresShell->GetDocument(); + if (!rootDocument) { + return false; + } + nsCOMPtr rootUtils; + nsCOMPtr rootWindow = rootDocument->GetDefaultView(); + if (!rootWindow) { + return false; + } + rootUtils = do_GetInterface(rootWindow); + if (!rootUtils) { + return false; + } + + // For tabs and subframes this will return the HTML sub document + rootUtils->FindElementWithViewId(aScrollId, getter_AddRefs(aTargetElement)); + if (!aTargetElement) { + return false; + } + nsCOMPtr domElement = do_QueryInterface(aTargetElement); + if (!domElement) { + return false; + } + + aSubDocument = domElement->OwnerDoc(); + + if (!aSubDocument) { + return false; + } + + // If the root element equals domElement, FindElementWithViewId found + // a document, vs. an element within a document. + if (aSubDocument->GetRootElement() == domElement && IsTab(aSubDocument)) { + aTargetElement = nullptr; + } + + return true; +} + class RequestContentRepaintEvent : public nsRunnable { - typedef mozilla::layers::FrameMetrics FrameMetrics; + typedef mozilla::layers::FrameMetrics FrameMetrics; public: - RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics) : mFrameMetrics(aFrameMetrics) - { + RequestContentRepaintEvent(const FrameMetrics& aFrameMetrics, + nsIWidgetListener* aListener, + CSSIntPoint* aLastOffsetOut) : + mFrameMetrics(aFrameMetrics), + mWidgetListener(aListener), + mLastOffsetOut(aLastOffsetOut) + { + } + + NS_IMETHOD Run() { + // This event shuts down the worker thread and so must be main thread. + MOZ_ASSERT(NS_IsMainThread()); + +#ifdef DEBUG_CONTROLLER + WinUtils::Log("APZController: mScrollOffset: %f %f", mFrameMetrics.mScrollOffset.x, + mFrameMetrics.mScrollOffset.y); +#endif + + nsIPresShell* presShell = mWidgetListener->GetPresShell(); + if (!presShell) { + return NS_OK; } - NS_IMETHOD Run() { - // This event shuts down the worker thread and so must be main thread. - MOZ_ASSERT(NS_IsMainThread()); - - CSSToScreenScale resolution = mFrameMetrics.mZoom; - CSSRect compositedRect = mFrameMetrics.CalculateCompositedRectInCssPixels(); - - NS_ConvertASCIItoUTF16 data(nsPrintfCString("{ " \ - " \"resolution\": %.2f, " \ - " \"scrollId\": %d, " \ - " \"compositedRect\": { \"width\": %d, \"height\": %d }, " \ - " \"displayPort\": { \"x\": %d, \"y\": %d, \"width\": %d, \"height\": %d }, " \ - " \"scrollTo\": { \"x\": %d, \"y\": %d }" \ - "}", - (float)(resolution.scale / mFrameMetrics.mDevPixelsPerCSSPixel.scale), - (int)mFrameMetrics.mScrollId, - (int)compositedRect.width, - (int)compositedRect.height, - (int)mFrameMetrics.mDisplayPort.x, - (int)mFrameMetrics.mDisplayPort.y, - (int)mFrameMetrics.mDisplayPort.width, - (int)mFrameMetrics.mDisplayPort.height, - (int)mFrameMetrics.mScrollOffset.x, - (int)mFrameMetrics.mScrollOffset.y)); - - MetroUtils::FireObserver("apzc-request-content-repaint", data.get()); - return NS_OK; + nsCOMPtr subDocument; + nsCOMPtr targetElement; + if (!GetDOMTargets(presShell, mFrameMetrics.mScrollId, + subDocument, targetElement)) { + return NS_OK; } + + // If we're dealing with a sub frame or content editable element, + // call UpdateSubFrame. + if (targetElement) { +#ifdef DEBUG_CONTROLLER + WinUtils::Log("APZController: detected subframe or content editable"); +#endif + nsCOMPtr content = do_QueryInterface(targetElement); + if (content) { + APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics); + } + return NS_OK; + } + +#ifdef DEBUG_CONTROLLER + WinUtils::Log("APZController: detected tab"); +#endif + + // We're dealing with a tab, call UpdateRootFrame. + nsCOMPtr utils; + nsCOMPtr window = subDocument->GetDefaultView(); + if (window) { + utils = do_GetInterface(window); + if (utils) { + APZCCallbackHelper::UpdateRootFrame(utils, mFrameMetrics); + + // Return the actual scroll value so we can use it to filter + // out scroll messages triggered by setting the display port. + CSSIntPoint actualScrollOffset; + utils->GetScrollXY(false, &actualScrollOffset.x, &actualScrollOffset.y); + if (mLastOffsetOut) { + *mLastOffsetOut = actualScrollOffset; + } + +#ifdef DEBUG_CONTROLLER + WinUtils::Log("APZController: %I64d mDisplayPort: %0.2f %0.2f %0.2f %0.2f", + mFrameMetrics.mScrollId, + mFrameMetrics.mDisplayPort.x, + mFrameMetrics.mDisplayPort.y, + mFrameMetrics.mDisplayPort.width, + mFrameMetrics.mDisplayPort.height); +#endif + } + } + return NS_OK; + } protected: - const FrameMetrics mFrameMetrics; + FrameMetrics mFrameMetrics; + nsIWidgetListener* mWidgetListener; + CSSIntPoint* mLastOffsetOut; }; +void +APZController::SetWidgetListener(nsIWidgetListener* aWidgetListener) +{ + mWidgetListener = aWidgetListener; +} + +// APZC sends us this request when we need to update the display port on +// the scrollable frame the apzc is managing. void APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) { // Send the result back to the main thread so that it can shutdown - nsCOMPtr r1 = new RequestContentRepaintEvent(aFrameMetrics); + if (!mWidgetListener) { + NS_WARNING("Can't update display port, !mWidgetListener"); + return; + } + +#ifdef DEBUG_CONTROLLER + WinUtils::Log("APZController::RequestContentRepaint scroll id = %I64d", + aFrameMetrics.mScrollId); +#endif + nsCOMPtr r1 = new RequestContentRepaintEvent(aFrameMetrics, + mWidgetListener, + &mLastScrollOffset); if (!NS_IsMainThread()) { NS_DispatchToMainThread(r1); } else { @@ -66,6 +210,27 @@ APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics) } } +// Content send us this when it detect content has scrolled via +// a dom scroll event. Note we get these in response to dom scroll +// events and as a result of apzc scrolling which we filter out. +void +APZController::UpdateScrollOffset(const mozilla::layers::ScrollableLayerGuid& aScrollLayerId, + CSSIntPoint& aScrollOffset) +{ +#ifdef DEBUG_CONTROLLER + WinUtils::Log("APZController::UpdateScrollOffset: %d %d == %d %d", + aScrollOffset.x, aScrollOffset.y, + mLastScrollOffset.x, mLastScrollOffset.y); +#endif + + if (!sAPZC || mLastScrollOffset == aScrollOffset) { + return; + } + sAPZC->UpdateScrollOffset(aScrollLayerId, aScrollOffset); +} + +// Gesture event handlers from the APZC. Currently not in use. + void APZController::HandleDoubleTap(const CSSIntPoint& aPoint) { @@ -81,8 +246,11 @@ APZController::HandleLongTap(const CSSIntPoint& aPoint) { } +// requests that we send a mozbrowserasyncscroll domevent. not in use. void -APZController::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize) +APZController::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, + const CSSRect &aContentRect, + const CSSSize &aScrollableSize) { } @@ -92,6 +260,8 @@ APZController::PostDelayedTask(Task* aTask, int aDelayMs) MessageLoop::current()->PostDelayedTask(FROM_HERE, aTask, aDelayMs); } +// async scroll notifications + void APZController::HandlePanBegin() { diff --git a/widget/windows/winrt/APZController.h b/widget/windows/winrt/APZController.h index 8542b2fd94f1..fbfd733710b6 100644 --- a/widget/windows/winrt/APZController.h +++ b/widget/windows/winrt/APZController.h @@ -7,18 +7,23 @@ #include "mozwrlbase.h" #include "mozilla/layers/GeckoContentController.h" +#include "mozilla/layers/APZCTreeManager.h" #include "FrameMetrics.h" #include "Units.h" +class nsIWidgetListener; + namespace mozilla { namespace widget { namespace winrt { -class APZController : public mozilla::layers::GeckoContentController +class APZController : + public mozilla::layers::GeckoContentController { typedef mozilla::layers::FrameMetrics FrameMetrics; public: + // GeckoContentController interface virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics); virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint); virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint); @@ -27,6 +32,16 @@ public: virtual void PostDelayedTask(Task* aTask, int aDelayMs); virtual void HandlePanBegin(); virtual void HandlePanEnd(); + + void SetWidgetListener(nsIWidgetListener* aWidgetListener); + void UpdateScrollOffset(const mozilla::layers::ScrollableLayerGuid& aScrollLayerId, CSSIntPoint& aScrollOffset); + +public: + static nsRefPtr sAPZC; + +private: + nsIWidgetListener* mWidgetListener; + CSSIntPoint mLastScrollOffset; }; } } } \ No newline at end of file diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp index cdf9cb09922f..ba210ff39ad4 100644 --- a/widget/windows/winrt/MetroWidget.cpp +++ b/widget/windows/winrt/MetroWidget.cpp @@ -61,7 +61,6 @@ extern PRLogModuleInfo* gWindowsLog; static uint32_t gInstanceCount = 0; const PRUnichar* kMetroSubclassThisProp = L"MetroSubclassThisProp"; HWND MetroWidget::sICoreHwnd = nullptr; -nsRefPtr MetroWidget::sAPZC; namespace mozilla { namespace widget { @@ -186,7 +185,7 @@ MetroWidget::~MetroWidget() // Global shutdown if (!gInstanceCount) { - MetroWidget::sAPZC = nullptr; + APZController::sAPZC = nullptr; nsTextStore::Terminate(); } // !gInstanceCount } @@ -278,7 +277,7 @@ MetroWidget::Destroy() nsresult rv; nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); if (NS_SUCCEEDED(rv)) { - observerService->RemoveObserver(this, "scroll-offset-changed"); + observerService->RemoveObserver(this, "apzc-scroll-offset-changed"); } } @@ -939,22 +938,34 @@ MetroWidget::ShouldUseAPZC() Preferences::GetBool(kPrefName, false); } +void +MetroWidget::SetWidgetListener(nsIWidgetListener* aWidgetListener) +{ + mWidgetListener = aWidgetListener; + if (mController) { + mController->SetWidgetListener(aWidgetListener); + } +} + CompositorParent* MetroWidget::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight) { CompositorParent *compositor = nsBaseWidget::NewCompositorParent(aSurfaceWidth, aSurfaceHeight); if (ShouldUseAPZC()) { mRootLayerTreeId = compositor->RootLayerTreeId(); + mController = new APZController(); + mController->SetWidgetListener(mWidgetListener); + CompositorParent::SetControllerForLayerTree(mRootLayerTreeId, mController); - MetroWidget::sAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId()); - MetroWidget::sAPZC->SetDPI(GetDPI()); + APZController::sAPZC = CompositorParent::GetAPZCTreeManager(compositor->RootLayerTreeId()); + APZController::sAPZC->SetDPI(GetDPI()); nsresult rv; nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); if (NS_SUCCEEDED(rv)) { - observerService->AddObserver(this, "scroll-offset-changed", false); + observerService->AddObserver(this, "apzc-scroll-offset-changed", false); } } @@ -965,29 +976,29 @@ void MetroWidget::ApzContentConsumingTouch() { LogFunction(); - if (!MetroWidget::sAPZC) { + if (!APZController::sAPZC) { return; } - MetroWidget::sAPZC->ContentReceivedTouch(mRootLayerTreeId, true); + APZController::sAPZC->ContentReceivedTouch(mRootLayerTreeId, true); } void MetroWidget::ApzContentIgnoringTouch() { LogFunction(); - if (!MetroWidget::sAPZC) { + if (!APZController::sAPZC) { return; } - MetroWidget::sAPZC->ContentReceivedTouch(mRootLayerTreeId, false); + APZController::sAPZC->ContentReceivedTouch(mRootLayerTreeId, false); } bool MetroWidget::HitTestAPZC(ScreenPoint& pt) { - if (!MetroWidget::sAPZC) { + if (!APZController::sAPZC) { return false; } - return MetroWidget::sAPZC->HitTestAPZC(pt); + return APZController::sAPZC->HitTestAPZC(pt); } nsEventStatus @@ -995,10 +1006,10 @@ MetroWidget::ApzReceiveInputEvent(WidgetInputEvent* aEvent) { MOZ_ASSERT(aEvent); - if (!MetroWidget::sAPZC) { + if (!APZController::sAPZC) { return nsEventStatus_eIgnore; } - return MetroWidget::sAPZC->ReceiveInputEvent(*aEvent->AsInputEvent()); + return APZController::sAPZC->ReceiveInputEvent(*aEvent->AsInputEvent()); } nsEventStatus @@ -1008,11 +1019,11 @@ MetroWidget::ApzReceiveInputEvent(WidgetInputEvent* aInEvent, MOZ_ASSERT(aInEvent); MOZ_ASSERT(aOutEvent); - if (!MetroWidget::sAPZC) { + if (!APZController::sAPZC) { return nsEventStatus_eIgnore; } - return MetroWidget::sAPZC->ReceiveInputEvent(*aInEvent->AsInputEvent(), - aOutEvent); + return APZController::sAPZC->ReceiveInputEvent(*aInEvent->AsInputEvent(), + aOutEvent); } LayerManager* @@ -1515,7 +1526,7 @@ NS_IMETHODIMP MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *data) { NS_ENSURE_ARG_POINTER(topic); - if (!strcmp(topic, "scroll-offset-changed")) { + if (!strcmp(topic, "apzc-scroll-offset-changed")) { uint64_t scrollId; int32_t presShellId; CSSIntPoint scrollOffset; @@ -1529,11 +1540,11 @@ MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *d NS_WARNING("Malformed scroll-offset-changed message"); return NS_ERROR_UNEXPECTED; } - if (MetroWidget::sAPZC) { - MetroWidget::sAPZC->UpdateScrollOffset( - ScrollableLayerGuid(mRootLayerTreeId, presShellId, scrollId), - scrollOffset); + if (!mController) { + return NS_ERROR_UNEXPECTED; } + mController->UpdateScrollOffset(ScrollableLayerGuid(mRootLayerTreeId, presShellId, scrollId), + scrollOffset); } return NS_OK; } diff --git a/widget/windows/winrt/MetroWidget.h b/widget/windows/winrt/MetroWidget.h index 37d924dea3eb..15b2da9121a7 100644 --- a/widget/windows/winrt/MetroWidget.h +++ b/widget/windows/winrt/MetroWidget.h @@ -22,7 +22,6 @@ #endif #include "mozilla/EventForwards.h" #include "mozilla/layers/CompositorParent.h" -#include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/LayerManagerComposite.h" #include "nsDeque.h" #include "APZController.h" @@ -85,6 +84,7 @@ public: // nsBaseWidget virtual CompositorParent* NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight); + virtual void SetWidgetListener(nsIWidgetListener* aWidgetListener); // nsIWidget interface NS_IMETHOD Create(nsIWidget *aParent, @@ -235,10 +235,6 @@ protected: void DispatchAsyncScrollEvent(DispatchMsg* aEvent); void DeliverNextScrollEvent(); void DeliverNextKeyboardEvent(); - DispatchMsg* CreateDispatchMsg(UINT aMsg, WPARAM aWParam, LPARAM aLParam); - -public: - static nsRefPtr sAPZC; protected: OleInitializeWrapper mOleInitializeWrapper; From dddd9e2bd7f9b4128fbfe1a4f89fb607fb05dec7 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 1 Nov 2013 12:08:37 +0100 Subject: [PATCH 592/795] Backed out changeset 109710b0f5f6 (bug 754344) --- browser/base/content/utilityOverlay.js | 46 ++--- browser/components/nsBrowserContentHandler.js | 6 +- browser/components/preferences/handlers.css | 4 +- .../preferences/in-content/advanced.xul | 5 + .../preferences/in-content/applications.xul | 5 + .../preferences/in-content/content.xul | 7 +- .../components/preferences/in-content/jar.mn | 1 + .../preferences/in-content/landing.xul | 55 ++++++ .../preferences/in-content/main.xul | 11 +- .../preferences/in-content/preferences.js | 37 +--- .../preferences/in-content/preferences.xul | 64 +------ .../preferences/in-content/privacy.xul | 5 + .../preferences/in-content/security.xul | 7 +- .../preferences/in-content/sync.xul | 5 + .../chrome/browser/preferences/content.dtd | 2 - .../chrome/browser/preferences/security.dtd | 2 - browser/themes/linux/jar.mn | 2 +- .../themes/linux/preferences/applications.css | 4 +- .../preferences/in-content/preferences.css | 174 ++++++++--------- browser/themes/osx/jar.mn | 2 +- .../themes/osx/preferences/applications.css | 4 +- .../preferences/in-content/preferences.css | 177 ++++++++--------- browser/themes/windows/jar.mn | 4 +- .../windows/preferences/applications.css | 4 +- .../preferences/in-content/preferences.css | 178 ++++++++---------- 25 files changed, 374 insertions(+), 437 deletions(-) create mode 100644 browser/components/preferences/in-content/landing.xul diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index 7046a56e20c1..8c5e9fa72140 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -473,37 +473,8 @@ function openAboutDialog() { function openPreferences(paneID, extraArgs) { - function switchToAdvancedSubPane(doc) { - if (extraArgs && extraArgs["advancedTab"]) { - let advancedPaneTabs = doc.getElementById("advancedPrefs"); - advancedPaneTabs.selectedTab = doc.getElementById(extraArgs["advancedTab"]); - } - } - - if (getBoolPref("browser.preferences.inContent")) { - let win = Services.wm.getMostRecentWindow("navigator:browser"); - if (!win) { - return; - } - - let newLoad = !win.switchToTabHavingURI("about:preferences", true); - let browser = win.gBrowser.selectedBrowser; - - function switchToPane() { - if (paneID) { - browser.contentWindow.selectCategory(paneID); - } - switchToAdvancedSubPane(browser.contentDocument); - } - - if (newLoad) { - browser.addEventListener("load", function onload() { - browser.removeEventListener("load", onload, true); - switchToPane(); - }, true); - } else { - switchToPane(); - } + if (Services.prefs.getBoolPref("browser.preferences.inContent")) { + openUILinkIn("about:preferences", "tab"); } else { var instantApply = getBoolPref("browser.preferences.instantApply", false); var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal"); @@ -516,11 +487,16 @@ function openPreferences(paneID, extraArgs) win.document.documentElement.showPane(pane); } - switchToAdvancedSubPane(win.document); - } else { - openDialog("chrome://browser/content/preferences/preferences.xul", - "Preferences", features, paneID, extraArgs); + if (extraArgs && extraArgs["advancedTab"]) { + var advancedPaneTabs = win.document.getElementById("advancedPrefs"); + advancedPaneTabs.selectedTab = win.document.getElementById(extraArgs["advancedTab"]); + } + + return; } + + openDialog("chrome://browser/content/preferences/preferences.xul", + "Preferences", features, paneID, extraArgs); } } diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index 1624089522b4..f129168609b0 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -452,10 +452,8 @@ nsBrowserContentHandler.prototype = { var chromeParam = cmdLine.handleFlagWithParam("chrome", false); if (chromeParam) { - // Handle old preference dialog URLs. - if (chromeParam == "chrome://browser/content/pref/pref.xul" || - (Services.prefs.getBoolPref("browser.preferences.inContent") && - chromeParam == "chrome://browser/content/preferences/preferences.xul")) { + // Handle the old preference dialog URL separately (bug 285416) + if (chromeParam == "chrome://browser/content/pref/pref.xul") { openPreferences(); cmdLine.preventDefault = true; } else try { diff --git a/browser/components/preferences/handlers.css b/browser/components/preferences/handlers.css index abac7d575e9f..9a1d47446d09 100644 --- a/browser/components/preferences/handlers.css +++ b/browser/components/preferences/handlers.css @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#handlersView > richlistitem { +richlistitem { -moz-binding: url("chrome://browser/content/preferences/handlers.xml#handler"); } -#handlersView > richlistitem[selected="true"] { +richlistitem[selected="true"] { -moz-binding: url("chrome://browser/content/preferences/handlers.xml#handler-selected"); } diff --git a/browser/components/preferences/in-content/advanced.xul b/browser/components/preferences/in-content/advanced.xul index 9231fe4972c9..40781fe7e31b 100644 --- a/browser/components/preferences/in-content/advanced.xul +++ b/browser/components/preferences/in-content/advanced.xul @@ -128,6 +128,11 @@ #endif + +