Merge.
@ -617,8 +617,12 @@ var ctrlTab = {
|
||||
case "keydown":
|
||||
case "keyup":
|
||||
if (event.target == this.searchField) {
|
||||
if (event.keyCode == event.DOM_VK_RETURN)
|
||||
this.panel.focus();
|
||||
if (event.keyCode == event.DOM_VK_RETURN) {
|
||||
// If there's a pending search, kick it off now.
|
||||
if (this.searchField._timer)
|
||||
this.search();
|
||||
this.selectThumbnail();
|
||||
}
|
||||
} else {
|
||||
// Manually consume the events, as the panel is open but doesn't
|
||||
// necessarily have focus.
|
||||
|
@ -2095,6 +2095,11 @@ function losslessDecodeURI(aURI) {
|
||||
encodeURIComponent);
|
||||
} catch (e) {}
|
||||
|
||||
// Encode invisible characters (invisible control characters, soft hyphen,
|
||||
// zero-width space, BOM, line separator, paragraph separator) (bug 452979)
|
||||
value = value.replace(/[\v\x0c\x1c\x1d\x1e\x1f\u00ad\u200b\ufeff\u2028\u2029]/g,
|
||||
encodeURIComponent);
|
||||
|
||||
// Encode bidirectional formatting characters.
|
||||
// (RFC 3987 sections 3.2 and 4.1 paragraph 6)
|
||||
value = value.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
|
||||
|
@ -102,10 +102,17 @@
|
||||
|
||||
sanitize: function ()
|
||||
{
|
||||
// Update pref values before handing off to the sanitizer (bug 453440)
|
||||
this.updatePrefs();
|
||||
var s = new Sanitizer();
|
||||
s.ignoreTimespan = false;
|
||||
s.prefDomain = "privacy.cpd.";
|
||||
s.sanitize();
|
||||
try {
|
||||
s.sanitize();
|
||||
} catch (er) {
|
||||
Components.utils.reportError("Exception during sanitize: " + er);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
onReadGeneric: function ()
|
||||
@ -155,6 +162,18 @@
|
||||
if (history.checked)
|
||||
downloads.checked = true;
|
||||
},
|
||||
|
||||
updatePrefs : function ()
|
||||
{
|
||||
var tsPref = document.getElementById("privacy.sanitize.timeSpan");
|
||||
Sanitizer.prefs.setIntPref("timeSpan", tsPref.value);
|
||||
var sanitizePreferences = document.getElementById("sanitizePreferences");
|
||||
var prefs = sanitizePreferences.rootBranch;
|
||||
for (var i = 0; i < sanitizePreferences.childNodes.length; ++i) {
|
||||
var p = sanitizePreferences.childNodes[i];
|
||||
prefs.setBoolPref(p.name, p.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
]]>
|
||||
</script>
|
||||
|
@ -91,7 +91,18 @@ function test() {
|
||||
ok(isOpen(),
|
||||
"panel is sticky after focusing the search field and releasing the Ctrl key");
|
||||
|
||||
ctrlTab.searchField.value = "foo";
|
||||
EventUtils.synthesizeKey("f", {});
|
||||
EventUtils.synthesizeKey("o", {});
|
||||
EventUtils.synthesizeKey("o", {});
|
||||
is(ctrlTab.searchField.value, "foo",
|
||||
"text entered into search field");
|
||||
|
||||
EventUtils.synthesizeKey("VK_RETURN", {});
|
||||
ok(isOpen(),
|
||||
"Enter key kicks pending search off; the panel stays open as there's no match");
|
||||
is(ctrlTab.searchField.value, "foo",
|
||||
"search field value persists after Enter pressed");
|
||||
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
is(ctrlTab.searchField.value, "",
|
||||
"ESC key clears the search field");
|
||||
|
@ -66,6 +66,12 @@ clean::
|
||||
distclean::
|
||||
@$(MAKE) -C browser/installer distclean
|
||||
|
||||
source-package::
|
||||
@$(MAKE) -C browser/installer source-package
|
||||
|
||||
upload::
|
||||
@$(MAKE) -C browser/installer upload
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
# Implemented in testing/testsuite-targets.mk
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
# Giorgio Maone <g.maone@informaction.com>
|
||||
# Seth Spitzer <sspitzer@mozilla.com>
|
||||
# Asaf Romano <mano@mozilla.com>
|
||||
# Marco Bonardo <mak77@bonardo.net>
|
||||
#
|
||||
# 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
|
||||
@ -127,6 +128,9 @@ BrowserGlue.prototype = {
|
||||
subject.QueryInterface(Ci.nsISupportsPRBool);
|
||||
subject.data = true;
|
||||
break;
|
||||
case "places-init-complete":
|
||||
this._initPlaces();
|
||||
break;
|
||||
case "idle":
|
||||
if (this.idleService.idleTime > BOOKMARKS_ARCHIVE_IDLE_TIME * 1000) {
|
||||
// Back up bookmarks.
|
||||
@ -151,6 +155,7 @@ BrowserGlue.prototype = {
|
||||
osvr.addObserver(this, "quit-application-requested", false);
|
||||
osvr.addObserver(this, "quit-application-granted", false);
|
||||
osvr.addObserver(this, "session-save", false);
|
||||
osvr.addObserver(this, "places-init-complete", false);
|
||||
},
|
||||
|
||||
// cleanup (called on application shutdown)
|
||||
@ -168,6 +173,7 @@ BrowserGlue.prototype = {
|
||||
osvr.removeObserver(this, "quit-application-requested");
|
||||
osvr.removeObserver(this, "quit-application-granted");
|
||||
osvr.removeObserver(this, "session-save");
|
||||
osvr.removeObserver(this, "places-init-complete");
|
||||
},
|
||||
|
||||
_onAppDefaults: function()
|
||||
@ -192,9 +198,6 @@ BrowserGlue.prototype = {
|
||||
"_blank", "chrome,centerscreen,modal,resizable=no", null);
|
||||
}
|
||||
|
||||
// initialize Places
|
||||
this._initPlaces();
|
||||
|
||||
// apply distribution customizations
|
||||
// prefs are applied in _onAppDefaults()
|
||||
var distro = new DistributionCustomizer();
|
||||
@ -426,7 +429,7 @@ BrowserGlue.prototype = {
|
||||
}
|
||||
];
|
||||
|
||||
// Set pref to indicate we've shown the notficiation.
|
||||
// Set pref to indicate we've shown the notification.
|
||||
var currentVersion = this._prefs.getIntPref("browser.rights.version");
|
||||
this._prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
|
||||
|
||||
@ -454,46 +457,73 @@ BrowserGlue.prototype = {
|
||||
|
||||
/**
|
||||
* Initialize Places
|
||||
* - imports the bookmarks html file if bookmarks datastore is empty
|
||||
* - imports the bookmarks html file if bookmarks database is empty, try to
|
||||
* restore bookmarks from a JSON backup if the backend indicates that the
|
||||
* database was corrupt.
|
||||
*
|
||||
* These prefs can be set up by the frontend:
|
||||
*
|
||||
* WARNING: setting these preferences to true will overwite existing bookmarks
|
||||
*
|
||||
* These prefs are set by the backend services upon creation (or recreation)
|
||||
* of the Places db:
|
||||
* - browser.places.importBookmarksHTML
|
||||
* Set to false by the history service to indicate we need to re-import.
|
||||
* Set to true will import the bookmarks.html file from the profile folder.
|
||||
* - browser.places.smartBookmarksVersion
|
||||
* Set during HTML import to indicate that Smart Bookmarks were created.
|
||||
* Set to -1 to disable Smart Bookmarks creation.
|
||||
* Set to 0 to restore current Smart Bookmarks.
|
||||
*
|
||||
* These prefs are set up by the frontend:
|
||||
* - browser.bookmarks.restore_default_bookmarks
|
||||
* Set to true by safe-mode dialog to indicate we must restore default
|
||||
* bookmarks.
|
||||
*/
|
||||
_initPlaces: function bg__initPlaces() {
|
||||
// we need to instantiate the history service before checking
|
||||
// the browser.places.importBookmarksHTML pref, as
|
||||
// nsNavHistory::ForceMigrateBookmarksDB() will set that pref
|
||||
// if we need to force a migration (due to a schema change)
|
||||
// We must instantiate the history service since it will tell us if we
|
||||
// need to import or restore bookmarks due to first-run, corruption or
|
||||
// forced migration (due to a major schema change).
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
var databaseStatus = histsvc.databaseStatus;
|
||||
|
||||
var importBookmarks = false;
|
||||
var restoreDefaultBookmarks = false;
|
||||
// If the database is corrupt or has been newly created we should
|
||||
// import bookmarks.
|
||||
var importBookmarks = databaseStatus != histsvc.DATABASE_STATUS_OK;
|
||||
|
||||
// Check if user or an extension has required to import bookmarks.html
|
||||
var importBookmarksHTML = false;
|
||||
try {
|
||||
restoreDefaultBookmarks = this._prefs.getBoolPref("browser.bookmarks.restore_default_bookmarks");
|
||||
importBookmarksHTML =
|
||||
this._prefs.getBoolPref("browser.places.importBookmarksHTML");
|
||||
if (importBookmarksHTML)
|
||||
importBookmarks = true;
|
||||
} catch(ex) {}
|
||||
|
||||
if (restoreDefaultBookmarks) {
|
||||
// Ensure that we already have a bookmarks backup for today
|
||||
this._archiveBookmarks();
|
||||
// we will restore bookmarks from html
|
||||
importBookmarks = true;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
importBookmarks = this._prefs.getBoolPref("browser.places.importBookmarksHTML");
|
||||
} catch(ex) {}
|
||||
// Check if Safe Mode or the user has required to restore bookmarks from
|
||||
// default profile's bookmarks.html
|
||||
var restoreDefaultBookmarks = false;
|
||||
try {
|
||||
restoreDefaultBookmarks =
|
||||
this._prefs.getBoolPref("browser.bookmarks.restore_default_bookmarks");
|
||||
if (restoreDefaultBookmarks) {
|
||||
// Ensure that we already have a bookmarks backup for today
|
||||
this._archiveBookmarks();
|
||||
importBookmarks = true;
|
||||
}
|
||||
} catch(ex) {}
|
||||
|
||||
// If the user did not require to restore default bookmarks, or import
|
||||
// from bookmarks.html, we will try to restore from JSON
|
||||
if (importBookmarks && !restoreDefaultBookmarks && !importBookmarksHTML) {
|
||||
// get latest JSON backup
|
||||
Cu.import("resource://gre/modules/utils.js");
|
||||
var bookmarksFile = PlacesUtils.getMostRecentBackup();
|
||||
if (bookmarksFile && bookmarksFile.leafName.match("\.json$")) {
|
||||
// restore from JSON backup
|
||||
PlacesUtils.restoreBookmarksFromJSONFile(bookmarksFile);
|
||||
importBookmarks = false;
|
||||
}
|
||||
else {
|
||||
// No backup was available we will try to import from bookmarks.html
|
||||
importBookmarks = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!importBookmarks) {
|
||||
@ -502,45 +532,41 @@ BrowserGlue.prototype = {
|
||||
this.ensurePlacesDefaultQueriesInitialized();
|
||||
}
|
||||
else {
|
||||
// get latest backup
|
||||
Cu.import("resource://gre/modules/utils.js");
|
||||
var bookmarksFile = PlacesUtils.getMostRecentBackup();
|
||||
// Create a new Organizer left pane folder root, the old will not be
|
||||
// valid anymore.
|
||||
this._prefs.setIntPref("browser.places.leftPaneFolderId", -1);
|
||||
|
||||
if (!restoreDefaultBookmarks &&
|
||||
bookmarksFile && bookmarksFile.leafName.match("\.json$")) {
|
||||
// restore a JSON backup
|
||||
PlacesUtils.restoreBookmarksFromJSONFile(bookmarksFile);
|
||||
// ensurePlacesDefaultQueriesInitialized() is called by import.
|
||||
this._prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
|
||||
|
||||
// Get bookmarks folder
|
||||
var dirService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
var bookmarksFile = dirService.get("BMarks", Ci.nsILocalFile);
|
||||
|
||||
// User wants to restore default bookmarks
|
||||
if (restoreDefaultBookmarks || !bookmarksFile.exists()) {
|
||||
// get bookmarks.html file from default profile folder
|
||||
bookmarksFile = dirService.get("profDef", Ci.nsILocalFile);
|
||||
bookmarksFile.append("bookmarks.html");
|
||||
}
|
||||
else {
|
||||
// if there's no JSON backup or we are restoring default bookmarks
|
||||
|
||||
// ensurePlacesDefaultQueriesInitialized() is called by import.
|
||||
this._prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
|
||||
// import the file
|
||||
try {
|
||||
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
|
||||
getService(Ci.nsIPlacesImportExportService);
|
||||
importer.importHTMLFromFile(bookmarksFile, true /* overwrite existing */);
|
||||
} catch (err) {
|
||||
// Report the error, but ignore it.
|
||||
Cu.reportError(err);
|
||||
}
|
||||
|
||||
var dirService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
|
||||
var bookmarksFile = dirService.get("BMarks", Ci.nsILocalFile);
|
||||
if (restoreDefaultBookmarks || !bookmarksFile.exists()) {
|
||||
// get bookmarks.html file from default profile folder
|
||||
bookmarksFile = dirService.get("profDef", Ci.nsILocalFile);
|
||||
bookmarksFile.append("bookmarks.html");
|
||||
}
|
||||
|
||||
// import the file
|
||||
try {
|
||||
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
|
||||
getService(Ci.nsIPlacesImportExportService);
|
||||
importer.importHTMLFromFile(bookmarksFile, true /* overwrite existing */);
|
||||
} catch (err) {
|
||||
// Report the error, but ignore it.
|
||||
Cu.reportError(err);
|
||||
}
|
||||
// Reset preferences, so we won't try to import again at next run
|
||||
if (importBookmarksHTML)
|
||||
this._prefs.setBoolPref("browser.places.importBookmarksHTML", false);
|
||||
if (restoreDefaultBookmarks)
|
||||
this._prefs.setBoolPref("browser.bookmarks.restore_default_bookmarks",
|
||||
false);
|
||||
}
|
||||
if (restoreDefaultBookmarks)
|
||||
this._prefs.setBoolPref("browser.bookmarks.restore_default_bookmarks",
|
||||
false);
|
||||
}
|
||||
|
||||
// Initialize bookmark archiving on idle.
|
||||
@ -923,11 +949,6 @@ GeolocationPrompt.prototype = {
|
||||
callback: function() request.allow() ,
|
||||
},
|
||||
{
|
||||
label: browserBundle.GetStringFromName("geolocation.neighborhoodLocation"),
|
||||
accessKey: browserBundle.GetStringFromName("geolocation.neighborhoodLocationKey"),
|
||||
callback: function() request.allowButFuzz() ,
|
||||
},
|
||||
{
|
||||
label: browserBundle.GetStringFromName("geolocation.nothingLocation"),
|
||||
accessKey: browserBundle.GetStringFromName("geolocation.nothingLocationKey"),
|
||||
callback: function() request.cancel() ,
|
||||
|
@ -693,6 +693,7 @@ var gEditItemOverlay = {
|
||||
if (!this._uri.equals(uri)) {
|
||||
var txn = PlacesUIUtils.ptm.editBookmarkURI(this._itemId, uri);
|
||||
PlacesUIUtils.ptm.doTransaction(txn);
|
||||
this._uri = uri;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -178,6 +178,7 @@
|
||||
observes="paneElementsBroadcaster"/>
|
||||
<textbox id="editBMPanel_tagsField"
|
||||
type="autocomplete"
|
||||
class="padded"
|
||||
autocompletesearch="places-tag-autocomplete"
|
||||
completedefaultindex="true"
|
||||
tabscrolling="true"
|
||||
|
@ -415,11 +415,14 @@ var PlacesOrganizer = {
|
||||
restorePopup.removeChild(restorePopup.firstChild);
|
||||
|
||||
// get list of files
|
||||
var localizedFilename = PlacesUtils.getString("bookmarksArchiveFilename");
|
||||
var localizedFilenamePrefix = localizedFilename.substr(0, localizedFilename.indexOf("-"));
|
||||
var fileList = [];
|
||||
var files = this.bookmarksBackupDir.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
var f = files.getNext().QueryInterface(Ci.nsIFile);
|
||||
if (!f.isHidden() && f.leafName.match(/^bookmarks-.+json$/))
|
||||
var rx = new RegExp("^(bookmarks|" + localizedFilenamePrefix + ")-.+\.json");
|
||||
if (!f.isHidden() && f.leafName.match(rx))
|
||||
fileList.push(f);
|
||||
}
|
||||
|
||||
@ -435,8 +438,8 @@ var PlacesOrganizer = {
|
||||
var m = restorePopup.insertBefore
|
||||
(document.createElement("menuitem"),
|
||||
document.getElementById("restoreFromFile"));
|
||||
var dateStr = fileList[i].leafName.replace("bookmarks-", "").
|
||||
replace(/\.json$/, "");
|
||||
var rx = new RegExp("^(bookmarks|" + localizedFilenamePrefix + ")-");
|
||||
var dateStr = fileList[i].leafName.replace(rx, "").replace(/\.json$/, "");
|
||||
if (!dateStr.length)
|
||||
dateStr = fileList[i].leafName;
|
||||
m.setAttribute("label", dateStr);
|
||||
|
@ -157,7 +157,6 @@ bin/components/places.xpt
|
||||
bin/components/plugin.xpt
|
||||
bin/components/prefetch.xpt
|
||||
bin/components/pref.xpt
|
||||
bin/components/privatebrowsing.xpt
|
||||
bin/components/proxyObjInst.xpt
|
||||
bin/components/toolkitremote.xpt
|
||||
bin/components/rdf.xpt
|
||||
|
@ -163,7 +163,6 @@ bin\components\places.xpt
|
||||
bin\components\plugin.xpt
|
||||
bin\components\pref.xpt
|
||||
bin\components\prefetch.xpt
|
||||
bin\components\privatebrowsing.xpt
|
||||
bin\components\profile.xpt
|
||||
bin\components\proxyObject.xpt
|
||||
bin\components\rdf.xpt
|
||||
|
@ -143,8 +143,6 @@ editBookmarkPanel.editBookmarkTitle=Edit This Bookmark
|
||||
#
|
||||
geolocation.exactLocation=Exact Location (within 10 feet)
|
||||
geolocation.exactLocationKey=E
|
||||
geolocation.neighborhoodLocation=Neighborhood (within 1 mile)
|
||||
geolocation.neighborhoodLocationKey=N
|
||||
geolocation.nothingLocation=Nothing
|
||||
geolocation.nothingLocationKey=o
|
||||
geolocation.requestMessage=%S wants to know where you are. Tell them:
|
||||
|
@ -1,25 +1,39 @@
|
||||
af
|
||||
ar
|
||||
be
|
||||
bg
|
||||
bn-IN
|
||||
ca
|
||||
cs
|
||||
cy
|
||||
de
|
||||
el
|
||||
en-GB
|
||||
en-US
|
||||
eo
|
||||
es-AR
|
||||
es-ES
|
||||
et
|
||||
eu
|
||||
fi
|
||||
fr
|
||||
fy-NL
|
||||
ga-IE
|
||||
gu-IN
|
||||
he
|
||||
hi-IN
|
||||
hu
|
||||
id
|
||||
is
|
||||
it
|
||||
ja linux win32
|
||||
ja-JP-mac osx
|
||||
ka
|
||||
kn
|
||||
ko
|
||||
lt
|
||||
lv
|
||||
mr
|
||||
nb-NO
|
||||
nl
|
||||
nn-NO
|
||||
@ -31,7 +45,11 @@ ro
|
||||
ru
|
||||
si
|
||||
sk
|
||||
sl
|
||||
sq
|
||||
sv-SE
|
||||
te
|
||||
tr
|
||||
uk
|
||||
zh-CN
|
||||
zh-TW
|
||||
|
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 725 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.8 KiB |
@ -16,9 +16,7 @@ classic.jar:
|
||||
skin/classic/browser/pageInfo.png
|
||||
skin/classic/browser/page-livemarks.png
|
||||
skin/classic/browser/Privacy-16.png
|
||||
skin/classic/browser/Privacy-32.png
|
||||
skin/classic/browser/Privacy-48.png
|
||||
skin/classic/browser/Privacy-64.png
|
||||
skin/classic/browser/searchbar.css (searchbar.css)
|
||||
skin/classic/browser/Search-glass.png
|
||||
skin/classic/browser/Search-glass-rtl.png
|
||||
|
@ -73,15 +73,6 @@ radio[pane=paneAdvanced] {
|
||||
-moz-image-region: rect(0px, 224px, 32px, 192px)
|
||||
}
|
||||
|
||||
/* General Pane */
|
||||
#browserHomePage {
|
||||
padding-top: 2px;
|
||||
padding-bottom: 3px;
|
||||
-moz-padding-start: 4px;
|
||||
-moz-padding-end: 2px;
|
||||
background-color: -moz-Dialog;
|
||||
}
|
||||
|
||||
/* Applications Pane */
|
||||
#BrowserPreferences[animated="true"] #handlersView {
|
||||
height: 25em;
|
||||
|
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 403 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 6.0 KiB |
@ -38,9 +38,7 @@ classic.jar:
|
||||
skin/classic/browser/pageInfo.png
|
||||
skin/classic/browser/Popup-blocked.png
|
||||
skin/classic/browser/Privacy-16.png
|
||||
skin/classic/browser/Privacy-32.png
|
||||
skin/classic/browser/Privacy-48.png
|
||||
skin/classic/browser/Privacy-64.png
|
||||
skin/classic/browser/searchbar.css
|
||||
skin/classic/browser/Search.png
|
||||
skin/classic/browser/Search-addengines.png
|
||||
|
BIN
browser/themes/winstripe/browser/Privacy-16-aero.png
Normal file
After Width: | Height: | Size: 829 B |
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 817 B |
BIN
browser/themes/winstripe/browser/Privacy-32-aero.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
browser/themes/winstripe/browser/Privacy-48-aero.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 4.6 KiB |
BIN
browser/themes/winstripe/browser/Privacy-64-aero.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 6.8 KiB |
@ -86,7 +86,7 @@ body[dir="rtl"] #errorPageContainer {
|
||||
}
|
||||
|
||||
#technicalContent > h2, #expertContent > h2 {
|
||||
background : url("chrome://browser/skin/section_expanded.png") left 0 no-repeat;
|
||||
background : url("chrome://browser/skin/section_expanded.png") left center no-repeat;
|
||||
}
|
||||
|
||||
#technicalContent[collapsed] > h2,
|
||||
|
@ -18,9 +18,7 @@ classic.jar:
|
||||
skin/classic/browser/livemark-folder.png (livemark-folder.png)
|
||||
skin/classic/browser/Bookmarks-folder.png (Bookmarks-folder.png)
|
||||
skin/classic/browser/Privacy-16.png
|
||||
skin/classic/browser/Privacy-32.png
|
||||
skin/classic/browser/Privacy-48.png
|
||||
skin/classic/browser/Privacy-64.png
|
||||
skin/classic/browser/Secure.png (Secure.png)
|
||||
skin/classic/browser/Secure24.png (Secure24.png)
|
||||
skin/classic/browser/Security-broken.png (Security-broken.png)
|
||||
@ -113,10 +111,8 @@ classic.jar:
|
||||
skin/classic/aero/browser/livemark-item.png (livemark-item-aero.png)
|
||||
skin/classic/aero/browser/livemark-folder.png (livemark-folder-aero.png)
|
||||
skin/classic/aero/browser/Bookmarks-folder.png (Bookmarks-folder-aero.png)
|
||||
skin/classic/aero/browser/Privacy-16.png
|
||||
skin/classic/aero/browser/Privacy-32.png
|
||||
skin/classic/aero/browser/Privacy-48.png
|
||||
skin/classic/aero/browser/Privacy-64.png
|
||||
skin/classic/aero/browser/Privacy-16.png (Privacy-16-aero.png)
|
||||
skin/classic/aero/browser/Privacy-48.png (Privacy-48-aero.png)
|
||||
skin/classic/aero/browser/Secure.png (Secure-aero.png)
|
||||
skin/classic/aero/browser/Secure24.png (Secure24-aero.png)
|
||||
skin/classic/aero/browser/Security-broken.png (Security-broken-aero.png)
|
||||
|
@ -59,3 +59,9 @@
|
||||
#placeContent:-moz-system-metric(windows-default-theme) {
|
||||
background-color: #EEF3FA;
|
||||
}
|
||||
|
||||
/**** Vista default theme: Library's search box needs to be vertically centered ****/
|
||||
#searchFilter:-moz-system-metric(windows-default-theme) {
|
||||
padding-top: 3px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
@ -100,15 +100,6 @@ radio[pane=paneAdvanced][selected="true"] {
|
||||
-moz-image-region: rect(32px, 224px, 64px, 192px)
|
||||
}
|
||||
|
||||
/* General Pane */
|
||||
#browserHomePage {
|
||||
padding-top: 2px;
|
||||
padding-bottom: 3px;
|
||||
-moz-padding-start: 4px;
|
||||
-moz-padding-end: 2px;
|
||||
background-color: -moz-Dialog;
|
||||
}
|
||||
|
||||
/* Applications Pane */
|
||||
#BrowserPreferences[animated="true"] #handlersView {
|
||||
height: 25em;
|
||||
|
0
build/__init__.py
Normal file
@ -79,6 +79,7 @@ if __name__ == '__main__':
|
||||
if automation.UNIXISH:
|
||||
browserEnv["LD_LIBRARY_PATH"] = os.path.join(SCRIPT_DIR, DIST_BIN)
|
||||
browserEnv["MOZILLA_FIVE_HOME"] = os.path.join(SCRIPT_DIR, DIST_BIN)
|
||||
browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1"
|
||||
|
||||
automation.runApp("http://localhost:%d/bloatcycle.html" % PORT, browserEnv,
|
||||
os.path.join(SCRIPT_DIR, automation.DEFAULT_APP),
|
||||
|
196
build/upload.py
Normal file
@ -0,0 +1,196 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# The Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2008
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Ted Mielczarek <ted.mielczarek@gmail.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 *****
|
||||
#
|
||||
# When run directly, this script expects the following environment variables
|
||||
# to be set:
|
||||
# UPLOAD_HOST : host to upload files to
|
||||
# UPLOAD_USER : username on that host
|
||||
# UPLOAD_PATH : path on that host to put the files in
|
||||
#
|
||||
# And will use the following optional environment variables if set:
|
||||
# UPLOAD_SSH_KEY : path to a ssh private key to use
|
||||
# UPLOAD_PORT : port to use for ssh
|
||||
# POST_UPLOAD_CMD: a commandline to run on the remote host after uploading.
|
||||
# UPLOAD_PATH and the full paths of all files uploaded will
|
||||
# be appended to the commandline.
|
||||
#
|
||||
# All files to be uploaded should be passed as commandline arguments to this
|
||||
# script. The script takes one other parameter, --base-path, which you can use
|
||||
# to indicate that files should be uploaded including their paths relative
|
||||
# to the base path.
|
||||
|
||||
import sys, os
|
||||
from optparse import OptionParser
|
||||
from util import check_call
|
||||
|
||||
def RequireEnvironmentVariable(v):
|
||||
"""Return the value of the environment variable named v, or print
|
||||
an error and exit if it's unset (or empty)."""
|
||||
if not v in os.environ or os.environ[v] == "":
|
||||
print "Error: required environment variable %s not set" % v
|
||||
sys.exit(1)
|
||||
return os.environ[v]
|
||||
|
||||
def OptionalEnvironmentVariable(v):
|
||||
"""Return the value of the environment variable named v, or None
|
||||
if it's unset (or empty)."""
|
||||
if v in os.environ and os.environ[v] != "":
|
||||
return os.environ[v]
|
||||
return None
|
||||
|
||||
def FixupMsysPath(path):
|
||||
"""MSYS helpfully translates absolute pathnames in environment variables
|
||||
and commandline arguments into Windows native paths. This sucks if you're
|
||||
trying to pass an absolute path on a remote server. This function attempts
|
||||
to un-mangle such paths."""
|
||||
if 'OSTYPE' in os.environ and os.environ['OSTYPE'] == 'msys':
|
||||
# sort of awful, find out where our shell is (should be in msys/bin)
|
||||
# and strip the first part of that path out of the other path
|
||||
if 'SHELL' in os.environ:
|
||||
sh = os.environ['SHELL']
|
||||
msys = sh[:sh.find('/bin')]
|
||||
if path.startswith(msys):
|
||||
path = path[len(msys):]
|
||||
return path
|
||||
|
||||
def WindowsPathToMsysPath(path):
|
||||
"""Translate a Windows pathname to an MSYS pathname.
|
||||
Necessary because we call out to ssh/scp, which are MSYS binaries
|
||||
and expect MSYS paths."""
|
||||
if sys.platform != 'win32':
|
||||
return path
|
||||
(drive, path) = os.path.splitdrive(os.path.abspath(path))
|
||||
return "/" + drive[0] + path.replace('\\','/')
|
||||
|
||||
def AppendOptionalArgsToSSHCommandline(cmdline, port, ssh_key):
|
||||
"""Given optional port and ssh key values, append valid OpenSSH
|
||||
commandline arguments to the list cmdline if the values are not None."""
|
||||
if port is not None:
|
||||
cmdline.append("-P%d" % port)
|
||||
if ssh_key is not None:
|
||||
cmdline.extend(["-i", WindowsPathToMsysPath(ssh_key)])
|
||||
|
||||
def DoSSHCommand(command, user, host, port=None, ssh_key=None):
|
||||
"""Execute command on user@host using ssh. Optionally use
|
||||
port and ssh_key, if provided."""
|
||||
cmdline = ["ssh"]
|
||||
AppendOptionalArgsToSSHCommandline(cmdline, port, ssh_key)
|
||||
cmdline.extend(["%s@%s" % (user, host), command])
|
||||
check_call(cmdline)
|
||||
|
||||
def DoSCPFile(file, remote_path, user, host, port=None, ssh_key=None):
|
||||
"""Upload file to user@host:remote_path using scp. Optionally use
|
||||
port and ssh_key, if provided."""
|
||||
cmdline = ["scp"]
|
||||
AppendOptionalArgsToSSHCommandline(cmdline, port, ssh_key)
|
||||
cmdline.extend([WindowsPathToMsysPath(file),
|
||||
"%s@%s:%s" % (user, host, remote_path)])
|
||||
check_call(cmdline)
|
||||
|
||||
def GetRemotePath(path, local_file, base_path):
|
||||
"""Given a remote path to upload to, a full path to a local file, and an
|
||||
optional full path that is a base path of the local file, construct the
|
||||
full remote path to place the file in. If base_path is not None, include
|
||||
the relative path from base_path to file."""
|
||||
if base_path is None or not local_file.startswith(base_path):
|
||||
return path
|
||||
dir = os.path.dirname(local_file)
|
||||
# strip base_path + extra slash and make it unixy
|
||||
dir = dir[len(base_path)+1:].replace('\\','/')
|
||||
return path + dir
|
||||
|
||||
def UploadFiles(user, host, path, files, verbose=False, port=None, ssh_key=None, base_path=None, post_upload_command=None):
|
||||
"""Upload each file in the list files to user@host:path. Optionally pass
|
||||
port and ssh_key to the ssh commands. If base_path is not None, upload
|
||||
files including their path relative to base_path. If post_upload_command
|
||||
is not None, execute that command on the remote host after uploading
|
||||
all files, passing it the upload path, and the full paths to all files
|
||||
uploaded. If verbose is True, print status updates while working."""
|
||||
if not path.endswith("/"):
|
||||
path += "/"
|
||||
if base_path is not None:
|
||||
base_path = os.path.abspath(base_path)
|
||||
remote_files = []
|
||||
for file in files:
|
||||
file = os.path.abspath(file)
|
||||
if not os.path.isfile(file):
|
||||
raise IOError("File not found: %s" % file)
|
||||
# first ensure that path exists remotely
|
||||
remote_path = GetRemotePath(path, file, base_path)
|
||||
DoSSHCommand("mkdir -p " + remote_path, user, host, port=port, ssh_key=ssh_key)
|
||||
if verbose:
|
||||
print "Uploading " + file
|
||||
DoSCPFile(file, remote_path, user, host, port=port, ssh_key=ssh_key)
|
||||
remote_files.append(remote_path + '/' + os.path.basename(file))
|
||||
if post_upload_command is not None:
|
||||
if verbose:
|
||||
print "Running post-upload command: " + post_upload_command
|
||||
file_list = '"' + '" "'.join(remote_files) + '"'
|
||||
DoSSHCommand('%s "%s" %s' % (post_upload_command, path, file_list), user, host, port=port, ssh_key=ssh_key)
|
||||
if verbose:
|
||||
print "Upload complete"
|
||||
|
||||
if __name__ == '__main__':
|
||||
host = RequireEnvironmentVariable('UPLOAD_HOST')
|
||||
user = RequireEnvironmentVariable('UPLOAD_USER')
|
||||
path = RequireEnvironmentVariable('UPLOAD_PATH')
|
||||
port = int(OptionalEnvironmentVariable('UPLOAD_PORT'))
|
||||
key = OptionalEnvironmentVariable('UPLOAD_SSH_KEY')
|
||||
post_upload_command = OptionalEnvironmentVariable('POST_UPLOAD_CMD')
|
||||
if sys.platform == 'win32':
|
||||
path = FixupMsysPath(path)
|
||||
post_upload_command = FixupMsysPath(post_upload_command)
|
||||
|
||||
parser = OptionParser(usage="usage: %prog [options] <files>")
|
||||
parser.add_option("-b", "--base-path",
|
||||
action="store", dest="base_path",
|
||||
help="Preserve file paths relative to this path when uploading. If unset, all files will be uploaded directly to UPLOAD_PATH.")
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) < 1:
|
||||
print "You must specify at least one file to upload"
|
||||
sys.exit(1)
|
||||
try:
|
||||
UploadFiles(user, host, path, args, base_path=options.base_path,
|
||||
port=port, ssh_key=key, post_upload_command=post_upload_command,
|
||||
verbose=True)
|
||||
except IOError, (strerror):
|
||||
print strerror
|
||||
except Exception, (err):
|
||||
print err
|
||||
|
50
build/util.py
Normal file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# The Mozilla Foundation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2008
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Ted Mielczarek <ted.mielczarek@gmail.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 *****
|
||||
|
||||
try:
|
||||
from subprocess import check_call
|
||||
except ImportError:
|
||||
import subprocess
|
||||
def check_call(*popenargs, **kwargs):
|
||||
retcode = subprocess.call(*popenargs, **kwargs)
|
||||
if retcode:
|
||||
cmd = kwargs.get("args")
|
||||
if cmd is None:
|
||||
cmd = popenargs[0]
|
||||
raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
|
@ -750,8 +750,8 @@ nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult)
|
||||
|
||||
PackageEntry* entry =
|
||||
static_cast<PackageEntry*>(PL_DHashTableOperate(&mPackagesHash,
|
||||
& (nsACString&) package,
|
||||
PL_DHASH_LOOKUP));
|
||||
& (nsACString&) package,
|
||||
PL_DHASH_LOOKUP));
|
||||
|
||||
if (PL_DHASH_ENTRY_IS_FREE(entry)) {
|
||||
if (!mInitialized)
|
||||
@ -1326,6 +1326,32 @@ nsChromeRegistry::CheckForNewChrome()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(PRBool)
|
||||
nsChromeRegistry::WrappersEnabled(nsIURI *aURI)
|
||||
{
|
||||
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aURI));
|
||||
if (!chromeURL)
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool isChrome = PR_FALSE;
|
||||
nsresult rv = chromeURL->SchemeIs("chrome", &isChrome);
|
||||
if (NS_FAILED(rv) || !isChrome)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCAutoString package;
|
||||
rv = chromeURL->GetHostPort(package);
|
||||
if (NS_FAILED(rv))
|
||||
return PR_FALSE;
|
||||
|
||||
PackageEntry* entry =
|
||||
static_cast<PackageEntry*>(PL_DHashTableOperate(&mPackagesHash,
|
||||
& (nsACString&) package,
|
||||
PL_DHASH_LOOKUP));
|
||||
|
||||
return PL_DHASH_ENTRY_IS_LIVE(entry) &&
|
||||
entry->flags & PackageEntry::XPCNATIVEWRAPPERS;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::ProcessNewChromeFile(nsILocalFile *aListFile, nsIURI* aManifest)
|
||||
{
|
||||
|
13
client.py
@ -11,23 +11,12 @@ import sys
|
||||
import datetime
|
||||
import shutil
|
||||
from optparse import OptionParser
|
||||
from build.util import check_call
|
||||
|
||||
topsrcdir = os.path.dirname(__file__)
|
||||
if topsrcdir == '':
|
||||
topsrcdir = '.'
|
||||
|
||||
try:
|
||||
from subprocess import check_call
|
||||
except ImportError:
|
||||
import subprocess
|
||||
def check_call(*popenargs, **kwargs):
|
||||
retcode = subprocess.call(*popenargs, **kwargs)
|
||||
if retcode:
|
||||
cmd = kwargs.get("args")
|
||||
if cmd is None:
|
||||
cmd = popenargs[0]
|
||||
raise Exception("Command '%s' returned non-zero exit status %i" % (cmd, retcode))
|
||||
|
||||
def check_call_noisy(cmd, *args, **kwargs):
|
||||
print "Executing command:", cmd
|
||||
check_call(cmd, *args, **kwargs)
|
||||
|
@ -1487,7 +1487,6 @@ $(FINAL_TARGET):
|
||||
$(NSINSTALL) -D $@
|
||||
|
||||
export:: $(FINAL_TARGET)
|
||||
$(NSINSTALL) -D $(FINAL_TARGET)
|
||||
endif
|
||||
|
||||
ifndef NO_DIST_INSTALL
|
||||
|
@ -808,6 +808,20 @@ public:
|
||||
*/
|
||||
static PRBool IsChromeDoc(nsIDocument *aDocument);
|
||||
|
||||
/**
|
||||
* Get the script file name to use when compiling the script
|
||||
* referenced by aURI. In cases where there's no need for any extra
|
||||
* security wrapper automation the script file name that's returned
|
||||
* will be the spec in aURI, else it will be the spec in aDocument's
|
||||
* URI followed by aURI's spec, separated by " -> ". Returns PR_TRUE
|
||||
* if the script file name was modified, PR_FALSE if it's aURI's
|
||||
* spec.
|
||||
*/
|
||||
static PRBool GetWrapperSafeScriptFilename(nsIDocument *aDocument,
|
||||
nsIURI *aURI,
|
||||
nsACString& aScriptURI);
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if aDocument belongs to a chrome docshell for
|
||||
* display purposes. Returns false for null documents or documents
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(68389281-f6d0-4533-841d-344a2018140c)]
|
||||
[scriptable, uuid(249fb5ad-ae29-4e2c-a728-ba5cf464d188)]
|
||||
interface nsIChromeRegistry : nsISupports
|
||||
{
|
||||
const PRInt32 NONE = 0;
|
||||
@ -73,6 +73,11 @@ interface nsIChromeRegistry : nsISupports
|
||||
* refresh the chrome list at runtime, looking for new packages/etc
|
||||
*/
|
||||
void checkForNewChrome();
|
||||
|
||||
/**
|
||||
* returns whether XPCNativeWrappers are enabled for aURI.
|
||||
*/
|
||||
[notxpcom] boolean wrappersEnabled(in nsIURI aURI);
|
||||
};
|
||||
|
||||
[scriptable, uuid(2860e205-490e-4b06-90b6-87160d35a5a7)]
|
||||
|
@ -902,15 +902,6 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
|
||||
nsContentUtils::TraverseListenerManager(tmp, cb); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_PRESERVED_WRAPPER \
|
||||
{ \
|
||||
nsISupports *preservedWrapper = nsnull; \
|
||||
if (tmp->GetOwnerDoc()) \
|
||||
preservedWrapper = tmp->GetOwnerDoc()->GetReference(tmp); \
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[preserved wrapper]");\
|
||||
cb.NoteXPCOMChild(preservedWrapper); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_USERDATA \
|
||||
if (tmp->HasProperties()) { \
|
||||
nsNodeUtils::TraverseUserData(tmp, cb); \
|
||||
@ -922,10 +913,6 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
|
||||
tmp->UnsetFlags(NODE_HAS_LISTENERMANAGER); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \
|
||||
if (tmp->GetOwnerDoc()) \
|
||||
tmp->GetOwnerDoc()->RemoveReference(tmp);
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_USERDATA \
|
||||
if (tmp->HasProperties()) { \
|
||||
nsNodeUtils::UnlinkUserData(tmp); \
|
||||
|
@ -97,8 +97,8 @@ class nsFrameLoader;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x6304ae8e, 0x2634, 0x45ed, \
|
||||
{ 0x9e, 0x09, 0x83, 0x09, 0x5b, 0x46, 0x72, 0x8b } }
|
||||
{ 0x92b19d1c, 0x8f37, 0x4d4b, \
|
||||
{ 0xa3, 0x42, 0xb5, 0xc6, 0x8b, 0x54, 0xde, 0x6c } }
|
||||
|
||||
// Flag for AddStyleSheet().
|
||||
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
|
||||
@ -678,10 +678,6 @@ public:
|
||||
virtual void ResetToURI(nsIURI *aURI, nsILoadGroup* aLoadGroup,
|
||||
nsIPrincipal* aPrincipal) = 0;
|
||||
|
||||
virtual void AddReference(void *aKey, nsISupports *aReference) = 0;
|
||||
virtual nsISupports *GetReference(void *aKey) = 0;
|
||||
virtual void RemoveReference(void *aKey) = 0;
|
||||
|
||||
/**
|
||||
* Set the container (docshell) for this document.
|
||||
*/
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "nsTObserverArray.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
@ -150,16 +151,17 @@ inline nsINode* NODE_FROM(C& aContent, D& aDocument)
|
||||
|
||||
// IID for the nsINode interface
|
||||
#define NS_INODE_IID \
|
||||
{ 0x2593b0d5, 0x9a06, 0x4d6b, \
|
||||
{ 0x9a, 0x10, 0xb1, 0x39, 0x9f, 0x1b, 0xa0, 0x8e } }
|
||||
|
||||
{ 0x0f7b2557, 0xa09d, 0x468f, \
|
||||
{ 0x93, 0x92, 0xf1, 0xf1, 0xd1, 0xfa, 0x31, 0x78 } }
|
||||
|
||||
/**
|
||||
* An internal interface that abstracts some DOMNode-related parts that both
|
||||
* nsIContent and nsIDocument share. An instance of this interface has a list
|
||||
* of nsIContent children and provides access to them.
|
||||
*/
|
||||
class nsINode : public nsPIDOMEventTarget {
|
||||
class nsINode : public nsPIDOMEventTarget,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
||||
|
||||
@ -850,4 +852,12 @@ extern const nsIID kThisPtrOffsetsSID;
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID)
|
||||
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_PRESERVED_WRAPPER \
|
||||
tmp->TraverseWrapper(cb);
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER \
|
||||
tmp->ReleaseWrapper();
|
||||
|
||||
|
||||
#endif /* nsINode_h___ */
|
||||
|
@ -358,6 +358,7 @@ nsContentList::~nsContentList()
|
||||
|
||||
// QueryInterface implementation for nsContentList
|
||||
NS_INTERFACE_TABLE_HEAD(nsContentList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsContentList)
|
||||
NS_CONTENT_LIST_INTERFACES(nsContentList)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIHTMLCollection)
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
// Magic namespace id that means "match all namespaces". This is
|
||||
// negative so it won't collide with actual namespace constants.
|
||||
@ -182,7 +183,8 @@ protected:
|
||||
class nsContentList : public nsBaseContentList,
|
||||
protected nsContentListKey,
|
||||
public nsIHTMLCollection,
|
||||
public nsStubMutationObserver
|
||||
public nsStubMutationObserver,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
@ -102,6 +102,8 @@
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
|
||||
PRLogModuleInfo* gContentSinkLogModuleInfo;
|
||||
|
||||
@ -722,6 +724,10 @@ nsContentSink::ProcessLink(nsIContent* aElement,
|
||||
PrefetchHref(aHref, aElement, hasPrefetch);
|
||||
}
|
||||
|
||||
if ((!aHref.IsEmpty()) && linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
|
||||
PrefetchDNS(aHref);
|
||||
}
|
||||
|
||||
// is it a stylesheet link?
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("stylesheet")) == -1) {
|
||||
return NS_OK;
|
||||
@ -853,6 +859,23 @@ nsContentSink::PrefetchHref(const nsAString &aHref,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsContentSink::PrefetchDNS(const nsAString &aHref)
|
||||
{
|
||||
nsAutoString hostname;
|
||||
|
||||
if (StringBeginsWith(aHref, NS_LITERAL_STRING("//"))) {
|
||||
hostname = Substring(aHref, 2);
|
||||
}
|
||||
else
|
||||
nsGenericHTMLElement::GetHostnameFromHrefString(aHref, hostname);
|
||||
|
||||
nsRefPtr<nsHTMLDNSPrefetch> prefetch = new nsHTMLDNSPrefetch(hostname, mDocument);
|
||||
if (prefetch) {
|
||||
prefetch->PrefetchLow();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::GetChannelCacheKey(nsIChannel* aChannel, nsACString& aCacheKey)
|
||||
{
|
||||
|
@ -195,6 +195,10 @@ protected:
|
||||
void PrefetchHref(const nsAString &aHref, nsIContent *aSource,
|
||||
PRBool aExplicit);
|
||||
|
||||
// aHref can either be the usual URI format or of the form "//www.hostname.com"
|
||||
// without a scheme.
|
||||
void PrefetchDNS(const nsAString &aHref);
|
||||
|
||||
// Gets the cache key (used to identify items in a cache) of the channel.
|
||||
nsresult GetChannelCacheKey(nsIChannel* aChannel, nsACString& aCacheKey);
|
||||
|
||||
|
@ -160,6 +160,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIOfflineCacheUpdate.h"
|
||||
#include "nsCPrefetchService.h"
|
||||
#include "nsIChromeRegistry.h"
|
||||
|
||||
#ifdef IBMBIDI
|
||||
#include "nsIBidiKeyboard.h"
|
||||
@ -1106,15 +1107,6 @@ nsContentUtils::doReparentContentWrapper(nsIContent *aNode,
|
||||
getter_AddRefs(old_wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aOldDocument) {
|
||||
nsCOMPtr<nsISupports> old_ref = aOldDocument->GetReference(aNode);
|
||||
if (old_ref) {
|
||||
// Transfer the reference from aOldDocument to aNewDocument
|
||||
aOldDocument->RemoveReference(aNode);
|
||||
aNewDocument->AddReference(aNode, old_ref);
|
||||
}
|
||||
}
|
||||
|
||||
// Whether or not aChild is already wrapped we must iterate through
|
||||
// its descendants since there's no guarantee that a descendant isn't
|
||||
// wrapped even if this child is not wrapped. That used to be true
|
||||
@ -2917,6 +2909,53 @@ nsContentUtils::IsChromeDoc(nsIDocument *aDocument)
|
||||
return aDocument->NodePrincipal() == systemPrincipal;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(nsIDocument *aDocument,
|
||||
nsIURI *aURI,
|
||||
nsACString& aScriptURI)
|
||||
{
|
||||
PRBool scriptFileNameModified = PR_FALSE;
|
||||
aURI->GetSpec(aScriptURI);
|
||||
|
||||
if (IsChromeDoc(aDocument)) {
|
||||
nsCOMPtr<nsIChromeRegistry> chromeReg =
|
||||
do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
|
||||
|
||||
if (!chromeReg) {
|
||||
// If we're running w/o a chrome registry we won't modify any
|
||||
// script file names.
|
||||
|
||||
return scriptFileNameModified;
|
||||
}
|
||||
|
||||
PRBool docWrappersEnabled =
|
||||
chromeReg->WrappersEnabled(aDocument->GetDocumentURI());
|
||||
|
||||
PRBool uriWrappersEnabled = chromeReg->WrappersEnabled(aURI);
|
||||
|
||||
nsIURI *docURI = aDocument->GetDocumentURI();
|
||||
|
||||
if (docURI && docWrappersEnabled && !uriWrappersEnabled) {
|
||||
// aURI is a script from a URL that doesn't get wrapper
|
||||
// automation. aDocument is a chrome document that does get
|
||||
// wrapper automation. Prepend the chrome document's URI
|
||||
// followed by the string " -> " to the URI of the script we're
|
||||
// loading here so that script in that URI gets the same wrapper
|
||||
// automation that the chrome document expects.
|
||||
nsCAutoString spec;
|
||||
docURI->GetSpec(spec);
|
||||
spec.AppendASCII(" -> ");
|
||||
spec.Append(aScriptURI);
|
||||
|
||||
aScriptURI = spec;
|
||||
|
||||
scriptFileNameModified = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return scriptFileNameModified;
|
||||
}
|
||||
|
||||
// static
|
||||
PRBool
|
||||
nsContentUtils::IsInChromeDocshell(nsIDocument *aDocument)
|
||||
|
@ -101,6 +101,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMAttribute)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
// QueryInterface implementation for nsDOMAttribute
|
||||
NS_INTERFACE_TABLE_HEAD(nsDOMAttribute)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_NODE_INTERFACE_TABLE7(nsDOMAttribute, nsIDOMAttr, nsIAttribute, nsINode,
|
||||
nsIDOMNode, nsIDOM3Node, nsIDOM3Attr,
|
||||
nsPIDOMEventTarget)
|
||||
|
@ -1567,13 +1567,12 @@ nsDocument::~nsDocument()
|
||||
mBoxObjectTable->EnumerateRead(ClearAllBoxObjects, nsnull);
|
||||
delete mBoxObjectTable;
|
||||
}
|
||||
|
||||
delete mContentWrapperHash;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocument)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsDocument)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsDocument)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsINode)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument)
|
||||
@ -1753,9 +1752,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mCatalogSheets)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mVisitednessChangedURIs)
|
||||
|
||||
// Traverse any associated preserved wrapper.
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[preserved wrapper]");
|
||||
cb.NoteXPCOMChild(tmp->GetReference(tmp));
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_PRESERVED_WRAPPER
|
||||
|
||||
if (tmp->mSubDocuments && tmp->mSubDocuments->ops) {
|
||||
PL_DHashTableEnumerate(tmp->mSubDocuments, SubDocTraverser, &cb);
|
||||
@ -1786,12 +1783,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_USERDATA
|
||||
|
||||
// Drop the content hash.
|
||||
delete tmp->mContentWrapperHash;
|
||||
tmp->mContentWrapperHash = nsnull;
|
||||
|
||||
tmp->mParentDocument = nsnull;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
|
||||
// nsDocument has a pretty complex destructor, so we're going to
|
||||
// assume that *most* cycles you actually want to break somewhere
|
||||
// else, and not unlink an awful lot here.
|
||||
@ -6239,41 +6234,6 @@ nsDocument::FlushPendingNotifications(mozFlushType aType)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::AddReference(void *aKey, nsISupports *aReference)
|
||||
{
|
||||
if (mScriptGlobalObject) {
|
||||
if (!mContentWrapperHash) {
|
||||
mContentWrapperHash = new nsInterfaceHashtable<nsVoidPtrHashKey, nsISupports>;
|
||||
if (mContentWrapperHash) {
|
||||
mContentWrapperHash->Init(10);
|
||||
}
|
||||
}
|
||||
|
||||
if (mContentWrapperHash)
|
||||
mContentWrapperHash->Put(aKey, aReference);
|
||||
}
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
nsDocument::GetReference(void *aKey)
|
||||
{
|
||||
// NB: This method is part of content cycle collection,
|
||||
// and must *not* Addref its return value.
|
||||
|
||||
if (mContentWrapperHash)
|
||||
return mContentWrapperHash->GetWeak(aKey);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RemoveReference(void *aKey)
|
||||
{
|
||||
if (mContentWrapperHash) {
|
||||
mContentWrapperHash->Remove(aKey);
|
||||
}
|
||||
}
|
||||
|
||||
nsIScriptEventManager*
|
||||
nsDocument::GetScriptEventManager()
|
||||
{
|
||||
@ -6572,6 +6532,7 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
||||
"content-language",
|
||||
"content-disposition",
|
||||
"refresh",
|
||||
"x-dns-prefetch-control",
|
||||
// add more http headers if you need
|
||||
// XXXbz don't add content-location support without reading bug
|
||||
// 238654 and its dependencies/dups first.
|
||||
@ -6887,10 +6848,7 @@ nsDocument::Destroy()
|
||||
|
||||
// XXX We really should let cycle collection do this, but that currently still
|
||||
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
|
||||
// When we start relying on cycle collection again we should remove the
|
||||
// check for mScriptGlobalObject in AddReference.
|
||||
delete mContentWrapperHash;
|
||||
mContentWrapperHash = nsnull;
|
||||
ReleaseWrapper();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -750,9 +750,6 @@ public:
|
||||
nsIStyleRule* aStyleRule);
|
||||
|
||||
virtual void FlushPendingNotifications(mozFlushType aType);
|
||||
virtual void AddReference(void *aKey, nsISupports *aReference);
|
||||
virtual nsISupports *GetReference(void *aKey);
|
||||
virtual void RemoveReference(void *aKey);
|
||||
virtual nsIScriptEventManager* GetScriptEventManager();
|
||||
virtual void SetXMLDeclaration(const PRUnichar *aVersion,
|
||||
const PRUnichar *aEncoding,
|
||||
@ -1164,7 +1161,6 @@ protected:
|
||||
PRUint8 mIdMissCount;
|
||||
|
||||
nsInterfaceHashtable<nsVoidPtrHashKey, nsPIBoxObject> *mBoxObjectTable;
|
||||
nsInterfaceHashtable<nsVoidPtrHashKey, nsISupports> *mContentWrapperHash;
|
||||
|
||||
// The channel that got passed to StartDocumentLoad(), if any
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
@ -105,7 +105,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGenericDOMDataNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericDOMDataNode)
|
||||
NS_INTERFACE_MAP_BEGIN(nsGenericDOMDataNode)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericDOMDataNode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
|
||||
@ -858,6 +860,9 @@ nsGenericDOMDataNode::SaveSubtreeState()
|
||||
void
|
||||
nsGenericDOMDataNode::DestroyContent()
|
||||
{
|
||||
// XXX We really should let cycle collection do this, but that currently still
|
||||
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
|
||||
ReleaseWrapper();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -462,6 +462,7 @@ NS_IMPL_ADDREF(nsChildContentList)
|
||||
NS_IMPL_RELEASE(nsChildContentList)
|
||||
|
||||
NS_INTERFACE_TABLE_HEAD(nsChildContentList)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsChildContentList)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsChildContentList, nsINodeList)
|
||||
NS_INTERFACE_TABLE_ENTRY(nsChildContentList, nsIDOMNodeList)
|
||||
@ -3473,6 +3474,10 @@ nsGenericElement::DestroyContent()
|
||||
document->ClearBoxObjectFor(this);
|
||||
}
|
||||
|
||||
// XXX We really should let cycle collection do this, but that currently still
|
||||
// leaks (see https://bugzilla.mozilla.org/show_bug.cgi?id=406684).
|
||||
ReleaseWrapper();
|
||||
|
||||
PRUint32 i, count = mAttrsAndChildren.ChildCount();
|
||||
for (i = 0; i < count; ++i) {
|
||||
// The child can remove itself from the parent in BindToTree.
|
||||
@ -4066,7 +4071,9 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGenericElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericElement)
|
||||
NS_INTERFACE_MAP_BEGIN(nsGenericElement)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsGenericElement)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIContent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINode)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
|
||||
|
@ -89,7 +89,8 @@ typedef unsigned long PtrBits;
|
||||
* and Item to its existing child list.
|
||||
* @see nsIDOMNodeList
|
||||
*/
|
||||
class nsChildContentList : public nsINodeList
|
||||
class nsChildContentList : public nsINodeList,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
nsChildContentList(nsINode* aNode)
|
||||
@ -110,6 +111,27 @@ public:
|
||||
mNode = nsnull;
|
||||
}
|
||||
|
||||
nsISupports* GetParentObject()
|
||||
{
|
||||
return mNode;
|
||||
}
|
||||
|
||||
static nsChildContentList* FromSupports(nsISupports* aSupports)
|
||||
{
|
||||
nsINodeList* list = static_cast<nsINodeList*>(aSupports);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINodeList> list_qi = do_QueryInterface(aSupports);
|
||||
|
||||
// If this assertion fires the QI implementation for the object in
|
||||
// question doesn't use the nsINodeList pointer as the nsISupports
|
||||
// pointer. That must be fixed, or we'll crash...
|
||||
NS_ASSERTION(list_qi == list, "Uh, fix QI!");
|
||||
}
|
||||
#endif
|
||||
return static_cast<nsChildContentList*>(list);
|
||||
}
|
||||
|
||||
private:
|
||||
// The node whose children make up the list (weak reference)
|
||||
nsINode* mNode;
|
||||
|
@ -987,6 +987,7 @@ GK_ATOM(headerWindowTarget, "window-target")
|
||||
GK_ATOM(withParam, "with-param")
|
||||
GK_ATOM(wizard, "wizard")
|
||||
GK_ATOM(wrap, "wrap")
|
||||
GK_ATOM(headerDNSPrefetchControl,"x-dns-prefetch-control")
|
||||
GK_ATOM(xml, "xml")
|
||||
GK_ATOM(xmlns, "xmlns")
|
||||
GK_ATOM(xmp, "xmp")
|
||||
|
@ -564,26 +564,15 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, PRBool aClone, PRBool aDeep,
|
||||
}
|
||||
}
|
||||
else if (nodeInfoManager) {
|
||||
nsCOMPtr<nsISupports> oldRef;
|
||||
nsIDocument* oldDoc = aNode->GetOwnerDoc();
|
||||
if (oldDoc) {
|
||||
if (aNode->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
oldDoc->ClearBoxObjectFor(static_cast<nsIContent*>(aNode));
|
||||
}
|
||||
oldRef = oldDoc->GetReference(aNode);
|
||||
if (oldRef) {
|
||||
oldDoc->RemoveReference(aNode);
|
||||
}
|
||||
if (oldDoc && aNode->IsNodeOfType(nsINode::eELEMENT)) {
|
||||
oldDoc->ClearBoxObjectFor(static_cast<nsIContent*>(aNode));
|
||||
}
|
||||
|
||||
aNode->mNodeInfo.swap(newNodeInfo);
|
||||
|
||||
nsIDocument* newDoc = aNode->GetOwnerDoc();
|
||||
if (newDoc) {
|
||||
if (oldRef) {
|
||||
newDoc->AddReference(aNode, oldRef);
|
||||
}
|
||||
|
||||
nsPIDOMWindow* window = newDoc->GetInnerWindow();
|
||||
if (window) {
|
||||
nsCOMPtr<nsIEventListenerManager> elm;
|
||||
|
@ -623,13 +623,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCAutoString url;
|
||||
|
||||
nsIURI* uri = aRequest->mFinalURI ? aRequest->mFinalURI : aRequest->mURI;
|
||||
rv = uri->GetSpec(url);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool oldProcessingScriptTag = context->GetProcessingScriptTag();
|
||||
context->SetProcessingScriptTag(PR_TRUE);
|
||||
@ -638,6 +632,9 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
||||
nsCOMPtr<nsIScriptElement> oldCurrent = mCurrentScript;
|
||||
mCurrentScript = aRequest->mElement;
|
||||
|
||||
nsCAutoString url;
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, uri, url);
|
||||
|
||||
PRBool isUndefined;
|
||||
rv = context->EvaluateString(aScript,
|
||||
globalObject->GetScriptGlobal(stid),
|
||||
|
@ -530,13 +530,7 @@ GetDocumentFromScriptContext(nsIScriptContext *aScriptContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsXHREventTarget)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXHREventTarget)
|
||||
if (tmp->mOwner) {
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_QueryInterface(tmp->mOwner->GetExtantDocument());
|
||||
if (doc) {
|
||||
cb.NoteXPCOMChild(doc->GetReference(tmp));
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnLoadListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener)
|
||||
@ -548,13 +542,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXHREventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXHREventTarget)
|
||||
if (tmp->mOwner) {
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_QueryInterface(tmp->mOwner->GetExtantDocument());
|
||||
if (doc) {
|
||||
doc->RemoveReference(tmp);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnLoadListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener)
|
||||
@ -565,7 +553,9 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXHREventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXHREventTarget)
|
||||
NS_INTERFACE_MAP_BEGIN(nsXHREventTarget)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsXHREventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXMLHttpRequestEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXMLHttpRequestEventTarget)
|
||||
NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
|
||||
@ -1570,6 +1560,17 @@ nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
|
||||
nsresult rv = NS_OK;
|
||||
_retval.Truncate();
|
||||
|
||||
// See bug #380418. Hide "Set-Cookie" headers from non-chrome scripts.
|
||||
PRBool chrome = PR_FALSE; // default to false in case IsCapabilityEnabled fails
|
||||
IsCapabilityEnabled("UniversalXPConnect", &chrome);
|
||||
if (!chrome &&
|
||||
(header.LowerCaseEqualsASCII("set-cookie") ||
|
||||
header.LowerCaseEqualsASCII("set-cookie2"))) {
|
||||
NS_WARNING("blocked access to response header");
|
||||
_retval.SetIsVoid(PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check for dangerous headers
|
||||
if (mState & XML_HTTP_REQUEST_USE_XSITE_AC) {
|
||||
|
||||
@ -3353,10 +3354,19 @@ NS_IMPL_ISUPPORTS1(nsXMLHttpRequest::nsHeaderVisitor, nsIHttpHeaderVisitor)
|
||||
NS_IMETHODIMP nsXMLHttpRequest::
|
||||
nsHeaderVisitor::VisitHeader(const nsACString &header, const nsACString &value)
|
||||
{
|
||||
mHeaders.Append(header);
|
||||
mHeaders.Append(": ");
|
||||
mHeaders.Append(value);
|
||||
mHeaders.Append('\n');
|
||||
// See bug #380418. Hide "Set-Cookie" headers from non-chrome scripts.
|
||||
PRBool chrome = PR_FALSE; // default to false in case IsCapabilityEnabled fails
|
||||
IsCapabilityEnabled("UniversalXPConnect", &chrome);
|
||||
if (!chrome &&
|
||||
(header.LowerCaseEqualsASCII("set-cookie") ||
|
||||
header.LowerCaseEqualsASCII("set-cookie2"))) {
|
||||
NS_WARNING("blocked access to response header");
|
||||
} else {
|
||||
mHeaders.Append(header);
|
||||
mHeaders.Append(": ");
|
||||
mHeaders.Append(value);
|
||||
mHeaders.Append('\n');
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,7 @@
|
||||
#include "nsITimer.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsDOMProgressEvent.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
class nsILoadGroup;
|
||||
|
||||
@ -159,7 +160,8 @@ protected:
|
||||
|
||||
class nsXHREventTarget : public nsIXMLHttpRequestEventTarget,
|
||||
public nsPIDOMEventTarget,
|
||||
public nsIDOMNSEventTarget
|
||||
public nsIDOMNSEventTarget,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
nsXHREventTarget() : mLang(nsIProgrammingLanguage::JAVASCRIPT) {}
|
||||
@ -207,6 +209,36 @@ public:
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void GetParentObject(nsIScriptGlobalObject **aParentObject)
|
||||
{
|
||||
if (mOwner) {
|
||||
CallQueryInterface(mOwner, aParentObject);
|
||||
}
|
||||
else {
|
||||
*aParentObject = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
static nsXHREventTarget* FromSupports(nsISupports* aSupports)
|
||||
{
|
||||
nsIXMLHttpRequestEventTarget* target =
|
||||
static_cast<nsIXMLHttpRequestEventTarget*>(aSupports);
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsIXMLHttpRequestEventTarget> target_qi =
|
||||
do_QueryInterface(aSupports);
|
||||
|
||||
// If this assertion fires the QI implementation for the object in
|
||||
// question doesn't use the nsIXMLHttpRequestEventTarget pointer as the
|
||||
// nsISupports pointer. That must be fixed, or we'll crash...
|
||||
NS_ASSERTION(target_qi == target, "Uh, fix QI!");
|
||||
}
|
||||
#endif
|
||||
|
||||
return static_cast<nsXHREventTarget*>(target);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnLoadListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
|
@ -258,6 +258,8 @@ _TEST_FILES = test_bug5141.html \
|
||||
bug461735-redirect2.sjs \
|
||||
bug461735-post-redirect.js \
|
||||
test_bug461735.html \
|
||||
test_bug380418.html \
|
||||
test_bug380418.html^headers^ \
|
||||
$(NULL)
|
||||
|
||||
# Disabled for now. Mochitest isn't reliable enough for these.
|
||||
|
51
content/base/test/test_bug380418.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!-- https://bugzilla.mozilla.org/show_bug.cgi?id=380418 -->
|
||||
<head>
|
||||
<title>Test for Bug 380418</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=380418">Mozilla Bug 380418</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("GET", window.location.href, false);
|
||||
request.send(null);
|
||||
|
||||
// Try reading headers in privileged context
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserRead");
|
||||
is(request.getResponseHeader("Set-Cookie"), "test", "Reading Set-Cookie response header in privileged context");
|
||||
is(request.getResponseHeader("Set-Cookie2"), "test2", "Reading Set-Cookie2 response header in privileged context");
|
||||
is(request.getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in privileged context");
|
||||
|
||||
ok(/\bSet-Cookie:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie in all response headers in privileged context");
|
||||
ok(/\bSet-Cookie2:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie2 in all response headers in privileged context");
|
||||
ok(/\bX-Dummy:/i.test(request.getAllResponseHeaders()), "Looking for X-Dummy in all response headers in privileged context");
|
||||
|
||||
// Try reading headers in unprivileged context
|
||||
setTimeout(function() {
|
||||
is(request.getResponseHeader("Set-Cookie"), null, "Reading Set-Cookie response header in unprivileged context");
|
||||
is(request.getResponseHeader("Set-Cookie2"), null, "Reading Set-Cookie2 response header in unprivileged context");
|
||||
is(request.getResponseHeader("X-Dummy"), "test", "Reading X-Dummy response header in unprivileged context");
|
||||
|
||||
ok(!/\bSet-Cookie:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie in all response headers in unprivileged context");
|
||||
ok(!/\bSet-Cookie2:/i.test(request.getAllResponseHeaders()), "Looking for Set-Cookie2 in all response headers in unprivileged context");
|
||||
ok(/\bX-Dummy:/i.test(request.getAllResponseHeaders()), "Looking for X-Dummy in all response headers in unprivileged context");
|
||||
|
||||
SimpleTest.finish();
|
||||
}, 0);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
4
content/base/test/test_bug380418.html^headers^
Normal file
@ -0,0 +1,4 @@
|
||||
Set-Cookie: test
|
||||
Set-Cookie2: test2
|
||||
X-Dummy: test
|
||||
Cache-Control: max-age=0
|
@ -83,6 +83,7 @@ EXPORTS = \
|
||||
|
||||
CPPSRCS = \
|
||||
nsClientRect.cpp \
|
||||
nsHTMLDNSPrefetch.cpp \
|
||||
nsGenericHTMLElement.cpp \
|
||||
nsFormSubmission.cpp \
|
||||
nsImageMapUtils.cpp \
|
||||
|
@ -64,6 +64,8 @@
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
|
||||
nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
|
||||
|
||||
class nsHTMLAnchorElement : public nsGenericHTMLElement,
|
||||
@ -135,11 +137,26 @@ public:
|
||||
protected:
|
||||
// The cached visited state
|
||||
nsLinkState mLinkState;
|
||||
|
||||
void PrefetchDNS();
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Anchor)
|
||||
|
||||
void
|
||||
nsHTMLAnchorElement::PrefetchDNS()
|
||||
{
|
||||
nsCOMPtr<nsIURI> hrefURI;
|
||||
GetHrefURI(getter_AddRefs(hrefURI));
|
||||
|
||||
if (hrefURI) {
|
||||
nsRefPtr<nsHTMLDNSPrefetch> prefetch =
|
||||
new nsHTMLDNSPrefetch(hrefURI, GetOwnerDoc());
|
||||
if (prefetch)
|
||||
prefetch->PrefetchLow();
|
||||
}
|
||||
}
|
||||
|
||||
nsHTMLAnchorElement::nsHTMLAnchorElement(nsINodeInfo *aNodeInfo)
|
||||
: nsGenericHTMLElement(aNodeInfo),
|
||||
@ -212,6 +229,7 @@ nsHTMLAnchorElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
||||
RegUnRegAccessKey(PR_TRUE);
|
||||
}
|
||||
|
||||
PrefetchDNS();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -691,24 +691,30 @@ nsHTMLSelectElement::GetLength(PRUint32* aLength)
|
||||
return mOptions->GetLength(aLength);
|
||||
}
|
||||
|
||||
#define MAX_DYNAMIC_SELECT_LENGTH 10000
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLSelectElement::SetLength(PRUint32 aLength)
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
|
||||
PRUint32 curlen;
|
||||
PRInt32 i;
|
||||
PRUint32 i;
|
||||
|
||||
rv = GetLength(&curlen);
|
||||
if (NS_FAILED(rv)) {
|
||||
curlen = 0;
|
||||
}
|
||||
|
||||
if (curlen && (curlen > aLength)) { // Remove extra options
|
||||
for (i = (curlen - 1); (i >= (PRInt32)aLength) && NS_SUCCEEDED(rv); i--) {
|
||||
rv = Remove(i);
|
||||
if (curlen > aLength) { // Remove extra options
|
||||
for (i = curlen; i > aLength && NS_SUCCEEDED(rv); --i) {
|
||||
rv = Remove(i-1);
|
||||
}
|
||||
} else if (aLength) {
|
||||
} else if (aLength > curlen) {
|
||||
if (aLength > MAX_DYNAMIC_SELECT_LENGTH) {
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
||||
// This violates the W3C DOM but we do this for backwards compatibility
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
|
||||
@ -729,7 +735,7 @@ nsHTMLSelectElement::SetLength(PRUint32 aLength)
|
||||
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(element));
|
||||
|
||||
for (i = curlen; i < (PRInt32)aLength; i++) {
|
||||
for (i = curlen; i < aLength; i++) {
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
|
||||
rv = AppendChild(node, getter_AddRefs(tmpNode));
|
||||
|
@ -2950,6 +2950,13 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
||||
PrefetchHref(hrefVal, element, hasPrefetch);
|
||||
}
|
||||
}
|
||||
if (linkTypes.IndexOf(NS_LITERAL_STRING("dns-prefetch")) != -1) {
|
||||
nsAutoString hrefVal;
|
||||
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchDNS(hrefVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,13 +149,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Root ourselves in the document.
|
||||
nsIDocument* doc = aBoundElement->GetOwnerDoc();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIXPConnectWrappedNative> nativeWrapper(do_QueryInterface(wrapper));
|
||||
if (nativeWrapper)
|
||||
doc->AddReference(aBoundElement, nativeWrapper);
|
||||
}
|
||||
aBoundElement->PreserveWrapper();
|
||||
|
||||
wrapper.swap(*aScriptObjectHolder);
|
||||
|
||||
|
@ -548,6 +548,14 @@ nsXBLService::LoadBindings(nsIContent* aContent, nsIURI* aURL,
|
||||
if (!document)
|
||||
return NS_OK;
|
||||
|
||||
nsCAutoString urlspec;
|
||||
if (nsContentUtils::GetWrapperSafeScriptFilename(document, aURL, urlspec)) {
|
||||
// Block an attempt to load a binding that has special wrapper
|
||||
// automation needs.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsBindingManager *bindingManager = document->BindingManager();
|
||||
|
||||
nsXBLBinding *binding = bindingManager->GetBinding(aContent);
|
||||
@ -684,28 +692,6 @@ nsXBLService::ResolveTag(nsIContent* aContent, PRInt32* aNameSpaceID,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIXBLDocumentInfo*
|
||||
nsXBLService::GetXBLDocumentInfo(nsIURI* aURI, nsIContent* aBoundElement)
|
||||
{
|
||||
#ifdef MOZ_XUL
|
||||
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
|
||||
if (cache && cache->IsEnabled()) {
|
||||
// The first line of defense is the chrome cache.
|
||||
// This cache crosses the entire product, so any XBL bindings that are
|
||||
// part of chrome will be reused across all XUL documents.
|
||||
return cache->GetXBLDocumentInfo(aURI);
|
||||
}
|
||||
#endif
|
||||
|
||||
// The second line of defense is the binding manager's document table.
|
||||
nsIDocument* boundDocument = aBoundElement->GetOwnerDoc();
|
||||
if (boundDocument) {
|
||||
return boundDocument->BindingManager()->GetXBLDocumentInfo(aURI);
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// AttachGlobalKeyHandler
|
||||
|
@ -108,9 +108,6 @@ protected:
|
||||
nsIURI* aDocumentURI, nsIURI* aBindingURI,
|
||||
PRBool aForceSyncLoad, nsIDocument** aResult);
|
||||
|
||||
nsIXBLDocumentInfo* GetXBLDocumentInfo(nsIURI* aURI,
|
||||
nsIContent* aBoundElement);
|
||||
|
||||
/**
|
||||
* This method calls the one below with an empty |aDontExtendURIs| array.
|
||||
*/
|
||||
|
@ -657,6 +657,18 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
|
||||
mScriptLoader->AddExecuteBlocker();
|
||||
}
|
||||
}
|
||||
// Look for <link rel="dns-prefetch" href="hostname">
|
||||
if (nodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
|
||||
nsAutoString relVal;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
|
||||
if (relVal.EqualsLiteral("dns-prefetch")) {
|
||||
nsAutoString hrefVal;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
|
||||
if (!hrefVal.IsEmpty()) {
|
||||
PrefetchDNS(hrefVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -3129,7 +3129,7 @@ nsXULPrototypeScript::Compile(const PRUnichar* aText,
|
||||
}
|
||||
|
||||
nsCAutoString urlspec;
|
||||
aURI->GetSpec(urlspec);
|
||||
nsContentUtils::GetWrapperSafeScriptFilename(aDocument, aURI, urlspec);
|
||||
|
||||
// Ok, compile it to create a prototype script object!
|
||||
|
||||
|
@ -71,6 +71,7 @@ EXPORTS=nsIScriptContext.h \
|
||||
nsDOMString.h \
|
||||
nsDOMJSUtils.h \
|
||||
nsDOMScriptObjectHolder.h \
|
||||
nsWrapperCache.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -41,7 +41,7 @@ interface nsIDOMGeoPositionOptions;
|
||||
interface nsIDOMGeoPositionCallback;
|
||||
interface nsIDOMGeoPositionErrorCallback;
|
||||
|
||||
[scriptable, function, uuid(CE495440-C8B9-42DE-B67C-60E6928C0F40)]
|
||||
[scriptable, function, uuid(0EC70F3F-7E15-45E0-84E9-CDE078CB150A)]
|
||||
interface nsIDOMGeoGeolocation : nsISupports
|
||||
{
|
||||
readonly attribute nsIDOMGeoPosition lastPosition;
|
||||
@ -50,9 +50,9 @@ interface nsIDOMGeoGeolocation : nsISupports
|
||||
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
|
||||
[optional] in nsIDOMGeoPositionOptions options);
|
||||
|
||||
unsigned short watchPosition(in nsIDOMGeoPositionCallback successCallback,
|
||||
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
|
||||
[optional] in nsIDOMGeoPositionOptions options);
|
||||
long watchPosition(in nsIDOMGeoPositionCallback successCallback,
|
||||
[optional] in nsIDOMGeoPositionErrorCallback errorCallback,
|
||||
[optional] in nsIDOMGeoPositionOptions options);
|
||||
|
||||
void clearWatch(in unsigned short watchId);
|
||||
void clearWatch(in long watchId);
|
||||
};
|
||||
|
@ -37,9 +37,14 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(39928BF8-4466-4A64-BF5F-97114A5CD171)]
|
||||
[scriptable, uuid(1B493214-4E58-4A40-AA4C-1AB70C6DDBEC)]
|
||||
interface nsIDOMGeoPositionError : nsISupports
|
||||
{
|
||||
const unsigned short UNKNOWN_ERROR = 0;
|
||||
const unsigned short PERMISSION_DENIED = 1;
|
||||
const unsigned short POSITION_UNAVAILABLE = 2;
|
||||
const unsigned short TIMEOUT = 3;
|
||||
|
||||
readonly attribute short code;
|
||||
readonly attribute DOMString message;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ interface nsIGeolocationPrompt;
|
||||
* the nsIGeolocationPrompt so that the application can approve
|
||||
* or deny the request.
|
||||
*/
|
||||
[scriptable, function, uuid(D681C322-C075-4C6E-9765-C22711A4A60E)]
|
||||
[scriptable, function, uuid(F2AEFDE1-8E38-48B3-BBB8-BD6C4AE1AC8A)]
|
||||
interface nsIGeolocationRequest : nsISupports {
|
||||
|
||||
readonly attribute nsIURI requestingURI;
|
||||
@ -56,7 +56,6 @@ interface nsIGeolocationRequest : nsISupports {
|
||||
|
||||
void cancel();
|
||||
void allow();
|
||||
void allowButFuzz();
|
||||
};
|
||||
|
||||
/**
|
||||
|
146
dom/public/nsWrapperCache.h
Normal file
@ -0,0 +1,146 @@
|
||||
/* ***** 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 Gecko DOM code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken <peterv@propagandism.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsWrapperCache_h___
|
||||
#define nsWrapperCache_h___
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
typedef unsigned long PtrBits;
|
||||
|
||||
#define NS_WRAPPERCACHE_IID \
|
||||
{ 0x3a51ca81, 0xddab, 0x422c, \
|
||||
{ 0x95, 0x3a, 0x13, 0x06, 0x28, 0x0e, 0xee, 0x14 } }
|
||||
|
||||
/**
|
||||
* Class to store the XPCWrappedNative for an object. This can only be used
|
||||
* with objects that only have one XPCWrappedNative at a time (usually ensured
|
||||
* by setting an explicit parent in the PreCreate hook for the class). This
|
||||
* object can be gotten by calling QueryInterface, note that this breaks XPCOM
|
||||
* rules a bit (this object doesn't derive from nsISupports).
|
||||
*/
|
||||
class nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_WRAPPERCACHE_IID)
|
||||
|
||||
nsWrapperCache() : mWrapperPtrBits(0)
|
||||
{
|
||||
}
|
||||
~nsWrapperCache()
|
||||
{
|
||||
if (PreservingWrapper()) {
|
||||
GetWrapper()->Release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns an nsIXPConnectWrappedNative, but we want to avoid
|
||||
* including nsIXPConnect, because we don't want to make everyone require
|
||||
* JS and XPConnect.
|
||||
*/
|
||||
nsISupports* GetWrapper()
|
||||
{
|
||||
return reinterpret_cast<nsISupports*>(mWrapperPtrBits & ~kWrapperBitMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method takes an nsIXPConnectWrappedNative, but we want to avoid
|
||||
* including nsIXPConnect, because we don't want to make everyone require
|
||||
* JS and XPConnect.
|
||||
*/
|
||||
void SetWrapper(nsISupports* aWrapper)
|
||||
{
|
||||
NS_ASSERTION(!mWrapperPtrBits, "Already have a wrapper!");
|
||||
mWrapperPtrBits = reinterpret_cast<PtrBits>(aWrapper);
|
||||
}
|
||||
|
||||
void ClearWrapper()
|
||||
{
|
||||
if (PreservingWrapper()) {
|
||||
GetWrapper()->Release();
|
||||
}
|
||||
mWrapperPtrBits = 0;
|
||||
}
|
||||
|
||||
void PreserveWrapper()
|
||||
{
|
||||
NS_ASSERTION(mWrapperPtrBits, "No wrapper to preserve?");
|
||||
if (!PreservingWrapper()) {
|
||||
NS_ADDREF(reinterpret_cast<nsISupports*>(mWrapperPtrBits));
|
||||
mWrapperPtrBits |= WRAPPER_BIT_PRESERVED;
|
||||
}
|
||||
}
|
||||
|
||||
void ReleaseWrapper()
|
||||
{
|
||||
if (PreservingWrapper()) {
|
||||
nsISupports* wrapper = GetWrapper();
|
||||
mWrapperPtrBits = reinterpret_cast<PtrBits>(wrapper);
|
||||
NS_RELEASE(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
void TraverseWrapper(nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
if (PreservingWrapper()) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mWrapper");
|
||||
cb.NoteXPCOMChild(GetWrapper());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
PRBool PreservingWrapper()
|
||||
{
|
||||
return mWrapperPtrBits & WRAPPER_BIT_PRESERVED;
|
||||
}
|
||||
|
||||
enum { WRAPPER_BIT_PRESERVED = 1 << 0 };
|
||||
enum { kWrapperBitMask = 0x1 };
|
||||
|
||||
PtrBits mWrapperPtrBits;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID)
|
||||
|
||||
#define NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY \
|
||||
if ( aIID.Equals(NS_GET_IID(nsWrapperCache)) ) { \
|
||||
*aInstancePtr = static_cast<nsWrapperCache*>(this); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
#endif /* nsWrapperCache_h___ */
|
@ -171,6 +171,7 @@
|
||||
|
||||
// ContentList includes
|
||||
#include "nsContentList.h"
|
||||
#include "nsGenericElement.h"
|
||||
|
||||
// Event related includes
|
||||
#include "nsIEventListenerManager.h"
|
||||
@ -212,7 +213,7 @@
|
||||
#include "nsIDOMLSProgressEvent.h"
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsIDOMSerializer.h"
|
||||
#include "nsIXMLHttpRequest.h"
|
||||
#include "nsXMLHttpRequest.h"
|
||||
|
||||
// includes needed for the prototype chain interfaces
|
||||
#include "nsIDOMNavigator.h"
|
||||
@ -492,7 +493,8 @@ static const char kDOMStringBundleURL[] =
|
||||
((DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_GETPROPERTY | \
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY | \
|
||||
nsIXPCScriptable::WANT_SETPROPERTY) & \
|
||||
nsIXPCScriptable::WANT_SETPROPERTY | \
|
||||
nsIXPCScriptable::WANT_FINALIZE) & \
|
||||
~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
|
||||
|
||||
// We need to let JavaScript QI elements to interfaces that are not in
|
||||
@ -516,15 +518,22 @@ static const char kDOMStringBundleURL[] =
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY | \
|
||||
nsIXPCScriptable::WANT_DELPROPERTY | \
|
||||
nsIXPCScriptable::WANT_GETPROPERTY | \
|
||||
nsIXPCScriptable::WANT_ENUMERATE | \
|
||||
nsIXPCScriptable::WANT_POSTCREATE | \
|
||||
nsIXPCScriptable::WANT_FINALIZE)
|
||||
nsIXPCScriptable::WANT_ENUMERATE)
|
||||
|
||||
#define ARRAY_SCRIPTABLE_FLAGS \
|
||||
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_GETPROPERTY | \
|
||||
nsIXPCScriptable::WANT_ENUMERATE)
|
||||
|
||||
#define NODELIST_SCRIPTABLE_FLAGS \
|
||||
(ARRAY_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_FINALIZE)
|
||||
|
||||
#define EVENTTARGET_SCRIPTABLE_FLAGS \
|
||||
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY | \
|
||||
nsIXPCScriptable::WANT_FINALIZE)
|
||||
|
||||
#define DOMCLASSINFO_STANDARD_FLAGS \
|
||||
(nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::DOM_OBJECT)
|
||||
|
||||
@ -635,7 +644,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(ProcessingInstruction, nsNodeSH,
|
||||
NODE_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(Notation, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(NodeList, nsNodeListSH, ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(NodeList, nsNodeListSH, NODELIST_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(NamedNodeMap, nsNamedNodeMapSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
|
||||
@ -886,9 +895,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA_WITH_NAME(ContentList, HTMLCollection,
|
||||
nsContentListSH,
|
||||
ARRAY_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE)
|
||||
nsContentListSH, NODELIST_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(XMLStylesheetProcessingInstruction, nsNodeSH,
|
||||
NODE_SCRIPTABLE_FLAGS)
|
||||
@ -1209,8 +1216,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(XMLHttpProgressEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(XMLHttpRequest, nsEventTargetSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY)
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
@ -1281,8 +1287,7 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(XMLHttpRequestUpload, nsEventTargetSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY)
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
|
||||
// DOM Traversal NodeIterator class
|
||||
NS_DEFINE_CLASSINFO_DATA(NodeIterator, nsDOMGenericSH,
|
||||
@ -4208,28 +4213,14 @@ nsDOMClassInfo::GetClassInfoInstance(nsDOMClassInfoData* aData)
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
void
|
||||
nsDOMClassInfo::PreserveNodeWrapper(nsIXPConnectWrappedNative *aWrapper)
|
||||
{
|
||||
nsISupports *native = aWrapper->Native();
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(native));
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (node) {
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
node->GetOwnerDocument(getter_AddRefs(domdoc));
|
||||
doc = do_QueryInterface(domdoc);
|
||||
nsWrapperCache* cache = nsnull;
|
||||
CallQueryInterface(aWrapper->Native(), &cache);
|
||||
if (cache) {
|
||||
cache->PreserveWrapper();
|
||||
}
|
||||
|
||||
if (!doc) {
|
||||
doc = do_QueryInterface(native);
|
||||
}
|
||||
|
||||
if (doc) {
|
||||
nsCOMPtr<nsINode> n(do_QueryInterface(node));
|
||||
doc->AddReference(n, aWrapper);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -6972,6 +6963,16 @@ nsNodeSH::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsINode* node = static_cast<nsINode*>(wrapper->Native());
|
||||
node->SetWrapper(wrapper);
|
||||
|
||||
return nsEventReceiverSH::PostCreate(wrapper, cx, obj);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval)
|
||||
@ -6990,6 +6991,13 @@ nsNodeSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
return DefineVoidProp(cx, obj, id, objp);
|
||||
}
|
||||
|
||||
if (id == sOnload_id || id == sOnerror_id) {
|
||||
// Make sure that this node can't go away while waiting for a
|
||||
// network load that could fire an event handler.
|
||||
nsINode* node = static_cast<nsINode*>(wrapper->Native());
|
||||
node->PreserveWrapper();
|
||||
}
|
||||
|
||||
return nsEventReceiverSH::NewResolve(wrapper, cx, obj, id, flags, objp,
|
||||
_retval);
|
||||
}
|
||||
@ -7058,6 +7066,16 @@ nsNodeSH::GetFlags(PRUint32 *aFlags)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsINode* node = static_cast<nsINode*>(wrapper->Native());
|
||||
node->ClearWrapper();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// EventReceiver helper
|
||||
|
||||
// static
|
||||
@ -7308,12 +7326,6 @@ nsEventReceiverSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
PRUint32 flags, JSObject **objp, PRBool *_retval)
|
||||
{
|
||||
if (id == sOnload_id || id == sOnerror_id) {
|
||||
// Make sure that this node can't go away while waiting for a
|
||||
// network load that could fire an event handler.
|
||||
nsDOMClassInfo::PreserveNodeWrapper(wrapper);
|
||||
}
|
||||
|
||||
if (!JSVAL_IS_STRING(id)) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -7398,6 +7410,30 @@ nsEventReceiverSH::AddProperty(nsIXPConnectWrappedNative *wrapper,
|
||||
|
||||
// EventTarget helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventTargetSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
nsXHREventTarget *target = nsXHREventTarget::FromSupports(nativeObj);
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> native_parent;
|
||||
target->GetParentObject(getter_AddRefs(native_parent));
|
||||
|
||||
*parentObj = native_parent ? native_parent->GetGlobalJSObject() : globalObj;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventTargetSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsXHREventTarget *target = nsXHREventTarget::FromSupports(wrapper->Native());
|
||||
target->SetWrapper(wrapper);
|
||||
|
||||
return nsDOMGenericSH::PostCreate(wrapper, cx, obj);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventTargetSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *obj, jsval id,
|
||||
@ -7420,26 +7456,24 @@ nsEventTargetSH::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
if (id == sAddEventListener_id) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsISupports* native = wrapper->Native();
|
||||
nsCOMPtr<nsPIDOMEventTarget> target = do_QueryInterface(native);
|
||||
if (target) {
|
||||
nsCOMPtr<nsIScriptContext> scriptContext;
|
||||
target->GetContextForEventHandlers(getter_AddRefs(scriptContext));
|
||||
if (scriptContext) {
|
||||
nsCOMPtr<nsPIDOMWindow> window =
|
||||
do_QueryInterface(scriptContext->GetGlobalObject());
|
||||
if (window) {
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_QueryInterface(window->GetExtantDocument());
|
||||
if (doc) {
|
||||
doc->AddReference(native, wrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsXHREventTarget *target = nsXHREventTarget::FromSupports(wrapper->Native());
|
||||
target->PreserveWrapper();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEventTargetSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsXHREventTarget *target = nsXHREventTarget::FromSupports(wrapper->Native());
|
||||
target->ClearWrapper();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Element helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -7712,6 +7746,49 @@ nsArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
|
||||
// NodeList scriptable helper
|
||||
|
||||
nsresult
|
||||
nsNodeListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
nsWrapperCache* cache = nsnull;
|
||||
CallQueryInterface(nativeObj, &cache);
|
||||
if (!cache) {
|
||||
*parentObj = globalObj;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsChildContentList is the only class that uses nsNodeListSH and has a
|
||||
// cached wrapper.
|
||||
nsChildContentList *list = nsChildContentList::FromSupports(nativeObj);
|
||||
nsISupports *native_parent = list->GetParentObject();
|
||||
if (!native_parent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
jsval v;
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
nsresult rv = WrapNative(cx, globalObj, native_parent,
|
||||
NS_GET_IID(nsISupports), &v,
|
||||
getter_AddRefs(holder));
|
||||
|
||||
*parentObj = JSVAL_TO_OBJECT(v);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeListSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsWrapperCache* cache = nsnull;
|
||||
CallQueryInterface(wrapper->Native(), &cache);
|
||||
if (cache) {
|
||||
cache->SetWrapper(wrapper);
|
||||
}
|
||||
|
||||
return nsArraySH::PostCreate(wrapper, cx, obj);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNodeListSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 *length)
|
||||
@ -7750,6 +7827,19 @@ nsNodeListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
|
||||
return list->GetNodeAt(aIndex);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNodeListSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsWrapperCache* cache = nsnull;
|
||||
CallQueryInterface(wrapper->Native(), &cache);
|
||||
if (cache) {
|
||||
cache->ClearWrapper();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// StringList scriptable helper
|
||||
|
||||
@ -7887,8 +7977,7 @@ nsContentListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
nsISupports *native_parent = contentList->GetParentObject();
|
||||
|
||||
if (!native_parent) {
|
||||
*parentObj = globalObj;
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
jsval v;
|
||||
@ -7902,6 +7991,16 @@ nsContentListSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentListSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsContentList *list = nsContentList::FromSupports(wrapper->Native());
|
||||
list->SetWrapper(wrapper);
|
||||
|
||||
return nsNamedArraySH::PostCreate(wrapper, cx, obj);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentListSH::GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 *length)
|
||||
@ -7929,6 +8028,15 @@ nsContentListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
|
||||
return list->GetNamedItem(aName, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentListSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj)
|
||||
{
|
||||
nsContentList *list = nsContentList::FromSupports(wrapper->Native());
|
||||
list->ClearWrapper();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Document helper for document.location and document.on*
|
||||
|
||||
@ -8153,7 +8261,7 @@ nsDocumentSH::Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
|
||||
doc->SetJSObject(nsnull);
|
||||
|
||||
return NS_OK;
|
||||
return nsNodeSH::Finalize(wrapper, cx, obj);
|
||||
}
|
||||
|
||||
// HTMLDocument helper
|
||||
|
@ -173,7 +173,7 @@ public:
|
||||
::JS_GET_CLASS(cx, obj) == sXPCNativeWrapperClass;
|
||||
}
|
||||
|
||||
static nsresult PreserveNodeWrapper(nsIXPConnectWrappedNative *aWrapper);
|
||||
static void PreserveNodeWrapper(nsIXPConnectWrappedNative *aWrapper);
|
||||
|
||||
protected:
|
||||
friend nsIClassInfo* NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
|
||||
@ -401,11 +401,17 @@ protected:
|
||||
{
|
||||
}
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, PRUint32 flags,
|
||||
JSObject **objp, PRBool *_retval);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
@ -557,6 +563,8 @@ protected:
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
@ -567,6 +575,8 @@ public:
|
||||
NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
|
||||
NS_IMETHOD GetFlags(PRUint32 *aFlags);
|
||||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
@ -669,6 +679,13 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
virtual nsresult GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 *length);
|
||||
virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
|
||||
@ -780,6 +797,10 @@ protected:
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
JSObject *globalObj, JSObject **parentObj);
|
||||
NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj);
|
||||
|
||||
virtual nsresult GetLength(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, PRUint32 *length);
|
||||
|
@ -1016,13 +1016,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGlobalWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocumentPrincipal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDoc)
|
||||
|
||||
// Traverse any associated preserved wrappers.
|
||||
{
|
||||
if (tmp->mDoc) {
|
||||
cb.NoteXPCOMChild(tmp->mDoc->GetReference(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse stuff from nsPIDOMWindow
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mChromeEventHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument)
|
||||
@ -1055,12 +1048,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mApplicationCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocumentPrincipal)
|
||||
|
||||
// Unlink any associated preserved wrapper.
|
||||
if (tmp->mDoc) {
|
||||
tmp->mDoc->RemoveReference(tmp);
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDoc)
|
||||
}
|
||||
|
||||
// Unlink stuff from nsPIDOMWindow
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mChromeEventHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocument)
|
||||
|
@ -3377,7 +3377,8 @@ nsJSContext::ScriptExecuted()
|
||||
NS_IMETHODIMP
|
||||
nsJSContext::PreserveWrapper(nsIXPConnectWrappedNative *aWrapper)
|
||||
{
|
||||
return nsDOMClassInfo::PreserveNodeWrapper(aWrapper);
|
||||
nsDOMClassInfo::PreserveNodeWrapper(aWrapper);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//static
|
||||
|
@ -39,6 +39,95 @@
|
||||
#include "MaemoLocationProvider.h"
|
||||
#include "nsGeolocation.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsGeoPosition
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Simple object that holds a single point in space.
|
||||
*/
|
||||
class nsGeoPosition : public nsIDOMGeoPosition
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMGEOPOSITION
|
||||
|
||||
nsGeoPosition(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aSpeed, long long aTimestamp)
|
||||
: mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mHeading(aHeading), mSpeed(aSpeed), mTimestamp(aTimestamp){};
|
||||
|
||||
private:
|
||||
~nsGeoPosition(){}
|
||||
double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
|
||||
long long mTimestamp;
|
||||
};
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsGeoPosition)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPosition)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPosition)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPosition)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsGeoPosition)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetLatitude(double *aLatitude)
|
||||
{
|
||||
*aLatitude = mLat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetLongitude(double *aLongitude)
|
||||
{
|
||||
*aLongitude = mLong;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetAltitude(double *aAltitude)
|
||||
{
|
||||
*aAltitude = mAlt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetAccuracy(double *aAccuracy)
|
||||
{
|
||||
*aAccuracy = mHError;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetAltitudeAccuracy(double *aAltitudeAccuracy)
|
||||
{
|
||||
*aAltitudeAccuracy = mVError;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetHeading(double *aHeading)
|
||||
{
|
||||
*aHeading = mHeading;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetSpeed(double *aSpeed)
|
||||
{
|
||||
*aSpeed = mSpeed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
{
|
||||
*aTimestamp = mTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(MaemoLocationProvider, nsIGeolocationProvider)
|
||||
|
||||
MaemoLocationProvider::MaemoLocationProvider()
|
||||
|
@ -58,6 +58,10 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
// Some limit to the number of get or watch geolocation requests
|
||||
// that a window can make.
|
||||
#define MAX_GEO_REQUESTS_PER_WINDOW 1500
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsDOMGeoPositionError
|
||||
////////////////////////////////////////////////////
|
||||
@ -135,7 +139,6 @@ nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator,
|
||||
nsIDOMGeoPositionOptions* aOptions)
|
||||
: mAllowed(PR_FALSE),
|
||||
mCleared(PR_FALSE),
|
||||
mFuzzLocation(PR_FALSE),
|
||||
mHasSentData(PR_FALSE),
|
||||
mCallback(aCallback),
|
||||
mErrorCallback(aErrorCallback),
|
||||
@ -148,6 +151,22 @@ nsGeolocationRequest::~nsGeolocationRequest()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGeolocationRequest::Init()
|
||||
{
|
||||
// This method is called before the user has given permission for this request.
|
||||
|
||||
// check to see if we have a geolocation provider, if not, notify an error and bail.
|
||||
nsRefPtr<nsGeolocationService> geoService = nsGeolocationService::GetInstance();
|
||||
if (!geoService->HasGeolocationProvider()) {
|
||||
NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
|
||||
return NS_ERROR_FAILURE;;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsGeolocationRequest)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIGeolocationRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGeolocationRequest)
|
||||
@ -177,7 +196,7 @@ nsGeolocationRequest::Notify(nsITimer* aTimer)
|
||||
// ::Cancel, just a different error
|
||||
|
||||
if (!mHasSentData) {
|
||||
NotifyError(NS_GEO_ERROR_CODE_TIMEOUT);
|
||||
NotifyError(nsIDOMGeoPositionError::TIMEOUT);
|
||||
// remove ourselves from the locator's callback lists.
|
||||
mLocator->RemoveRequest(this);
|
||||
}
|
||||
@ -207,7 +226,7 @@ nsGeolocationRequest::GetRequestingWindow(nsIDOMWindow * *aRequestingWindow)
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequest::Cancel()
|
||||
{
|
||||
NotifyError(NS_GEO_ERROR_CODE_PERMISSION_ERROR);
|
||||
NotifyError(nsIDOMGeoPositionError::PERMISSION_DENIED);
|
||||
|
||||
// remove ourselves from the locators callback lists.
|
||||
mLocator->RemoveRequest(this);
|
||||
@ -223,7 +242,7 @@ nsGeolocationRequest::Allow()
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Location provider error
|
||||
NotifyError(NS_GEO_ERROR_CODE_LOCATION_PROVIDER_ERROR);
|
||||
NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -237,13 +256,6 @@ nsGeolocationRequest::Allow()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocationRequest::AllowButFuzz()
|
||||
{
|
||||
mFuzzLocation = PR_TRUE;
|
||||
return Allow();
|
||||
}
|
||||
|
||||
void
|
||||
nsGeolocationRequest::MarkCleared()
|
||||
{
|
||||
@ -256,55 +268,18 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
|
||||
if (mCleared || !mAllowed)
|
||||
return;
|
||||
|
||||
// we should not pass null back to the DOM.
|
||||
if (!aPosition) {
|
||||
NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure that the proper context is on the stack (bug 452762)
|
||||
nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
|
||||
if (!stack || NS_FAILED(stack->Push(nsnull)))
|
||||
return; // silently fail
|
||||
|
||||
//TODO mFuzzLocation. Needs to be defined what we do here.
|
||||
if (mFuzzLocation)
|
||||
{
|
||||
// need to make a copy because nsIDOMGeoPosition is
|
||||
// readonly, and we are not sure of its implementation.
|
||||
|
||||
double lat, lon, alt, herror, verror, heading, speed;
|
||||
DOMTimeStamp time;
|
||||
aPosition->GetLatitude(&lat);
|
||||
aPosition->GetLongitude(&lon);
|
||||
aPosition->GetAltitude(&alt);
|
||||
aPosition->GetAccuracy(&herror);
|
||||
aPosition->GetAltitudeAccuracy(&verror);
|
||||
aPosition->GetHeading(&heading);
|
||||
aPosition->GetSpeed(&speed);
|
||||
aPosition->GetTimestamp(&time);
|
||||
|
||||
// Truncate ?
|
||||
// lat = floor(lat*10+.5)/10;
|
||||
// lon = floor(lon*10+.5)/10;
|
||||
// herror = 1600; /* about 1 mile */
|
||||
|
||||
lat = 0;
|
||||
lon = 0;
|
||||
herror = 0;
|
||||
heading = 0;
|
||||
speed = 0;
|
||||
alt = 0;
|
||||
verror = 0;
|
||||
|
||||
nsRefPtr<nsGeoPosition> somewhere = new nsGeoPosition(lat,
|
||||
lon,
|
||||
alt,
|
||||
herror,
|
||||
verror,
|
||||
heading,
|
||||
speed,
|
||||
time);
|
||||
mCallback->HandleEvent(somewhere);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCallback->HandleEvent(aPosition);
|
||||
}
|
||||
mCallback->HandleEvent(aPosition);
|
||||
|
||||
// remove the stack
|
||||
JSContext* cx;
|
||||
@ -321,74 +296,6 @@ nsGeolocationRequest::Shutdown()
|
||||
mErrorCallback = nsnull;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsGeoPosition
|
||||
////////////////////////////////////////////////////
|
||||
NS_INTERFACE_MAP_BEGIN(nsGeoPosition)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPosition)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPosition)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPosition)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsGeoPosition)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetLatitude(double *aLatitude)
|
||||
{
|
||||
*aLatitude = mLat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetLongitude(double *aLongitude)
|
||||
{
|
||||
*aLongitude = mLong;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetAltitude(double *aAltitude)
|
||||
{
|
||||
*aAltitude = mAlt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetAccuracy(double *aAccuracy)
|
||||
{
|
||||
*aAccuracy = mHError;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetAltitudeAccuracy(double *aAltitudeAccuracy)
|
||||
{
|
||||
*aAltitudeAccuracy = mVError;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetHeading(double *aHeading)
|
||||
{
|
||||
*aHeading = mHeading;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetSpeed(double *aSpeed)
|
||||
{
|
||||
*aSpeed = mSpeed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
|
||||
{
|
||||
*aTimestamp = mTimestamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsGeolocationService
|
||||
////////////////////////////////////////////////////
|
||||
@ -402,6 +309,7 @@ NS_IMPL_THREADSAFE_ADDREF(nsGeolocationService)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsGeolocationService)
|
||||
|
||||
nsGeolocationService::nsGeolocationService()
|
||||
: mProviderStarted(PR_FALSE)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = do_GetService("@mozilla.org/observer-service;1");
|
||||
if (obs) {
|
||||
@ -409,6 +317,15 @@ nsGeolocationService::nsGeolocationService()
|
||||
}
|
||||
|
||||
mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000);
|
||||
|
||||
mProvider = do_GetService(NS_GEOLOCATION_PROVIDER_CONTRACTID);
|
||||
|
||||
// if NS_MAEMO_LOCATION, see if we should try the MAEMO location provider
|
||||
#ifdef NS_MAEMO_LOCATION
|
||||
if (!mProvider)
|
||||
mProvider = new MaemoLocationProvider();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
nsGeolocationService::~nsGeolocationService()
|
||||
@ -462,58 +379,36 @@ nsGeolocationService::Update(nsIDOMGeoPosition *aSomewhere)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMGeoPosition>
|
||||
nsGeolocationService::GetLastKnownPosition()
|
||||
{
|
||||
nsIDOMGeoPosition* p = nsnull;
|
||||
if (mProvider)
|
||||
mProvider->GetCurrentPosition(&p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGeolocationService::IsDeviceReady()
|
||||
nsGeolocationService::HasGeolocationProvider()
|
||||
{
|
||||
PRBool ready = PR_FALSE;
|
||||
if (mProvider)
|
||||
mProvider->IsReady(&ready);
|
||||
|
||||
return ready;
|
||||
return (mProvider != nsnull);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGeolocationService::StartDevice()
|
||||
{
|
||||
if (!mProvider)
|
||||
{
|
||||
// Check to see if there is an override in place. if so, use it.
|
||||
mProvider = do_GetService(NS_GEOLOCATION_PROVIDER_CONTRACTID);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (!mProviderStarted) {
|
||||
|
||||
// if NS_MAEMO_LOCATION, see if we should try the MAEMO location provider
|
||||
#ifdef NS_MAEMO_LOCATION
|
||||
if (!mProvider)
|
||||
{
|
||||
// guess not, lets try a default one:
|
||||
mProvider = new MaemoLocationProvider();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!mProvider)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// if we have one, start it up.
|
||||
nsresult rv = mProvider->Startup();
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
|
||||
// lets monitor it for any changes.
|
||||
mProvider->Watch(this);
|
||||
|
||||
|
||||
// remember that we are started up
|
||||
mProviderStarted = PR_TRUE;
|
||||
|
||||
// we do not want to keep the geolocation devices online
|
||||
// indefinitely. Close them down after a reasonable period of
|
||||
// inactivivity
|
||||
SetDisconnectTimer();
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -537,7 +432,7 @@ nsGeolocationService::StopDevice()
|
||||
{
|
||||
if (mProvider) {
|
||||
mProvider->Shutdown();
|
||||
mProvider = nsnull;
|
||||
mProviderStarted = PR_FALSE;
|
||||
}
|
||||
|
||||
if(mDisconnectTimer) {
|
||||
@ -700,15 +595,20 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
|
||||
nsIDOMGeoPositionErrorCallback *errorCallback,
|
||||
nsIDOMGeoPositionOptions *options)
|
||||
{
|
||||
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
if (prompt == nsnull)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
if (mPendingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this, callback, errorCallback, options);
|
||||
if (!request)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(request->Init()))
|
||||
return NS_OK;
|
||||
|
||||
prompt->Prompt(request);
|
||||
|
||||
// What if you have a location provider that only sends a location once, then stops.? fix.
|
||||
@ -720,16 +620,22 @@ NS_IMETHODIMP
|
||||
nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback,
|
||||
nsIDOMGeoPositionErrorCallback *aErrorCallback,
|
||||
nsIDOMGeoPositionOptions *aOptions,
|
||||
PRUint16 *_retval NS_OUTPARAM)
|
||||
PRInt32 *_retval NS_OUTPARAM)
|
||||
{
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
if (prompt == nsnull)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
|
||||
if (mWatchingCallbacks.Length() > MAX_GEO_REQUESTS_PER_WINDOW)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsRefPtr<nsGeolocationRequest> request = new nsGeolocationRequest(this, aCallback, aErrorCallback, aOptions);
|
||||
if (!request)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(request->Init()))
|
||||
return NS_OK;
|
||||
|
||||
prompt->Prompt(request);
|
||||
|
||||
// need to hand back an index/reference.
|
||||
@ -739,8 +645,12 @@ nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *aCallback,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGeolocation::ClearWatch(PRUint16 aWatchId)
|
||||
nsGeolocation::ClearWatch(PRInt32 aWatchId)
|
||||
{
|
||||
PRUint32 count = mWatchingCallbacks.Length();
|
||||
if (aWatchId < 0 || count == 0 || aWatchId > count)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mWatchingCallbacks[aWatchId]->MarkCleared();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -55,11 +55,6 @@
|
||||
|
||||
#include "nsIGeolocationProvider.h"
|
||||
|
||||
#define NS_GEO_ERROR_CODE_PERMISSION_ERROR 1
|
||||
#define NS_GEO_ERROR_CODE_LOCATION_PROVIDER_ERROR 2
|
||||
#define NS_GEO_ERROR_CODE_POSITION_NOT_FOUND 3
|
||||
#define NS_GEO_ERROR_CODE_TIMEOUT 4
|
||||
|
||||
class nsGeolocationService;
|
||||
class nsGeolocation;
|
||||
|
||||
@ -74,6 +69,7 @@ class nsGeolocationRequest : public nsIGeolocationRequest, public nsITimerCallba
|
||||
nsIDOMGeoPositionCallback* callback,
|
||||
nsIDOMGeoPositionErrorCallback* errorCallback,
|
||||
nsIDOMGeoPositionOptions* options);
|
||||
nsresult Init();
|
||||
void Shutdown();
|
||||
|
||||
void SendLocation(nsIDOMGeoPosition* location);
|
||||
@ -87,7 +83,6 @@ class nsGeolocationRequest : public nsIGeolocationRequest, public nsITimerCallba
|
||||
void NotifyError(PRInt16 errorCode);
|
||||
PRPackedBool mAllowed;
|
||||
PRPackedBool mCleared;
|
||||
PRPackedBool mFuzzLocation;
|
||||
PRPackedBool mHasSentData;
|
||||
|
||||
nsCOMPtr<nsITimer> mTimeoutTimer;
|
||||
@ -96,25 +91,6 @@ class nsGeolocationRequest : public nsIGeolocationRequest, public nsITimerCallba
|
||||
nsCOMPtr<nsIDOMGeoPositionOptions> mOptions;
|
||||
|
||||
nsGeolocation* mLocator; // The locator exists longer than this object.
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple object that holds a single point in space.
|
||||
*/
|
||||
class nsGeoPosition : public nsIDOMGeoPosition
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMGEOPOSITION
|
||||
|
||||
nsGeoPosition(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aSpeed, long long aTimestamp)
|
||||
: mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mHeading(aHeading), mSpeed(aSpeed), mTimestamp(aTimestamp){};
|
||||
|
||||
private:
|
||||
~nsGeoPosition(){}
|
||||
double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
|
||||
long long mTimestamp;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -138,12 +114,8 @@ public:
|
||||
void AddLocator(nsGeolocation* locator);
|
||||
void RemoveLocator(nsGeolocation* locator);
|
||||
|
||||
// Returns the last geolocation we have seen since calling StartDevice()
|
||||
already_AddRefed<nsIDOMGeoPosition> GetLastKnownPosition();
|
||||
|
||||
// Returns true if the we have successfully found and started a
|
||||
// geolocation device
|
||||
PRBool IsDeviceReady();
|
||||
// Returns true if there is a geolocation provider registered.
|
||||
PRBool HasGeolocationProvider();
|
||||
|
||||
// Find and startup a geolocation device (gps, nmea, etc.)
|
||||
nsresult StartDevice();
|
||||
@ -169,6 +141,9 @@ private:
|
||||
// The object providing geo location information to us.
|
||||
nsCOMPtr<nsIGeolocationProvider> mProvider;
|
||||
|
||||
// A flag that lets us know if the mProvider has been started up.
|
||||
PRBool mProviderStarted;
|
||||
|
||||
// mGeolocators are not owned here. Their constructor
|
||||
// addes them to this list, and their destructor removes
|
||||
// them from this list.
|
||||
|
@ -40,6 +40,9 @@ req.onreadystatechange = function() {
|
||||
|
||||
function finish()
|
||||
{
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
pm.remove(uri.asciiHost, "offline-app");
|
||||
|
||||
gTestWin.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ _TEST_FILES = \
|
||||
test_cancelCurrent.html \
|
||||
test_cancelWatch.html \
|
||||
test_clearWatch.html \
|
||||
test_clearWatch_invalid.html \
|
||||
test_geoPrompt.html \
|
||||
test_timeoutWatch.html \
|
||||
prompt_common.js \
|
||||
|
@ -25,6 +25,14 @@ var numCallbacks = 5;
|
||||
var callbackCounter = new Array(numCallbacks);
|
||||
var watchID = new Array(numCallbacks);
|
||||
|
||||
function failureCallback(error)
|
||||
{
|
||||
ok(error.code == 2, "Failure was something other than position unavailable");
|
||||
removePrompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
||||
// define success callbacks
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
eval("function successCallback" + i + "(position) {" +
|
||||
@ -37,7 +45,7 @@ for(var i = 0; i < numCallbacks; i++) {
|
||||
function registerWatches() {
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
|
||||
+ i + ", null, null);"
|
||||
+ i + ", failureCallback, null);"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
|
||||
var numCallbacks = 5;
|
||||
var callbackCounter = new Array(numCallbacks);
|
||||
|
||||
function failureCallback(error)
|
||||
{
|
||||
ok(error.code == 2, "Failure was something other than position unavailable");
|
||||
removePrompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// define success callbacks
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
eval("function successCallback" + i + "(position) {" +
|
||||
@ -50,7 +57,7 @@ promptOption = DECLINE;
|
||||
|
||||
// one-shot position requests
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
eval("navigator.geolocation.getCurrentPosition(successCallback" + i + ", null, null);");
|
||||
eval("navigator.geolocation.getCurrentPosition(successCallback" + i + ", failureCallback, null);");
|
||||
}
|
||||
|
||||
// wait for position change
|
||||
|
@ -25,6 +25,13 @@ var numCallbacks = 5;
|
||||
var callbackCounter = new Array(numCallbacks);
|
||||
var watchID = new Array(numCallbacks);
|
||||
|
||||
function failureCallback(error)
|
||||
{
|
||||
ok(error.code == 2, "Failure was something other than position unavailable");
|
||||
removePrompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// define success callbacks
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
eval("function successCallback" + i + "(position) {" +
|
||||
@ -37,7 +44,7 @@ for(var i = 0; i < numCallbacks; i++) {
|
||||
function registerWatches() {
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
|
||||
+ i + ", null, null);"
|
||||
+ i + ", failureCallback, null);"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,13 @@ var numCallbacks = 5;
|
||||
var callbackCounter = new Array(numCallbacks);
|
||||
var watchID = new Array(numCallbacks);
|
||||
|
||||
function failureCallback(error)
|
||||
{
|
||||
ok(error.code == 2, "Failure was something other than position unavailable");
|
||||
removePrompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
// define success callbacks
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
eval("function successCallback" + i + "(position) {" +
|
||||
@ -37,7 +44,7 @@ for(var i = 0; i < numCallbacks; i++) {
|
||||
function registerWatches() {
|
||||
for(var i = 0; i < numCallbacks; i++) {
|
||||
watchID[i] = eval("navigator.geolocation.watchPosition(successCallback"
|
||||
+ i + ", null, null);"
|
||||
+ i + ", failureCallback, null);"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
52
dom/tests/mochitest/geolocation/test_clearWatch_invalid.html
Normal file
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=463039
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 463039</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="prompt_common.js"></script>
|
||||
<script type="text/javascript" src="geolocation_common.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=463039">Mozilla Bug 463039</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 463039 **/
|
||||
|
||||
ok(navigator.geolocation, "Should have geolocation");
|
||||
|
||||
|
||||
// there are no watches, so this should always throw
|
||||
for (x=-10; x<10; x++) {
|
||||
try {
|
||||
navigator.geolocation.clearWatch(x);
|
||||
ok(0, "clearWatch should throw");
|
||||
} catch (ex) {
|
||||
ok(1, "clearWatch with a bad value did throw");
|
||||
}
|
||||
}
|
||||
|
||||
// lets try something huge
|
||||
try {
|
||||
navigator.geolocation.clearWatch(Number.MAX_VALUE);
|
||||
ok(0, "clearWatch should throw");
|
||||
} catch (ex) {
|
||||
ok(1, "clearWatch with a bad value did throw");
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -324,7 +324,7 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data,
|
||||
cairo_surface_t *surface;
|
||||
pixman_image_t *pixman_image;
|
||||
|
||||
pixman_image = pixman_image_create_bits (pixman_format, width, height,
|
||||
pixman_image = pixman_image_create_bits (pixman_format, width ? width : 1, height ? height : 1,
|
||||
(uint32_t *) data, stride);
|
||||
|
||||
if (pixman_image == NULL)
|
||||
|
@ -263,7 +263,7 @@ endif
|
||||
ifdef HAVE_DTRACE
|
||||
INSTALLED_HEADERS += \
|
||||
jsdtracef.h \
|
||||
javascript-trace.h \
|
||||
$(CURDIR)/javascript-trace.h \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
@ -655,8 +655,10 @@ $(CURDIR)/jsautooplen.h: host_jsoplengen$(HOST_BIN_SUFFIX)
|
||||
$(CPPSRCS:%.cpp=%.$(OBJ_SUFFIX)): $(CURDIR)/jsautokw.h $(CURDIR)/jsautooplen.h
|
||||
|
||||
ifdef HAVE_DTRACE
|
||||
javascript-trace.h: $(srcdir)/javascript-trace.d
|
||||
$(CURDIR)/javascript-trace.h: $(srcdir)/javascript-trace.d
|
||||
dtrace -h -s $(srcdir)/javascript-trace.d -o javascript-trace.h.in
|
||||
sed 's/if _DTRACE_VERSION/ifdef INCLUDE_MOZILLA_DTRACE/' \
|
||||
javascript-trace.h.in > javascript-trace.h
|
||||
|
||||
$(CPPSRCS:%.cpp=%.$(OBJ_SUFFIX)): $(CURDIR)/javascript-trace.h
|
||||
endif
|
||||
|
@ -1487,7 +1487,6 @@ $(FINAL_TARGET):
|
||||
$(NSINSTALL) -D $@
|
||||
|
||||
export:: $(FINAL_TARGET)
|
||||
$(NSINSTALL) -D $(FINAL_TARGET)
|
||||
endif
|
||||
|
||||
ifndef NO_DIST_INSTALL
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "nsIAtom.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "nsJSPrincipals.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
//#define STRICT_CHECK_OF_UNICODE
|
||||
#ifdef STRICT_CHECK_OF_UNICODE
|
||||
@ -1091,15 +1092,30 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx,
|
||||
if(!iface)
|
||||
return JS_FALSE;
|
||||
|
||||
nsresult rv;
|
||||
XPCWrappedNative* wrapper;
|
||||
nsresult rv = XPCWrappedNative::GetNewOrUsed(ccx, src, xpcscope,
|
||||
iface, isGlobal,
|
||||
&wrapper);
|
||||
nsWrapperCache* cache = nsnull;
|
||||
CallQueryInterface(src, &cache);
|
||||
if(cache &&
|
||||
(wrapper = static_cast<XPCWrappedNative*>(cache->GetWrapper())))
|
||||
{
|
||||
NS_ADDREF(wrapper);
|
||||
wrapper->FindTearOff(ccx, iface, JS_FALSE, &rv);
|
||||
if(NS_FAILED(rv))
|
||||
NS_RELEASE(wrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = XPCWrappedNative::GetNewOrUsed(ccx, src, xpcscope, iface,
|
||||
isGlobal, &wrapper);
|
||||
}
|
||||
|
||||
if(pErr)
|
||||
*pErr = rv;
|
||||
if(NS_SUCCEEDED(rv) && wrapper)
|
||||
{
|
||||
uint32 flags = 0;
|
||||
JSObject *flat = wrapper->GetFlatJSObject();
|
||||
if (allowNativeWrapper && wrapper->GetScope() != xpcscope)
|
||||
{
|
||||
// Cross scope access detected. Check if chrome code
|
||||
@ -1157,7 +1173,6 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx,
|
||||
|
||||
flags = script ? JS_GetScriptFilenameFlags(script) : 0;
|
||||
NS_ASSERTION(flags != JSFILENAME_NULL, "null script filename");
|
||||
JSObject *flat = wrapper->GetFlatJSObject();
|
||||
|
||||
if(!JS_IsSystemObject(ccx, flat))
|
||||
{
|
||||
@ -1265,7 +1280,6 @@ XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx,
|
||||
}
|
||||
}
|
||||
|
||||
JSObject *flat = wrapper->GetFlatJSObject();
|
||||
const char *name = STOBJ_GET_CLASS(flat)->name;
|
||||
if(allowNativeWrapper &&
|
||||
!(flags & JSFILENAME_SYSTEM) &&
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "XPCNativeWrapper.h"
|
||||
#include "XPCWrapper.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
@ -589,27 +590,13 @@ XPCWrappedNative::GetUsedOnly(XPCCallContext& ccx,
|
||||
XPCWrappedNative** resultWrapper)
|
||||
{
|
||||
NS_ASSERTION(Object, "XPCWrappedNative::GetUsedOnly was called with a null Object");
|
||||
nsCOMPtr<nsISupports> identity;
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
// XXX See GetNewOrUsed for more info on this
|
||||
if(Interface->GetIID()->Equals(NSID_IDISPATCH))
|
||||
identity = Object;
|
||||
else
|
||||
#endif
|
||||
identity = do_QueryInterface(Object);
|
||||
|
||||
if(!identity)
|
||||
{
|
||||
NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
XPCWrappedNative* wrapper;
|
||||
Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap();
|
||||
|
||||
{ // scoped lock
|
||||
XPCAutoLock lock(Scope->GetRuntime()->GetMapLock());
|
||||
wrapper = map->Find(identity);
|
||||
nsWrapperCache* cache = nsnull;
|
||||
CallQueryInterface(Object, &cache);
|
||||
if(cache)
|
||||
{
|
||||
wrapper = static_cast<XPCWrappedNative*>(cache->GetWrapper());
|
||||
if(!wrapper)
|
||||
{
|
||||
*resultWrapper = nsnull;
|
||||
@ -617,6 +604,36 @@ XPCWrappedNative::GetUsedOnly(XPCCallContext& ccx,
|
||||
}
|
||||
NS_ADDREF(wrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCOMPtr<nsISupports> identity;
|
||||
#ifdef XPC_IDISPATCH_SUPPORT
|
||||
// XXX See GetNewOrUsed for more info on this
|
||||
if(Interface->GetIID()->Equals(NSID_IDISPATCH))
|
||||
identity = Object;
|
||||
else
|
||||
#endif
|
||||
identity = do_QueryInterface(Object);
|
||||
|
||||
if(!identity)
|
||||
{
|
||||
NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap();
|
||||
|
||||
{ // scoped lock
|
||||
XPCAutoLock lock(Scope->GetRuntime()->GetMapLock());
|
||||
wrapper = map->Find(identity);
|
||||
if(!wrapper)
|
||||
{
|
||||
*resultWrapper = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_ADDREF(wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
if(!wrapper->FindTearOff(ccx, Interface, JS_FALSE, &rv))
|
||||
|