diff options
Diffstat (limited to 'dom')
-rw-r--r-- | dom/base/nsJSEnvironment.cpp | 5 | ||||
-rw-r--r-- | dom/base/nsScriptLoader.cpp | 5 | ||||
-rw-r--r-- | dom/canvas/CanvasRenderingContext2D.cpp | 73 | ||||
-rw-r--r-- | dom/system/NetworkGeolocationProvider.js | 41 |
4 files changed, 101 insertions, 23 deletions
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index b273d00c9..576f3052a 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -2282,6 +2282,7 @@ SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure) { bool enableZoneGC = Preferences::GetBool("javascript.options.mem.gc_per_zone"); bool enableIncrementalGC = Preferences::GetBool("javascript.options.mem.gc_incremental"); + bool enableGenerationalGC = Preferences::GetBool("javascript.options.mem.gc_generational"); JSGCMode mode; if (enableIncrementalGC) { mode = JSGC_MODE_INCREMENTAL; @@ -2291,6 +2292,7 @@ SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure) mode = JSGC_MODE_GLOBAL; } JS_SetGCParameter(sContext, JSGC_MODE, mode); + JS_SetGGCMode(sContext, enableGenerationalGC); } static void @@ -2485,6 +2487,9 @@ nsJSContext::EnsureStatics() Preferences::RegisterCallbackAndCall(SetMemoryGCSliceTimePrefChangedCallback, "javascript.options.mem.gc_incremental_slice_ms"); + Preferences::RegisterCallbackAndCall(SetMemoryGCModePrefChangedCallback, + "javascript.options.mem.gc_generational"); + Preferences::RegisterCallbackAndCall(SetMemoryGCCompactingPrefChangedCallback, "javascript.options.mem.gc_compacting"); diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp index 6c732db6c..a6d20e363 100644 --- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -2630,7 +2630,10 @@ nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest, } nsAutoCString sourceMapURL; - rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-SourceMap"), sourceMapURL); + rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("SourceMap"), sourceMapURL); + if (NS_FAILED(rv)) { + rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("X-SourceMap"), sourceMapURL); + } if (NS_SUCCEEDED(rv)) { aRequest->mHasSourceMapURL = true; aRequest->mSourceMapURL = NS_ConvertUTF8toUTF16(sourceMapURL); diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 2ed39627e..b0a430fe4 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -68,6 +68,8 @@ #include "CanvasImageCache.h" #include <algorithm> +#include <stdlib.h> +#include <time.h> #include "jsapi.h" #include "jsfriendapi.h" @@ -2083,6 +2085,18 @@ CanvasRenderingContext2D::GetInputStream(const char* aMimeType, return NS_ERROR_FAILURE; } + bool PoisonData = Preferences::GetBool("canvas.poisondata",false); + if (PoisonData) { + srand(time(NULL)); + // Image buffer is always a packed BGRA array (BGRX -> BGR[FF]) + // so always 4-byte pixels. + // GetImageBuffer => SurfaceToPackedBGRA [=> ConvertBGRXToBGRA] + for (int32_t j = 0; j < mWidth * mHeight * 4; ++j) { + if (imageBuffer[j] !=0 && imageBuffer[j] != 255) + imageBuffer[j] += rand() % 3 - 1; + } + } + return ImageEncoder::GetInputStream(mWidth, mHeight, imageBuffer.get(), format, encoder, aEncoderOptions, aStream); @@ -5698,6 +5712,14 @@ CanvasRenderingContext2D::GetImageData(JSContext* aCx, double aSx, return imageData.forget(); } +inline uint8_t PoisonValue(uint8_t v) +{ + if (v==0 || v==255) + return v; //don't fuzz edges to prevent overflow/underflow + + return v + rand() %3 -1; +} + nsresult CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, int32_t aX, @@ -5712,6 +5734,10 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, MOZ_ASSERT(aWidth && aHeight); + bool PoisonData = Preferences::GetBool("canvas.poisondata",false); + if (PoisonData) + srand(time(NULL)); + CheckedInt<uint32_t> len = CheckedInt<uint32_t>(aWidth) * aHeight * 4; if (!len.isValid()) { return NS_ERROR_DOM_INDEX_SIZE_ERR; @@ -5784,21 +5810,31 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, uint8_t* dst = data + dstWriteRect.y * (aWidth * 4) + dstWriteRect.x * 4; + uint8_t a,r,g,b; + if (mOpaque) { for (int32_t j = 0; j < dstWriteRect.height; ++j) { for (int32_t i = 0; i < dstWriteRect.width; ++i) { // XXX Is there some useful swizzle MMX we can use here? #if MOZ_LITTLE_ENDIAN - uint8_t b = *src++; - uint8_t g = *src++; - uint8_t r = *src++; + b = *src++; + g = *src++; + r = *src++; src++; #else src++; - uint8_t r = *src++; - uint8_t g = *src++; - uint8_t b = *src++; + r = *src++; + g = *src++; + b = *src++; #endif + + // Poison data for trackers if enabled + if (PoisonData) { + PoisonValue(r); + PoisonValue(g); + PoisonValue(b); + } + *dst++ = r; *dst++ = g; *dst++ = b; @@ -5812,16 +5848,25 @@ CanvasRenderingContext2D::GetImageDataArray(JSContext* aCx, for (int32_t i = 0; i < dstWriteRect.width; ++i) { // XXX Is there some useful swizzle MMX we can use here? #if MOZ_LITTLE_ENDIAN - uint8_t b = *src++; - uint8_t g = *src++; - uint8_t r = *src++; - uint8_t a = *src++; + b = *src++; + g = *src++; + r = *src++; + a = *src++; #else - uint8_t a = *src++; - uint8_t r = *src++; - uint8_t g = *src++; - uint8_t b = *src++; + a = *src++; + r = *src++; + g = *src++; + b = *src++; #endif + + // Poison data for trackers if enabled + if (PoisonData) { + PoisonValue(a); + PoisonValue(r); + PoisonValue(g); + PoisonValue(b); + } + // Convert to non-premultiplied color *dst++ = gfxUtils::sUnpremultiplyTable[a * 256 + r]; *dst++ = gfxUtils::sUnpremultiplyTable[a * 256 + g]; diff --git a/dom/system/NetworkGeolocationProvider.js b/dom/system/NetworkGeolocationProvider.js index ea2abe55f..ad15ed802 100644 --- a/dom/system/NetworkGeolocationProvider.js +++ b/dom/system/NetworkGeolocationProvider.js @@ -219,9 +219,20 @@ WifiGeoCoordsObject.prototype = { QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]) }; -function WifiGeoPositionObject(lat, lng, acc) { +function WifiGeoPositionObject(lat, lng, acc, cc, tz, zip, city, rc, region, country, isp, org, as) { this.coords = new WifiGeoCoordsObject(lat, lng, acc, 0, 0); this.address = null; + this.countrycode = cc; + this.timezone = tz; + this.zipcode = zip; + this.postalcode = zip; + this.city = city; + this.regioncode = rc; + this.region = region; + this.country = country; + this.isp = isp; + this.org = org; + this.as = as; this.timestamp = Date.now(); } @@ -431,41 +442,54 @@ WifiGeoPositionProvider.prototype = { let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] .createInstance(Ci.nsIXMLHttpRequest); - this.notifyListener("locationUpdatePending"); + // XXX: Dead code? + // this.notifyListener("locationUpdatePending"); try { - xhr.open("POST", url, true); + xhr.open("GET", url, true); xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS; } catch (e) { this.notifyListener("notifyError", [POSITION_UNAVAILABLE]); return; } - xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); xhr.responseType = "json"; xhr.mozBackgroundRequest = true; xhr.timeout = Services.prefs.getIntPref("geo.wifi.xhr.timeout"); + xhr.ontimeout = (function() { LOG("Location request XHR timed out.") this.notifyListener("notifyError", [POSITION_UNAVAILABLE]); }).bind(this); + xhr.onerror = (function() { this.notifyListener("notifyError", [POSITION_UNAVAILABLE]); }).bind(this); + xhr.onload = (function() { LOG("server returned status: " + xhr.status + " --> " + JSON.stringify(xhr.response)); if ((xhr.channel instanceof Ci.nsIHttpChannel && xhr.status != 200) || - !xhr.response || !xhr.response.location) { + !xhr.response || xhr.response.status == 'fail') { this.notifyListener("notifyError", [POSITION_UNAVAILABLE]); return; } - let newLocation = new WifiGeoPositionObject(xhr.response.location.lat, - xhr.response.location.lng, - xhr.response.accuracy); + let newLocation = new WifiGeoPositionObject(xhr.response.lat, + xhr.response.lon, + null, //accuracy not provided + xhr.response.countryCode, + xhr.response.timezone, + xhr.response.zip, + xhr.response.city, + xhr.response.region, + xhr.response.regionName, + xhr.response.country, + xhr.response.isp, + xhr.response.org, + xhr.response.as); this.notifyListener("update", [newLocation]); gCachedRequest = new CachedRequest(newLocation, data.cellTowers, data.wifiAccessPoints); @@ -478,6 +502,7 @@ WifiGeoPositionProvider.prototype = { notifyListener: function(listenerFunc, args) { args = args || []; + LOG("Notify listener " + listenerFunc); try { this.listener[listenerFunc].apply(this.listener, args); } catch(e) { |