Merge m-c into s-c

This commit is contained in:
Gregory Szorc 2012-03-06 14:01:51 -08:00
commit 6c1283fdec
193 changed files with 4788 additions and 2770 deletions

View File

@ -969,10 +969,8 @@ void nsAccessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame
*aBoundingFrame = ancestorFrame;
// If any other frame type, we only need to deal with the primary frame
// Otherwise, there may be more frames attached to the same content node
if (!nsCoreUtils::IsCorrectFrameType(ancestorFrame,
nsGkAtoms::inlineFrame) &&
!nsCoreUtils::IsCorrectFrameType(ancestorFrame,
nsGkAtoms::textFrame))
if (ancestorFrame->GetType() != nsGkAtoms::inlineFrame &&
ancestorFrame->GetType() != nsGkAtoms::textFrame)
break;
ancestorFrame = ancestorFrame->GetParent();
}
@ -996,8 +994,7 @@ void nsAccessible::GetBoundsRect(nsRect& aTotalBounds, nsIFrame** aBoundingFrame
nsIFrame *iterNextFrame = nsnull;
if (nsCoreUtils::IsCorrectFrameType(iterFrame,
nsGkAtoms::inlineFrame)) {
if (iterFrame->GetType() == nsGkAtoms::inlineFrame) {
// Only do deeper bounds search if we're on an inline frame
// Inline frames can contain larger frames inside of them
iterNextFrame = iterFrame->GetFirstPrincipalChild();

View File

@ -503,17 +503,6 @@ nsCoreUtils::IsErrorPage(nsIDocument *aDocument)
return StringBeginsWith(path, neterror) || StringBeginsWith(path, certerror);
}
bool
nsCoreUtils::IsCorrectFrameType(nsIFrame *aFrame, nsIAtom *aAtom)
{
NS_ASSERTION(aFrame != nsnull,
"aFrame is null in call to IsCorrectFrameType!");
NS_ASSERTION(aAtom != nsnull,
"aAtom is null in call to IsCorrectFrameType!");
return aFrame->GetType() == aAtom;
}
already_AddRefed<nsIDOMNode>
nsCoreUtils::GetDOMNodeForContainer(nsIDocShellTreeItem *aContainer)
{

View File

@ -241,14 +241,6 @@ public:
*/
static bool IsErrorPage(nsIDocument *aDocument);
/**
* Retrun true if the type of given frame equals to the given frame type.
*
* @param aFrame the frame
* @param aAtom the frame type
*/
static bool IsCorrectFrameType(nsIFrame* aFrame, nsIAtom* aAtom);
/**
* Return presShell for the document containing the given DOM node.
*/

View File

@ -384,14 +384,11 @@
{
if (SEAMONKEY) {
todo(false, "Skipping this test on SeaMonkey ftb. (Bug 718237)");
shutdownAutoComplete();
SimpleTest.finish();
return;
}
// register 'test-a11y-search' autocomplete search
initAutoComplete([ "hello", "hi" ],
[ "Beep beep'm beep beep yeah", "Baby you can drive my car" ]);
gInitQueue = new eventQueue();
gInitQueue.push(new loadFormAutoComplete("iframe"));
gInitQueue.push(new initFormAutoCompleteBy("iframe", "hello"));
@ -461,6 +458,12 @@
}
SimpleTest.waitForExplicitFinish();
// Register 'test-a11y-search' autocomplete search.
// XPFE AutoComplete needs to register early.
initAutoComplete([ "hello", "hi" ],
[ "Beep beep'm beep beep yeah", "Baby you can drive my car" ]);
addA11yLoadEvent(initTests);
]]>
</script>

View File

@ -35,10 +35,6 @@
var gQueue = null;
function doTest()
{
// register 'test-a11y-search' autocomplete search
initAutoComplete([ "hello", "hi" ],
[ "Beep beep'm beep beep yeah", "Baby you can drive my car" ]);
gQueue = new eventQueue();
gQueue.push(new openCombobox("menulist"));
@ -73,6 +69,12 @@
}
SimpleTest.waitForExplicitFinish();
// Register 'test-a11y-search' autocomplete search.
// XPFE AutoComplete needs to register early.
initAutoComplete([ "hello", "hi" ],
[ "Beep beep'm beep beep yeah", "Baby you can drive my car" ]);
addA11yLoadEvent(doTest);
]]>
</script>

View File

@ -181,7 +181,11 @@ const ContentPanning = {
case 'click':
evt.stopPropagation();
evt.preventDefault();
evt.target.removeEventListener('click', this, true);
let target = evt.target;
let view = target.ownerDocument ? target.ownerDocument.defaultView
: target;
view.removeEventListener('click', this, true, true);
break;
}
},
@ -190,16 +194,24 @@ const ContentPanning = {
onTouchStart: function cp_onTouchStart(evt) {
this.dragging = true;
this.panning = false;
let oldTarget = this.target;
[this.target, this.scrollCallback] = this.getPannable(evt.target);
// If there is a pan animation running (from a previous pan gesture) and
// the user touch back the screen, stop this animation immediatly and
// prevent the possible click action.
// prevent the possible click action if the touch happens on the same
// target.
this.preventNextClick = false;
if (KineticPanning.active) {
KineticPanning.stop();
this.preventNextClick = true;
if (oldTarget && oldTarget == this.target)
this.preventNextClick = true;
}
this.scrollCallback = this.getPannable(evt.originalTarget);
this.position.set(evt.screenX, evt.screenY);
KineticPanning.record(new Point(0, 0), evt.timeStamp);
},
@ -211,14 +223,15 @@ const ContentPanning = {
this.onTouchMove(evt);
let pan = KineticPanning.isPan();
let click = evt.detail;
if (click && (pan || this.preventNextClick))
evt.target.addEventListener('click', this, true);
if (this.target && click && (this.panning || this.preventNextClick)) {
let target = this.target;
let view = target.ownerDocument ? target.ownerDocument.defaultView
: target;
view.addEventListener('click', this, true, true);
}
this.preventNextClick = false;
if (pan)
if (this.panning)
KineticPanning.start(this);
},
@ -232,6 +245,13 @@ const ContentPanning = {
KineticPanning.record(delta, evt.timeStamp);
this.scrollCallback(delta.scale(-1));
// If a pan action happens, cancel the active state of the
// current target.
if (!this.panning && KineticPanning.isPan()) {
this.panning = true;
this._resetActive();
}
},
@ -249,7 +269,7 @@ const ContentPanning = {
getPannable: function cp_getPannable(node) {
if (!(node instanceof Ci.nsIDOMHTMLElement) || node.tagName == 'HTML')
return null;
return [null, null];
let content = node.ownerDocument.defaultView;
while (!(node instanceof Ci.nsIDOMHTMLBodyElement)) {
@ -266,12 +286,12 @@ const ContentPanning = {
let isScroll = (overflow.indexOf('scroll') != -1);
if (isScroll || isAuto)
return this._generateCallback(node);
return [node, this._generateCallback(node)];
node = node.parentNode;
}
return this._generateCallback(content);
return [content, this._generateCallback(content)];
},
_generateCallback: function cp_generateCallback(content) {
@ -290,6 +310,19 @@ const ContentPanning = {
}
}
return scroll;
},
get _domUtils() {
delete this._domUtils;
return this._domUtils = Cc['@mozilla.org/inspector/dom-utils;1']
.getService(Ci.inIDOMUtils);
},
_resetActive: function cp_resetActive() {
let root = this.target.ownerDocument || this.target.document;
const kStateActive = 0x00000001;
this._domUtils.setContentState(root.documentElement, kStateActive);
}
};
@ -370,6 +403,7 @@ const KineticPanning = {
return;
this.momentums = [];
this.distance.set(0, 0);
this.target.onKineticEnd();
this.target = null;
@ -378,23 +412,24 @@ const KineticPanning = {
momentums: [],
record: function kp_record(delta, timestamp) {
this.momentums.push({ 'time': timestamp, 'dx' : delta.x, 'dy' : delta.y });
this.distance.add(delta.x, delta.y);
},
isPan: function cp_isPan() {
get threshold() {
let dpi = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.displayDPI;
let threshold = Services.prefs.getIntPref('ui.dragThresholdX') / 240 * dpi;
let deltaX = 0;
let deltaY = 0;
let start = this.momentums[0].time;
return this.momentums.slice(1).some(function(momentum) {
deltaX += momentum.dx;
deltaY += momentum.dy;
return (Math.abs(deltaX) > threshold) || (Math.abs(deltaY) > threshold);
});
delete this.threshold;
return this.threshold = threshold;
},
distance: new Point(0, 0),
isPan: function cp_isPan() {
return (Math.abs(this.distance.x) > this.threshold ||
Math.abs(this.distance.y) > this.threshold);
},
_startAnimation: function kp_startAnimation() {

View File

@ -3989,10 +3989,22 @@ var FullScreen = {
}
},
exitDomFullScreen : function(e) {
exitDomFullScreen : function() {
document.mozCancelFullScreen();
},
handleEvent: function (event) {
switch (event.type) {
case "deactivate":
// We must call exitDomFullScreen asynchronously, since "deactivate" is
// dispatched in the middle of the focus manager's window lowering code,
// and the focus manager gets confused if we exit fullscreen mode in the
// middle of window lowering. See bug 729872.
setTimeout(this.exitDomFullScreen.bind(this), 0);
break;
}
},
enterDomFullScreen : function(event) {
if (!document.mozFullScreen) {
return;
@ -4039,7 +4051,7 @@ var FullScreen = {
// Exit DOM full-screen mode when the browser window loses focus (ALT+TAB, etc).
if (gPrefService.getBoolPref("full-screen-api.exit-on-deactivate")) {
window.addEventListener("deactivate", this.exitDomFullScreen, true);
window.addEventListener("deactivate", this);
}
// Cancel any "hide the toolbar" animation which is in progress, and make
@ -4074,7 +4086,7 @@ var FullScreen = {
gBrowser.tabContainer.removeEventListener("TabOpen", this.exitDomFullScreen);
gBrowser.tabContainer.removeEventListener("TabClose", this.exitDomFullScreen);
gBrowser.tabContainer.removeEventListener("TabSelect", this.exitDomFullScreen);
window.removeEventListener("deactivate", this.exitDomFullScreen, true);
window.removeEventListener("deactivate", this);
}
},
@ -6121,103 +6133,114 @@ function charsetLoadListener(event) {
}
}
/* Begin Page Style Functions */
function getAllStyleSheets(frameset) {
var styleSheetsArray = Array.slice(frameset.document.styleSheets);
for (let i = 0; i < frameset.frames.length; i++) {
let frameSheets = getAllStyleSheets(frameset.frames[i]);
styleSheetsArray = styleSheetsArray.concat(frameSheets);
}
return styleSheetsArray;
}
function stylesheetFillPopup(menuPopup) {
var noStyle = menuPopup.firstChild;
var persistentOnly = noStyle.nextSibling;
var sep = persistentOnly.nextSibling;
while (sep.nextSibling)
menuPopup.removeChild(sep.nextSibling);
var gPageStyleMenu = {
var styleSheets = getAllStyleSheets(window.content);
var currentStyleSheets = {};
var styleDisabled = getMarkupDocumentViewer().authorStyleDisabled;
var haveAltSheets = false;
var altStyleSelected = false;
getAllStyleSheets: function (frameset) {
var styleSheetsArray = Array.slice(frameset.document.styleSheets);
for (let i = 0; i < frameset.frames.length; i++) {
let frameSheets = this.getAllStyleSheets(frameset.frames[i]);
styleSheetsArray = styleSheetsArray.concat(frameSheets);
}
return styleSheetsArray;
},
for (let i = 0; i < styleSheets.length; ++i) {
let currentStyleSheet = styleSheets[i];
stylesheetFillPopup: function (menuPopup) {
var noStyle = menuPopup.firstChild;
var persistentOnly = noStyle.nextSibling;
var sep = persistentOnly.nextSibling;
while (sep.nextSibling)
menuPopup.removeChild(sep.nextSibling);
if (!currentStyleSheet.title)
continue;
var styleSheets = this.getAllStyleSheets(window.content);
var currentStyleSheets = {};
var styleDisabled = getMarkupDocumentViewer().authorStyleDisabled;
var haveAltSheets = false;
var altStyleSelected = false;
// Skip any stylesheets whose media attribute doesn't match.
if (currentStyleSheet.media.length > 0) {
let mediaQueryList = currentStyleSheet.media.mediaText;
if (!window.content.matchMedia(mediaQueryList).matches)
for (let i = 0; i < styleSheets.length; ++i) {
let currentStyleSheet = styleSheets[i];
if (!currentStyleSheet.title)
continue;
// Skip any stylesheets whose media attribute doesn't match.
if (currentStyleSheet.media.length > 0) {
let mediaQueryList = currentStyleSheet.media.mediaText;
if (!window.content.matchMedia(mediaQueryList).matches)
continue;
}
if (!currentStyleSheet.disabled)
altStyleSelected = true;
haveAltSheets = true;
let lastWithSameTitle = null;
if (currentStyleSheet.title in currentStyleSheets)
lastWithSameTitle = currentStyleSheets[currentStyleSheet.title];
if (!lastWithSameTitle) {
let menuItem = document.createElement("menuitem");
menuItem.setAttribute("type", "radio");
menuItem.setAttribute("label", currentStyleSheet.title);
menuItem.setAttribute("data", currentStyleSheet.title);
menuItem.setAttribute("checked", !currentStyleSheet.disabled && !styleDisabled);
menuPopup.appendChild(menuItem);
currentStyleSheets[currentStyleSheet.title] = menuItem;
} else if (currentStyleSheet.disabled) {
lastWithSameTitle.removeAttribute("checked");
}
}
if (!currentStyleSheet.disabled)
altStyleSelected = true;
noStyle.setAttribute("checked", styleDisabled);
persistentOnly.setAttribute("checked", !altStyleSelected && !styleDisabled);
persistentOnly.hidden = (window.content.document.preferredStyleSheetSet) ? haveAltSheets : false;
sep.hidden = (noStyle.hidden && persistentOnly.hidden) || !haveAltSheets;
return true;
},
haveAltSheets = true;
stylesheetInFrame: function (frame, title) {
return Array.some(frame.document.styleSheets,
function (stylesheet) stylesheet.title == title);
},
let lastWithSameTitle = null;
if (currentStyleSheet.title in currentStyleSheets)
lastWithSameTitle = currentStyleSheets[currentStyleSheet.title];
stylesheetSwitchFrame: function (frame, title) {
var docStyleSheets = frame.document.styleSheets;
if (!lastWithSameTitle) {
let menuItem = document.createElement("menuitem");
menuItem.setAttribute("type", "radio");
menuItem.setAttribute("label", currentStyleSheet.title);
menuItem.setAttribute("data", currentStyleSheet.title);
menuItem.setAttribute("checked", !currentStyleSheet.disabled && !styleDisabled);
menuPopup.appendChild(menuItem);
currentStyleSheets[currentStyleSheet.title] = menuItem;
} else if (currentStyleSheet.disabled) {
lastWithSameTitle.removeAttribute("checked");
for (let i = 0; i < docStyleSheets.length; ++i) {
let docStyleSheet = docStyleSheets[i];
if (title == "_nostyle")
docStyleSheet.disabled = true;
else if (docStyleSheet.title)
docStyleSheet.disabled = (docStyleSheet.title != title);
else if (docStyleSheet.disabled)
docStyleSheet.disabled = false;
}
}
},
noStyle.setAttribute("checked", styleDisabled);
persistentOnly.setAttribute("checked", !altStyleSelected && !styleDisabled);
persistentOnly.hidden = (window.content.document.preferredStyleSheetSet) ? haveAltSheets : false;
sep.hidden = (noStyle.hidden && persistentOnly.hidden) || !haveAltSheets;
return true;
}
stylesheetSwitchAll: function (frameset, title) {
if (!title || title == "_nostyle" || this.stylesheetInFrame(frameset, title))
this.stylesheetSwitchFrame(frameset, title);
function stylesheetInFrame(frame, title) {
return Array.some(frame.document.styleSheets,
function (stylesheet) stylesheet.title == title);
}
for (let i = 0; i < frameset.frames.length; i++)
this.stylesheetSwitchAll(frameset.frames[i], title);
},
function stylesheetSwitchFrame(frame, title) {
var docStyleSheets = frame.document.styleSheets;
setStyleDisabled: function (disabled) {
getMarkupDocumentViewer().authorStyleDisabled = disabled;
},
};
for (let i = 0; i < docStyleSheets.length; ++i) {
let docStyleSheet = docStyleSheets[i];
/* Legacy global page-style functions */
var getAllStyleSheets = gPageStyleMenu.getAllStyleSheets;
var stylesheetFillPopup = gPageStyleMenu.stylesheetFillPopup;
var stylesheetInFrame = gPageStyleMenu.stylesheetInFrame;
var stylesheetSwitchFrame = gPageStyleMenu.stylesheetSwitchFrame;
var stylesheetSwitchAll = gPageStyleMenu.stylesheetSwitchAll;
var setStyleDisabled = gPageStyleMenu.setStyleDisabled;
if (title == "_nostyle")
docStyleSheet.disabled = true;
else if (docStyleSheet.title)
docStyleSheet.disabled = (docStyleSheet.title != title);
else if (docStyleSheet.disabled)
docStyleSheet.disabled = false;
}
}
function stylesheetSwitchAll(frameset, title) {
if (!title || title == "_nostyle" || stylesheetInFrame(frameset, title))
stylesheetSwitchFrame(frameset, title);
for (let i = 0; i < frameset.frames.length; i++)
stylesheetSwitchAll(frameset.frames[i], title);
}
function setStyleDisabled(disabled) {
getMarkupDocumentViewer().authorStyleDisabled = disabled;
}
/* End of the Page Style functions */
var BrowserOffline = {
_inited: false,

View File

@ -42,7 +42,7 @@ let test_bookmarks = {
menu: [
{ title: "Mozilla Firefox",
children: [
{ title: "Help and Tutorials",
{ title: "Help and Tutorials",
url: "http://en-us.www.mozilla.com/en-US/firefox/help/",
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg=="
},
@ -57,8 +57,8 @@ let test_bookmarks = {
{ title: "About Us",
url: "http://en-us.www.mozilla.com/en-US/about/",
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg=="
},
],
}
]
},
{ title: "test",
description: "folder test comment",
@ -72,10 +72,10 @@ let test_bookmarks = {
keyword: "test",
sidebar: true,
postData: "hidden1%3Dbar&text1%3D%25s",
charset: "ISO-8859-1",
},
charset: "ISO-8859-1"
}
]
},
}
],
toolbar: [
{ title: "Getting Started",
@ -84,14 +84,14 @@ let test_bookmarks = {
},
{ title: "Latest Headlines",
url: "http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
feedUrl: "http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
feedUrl: "http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml"
}
],
unfiled: [
{ title: "Example.tld",
url: "http://example.tld/",
},
],
url: "http://example.tld/"
}
]
};
// Pre-Places bookmarks.html file pointer.
@ -303,6 +303,8 @@ add_test(function test_import_ontop()
function testImportedBookmarks()
{
for (let group in test_bookmarks) {
do_print("[testImportedBookmarks()] Checking group '" + group + "'");
let root;
switch (group) {
case "menu":
@ -335,6 +337,7 @@ function testImportedBookmarksToFolder(aFolder)
for (let i = 0; i < root.childCount; i++) {
let child = root.getChild(i);
// This check depends on all "menu" bookmarks being listed first in the imported file :-|
if (i < rootFolderCount) {
checkItem(test_bookmarks.menu[i], child);
}
@ -343,9 +346,8 @@ function testImportedBookmarksToFolder(aFolder)
let group = /Toolbar/.test(container.title) ? test_bookmarks.toolbar
: test_bookmarks.unfiled;
container.containerOpen = true;
print(container.title);
do_print("[testImportedBookmarksToFolder()] Checking container '" + container.title + "'");
for (let t = 0; t < container.childCount; t++) {
print(group[t].title + " " + container.getChild(t).title);
checkItem(group[t], container.getChild(t));
}
container.containerOpen = false;

View File

@ -1224,7 +1224,7 @@ toolbar[mode="full"] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
padding: 0;
background-clip: padding-box;
border: 1px solid ThreeDShadow;
border-radius: 2.5px;
border-radius: 2px;
}
#urlbar {

View File

@ -74,6 +74,6 @@
-moz-padding-start: 4px;
background-clip: padding-box;
border: 1px solid rgba(0,0,0,.32);
border-radius: 2.5px;
border-radius: 2px;
}
}

View File

@ -67,11 +67,12 @@ NS_IMPL_THREADSAFE_ADDREF(nsNullPrincipalURI)
NS_IMPL_THREADSAFE_RELEASE(nsNullPrincipalURI)
NS_INTERFACE_MAP_BEGIN(nsNullPrincipalURI)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURI)
if (aIID.Equals(kNullPrincipalURIImplementationCID))
foundInterface = static_cast<nsIURI *>(this);
else
NS_INTERFACE_MAP_ENTRY(nsIURI)
NS_INTERFACE_MAP_ENTRY(nsISizeOf)
NS_INTERFACE_MAP_END
////////////////////////////////////////////////////////////////////////////////
@ -299,3 +300,19 @@ nsNullPrincipalURI::SchemeIs(const char *aScheme, bool *_schemeIs)
*_schemeIs = (0 == nsCRT::strcasecmp(mScheme.get(), aScheme));
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
//// nsISizeOf
size_t
nsNullPrincipalURI::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return mScheme.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
mPath.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
size_t
nsNullPrincipalURI::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -45,6 +45,7 @@
#define __nsNullPrincipalURI_h__
#include "nsIURI.h"
#include "nsISizeOf.h"
#include "nsAutoPtr.h"
#include "nsString.h"
@ -54,11 +55,16 @@
{0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6} }
class nsNullPrincipalURI : public nsIURI
, public nsISizeOf
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIURI
// nsISizeOf
virtual size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
virtual size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
nsNullPrincipalURI(const nsCString &aSpec);
private:

View File

@ -9212,7 +9212,7 @@ if test -z "$MOZ_NATIVE_NSPR"; then
fi
if test "$MOZ_OPTIMIZE" = "1"; then
ac_configure_args="$ac_configure_args --enable-optimize"
else
elif test -z "$MOZ_OPTIMIZE"; then
ac_configure_args="$ac_configure_args --disable-optimize"
fi
if test -n "$HAVE_64BIT_OS"; then

View File

@ -41,6 +41,7 @@
#include "nsEventStates.h"
#include "nsIURL.h"
#include "nsISizeOf.h"
#include "nsContentUtils.h"
#include "nsEscape.h"
@ -531,5 +532,24 @@ Link::SetHrefAttribute(nsIURI *aURI)
NS_ConvertUTF8toUTF16(href), true);
}
size_t
Link::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
size_t n = 0;
if (mCachedURI) {
nsCOMPtr<nsISizeOf> iface = do_QueryInterface(mCachedURI);
if (iface) {
n += iface->SizeOfIncludingThis(aMallocSizeOf);
}
}
// The following members don't need to be measured:
// - mElement, because it is a pointer-to-self used to avoid QIs
// - mHistory, because it is non-owning
return n;
}
} // namespace dom
} // namespace mozilla

View File

@ -131,6 +131,9 @@ public:
*/
virtual bool HasDeferredDNSPrefetchRequest() { return true; }
virtual size_t
SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
protected:
virtual ~Link();

View File

@ -44,7 +44,6 @@
#include "nsNetUtil.h"
#include "nsIParser.h"
#include "nsParserCIID.h"
#include "nsICharsetAlias.h"
#include "nsMimeTypes.h"
#include "nsIStreamConverterService.h"
#include "nsStringStream.h"

View File

@ -43,7 +43,6 @@
#include "nsContentUtils.h"
#include "nsDOMClassInfoID.h"
#include "nsDOMError.h"
#include "nsICharsetAlias.h"
#include "nsICharsetDetector.h"
#include "nsICharsetConverterManager.h"
#include "nsIConverterInputStream.h"

View File

@ -42,7 +42,7 @@
#include "nsDOMClassInfoID.h"
#include "nsDOMFile.h"
#include "nsDOMError.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsICharsetDetector.h"
#include "nsICharsetConverterManager.h"
#include "nsIConverterInputStream.h"
@ -495,10 +495,7 @@ nsDOMFileReader::GetAsText(const nsACString &aCharset,
}
nsCAutoString charset;
nsCOMPtr<nsICharsetAlias> alias = do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = alias->GetPreferred(charsetGuess, charset);
rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
NS_ENSURE_SUCCESS(rv, rv);
rv = ConvertStream(aFileData, aDataLen, charset.get(), aResult);

View File

@ -147,7 +147,7 @@
#include "nsILink.h"
#include "nsBlobProtocolHandler.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsIParser.h"
#include "nsIContentSink.h"
@ -3012,13 +3012,10 @@ nsDocument::SetDocumentCharacterSet(const nsACString& aCharSetID)
mCharacterSet = aCharSetID;
#ifdef DEBUG
nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
if (calias) {
nsCAutoString canonicalName;
calias->GetPreferred(aCharSetID, canonicalName);
NS_ASSERTION(canonicalName.Equals(aCharSetID),
"charset name must be canonical");
}
nsCAutoString canonicalName;
nsCharsetAlias::GetPreferred(aCharSetID, canonicalName);
NS_ASSERTION(canonicalName.Equals(aCharSetID),
"charset name must be canonical");
#endif
PRInt32 n = mCharSetObservers.Length();
@ -3172,16 +3169,10 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel,
nsCAutoString charsetVal;
nsresult rv = aChannel->GetContentCharset(charsetVal);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID));
if (calias) {
nsCAutoString preferred;
rv = calias->GetPreferred(charsetVal,
preferred);
if(NS_SUCCEEDED(rv)) {
aCharset = preferred;
aCharsetSource = kCharsetFromChannel;
return true;
}
rv = nsCharsetAlias::GetPreferred(charsetVal, aCharset);
if(NS_SUCCEEDED(rv)) {
aCharsetSource = kCharsetFromChannel;
return true;
}
}
}

View File

@ -882,9 +882,7 @@ nsFrameScriptExecutor::InitTabChildGlobalInternal(nsISupports* aScope)
JS_SetContextPrivate(cx, aScope);
nsresult rv =
xpc->InitClassesWithNewWrappedGlobal(cx, aScope,
NS_GET_IID(nsISupports),
mPrincipal, nsnull,
xpc->InitClassesWithNewWrappedGlobal(cx, aScope, mPrincipal,
flags, getter_AddRefs(mGlobal));
NS_ENSURE_SUCCESS(rv, false);

View File

@ -61,7 +61,7 @@
#include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h"
#include "nsWeakPtr.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsIScriptGlobalObject.h"
#include "nsDOMClassInfoID.h"
#include "nsIDOMElement.h"
@ -812,11 +812,7 @@ nsXMLHttpRequest::DetectCharset()
nsresult rv = channel ? channel->GetContentCharset(charsetVal) :
NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> calias =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && calias) {
rv = calias->GetPreferred(charsetVal, mResponseCharset);
}
rv = nsCharsetAlias::GetPreferred(charsetVal, mResponseCharset);
}
if (NS_FAILED(rv) || mResponseCharset.IsEmpty()) {

View File

@ -60,7 +60,7 @@
#include "nsNetUtil.h"
#include "nsLinebreakConverter.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsEscape.h"
#include "nsUnicharUtils.h"
#include "nsIMultiplexInputStream.h"
@ -782,7 +782,6 @@ GetSubmitCharset(nsGenericHTMLElement* aForm,
{
oCharset.AssignLiteral("UTF-8"); // default to utf-8
nsresult rv = NS_OK;
nsAutoString acceptCharsetValue;
aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset,
acceptCharsetValue);
@ -792,26 +791,19 @@ GetSubmitCharset(nsGenericHTMLElement* aForm,
PRInt32 offset=0;
PRInt32 spPos=0;
// get charset from charsets one by one
nsCOMPtr<nsICharsetAlias> calias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv));
if (NS_FAILED(rv)) {
return;
}
if (calias) {
do {
spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
if (cnt > 0) {
nsAutoString uCharset;
acceptCharsetValue.Mid(uCharset, offset, cnt);
do {
spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
if (cnt > 0) {
nsAutoString uCharset;
acceptCharsetValue.Mid(uCharset, offset, cnt);
if (NS_SUCCEEDED(calias->
GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
oCharset)))
return;
}
offset = spPos + 1;
} while (spPos != -1);
}
if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
oCharset)))
return;
}
offset = spPos + 1;
} while (spPos != -1);
}
// if there are no accept-charset or all the charset are not supported
// Get the charset from document

View File

@ -96,8 +96,8 @@ public:
// nsIDOMHTMLAnchorElement
NS_DECL_NSIDOMHTMLANCHORELEMENT
// TODO: nsHTMLAnchorElement::SizeOfAnchorElement should call
// Link::SizeOfExcludingThis(). See bug 682431.
// DOM memory reporter participant
NS_DECL_SIZEOF_EXCLUDING_THIS
// nsILink
NS_IMETHOD LinkAdded() { return NS_OK; }
@ -520,3 +520,10 @@ nsHTMLAnchorElement::IntrinsicState() const
return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
}
size_t
nsHTMLAnchorElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -61,8 +61,8 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// TODO: nsHTMLAreaElement::SizeOfAnchorElement should call
// Link::SizeOfExcludingThis(). See bug 682431.
// DOM memory reporter participant
NS_DECL_SIZEOF_EXCLUDING_THIS
// nsIDOMNode
NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
@ -335,3 +335,11 @@ nsHTMLAreaElement::IntrinsicState() const
{
return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
}
size_t
nsHTMLAreaElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -84,8 +84,8 @@ public:
// nsIDOMHTMLLinkElement
NS_DECL_NSIDOMHTMLLINKELEMENT
// TODO: nsHTMLLinkElement::SizeOfAnchorElement should call
// Link::SizeOfExcludingThis(). See bug 682431.
// DOM memory reporter participant
NS_DECL_SIZEOF_EXCLUDING_THIS
// nsILink
NS_IMETHOD LinkAdded();
@ -458,3 +458,11 @@ nsHTMLLinkElement::IntrinsicState() const
{
return Link::LinkState() | nsGenericHTMLElement::IntrinsicState();
}
size_t
nsHTMLLinkElement::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
{
return nsGenericHTMLElement::SizeOfExcludingThis(aMallocSizeOf) +
Link::SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -40,8 +40,6 @@
#include "mozilla/Util.h"
#include "nsICharsetAlias.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsPrintfCString.h"
@ -102,7 +100,6 @@
#include "nsFrameSelection.h"
#include "nsISelectionPrivate.h"//for toStringwithformat code
#include "nsICharsetAlias.h"
#include "nsContentUtils.h"
#include "nsJSUtils.h"
#include "nsIDocumentEncoder.h" //for outputting selection

View File

@ -2019,6 +2019,13 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame()
// duration.
RenderVideoFrame(currentFrame, presTime);
}
// If we're no longer playing after dropping and reacquiring the lock,
// playback must've been stopped on the decode thread (by a seek, for
// example). In that case, the current frame is probably out of date.
if (!IsPlaying()) {
ScheduleStateMachine();
return;
}
mDecoder->GetFrameStatistics().NotifyPresentedFrame();
PRInt64 now = DurationToUsecs(TimeStamp::Now() - mPlayStartTime) + mPlayDuration;
remainingTime = currentFrame->mEndTime - mStartTime - now;

View File

@ -59,8 +59,6 @@
#include "nsIHttpChannel.h"
#include "nsIURI.h"
#include "nsIServiceManager.h"
#include "nsICharsetAlias.h"
#include "nsICharsetAlias.h"
#include "nsNetUtil.h"
#include "nsDOMError.h"
#include "nsIScriptSecurityManager.h"

View File

@ -39,7 +39,7 @@
#include "nsCOMArray.h"
#include "nsIAuthPrompt.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsIDOMNode.h"
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
@ -282,29 +282,23 @@ txStylesheetSink::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext,
NS_IMETHODIMP
txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
{
nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8"));
PRInt32 charsetSource = kCharsetFromDocTypeDefault;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
// check channel's charset...
nsCAutoString charsetVal;
nsresult rv = channel->GetContentCharset(charsetVal);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICharsetAlias> calias =
do_GetService(NS_CHARSETALIAS_CONTRACTID);
if (calias) {
nsCAutoString preferred;
rv = calias->GetPreferred(charsetVal,
preferred);
if (NS_SUCCEEDED(rv)) {
charset = preferred;
charsetSource = kCharsetFromChannel;
}
nsCAutoString charset;
if (NS_SUCCEEDED(channel->GetContentCharset(charsetVal))) {
if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charsetVal, charset))) {
charsetSource = kCharsetFromChannel;
}
}
if (charset.IsEmpty()) {
charset.AssignLiteral("UTF-8");
}
nsCOMPtr<nsIParser> parser = do_QueryInterface(aContext);
parser->SetDocumentCharset(charset, charsetSource);
@ -318,6 +312,7 @@ txStylesheetSink::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
bool sniff;
if (NS_SUCCEEDED(uri->SchemeIs("file", &sniff)) && sniff &&
contentType.Equals(UNKNOWN_CONTENT_TYPE)) {
nsresult rv;
nsCOMPtr<nsIStreamConverterService> serv =
do_GetService("@mozilla.org/streamConverters;1", &rv);
if (NS_SUCCEEDED(rv)) {

View File

@ -45,7 +45,7 @@
#include "nsIDocumentTransformer.h"
#include "nsNetUtil.h"
#include "nsIParser.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsIPrincipal.h"
#include "txURIUtils.h"
#include "nsContentCreatorFunctions.h"
@ -184,11 +184,9 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument)
if (!mOutputFormat.mEncoding.IsEmpty()) {
NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
nsCAutoString canonicalCharset;
nsCOMPtr<nsICharsetAlias> calias =
do_GetService("@mozilla.org/intl/charsetalias;1");
if (calias &&
NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charset,
canonicalCharset))) {
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
mDocument->SetDocumentCharacterSet(canonicalCharset);
}

View File

@ -64,7 +64,7 @@
#include "nsIDocumentTransformer.h"
#include "mozilla/css/Loader.h"
#include "mozilla/dom/Element.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsIHTMLContentSink.h"
#include "nsContentUtils.h"
#include "txXMLUtils.h"
@ -857,11 +857,7 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, PRInt32 aNsID
if (!mOutputFormat.mEncoding.IsEmpty()) {
NS_LossyConvertUTF16toASCII charset(mOutputFormat.mEncoding);
nsCAutoString canonicalCharset;
nsCOMPtr<nsICharsetAlias> calias =
do_GetService("@mozilla.org/intl/charsetalias;1");
if (calias &&
NS_SUCCEEDED(calias->GetPreferred(charset, canonicalCharset))) {
if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(charset, canonicalCharset))) {
mDocument->SetDocumentCharacterSetSource(kCharsetFromOtherComponent);
mDocument->SetDocumentCharacterSet(canonicalCharset);
}

View File

@ -548,6 +548,7 @@ static const char kDOMStringBundleURL[] =
nsIXPCScriptable::WANT_ENUMERATE | \
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
nsIXPCScriptable::USE_STUB_EQUALITY_HOOK | \
nsIXPCScriptable::IS_GLOBAL_OBJECT | \
nsIXPCScriptable::WANT_OUTER_OBJECT)
#define NODE_SCRIPTABLE_FLAGS \
@ -1549,7 +1550,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(AnimationEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::IS_GLOBAL_OBJECT)
NS_DEFINE_CLASSINFO_DATA(FormData, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -1617,8 +1618,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
#endif
#ifdef MOZ_B2G_BT
NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(DOMError, nsDOMGenericSH,

View File

@ -144,7 +144,11 @@ static PRLogModuleInfo* gJSDiagnostics;
#define NS_CC_SKIPPABLE_DELAY 400 // ms
#define NS_CC_FORCED (5 * 60 * PR_USEC_PER_SEC) // 5 min
// Force a CC after this long if there's anything in the purple buffer.
#define NS_CC_FORCED (2 * 60 * PR_USEC_PER_SEC) // 2 min
// Trigger a CC if the purple buffer exceeds this size when we check it.
#define NS_CC_PURPLE_LIMIT 250
#define JAVASCRIPT nsIProgrammingLanguage::JAVASCRIPT
@ -2227,11 +2231,9 @@ nsJSContext::CreateNativeGlobalForInner(
nsRefPtr<nsIXPConnectJSObjectHolder> jsholder;
nsresult rv = xpc->
InitClassesWithNewWrappedGlobal(mContext,
aNewInner, NS_GET_IID(nsISupports),
InitClassesWithNewWrappedGlobal(mContext, aNewInner,
aIsChrome ? systemPrincipal.get() : aPrincipal,
nsnull, flags,
getter_AddRefs(jsholder));
flags, getter_AddRefs(jsholder));
if (NS_FAILED(rv)) {
return rv;
}
@ -2324,7 +2326,7 @@ nsJSContext::SetOuterObject(JSObject* aOuterObject)
NS_ENSURE_SUCCESS(rv, rv);
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
wrapper->RefreshPrototype();
wrapper->FinishInitForWrappedGlobal();
JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(inner));
return NS_OK;
@ -3286,46 +3288,70 @@ ShrinkGCBuffersTimerFired(nsITimer *aTimer, void *aClosure)
nsJSContext::ShrinkGCBuffersNow();
}
// static
void
static bool
ShouldTriggerCC(PRUint32 aSuspected)
{
return sNeedsFullCC ||
aSuspected > NS_CC_PURPLE_LIMIT ||
sLastCCEndTime + NS_CC_FORCED < PR_Now();
}
static void
TimerFireForgetSkippable(PRUint32 aSuspected, bool aRemoveChildless)
{
PRTime startTime = PR_Now();
nsCycleCollector_forgetSkippable(aRemoveChildless);
sPreviousSuspectedCount = nsCycleCollector_suspectedCount();
sCleanupSinceLastGC = true;
PRTime delta = PR_Now() - startTime;
if (sMinForgetSkippableTime > delta) {
sMinForgetSkippableTime = delta;
}
if (sMaxForgetSkippableTime < delta) {
sMaxForgetSkippableTime = delta;
}
sTotalForgetSkippableTime += delta;
sRemovedPurples += (aSuspected - sPreviousSuspectedCount);
++sForgetSkippableBeforeCC;
}
static void
CCTimerFired(nsITimer *aTimer, void *aClosure)
{
if (sDidShutdown) {
return;
}
if (sCCLockedOut) {
if (sDidShutdown || sCCLockedOut) {
return;
}
++sCCTimerFireCount;
if (sCCTimerFireCount < (NS_CC_DELAY / NS_CC_SKIPPABLE_DELAY)) {
PRUint32 suspected = nsCycleCollector_suspectedCount();
if ((sPreviousSuspectedCount + 100) > suspected) {
// Just few new suspected objects, return early.
return;
}
PRTime startTime = PR_Now();
nsCycleCollector_forgetSkippable();
sPreviousSuspectedCount = nsCycleCollector_suspectedCount();
sCleanupSinceLastGC = true;
PRTime delta = PR_Now() - startTime;
if (sMinForgetSkippableTime > delta) {
sMinForgetSkippableTime = delta;
}
if (sMaxForgetSkippableTime < delta) {
sMaxForgetSkippableTime = delta;
}
sTotalForgetSkippableTime += delta;
sRemovedPurples += (suspected - sPreviousSuspectedCount);
++sForgetSkippableBeforeCC;
} else {
sPreviousSuspectedCount = 0;
nsJSContext::KillCCTimer();
if (sNeedsFullCC ||
nsCycleCollector_suspectedCount() > 500 ||
sLastCCEndTime + NS_CC_FORCED < PR_Now()) {
// During early timer fires, we only run forgetSkippable. During the first
// late timer fire, we decide if we are going to have a second and final
// late timer fire, where we may run the CC.
const PRUint32 numEarlyTimerFires = NS_CC_DELAY / NS_CC_SKIPPABLE_DELAY - 2;
bool isLateTimerFire = sCCTimerFireCount > numEarlyTimerFires;
PRUint32 suspected = nsCycleCollector_suspectedCount();
if (isLateTimerFire && ShouldTriggerCC(suspected)) {
if (sCCTimerFireCount == numEarlyTimerFires + 1) {
TimerFireForgetSkippable(suspected, true);
if (ShouldTriggerCC(nsCycleCollector_suspectedCount())) {
// Our efforts to avoid a CC have failed, so we return to let the
// timer fire once more to trigger a CC.
return;
}
} else {
// We are in the final timer fire and still meet the conditions for
// triggering a CC.
nsJSContext::CycleCollectNow();
}
} else if ((sPreviousSuspectedCount + 100) <= suspected) {
// Only do a forget skippable if there are more than a few new objects.
TimerFireForgetSkippable(suspected, false);
}
if (isLateTimerFire) {
// We have either just run the CC or decided we don't want to run the CC
// next time, so kill the timer.
sPreviousSuspectedCount = 0;
nsJSContext::KillCCTimer();
}
}

View File

@ -16,47 +16,56 @@
#include <bluedroid/bluetooth.h>
#endif
#define POWERED_EVENT_NAME NS_LITERAL_STRING("powered")
BEGIN_BLUETOOTH_NAMESPACE
USING_BLUETOOTH_NAMESPACE
class ToggleBtResultTask : public nsRunnable
{
public:
ToggleBtResultTask(bool result, nsRefPtr<BluetoothAdapter>& adapterPtr)
ToggleBtResultTask(nsRefPtr<BluetoothAdapter>& adapterPtr, bool result)
: mResult(result)
{
MOZ_ASSERT(!NS_IsMainThread()); // This should be running on the worker thread
MOZ_ASSERT(!NS_IsMainThread());
mAdapterPtr.swap(adapterPtr);
}
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread()); // This method is supposed to run on the main thread!
NS_IMETHOD Run()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mResult) {
//TODO:Bug-731361
NS_WARNING("BT firmware loading fails.\n");
}
//mAdapterPtr must be null before returning to prevent the background
//thread from racing to release it during the destruction of this runnable.
mAdapterPtr->FirePowered();
mAdapterPtr = nsnull;
return NS_OK;
}
private:
bool mResult;
nsRefPtr<BluetoothAdapter> mAdapterPtr;
bool mResult;
};
class ToggleBtTask : public nsRunnable
{
public:
ToggleBtTask(bool onOff, BluetoothAdapter* adapterPtr)
ToggleBtTask(bool onOff, BluetoothAdapter* adapterPtr)
: mOnOff(onOff),
mAdapterPtr(adapterPtr)
mAdapterPtr(adapterPtr)
{
MOZ_ASSERT(NS_IsMainThread()); // The constructor should be running on the main thread.
MOZ_ASSERT(NS_IsMainThread());
}
NS_IMETHOD Run() {
bool result;
NS_IMETHOD Run()
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!NS_IsMainThread()); // This should be running on the worker thread.
bool result;
//Toggle BT here
#if defined(MOZ_WIDGET_GONK)
@ -65,13 +74,16 @@ class ToggleBtTask : public nsRunnable
} else {
result = bt_disable();
}
#else
#else
result = true;
#endif
// Create a result thread and pass it to Main Thread,
nsCOMPtr<nsIRunnable> resultRunnable = new ToggleBtResultTask(result, mAdapterPtr);
NS_DispatchToMainThread(resultRunnable);
nsCOMPtr<nsIRunnable> resultRunnable = new ToggleBtResultTask(mAdapterPtr, result);
if (NS_FAILED(NS_DispatchToMainThread(resultRunnable))) {
NS_WARNING("Failed to dispatch to main thread!");
}
return NS_OK;
}
@ -81,25 +93,21 @@ class ToggleBtTask : public nsRunnable
bool mOnOff;
};
END_BLUETOOTH_NAMESPACE
DOMCI_DATA(BluetoothAdapter, mozilla::dom::bluetooth::BluetoothAdapter)
USING_BLUETOOTH_NAMESPACE
DOMCI_DATA(BluetoothAdapter, BluetoothAdapter)
NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothAdapter)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothAdapter,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(powered)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothAdapter,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(powered)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothAdapter,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(powered)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothAdapter,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(powered)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothAdapter)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothAdapter)
NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothAdapter)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothAdapter)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
@ -107,18 +115,16 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(BluetoothAdapter, nsDOMEventTargetHelper)
BluetoothAdapter::BluetoothAdapter() : mPower(false)
BluetoothAdapter::BluetoothAdapter()
: mPower(false)
{
}
NS_IMETHODIMP
BluetoothAdapter::GetPower(bool* aPower)
{
#if defined(MOZ_WIDGET_GONK)
*aPower = bt_is_enabled();
#else
*aPower = mPower;
#endif
return NS_OK;
}
@ -128,13 +134,13 @@ BluetoothAdapter::SetPower(bool aPower)
if (mPower != aPower) {
mPower = aPower;
ToggleBluetoothAsync();
return ToggleBluetoothAsync();
}
return NS_OK;
}
void
nsresult
BluetoothAdapter::ToggleBluetoothAsync()
{
if (!mToggleBtThread) {
@ -143,14 +149,17 @@ BluetoothAdapter::ToggleBluetoothAsync()
nsCOMPtr<nsIRunnable> r = new ToggleBtTask(mPower, this);
mToggleBtThread->Dispatch(r, 0);
return mToggleBtThread->Dispatch(r, NS_DISPATCH_NORMAL);
}
nsresult
BluetoothAdapter::FirePowered()
{
nsRefPtr<nsDOMEvent> event = new nsDOMEvent(nsnull, nsnull);
nsresult rv = event->InitEvent(POWERED_EVENT_NAME, false, false);
nsresult rv = event->InitEvent(NS_LITERAL_STRING("powered"), false, false);
NS_ENSURE_SUCCESS(rv, rv);
rv = event->SetTrusted(true);
NS_ENSURE_SUCCESS(rv, rv);
bool dummy;

View File

@ -11,10 +11,12 @@
#include "nsDOMEventTargetHelper.h"
#include "nsIDOMBluetoothAdapter.h"
class nsIEventTarget;
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothAdapter : public nsIDOMBluetoothAdapter
,public nsDOMEventTargetHelper
, public nsDOMEventTargetHelper
{
public:
NS_DECL_ISUPPORTS
@ -36,7 +38,7 @@ protected:
private:
nsCOMPtr<nsIEventTarget> mToggleBtThread;
void ToggleBluetoothAsync();
nsresult ToggleBluetoothAsync();
};
END_BLUETOOTH_NAMESPACE

View File

@ -11,41 +11,613 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const RIL_SMSDATABASESERVICE_CONTRACTID = "@mozilla.org/sms/rilsmsdatabaseservice;1";
const RIL_SMSDATABASESERVICE_CID = Components.ID("{a1fa610c-eb6c-4ac2-878f-b005d5e89249}");
const DEBUG = true;
const DB_NAME = "sms";
const DB_VERSION = 1;
const STORE_NAME = "sms";
const DELIVERY_SENT = "sent";
const DELIVERY_RECEIVED = "received";
const FILTER_TIMESTAMP = "timestamp";
const FILTER_NUMBERS = "numbers";
const FILTER_DELIVERY = "delivery";
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
"@mozilla.org/sms/smsservice;1",
"nsISmsService");
XPCOMUtils.defineLazyServiceGetter(this, "gSmsRequestManager",
"@mozilla.org/sms/smsrequestmanager;1",
"nsISmsRequestManager");
XPCOMUtils.defineLazyServiceGetter(this, "gIDBManager",
"@mozilla.org/dom/indexeddb/manager;1",
"nsIIndexedDatabaseManager");
const GLOBAL_SCOPE = this;
/**
* SmsDatabaseService
*/
function SmsDatabaseService() {
gIDBManager.initWindowless(GLOBAL_SCOPE);
let that = this;
this.newTxn(Ci.nsIIDBTransaction.READ_ONLY, function(error, txn, store){
if (error) {
return;
}
// In order to get the highest key value, we open a key cursor in reverse
// order and get only the first pointed value.
let request = store.openCursor(null, Ci.nsIIDBCursor.PREV);
request.onsuccess = function onsuccess(event) {
let cursor = event.target.result;
if (!cursor) {
if (DEBUG) {
debug("Could not get the last key from sms database. " +
"Probably empty database");
}
return;
}
that.lastKey = cursor.key || 0;
if (DEBUG) debug("Last assigned message ID was " + that.lastKey);
};
request.onerror = function onerror(event) {
if (DEBUG) {
debug("Could not get the last key from sms database " +
event.target.errorCode);
}
};
});
this.messageLists = {};
}
SmsDatabaseService.prototype = {
classID: RIL_SMSDATABASESERVICE_CID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISmsDatabaseService]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsISmsDatabaseService,
Ci.nsIObserver]),
// nsISmsDatabaseService
/**
* Cache the DB here.
*/
db: null,
/**
* This object keeps the message lists associated with each search. Each
* message list is stored as an array of primary keys.
*/
messageLists: null,
lastMessageListId: 0,
/**
* Last key value stored in the database.
*/
lastKey: 0,
/**
* nsIObserver
*/
observe: function observe() {},
/**
* Prepare the database. This may include opening the database and upgrading
* it to the latest schema version.
*
* @param callback
* Function that takes an error and db argument. It is called when
* the database is ready to use or if an error occurs while preparing
* the database.
*
* @return (via callback) a database ready for use.
*/
ensureDB: function ensureDB(callback) {
if (this.db) {
if (DEBUG) debug("ensureDB: already have a database, returning early.");
callback(null, this.db);
return;
}
let self = this;
function gotDB(db) {
self.db = db;
callback(null, db);
}
let request = GLOBAL_SCOPE.mozIndexedDB.open(DB_NAME, DB_VERSION);
request.onsuccess = function (event) {
if (DEBUG) debug("Opened database:", DB_NAME, DB_VERSION);
gotDB(event.target.result);
};
request.onupgradeneeded = function (event) {
if (DEBUG) {
debug("Database needs upgrade:", DB_NAME,
event.oldVersion, event.newVersion);
debug("Correct new database version:", event.newVersion == DB_VERSION);
}
let db = event.target.result;
switch (event.oldVersion) {
case 0:
if (DEBUG) debug("New database");
self.createSchema(db);
break;
default:
event.target.transaction.abort();
callback("Old database version: " + event.oldVersion, null);
break;
}
};
request.onerror = function (event) {
//TODO look at event.target.Code and change error constant accordingly
callback("Error opening database!", null);
};
request.onblocked = function (event) {
callback("Opening database request is blocked.", null);
};
},
/**
* Start a new transaction.
*
* @param txn_type
* Type of transaction (e.g. IDBTransaction.READ_WRITE)
* @param callback
* Function to call when the transaction is available. It will
* be invoked with the transaction and the 'sms' object store.
*/
newTxn: function newTxn(txn_type, callback) {
this.ensureDB(function (error, db) {
if (error) {
if (DEBUG) debug("Could not open database: " + error);
callback(error);
return;
}
let txn = db.transaction([STORE_NAME], txn_type);
if (DEBUG) debug("Started transaction " + txn + " of type " + txn_type);
if (DEBUG) {
txn.oncomplete = function oncomplete(event) {
debug("Transaction " + txn + " completed.");
};
txn.onerror = function onerror(event) {
//TODO check event.target.errorCode and show an appropiate error
// message according to it.
debug("Error occurred during transaction: " + event.target.errorCode);
};
}
if (DEBUG) debug("Retrieving object store", STORE_NAME);
let store = txn.objectStore(STORE_NAME);
callback(null, txn, store);
});
},
/**
* Create the initial database schema.
*
* TODO need to worry about number normalization somewhere...
* TODO full text search on body???
* TODO We probably want to add a 'read' index
*/
createSchema: function createSchema(db) {
let objectStore = db.createObjectStore(STORE_NAME, { keyPath: "id" });
objectStore.createIndex("id", "id", { unique: true });
objectStore.createIndex("delivery", "delivery", { unique: false });
objectStore.createIndex("sender", "sender", { unique: false });
objectStore.createIndex("receiver", "receiver", { unique: false });
objectStore.createIndex("timestamp", "timestamp", { unique:false });
if (DEBUG) debug("Created object stores and indexes");
},
/**
* Helper function to make the intersection of the partial result arrays
* obtained within createMessageList.
*
* @param keys
* Object containing the partial result arrays.
* @param fiter
* Object containing the filter search criteria used to retrieved the
* partial results.
*
* return Array of keys containing the final result of createMessageList.
*/
keyIntersection: function keyIntersection(keys, filter) {
let result = keys[FILTER_TIMESTAMP];
if (keys[FILTER_NUMBERS].length || filter.numbers) {
result = keys[FILTER_NUMBERS].filter(function(i) {
return result.indexOf(i) != -1;
});
}
if (keys[FILTER_DELIVERY].length || filter.delivery) {
result = keys[FILTER_DELIVERY].filter(function(i) {
return result.indexOf(i) != -1;
});
}
return result;
},
/**
* Helper function called after createMessageList gets the final result array
* containing the list of primary keys of records that matches the provided
* search criteria. This function retrieves from the store the message with
* the primary key matching the first one in the message list array and keeps
* the rest of this array in memory. It also notifies via gSmsRequestManager.
*
* @param messageList
* Array of primary keys retrieved within createMessageList.
* @param requestId
* Id used by the SmsRequestManager
*/
onMessageListCreated: function onMessageListCreated(messageList, requestId) {
if (DEBUG) debug("Message list created: " + messageList);
let self = this;
self.newTxn(Ci.nsIIDBTransaction.READ_ONLY, function (error, txn, store) {
if (error) {
gSmsRequestManager.notifyReadMessageListFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
return;
}
let messageId = messageList.shift();
if (DEBUG) debug ("Fetching message " + messageId);
let request = store.get(messageId);
let message;
request.onsuccess = function (event) {
message = request.result;
};
txn.oncomplete = function oncomplete(event) {
if (DEBUG) debug("Transaction " + txn + " completed.");
if (!message) {
gSmsRequestManager.notifyReadMessageListFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
return;
}
self.lastMessageListId += 1;
self.messageLists[self.lastMessageListId] = messageList;
let sms = gSmsService.createSmsMessage(message.id,
message.delivery,
message.sender,
message.receiver,
message.body,
message.timestamp);
gSmsRequestManager.notifyCreateMessageList(requestId,
self.lastMessageListId,
sms);
};
});
},
saveMessage: function saveMessage(message) {
this.lastKey += 1;
message.id = this.lastKey;
if (DEBUG) debug("Going to store " + JSON.stringify(message));
this.newTxn(Ci.nsIIDBTransaction.READ_WRITE, function(error, txn, store) {
if (error) {
return;
}
let request = store.put(message);
});
// We return the key that we expect to store in the db
return message.id;
},
/**
* nsISmsDatabaseService API
*/
saveReceivedMessage: function saveReceivedMessage(sender, body, date) {
return -1;
let message = {delivery: DELIVERY_RECEIVED,
sender: sender,
receiver: null, //TODO see bug 733266
body: body,
timestamp: date};
return this.saveMessage(message);
},
saveSentMessage: function saveSentMessage(receiver, body, date) {
return -1;
let message = {delivery: DELIVERY_SENT,
sender: null, //TODO see bug 733266
receiver: receiver,
body: body,
timestamp: date};
return this.saveMessage(message);
},
getMessage: function getMessage(messageId, requestId) {
if (DEBUG) debug("Retrieving message with ID " + messageId);
this.newTxn(Ci.nsIIDBTransaction.READ_ONLY, function (error, txn, store) {
if (error) {
if (DEBUG) debug(error);
gSmsRequestManager.notifyGetSmsFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
return;
}
let request = store.getAll(messageId);
txn.oncomplete = function oncomplete() {
if (DEBUG) debug("Transaction " + txn + " completed.");
if (request.result.length > 1) {
if (DEBUG) debug("Got too many results for id " + messageId);
gSmsRequestManager.notifyGetSmsFailed(
requestId, Ci.nsISmsRequestManager.UNKNOWN_ERROR);
return;
}
let data = request.result[0];
if (!data) {
if (DEBUG) debug("Message ID " + messageId + " not found");
gSmsRequestManager.notifyGetSmsFailed(
requestId, Ci.nsISmsRequestManager.NOT_FOUND_ERROR);
return;
}
if (data.id != messageId) {
if (DEBUG) {
debug("Requested message ID (" + messageId + ") is " +
"different from the one we got");
}
gSmsRequestManager.notifyGetSmsFailed(
requestId, Ci.nsISmsRequestManager.UNKNOWN_ERROR);
return;
}
let message = gSmsService.createSmsMessage(data.id,
data.delivery,
data.sender,
data.receiver,
data.body,
data.timestamp);
gSmsRequestManager.notifyGotSms(requestId, message);
};
txn.onerror = function onerror(event) {
if (DEBUG) debug("Caught error on transaction", event.target.errorCode);
//TODO look at event.target.errorCode, pick appropriate error constant
gSmsRequestManager.notifyGetSmsFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
};
});
},
deleteMessage: function deleteMessage(messageId, requestId) {
let self = this;
this.newTxn(Ci.nsIIDBTransaction.READ_WRITE, function (error, txn, store) {
if (error) {
gSmsRequestManager.notifySmsDeleteFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
return;
}
let request = store.delete(messageId);
request.onerror = function onerror(event) {
if (DEBUG) debug("Caught error on request ", event.target.errorCode);
//TODO look at event.target.errorCode
gSmsRequestManager.notifySmsDeleteFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
};
txn.oncomplete = function oncomplete(event) {
if (DEBUG) debug("Transaction " + txn + " completed.");
// Once we transaction is done, we need to check if we actually deleted
// the message. As IndexedDB does not provide the affected records info,
// we need to try to get the message from the database again to check
// that it is actually gone.
self.newTxn(Ci.nsIIDBTransaction.READ_ONLY, function (error, txn, store) {
let request = store.getAll(messageId);
request.onsuccess = function onsuccess(event) {
let deleted = (event.target.result.length == 0);
gSmsRequestManager.notifySmsDeleted(requestId, deleted);
};
request.onerror = function onerror(event) {
if (DEBUG) {
debug("Error checking the message deletion " +
event.target.errorCode);
}
//TODO should we notify here as an internal error? The failed check
// does not mean that the deletion has failed, so maybe we
// should notify successfully.
gSmsRequestManager.notifySmsDeleteFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
};
});
};
txn.onerror = function onerror(event) {
if (DEBUG) debug("Caught error on transaction", event.target.errorCode);
//TODO look at event.target.errorCode, pick appropriate error constant
gSmsRequestManager.notifySmsDeleteFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
};
});
},
createMessageList: function createMessageList(filter, reverse, requestId) {
if (DEBUG) {
debug("Creating a message list. Filters:" +
" startDate: " + filter.startDate +
" endDate: " + filter.endDate +
" delivery: " + filter.delivery +
" numbers: " + filter.numbers +
" reverse: " + reverse);
}
// This object keeps the lists of keys retrieved by the search specific to
// each nsIMozSmsFilter. Once all the keys have been retrieved from the
// store, the final intersection of this arrays will contain all the
// keys for the message list that we are creating.
let filteredKeys = {};
filteredKeys[FILTER_TIMESTAMP] = [];
filteredKeys[FILTER_NUMBERS] = [];
filteredKeys[FILTER_DELIVERY] = [];
// Callback function to iterate through request results via IDBCursor.
let successCb = function onsuccess(result, filter) {
// Once the cursor has retrieved all keys that matches its key range,
// the filter search is done.
if (!result) {
if (DEBUG) {
debug("These messages match the " + filter + " filter: " +
filteredKeys[filter]);
}
return;
}
// The cursor primaryKey is stored in its corresponding partial array
// according to the filter parameter.
let primaryKey = result.primaryKey;
filteredKeys[filter].push(primaryKey);
result.continue();
};
let errorCb = function onerror(event) {
//TODO look at event.target.errorCode, pick appropriate error constant.
if (DEBUG) debug("IDBRequest error " + event.target.errorCode);
gSmsRequestManager.notifyReadMessageListFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
return;
};
let self = this;
this.newTxn(Ci.nsIIDBTransaction.READ_ONLY, function (error, txn, store) {
if (error) {
errorCb(error);
return;
}
// In first place, we retrieve the keys that match the filter.startDate
// and filter.endDate search criteria.
let timeKeyRange = null;
if (!filter.startDate != null && filter.endDate != null) {
timeKeyRange = IDBKeyRange.bound(filter.startDate.getTime(),
filter.endDate.getTime());
} else if (filter.startDate != null) {
timeKeyRange = IDBKeyRange.lowerBound(filter.startDate.getTime());
} else if (filter.endDate != null) {
timeKeyRange = IDBKeyRange.upperBound(filter.endDate.getTime());
}
let direction = reverse ? Ci.nsIIDBCursor.PREV : Ci.nsIIDBCursor.NEXT;
let timeRequest = store.index("timestamp").openKeyCursor(timeKeyRange,
direction);
timeRequest.onsuccess = function onsuccess(event) {
successCb(event.target.result, FILTER_TIMESTAMP);
};
timeRequest.onerror = errorCb;
// Retrieve the keys from the 'delivery' index that matches the
// value of filter.delivery.
if (filter.delivery) {
let deliveryKeyRange = IDBKeyRange.only(filter.delivery);
let deliveryRequest = store.index("delivery")
.openKeyCursor(deliveryKeyRange);
deliveryRequest.onsuccess = function onsuccess(event) {
successCb(event.target.result, FILTER_DELIVERY);
};
deliveryRequest.onerror = errorCb;
}
// Retrieve the keys from the 'sender' and 'receiver' indexes that
// match the values of filter.numbers
if (filter.numbers) {
for (let i = 0; i < filter.numbers.length; i++) {
let numberKeyRange = IDBKeyRange.only(filter.numbers[i]);
let senderRequest = store.index("sender")
.openKeyCursor(numberKeyRange);
let receiverRequest = store.index("receiver")
.openKeyCursor(numberKeyRange);
senderRequest.onsuccess = receiverRequest.onsuccess =
function onsuccess(event){
successCb(event.target.result, FILTER_NUMBERS);
};
senderRequest.onerror = receiverRequest.onerror = errorCb;
}
}
txn.oncomplete = function oncomplete(event) {
if (DEBUG) debug("Transaction " + txn + " completed.");
// We need to get the intersection of all the partial searches to
// get the final result array.
let result = self.keyIntersection(filteredKeys, filter);
if (!result.length) {
if (DEBUG) debug("No messages matching the filter criteria");
gSmsRequestManager.notifyNoMessageInList(requestId);
return;
}
// At this point, filteredKeys should have all the keys that matches
// all the search filters. So we take the first key and retrieve the
// corresponding message. The rest of the keys are added to the
// messageLists object as a new list.
self.onMessageListCreated(result, requestId);
};
txn.onerror = function onerror(event) {
errorCb(event);
};
});
},
getNextMessageInList: function getNextMessageInList(listId, requestId) {
if (DEBUG) debug("Getting next message in list " + listId);
let messageId;
let list = this.messageLists[listId];
if (!list) {
if (DEBUG) debug("Wrong list id");
gSmsRequestManager.notifyReadMessageListFailed(
requestId, Ci.nsISmsRequestManager.NOT_FOUND_ERROR);
return;
}
messageId = list.shift();
if (messageId == null) {
if (DEBUG) debug("Reached the end of the list!");
gSmsRequestManager.notifyNoMessageInList(requestId);
return;
}
this.newTxn(Ci.nsIIDBTransaction.READ_ONLY, function (error, txn, store) {
if (DEBUG) debug("Fetching message " + messageId);
let request = store.get(messageId);
let message;
request.onsuccess = function onsuccess(event) {
message = request.result;
};
txn.oncomplete = function oncomplete(event) {
if (DEBUG) debug("Transaction " + txn + " completed.");
if (!message) {
if (DEBUG) debug("Could not get message id " + messageId);
gSmsRequestManager.notifyReadMessageListFailed(
requestId, Ci.nsISmsRequestManager.NOT_FOUND_ERROR);
}
let sms = gSmsService.createSmsMessage(message.id,
message.delivery,
message.sender,
message.receiver,
message.body,
message.timestamp);
gSmsRequestManager.notifyGotNextMessage(requestId, sms);
};
txn.onerror = function onerror(event) {
//TODO check event.target.errorCode
if (DEBUG) {
debug("Error retrieving message id: " + messageId +
". Error code: " + event.target.errorCode);
}
gSmsRequestManager.notifyReadMessageListFailed(
requestId, Ci.nsISmsRequestManager.INTERNAL_ERROR);
};
});
},
clearMessageList: function clearMessageList(listId) {
if (DEBUG) debug("Clearing message list: " + listId);
delete this.messageLists[listId];
}
};
const NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsDatabaseService]);
function debug() {
dump("SmsDatabaseService: " + Array.slice(arguments).join(" ") + "\n");
}

View File

@ -69,6 +69,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "gSmsRequestManager",
"@mozilla.org/sms/smsrequestmanager;1",
"nsISmsRequestManager");
XPCOMUtils.defineLazyServiceGetter(this, "gSmsDatabaseService",
"@mozilla.org/sms/rilsmsdatabaseservice;1",
"nsISmsDatabaseService");
function convertRILCallState(state) {
switch (state) {
case RIL.CALL_STATE_ACTIVE:
@ -308,8 +312,11 @@ RadioInterfaceLayer.prototype = {
},
handleSmsReceived: function handleSmsReceived(message) {
//TODO: put the sms into a database, assign it a proper id, yada yada
let sms = gSmsService.createSmsMessage(-1,
debug("handleSmsReceived: " + JSON.stringify(message));
let id = gSmsDatabaseService.saveReceivedMessage(message.sender || null,
message.body || null,
message.timestamp);
let sms = gSmsService.createSmsMessage(id,
DOM_SMS_DELIVERY_RECEIVED,
message.sender || null,
message.receiver || null,
@ -319,13 +326,15 @@ RadioInterfaceLayer.prototype = {
},
handleSmsSent: function handleSmsSent(message) {
let sms = gSmsService.createSmsMessage(-1,
debug("handleSmsSent: " + JSON.stringify(message));
let timestamp = Date.now();
let id = gSmsDatabaseService.saveSentMessage(message.number, message.body, timestamp);
let sms = gSmsService.createSmsMessage(id,
DOM_SMS_DELIVERY_SENT,
null,
message.number,
message.body,
Date.now());
//TODO At this point we should save the sms into the DB (bug 712809)
timestamp);
//TODO handle errors (bug 727319)
gSmsRequestManager.notifySmsSent(message.requestId, sms);
},

View File

@ -336,80 +336,667 @@ const PDU_DCS_MSG_CLASS_TE_SPECIFIC = 0xF3;
// Because service center timestamp omit the century. Yay.
const PDU_TIMESTAMP_YEAR_OFFSET = 2000;
// 7bit Default Alphabet
//TODO: maybe convert this to a string? might be faster/cheaper
const PDU_ALPHABET_7BIT_DEFAULT = [
"@", // COMMERCIAL AT
"\xa3", // POUND SIGN
"$", // DOLLAR SIGN
"\xa5", // YEN SIGN
"\xe8", // LATIN SMALL LETTER E WITH GRAVE
"\xe9", // LATIN SMALL LETTER E WITH ACUTE
"\xf9", // LATIN SMALL LETTER U WITH GRAVE
"\xec", // LATIN SMALL LETTER I WITH GRAVE
"\xf2", // LATIN SMALL LETTER O WITH GRAVE
"\xc7", // LATIN CAPITAL LETTER C WITH CEDILLA
"\n", // LINE FEED
"\xd8", // LATIN CAPITAL LETTER O WITH STROKE
"\xf8", // LATIN SMALL LETTER O WITH STROKE
"\r", // CARRIAGE RETURN
"\xc5", // LATIN CAPITAL LETTER A WITH RING ABOVE
"\xe5", // LATIN SMALL LETTER A WITH RING ABOVE
"\u0394", // GREEK CAPITAL LETTER DELTA
"_", // LOW LINE
"\u03a6", // GREEK CAPITAL LETTER PHI
"\u0393", // GREEK CAPITAL LETTER GAMMA
"\u039b", // GREEK CAPITAL LETTER LAMBDA
"\u03a9", // GREEK CAPITAL LETTER OMEGA
"\u03a0", // GREEK CAPITAL LETTER PI
"\u03a8", // GREEK CAPITAL LETTER PSI
"\u03a3", // GREEK CAPITAL LETTER SIGMA
"\u0398", // GREEK CAPITAL LETTER THETA
"\u039e", // GREEK CAPITAL LETTER XI
"\u20ac", // (escape to extension table)
"\xc6", // LATIN CAPITAL LETTER AE
"\xe6", // LATIN SMALL LETTER AE
"\xdf", // LATIN SMALL LETTER SHARP S (German)
"\xc9", // LATIN CAPITAL LETTER E WITH ACUTE
" ", // SPACE
"!", // EXCLAMATION MARK
"\"", // QUOTATION MARK
"#", // NUMBER SIGN
"\xa4", // CURRENCY SIGN
"%", // PERCENT SIGN
"&", // AMPERSAND
"'", // APOSTROPHE
"(", // LEFT PARENTHESIS
")", // RIGHT PARENTHESIS
"*", // ASTERISK
"+", // PLUS SIGN
",", // COMMA
"-", // HYPHEN-MINUS
".", // FULL STOP
"/", // SOLIDUS (SLASH)
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
":", // COLON
";", // SEMICOLON
"<", // LESS-THAN SIGN
"=", // EQUALS SIGN
">", // GREATER-THAN SIGN
"?", // QUESTION MARK
"\xa1", // INVERTED EXCLAMATION MARK
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"\xc4", // LATIN CAPITAL LETTER A WITH DIAERESIS
"\xd6", // LATIN CAPITAL LETTER O WITH DIAERESIS
"\xd1", // LATIN CAPITAL LETTER N WITH TILDE
"\xdc", // LATIN CAPITAL LETTER U WITH DIAERESIS
"\xa7", // SECTION SIGN
"\xbf", // INVERTED QUESTION MARK
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"\xe4", // LATIN SMALL LETTER A WITH DIAERESIS
"\xf6", // LATIN SMALL LETTER O WITH DIAERESIS
"\xf1", // LATIN SMALL LETTER N WITH TILDE
"\xfc", // LATIN SMALL LETTER U WITH DIAERESIS
"\xe0" // LATIN SMALL LETTER A WITH GRAVE
// See 9.2.3.24 TPUser Data (TPUD)
const PDU_IEI_CONCATENATED_SHORT_MESSAGES_8BIT = 0x00;
const PDU_IEI_SPECIAL_SMS_MESSAGE_INDICATION = 0x01;
const PDU_IEI_APPLICATION_PORT_ADDREESING_SCHEME_8BIT = 0x04;
const PDU_IEI_APPLICATION_PORT_ADDREESING_SCHEME_16BIT = 0x05;
const PDU_IEI_SMSC_CONTROL_PARAMS = 0x06;
const PDU_IEI_UDH_SOURCE_INDICATOR = 0x07;
const PDU_IEI_CONCATENATED_SHORT_MESSAGES_16BIT = 0x08;
const PDU_IEI_WIRELESS_CONTROL_MESSAGE_PROTOCOL = 0x09;
const PDU_IEI_TEXT_FORMATING = 0x0A;
const PDU_IEI_PREDEFINED_SOUND = 0x0B;
const PDU_IEI_USER_DATA_SOUND = 0x0C;
const PDU_IEI_PREDEFINED_ANIMATION = 0x0D;
const PDU_IEI_LARGE_ANIMATION = 0x0E;
const PDU_IEI_SMALL_ANIMATION = 0x0F;
const PDU_IEI_LARGE_PICTURE = 0x10;
const PDU_IEI_SMALL_PICTURE = 0x11;
const PDU_IEI_VARIABLE_PICTURE = 0x12;
const PDU_IEI_USER_PROMPT_INDICATOR = 0x13;
const PDU_IEI_EXTENDED_OBJECT = 0x14;
const PDU_IEI_REUSED_EXTENDED_OBJECT = 0x15;
const PDU_IEI_COMPRESS_CONTROL = 0x16;
const PDU_IEI_OBJECT_DISTRIBUTION_INDICATOR = 0x17;
const PDU_IEI_STANDARD_WVG_OBJECT = 0x18;
const PDU_IEI_CHARACTER_SIZE_WVG_OBJECT = 0x19;
const PDU_IEI_EXTENDED_OBJECT_DATA_REQUEST_COMMAND = 0x1A;
const PDU_IEI_RFC822_EMAIL_HEADER = 0x20;
const PDU_IEI_HYPERLINK_FORMAT_ELEMENT = 0x21;
const PDU_IEI_REPLY_ADDRESS_ELEMENT = 0x22;
const PDU_IEI_ENHANCED_VOICE_MAIL_INFORMATION = 0x23;
const PDU_IEI_NATIONAL_LANGUAGE_SINGLE_SHIFT = 0x24;
const PDU_IEI_NATIONAL_LANGUAGE_LOCKING_SHIFT = 0x25;
// 7bit alphabet escape character. The encoded value of this code point is left
// undefined in official spec. Its code value is internally assigned to \uffff,
// <noncharacter-FFFF> in Unicode basic multilingual plane.
const PDU_NL_EXTENDED_ESCAPE = 0x1B;
// <SP>, <LF>, <CR> are only defined in locking shift tables.
const PDU_NL_SPACE = 0x20;
const PDU_NL_LINE_FEED = 0x0A;
const PDU_NL_CARRIAGE_RETURN = 0x0D;
// 7bit alphabet page break character, only defined in single shift tables.
// The encoded value of this code point is left undefined in official spec, but
// the code point itself maybe be used for example in compressed CBS messages.
// Its code value is internally assigned to \u000c, ASCII form feed, or new page.
const PDU_NL_PAGE_BREAK = 0x0A;
// 7bit alphabet reserved control character, only defined in single shift
// tables. The encoded value of this code point is left undefined in official
// spec. Its code value is internally assigned to \ufffe, <noncharacter-FFFE>
// in Unicode basic multilingual plane.
const PDU_NL_RESERVED_CONTROL = 0x0D;
const PDU_NL_IDENTIFIER_DEFAULT = 0;
const PDU_NL_IDENTIFIER_TURKISH = 1;
const PDU_NL_IDENTIFIER_SPANISH = 2;
const PDU_NL_IDENTIFIER_PORTUGUESE = 3;
const PDU_NL_IDENTIFIER_BENGALI = 4;
const PDU_NL_IDENTIFIER_GUJARATI = 5;
const PDU_NL_IDENTIFIER_HINDI = 6;
const PDU_NL_IDENTIFIER_KANNADA = 7;
const PDU_NL_IDENTIFIER_MALAYALAM = 8;
const PDU_NL_IDENTIFIER_ORIYA = 9;
const PDU_NL_IDENTIFIER_PUNJABI = 10;
const PDU_NL_IDENTIFIER_TAMIL = 11;
const PDU_NL_IDENTIFIER_TELUGU = 12;
const PDU_NL_IDENTIFIER_URDU = 13;
// National Language Locking Shift Tables, see 3GPP TS 23.038
const PDU_NL_LOCKING_SHIFT_TABLES = [
/**
* National Language Identifier: 0x00
* 6.2.1 GSM 7 bit Default Alphabet
*/
// 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....
"@\u00a3$\u00a5\u00e8\u00e9\u00f9\u00ec\u00f2\u00c7\n\u00d8\u00f8\r\u00c5\u00e5"
// 0.....12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u00c6\u00e6\u00df\u00c9"
// 012.34.....56789ABCDEF
+ " !\"#\u00a4%&'()*+,-./"
// 0123456789ABCDEF
+ "0123456789:;<=>?"
// 0.....123456789ABCDEF
+ "\u00a1ABCDEFGHIJKLMNO"
// 0123456789AB.....C.....D.....E.....F.....
+ "PQRSTUVWXYZ\u00c4\u00d6\u00d1\u00dc\u00a7"
// 0.....123456789ABCDEF
+ "\u00bfabcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u00e4\u00f6\u00f1\u00fc\u00e0",
/**
* National Language Identifier: 0x01
* A.3.1 Turkish National Language Locking Shift Table
*/
// 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....
"@\u00a3$\u00a5\u20ac\u00e9\u00f9\u0131\u00f2\u00c7\n\u011e\u011f\r\u00c5\u00e5"
// 0.....12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0394_\u03a6\u0393\u039b\u03a9\u03a0\u03a8\u03a3\u0398\u039e\uffff\u015e\u015f\u00df\u00c9"
// 012.34.....56789ABCDEF
+ " !\"#\u00a4%&'()*+,-./"
// 0123456789ABCDEF
+ "0123456789:;<=>?"
// 0.....123456789ABCDEF
+ "\u0130ABCDEFGHIJKLMNO"
// 0123456789AB.....C.....D.....E.....F.....
+ "PQRSTUVWXYZ\u00c4\u00d6\u00d1\u00dc\u00a7"
// 0.....123456789ABCDEF
+ "\u00e7abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u00e4\u00f6\u00f1\u00fc\u00e0",
/**
* National Language Identifier: 0x02
* A.3.2 Void
*/
// 0123456789A.BCD.EF
" \n \r "
// 0123456789AB.....CDEF
+ " \uffff "
// 0123456789ABCDEF
+ " "
// 0123456789ABCDEF
+ " "
// 0123456789ABCDEF
+ " "
// 0123456789ABCDEF
+ " "
// 0123456789ABCDEF
+ " "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x03
* A.3.3 Portuguese National Language Locking Shift Table
*/
// 01.....23.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....
"@\u00a3$\u00a5\u00ea\u00e9\u00fa\u00ed\u00f3\u00e7\n\u00d4\u00f4\r\u00c1\u00e1"
// 0.....12.....3.....4.....5.....67.8.....9.....AB.....C.....D.....E.....F.....
+ "\u0394_\u00aa\u00c7\u00c0\u221e^\\\u20ac\u00d3|\uffff\u00c2\u00e2\u00ca\u00c9"
// 012.34.....56789ABCDEF
+ " !\"#\u00ba%&'()*+,-./"
// 0123456789ABCDEF
+ "0123456789:;<=>?"
// 0.....123456789ABCDEF
+ "\u00cdABCDEFGHIJKLMNO"
// 0123456789AB.....C.....D.....E.....F.....
+ "PQRSTUVWXYZ\u00c3\u00d5\u00da\u00dc\u00a7"
// 0123456789ABCDEF
+ "~abcdefghijklmno"
// 0123456789AB.....C.....DE.....F.....
+ "pqrstuvwxyz\u00e3\u00f5`\u00fc\u00e0",
/**
* National Language Identifier: 0x04
* A.3.4 Bengali National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....
"\u0981\u0982\u0983\u0985\u0986\u0987\u0988\u0989\u098a\u098b\n\u098c \r \u098f"
// 0.....123.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0990 \u0993\u0994\u0995\u0996\u0997\u0998\u0999\u099a\uffff\u099b\u099c\u099d\u099e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u099f\u09a0\u09a1\u09a2\u09a3\u09a4)(\u09a5\u09a6,\u09a7.\u09a8"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u09aa\u09ab?"
// 0.....1.....2.....3.....4.....56.....789A.....B.....C.....D.....E.....F.....
+ "\u09ac\u09ad\u09ae\u09af\u09b0 \u09b2 \u09b6\u09b7\u09b8\u09b9\u09bc\u09bd"
// 0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD.....E.....F.....
+ "\u09be\u09bf\u09c0\u09c1\u09c2\u09c3\u09c4 \u09c7\u09c8 \u09cb\u09cc\u09cd"
// 0.....123456789ABCDEF
+ "\u09ceabcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u09d7\u09dc\u09dd\u09f0\u09f1",
/**
* National Language Identifier: 0x05
* A.3.5 Gujarati National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.EF.....
"\u0a81\u0a82\u0a83\u0a85\u0a86\u0a87\u0a88\u0a89\u0a8a\u0a8b\n\u0a8c\u0a8d\r \u0a8f"
// 0.....1.....23.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0a90\u0a91 \u0a93\u0a94\u0a95\u0a96\u0a97\u0a98\u0a99\u0a9a\uffff\u0a9b\u0a9c\u0a9d\u0a9e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u0a9f\u0aa0\u0aa1\u0aa2\u0aa3\u0aa4)(\u0aa5\u0aa6,\u0aa7.\u0aa8"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u0aaa\u0aab?"
// 0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C.....D.....E.....F.....
+ "\u0aac\u0aad\u0aae\u0aaf\u0ab0 \u0ab2\u0ab3 \u0ab5\u0ab6\u0ab7\u0ab8\u0ab9\u0abc\u0abd"
// 0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B.....CD.....E.....F.....
+ "\u0abe\u0abf\u0ac0\u0ac1\u0ac2\u0ac3\u0ac4\u0ac5 \u0ac7\u0ac8\u0ac9 \u0acb\u0acc\u0acd"
// 0.....123456789ABCDEF
+ "\u0ad0abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0ae0\u0ae1\u0ae2\u0ae3\u0af1",
/**
* National Language Identifier: 0x06
* A.3.6 Hindi National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....
"\u0901\u0902\u0903\u0905\u0906\u0907\u0908\u0909\u090a\u090b\n\u090c\u090d\r\u090e\u090f"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0910\u0911\u0912\u0913\u0914\u0915\u0916\u0917\u0918\u0919\u091a\uffff\u091b\u091c\u091d\u091e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u091f\u0920\u0921\u0922\u0923\u0924)(\u0925\u0926,\u0927.\u0928"
// 0123456789ABC.....D.....E.....F
+ "0123456789:;\u0929\u092a\u092b?"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u092c\u092d\u092e\u092f\u0930\u0931\u0932\u0933\u0934\u0935\u0936\u0937\u0938\u0939\u093c\u093d"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u093e\u093f\u0940\u0941\u0942\u0943\u0944\u0945\u0946\u0947\u0948\u0949\u094a\u094b\u094c\u094d"
// 0.....123456789ABCDEF
+ "\u0950abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0972\u097b\u097c\u097e\u097f",
/**
* National Language Identifier: 0x07
* A.3.7 Kannada National Language Locking Shift Table
*/
// 01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....
" \u0c82\u0c83\u0c85\u0c86\u0c87\u0c88\u0c89\u0c8a\u0c8b\n\u0c8c \r\u0c8e\u0c8f"
// 0.....12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0c90 \u0c92\u0c93\u0c94\u0c95\u0c96\u0c97\u0c98\u0c99\u0c9a\uffff\u0c9b\u0c9c\u0c9d\u0c9e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u0c9f\u0ca0\u0ca1\u0ca2\u0ca3\u0ca4)(\u0ca5\u0ca6,\u0ca7.\u0ca8"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u0caa\u0cab?"
// 0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B.....C.....D.....E.....F.....
+ "\u0cac\u0cad\u0cae\u0caf\u0cb0\u0cb1\u0cb2\u0cb3 \u0cb5\u0cb6\u0cb7\u0cb8\u0cb9\u0cbc\u0cbd"
// 0.....1.....2.....3.....4.....5.....6.....78.....9.....A.....BC.....D.....E.....F.....
+ "\u0cbe\u0cbf\u0cc0\u0cc1\u0cc2\u0cc3\u0cc4 \u0cc6\u0cc7\u0cc8 \u0cca\u0ccb\u0ccc\u0ccd"
// 0.....123456789ABCDEF
+ "\u0cd5abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0cd6\u0ce0\u0ce1\u0ce2\u0ce3",
/**
* National Language Identifier: 0x08
* A.3.8 Malayalam National Language Locking Shift Table
*/
// 01.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....
" \u0d02\u0d03\u0d05\u0d06\u0d07\u0d08\u0d09\u0d0a\u0d0b\n\u0d0c \r\u0d0e\u0d0f"
// 0.....12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0d10 \u0d12\u0d13\u0d14\u0d15\u0d16\u0d17\u0d18\u0d19\u0d1a\uffff\u0d1b\u0d1c\u0d1d\u0d1e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u0d1f\u0d20\u0d21\u0d22\u0d23\u0d24)(\u0d25\u0d26,\u0d27.\u0d28"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u0d2a\u0d2b?"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....EF.....
+ "\u0d2c\u0d2d\u0d2e\u0d2f\u0d30\u0d31\u0d32\u0d33\u0d34\u0d35\u0d36\u0d37\u0d38\u0d39 \u0d3d"
// 0.....1.....2.....3.....4.....5.....6.....78.....9.....A.....BC.....D.....E.....F.....
+ "\u0d3e\u0d3f\u0d40\u0d41\u0d42\u0d43\u0d44 \u0d46\u0d47\u0d48 \u0d4a\u0d4b\u0d4c\u0d4d"
// 0.....123456789ABCDEF
+ "\u0d57abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0d60\u0d61\u0d62\u0d63\u0d79",
/**
* National Language Identifier: 0x09
* A.3.9 Oriya National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.EF.....
"\u0b01\u0b02\u0b03\u0b05\u0b06\u0b07\u0b08\u0b09\u0b0a\u0b0b\n\u0b0c \r \u0b0f"
// 0.....123.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0b10 \u0b13\u0b14\u0b15\u0b16\u0b17\u0b18\u0b19\u0b1a\uffff\u0b1b\u0b1c\u0b1d\u0b1e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u0b1f\u0b20\u0b21\u0b22\u0b23\u0b24)(\u0b25\u0b26,\u0b27.\u0b28"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u0b2a\u0b2b?"
// 0.....1.....2.....3.....4.....56.....7.....89.....A.....B.....C.....D.....E.....F.....
+ "\u0b2c\u0b2d\u0b2e\u0b2f\u0b30 \u0b32\u0b33 \u0b35\u0b36\u0b37\u0b38\u0b39\u0b3c\u0b3d"
// 0.....1.....2.....3.....4.....5.....6.....789.....A.....BCD.....E.....F.....
+ "\u0b3e\u0b3f\u0b40\u0b41\u0b42\u0b43\u0b44 \u0b47\u0b48 \u0b4b\u0b4c\u0b4d"
// 0.....123456789ABCDEF
+ "\u0b56abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0b57\u0b60\u0b61\u0b62\u0b63",
/**
* National Language Identifier: 0x0A
* A.3.10 Punjabi National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.EF.....
"\u0a01\u0a02\u0a03\u0a05\u0a06\u0a07\u0a08\u0a09\u0a0a \n \r \u0a0f"
// 0.....123.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0a10 \u0a13\u0a14\u0a15\u0a16\u0a17\u0a18\u0a19\u0a1a\uffff\u0a1b\u0a1c\u0a1d\u0a1e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u0a1f\u0a20\u0a21\u0a22\u0a23\u0a24)(\u0a25\u0a26,\u0a27.\u0a28"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u0a2a\u0a2b?"
// 0.....1.....2.....3.....4.....56.....7.....89.....A.....BC.....D.....E.....F
+ "\u0a2c\u0a2d\u0a2e\u0a2f\u0a30 \u0a32\u0a33 \u0a35\u0a36 \u0a38\u0a39\u0a3c "
// 0.....1.....2.....3.....4.....56789.....A.....BCD.....E.....F.....
+ "\u0a3e\u0a3f\u0a40\u0a41\u0a42 \u0a47\u0a48 \u0a4b\u0a4c\u0a4d"
// 0.....123456789ABCDEF
+ "\u0a51abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0a70\u0a71\u0a72\u0a73\u0a74",
/**
* National Language Identifier: 0x0B
* A.3.11 Tamil National Language Locking Shift Table
*/
// 01.....2.....3.....4.....5.....6.....7.....8.....9A.BCD.E.....F.....
" \u0b82\u0b83\u0b85\u0b86\u0b87\u0b88\u0b89\u0b8a \n \r\u0b8e\u0b8f"
// 0.....12.....3.....4.....5.....6789.....A.....B.....CD.....EF.....
+ "\u0b90 \u0b92\u0b93\u0b94\u0b95 \u0b99\u0b9a\uffff \u0b9c \u0b9e"
// 012.....3456.....7.....89ABCDEF.....
+ " !\u0b9f \u0ba3\u0ba4)( , .\u0ba8"
// 0123456789ABC.....D.....EF
+ "0123456789:;\u0ba9\u0baa ?"
// 012.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....EF
+ " \u0bae\u0baf\u0bb0\u0bb1\u0bb2\u0bb3\u0bb4\u0bb5\u0bb6\u0bb7\u0bb8\u0bb9 "
// 0.....1.....2.....3.....4.....5678.....9.....A.....BC.....D.....E.....F.....
+ "\u0bbe\u0bbf\u0bc0\u0bc1\u0bc2 \u0bc6\u0bc7\u0bc8 \u0bca\u0bcb\u0bcc\u0bcd"
// 0.....123456789ABCDEF
+ "\u0bd0abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0bd7\u0bf0\u0bf1\u0bf2\u0bf9",
/**
* National Language Identifier: 0x0C
* A.3.12 Telugu National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....CD.E.....F.....
"\u0c01\u0c02\u0c03\u0c05\u0c06\u0c07\u0c08\u0c09\u0c0a\u0c0b\n\u0c0c \r\u0c0e\u0c0f"
// 0.....12.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0c10 \u0c12\u0c13\u0c14\u0c15\u0c16\u0c17\u0c18\u0c19\u0c1a\uffff\u0c1b\u0c1c\u0c1d\u0c1e"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u0c1f\u0c20\u0c21\u0c22\u0c23\u0c24)(\u0c25\u0c26,\u0c27.\u0c28"
// 0123456789ABCD.....E.....F
+ "0123456789:; \u0c2a\u0c2b?"
// 0.....1.....2.....3.....4.....5.....6.....7.....89.....A.....B.....C.....D.....EF.....
+ "\u0c2c\u0c2d\u0c2e\u0c2f\u0c30\u0c31\u0c32\u0c33 \u0c35\u0c36\u0c37\u0c38\u0c39 \u0c3d"
// 0.....1.....2.....3.....4.....5.....6.....78.....9.....A.....BC.....D.....E.....F.....
+ "\u0c3e\u0c3f\u0c40\u0c41\u0c42\u0c43\u0c44 \u0c46\u0c47\u0c48 \u0c4a\u0c4b\u0c4c\u0c4d"
// 0.....123456789ABCDEF
+ "\u0c55abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0c56\u0c60\u0c61\u0c62\u0c63",
/**
* National Language Identifier: 0x0D
* A.3.13 Urdu National Language Locking Shift Table
*/
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.B.....C.....D.E.....F.....
"\u0627\u0622\u0628\u067b\u0680\u067e\u06a6\u062a\u06c2\u067f\n\u0679\u067d\r\u067a\u067c"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u062b\u062c\u0681\u0684\u0683\u0685\u0686\u0687\u062d\u062e\u062f\uffff\u068c\u0688\u0689\u068a"
// 012.....3.....4.....5.....6.....7.....89A.....B.....CD.....EF.....
+ " !\u068f\u068d\u0630\u0631\u0691\u0693)(\u0699\u0632,\u0696.\u0698"
// 0123456789ABC.....D.....E.....F
+ "0123456789:;\u069a\u0633\u0634?"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u0635\u0636\u0637\u0638\u0639\u0641\u0642\u06a9\u06aa\u06ab\u06af\u06b3\u06b1\u0644\u0645\u0646"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....C.....D.....E.....F.....
+ "\u06ba\u06bb\u06bc\u0648\u06c4\u06d5\u06c1\u06be\u0621\u06cc\u06d0\u06d2\u064d\u0650\u064f\u0657"
// 0.....123456789ABCDEF
+ "\u0654abcdefghijklmno"
// 0123456789AB.....C.....D.....E.....F.....
+ "pqrstuvwxyz\u0655\u0651\u0653\u0656\u0670"
];
// National Language Single Shift Tables, see 3GPP TS 23.038
const PDU_NL_SINGLE_SHIFT_TABLES = [
/**
* National Language Identifier: 0x00
* 6.2.1.1 GSM 7 bit default alphabet extension table
*/
// 0123456789A.....BCD.....EF
" \u000c \ufffe "
// 0123456789AB.....CDEF
+ " ^ \uffff "
// 0123456789ABCDEF.
+ " {} \\"
// 0123456789ABCDEF
+ " [~] "
// 0123456789ABCDEF
+ "| "
// 0123456789ABCDEF
+ " "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x01
* A.2.1 Turkish National Language Single Shift Table
*/
// 0123456789A.....BCD.....EF
" \u000c \ufffe "
// 0123456789AB.....CDEF
+ " ^ \uffff "
// 0123456789ABCDEF.
+ " {} \\"
// 0123456789ABCDEF
+ " [~] "
// 01234567.....89.....ABCDEF
+ "| \u011e \u0130 "
// 0123.....456789ABCDEF
+ " \u015e "
// 0123.....45.....67.....89.....ABCDEF
+ " \u00e7 \u20ac \u011f \u0131 "
// 0123.....456789ABCDEF
+ " \u015f ",
/**
* National Language Identifier: 0x02
* A.2.2 Spanish National Language Single Shift Table
*/
// 0123456789.....A.....BCD.....EF
" \u00e7\u000c \ufffe "
// 0123456789AB.....CDEF
+ " ^ \uffff "
// 0123456789ABCDEF.
+ " {} \\"
// 0123456789ABCDEF
+ " [~] "
// 01.....23456789.....ABCDEF.....
+ "|\u00c1 \u00cd \u00d3"
// 012345.....6789ABCDEF
+ " \u00da "
// 01.....2345.....6789.....ABCDEF.....
+ " \u00e1 \u20ac \u00ed \u00f3"
// 012345.....6789ABCDEF
+ " \u00fa ",
/**
* National Language Identifier: 0x03
* A.2.3 Portuguese National Language Single Shift Table
*/
// 012345.....6789.....A.....B.....C.....D.....E.....F.....
" \u00ea \u00e7\u000c\u00d4\u00f4\ufffe\u00c1\u00e1"
// 012.....3.....45.....6.....7.....8.....9.....AB.....CDEF.....
+ " \u03a6\u0393^\u03a9\u03a0\u03a8\u03a3\u0398 \uffff \u00ca"
// 0123456789ABCDEF.
+ " {} \\"
// 0123456789ABCDEF
+ " [~] "
// 01.....23456789.....ABCDEF.....
+ "|\u00c0 \u00cd \u00d3"
// 012345.....6789AB.....C.....DEF
+ " \u00da \u00c3\u00d5 "
// 01.....2345.....6789.....ABCDEF.....
+ " \u00c2 \u20ac \u00ed \u00f3"
// 012345.....6789AB.....C.....DEF.....
+ " \u00fa \u00e3\u00f5 \u00e2",
/**
* National Language Identifier: 0x04
* A.2.4 Bengali National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u09e6\u09e7\uffff\u09e8\u09e9\u09ea\u09eb"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
+ "\u09ec\u09ed\u09ee\u09ef\u09df\u09e0\u09e1\u09e2{}\u09e3\u09f2\u09f3\u09f4\u09f5\\"
// 0.....1.....2.....3.....4.....56789ABCDEF
+ "\u09f6\u09f7\u09f8\u09f9\u09fa [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x05
* A.2.5 Gujarati National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0ae6\u0ae7\u0ae8\u0ae9"
// 0.....1.....2.....3.....4.....5.....6789ABCDEF.
+ "\u0aea\u0aeb\u0aec\u0aed\u0aee\u0aef {} \\"
// 0123456789ABCDEF
+ " [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x06
* A.2.6 Hindi National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0966\u0967\u0968\u0969"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
+ "\u096a\u096b\u096c\u096d\u096e\u096f\u0951\u0952{}\u0953\u0954\u0958\u0959\u095a\\"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....BCDEF
+ "\u095b\u095c\u095d\u095e\u095f\u0960\u0961\u0962\u0963\u0970\u0971 [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x07
* A.2.7 Kannada National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0ce6\u0ce7\u0ce8\u0ce9"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....BCDEF.
+ "\u0cea\u0ceb\u0cec\u0ced\u0cee\u0cef\u0cde\u0cf1{}\u0cf2 \\"
// 0123456789ABCDEF
+ " [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x08
* A.2.8 Malayalam National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0d66\u0d67\u0d68\u0d69"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
+ "\u0d6a\u0d6b\u0d6c\u0d6d\u0d6e\u0d6f\u0d70\u0d71{}\u0d72\u0d73\u0d74\u0d75\u0d7a\\"
// 0.....1.....2.....3.....4.....56789ABCDEF
+ "\u0d7b\u0d7c\u0d7d\u0d7e\u0d7f [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x09
* A.2.9 Oriya National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0b66\u0b67\u0b68\u0b69"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....DEF.
+ "\u0b6a\u0b6b\u0b6c\u0b6d\u0b6e\u0b6f\u0b5c\u0b5d{}\u0b5f\u0b70\u0b71 \\"
// 0123456789ABCDEF
+ " [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x0A
* A.2.10 Punjabi National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0a66\u0a67\u0a68\u0a69"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....EF.
+ "\u0a6a\u0a6b\u0a6c\u0a6d\u0a6e\u0a6f\u0a59\u0a5a{}\u0a5b\u0a5c\u0a5e\u0a75 \\"
// 0123456789ABCDEF
+ " [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x0B
* A.2.11 Tamil National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0964\u0965\uffff\u0be6\u0be7\u0be8\u0be9"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
+ "\u0bea\u0beb\u0bec\u0bed\u0bee\u0bef\u0bf3\u0bf4{}\u0bf5\u0bf6\u0bf7\u0bf8\u0bfa\\"
// 0123456789ABCDEF
+ " [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x0C
* A.2.12 Telugu National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789AB.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#* \uffff\u0c66\u0c67\u0c68\u0c69"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
+ "\u0c6a\u0c6b\u0c6c\u0c6d\u0c6e\u0c6f\u0c58\u0c59{}\u0c78\u0c79\u0c7a\u0c7b\u0c7c\\"
// 0.....1.....2.....3456789ABCDEF
+ "\u0c7d\u0c7e\u0c7f [~] "
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " ",
/**
* National Language Identifier: 0x0D
* A.2.13 Urdu National Language Single Shift Table
*/
// 01.....23.....4.....5.6.....789A.....BCD.....EF
"@\u00a3$\u00a5\u00bf\"\u00a4%&'\u000c*+\ufffe-/"
// 0123.....45.....6789.....A.....B.....C.....D.....E.....F.....
+ "<=>\u00a1^\u00a1_#*\u0600\u0601\uffff\u06f0\u06f1\u06f2\u06f3"
// 0.....1.....2.....3.....4.....5.....6.....7.....89A.....B.....C.....D.....E.....F.
+ "\u06f4\u06f5\u06f6\u06f7\u06f8\u06f9\u060c\u060d{}\u060e\u060f\u0610\u0611\u0612\\"
// 0.....1.....2.....3.....4.....5.....6.....7.....8.....9.....A.....B.....CDEF.....
+ "\u0613\u0614\u061b\u061f\u0640\u0652\u0658\u066b\u066c\u0672\u0673\u06cd[~]\u06d4"
// 0123456789ABCDEF
+ "|ABCDEFGHIJKLMNO"
// 0123456789ABCDEF
+ "PQRSTUVWXYZ "
// 012345.....6789ABCDEF
+ " \u20ac "
// 0123456789ABCDEF
+ " "
];
const DATACALL_RADIOTECHNOLOGY_CDMA = 0;

View File

@ -790,8 +790,16 @@ let RIL = {
* @param dcs
* Data coding scheme. One of the PDU_DCS_MSG_CODING_*BITS_ALPHABET
* constants.
* @param bodyLengthInOctets
* Byte length of the message body when encoded with the given DCS.
* @param userDataHeaderLength
* Length of embedded user data header, in bytes. The whole header
* size will be userDataHeaderLength + 1; 0 for no header.
* @param encodedBodyLength
* Length of the message body when encoded with the given DCS. For
* UCS2, in bytes; for 7-bit, in septets.
* @param langIndex
* Table index used for normal 7-bit encoded character lookup.
* @param langShiftIndex
* Table index used for escaped 7-bit encoded character lookup.
*/
sendSMS: function sendSMS(options) {
let token = Buf.newParcel(REQUEST_SEND_SMS, options);
@ -801,10 +809,7 @@ let RIL = {
// handle it within tokenRequestMap[].
Buf.writeUint32(2);
Buf.writeString(options.SMSC);
GsmPDUHelper.writeMessage(options.number,
options.body,
options.dcs,
options.bodyLengthInOctets);
GsmPDUHelper.writeMessage(options);
Buf.sendParcel();
},
@ -2164,6 +2169,13 @@ let Phone = {
*/
let GsmPDUHelper = {
/**
* List of tuples of national language identifier pairs.
*/
enabledGsmTableTuples: [
[PDU_NL_IDENTIFIER_DEFAULT, PDU_NL_IDENTIFIER_DEFAULT],
],
/**
* Read one character (2 bytes) from a RIL string and decode as hex.
*
@ -2283,66 +2295,126 @@ let GsmPDUHelper = {
*
* @param length
* Number of septets to read (*not* octets)
* @param paddingBits
* Number of padding bits in the first byte of user data.
* @param langIndex
* Table index used for normal 7-bit encoded character lookup.
* @param langShiftIndex
* Table index used for escaped 7-bit encoded character lookup.
*
* @return a string.
*
* TODO: support other alphabets
* TODO: support escape chars
*/
readSeptetsToString: function readSeptetsToString(length) {
readSeptetsToString: function readSeptetsToString(length, paddingBits, langIndex, langShiftIndex) {
let ret = "";
let byteLength = Math.ceil(length * 7 / 8);
let byteLength = Math.ceil((length * 7 + paddingBits) / 8);
let leftOver = 0;
for (let i = 0; i < byteLength; i++) {
let octet = this.readHexOctet();
let shift = (i % 7);
let leftOver_mask = (0xff << (7 - shift)) & 0xff;
let septet_mask = (0xff >> (shift + 1));
let septet = ((octet & septet_mask) << shift) | leftOver;
ret += PDU_ALPHABET_7BIT_DEFAULT[septet];
leftOver = (octet & leftOver_mask) >> (7 - shift);
// Every 7th byte we have a whole septet left over that we can apply.
if (shift == 6) {
ret += PDU_ALPHABET_7BIT_DEFAULT[leftOver];
leftOver = 0;
}
/**
* |<- last byte in header ->|
* |<- incompleteBits ->|<- last header septet->|
* +===7===|===6===|===5===|===4===|===3===|===2===|===1===|===0===|
*
* |<- 1st byte in user data ->|
* |<- data septet 1 ->|<-paddingBits->|
* +===7===|===6===|===5===|===4===|===3===|===2===|===1===|===0===|
*
* |<- 2nd byte in user data ->|
* |<- data spetet 2 ->|<-ds1->|
* +===7===|===6===|===5===|===4===|===3===|===2===|===1===|===0===|
*/
let data = 0;
let dataBits = 0;
if (paddingBits) {
data = this.readHexOctet() >> paddingBits;
dataBits = 8 - paddingBits;
--byteLength;
}
let escapeFound = false;
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[langIndex];
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[langShiftIndex];
do {
// Read as much as fits in 32bit word
let bytesToRead = Math.min(byteLength, dataBits ? 3 : 4);
for (let i = 0; i < bytesToRead; i++) {
data |= this.readHexOctet() << dataBits;
dataBits += 8;
--byteLength;
}
// Consume available full septets
for (; dataBits >= 7; dataBits -= 7) {
let septet = data & 0x7F;
data >>>= 7;
if (escapeFound) {
escapeFound = false;
if (septet == PDU_NL_EXTENDED_ESCAPE) {
// According to 3GPP TS 23.038, section 6.2.1.1, NOTE 1, "On
// receipt of this code, a receiving entity shall display a space
// until another extensiion table is defined."
ret += " ";
} else if (septet == PDU_NL_RESERVED_CONTROL) {
// According to 3GPP TS 23.038 B.2, "This code represents a control
// character and therefore must not be used for language specific
// characters."
ret += " ";
} else {
ret += langShiftTable[septet];
}
} else if (septet == PDU_NL_EXTENDED_ESCAPE) {
escapeFound = true;
} else {
ret += langTable[septet];
}
}
} while (byteLength);
if (ret.length != length) {
ret = ret.slice(0, length);
}
return ret;
},
writeStringAsSeptets: function writeStringAsSeptets(message) {
let right = 0;
for (let i = 0; i < message.length + 1; i++) {
let shift = (i % 8);
let septet;
if (i < message.length) {
septet = PDU_ALPHABET_7BIT_DEFAULT.indexOf(message[i]);
} else {
septet = 0;
}
if (septet == -1) {
if (DEBUG) debug("Fffff, " + message[i] + " not in 7 bit alphabet!");
septet = 0;
}
if (shift == 0) {
// We're at the beginning of a cycle, but we need two septet values
// to make an octet. So we're going to have to sit this one out.
right = septet;
writeStringAsSeptets: function writeStringAsSeptets(message, paddingBits, langIndex, langShiftIndex) {
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[langIndex];
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[langShiftIndex];
let dataBits = paddingBits;
let data = 0;
for (let i = 0; i < message.length; i++) {
let septet = langTable.indexOf(message[i]);
if (septet == PDU_NL_EXTENDED_ESCAPE) {
continue;
}
let left_mask = 0xff >> (8 - shift);
let right_mask = (0xff << shift) & 0xff;
let left = (septet & left_mask) << (8 - shift);
let octet = left | right;
this.writeHexOctet(left | right);
right = (septet & right_mask) >> shift;
if (septet >= 0) {
data |= septet << dataBits;
dataBits += 7;
} else {
septet = langShiftTable.indexOf(message[i]);
if (septet == -1) {
throw new Error(message[i] + " not in 7 bit alphabet "
+ langIndex + ":" + langShiftIndex + "!");
}
if (septet == PDU_NL_RESERVED_CONTROL) {
continue;
}
data |= PDU_NL_EXTENDED_ESCAPE << dataBits;
dataBits += 7;
data |= septet << dataBits;
dataBits += 7;
}
for (; dataBits >= 8; dataBits -= 8) {
this.writeHexOctet(data & 0xFF);
data >>>= 8;
}
}
if (dataBits != 0) {
this.writeHexOctet(data & 0xFF);
}
},
@ -2381,37 +2453,231 @@ let GsmPDUHelper = {
}
},
/**
* Calculate encoded length using specified locking/single shift table
*
* @param message
* message string to be encoded.
* @param langTable
* locking shift table string.
* @param langShiftTable
* single shift table string.
*
* @note that the algorithm used in this function must match exactly with
* #writeStringAsSeptets.
*/
_calculateLangEncodedLength: function _calculateLangEncodedLength(message, langTable, langShiftTable) {
let length = 0;
for (let msgIndex = 0; msgIndex < message.length; msgIndex++) {
let septet = langTable.indexOf(message.charAt(msgIndex));
// According to 3GPP TS 23.038, section 6.1.1 General notes, "The
// characters marked '1)' are not used but are displayed as a space."
if (septet == PDU_NL_EXTENDED_ESCAPE) {
continue;
}
if (septet >= 0) {
length++;
continue;
}
septet = langShiftTable.indexOf(message.charAt(msgIndex));
if (septet == -1) {
return -1;
}
// According to 3GPP TS 23.038 B.2, "This code represents a control
// character and therefore must not be used for language specific
// characters."
if (septet == PDU_NL_RESERVED_CONTROL) {
continue;
}
// The character is not found in locking shfit table, but could be
// encoded as <escape><char> with single shift table. Note that it's
// still possible for septet to has the value of PDU_NL_EXTENDED_ESCAPE,
// but we can display it as a space in this case as said in previous
// comment.
length += 2;
}
return length;
},
/**
* Calculate user data length and its encoding.
*
* The `options` parameter object should contain the `body` attribute, and
* the `dcs`, `bodyLengthInOctets` attributes will be set as return:
* the `dcs`, `userDataHeaderLength`, `encodedBodyLength`, `langIndex`,
* `langShiftIndex` attributes will be set as return:
*
* @param body
* String containing the message body.
* @param dcs
* Data coding scheme. One of the PDU_DCS_MSG_CODING_*BITS_ALPHABET
* constants.
* @param bodyLengthInOctets
* Byte length of the message body when encoded with the given DCS.
* @param userDataHeaderLength
* Length of embedded user data header, in bytes. The whole header
* size will be userDataHeaderLength + 1; 0 for no header.
* @param encodedBodyLength
* Length of the message body when encoded with the given DCS. For
* UCS2, in bytes; for 7-bit, in septets.
* @param langIndex
* Table index used for normal 7-bit encoded character lookup.
* @param langShiftIndex
* Table index used for escaped 7-bit encoded character lookup.
*/
calculateUserDataLength: function calculateUserDataLength(options) {
//TODO: support language tables, see bug 729876
//TODO: support multipart SMS, see bug 712933
let needUCS2 = false;
for (let i = 0; i < options.body.length; ++i) {
if (options.body.charCodeAt(i) >= 128) {
needUCS2 = true;
break;
options.dcs = PDU_DCS_MSG_CODING_7BITS_ALPHABET;
options.langIndex = PDU_NL_IDENTIFIER_DEFAULT;
options.langShiftIndex = PDU_NL_IDENTIFIER_DEFAULT;
options.encodedBodyLength = 0;
options.userDataHeaderLength = 0;
let needUCS2 = true;
let minUserDataLength = Number.MAX_VALUE;
for (let i = 0; i < this.enabledGsmTableTuples.length; i++) {
let [langIndex, langShiftIndex] = this.enabledGsmTableTuples[i];
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[langIndex];
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[langShiftIndex];
let length = this._calculateLangEncodedLength(options.body,
langTable,
langShiftTable);
if (length < 0) {
continue;
}
let headerLen = 0;
if (langIndex != PDU_NL_IDENTIFIER_DEFAULT) {
headerLen += 3; // IEI + len + langIndex
}
if (langShiftIndex != PDU_NL_IDENTIFIER_DEFAULT) {
headerLen += 3; // IEI + len + langShiftIndex
}
// Calculate full user data length, note the extra byte is for header len
let userDataLength = length + (headerLen ? headerLen + 1 : 0);
if (userDataLength >= minUserDataLength) {
continue;
}
needUCS2 = false;
minUserDataLength = userDataLength;
options.encodedBodyLength = length;
options.userDataHeaderLength = headerLen;
options.langIndex = langIndex;
options.langShiftIndex = langShiftIndex;
if (userDataLength <= options.body.length) {
// Found minimum user data length already
return;
}
}
if (needUCS2) {
options.dcs = PDU_DCS_MSG_CODING_16BITS_ALPHABET;
options.bodyLengthInOctets = options.body.length * 2;
} else {
options.dcs = PDU_DCS_MSG_CODING_7BITS_ALPHABET;
options.bodyLengthInOctets = Math.ceil(options.body.length * 7 / 8);
options.encodedBodyLength = options.body.length * 2;
options.userDataHeaderLength = 0;
}
},
/**
* Read 1 + UDHL octets and construct user data header at return.
*
* @return A header object with properties contained in received message.
* The properties set include:
* <ul>
* <li>length: totoal length of the header, default 0.
* <li>langIndex: used locking shift table index, default
* PDU_NL_IDENTIFIER_DEFAULT.
* <li>langShiftIndex: used locking shift table index, default
* PDU_NL_IDENTIFIER_DEFAULT.
* </ul>
*/
readUserDataHeader: function readUserDataHeader() {
let header = {
length: 0,
langIndex: PDU_NL_IDENTIFIER_DEFAULT,
langShiftIndex: PDU_NL_IDENTIFIER_DEFAULT
};
header.length = this.readHexOctet();
let dataAvailable = header.length;
while (dataAvailable >= 2) {
let id = this.readHexOctet();
let length = this.readHexOctet();
dataAvailable -= 2;
switch (id) {
case PDU_IEI_NATIONAL_LANGUAGE_SINGLE_SHIFT:
let langShiftIndex = this.readHexOctet();
--dataAvailable;
if (langShiftIndex < PDU_NL_SINGLE_SHIFT_TABLES.length) {
header.langShiftIndex = langShiftIndex;
}
break;
case PDU_IEI_NATIONAL_LANGUAGE_LOCKING_SHIFT:
let langIndex = this.readHexOctet();
--dataAvailable;
if (langIndex < PDU_NL_LOCKING_SHIFT_TABLES.length) {
header.langIndex = langIndex;
}
break;
default:
if (DEBUG) {
debug("readUserDataHeader: unsupported IEI(" + id
+ "), " + length + " bytes.");
}
// Read out unsupported data
if (length) {
let octets;
if (DEBUG) octets = new Uint8Array(length);
for (let i = 0; i < length; i++) {
let octet = this.readHexOctet();
if (DEBUG) octets[i] = octet;
}
dataAvailable -= length;
if (DEBUG) debug("readUserDataHeader: " + Array.slice(octets));
}
break;
}
}
if (dataAvailable != 0) {
throw new Error("Illegal user data header found!");
}
return header;
},
/**
* Write out user data header.
*
* @param options
* Options containing information for user data header write-out. The
* `userDataHeaderLength` property must be correctly pre-calculated.
*/
writeUserDataHeader: function writeUserDataHeader(options) {
this.writeHexOctet(options.userDataHeaderLength);
if (options.langIndex != PDU_NL_IDENTIFIER_DEFAULT) {
this.writeHexOctet(PDU_IEI_NATIONAL_LANGUAGE_LOCKING_SHIFT);
this.writeHexOctet(1);
this.writeHexOctet(options.langIndex);
}
if (options.langShiftIndex != PDU_NL_IDENTIFIER_DEFAULT) {
this.writeHexOctet(PDU_IEI_NATIONAL_LANGUAGE_SINGLE_SHIFT);
this.writeHexOctet(1);
this.writeHexOctet(options.langShiftIndex);
}
},
@ -2419,7 +2685,7 @@ let GsmPDUHelper = {
* User data can be 7 bit (default alphabet) data, 8 bit data, or 16 bit
* (UCS2) data.
*/
readUserData: function readUserData(length, codingScheme) {
readUserData: function readUserData(length, codingScheme, hasHeader) {
if (DEBUG) {
debug("Reading " + length + " bytes of user data.");
debug("Coding scheme: " + codingScheme);
@ -2456,6 +2722,22 @@ let GsmPDUHelper = {
break;
}
let header;
let paddingBits = 0;
if (hasHeader) {
header = this.readUserDataHeader();
if (encoding == PDU_DCS_MSG_CODING_7BITS_ALPHABET) {
let headerBits = (header.length + 1) * 8;
let headerSeptets = Math.ceil(headerBits / 7);
length -= headerSeptets;
paddingBits = headerSeptets * 7 - headerBits;
} else {
length -= (header.length + 1);
}
}
if (DEBUG) debug("PDU: message encoding is " + encoding + " bit.");
switch (encoding) {
case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
@ -2465,7 +2747,11 @@ let GsmPDUHelper = {
if (DEBUG) debug("PDU error: user data is too long: " + length);
return null;
}
return this.readSeptetsToString(length);
return this.readSeptetsToString(length,
paddingBits,
hasHeader ? header.langIndex : PDU_NL_IDENTIFIER_DEFAULT,
hasHeader ? header.langShiftIndex : PDU_NL_IDENTIFIER_DEFAULT);
case PDU_DCS_MSG_CODING_8BITS_ALPHABET:
// Unsupported.
return null;
@ -2505,6 +2791,10 @@ let GsmPDUHelper = {
// First octet of this SMS-DELIVER or SMS-SUBMIT message
let firstOctet = this.readHexOctet();
// User data header indicator
let hasUserDataHeader = firstOctet & PDU_UDHI;
// if the sms is of SMS-SUBMIT type it would contain a TP-MR
let isSmsSubmit = firstOctet & PDU_MTI_SMS_SUBMIT;
if (isSmsSubmit) {
@ -2582,7 +2872,9 @@ let GsmPDUHelper = {
// - TP-User-Data -
if (userDataLength > 0) {
msg.body = this.readUserData(userDataLength, dataCodingScheme);
msg.body = this.readUserData(userDataLength,
dataCodingScheme,
hasUserDataHeader);
}
return msg;
@ -2602,13 +2894,29 @@ let GsmPDUHelper = {
* @param dcs
* Data coding scheme. One of the PDU_DCS_MSG_CODING_*BITS_ALPHABET
* constants.
* @param userDataLengthInOctets
* Byte length of the user data when encoded with the given DCS.
* @param userDataHeaderLength
* Length of embedded user data header, in bytes. The whole header
* size will be userDataHeaderLength + 1; 0 for no header.
* @param encodedBodyLength
* Length of the user data when encoded with the given DCS. For UCS2,
* in bytes; for 7-bit, in septets.
* @param langIndex
* Table index used for normal 7-bit encoded character lookup.
* @param langShiftIndex
* Table index used for escaped 7-bit encoded character lookup.
*/
writeMessage: function writeMessage(address,
userData,
dcs,
userDataLengthInOctets) {
writeMessage: function writeMessage(options) {
if (DEBUG) {
debug("writeMessage: " + JSON.stringify(options));
}
let address = options.number;
let body = options.body;
let dcs = options.dcs;
let userDataHeaderLength = options.userDataHeaderLength;
let encodedBodyLength = options.encodedBodyLength;
let langIndex = options.langIndex;
let langShiftIndex = options.langShiftIndex;
// SMS-SUBMIT Format:
//
// PDU Type - 1 octet
@ -2628,6 +2936,20 @@ let GsmPDUHelper = {
//TODO validity is unsupported for now
let validity = 0;
let headerOctets = (userDataHeaderLength ? userDataHeaderLength + 1 : 0);
let paddingBits;
let userDataLengthInSeptets;
let userDataLengthInOctets;
if (dcs == PDU_DCS_MSG_CODING_7BITS_ALPHABET) {
let headerSeptets = Math.ceil(headerOctets * 8 / 7);
userDataLengthInSeptets = headerSeptets + encodedBodyLength;
userDataLengthInOctets = Math.ceil(userDataLengthInSeptets * 7 / 8);
paddingBits = headerSeptets * 7 - headerOctets * 8;
} else {
userDataLengthInOctets = headerOctets + encodedBodyLength;
paddingBits = 0;
}
let pduOctetLength = 4 + // PDU Type, Message Ref, address length + format
Math.ceil(address.length / 2) +
3 + // PID, DCS, UDL
@ -2672,8 +2994,8 @@ let GsmPDUHelper = {
if (validity) {
//TODO: not supported yet, OR with one of PDU_VPF_*
}
let udhi = ""; //TODO: for now this is unsupported
if (udhi) {
// User data header indicator
if (headerOctets) {
firstOctet |= PDU_UDHI;
}
this.writeHexOctet(firstOctet);
@ -2699,20 +3021,25 @@ let GsmPDUHelper = {
}
// - User Data -
let userDataLength = userData.length;
if (dcs == PDU_DCS_MSG_CODING_16BITS_ALPHABET) {
userDataLength = userData.length * 2;
if (dcs == PDU_DCS_MSG_CODING_7BITS_ALPHABET) {
this.writeHexOctet(userDataLengthInSeptets);
} else {
this.writeHexOctet(userDataLengthInOctets);
}
this.writeHexOctet(userDataLength);
if (headerOctets) {
this.writeUserDataHeader(options);
}
switch (dcs) {
case PDU_DCS_MSG_CODING_7BITS_ALPHABET:
this.writeStringAsSeptets(userData);
this.writeStringAsSeptets(body, paddingBits, langIndex, langShiftIndex);
break;
case PDU_DCS_MSG_CODING_8BITS_ALPHABET:
// Unsupported.
break;
case PDU_DCS_MSG_CODING_16BITS_ALPHABET:
this.writeUCS2String(userData);
this.writeUCS2String(body);
break;
}

View File

@ -100,7 +100,7 @@ function startTest()
var secondKey = localStorage.key(1);
ok((firstKey == 'key1' && secondKey == 'key2') ||
(firstKey == 'key2' && secondKey == 'key1'),
'Both keys should be present.');
'key() API works.');
// change the second key
localStorage.setItem("key2", "value2-2");

View File

@ -119,7 +119,7 @@ function doTest()
var secondKey = localStorage.key(1);
ok((firstKey == 'key1' && secondKey == 'key2') ||
(firstKey == 'key2' && secondKey == 'key1'),
'Both keys should be present.');
'key() API works.');
// change the second key
localStorage.setItem("key2", "value2-2");

View File

@ -110,7 +110,7 @@ function startTest()
var secondKey = localStorage.key(1);
ok((firstKey == 'key1' && secondKey == 'key2') ||
(firstKey == 'key2' && secondKey == 'key1'),
'Both keys should be present.');
'key() API works.');
// change the second key
localStorage.setItem("key2", "value2-2");

View File

@ -102,7 +102,7 @@ function startTest()
var secondKey = sessionStorage.key(1);
ok((firstKey == 'key1' && secondKey == 'key2') ||
(firstKey == 'key2' && secondKey == 'key1'),
'Both keys should be present.');
'key() API works.');
// change the second key
sessionStorage.setItem("key2", "value2-2");

View File

@ -434,20 +434,27 @@ var WifiManager = (function() {
});
}
var dhcpInfo = null;
function runDhcp(ifname, callback) {
controlMessage({ cmd: "dhcp_do_request", ifname: ifname }, function(data) {
if (!data.status)
dhcpInfo = data;
callback(data.status ? null : data);
});
}
function stopDhcp(ifname, callback) {
controlMessage({ cmd: "dhcp_stop", ifname: ifname }, function(data) {
if (!data.status)
dhcpInfo = null;
callback(!data.status);
});
}
function releaseDhcpLease(ifname, callback) {
controlMessage({ cmd: "dhcp_release_lease", ifname: ifname }, function(data) {
if (!data.status)
dhcpInfo = null;
callback(!data.status);
});
}
@ -468,6 +475,8 @@ var WifiManager = (function() {
function runDhcpRenew(ifname, callback) {
controlMessage({ cmd: "dhcp_do_request", ifname: ifname }, function(data) {
if (!data.status)
dhcpInfo = data;
callback(data.status ? null : data);
});
}
@ -486,6 +495,12 @@ var WifiManager = (function() {
function notifyStateChange(fields) {
fields.prevState = manager.state;
manager.state = fields.state;
// If we got disconnected, kill the DHCP client in preparation for
// reconnection.
if (fields.state === "DISCONNECTED" && dhcpInfo)
stopDhcp(manager.ifname, function() {});
notify("statechange", fields);
}

View File

@ -45,7 +45,7 @@
#include "nsDOMClassInfoID.h"
#include "nsDOMError.h"
#include "nsIDOMFile.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsICharsetDetector.h"
#include "nsIConverterInputStream.h"
#include "nsIInputStream.h"
@ -135,12 +135,8 @@ FileReaderSyncPrivate::ReadAsText(nsIDOMBlob* aBlob,
CopyUTF16toUTF8(aEncoding, charsetGuess);
}
nsCOMPtr<nsICharsetAlias> alias =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCString charset;
rv = alias->GetPreferred(charsetGuess, charset);
rv = nsCharsetAlias::GetPreferred(charsetGuess, charset);
NS_ENSURE_SUCCESS(rv, rv);
return ConvertStream(stream, charset.get(), aResult);

View File

@ -49,6 +49,7 @@ function clickEventHnalder(aEvent)
// are a lot of functions and SimpleTest.executeSoon()s.
SimpleTest.waitForFocus(function() {
SpecialPowers.setBoolPref("middlemouse.contentLoadURL", false);
SpecialPowers.setBoolPref("middlemouse.paste", true);
frameWindow = iframe.contentWindow;
@ -384,7 +385,9 @@ function runBodyEditableDocumentTests2()
function cleanup()
{
SpecialPowers.clearUserPref("middlemouse.contentLoadURL");
SpecialPowers.clearUserPref("middlemouse.paste");
SimpleTest.finish();
}

View File

@ -52,6 +52,7 @@ sed '1d' $HUNSPELL_PATCHED > $HUNSPELL_PATCHED_STRIPPED
# Combine dictionaries and sort
echo Combining dictionaries
export LC_ALL=C
sort $CHROMIUM_AFFIX_CONVERTED $HUNSPELL_PATCHED_STRIPPED $MOZILLA_START > $MERGED_SORTED
# Display any dupes.

View File

@ -36,7 +36,6 @@
* ***** END LICENSE BLOCK ***** */
#include "mozEnglishWordUtils.h"
#include "nsICharsetAlias.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsUnicharUtils.h"

View File

@ -41,7 +41,6 @@
#include "nsIFile.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsICharsetConverterManager.h"
#include "nsICharsetAlias.h"
#include "nsIObserverService.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"

View File

@ -37,7 +37,6 @@
#include "mozilla/ModuleUtils.h"
#include "nsICharsetAlias.h"
#include "nsCOMPtr.h"
#include "nspr.h"

View File

@ -26,7 +26,25 @@ diff --git a/gfx/angle/README.mozilla b/gfx/angle/README.mozilla
diff --git a/gfx/angle/src/compiler/Types.h b/gfx/angle/src/compiler/Types.h
--- a/gfx/angle/src/compiler/Types.h
+++ b/gfx/angle/src/compiler/Types.h
@@ -203,17 +203,17 @@ public:
@@ -5,16 +5,17 @@
//
#ifndef _TYPES_INCLUDED
#define _TYPES_INCLUDED
#include "compiler/BaseTypes.h"
#include "compiler/Common.h"
#include "compiler/compilerdebug.h"
+#include <cstdlib>
//
// Need to have association of line numbers to types in a list for building structs.
//
class TType;
struct TTypeLine {
TType* type;
int line;
@@ -203,17 +204,17 @@ public:
bool isVector() const { return size > 1 && !matrix; }
bool isScalar() const { return size == 1 && !matrix && !structure; }

View File

@ -10,6 +10,7 @@
#include "compiler/BaseTypes.h"
#include "compiler/Common.h"
#include "compiler/compilerdebug.h"
#include <cstdlib>
//
// Need to have association of line numbers to types in a list for building structs.

View File

@ -39,6 +39,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "mozilla/Preferences.h"
#include "mozilla/Util.h"
#if defined(XP_UNIX)
@ -69,6 +70,12 @@
#include "AndroidBridge.h"
#endif
#include <android/log.h>
// We only need to explicitly dlopen egltrace
// on android as we can use LD_PRELOAD or other tricks
// on other platforms. We look for it in /data/local
// as that's writeable by all users
#define APITRACE_LIB "/data/local/egltrace.so"
#endif
#define EGL_LIB "libEGL.so"
@ -227,6 +234,38 @@ static EGLint gContextAttribsRobustness[] = {
LOCAL_EGL_NONE
};
static PRLibrary* LoadApitraceLibrary()
{
static PRLibrary* sApitraceLibrary = NULL;
if (sApitraceLibrary)
return sApitraceLibrary;
#if defined(ANDROID)
nsCString logFile = Preferences::GetCString("gfx.apitrace.logfile");
if (logFile.IsEmpty()) {
logFile = "firefox.trace";
}
// The firefox process can't write to /data/local, but it can write
// to $GRE_HOME/
nsCAutoString logPath;
logPath.AppendPrintf("%s/%s", getenv("GRE_HOME"), logFile.get());
// apitrace uses the TRACE_FILE environment variable to determine where
// to log trace output to
printf_stderr("Logging GL tracing output to %s", logPath.get());
setenv("TRACE_FILE", logPath.get(), false);
printf_stderr("Attempting load of %s\n", APITRACE_LIB);
sApitraceLibrary = PR_LoadLibrary(APITRACE_LIB);
#endif
return sApitraceLibrary;
}
static int
next_power_of_two(int v)
{
@ -650,12 +689,17 @@ public:
#endif
if (!mEGLLibrary) {
mEGLLibrary = PR_LoadLibrary(EGL_LIB);
#if defined(XP_UNIX)
mEGLLibrary = LoadApitraceLibrary();
if (!mEGLLibrary) {
mEGLLibrary = PR_LoadLibrary(EGL_LIB1);
}
printf_stderr("Attempting load of %s\n", EGL_LIB);
mEGLLibrary = PR_LoadLibrary(EGL_LIB);
#if defined(XP_UNIX)
if (!mEGLLibrary) {
mEGLLibrary = PR_LoadLibrary(EGL_LIB1);
}
#endif
}
}
if (!mEGLLibrary) {
@ -1019,14 +1063,19 @@ public:
bool Init()
{
if (!OpenLibrary(GLES2_LIB)) {
#if defined(XP_UNIX)
if (!OpenLibrary(GLES2_LIB2)) {
NS_WARNING("Couldn't load EGL LIB.");
}
#if defined(ANDROID)
// We can't use LoadApitraceLibrary here because the GLContext
// expects its own handle to the GL library
if (!OpenLibrary(APITRACE_LIB))
#endif
return false;
}
if (!OpenLibrary(GLES2_LIB)) {
#if defined(XP_UNIX)
if (!OpenLibrary(GLES2_LIB2)) {
NS_WARNING("Couldn't load GLES2 LIB.");
return false;
}
#endif
}
bool current = MakeCurrent();
if (!current) {

View File

@ -73,6 +73,7 @@ CPPSRCS = \
BasicImages.cpp \
BasicLayers.cpp \
Layers.cpp \
RenderTrace.cpp \
ReadbackProcessor.cpp \
ThebesLayerBuffer.cpp \
CanvasLayerOGL.cpp \

107
gfx/layers/RenderTrace.cpp Normal file
View File

@ -0,0 +1,107 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benoit Girard <bgirard@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "Layers.h"
#include "RenderTrace.h"
// If rendertrace is off let's no compile this code
#ifdef MOZ_RENDERTRACE
namespace mozilla {
namespace layers {
static int colorId = 0;
// This should be done in the printf but android's printf is buggy
const char* colors[] = {
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19"
};
static gfx3DMatrix GetRootTransform(Layer *aLayer) {
gfx3DMatrix layerTrans = aLayer->GetTransform().ProjectTo2D();
if (aLayer->GetParent() != NULL) {
return GetRootTransform(aLayer->GetParent()) * layerTrans;
}
return layerTrans;
}
void RenderTraceLayers(Layer *aLayer, const char *aColor, const gfx3DMatrix aRootTransform, bool aReset) {
if (!aLayer)
return;
gfx3DMatrix trans = aRootTransform * aLayer->GetTransform().ProjectTo2D();
nsIntRect clipRect = aLayer->GetEffectiveVisibleRegion().GetBounds();
gfxRect rect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
trans.TransformBounds(rect);
printf_stderr("%s RENDERTRACE %u rect #%02X%s %i %i %i %i\n",
aLayer->Name(), (int)PR_IntervalNow(),
colorId, aColor,
(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
colorId++;
for (Layer* child = aLayer->GetFirstChild();
child; child = child->GetNextSibling()) {
RenderTraceLayers(child, aColor, aRootTransform, false);
}
if (aReset) colorId = 0;
}
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect) {
gfx3DMatrix trans = GetRootTransform(aLayer);
gfxRect rect(aRect.x, aRect.y, aRect.width, aRect.height);
trans.TransformBounds(rect);
printf_stderr("%s RENDERTRACE %u fillrect #%s %i %i %i %i\n",
aLayer->Name(), (int)PR_IntervalNow(),
aColor,
(int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
}
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor) {
// Clear with an empty rect
RenderTraceInvalidateStart(aLayer, aColor, nsIntRect());
}
}
}
#endif

69
gfx/layers/RenderTrace.h Normal file
View File

@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Benoit Girard <bgirard@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// This is a general tool that will let you visualize platform operation.
// Currently used for the layer system, the general syntax allows this
// tools to be adapted to trace other operations.
//
// For the front end see: https://github.com/staktrace/rendertrace
// Uncomment this line to enable RENDERTRACE
//#define MOZ_RENDERTRACE
#ifdef MOZ_RENDERTRACE
#include "gfx3DMatrix.h"
#include "nsRect.h"
#ifndef GFX_RENDERTRACE_H
#define GFX_RENDERTRACE_H
namespace mozilla {
namespace layers {
class Layer;
void RenderTraceLayers(Layer *aLayer, const char *aColor, gfx3DMatrix aRootTransform = gfx3DMatrix(), bool aReset = true);
void RenderTraceInvalidateStart(Layer *aLayer, const char *aColor, const nsIntRect aRect);
void RenderTraceInvalidateEnd(Layer *aLayer, const char *aColor);
}
}
#endif //GFX_RENDERTRACE_H
#endif // MOZ_RENDERTRACE

View File

@ -49,6 +49,7 @@
#include "BasicLayers.h"
#include "ImageLayers.h"
#include "RenderTrace.h"
#include "prprf.h"
#include "nsTArray.h"
@ -688,6 +689,11 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
mBuffer.Clear();
nsIntRegion toDraw = IntersectWithClip(GetEffectiveVisibleRegion(), aContext);
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateStart(this, "FFFF00", toDraw.GetBounds());
#endif
if (!toDraw.IsEmpty() && !IsHidden()) {
if (!aCallback) {
BasicManager()->SetTransactionIncomplete();
@ -723,6 +729,10 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
aContext->Restore();
}
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateEnd(this, "FFFF00");
#endif
return;
}
@ -748,11 +758,20 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
GetEffectiveVisibleRegion());
nsIntRegion extendedDrawRegion = state.mRegionToDraw;
SetAntialiasingFlags(this, state.mContext);
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateStart(this, "FFFF00", state.mRegionToDraw.GetBounds());
#endif
PaintBuffer(state.mContext,
state.mRegionToDraw, extendedDrawRegion, state.mRegionToInvalidate,
state.mDidSelfCopy,
aCallback, aCallbackData);
Mutated();
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateEnd(this, "FFFF00");
#endif
} else {
// It's possible that state.mRegionToInvalidate is nonempty here,
// if we are shrinking the valid region to nothing.
@ -1600,6 +1619,11 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
mPhase = PHASE_DRAWING;
#endif
#ifdef MOZ_RENDERTRACE
Layer* aLayer = GetRoot();
RenderTraceLayers(aLayer, "FF00");
#endif
mTransactionIncomplete = false;
if (mTarget && mRoot && !(aFlags & END_NO_IMMEDIATE_REDRAW)) {
@ -1820,6 +1844,8 @@ Transform3D(gfxASurface* aSource, gfxContext* aDest,
return destImage.forget();
}
void
BasicLayerManager::PaintLayer(gfxContext* aTarget,
Layer* aLayer,

View File

@ -39,6 +39,7 @@
* ***** END LICENSE BLOCK ***** */
#include "CompositorParent.h"
#include "RenderTrace.h"
#include "ShadowLayersParent.h"
#include "LayerManagerOGL.h"
#include "nsIWidget.h"
@ -80,6 +81,12 @@ CompositorParent::ScheduleComposition()
{
CancelableTask *composeTask = NewRunnableMethod(this, &CompositorParent::Composite);
MessageLoop::current()->PostTask(FROM_HERE, composeTask);
#ifdef MOZ_RENDERTRACE
Layer* aLayer = mLayerManager->GetRoot();
mozilla::layers::RenderTraceLayers(aLayer, "0000");
#endif
}
void

View File

@ -43,6 +43,7 @@
#include "ShadowLayersParent.h"
#include "ShadowLayerParent.h"
#include "ShadowLayers.h"
#include "RenderTrace.h"
#include "mozilla/unused.h"
@ -318,6 +319,10 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
static_cast<ShadowThebesLayer*>(shadow->AsLayer());
const ThebesBuffer& newFront = op.newFrontBuffer();
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateStart(thebes, "FF00FF", op.updatedRegion().GetBounds());
#endif
OptionalThebesBuffer newBack;
nsIntRegion newValidRegion;
OptionalThebesBuffer readonlyFront;
@ -330,6 +335,10 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
shadow, NULL,
newBack, newValidRegion,
readonlyFront, frontUpdatedRegion));
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateEnd(thebes, "FF00FF");
#endif
break;
}
case Edit::TOpPaintCanvas: {
@ -340,6 +349,10 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
ShadowCanvasLayer* canvas =
static_cast<ShadowCanvasLayer*>(shadow->AsLayer());
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateStart(canvas, "FF00FF", canvas->GetVisibleRegion().GetBounds());
#endif
canvas->SetAllocator(this);
CanvasSurface newBack;
canvas->Swap(op.newFrontBuffer(), op.needYFlip(), &newBack);
@ -347,6 +360,9 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
replyv.push_back(OpBufferSwap(shadow, NULL,
newBack));
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateEnd(canvas, "FF00FF");
#endif
break;
}
case Edit::TOpPaintImage: {
@ -357,12 +373,19 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
ShadowImageLayer* image =
static_cast<ShadowImageLayer*>(shadow->AsLayer());
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateStart(image, "FF00FF", image->GetVisibleRegion().GetBounds());
#endif
image->SetAllocator(this);
SharedImage newBack;
image->Swap(op.newFrontBuffer(), &newBack);
replyv.push_back(OpImageSwap(shadow, NULL,
newBack));
#ifdef MOZ_RENDERTRACE
RenderTraceInvalidateEnd(image, "FF00FF");
#endif
break;
}

View File

@ -367,7 +367,20 @@ LayerManagerOGL::Initialize(nsRefPtr<GLContext> aContext, bool force)
console->LogStringMessage(msg.get());
}
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
if (NS_IsMainThread()) {
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
} else {
// We have to dispatch an event to the main thread to read the pref.
class ReadDrawFPSPref : public nsRunnable {
public:
NS_IMETHOD Run()
{
Preferences::AddBoolVarCache(&sDrawFPS, "layers.acceleration.draw-fps");
return NS_OK;
}
};
NS_DispatchToMainThread(new ReadDrawFPSPref());
}
reporter.SetSuccessful();
return true;

View File

@ -98,7 +98,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(nsMozIconURI, nsIMozIconURI, nsIURI)
#define MOZICON_SCHEME_LEN (sizeof(MOZICON_SCHEME) - 1)
////////////////////////////////////////////////////////////////////////////////
// nsURI methods:
// nsIURI methods:
NS_IMETHODIMP
nsMozIconURI::GetSpec(nsACString &aSpec)

View File

@ -89,7 +89,6 @@ NS_DEFINE_NAMED_CID(NS_LOCALESERVICE_CID);
NS_DEFINE_NAMED_CID(NS_COLLATIONFACTORY_CID);
NS_DEFINE_NAMED_CID(NS_SCRIPTABLEDATEFORMAT_CID);
NS_DEFINE_NAMED_CID(NS_LANGUAGEATOMSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_CHARSETALIAS_CID);
NS_DEFINE_NAMED_CID(NS_PLATFORMCHARSET_CID);
#ifdef XP_WIN
NS_DEFINE_NAMED_CID(NS_COLLATION_CID);
@ -124,7 +123,6 @@ static const mozilla::Module::CIDEntry kIntlCIDs[] = {
{ &kNS_COLLATIONFACTORY_CID, false, NULL, nsCollationFactoryConstructor },
{ &kNS_SCRIPTABLEDATEFORMAT_CID, false, NULL, NS_NewScriptableDateFormat },
{ &kNS_LANGUAGEATOMSERVICE_CID, false, NULL, nsLanguageAtomServiceConstructor },
{ &kNS_CHARSETALIAS_CID, false, NULL, nsCharsetAlias2Constructor },
{ &kNS_PLATFORMCHARSET_CID, false, NULL, nsPlatformCharsetConstructor },
#ifdef XP_WIN
{ &kNS_COLLATION_CID, false, NULL, nsCollationWinConstructor },
@ -161,7 +159,6 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
{ NS_COLLATIONFACTORY_CONTRACTID, &kNS_COLLATIONFACTORY_CID },
{ NS_SCRIPTABLEDATEFORMAT_CONTRACTID, &kNS_SCRIPTABLEDATEFORMAT_CID },
{ NS_LANGUAGEATOMSERVICE_CONTRACTID, &kNS_LANGUAGEATOMSERVICE_CID },
{ NS_CHARSETALIAS_CONTRACTID, &kNS_CHARSETALIAS_CID },
{ NS_PLATFORMCHARSET_CONTRACTID, &kNS_PLATFORMCHARSET_CID },
#ifdef XP_WIN
{ NS_COLLATION_CONTRACTID, &kNS_COLLATION_CID },

View File

@ -47,7 +47,6 @@
// chardet
#include "nsISupports.h"
#include "nsICharsetDetector.h"
#include "nsICharsetAlias.h"
#include "nsICharsetDetectionObserver.h"
#include "nsIStringCharsetDetector.h"
#include "nsCyrillicDetector.h"

View File

@ -52,7 +52,7 @@ EXPORTS = \
nsPosixLocale.h \
nsIOS2Locale.h \
nsWin32Locale.h \
nsICharsetAlias.h \
nsCharsetAlias.h \
nsIPlatformCharset.h \
nsLocaleCID.h \
$(NULL)

View File

@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -12,7 +12,7 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
@ -34,27 +34,18 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsCharsetAlias_h__
#define nsCharsetAlias_h__
#include "nsICharsetAlias.h"
#ifndef nsCharsetAlias_h___
#define nsCharsetAlias_h___
//==============================================================
class nsCharsetAlias2 : public nsICharsetAlias
#include "nscore.h"
#include "nsStringGlue.h"
class nsCharsetAlias
{
NS_DECL_ISUPPORTS
public:
nsCharsetAlias2();
virtual ~nsCharsetAlias2();
NS_IMETHOD GetPreferred(const nsACString& aAlias, nsACString& aResult);
NS_IMETHOD Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* oResult) ;
static nsresult GetPreferred(const nsACString& aAlias, nsACString& aResult);
static nsresult Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* aResult);
};
#endif // nsCharsetAlias_h__
#endif /* nsCharsetAlias_h___ */

View File

@ -67,7 +67,7 @@ CPPSRCS = \
nsLanguageAtomService.cpp \
nsLocale.cpp \
nsLocaleService.cpp \
nsCharsetAliasImp.cpp \
nsCharsetAlias.cpp \
nsUConvPropertySearch.cpp \
$(NULL)
@ -89,7 +89,7 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
nsCharsetAliasImp.$(OBJ_SUFFIX): charsetalias.properties.h
nsCharsetAlias.$(OBJ_SUFFIX): charsetalias.properties.h
charsetalias.properties.h: props2arrays.py charsetalias.properties
$(PYTHON) $^ $@

View File

@ -37,7 +37,7 @@
#include "mozilla/Util.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "pratom.h"
// for NS_IMPL_IDS only
@ -46,46 +46,34 @@
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsUConvPropertySearch.h"
#include "nsCharsetAlias.h"
using namespace mozilla;
//--------------------------------------------------------------
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCharsetAlias2, nsICharsetAlias)
//--------------------------------------------------------------
nsCharsetAlias2::nsCharsetAlias2()
{
}
//--------------------------------------------------------------
nsCharsetAlias2::~nsCharsetAlias2()
{
}
//
static const char* kAliases[][3] = {
#include "charsetalias.properties.h"
};
//--------------------------------------------------------------
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias,
nsACString& oResult)
// static
nsresult
nsCharsetAlias::GetPreferred(const nsACString& aAlias,
nsACString& oResult)
{
if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
nsCAutoString key(aAlias);
ToLowerCase(key);
nsresult rv = nsUConvPropertySearch::SearchPropertyValue(kAliases,
return nsUConvPropertySearch::SearchPropertyValue(kAliases,
ArrayLength(kAliases), key, oResult);
return rv;
}
//--------------------------------------------------------------
NS_IMETHODIMP
nsCharsetAlias2::Equals(const nsACString& aCharset1,
const nsACString& aCharset2, bool* oResult)
// static
nsresult
nsCharsetAlias::Equals(const nsACString& aCharset1,
const nsACString& aCharset2, bool* oResult)
{
nsresult res = NS_OK;
@ -101,15 +89,15 @@ nsCharsetAlias2::Equals(const nsACString& aCharset1,
*oResult = false;
nsCAutoString name1;
nsCAutoString name2;
res = this->GetPreferred(aCharset1, name1);
if(NS_SUCCEEDED(res)) {
res = this->GetPreferred(aCharset2, name2);
if(NS_SUCCEEDED(res)) {
*oResult = name1.Equals(name2);
}
}
return res;
}
res = GetPreferred(aCharset1, name1);
if (NS_FAILED(res))
return res;
nsCAutoString name2;
res = GetPreferred(aCharset2, name2);
if (NS_FAILED(res))
return res;
*oResult = name1.Equals(name2);
return NS_OK;
}

View File

@ -46,7 +46,6 @@
#include "nsIScriptableDateFormat.h"
#include "nsIServiceManager.h"
#include "nsLanguageAtomService.h"
#include "nsCharsetAlias.h"
#include "nsPlatformCharset.h"
#include "nsLocaleCID.h"
@ -100,7 +99,6 @@ NSLOCALE_MAKE_CTOR(CreateLocaleService, nsILocaleService, NS_NewLocaleService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCollationFactory)
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableDateTimeFormat)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLanguageAtomService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetAlias2)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPlatformCharset, Init)
#ifdef XP_WIN

View File

@ -40,7 +40,7 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsICharsetAlias.h"
#include "nsCharsetAlias.h"
#include "nsIServiceManager.h"
#include "nsICategoryManager.h"
#include "nsICharsetConverterManager.h"
@ -308,10 +308,8 @@ nsCharsetConverterManager::GetCharsetAlias(const char * aCharset,
// We try to obtain the preferred name for this charset from the charset
// aliases.
nsresult rv;
nsCOMPtr<nsICharsetAlias> csAlias(do_GetService(NS_CHARSETALIAS_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = csAlias->GetPreferred(nsDependentCString(aCharset), aResult);
rv = nsCharsetAlias::GetPreferred(nsDependentCString(aCharset), aResult);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

View File

@ -46,8 +46,6 @@
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsICharsetAlias.h"
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
#include <stdio.h>
@ -90,15 +88,6 @@ int main(int argc, const char** argv)
return -1;
}
// Get the charset alias manager
nsCOMPtr<nsICharsetAlias> aliasmgr =
do_GetService(NS_CHARSETALIAS_CONTRACTID, &res);
if (NS_FAILED(res))
{
fprintf(stderr, "Cannot get Charset Alias Manager %x\n", res);
return -1;
}
int i;
if(argc > 4)
{
@ -111,7 +100,7 @@ int main(int argc, const char** argv)
// First check if a charset alias was given,
// and convert to the canonical name
res = aliasmgr->GetPreferred(nsDependentCString(argv[i+1]), str);
res = ccMain->GetCharsetAlias(argv[i+1], str);
if (NS_FAILED(res))
{
fprintf(stderr, "Cannot get charset alias for %s %x\n",
@ -136,7 +125,7 @@ int main(int argc, const char** argv)
// First check if a charset alias was given,
// and convert to the canonical name
res = aliasmgr->GetPreferred(nsDependentCString(argv[i+1]), str);
res = ccMain->GetCharsetAlias(argv[i+1], str);
if (NS_FAILED(res))
{
fprintf(stderr, "Cannot get charset alias for %s %x\n",

View File

@ -1169,9 +1169,7 @@ XPCShellEnvironment::Init()
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
rv = xpc->InitClassesWithNewWrappedGlobal(cx, backstagePass,
NS_GET_IID(nsISupports),
principal,
nsnull,
nsIXPConnect::
FLAG_SYSTEM_GLOBAL_OBJECT,
getter_AddRefs(holder));

View File

@ -173,6 +173,7 @@ CPPSRCS = \
RegExp.cpp \
Memory.cpp \
Statistics.cpp \
StringBuffer.cpp \
Unicode.cpp \
$(NULL)

View File

@ -45,6 +45,7 @@
#include "vm/MethodGuard-inl.h"
#include "vm/RegExpObject-inl.h"
#include "vm/RegExpStatics-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace js;
using namespace js::types;

View File

@ -4931,6 +4931,9 @@ EmitNormalFor(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn, ptrdiff_t top)
jmp = EmitJump(cx, bce, JSOP_GOTO, 0);
if (jmp < 0)
return false;
} else {
if (op != JSOP_NOP && Emit1(cx, bce, JSOP_NOP) < 0)
return false;
}
top = bce->offset();

View File

@ -294,8 +294,10 @@ HeapId::pre()
if (JS_UNLIKELY(JSID_IS_OBJECT(value))) {
JSObject *obj = JSID_TO_OBJECT(value);
JSCompartment *comp = obj->compartment();
if (comp->needsBarrier())
js::gc::MarkObjectUnbarriered(comp->barrierTracer(), obj, "write barrier");
if (comp->needsBarrier()) {
js::gc::MarkObjectUnbarriered(comp->barrierTracer(), &obj, "write barrier");
JS_ASSERT(obj == JSID_TO_OBJECT(value));
}
}
#endif
}

View File

@ -7,7 +7,8 @@
#include "jsatom.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/StringBuffer-inl.h"
BEGIN_TEST(testStringBuffer_finishString)
{

View File

@ -104,6 +104,7 @@
#include "vm/RegExpStatics-inl.h"
#include "vm/Stack-inl.h"
#include "vm/String-inl.h"
#include "vm/StringBuffer-inl.h"
#if ENABLE_YARR_JIT
#include "assembler/jit/ExecutableAllocator.h"
@ -4264,7 +4265,9 @@ prop_iter_trace(JSTracer *trc, JSObject *obj)
* barrier here because the pointer is updated via setPrivate, which
* always takes a barrier.
*/
MarkShapeUnbarriered(trc, (Shape *)pdata, "prop iter shape");
Shape *tmp = (Shape *)pdata;
MarkShapeUnbarriered(trc, &tmp, "prop iter shape");
JS_ASSERT(tmp == pdata);
} else {
/* Non-native case: mark each id in the JSIdArray private. */
JSIdArray *ida = (JSIdArray *) pdata;

View File

@ -128,6 +128,7 @@
#include "vm/ArgumentsObject.h"
#include "vm/MethodGuard.h"
#include "vm/StringBuffer-inl.h"
#include "ds/Sort.h"
@ -1193,7 +1194,7 @@ array_trace(JSTracer *trc, JSObject *obj)
JS_ASSERT(obj->isDenseArray());
uint32_t initLength = obj->getDenseArrayInitializedLength();
MarkSlotRange(trc, initLength, obj->getDenseArrayElements(), "element");
MarkArraySlots(trc, initLength, obj->getDenseArrayElements(), "element");
}
static JSBool

View File

@ -57,10 +57,10 @@
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/BooleanObject-inl.h"
#include "vm/MethodGuard-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace js;
using namespace js::types;

View File

@ -77,10 +77,10 @@
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/MethodGuard-inl.h"
#include "vm/Stack-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace mozilla;
using namespace js;

View File

@ -68,10 +68,10 @@
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/Stack-inl.h"
#include "vm/String-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace mozilla;
using namespace js;

View File

@ -1094,13 +1094,13 @@ JSFunction::trace(JSTracer *trc)
}
if (atom)
MarkStringUnbarriered(trc, atom, "atom");
MarkStringUnbarriered(trc, &atom, "atom");
if (isInterpreted()) {
if (script())
MarkScript(trc, &script(), "script");
if (environment())
MarkObjectUnbarriered(trc, environment(), "fun_callscope");
if (u.i.script_)
MarkScriptUnbarriered(trc, &u.i.script_, "script");
if (u.i.env_)
MarkObjectUnbarriered(trc, &u.i.env_, "fun_callscope");
}
}

View File

@ -126,10 +126,10 @@ MarkInternal(JSTracer *trc, T *thing)
template <typename T>
static void
MarkUnbarriered(JSTracer *trc, T *thing, const char *name)
MarkUnbarriered(JSTracer *trc, T **thingp, const char *name)
{
JS_SET_TRACING_NAME(trc, name);
MarkInternal(trc, thing);
MarkInternal(trc, *thingp);
}
template <typename T>
@ -186,9 +186,9 @@ Mark##base##Root(JSTracer *trc, type **thingp, const char *name)
} \
\
void \
Mark##base##Unbarriered(JSTracer *trc, type *thing, const char *name) \
Mark##base##Unbarriered(JSTracer *trc, type **thingp, const char *name) \
{ \
MarkUnbarriered<type>(trc, thing, name); \
MarkUnbarriered<type>(trc, thingp, name); \
} \
\
void Mark##base##Range(JSTracer *trc, size_t len, HeapPtr<type> *vec, const char *name) \
@ -202,6 +202,7 @@ void Mark##base##RootRange(JSTracer *trc, size_t len, type **vec, const char *na
} \
DeclMarkerImpl(BaseShape, BaseShape)
DeclMarkerImpl(BaseShape, UnownedBaseShape)
DeclMarkerImpl(Object, ArgumentsObject)
DeclMarkerImpl(Object, GlobalObject)
DeclMarkerImpl(Object, JSObject)
@ -366,7 +367,7 @@ MarkSlot(JSTracer *trc, HeapSlot *s, const char *name)
}
void
MarkSlotRange(JSTracer *trc, size_t len, HeapSlot *vec, const char *name)
MarkArraySlots(JSTracer *trc, size_t len, HeapSlot *vec, const char *name)
{
for (size_t i = 0; i < len; ++i) {
JS_SET_TRACING_INDEX(trc, name, i);
@ -374,6 +375,16 @@ MarkSlotRange(JSTracer *trc, size_t len, HeapSlot *vec, const char *name)
}
}
void
MarkObjectSlots(JSTracer *trc, JSObject *obj, uint32_t start, uint32_t nslots)
{
JS_ASSERT(obj->isNative());
for (uint32_t i = start; i < (start + nslots); ++i) {
JS_SET_TRACING_DETAILS(trc, js_PrintObjectSlotName, obj, i);
MarkValueInternal(trc, obj->nativeGetSlotRef(i).unsafeGet());
}
}
void
MarkCrossCompartmentSlot(JSTracer *trc, HeapSlot *s, const char *name)
{
@ -393,15 +404,11 @@ MarkCrossCompartmentSlot(JSTracer *trc, HeapSlot *s, const char *name)
/*** Special Marking ***/
/*
* The unioned HeapPtr stored in script->globalObj needs special treatment to
* typecheck correctly.
*/
static void
MarkObject(JSTracer *trc, const HeapPtr<GlobalObject, JSScript *> &thing, const char *name)
void
MarkObject(JSTracer *trc, HeapPtr<GlobalObject, JSScript *> *thingp, const char *name)
{
JS_SET_TRACING_NAME(trc, name);
MarkInternal(trc, thing.get());
MarkInternal(trc, thingp->get());
}
void
@ -644,113 +651,34 @@ PushMarkStack(GCMarker *gcmarker, JSString *str)
void
MarkChildren(JSTracer *trc, JSObject *obj)
{
MarkTypeObject(trc, &obj->typeFromGC(), "type");
Shape *shape = obj->lastProperty();
MarkShapeUnbarriered(trc, shape, "shape");
Class *clasp = shape->getObjectClass();
if (clasp->trace)
clasp->trace(trc, obj);
if (shape->isNative()) {
uint32_t nslots = obj->slotSpan();
for (uint32_t i = 0; i < nslots; i++) {
JS_SET_TRACING_DETAILS(trc, js_PrintObjectSlotName, obj, i);
MarkValueInternal(trc, obj->nativeGetSlotRef(i).unsafeGet());
}
}
obj->markChildren(trc);
}
static void
MarkChildren(JSTracer *trc, JSString *str)
{
/*
* We use custom barriers in JSString, so it's safe to use unbarriered
* marking here.
*/
if (str->isDependent()) {
MarkStringUnbarriered(trc, str->asDependent().base(), "base");
} else if (str->isRope()) {
JSRope &rope = str->asRope();
MarkStringUnbarriered(trc, rope.leftChild(), "left child");
MarkStringUnbarriered(trc, rope.rightChild(), "right child");
}
if (str->isDependent())
str->asDependent().markChildren(trc);
else if (str->isRope())
str->asRope().markChildren(trc);
}
static void
MarkChildren(JSTracer *trc, JSScript *script)
{
CheckScript(script, NULL);
JS_ASSERT_IF(trc->runtime->gcCheckCompartment,
script->compartment() == trc->runtime->gcCheckCompartment);
for (uint32_t i = 0; i < script->natoms; ++i) {
if (JSAtom *p = script->atoms[i])
MarkStringUnbarriered(trc, p, "atom");
}
if (JSScript::isValidOffset(script->objectsOffset)) {
JSObjectArray *objarray = script->objects();
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
}
if (JSScript::isValidOffset(script->regexpsOffset)) {
JSObjectArray *objarray = script->regexps();
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
}
if (JSScript::isValidOffset(script->constOffset)) {
JSConstArray *constarray = script->consts();
MarkValueRange(trc, constarray->length, constarray->vector, "consts");
}
if (script->function())
MarkObjectUnbarriered(trc, script->function(), "function");
if (!script->isCachedEval && script->globalObject)
MarkObject(trc, script->globalObject, "object");
if (IS_GC_MARKING_TRACER(trc) && script->filename)
js_MarkScriptFilename(script->filename);
script->bindings.trace(trc);
if (script->types)
script->types->trace(trc);
if (script->hasAnyBreakpointsOrStepMode())
script->markTrapClosures(trc);
script->markChildren(trc);
}
static void
MarkChildren(JSTracer *trc, Shape *shape)
{
MarkBaseShapeUnbarriered(trc, shape->base(), "base");
MarkId(trc, &shape->propidRef(), "propid");
if (shape->previous())
MarkShape(trc, &shape->previousRef(), "parent");
}
static inline void
MarkBaseShapeGetterSetter(JSTracer *trc, BaseShape *base)
{
if (base->hasGetterObject())
MarkObjectUnbarriered(trc, base->getterObject(), "getter");
if (base->hasSetterObject())
MarkObjectUnbarriered(trc, base->setterObject(), "setter");
shape->markChildren(trc);
}
static void
MarkChildren(JSTracer *trc, BaseShape *base)
{
MarkBaseShapeGetterSetter(trc, base);
if (base->isOwned())
MarkBaseShapeUnbarriered(trc, base->baseUnowned(), "base");
if (JSObject *parent = base->getObjectParent())
MarkObjectUnbarriered(trc, parent, "parent");
base->markChildren(trc);
}
/*
@ -773,11 +701,22 @@ MarkCycleCollectorChildren(JSTracer *trc, BaseShape *base, JSObject **prevParent
*/
base->assertConsistency();
MarkBaseShapeGetterSetter(trc, base);
if (base->hasGetterObject()) {
JSObject *tmp = base->getterObject();
MarkObjectUnbarriered(trc, &tmp, "getter");
JS_ASSERT(tmp == base->getterObject());
}
if (base->hasSetterObject()) {
JSObject *tmp = base->setterObject();
MarkObjectUnbarriered(trc, &tmp, "setter");
JS_ASSERT(tmp == base->setterObject());
}
JSObject *parent = base->getObjectParent();
if (parent && parent != *prevParent) {
MarkObjectUnbarriered(trc, parent, "parent");
MarkObjectUnbarriered(trc, &parent, "parent");
JS_ASSERT(parent == base->getObjectParent());
*prevParent = parent;
}
}

View File

@ -47,11 +47,12 @@ namespace gc {
#define DeclMarker(base, type) \
void Mark##base(JSTracer *trc, HeapPtr<type> *thing, const char *name); \
void Mark##base##Root(JSTracer *trc, type **thingp, const char *name); \
void Mark##base##Unbarriered(JSTracer *trc, type *thing, const char *name); \
void Mark##base##Unbarriered(JSTracer *trc, type **thingp, const char *name); \
void Mark##base##Range(JSTracer *trc, size_t len, HeapPtr<type> *thing, const char *name); \
void Mark##base##RootRange(JSTracer *trc, size_t len, type **thing, const char *name);
DeclMarker(BaseShape, BaseShape)
DeclMarker(BaseShape, UnownedBaseShape)
DeclMarker(Object, ArgumentsObject)
DeclMarker(Object, GlobalObject)
DeclMarker(Object, JSObject)
@ -120,7 +121,10 @@ void
MarkSlot(JSTracer *trc, HeapSlot *s, const char *name);
void
MarkSlotRange(JSTracer *trc, size_t len, HeapSlot *vec, const char *name);
MarkArraySlots(JSTracer *trc, size_t len, HeapSlot *vec, const char *name);
void
MarkObjectSlots(JSTracer *trc, JSObject *obj, uint32_t start, uint32_t nslots);
/*
* Mark a value that may be in a different compartment from the compartment
@ -129,8 +133,16 @@ MarkSlotRange(JSTracer *trc, size_t len, HeapSlot *vec, const char *name);
void
MarkCrossCompartmentSlot(JSTracer *trc, HeapSlot *s, const char *name);
/*** Special Cases ***/
/*
* The unioned HeapPtr stored in script->globalObj needs special treatment to
* typecheck correctly.
*/
void
MarkObject(JSTracer *trc, HeapPtr<GlobalObject, JSScript *> *thingp, const char *name);
/* Direct value access used by the write barriers and the methodjit. */
void
MarkValueUnbarriered(JSTracer *trc, Value *v, const char *name);

View File

@ -1312,8 +1312,11 @@ TypeObject::writeBarrierPre(TypeObject *type)
return;
JSCompartment *comp = type->compartment();
if (comp->needsBarrier())
MarkTypeObjectUnbarriered(comp->barrierTracer(), type, "write barrier");
if (comp->needsBarrier()) {
TypeObject *tmp = type;
MarkTypeObjectUnbarriered(comp->barrierTracer(), &tmp, "write barrier");
JS_ASSERT(tmp == type);
}
#endif
}
@ -1327,8 +1330,11 @@ TypeObject::readBarrier(TypeObject *type)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = type->compartment();
if (comp->needsBarrier())
MarkTypeObjectUnbarriered(comp->barrierTracer(), type, "read barrier");
if (comp->needsBarrier()) {
TypeObject *tmp = type;
MarkTypeObjectUnbarriered(comp->barrierTracer(), &tmp, "read barrier");
JS_ASSERT(tmp == type);
}
#endif
}
@ -1341,7 +1347,7 @@ TypeNewScript::writeBarrierPre(TypeNewScript *newScript)
JSCompartment *comp = newScript->fun->compartment();
if (comp->needsBarrier()) {
MarkObjectUnbarriered(comp->barrierTracer(), newScript->fun, "write barrier");
MarkObject(comp->barrierTracer(), &newScript->fun, "write barrier");
MarkShape(comp->barrierTracer(), &newScript->shape, "write barrier");
}
#endif

View File

@ -1071,22 +1071,12 @@ js::FindUpvarFrame(JSContext *cx, unsigned targetLevel)
#define POP_BOOLEAN(cx, vp, b) do { VALUE_TO_BOOLEAN(cx, vp, b); regs.sp--; } while(0)
#define VALUE_TO_OBJECT(cx, vp, obj) \
JS_BEGIN_MACRO \
if ((vp)->isObject()) { \
obj = &(vp)->toObject(); \
} else { \
obj = js_ValueToNonNullObject(cx, *(vp)); \
if (!obj) \
goto error; \
(vp)->setObject(*obj); \
} \
JS_END_MACRO
#define FETCH_OBJECT(cx, n, obj) \
JS_BEGIN_MACRO \
Value *vp_ = &regs.sp[n]; \
VALUE_TO_OBJECT(cx, vp_, obj); \
obj = ToObject(cx, (vp_)); \
if (!obj) \
goto error; \
JS_END_MACRO
/* Test whether v is an int in the range [-2^31 + 1, 2^31 - 2] */

View File

@ -255,7 +255,7 @@ GetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, Value *vp
}
}
JSObject *obj = ValueToObjectOrPrototype(cx, lval);
JSObject *obj = ValueToObject(cx, lval);
if (!obj)
return false;

View File

@ -78,11 +78,11 @@
#include "jsinferinlines.h"
#include "jsnuminlines.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/MethodGuard-inl.h"
#include "vm/NumberObject-inl.h"
#include "vm/String-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace js;
using namespace js::types;

View File

@ -89,9 +89,9 @@
#include "jsobjinlines.h"
#include "jsscopeinlines.h"
#include "jsscriptinlines.h"
#include "jsstrinlines.h"
#include "vm/MethodGuard-inl.h"
#include "vm/StringBuffer-inl.h"
#if JS_HAS_XML_SUPPORT
#include "jsxml.h"

View File

@ -695,7 +695,7 @@ struct JSObject : public js::ObjectImpl
inline js::types::TypeObject *getType(JSContext *cx);
js::HeapPtr<js::types::TypeObject> &typeFromGC() {
const js::HeapPtr<js::types::TypeObject> &typeFromGC() const {
/* Direct field access for use by GC. */
return type_;
}

View File

@ -652,23 +652,6 @@ JSObject::denseArrayHasInlineSlots() const
namespace js {
inline JSObject *
ValueToObjectOrPrototype(JSContext *cx, const Value &v)
{
if (v.isObject())
return &v.toObject();
GlobalObject *global = &cx->fp()->scopeChain().global();
if (v.isString())
return global->getOrCreateStringPrototype(cx);
if (v.isNumber())
return global->getOrCreateNumberPrototype(cx);
if (v.isBoolean())
return global->getOrCreateBooleanPrototype(cx);
JS_ASSERT(v.isNull() || v.isUndefined());
js_ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, v, NULL);
return NULL;
}
/*
* Any name atom for a function which will be added as a DeclEnv object to the
* scope chain above call objects for fun.

View File

@ -64,9 +64,9 @@
#include "jsboolinlines.h"
#include "jsinferinlines.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/Stack-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace js;
using namespace js::gc;

View File

@ -43,7 +43,8 @@
#include "jsonparser.h"
#include "jsobjinlines.h"
#include "jsstrinlines.h"
#include "vm/StringBuffer-inl.h"
using namespace js;

View File

@ -77,11 +77,11 @@
#include "jscntxtinlines.h"
#include "jsobjinlines.h"
#include "jsopcodeinlines.h"
#include "jsscriptinlines.h"
#include "jsautooplen.h"
#include "vm/RegExpObject-inl.h"
#include "vm/StringBuffer-inl.h"
using namespace mozilla;
using namespace js;
@ -2446,15 +2446,10 @@ SprintNormalFor(JSContext *cx, JSPrinter *jp, SprintStack *ss, const char *initP
ptrdiff_t next = js_GetSrcNoteOffset(sn, 1);
ptrdiff_t tail = js_GetSrcNoteOffset(sn, 2);
/*
* If this loop has a condition, then pc points at a goto
* targeting the condition.
*/
/* Find the loop head, skipping over any leading GOTO or NOP. */
jsbytecode *pc2 = pc;
if (cond != tail) {
LOCAL_ASSERT(*pc == JSOP_GOTO);
pc2 += JSOP_GOTO_LENGTH;
}
if (*pc == JSOP_GOTO || *pc == JSOP_NOP)
pc2 += GetBytecodeLength(pc);
LOCAL_ASSERT(tail + GET_JUMP_OFFSET(pc + tail) == pc2 - pc);
if (cond != tail) {

View File

@ -150,7 +150,7 @@ Shape::removeChild(Shape *child)
if (hash->count() == 1) {
/* Convert from HASH form back to SHAPE form. */
KidsHash::Range r = hash->all();
KidsHash::Range r = hash->all();
Shape *otherChild = r.front();
JS_ASSERT((r.popFront(), r.empty())); /* No more elements! */
kidp->setShape(otherChild);
@ -166,8 +166,11 @@ ReadBarrier(Shape *shape)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = shape->compartment();
if (comp->needsBarrier())
MarkShapeUnbarriered(comp->barrierTracer(), shape, "read barrier");
if (comp->needsBarrier()) {
Shape *tmp = shape;
MarkShapeUnbarriered(comp->barrierTracer(), &tmp, "read barrier");
JS_ASSERT(tmp == shape);
}
#endif
return shape;
}

View File

@ -390,6 +390,8 @@ class BaseShape : public js::gc::Cell
static inline ThingRootKind rootKind() { return THING_ROOT_BASE_SHAPE; }
inline void markChildren(JSTracer *trc);
private:
static void staticAsserts() {
JS_STATIC_ASSERT(offsetof(BaseShape, clasp) == offsetof(js::shadow::BaseShape, clasp));
@ -563,10 +565,6 @@ struct Shape : public js::gc::Cell
return parent;
}
HeapPtrShape &previousRef() {
return parent;
}
class Range {
protected:
friend struct Shape;
@ -910,6 +908,8 @@ struct Shape : public js::gc::Cell
static inline ThingRootKind rootKind() { return THING_ROOT_SHAPE; }
inline void markChildren(JSTracer *trc);
/* For JIT usage */
static inline size_t offsetOfBase() { return offsetof(Shape, base_); }

View File

@ -394,8 +394,11 @@ Shape::writeBarrierPre(const js::Shape *shape)
return;
JSCompartment *comp = shape->compartment();
if (comp->needsBarrier())
MarkShapeUnbarriered(comp->barrierTracer(), const_cast<Shape *>(shape), "write barrier");
if (comp->needsBarrier()) {
Shape *tmp = const_cast<Shape *>(shape);
MarkShapeUnbarriered(comp->barrierTracer(), &tmp, "write barrier");
JS_ASSERT(tmp == shape);
}
#endif
}
@ -409,11 +412,23 @@ Shape::readBarrier(const Shape *shape)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = shape->compartment();
if (comp->needsBarrier())
MarkShapeUnbarriered(comp->barrierTracer(), const_cast<Shape *>(shape), "read barrier");
if (comp->needsBarrier()) {
Shape *tmp = const_cast<Shape *>(shape);
MarkShapeUnbarriered(comp->barrierTracer(), &tmp, "read barrier");
JS_ASSERT(tmp == shape);
}
#endif
}
inline void
Shape::markChildren(JSTracer *trc)
{
MarkBaseShape(trc, &base_, "base");
gc::MarkId(trc, &propidRef(), "propid");
if (parent)
MarkShape(trc, &parent, "parent");
}
inline void
BaseShape::writeBarrierPre(BaseShape *base)
{
@ -422,8 +437,11 @@ BaseShape::writeBarrierPre(BaseShape *base)
return;
JSCompartment *comp = base->compartment();
if (comp->needsBarrier())
MarkBaseShapeUnbarriered(comp->barrierTracer(), base, "write barrier");
if (comp->needsBarrier()) {
BaseShape *tmp = base;
MarkBaseShapeUnbarriered(comp->barrierTracer(), &tmp, "write barrier");
JS_ASSERT(tmp == base);
}
#endif
}
@ -437,11 +455,30 @@ BaseShape::readBarrier(BaseShape *base)
{
#ifdef JSGC_INCREMENTAL
JSCompartment *comp = base->compartment();
if (comp->needsBarrier())
MarkBaseShapeUnbarriered(comp->barrierTracer(), base, "read barrier");
if (comp->needsBarrier()) {
BaseShape *tmp = base;
MarkBaseShapeUnbarriered(comp->barrierTracer(), &tmp, "read barrier");
JS_ASSERT(tmp == base);
}
#endif
}
inline void
BaseShape::markChildren(JSTracer *trc)
{
if (hasGetterObject())
MarkObjectUnbarriered(trc, &getterObj, "getter");
if (hasSetterObject())
MarkObjectUnbarriered(trc, &setterObj, "setter");
if (isOwned())
MarkBaseShape(trc, &unowned_, "base");
if (parent)
MarkObject(trc, &parent, "parent");
}
} /* namespace js */
#endif /* jsscopeinlines_h___ */

View File

@ -322,20 +322,6 @@ Bindings::trace(JSTracer *trc)
MarkShape(trc, &lastBinding, "shape");
}
#ifdef JS_CRASH_DIAGNOSTICS
void
CheckScript(JSScript *script, JSScript *prev)
{
if (script->cookie1[0] != JS_SCRIPT_COOKIE || script->cookie2[0] != JS_SCRIPT_COOKIE) {
crash::StackBuffer<sizeof(JSScript), 0x87> buf1(script);
crash::StackBuffer<sizeof(JSScript), 0x88> buf2(prev);
JS_OPT_ASSERT(false);
}
}
#endif /* JS_CRASH_DIAGNOSTICS */
#if JS_HAS_XDR
static bool
@ -1453,10 +1439,24 @@ js_CallDestroyScriptHook(JSContext *cx, JSScript *script)
JS_ClearScriptTraps(cx, script);
}
#ifdef JS_CRASH_DIAGNOSTICS
void
JSScript::CheckScript(JSScript *prev)
{
if (cookie1[0] != JS_SCRIPT_COOKIE || cookie2[0] != JS_SCRIPT_COOKIE) {
crash::StackBuffer<sizeof(JSScript), 0x87> buf1(this);
crash::StackBuffer<sizeof(JSScript), 0x88> buf2(prev);
JS_OPT_ASSERT(false);
}
}
#endif /* JS_CRASH_DIAGNOSTICS */
void
JSScript::finalize(JSContext *cx, bool background)
{
CheckScript(this, NULL);
CheckScript(NULL);
js_CallDestroyScriptHook(cx, this);
@ -1945,13 +1945,52 @@ JSScript::clearTraps(JSContext *cx)
}
void
JSScript::markTrapClosures(JSTracer *trc)
JSScript::markChildren(JSTracer *trc)
{
JS_ASSERT(hasAnyBreakpointsOrStepMode());
CheckScript(NULL);
for (unsigned i = 0; i < length; i++) {
BreakpointSite *site = debug->breakpoints[i];
if (site && site->trapHandler)
MarkValue(trc, &site->trapClosure, "trap closure");
JS_ASSERT_IF(trc->runtime->gcCheckCompartment,
compartment() == trc->runtime->gcCheckCompartment);
for (uint32_t i = 0; i < natoms; ++i) {
if (atoms[i])
MarkStringUnbarriered(trc, &atoms[i], "atom");
}
if (JSScript::isValidOffset(objectsOffset)) {
JSObjectArray *objarray = objects();
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
}
if (JSScript::isValidOffset(regexpsOffset)) {
JSObjectArray *objarray = regexps();
MarkObjectRange(trc, objarray->length, objarray->vector, "objects");
}
if (JSScript::isValidOffset(constOffset)) {
JSConstArray *constarray = consts();
MarkValueRange(trc, constarray->length, constarray->vector, "consts");
}
if (function())
MarkObject(trc, &function_, "function");
if (!isCachedEval && globalObject)
MarkObject(trc, &globalObject, "object");
if (IS_GC_MARKING_TRACER(trc) && filename)
js_MarkScriptFilename(filename);
bindings.trace(trc);
if (types)
types->trace(trc);
if (hasAnyBreakpointsOrStepMode()) {
for (unsigned i = 0; i < length; i++) {
BreakpointSite *site = debug->breakpoints[i];
if (site && site->trapHandler)
MarkValue(trc, &site->trapClosure, "trap closure");
}
}
}

View File

@ -554,7 +554,11 @@ struct JSScript : public js::gc::Cell {
#ifdef JS_CRASH_DIAGNOSTICS
/* All diagnostic fields must be multiples of Cell::CellSize. */
uint32_t cookie2[Cell::CellSize / sizeof(uint32_t)];
#endif
void CheckScript(JSScript *prev);
#else
void CheckScript(JSScript *prev) {}
#endif /* !JS_CRASH_DIAGNOSTICS */
#ifdef DEBUG
/*
@ -834,6 +838,8 @@ struct JSScript : public js::gc::Cell {
JSPrincipals *originPrincipals) {
return originPrincipals ? originPrincipals : principals;
}
void markChildren(JSTracer *trc);
};
/* If this fails, padding_ can be removed. */

View File

@ -245,7 +245,9 @@ JSScript::writeBarrierPre(JSScript *script)
JSCompartment *comp = script->compartment();
if (comp->needsBarrier()) {
JS_ASSERT(!comp->rt->gcRunning);
MarkScriptUnbarriered(comp->barrierTracer(), script, "write barrier");
JSScript *tmp = script;
MarkScriptUnbarriered(comp->barrierTracer(), &tmp, "write barrier");
JS_ASSERT(tmp == script);
}
#endif
}

Some files were not shown because too many files have changed in this diff Show More