--HG--
extra : commitid : C5ZGJHM8FSu
This commit is contained in:
Wes Kocher 2015-11-24 13:54:06 -08:00
Родитель 4dc5e74675 72261b4523
Коммит bee783ac06
444 изменённых файлов: 29620 добавлений и 7286 удалений

Просмотреть файл

@ -20,6 +20,10 @@ const base64png = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYA" +
const { base64jpeg } = require("./fixtures");
const { platform } = require("sdk/system");
// For Windows, Mac and Linux, platform returns the following: winnt, darwin and linux.
var isWindows = platform.toLowerCase().indexOf("win") == 0;
const canvasHTML = "data:text/html," + encodeURIComponent(
"<html>\
<body>\
@ -99,6 +103,13 @@ exports["test With No Flavor"] = function(assert) {
exports["test With Flavor"] = function(assert) {
var contents = "<b>hello there</b>";
var contentsText = "hello there";
// On windows, HTML clipboard includes extra data.
// The values are from widget/windows/nsDataObj.cpp.
var contentsWindowsHtml = "<html><body>\n<!--StartFragment-->" +
contents +
"<!--EndFragment-->\n</body>\n</html>";
var flavor = "html";
var fullFlavor = "text/html";
var unicodeFlavor = "text";
@ -110,8 +121,8 @@ exports["test With Flavor"] = function(assert) {
assert.equal(clip.currentFlavors[0], unicodeFlavor);
assert.equal(clip.currentFlavors[1], flavor);
assert.equal(clip.get(), contentsText);
assert.equal(clip.get(flavor), contents);
assert.equal(clip.get(fullFlavor), contents);
assert.equal(clip.get(flavor), isWindows ? contentsWindowsHtml : contents);
assert.equal(clip.get(fullFlavor), isWindows ? contentsWindowsHtml : contents);
assert.equal(clip.get(unicodeFlavor), contentsText);
assert.equal(clip.get(unicodeFullFlavor), contentsText);
};

Просмотреть файл

@ -1,3 +0,0 @@
browser.jar:
% resource app %
defaults/permissions (permissions)

Просмотреть файл

@ -21,6 +21,7 @@ SOURCES += [
FINAL_TARGET_FILES += ['blocklist.xml']
FINAL_TARGET_FILES.defaults.profile += ['profile/prefs.js']
FINAL_TARGET_FILES.defaults += ['permissions']
DEFINES['APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
@ -70,7 +71,5 @@ if CONFIG['MOZ_LINKER']:
if CONFIG['HAVE_CLOCK_MONOTONIC']:
OS_LIBS += CONFIG['REALTIME_LIBS']
JAR_MANIFESTS += ['jar.mn']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']

Просмотреть файл

@ -22,8 +22,9 @@
<script type="application/javascript"><![CDATA[
// Error url MUST be formatted like this:
// about:blocked?e=error_code&u=url
// about:blocked?e=error_code&u=url(&o=1)?
// (o=1 when user overrides are allowed)
// Note that this file uses document.documentURI to get
// the URL (with the format from above). This is because
// document.location.href gets the current URI off the docshell,
@ -55,7 +56,18 @@
url = url.slice(12);
return url;
}
/**
* Check whether this warning page should be overridable or whether
* the "ignore warning" button should be hidden.
*/
function getOverride()
{
var url = document.documentURI;
var match = url.match(/&o=1&/);
return !!match;
}
/**
* Attempt to get the hostname via document.location. Fail back
* to getURL so that we always return something meaningful.
@ -135,6 +147,13 @@
document.title = document.getElementById("errorTitleText_" + error)
.innerHTML;
if (!getOverride()) {
var btn = document.getElementById("ignoreWarningButton");
if (btn) {
btn.parentNode.removeChild(btn);
}
}
// Inform the test harness that we're done loading the page
var event = new CustomEvent("AboutBlockedLoaded");
document.dispatchEvent(event);

Просмотреть файл

@ -2994,10 +2994,12 @@ var BrowserOnClick = {
break;
case "ignoreWarningButton":
if (sendTelemetry) {
secHistogram.add(nsISecTel[bucketName + "IGNORE_WARNING"]);
if (gPrefService.getBoolPref("browser.safebrowsing.allowOverride")) {
if (sendTelemetry) {
secHistogram.add(nsISecTel[bucketName + "IGNORE_WARNING"]);
}
this.ignoreWarningButton(reason);
}
this.ignoreWarningButton(reason);
break;
}
},

Просмотреть файл

@ -192,7 +192,7 @@ function* test_swapped_browser(oldTab, newBrowser, isPlaying) {
});
let AudioPlaybackPromise = new Promise(resolve => {
let observer = (subject, topic, data) => {
ok(false, "Should not see an audio-playback notification");
ok(true, "Should see an audio-playback notification");
};
Services.obs.addObserver(observer, "audio-playback", false);
setTimeout(() => {
@ -207,7 +207,7 @@ function* test_swapped_browser(oldTab, newBrowser, isPlaying) {
ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab");
is(newTab.hasAttribute("soundplaying"), isPlaying, "Expected the correct soundplaying attribute on the new tab");
// Wait to see if an audio-playback event is dispatched. This should not happen!
// Wait to see if an audio-playback event is dispatched.
yield AudioPlaybackPromise;
ok(newTab.hasAttribute("muted"), "Expected the correct muted attribute on the new tab");

Просмотреть файл

@ -14,11 +14,16 @@ add_task(function*() {
yield promiseTabLoadEvent(tab, "data:text/html," + escape(testPage));
yield SimpleTest.promiseFocus(browser.contentWindowAsCPOW);
const modifier = (content.navigator.platform.indexOf("Mac") >= 0) ?
const modifier = (navigator.platform.indexOf("Mac") >= 0) ?
Components.interfaces.nsIDOMWindowUtils.MODIFIER_META :
Components.interfaces.nsIDOMWindowUtils.MODIFIER_CONTROL;
let results = yield ContentTask.spawn(browser, { modifier: modifier },
// On windows, HTML clipboard includes extra data.
// The values are from widget/windows/nsDataObj.cpp.
const htmlPrefix = (navigator.platform.indexOf("Win") >= 0) ? "<html><body>\n<!--StartFragment-->" : "";
const htmlPostfix = (navigator.platform.indexOf("Win") >= 0) ? "<!--EndFragment-->\n</body>\n</html>" : "";
let results = yield ContentTask.spawn(browser, { modifier: modifier, htmlPrefix: htmlPrefix, htmlPostfix: htmlPostfix },
function* (arg) {
var doc = content.document;
var main = doc.getElementById("main");
@ -71,7 +76,7 @@ add_task(function*() {
is(clipboardData.types.length, 2, "Two types on clipboard");
is(clipboardData.types[0], "text/html", "text/html on clipboard");
is(clipboardData.types[1], "text/plain", "text/plain on clipboard");
is(clipboardData.getData("text/html"), "t <b>Bold</b>", "text/html value");
is(clipboardData.getData("text/html"), arg.htmlPrefix + "t <b>Bold</b>" + arg.htmlPostfix, "text/html value");
is(clipboardData.getData("text/plain"), "t Bold", "text/plain value");
resolve();
}, true)
@ -106,7 +111,7 @@ add_task(function*() {
is(clipboardData.types.length, 2, "Two types on clipboard 2");
is(clipboardData.types[0], "text/html", "text/html on clipboard 2");
is(clipboardData.types[1], "text/plain", "text/plain on clipboard 2");
is(clipboardData.getData("text/html"), "<i>Italic</i> ", "text/html value 2");
is(clipboardData.getData("text/html"), arg.htmlPrefix + "<i>Italic</i> " + arg.htmlPostfix, "text/html value 2");
is(clipboardData.getData("text/plain"), "Some text", "text/plain value 2");
resolve();
}, true)
@ -140,7 +145,7 @@ add_task(function*() {
// Focus the content again
yield SimpleTest.promiseFocus(browser.contentWindowAsCPOW);
let expectedContent = yield ContentTask.spawn(browser, { modifier: modifier },
let expectedContent = yield ContentTask.spawn(browser, { modifier: modifier, htmlPrefix: htmlPrefix, htmlPostfix: htmlPostfix },
function* (arg) {
var doc = content.document;
var main = doc.getElementById("main");
@ -153,9 +158,10 @@ add_task(function*() {
// DataTransfer doesn't support the image types yet, so only text/html
// will be present.
if (clipboardData.getData("text/html") !=
'<img id="img" tabindex="1" src="http://example.org/browser/browser/base/content/test/general/moz.png">') {
reject();
if (clipboardData.getData("text/html") !== arg.htmlPrefix +
'<img id="img" tabindex="1" src="http://example.org/browser/browser/base/content/test/general/moz.png">' +
arg.htmlPostfix) {
reject('Clipboard Data did not contain an image, was ' + clipboardData.getData("text/html"));
}
resolve();
}, true)

Просмотреть файл

@ -1,12 +1,17 @@
/* globals ok, equal, RemoteNewTabLocation, NewTabPrefsProvider, Services, Preferences */
/* globals ok, equal, RemoteNewTabLocation, NewTabPrefsProvider, Services, Preferences, XPCOMUtils, UpdateUtils */
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
"use strict";
Components.utils.import("resource:///modules/RemoteNewTabLocation.jsm");
Components.utils.import("resource:///modules/NewTabPrefsProvider.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/Preferences.jsm");
Components.utils.importGlobalProperties(["URL"]);
const {utils: Cu} = Components;
Cu.import("resource:///modules/RemoteNewTabLocation.jsm");
Cu.import("resource:///modules/NewTabPrefsProvider.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.importGlobalProperties(["URL"]);
XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
"resource://gre/modules/UpdateUtils.jsm");
RemoteNewTabLocation.init();
const DEFAULT_HREF = RemoteNewTabLocation.href;
@ -52,9 +57,11 @@ add_task(function* test_overrides() {
add_task(function* test_updates() {
RemoteNewTabLocation.init();
let notificationPromise;
let release = RemoteNewTabLocation._releaseFromUpdateChannel(
UpdateUtils.UpdateChannel);
let expectedHref = "https://newtab.cdn.mozilla.net" +
`/v${RemoteNewTabLocation.version}` +
"/nightly" +
`/${release}` +
"/en-GB" +
"/index.html";
Preferences.set("intl.locale.matchOS", true);

Просмотреть файл

@ -33,7 +33,9 @@ function testMalware(event) {
var style = content.getComputedStyle(el, null);
is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for malware");
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);
// Now launch the unwanted software test
window.addEventListener("DOMContentLoaded", testUnwanted, true);
content.location = "http://www.itisatrap.org/firefox/unwanted.html";
@ -48,10 +50,9 @@ function testUnwanted(event) {
// Confirm that "Ignore this warning" is visible - bug 422410
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for unwanted software");
ok(!el, "Ignore warning button should be missing for unwanted software");
var style = content.getComputedStyle(el, null);
is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for unwanted software");
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true);
// Now launch the phishing test
window.addEventListener("DOMContentLoaded", testPhishing, true);

Просмотреть файл

@ -708,6 +708,7 @@
@RESPATH@/greprefs.js
@RESPATH@/defaults/autoconfig/prefcalls.js
@RESPATH@/browser/defaults/profile/prefs.js
@RESPATH@/browser/defaults/permissions
; Warning: changing the path to channel-prefs.js can cause bugs (Bug 756325)
; Technically this is an app pref file, but we are keeping it in the original

Просмотреть файл

@ -61,7 +61,6 @@ SEARCH_PATHS = [
'python/requests',
'python/slugid',
'build',
'build/pymake',
'config',
'dom/bindings',
'dom/bindings/parser',

Просмотреть файл

@ -89,10 +89,6 @@ leak:MessageLoop::MessageLoop
leak:base::WaitableEvent::TimedWait
leak:MessageLoop::PostTask_Helper
# Bug 1189430 - DNS leaks in mochitest-chrome.
leak:nsDNSService::AsyncResolveExtended
leak:_GetAddrInfo_Portable
# Bug 1189568 - Indirect leaks of IMContextWrapper and nsIntRect.
leak:nsWindow::Create
leak:nsBaseWidget::StoreWindowClipRegion

Просмотреть файл

@ -51,7 +51,7 @@ _SUBDIR_CONFIG_ARGS="$ac_configure_args"
dnl Set the version number of the libs included with mozilla
dnl ========================================================
MOZJPEG=62
MOZPNG=10617
MOZPNG=10619
NSPR_VERSION=4
NSPR_MINVER=4.11
NSS_VERSION=3

Просмотреть файл

@ -5131,6 +5131,8 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
return NS_OK;
}
#define PREF_SAFEBROWSING_ALLOWOVERRIDE "browser.safebrowsing.allowOverride"
NS_IMETHODIMP
nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
const char* aErrorPage,
@ -5209,6 +5211,10 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
errorPageUrl.AppendASCII(escapedError.get());
errorPageUrl.AppendLiteral("&u=");
errorPageUrl.AppendASCII(escapedUrl.get());
if ((strcmp(aErrorPage, "blocked") == 0) &&
Preferences::GetBool(PREF_SAFEBROWSING_ALLOWOVERRIDE, true)) {
errorPageUrl.AppendLiteral("&o=1");
}
if (!escapedCSSClass.IsEmpty()) {
errorPageUrl.AppendLiteral("&s=");
errorPageUrl.AppendASCII(escapedCSSClass.get());

Просмотреть файл

@ -11,9 +11,11 @@
namespace mozilla {
AutoGlobalTimelineMarker::AutoGlobalTimelineMarker(const char* aName
AutoGlobalTimelineMarker::AutoGlobalTimelineMarker(const char* aName,
MarkerStackRequest aStackRequest /* = STACK */
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: mName(aName)
, mStackRequest(aStackRequest)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_ASSERT(NS_IsMainThread());
@ -23,7 +25,7 @@ AutoGlobalTimelineMarker::AutoGlobalTimelineMarker(const char* aName
return;
}
timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::START);
timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::START, mStackRequest);
}
AutoGlobalTimelineMarker::~AutoGlobalTimelineMarker()
@ -35,7 +37,7 @@ AutoGlobalTimelineMarker::~AutoGlobalTimelineMarker()
return;
}
timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::END);
timelines->AddMarkerForAllObservedDocShells(mName, MarkerTracingType::END, mStackRequest);
}
} // namespace mozilla

Просмотреть файл

@ -8,6 +8,7 @@
#define mozilla_AutoGlobalTimelineMarker_h_
#include "mozilla/GuardObjects.h"
#include "TimelineMarkerEnums.h"
namespace mozilla {
@ -32,9 +33,12 @@ class MOZ_RAII AutoGlobalTimelineMarker
// The name of the marker we are adding.
const char* mName;
// Whether to capture the JS stack or not.
MarkerStackRequest mStackRequest;
public:
explicit AutoGlobalTimelineMarker(const char* aName
explicit AutoGlobalTimelineMarker(const char* aName,
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
~AutoGlobalTimelineMarker();

Просмотреть файл

@ -235,7 +235,8 @@ TimelineConsumers::AddMarkerForDocShell(nsIDocShell* aDocShell,
void
TimelineConsumers::AddMarkerForAllObservedDocShells(const char* aName,
MarkerTracingType aTracingType)
MarkerTracingType aTracingType,
MarkerStackRequest aStackRequest /* = STACK */)
{
bool isMainThread = NS_IsMainThread();
StaticMutexAutoLock lock(sMutex); // for `mMarkersStores`.
@ -244,7 +245,7 @@ TimelineConsumers::AddMarkerForAllObservedDocShells(const char* aName,
storage != nullptr;
storage = storage->getNext()) {
UniquePtr<AbstractTimelineMarker> marker =
MakeUnique<TimelineMarker>(aName, aTracingType);
MakeUnique<TimelineMarker>(aName, aTracingType, aStackRequest);
if (isMainThread) {
storage->AddMarker(Move(marker));
} else {
@ -256,7 +257,8 @@ TimelineConsumers::AddMarkerForAllObservedDocShells(const char* aName,
void
TimelineConsumers::AddMarkerForAllObservedDocShells(const char* aName,
const TimeStamp& aTime,
MarkerTracingType aTracingType)
MarkerTracingType aTracingType,
MarkerStackRequest aStackRequest /* = STACK */)
{
bool isMainThread = NS_IsMainThread();
StaticMutexAutoLock lock(sMutex); // for `mMarkersStores`.
@ -265,7 +267,7 @@ TimelineConsumers::AddMarkerForAllObservedDocShells(const char* aName,
storage != nullptr;
storage = storage->getNext()) {
UniquePtr<AbstractTimelineMarker> marker =
MakeUnique<TimelineMarker>(aName, aTime, aTracingType);
MakeUnique<TimelineMarker>(aName, aTime, aTracingType, aStackRequest);
if (isMainThread) {
storage->AddMarker(Move(marker));
} else {

Просмотреть файл

@ -92,10 +92,12 @@ public:
// which doesn't have to be relevant to a specific docshell.
// May be called from any thread.
void AddMarkerForAllObservedDocShells(const char* aName,
MarkerTracingType aTracingType);
MarkerTracingType aTracingType,
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
void AddMarkerForAllObservedDocShells(const char* aName,
const TimeStamp& aTime,
MarkerTracingType aTracingType);
MarkerTracingType aTracingType,
MarkerStackRequest aStackRequest = MarkerStackRequest::STACK);
// This method clones and registers an already instantiated marker,
// which doesn't have to be relevant to a specific docshell.

Просмотреть файл

@ -5,6 +5,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/KeyframeEffect.h"
#include "mozilla/dom/AnimationEffectReadOnlyBinding.h"
#include "mozilla/dom/KeyframeEffectBinding.h"
#include "mozilla/dom/PropertyIndexedKeyframesBinding.h"
@ -22,43 +23,21 @@
namespace mozilla {
bool
AnimationTiming::FillsForwards() const
{
return mFillMode == dom::FillMode::Both ||
mFillMode == dom::FillMode::Forwards;
}
bool
AnimationTiming::FillsBackwards() const
{
return mFillMode == dom::FillMode::Both ||
mFillMode == dom::FillMode::Backwards;
}
// Helper functions for generating a ComputedTimingProperties dictionary
static dom::FillMode
ConvertFillMode(uint8_t aFill)
{
switch (aFill) {
case NS_STYLE_ANIMATION_FILL_MODE_NONE:
return dom::FillMode::None;
case NS_STYLE_ANIMATION_FILL_MODE_FORWARDS:
return dom::FillMode::Forwards;
case NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS:
return dom::FillMode::Backwards;
case NS_STYLE_ANIMATION_FILL_MODE_BOTH:
return dom::FillMode::Both;
default:
MOZ_ASSERT(false, "The mapping of FillMode is not correct");
return dom::FillMode::None;
}
}
static dom::PlaybackDirection
ConvertPlaybackDirection(uint8_t aDirection)
{
switch (aDirection) {
case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
return dom::PlaybackDirection::Normal;
case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
return dom::PlaybackDirection::Reverse;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
return dom::PlaybackDirection::Alternate;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
return dom::PlaybackDirection::Alternate_reverse;
default:
MOZ_ASSERT(false, "The mapping of PlaybackDirection is not correct");
return dom::PlaybackDirection::Normal;
}
}
static void
GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
const Nullable<TimeDuration>& aLocalTime,
@ -67,10 +46,10 @@ GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
{
// AnimationEffectTimingProperties
aRetVal.mDelay = aTiming.mDelay.ToMilliseconds();
aRetVal.mFill = ConvertFillMode(aTiming.mFillMode);
aRetVal.mFill = aTiming.mFillMode;
aRetVal.mIterations = aTiming.mIterationCount;
aRetVal.mDuration.SetAsUnrestrictedDouble() = aTiming.mIterationDuration.ToMilliseconds();
aRetVal.mDirection = ConvertPlaybackDirection(aTiming.mDirection);
aRetVal.mDirection = aTiming.mDirection;
// ComputedTimingProperties
aRetVal.mActiveDuration = aComputedTiming.mActiveDuration.ToMilliseconds();
@ -126,6 +105,18 @@ KeyframeEffectReadOnly::WrapObject(JSContext* aCx,
return KeyframeEffectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
}
IterationCompositeOperation
KeyframeEffectReadOnly::IterationComposite() const
{
return IterationCompositeOperation::Replace;
}
CompositeOperation
KeyframeEffectReadOnly::Composite() const
{
return CompositeOperation::Replace;
}
void
KeyframeEffectReadOnly::SetTiming(const AnimationTiming& aTiming)
{
@ -271,18 +262,20 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
bool thisIterationReverse = false;
switch (aTiming.mDirection) {
case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
case PlaybackDirection::Normal:
thisIterationReverse = false;
break;
case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
case PlaybackDirection::Reverse:
thisIterationReverse = true;
break;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
case PlaybackDirection::Alternate:
thisIterationReverse = (result.mCurrentIteration & 1) == 1;
break;
case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
case PlaybackDirection::Alternate_reverse:
thisIterationReverse = (result.mCurrentIteration & 1) == 0;
break;
default:
MOZ_ASSERT(true, "Unknown PlaybackDirection type");
}
if (thisIterationReverse) {
result.mProgress.SetValue(1.0 - result.mProgress.Value());
@ -554,25 +547,52 @@ DumpAnimationProperties(nsTArray<AnimationProperty>& aAnimationProperties)
}
#endif
// Extract an iteration duration from an UnrestrictedDoubleOrXXX object.
template <typename T>
static TimeDuration
GetIterationDuration(const T& aDuration) {
// Always return the same object to benefit from return-value optimization.
TimeDuration result;
if (aDuration.IsUnrestrictedDouble()) {
double durationMs = aDuration.GetAsUnrestrictedDouble();
if (!IsNaN(durationMs) && durationMs >= 0.0f) {
result = TimeDuration::FromMilliseconds(durationMs);
}
}
// else, aDuration should be zero
return result;
}
/* static */ AnimationTiming
KeyframeEffectReadOnly::ConvertKeyframeEffectOptions(
const Optional<double>& aOptions)
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions)
{
AnimationTiming animationTiming;
// The spec says to treat auto durations as 0 until a later version of
// the spec says otherwise. Bug 1215406 is for handling a
// KeyframeEffectOptions object and not just an offset.
if (aOptions.WasPassed()) {
animationTiming.mIterationDuration =
TimeDuration::FromMilliseconds(aOptions.Value());
} else {
animationTiming.mIterationDuration = TimeDuration(0);
}
animationTiming.mIterationCount = 1.0f;
animationTiming.mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
animationTiming.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_NONE;
if (aOptions.IsKeyframeEffectOptions()) {
const KeyframeEffectOptions& opt = aOptions.GetAsKeyframeEffectOptions();
animationTiming.mIterationDuration = GetIterationDuration(opt.mDuration);
animationTiming.mDelay = TimeDuration::FromMilliseconds(opt.mDelay);
// FIXME: Covert mIterationCount to a valid value.
// Bug 1214536 should revise this and keep the original value, so
// AnimationTimingEffectReadOnly can get the original iterations.
animationTiming.mIterationCount = (IsNaN(opt.mIterations) ||
opt.mIterations < 0.0f) ?
1.0f :
opt.mIterations;
animationTiming.mDirection = opt.mDirection;
// FIXME: We should store original value.
animationTiming.mFillMode = (opt.mFill == FillMode::Auto) ?
FillMode::None :
opt.mFill;
} else {
animationTiming.mIterationDuration = GetIterationDuration(aOptions);
animationTiming.mDelay = TimeDuration(0);
animationTiming.mIterationCount = 1.0f;
animationTiming.mDirection = PlaybackDirection::Normal;
animationTiming.mFillMode = FillMode::None;
}
return animationTiming;
}
@ -1600,7 +1620,7 @@ KeyframeEffectReadOnly::Constructor(
const GlobalObject& aGlobal,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
const Optional<double>& aOptions,
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
ErrorResult& aRv)
{
if (!aTarget) {

Просмотреть файл

@ -37,6 +37,9 @@ class AnimValuesStyleRule;
namespace dom {
struct ComputedTimingProperties;
class UnrestrictedDoubleOrKeyframeEffectOptions;
enum class IterationCompositeOperation : uint32_t;
enum class CompositeOperation : uint32_t;
}
/**
@ -51,17 +54,11 @@ struct AnimationTiming
TimeDuration mIterationDuration;
TimeDuration mDelay;
float mIterationCount; // mozilla::PositiveInfinity<float>() means infinite
uint8_t mDirection;
uint8_t mFillMode;
dom::PlaybackDirection mDirection;
dom::FillMode mFillMode;
bool FillsForwards() const {
return mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BOTH ||
mFillMode == NS_STYLE_ANIMATION_FILL_MODE_FORWARDS;
}
bool FillsBackwards() const {
return mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BOTH ||
mFillMode == NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS;
}
bool FillsForwards() const;
bool FillsBackwards() const;
bool operator==(const AnimationTiming& aOther) const {
return mIterationDuration == aOther.mIterationDuration &&
mDelay == aOther.mDelay &&
@ -190,7 +187,7 @@ public:
Constructor(const GlobalObject& aGlobal,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
const Optional<double>& aOptions,
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
ErrorResult& aRv);
Element* GetTarget() const {
// Currently we never return animations from the API whose effect
@ -213,12 +210,14 @@ public:
aPseudoType = mPseudoType;
}
const AnimationTiming& Timing() const {
return mTiming;
}
AnimationTiming& Timing() {
return mTiming;
IterationCompositeOperation IterationComposite() const;
CompositeOperation Composite() const;
void GetSpacing(nsString& aRetVal) const {
aRetVal.AssignLiteral("distribute");
}
const AnimationTiming& Timing() const { return mTiming; }
AnimationTiming& Timing() { return mTiming; }
void SetTiming(const AnimationTiming& aTiming);
Nullable<TimeDuration> GetLocalTime() const;
@ -299,13 +298,14 @@ protected:
void ResetIsRunningOnCompositor();
static AnimationTiming ConvertKeyframeEffectOptions(
const Optional<double>& aOptions);
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions);
static void BuildAnimationPropertyList(
JSContext* aCx,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv);
JSContext* aCx,
Element* aTarget,
const Optional<JS::Handle<JSObject*>>& aFrames,
InfallibleTArray<AnimationProperty>& aResult,
ErrorResult& aRv);
nsCOMPtr<Element> mTarget;
RefPtr<Animation> mAnimation;

Просмотреть файл

@ -309,7 +309,9 @@ private:
MOZ_ASSERT(aWindow->IsInnerWindow());
nsPIDOMWindow* outerWindow = aWindow->GetOuterWindow();
MOZ_ASSERT(outerWindow);
if (NS_WARN_IF(!outerWindow)) {
return;
}
RunConsole(jsapi.cx(), outerWindow, aWindow);
}
@ -695,9 +697,13 @@ Console::Console(nsPIDOMWindow* aWindow)
MOZ_ASSERT(mWindow->IsInnerWindow());
mInnerID = mWindow->WindowID();
// Without outerwindow any console message coming from this object will not
// shown in the devtools webconsole. But this should be fine because
// probably we are shutting down, or the window is CCed/GCed.
nsPIDOMWindow* outerWindow = mWindow->GetOuterWindow();
MOZ_ASSERT(outerWindow);
mOuterID = outerWindow->WindowID();
if (outerWindow) {
mOuterID = outerWindow->WindowID();
}
}
if (NS_IsMainThread()) {

Просмотреть файл

@ -130,7 +130,7 @@ Link::GetURI() const
}
void
Link::SetProtocol(const nsAString &aProtocol, ErrorResult& aError)
Link::SetProtocol(const nsAString &aProtocol)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -149,7 +149,7 @@ Link::SetProtocol(const nsAString &aProtocol, ErrorResult& aError)
}
void
Link::SetPassword(const nsAString &aPassword, ErrorResult& aError)
Link::SetPassword(const nsAString &aPassword)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -162,7 +162,7 @@ Link::SetPassword(const nsAString &aPassword, ErrorResult& aError)
}
void
Link::SetUsername(const nsAString &aUsername, ErrorResult& aError)
Link::SetUsername(const nsAString &aUsername)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -175,7 +175,7 @@ Link::SetUsername(const nsAString &aUsername, ErrorResult& aError)
}
void
Link::SetHost(const nsAString &aHost, ErrorResult& aError)
Link::SetHost(const nsAString &aHost)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -188,7 +188,7 @@ Link::SetHost(const nsAString &aHost, ErrorResult& aError)
}
void
Link::SetHostname(const nsAString &aHostname, ErrorResult& aError)
Link::SetHostname(const nsAString &aHostname)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -201,7 +201,7 @@ Link::SetHostname(const nsAString &aHostname, ErrorResult& aError)
}
void
Link::SetPathname(const nsAString &aPathname, ErrorResult& aError)
Link::SetPathname(const nsAString &aPathname)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
@ -215,14 +215,7 @@ Link::SetPathname(const nsAString &aPathname, ErrorResult& aError)
}
void
Link::SetSearch(const nsAString& aSearch, ErrorResult& aError)
{
SetSearchInternal(aSearch);
UpdateURLSearchParams();
}
void
Link::SetSearchInternal(const nsAString& aSearch)
Link::SetSearch(const nsAString& aSearch)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
@ -236,7 +229,7 @@ Link::SetSearchInternal(const nsAString& aSearch)
}
void
Link::SetPort(const nsAString &aPort, ErrorResult& aError)
Link::SetPort(const nsAString &aPort)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -261,7 +254,7 @@ Link::SetPort(const nsAString &aPort, ErrorResult& aError)
}
void
Link::SetHash(const nsAString &aHash, ErrorResult& aError)
Link::SetHash(const nsAString &aHash)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
@ -274,7 +267,7 @@ Link::SetHash(const nsAString &aHash, ErrorResult& aError)
}
void
Link::GetOrigin(nsAString &aOrigin, ErrorResult& aError)
Link::GetOrigin(nsAString &aOrigin)
{
aOrigin.Truncate();
@ -289,7 +282,7 @@ Link::GetOrigin(nsAString &aOrigin, ErrorResult& aError)
}
void
Link::GetProtocol(nsAString &_protocol, ErrorResult& aError)
Link::GetProtocol(nsAString &_protocol)
{
nsCOMPtr<nsIURI> uri(GetURI());
if (!uri) {
@ -301,11 +294,10 @@ Link::GetProtocol(nsAString &_protocol, ErrorResult& aError)
CopyASCIItoUTF16(scheme, _protocol);
}
_protocol.Append(char16_t(':'));
return;
}
void
Link::GetUsername(nsAString& aUsername, ErrorResult& aError)
Link::GetUsername(nsAString& aUsername)
{
aUsername.Truncate();
@ -320,7 +312,7 @@ Link::GetUsername(nsAString& aUsername, ErrorResult& aError)
}
void
Link::GetPassword(nsAString &aPassword, ErrorResult& aError)
Link::GetPassword(nsAString &aPassword)
{
aPassword.Truncate();
@ -335,7 +327,7 @@ Link::GetPassword(nsAString &aPassword, ErrorResult& aError)
}
void
Link::GetHost(nsAString &_host, ErrorResult& aError)
Link::GetHost(nsAString &_host)
{
_host.Truncate();
@ -353,7 +345,7 @@ Link::GetHost(nsAString &_host, ErrorResult& aError)
}
void
Link::GetHostname(nsAString &_hostname, ErrorResult& aError)
Link::GetHostname(nsAString &_hostname)
{
_hostname.Truncate();
@ -367,7 +359,7 @@ Link::GetHostname(nsAString &_hostname, ErrorResult& aError)
}
void
Link::GetPathname(nsAString &_pathname, ErrorResult& aError)
Link::GetPathname(nsAString &_pathname)
{
_pathname.Truncate();
@ -387,7 +379,7 @@ Link::GetPathname(nsAString &_pathname, ErrorResult& aError)
}
void
Link::GetSearch(nsAString &_search, ErrorResult& aError)
Link::GetSearch(nsAString &_search)
{
_search.Truncate();
@ -407,7 +399,7 @@ Link::GetSearch(nsAString &_search, ErrorResult& aError)
}
void
Link::GetPort(nsAString &_port, ErrorResult& aError)
Link::GetPort(nsAString &_port)
{
_port.Truncate();
@ -429,7 +421,7 @@ Link::GetPort(nsAString &_port, ErrorResult& aError)
}
void
Link::GetHash(nsAString &_hash, ErrorResult& aError)
Link::GetHash(nsAString &_hash)
{
_hash.Truncate();
@ -482,7 +474,6 @@ Link::ResetLinkState(bool aNotify, bool aHasHref)
// If we've cached the URI, reset always invalidates it.
mCachedURI = nullptr;
UpdateURLSearchParams();
// Update our state back to the default.
mLinkState = defaultState;
@ -571,67 +562,5 @@ Link::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
return n;
}
URLSearchParams*
Link::SearchParams()
{
CreateSearchParamsIfNeeded();
return mSearchParams;
}
void
Link::URLSearchParamsUpdated(URLSearchParams* aSearchParams)
{
MOZ_ASSERT(mSearchParams);
MOZ_ASSERT(mSearchParams == aSearchParams);
nsString search;
mSearchParams->Serialize(search);
SetSearchInternal(search);
}
void
Link::UpdateURLSearchParams()
{
if (!mSearchParams) {
return;
}
nsAutoCString search;
nsCOMPtr<nsIURI> uri(GetURI());
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
if (url) {
nsresult rv = url->GetQuery(search);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to get the query from a nsIURL.");
}
}
mSearchParams->ParseInput(search);
}
void
Link::CreateSearchParamsIfNeeded()
{
if (!mSearchParams) {
mSearchParams = new URLSearchParams(this, this);
UpdateURLSearchParams();
}
}
void
Link::Unlink()
{
if (mSearchParams) {
mSearchParams = nullptr;
}
}
void
Link::Traverse(nsCycleCollectionTraversalCallback &cb)
{
Link* tmp = this;
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSearchParams);
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -13,7 +13,6 @@
#include "mozilla/IHistory.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/URLSearchParams.h"
#include "nsIContent.h" // for nsLinkState
namespace mozilla {
@ -28,7 +27,7 @@ class Element;
{ 0xb25edee6, 0xdd35, 0x4f8b, \
{ 0xab, 0x90, 0x66, 0xd0, 0xbd, 0x3c, 0x22, 0xd5 } }
class Link : public URLSearchParamsObserver
class Link : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_LINK_IMPLEMENTATION_IID)
@ -57,26 +56,25 @@ public:
/**
* Helper methods for modifying and obtaining parts of the URI of the Link.
*/
void SetProtocol(const nsAString &aProtocol, ErrorResult& aError);
void SetUsername(const nsAString &aUsername, ErrorResult& aError);
void SetPassword(const nsAString &aPassword, ErrorResult& aError);
void SetHost(const nsAString &aHost, ErrorResult& aError);
void SetHostname(const nsAString &aHostname, ErrorResult& aError);
void SetPathname(const nsAString &aPathname, ErrorResult& aError);
void SetSearch(const nsAString &aSearch, ErrorResult& aError);
void SetPort(const nsAString &aPort, ErrorResult& aError);
void SetHash(const nsAString &aHash, ErrorResult& aError);
void GetOrigin(nsAString &aOrigin, ErrorResult& aError);
void GetProtocol(nsAString &_protocol, ErrorResult& aError);
void GetUsername(nsAString &aUsername, ErrorResult& aError);
void GetPassword(nsAString &aPassword, ErrorResult& aError);
void GetHost(nsAString &_host, ErrorResult& aError);
void GetHostname(nsAString &_hostname, ErrorResult& aError);
void GetPathname(nsAString &_pathname, ErrorResult& aError);
void GetSearch(nsAString &_search, ErrorResult& aError);
URLSearchParams* SearchParams();
void GetPort(nsAString &_port, ErrorResult& aError);
void GetHash(nsAString &_hash, ErrorResult& aError);
void SetProtocol(const nsAString &aProtocol);
void SetUsername(const nsAString &aUsername);
void SetPassword(const nsAString &aPassword);
void SetHost(const nsAString &aHost);
void SetHostname(const nsAString &aHostname);
void SetPathname(const nsAString &aPathname);
void SetSearch(const nsAString &aSearch);
void SetPort(const nsAString &aPort);
void SetHash(const nsAString &aHash);
void GetOrigin(nsAString &aOrigin);
void GetProtocol(nsAString &_protocol);
void GetUsername(nsAString &aUsername);
void GetPassword(nsAString &aPassword);
void GetHost(nsAString &_host);
void GetHostname(nsAString &_hostname);
void GetPathname(nsAString &_pathname);
void GetSearch(nsAString &_search);
void GetPort(nsAString &_port);
void GetHash(nsAString &_hash);
/**
* Invalidates any link caching, and resets the state to the default.
@ -113,9 +111,6 @@ public:
bool ElementHasHref() const;
// URLSearchParamsObserver
void URLSearchParamsUpdated(URLSearchParams* aSearchParams) override;
protected:
virtual ~Link();
@ -134,12 +129,6 @@ protected:
nsIURI* GetCachedURI() const { return mCachedURI; }
bool HasCachedURI() const { return !!mCachedURI; }
void UpdateURLSearchParams();
// CC methods
void Unlink();
void Traverse(nsCycleCollectionTraversalCallback &cb);
private:
/**
* Unregisters from History so this node no longer gets notifications about
@ -150,10 +139,6 @@ private:
already_AddRefed<nsIURI> GetURIToMutate();
void SetHrefAttribute(nsIURI *aURI);
void CreateSearchParamsIfNeeded();
void SetSearchInternal(const nsAString& aSearch);
mutable nsCOMPtr<nsIURI> mCachedURI;
Element * const mElement;
@ -167,9 +152,6 @@ private:
bool mNeedsRegistration;
bool mRegistered;
protected:
RefPtr<URLSearchParams> mSearchParams;
};
NS_DEFINE_STATIC_IID_ACCESSOR(Link, MOZILLA_DOM_LINK_IMPLEMENTATION_IID)

Просмотреть файл

@ -2506,13 +2506,13 @@ Navigator::HasDataStoreSupport(nsIPrincipal* aPrincipal)
// A WorkerMainThreadRunnable to synchronously dispatch the call of
// HasDataStoreSupport() from the worker thread to the main thread.
class HasDataStoreSupportRunnable final
: public workers::WorkerMainThreadRunnable
: public workers::WorkerCheckAPIExposureOnMainThreadRunnable
{
public:
bool mResult;
explicit HasDataStoreSupportRunnable(workers::WorkerPrivate* aWorkerPrivate)
: workers::WorkerMainThreadRunnable(aWorkerPrivate)
: workers::WorkerCheckAPIExposureOnMainThreadRunnable(aWorkerPrivate)
, mResult(false)
{
MOZ_ASSERT(aWorkerPrivate);
@ -2543,9 +2543,7 @@ Navigator::HasDataStoreSupport(JSContext* aCx, JSObject* aGlobal)
RefPtr<HasDataStoreSupportRunnable> runnable =
new HasDataStoreSupportRunnable(workerPrivate);
runnable->Dispatch(aCx);
return runnable->mResult;
return runnable->Dispatch() && runnable->mResult;
}
workers::AssertIsOnMainThread();

Просмотреть файл

@ -23,7 +23,7 @@ NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil)
//
// NSPR_LOG_MODULES=thirdPartyUtil:5
//
static PRLogModuleInfo *gThirdPartyLog;
static mozilla::LazyLogModule gThirdPartyLog("thirdPartyUtil");
#undef LOG
#define LOG(args) MOZ_LOG(gThirdPartyLog, mozilla::LogLevel::Debug, args)
@ -35,9 +35,6 @@ ThirdPartyUtil::Init()
nsresult rv;
mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv);
if (!gThirdPartyLog)
gThirdPartyLog = PR_NewLogModule("thirdPartyUtil");
return rv;
}

Просмотреть файл

@ -203,7 +203,7 @@ URL::RevokeObjectURL(const GlobalObject& aGlobal, const nsAString& aURL,
}
void
URL::GetHref(nsAString& aHref, ErrorResult& aRv) const
URL::GetHref(nsAString& aHref) const
{
aHref.Truncate();
@ -238,13 +238,13 @@ URL::SetHref(const nsAString& aHref, ErrorResult& aRv)
}
void
URL::GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const
URL::GetOrigin(nsAString& aOrigin) const
{
nsContentUtils::GetUTFOrigin(mURI, aOrigin);
}
void
URL::GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const
URL::GetProtocol(nsAString& aProtocol) const
{
nsAutoCString protocol;
if (NS_SUCCEEDED(mURI->GetScheme(protocol))) {
@ -256,7 +256,7 @@ URL::GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const
}
void
URL::SetProtocol(const nsAString& aProtocol, ErrorResult& aRv)
URL::SetProtocol(const nsAString& aProtocol)
{
nsAString::const_iterator start, end;
aProtocol.BeginReading(start);
@ -303,37 +303,37 @@ URL::SetProtocol(const nsAString& aProtocol, ErrorResult& aRv)
}
void
URL::GetUsername(nsAString& aUsername, ErrorResult& aRv) const
URL::GetUsername(nsAString& aUsername) const
{
URL_GETTER(aUsername, GetUsername);
}
void
URL::SetUsername(const nsAString& aUsername, ErrorResult& aRv)
URL::SetUsername(const nsAString& aUsername)
{
mURI->SetUsername(NS_ConvertUTF16toUTF8(aUsername));
}
void
URL::GetPassword(nsAString& aPassword, ErrorResult& aRv) const
URL::GetPassword(nsAString& aPassword) const
{
URL_GETTER(aPassword, GetPassword);
}
void
URL::SetPassword(const nsAString& aPassword, ErrorResult& aRv)
URL::SetPassword(const nsAString& aPassword)
{
mURI->SetPassword(NS_ConvertUTF16toUTF8(aPassword));
}
void
URL::GetHost(nsAString& aHost, ErrorResult& aRv) const
URL::GetHost(nsAString& aHost) const
{
URL_GETTER(aHost, GetHostPort);
}
void
URL::SetHost(const nsAString& aHost, ErrorResult& aRv)
URL::SetHost(const nsAString& aHost)
{
mURI->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
}
@ -369,14 +369,14 @@ URL::UpdateURLSearchParams()
}
void
URL::GetHostname(nsAString& aHostname, ErrorResult& aRv) const
URL::GetHostname(nsAString& aHostname) const
{
aHostname.Truncate();
nsContentUtils::GetHostOrIPv6WithBrackets(mURI, aHostname);
}
void
URL::SetHostname(const nsAString& aHostname, ErrorResult& aRv)
URL::SetHostname(const nsAString& aHostname)
{
// nsStandardURL returns NS_ERROR_UNEXPECTED for an empty hostname
// The return code is silently ignored
@ -384,7 +384,7 @@ URL::SetHostname(const nsAString& aHostname, ErrorResult& aRv)
}
void
URL::GetPort(nsAString& aPort, ErrorResult& aRv) const
URL::GetPort(nsAString& aPort) const
{
aPort.Truncate();
@ -398,7 +398,7 @@ URL::GetPort(nsAString& aPort, ErrorResult& aRv) const
}
void
URL::SetPort(const nsAString& aPort, ErrorResult& aRv)
URL::SetPort(const nsAString& aPort)
{
nsresult rv;
nsAutoString portStr(aPort);
@ -416,7 +416,7 @@ URL::SetPort(const nsAString& aPort, ErrorResult& aRv)
}
void
URL::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
URL::GetPathname(nsAString& aPathname) const
{
aPathname.Truncate();
@ -442,7 +442,7 @@ URL::GetPathname(nsAString& aPathname, ErrorResult& aRv) const
}
void
URL::SetPathname(const nsAString& aPathname, ErrorResult& aRv)
URL::SetPathname(const nsAString& aPathname)
{
nsCOMPtr<nsIURL> url(do_QueryInterface(mURI));
if (!url) {
@ -454,7 +454,7 @@ URL::SetPathname(const nsAString& aPathname, ErrorResult& aRv)
}
void
URL::GetSearch(nsAString& aSearch, ErrorResult& aRv) const
URL::GetSearch(nsAString& aSearch) const
{
aSearch.Truncate();
@ -473,7 +473,7 @@ URL::GetSearch(nsAString& aSearch, ErrorResult& aRv) const
}
void
URL::SetSearch(const nsAString& aSearch, ErrorResult& aRv)
URL::SetSearch(const nsAString& aSearch)
{
SetSearchInternal(aSearch);
UpdateURLSearchParams();
@ -499,7 +499,7 @@ URL::SearchParams()
}
void
URL::GetHash(nsAString& aHash, ErrorResult& aRv) const
URL::GetHash(nsAString& aHash) const
{
aHash.Truncate();
@ -515,7 +515,7 @@ URL::GetHash(nsAString& aHash, ErrorResult& aRv) const
}
void
URL::SetHash(const nsAString& aHash, ErrorResult& aRv)
URL::SetHash(const nsAString& aHash)
{
mURI->SetRef(NS_ConvertUTF16toUTF8(aHash));
}

Просмотреть файл

@ -88,53 +88,53 @@ public:
const nsAString& aURL,
ErrorResult& aRv);
void GetHref(nsAString& aHref, ErrorResult& aRv) const;
void GetHref(nsAString& aHref) const;
void SetHref(const nsAString& aHref, ErrorResult& aRv);
void GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const;
void GetOrigin(nsAString& aOrigin) const;
void GetProtocol(nsAString& aProtocol, ErrorResult& aRv) const;
void GetProtocol(nsAString& aProtocol) const;
void SetProtocol(const nsAString& aProtocol, ErrorResult& aRv);
void SetProtocol(const nsAString& aProtocol);
void GetUsername(nsAString& aUsername, ErrorResult& aRv) const;
void GetUsername(nsAString& aUsername) const;
void SetUsername(const nsAString& aUsername, ErrorResult& aRv);
void SetUsername(const nsAString& aUsername);
void GetPassword(nsAString& aPassword, ErrorResult& aRv) const;
void GetPassword(nsAString& aPassword) const;
void SetPassword(const nsAString& aPassword, ErrorResult& aRv);
void SetPassword(const nsAString& aPassword);
void GetHost(nsAString& aHost, ErrorResult& aRv) const;
void GetHost(nsAString& aHost) const;
void SetHost(const nsAString& aHost, ErrorResult& aRv);
void SetHost(const nsAString& aHost);
void GetHostname(nsAString& aHostname, ErrorResult& aRv) const;
void GetHostname(nsAString& aHostname) const;
void SetHostname(const nsAString& aHostname, ErrorResult& aRv);
void SetHostname(const nsAString& aHostname);
void GetPort(nsAString& aPort, ErrorResult& aRv) const;
void GetPort(nsAString& aPort) const;
void SetPort(const nsAString& aPort, ErrorResult& aRv);
void SetPort(const nsAString& aPort);
void GetPathname(nsAString& aPathname, ErrorResult& aRv) const;
void GetPathname(nsAString& aPathname) const;
void SetPathname(const nsAString& aPathname, ErrorResult& aRv);
void SetPathname(const nsAString& aPathname);
void GetSearch(nsAString& aRetval, ErrorResult& aRv) const;
void GetSearch(nsAString& aRetval) const;
void SetSearch(const nsAString& aArg, ErrorResult& aRv);
void SetSearch(const nsAString& aArg);
URLSearchParams* SearchParams();
void GetHash(nsAString& aRetval, ErrorResult& aRv) const;
void GetHash(nsAString& aRetval) const;
void SetHash(const nsAString& aArg, ErrorResult& aRv);
void SetHash(const nsAString& aArg);
void Stringify(nsAString& aRetval, ErrorResult& aRv) const
void Stringify(nsAString& aRetval) const
{
GetHref(aRetval, aRv);
GetHref(aRetval);
}
// URLSearchParamsObserver

Просмотреть файл

@ -138,14 +138,14 @@ public:
const nsACString& aReasonString = EmptyCString());
nsresult CloseConnection(uint16_t reasonCode,
const nsACString& aReasonString = EmptyCString());
nsresult Disconnect();
void Disconnect();
void DisconnectInternal();
nsresult ConsoleError();
nsresult PrintErrorOnConsole(const char* aBundleURI,
const char16_t* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen);
void PrintErrorOnConsole(const char* aBundleURI,
const char16_t* aError,
const char16_t** aFormatStrings,
uint32_t aFormatStringsLen);
nsresult DoOnMessageAvailable(const nsACString& aMsg,
bool isBinary);
@ -301,21 +301,15 @@ public:
, mError(aError)
, mFormatStrings(aFormatStrings)
, mFormatStringsLen(aFormatStringsLen)
, mRv(NS_ERROR_FAILURE)
{ }
bool MainThreadRun() override
{
mRv = mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
mFormatStringsLen);
mImpl->PrintErrorOnConsole(mBundleURI, mError, mFormatStrings,
mFormatStringsLen);
return true;
}
nsresult ErrorCode() const
{
return mRv;
}
private:
// Raw pointer because this runnable is sync.
WebSocketImpl* mImpl;
@ -324,12 +318,11 @@ private:
const char16_t* mError;
const char16_t** mFormatStrings;
uint32_t mFormatStringsLen;
nsresult mRv;
};
} // namespace
nsresult
void
WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
const char16_t *aError,
const char16_t **aFormatStrings,
@ -343,26 +336,32 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
RefPtr<PrintErrorOnConsoleRunnable> runnable =
new PrintErrorOnConsoleRunnable(this, aBundleURI, aError, aFormatStrings,
aFormatStringsLen);
runnable->Dispatch(mWorkerPrivate->GetJSContext());
return runnable->ErrorCode();
ErrorResult rv;
runnable->Dispatch(rv);
// XXXbz this seems totally broken. We should be propagating this out, but
// none of our callers really propagate anything usefully. Come to think of
// it, why is this a syncrunnable anyway? Can't this be a fire-and-forget
// runnable??
rv.SuppressException();
return;
}
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIStringBundle> strBundle;
rv = bundleService->CreateBundle(aBundleURI, getter_AddRefs(strBundle));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIConsoleService> console(
do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
nsCOMPtr<nsIScriptError> errorObject(
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
// Localize the error message
nsXPIDLString message;
@ -373,7 +372,7 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
} else {
rv = strBundle->GetStringFromName(aError, getter_Copies(message));
}
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
if (mInnerWindowID) {
rv = errorObject->InitWithWindowID(message,
@ -389,13 +388,11 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
nsIScriptError::errorFlag, "Web Socket");
}
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS_VOID(rv);
// print the error message directly to the JS console
rv = console->LogMessage(errorObject);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
NS_ENSURE_SUCCESS_VOID(rv);
}
namespace {
@ -603,11 +600,11 @@ private:
} // namespace
nsresult
void
WebSocketImpl::Disconnect()
{
if (mDisconnectingOrDisconnected) {
return NS_OK;
return;
}
AssertIsOnTargetThread();
@ -626,7 +623,11 @@ WebSocketImpl::Disconnect()
} else {
RefPtr<DisconnectInternalRunnable> runnable =
new DisconnectInternalRunnable(this);
runnable->Dispatch(mWorkerPrivate->GetJSContext());
ErrorResult rv;
runnable->Dispatch(rv);
// XXXbz this seems totally broken. We should be propagating this out, but
// where to, exactly?
rv.SuppressException();
}
// DontKeepAliveAnyMore() can release the object. So hold a reference to this
@ -645,8 +646,6 @@ WebSocketImpl::Disconnect()
// We want to release the WebSocket in the correct thread.
mWebSocket = nullptr;
return NS_OK;
}
void
@ -1270,7 +1269,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
new InitRunnable(webSocket->mImpl, aUrl, protocolArray,
nsAutoCString(file.get()), lineno, column, aRv,
&connectionFailed);
runnable->Dispatch(aGlobal.Context());
runnable->Dispatch(aRv);
}
if (NS_WARN_IF(aRv.Failed())) {
@ -1350,7 +1349,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
} else {
RefPtr<AsyncOpenRunnable> runnable =
new AsyncOpenRunnable(webSocket->mImpl, aRv);
runnable->Dispatch(aGlobal.Context());
runnable->Dispatch(aRv);
}
if (NS_WARN_IF(aRv.Failed())) {

Просмотреть файл

@ -30,7 +30,7 @@ using mozilla::LogLevel;
NS_IMPL_ISUPPORTS(nsContentPolicy, nsIContentPolicy)
static PRLogModuleInfo* gConPolLog;
static mozilla::LazyLogModule gConPolLog("nsContentPolicy");
nsresult
NS_NewContentPolicy(nsIContentPolicy **aResult)
@ -44,9 +44,6 @@ nsContentPolicy::nsContentPolicy()
: mPolicies(NS_CONTENTPOLICY_CATEGORY)
, mSimplePolicies(NS_SIMPLECONTENTPOLICY_CATEGORY)
{
if (! gConPolLog) {
gConPolLog = PR_NewLogModule("nsContentPolicy");
}
}
nsContentPolicy::~nsContentPolicy()

Просмотреть файл

@ -51,19 +51,16 @@
#include "nsParserConstants.h"
#include "nsSandboxFlags.h"
static PRLogModuleInfo*
using namespace mozilla;
static LogModule*
GetSriLog()
{
static PRLogModuleInfo *gSriPRLog;
if (!gSriPRLog) {
gSriPRLog = PR_NewLogModule("SRI");
}
static LazyLogModule gSriPRLog("SRI");
return gSriPRLog;
}
using namespace mozilla;
PRLogModuleInfo* gContentSinkLogModuleInfo;
LazyLogModule gContentSinkLogModuleInfo("nscontentsink");
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsContentSink)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsContentSink)
@ -110,12 +107,6 @@ nsContentSink::nsContentSink()
NS_ASSERTION(mInMonolithicContainer == 0, "What?");
NS_ASSERTION(mInNotification == 0, "What?");
NS_ASSERTION(!mDeferredLayoutStart, "What?");
#ifdef DEBUG
if (!gContentSinkLogModuleInfo) {
gContentSinkLogModuleInfo = PR_NewLogModule("nscontentsink");
}
#endif
}
nsContentSink::~nsContentSink()
@ -963,8 +954,10 @@ nsContentSink::SelectDocAppCache(nsIApplicationCache *aLoadApplicationCache,
nsAutoCString docURISpec, clientID;
mDocumentURI->GetAsciiSpec(docURISpec);
aLoadApplicationCache->GetClientID(clientID);
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
("Selection: assigning app cache %s to document %s", clientID.get(), docURISpec.get()));
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_CALLS,
("Selection: assigning app cache %s to document %s",
clientID.get(), docURISpec.get()));
#endif
rv = applicationCacheDocument->SetApplicationCache(aLoadApplicationCache);
@ -1017,8 +1010,10 @@ nsContentSink::SelectDocAppCacheNoManifest(nsIApplicationCache *aLoadApplication
nsAutoCString docURISpec, clientID;
mDocumentURI->GetAsciiSpec(docURISpec);
aLoadApplicationCache->GetClientID(clientID);
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
("Selection, no manifest: assigning app cache %s to document %s", clientID.get(), docURISpec.get()));
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_CALLS,
("Selection, no manifest: assigning app cache %s to document %s",
clientID.get(), docURISpec.get()));
#endif
rv = applicationCacheDocument->SetApplicationCache(aLoadApplicationCache);
@ -1332,7 +1327,8 @@ nsContentSink::WillInterruptImpl()
{
nsresult result = NS_OK;
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_CALLS,
("nsContentSink::WillInterrupt: this=%p", this));
#ifndef SINK_NO_INCREMENTAL
if (WaitForPendingSheets()) {
@ -1346,7 +1342,8 @@ nsContentSink::WillInterruptImpl()
// If it's already time for us to have a notification
if (diff > interval || mDroppedTimer) {
mBackoffCount--;
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_REFLOW,
("nsContentSink::WillInterrupt: flushing tags since we've "
"run out time; backoff count: %d", mBackoffCount));
result = FlushTags();
@ -1364,7 +1361,8 @@ nsContentSink::WillInterruptImpl()
mNotificationTimer = do_CreateInstance("@mozilla.org/timer;1",
&result);
if (NS_SUCCEEDED(result)) {
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_REFLOW,
("nsContentSink::WillInterrupt: setting up timer with "
"delay %d", delay));
@ -1378,7 +1376,8 @@ nsContentSink::WillInterruptImpl()
}
}
} else {
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_REFLOW,
("nsContentSink::WillInterrupt: flushing tags "
"unconditionally"));
result = FlushTags();
@ -1393,7 +1392,8 @@ nsContentSink::WillInterruptImpl()
nsresult
nsContentSink::WillResumeImpl()
{
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_CALLS,
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_CALLS,
("nsContentSink::WillResume: this=%p", this));
mParsing = true;
@ -1513,7 +1513,8 @@ nsContentSink::DidBuildModelImpl(bool aTerminated)
// Cancel a timer if we had one out there
if (mNotificationTimer) {
SINK_TRACE(gContentSinkLogModuleInfo, SINK_TRACE_REFLOW,
SINK_TRACE(static_cast<LogModule*>(gContentSinkLogModuleInfo),
SINK_TRACE_REFLOW,
("nsContentSink::DidBuildModel: canceling notification "
"timeout"));
mNotificationTimer->Cancel();

Просмотреть файл

@ -47,13 +47,13 @@ class Loader;
#ifdef DEBUG
extern PRLogModuleInfo* gContentSinkLogModuleInfo;
extern mozilla::LazyLogModule gContentSinkLogModuleInfo;
#define SINK_TRACE_CALLS 0x1
#define SINK_TRACE_REFLOW 0x2
#define SINK_ALWAYS_REFLOW 0x4
#define SINK_LOG_TEST(_lm, _bit) (int((_lm)->level) & (_bit))
#define SINK_LOG_TEST(_lm, _bit) (int((_lm)->Level()) & (_bit))
#define SINK_TRACE(_lm, _bit, _args) \
PR_BEGIN_MACRO \

Просмотреть файл

@ -2116,14 +2116,6 @@ nsContentUtils::IsCallerContentXBL()
return xpc::IsContentXBLScope(c);
}
bool
nsContentUtils::IsImageSrcSetDisabled()
{
return Preferences::GetBool("dom.disable_image_src_set") &&
!IsCallerChrome();
}
// static
bool
nsContentUtils::LookupBindingMember(JSContext* aCx, nsIContent *aContent,

Просмотреть файл

@ -236,8 +236,6 @@ public:
return SubjectPrincipal();
}
static bool IsImageSrcSetDisabled();
static bool LookupBindingMember(JSContext* aCx, nsIContent *aContent,
JS::Handle<jsid> aId,
JS::MutableHandle<JSPropertyDescriptor> aDesc);

Просмотреть файл

@ -471,11 +471,7 @@ nsDOMWindowUtils::SetResolution(float aResolution)
return NS_ERROR_FAILURE;
}
nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
if (sf) {
sf->SetResolution(aResolution);
presShell->SetResolution(aResolution);
}
presShell->SetResolution(aResolution);
return NS_OK;
}
@ -488,7 +484,7 @@ nsDOMWindowUtils::SetResolutionAndScaleTo(float aResolution)
return NS_ERROR_FAILURE;
}
nsLayoutUtils::SetResolutionAndScaleTo(presShell, aResolution);
presShell->SetResolutionAndScaleTo(aResolution);
return NS_OK;
}
@ -501,7 +497,7 @@ nsDOMWindowUtils::GetResolution(float* aResolution)
return NS_ERROR_FAILURE;
}
*aResolution = nsLayoutUtils::GetResolution(presShell);
*aResolution = presShell->GetResolution();
return NS_OK;
}
@ -513,8 +509,7 @@ nsDOMWindowUtils::GetIsResolutionSet(bool* aIsResolutionSet) {
return NS_ERROR_FAILURE;
}
const nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
*aIsResolutionSet = sf && sf->IsResolutionSet();
*aIsResolutionSet = presShell->IsResolutionSet();
return NS_OK;
}

Просмотреть файл

@ -257,8 +257,8 @@ using namespace mozilla::dom;
typedef nsTArray<Link*> LinkArray;
static PRLogModuleInfo* gDocumentLeakPRLog;
static PRLogModuleInfo* gCspPRLog;
static LazyLogModule gDocumentLeakPRLog("DocumentLeak");
static LazyLogModule gCspPRLog("CSP");
#define NAME_NOT_VALID ((nsSimpleContentList*)1)
@ -1459,16 +1459,10 @@ nsDocument::nsDocument(const char* aContentType)
{
SetContentTypeInternal(nsDependentCString(aContentType));
if (!gDocumentLeakPRLog)
gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak");
if (gDocumentLeakPRLog)
MOZ_LOG(gDocumentLeakPRLog, LogLevel::Debug,
("DOCUMENT %p created", this));
if (!gCspPRLog)
gCspPRLog = PR_NewLogModule("CSP");
// Start out mLastStyleSheetSet as null, per spec
SetDOMStringToNull(mLastStyleSheetSet);
@ -2653,23 +2647,12 @@ nsDocument::ApplySettingsFromCSP(bool aSpeculative)
}
// 2) apply settings from speculative csp
nsCOMPtr<nsIContentSecurityPolicy> preloadCsp;
rv = NodePrincipal()->GetPreloadCsp(getter_AddRefs(preloadCsp));
if (preloadCsp) {
// Set up any Referrer Policy specified by CSP
bool hasReferrerPolicy = false;
uint32_t referrerPolicy = mozilla::net::RP_Default;
rv = preloadCsp->GetReferrerPolicy(&referrerPolicy, &hasReferrerPolicy);
if (!mUpgradeInsecurePreloads) {
nsCOMPtr<nsIContentSecurityPolicy> preloadCsp;
rv = NodePrincipal()->GetPreloadCsp(getter_AddRefs(preloadCsp));
NS_ENSURE_SUCCESS_VOID(rv);
if (hasReferrerPolicy) {
// please note that referrer policy spec defines that the latest
// policy awlays wins, hence we can safely overwrite the policy here.
mReferrerPolicy = static_cast<ReferrerPolicy>(referrerPolicy);
mReferrerPolicySet = true;
}
if (!mUpgradeInsecurePreloads) {
rv = preloadCsp->GetUpgradeInsecureRequests(&mUpgradeInsecurePreloads);
NS_ENSURE_SUCCESS_VOID(rv);
if (preloadCsp) {
preloadCsp->GetUpgradeInsecureRequests(&mUpgradeInsecurePreloads);
}
}
}

Просмотреть файл

@ -77,8 +77,8 @@ using namespace mozilla::widget;
// Two types of focus pr logging are available:
// 'Focus' for normal focus manager calls
// 'FocusNavigation' for tab and document navigation
PRLogModuleInfo* gFocusLog;
PRLogModuleInfo* gFocusNavigationLog;
LazyLogModule gFocusLog("Focus");
LazyLogModule gFocusNavigationLog("FocusNavigation");
#define LOGFOCUS(args) MOZ_LOG(gFocusLog, mozilla::LogLevel::Debug, args)
#define LOGFOCUSNAVIGATION(args) MOZ_LOG(gFocusNavigationLog, mozilla::LogLevel::Debug, args)
@ -193,9 +193,6 @@ nsFocusManager::Init()
NS_ADDREF(fm);
sInstance = fm;
gFocusLog = PR_NewLogModule("Focus");
gFocusNavigationLog = PR_NewLogModule("FocusNavigation");
nsIContent::sTabFocusModelAppliesToXUL =
Preferences::GetBool("accessibility.tabfocus_applies_to_xul",
nsIContent::sTabFocusModelAppliesToXUL);

Просмотреть файл

@ -248,8 +248,6 @@ class nsIScriptTimeoutHandler;
#include <android/log.h>
#endif
static PRLogModuleInfo* gDOMLeakPRLog;
#ifdef XP_WIN
#include <process.h>
#define getpid _getpid
@ -269,6 +267,8 @@ using mozilla::TimeDuration;
using mozilla::dom::cache::CacheStorage;
using mozilla::dom::indexedDB::IDBFactory;
static LazyLogModule gDOMLeakPRLog("DOMLeak");
nsGlobalWindow::WindowByIdTable *nsGlobalWindow::sWindowsById = nullptr;
bool nsGlobalWindow::sWarnedAboutWindowInternal = false;
bool nsGlobalWindow::sIdleObserversAPIFuzzTimeDisabled = false;
@ -1278,7 +1278,6 @@ nsGlobalWindow::Init()
NS_ASSERTION(gEntropyCollector,
"gEntropyCollector should have been initialized!");
gDOMLeakPRLog = PR_NewLogModule("DOMLeak");
NS_ASSERTION(gDOMLeakPRLog, "gDOMLeakPRLog should have been initialized!");
sWindowsById = new WindowByIdTable();
@ -8132,6 +8131,7 @@ void
nsGlobalWindow::ForceClose()
{
MOZ_ASSERT(IsOuterWindow());
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
if (IsFrame() || !mDocShell) {
// This may be a frame in a frameset, or a window that's already closed.
@ -8160,6 +8160,12 @@ nsGlobalWindow::FinalClose()
// Flag that we were closed.
mIsClosed = true;
// If we get here from CloseOuter then it means that the parent process is
// going to close our window for us. It's just important to set mIsClosed.
if (XRE_GetProcessType() == GeckoProcessType_Content) {
return;
}
// This stuff is non-sensical but incredibly fragile. The reasons for the
// behavior here don't make sense today and may not have ever made sense,
// but various bits of frontend code break when you change them. If you need

Просмотреть файл

@ -36,7 +36,7 @@ using mozilla::dom::NodeInfo;
#include "mozilla/Logging.h"
static PRLogModuleInfo* gNodeInfoManagerLeakPRLog;
static LazyLogModule gNodeInfoManagerLeakPRLog("NodeInfoManagerLeak");
PLHashNumber
nsNodeInfoManager::GetNodeInfoInnerHashValue(const void *key)
@ -115,9 +115,6 @@ nsNodeInfoManager::nsNodeInfoManager()
{
nsLayoutStatics::AddRef();
if (!gNodeInfoManagerLeakPRLog)
gNodeInfoManagerLeakPRLog = PR_NewLogModule("NodeInfoManagerLeak");
if (gNodeInfoManagerLeakPRLog)
MOZ_LOG(gNodeInfoManagerLeakPRLog, LogLevel::Debug,
("NODEINFOMANAGER %p created", this));

Просмотреть файл

@ -107,12 +107,10 @@ static const char *kPrefJavaMIME = "plugin.java.mime";
using namespace mozilla;
using namespace mozilla::dom;
static PRLogModuleInfo*
static LogModule*
GetObjectLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("objlc");
static LazyLogModule sLog("objlc");
return sLog;
}

Просмотреть файл

@ -705,12 +705,12 @@ public:
}
};
class PrefEnabledRunnable final : public WorkerMainThreadRunnable
class PrefEnabledRunnable final : public WorkerCheckAPIExposureOnMainThreadRunnable
{
public:
PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate,
const nsCString& aPrefName)
: WorkerMainThreadRunnable(aWorkerPrivate)
: WorkerCheckAPIExposureOnMainThreadRunnable(aWorkerPrivate)
, mEnabled(false)
, mPrefName(aPrefName)
{ }
@ -748,9 +748,7 @@ nsPerformance::IsEnabled(JSContext* aCx, JSObject* aGlobal)
RefPtr<PrefEnabledRunnable> runnable =
new PrefEnabledRunnable(workerPrivate,
NS_LITERAL_CSTRING("dom.enable_user_timing"));
runnable->Dispatch(workerPrivate->GetJSContext());
return runnable->IsEnabled();
return runnable->Dispatch() && runnable->IsEnabled();
}
/* static */ bool
@ -767,9 +765,8 @@ nsPerformance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
RefPtr<PrefEnabledRunnable> runnable =
new PrefEnabledRunnable(workerPrivate,
NS_LITERAL_CSTRING("dom.enable_performance_observer"));
runnable->Dispatch(workerPrivate->GetJSContext());
return runnable->IsEnabled();
return runnable->Dispatch() && runnable->IsEnabled();
}
void

Просмотреть файл

@ -57,21 +57,18 @@
#include "mozilla/dom/SRICheck.h"
#include "nsIScriptError.h"
static PRLogModuleInfo* gCspPRLog;
static PRLogModuleInfo*
GetSriLog()
{
static PRLogModuleInfo *gSriPRLog;
if (!gSriPRLog) {
gSriPRLog = PR_NewLogModule("SRI");
}
return gSriPRLog;
}
using namespace mozilla;
using namespace mozilla::dom;
static LazyLogModule gCspPRLog("CSP");
static LogModule*
GetSriLog()
{
static LazyLogModule gSriPRLog("SRI");
return gSriPRLog;
}
// The nsScriptLoadRequest is passed as the context to necko, and thus
// it needs to be threadsafe. Necko won't do anything with this
// context, but it will AddRef and Release it on other threads.
@ -120,9 +117,6 @@ nsScriptLoader::nsScriptLoader(nsIDocument *aDocument)
mDocumentParsingDone(false),
mBlockingDOMContentLoaded(false)
{
// enable logging for CSP
if (!gCspPRLog)
gCspPRLog = PR_NewLogModule("CSP");
}
nsScriptLoader::~nsScriptLoader()

Просмотреть файл

@ -31,19 +31,16 @@
#include "nsStyleUtil.h"
#include "nsQueryObject.h"
static PRLogModuleInfo*
GetSriLog()
{
static PRLogModuleInfo *gSriPRLog;
if (!gSriPRLog) {
gSriPRLog = PR_NewLogModule("SRI");
}
return gSriPRLog;
}
using namespace mozilla;
using namespace mozilla::dom;
static LogModule*
GetSriLog()
{
static LazyLogModule gSriPRLog("SRI");
return gSriPRLog;
}
nsStyleLinkElement::nsStyleLinkElement()
: mDontLoadStyle(false)
, mUpdatesEnabled(true)

Просмотреть файл

@ -92,6 +92,17 @@ function testCopyPaste (isXHTML) {
transferable.getTransferData(mime, data, {}) ;
return data;
}
function testHtmlClipboardValue(mime, expected) {
// For Windows, navigator.platform returns "Win32".
var expectedValue = expected;
if (navigator.platform.indexOf("Win") >= 0) {
// Windows has extra content.
var expectedValue = "<html><body>\n<!--StartFragment-->" +
expected.replace(/\n/g, '\n') +
"<!--EndFragment-->\n</body>\n</html>";
}
testClipboardValue(mime, expectedValue);
}
function testClipboardValue(mime, expected) {
if (suppressHTMLCheck && mime == "text/html")
return null;
@ -133,37 +144,37 @@ function testCopyPaste (isXHTML) {
testSelectionToString("This is a draggable bit of text.");
testClipboardValue("text/unicode",
"This is a draggable bit of text.");
testClipboardValue("text/html",
testHtmlClipboardValue("text/html",
"<div id=\"draggable\" title=\"title to have a long HTML line\">This is a <em>draggable</em> bit of text.</div>");
testPasteText("This is a draggable bit of text.");
copyChildrenToClipboard("alist");
testSelectionToString(" bla\n\n foo\n bar\n\n");
testClipboardValue("text/unicode", " bla\n\n foo\n bar\n\n");
testClipboardValue("text/html", "<div id=\"alist\">\n bla\n <ul>\n <li>foo</li>\n \n <li>bar</li>\n </ul>\n </div>");
testHtmlClipboardValue("text/html", "<div id=\"alist\">\n bla\n <ul>\n <li>foo</li>\n \n <li>bar</li>\n </ul>\n </div>");
testPasteText(" bla\n\n foo\n bar\n\n");
copyChildrenToClipboard("blist");
testSelectionToString(" mozilla\n\n foo\n bar\n\n");
testClipboardValue("text/unicode", " mozilla\n\n foo\n bar\n\n");
testClipboardValue("text/html", "<div id=\"blist\">\n mozilla\n <ol>\n <li>foo</li>\n \n <li>bar</li>\n </ol>\n </div>");
testHtmlClipboardValue("text/html", "<div id=\"blist\">\n mozilla\n <ol>\n <li>foo</li>\n \n <li>bar</li>\n </ol>\n </div>");
testPasteText(" mozilla\n\n foo\n bar\n\n");
copyChildrenToClipboard("clist");
testSelectionToString(" mzla\n\n foo\n bazzinga!\n bar\n\n");
testClipboardValue("text/unicode", " mzla\n\n foo\n bazzinga!\n bar\n\n");
testClipboardValue("text/html", "<div id=\"clist\">\n mzla\n <ul>\n <li>foo<ul>\n <li>bazzinga!</li>\n </ul></li>\n \n <li>bar</li>\n </ul>\n </div>");
testHtmlClipboardValue("text/html", "<div id=\"clist\">\n mzla\n <ul>\n <li>foo<ul>\n <li>bazzinga!</li>\n </ul></li>\n \n <li>bar</li>\n </ul>\n </div>");
testPasteText(" mzla\n\n foo\n bazzinga!\n bar\n\n");
copyChildrenToClipboard("div4");
testSelectionToString(" Tt t t ");
testClipboardValue("text/unicode", " Tt t t ");
if (isXHTML) {
testClipboardValue("text/html", "<div id=\"div4\">\n T<textarea xmlns=\"http://www.w3.org/1999/xhtml\">t t t</textarea>\n</div>");
testHtmlClipboardValue("text/html", "<div id=\"div4\">\n T<textarea xmlns=\"http://www.w3.org/1999/xhtml\">t t t</textarea>\n</div>");
testInnerHTML("div4", "\n T<textarea xmlns=\"http://www.w3.org/1999/xhtml\">t t t</textarea>\n");
}
else {
testClipboardValue("text/html", "<div id=\"div4\">\n T<textarea>t t t</textarea>\n</div>");
testHtmlClipboardValue("text/html", "<div id=\"div4\">\n T<textarea>t t t</textarea>\n</div>");
testInnerHTML("div4", "\n T<textarea>t t t</textarea>\n");
}
testPasteText(" Tt t t ");
@ -172,11 +183,11 @@ function testCopyPaste (isXHTML) {
testSelectionToString(" T ");
testClipboardValue("text/unicode", " T ");
if (isXHTML) {
testClipboardValue("text/html", "<div id=\"div5\">\n T<textarea xmlns=\"http://www.w3.org/1999/xhtml\"> </textarea>\n</div>");
testHtmlClipboardValue("text/html", "<div id=\"div5\">\n T<textarea xmlns=\"http://www.w3.org/1999/xhtml\"> </textarea>\n</div>");
testInnerHTML("div5", "\n T<textarea xmlns=\"http://www.w3.org/1999/xhtml\"> </textarea>\n");
}
else {
testClipboardValue("text/html", "<div id=\"div5\">\n T<textarea> </textarea>\n</div>");
testHtmlClipboardValue("text/html", "<div id=\"div5\">\n T<textarea> </textarea>\n</div>");
testInnerHTML("div5", "\n T<textarea> </textarea>\n");
}
testPasteText(" T ");
@ -214,7 +225,7 @@ if (false) {
copyRangeToClipboard($("div9").childNodes[0],0, $("div9").childNodes[0],4,suppressUnicodeCheckIfHidden);
testSelectionToString("div9");
testClipboardValue("text/unicode", "div9");
testClipboardValue("text/html", "div9");
testHtmlClipboardValue("text/html", "div9");
testInnerHTML("div9", "div9");
copyToClipboard($("div10"), suppressUnicodeCheckIfHidden);
@ -357,7 +368,7 @@ if (false) {
copyChildrenToClipboard("div13");
testSelectionToString("__");
testClipboardValue("text/unicode", "__");
testClipboardValue("text/html", "<div id=\"div13\">__</div>");
testHtmlClipboardValue("text/html", "<div id=\"div13\">__</div>");
testPasteText("__");
// ============ converting cell boundaries to tabs in tables
@ -370,7 +381,7 @@ if (false) {
copyRangeToClipboard($("tr2"),0,$("tr3"),0);
testClipboardValue("text/unicode", "1\t2\n3\t4\n");
testClipboardValue("text/html", '<table><tbody><tr id="tr2"><tr id="tr2"><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr><tr id="tr3"></tr></tr></tbody></table>');
testHtmlClipboardValue("text/html", '<table><tbody><tr id="tr2"><tr id="tr2"><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr><tr id="tr3"></tr></tr></tbody></table>');
// ============ spanning multiple rows in multi-range selection
@ -379,20 +390,20 @@ if (false) {
addRange($("tr3"),0,$("tr3"),2);
copySelectionToClipboard();
testClipboardValue("text/unicode", "1\t2\n5\t6");
testClipboardValue("text/html", '<table><tbody><tr id="tr2"><td>1</td><td>2</td></tr><tr id="tr3"><td>5</td><td>6</td></tr></tbody></table>');
testHtmlClipboardValue("text/html", '<table><tbody><tr id="tr2"><td>1</td><td>2</td></tr><tr id="tr3"><td>5</td><td>6</td></tr></tbody></table>');
}
// ============ manipulating Selection in oncopy
copyRangeToClipboard($("div11").childNodes[0],0, $("div11").childNodes[1],2);
testClipboardValue("text/unicode", "Xdiv11");
testClipboardValue("text/html", "<div><p>X<span>div</span>11</p></div>");
testHtmlClipboardValue("text/html", "<div><p>X<span>div</span>11</p></div>");
setTimeout(function(){testSelectionToString("div11")},0);
setTimeout(function(){
copyRangeToClipboard($("div12").childNodes[0],0, $("div12").childNodes[1],2);
testClipboardValue("text/unicode", "Xdiv12");
testClipboardValue("text/html", "<div><p>X<span>div</span>12</p></div>");
testHtmlClipboardValue("text/html", "<div><p>X<span>div</span>12</p></div>");
setTimeout(function(){
testSelectionToString("div12");
setTimeout(SimpleTest.finish,0);

Просмотреть файл

@ -67,6 +67,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=816298
transferable.getTransferData(mime, data, {}) ;
return SpecialPowers.wrap(data);
}
function testHtmlClipboardValue(mime, expected, test) {
var expectedValue = expected;
// For Windows, navigator.platform returns "Win32".
if (navigator.platform.indexOf("Win") >= 0) {
expectedValue = "<html><body>\n<!--StartFragment-->" + expected + "<!--EndFragment-->\n</body>\n</html>";
}
testClipboardValue(mime, expectedValue, test);
}
function testClipboardValue(mime, expected, test) {
var data = getClipboardData(mime);
is (data.value == null ? data.value :
@ -140,7 +148,7 @@ for (var i = 0; i < originalStrings.length; i++) {
var id = 'test' + i;
copyChildrenToClipboard(id);
is(window.getSelection().toString(), originalStrings[i], id + ' Selection.toString()');
testClipboardValue("text/html", clipboardHTML[i], id);
testHtmlClipboardValue("text/html", clipboardHTML[i], id);
testClipboardValue("text/unicode", clipboardUnicode[i], id);
testInnerHTML(id, innerHTMLStrings[i]);
testPasteText(textareaStrings[i], id + '.innerHTML');

Просмотреть файл

@ -71,7 +71,11 @@ function testCopyImage () {
// Is the text/uncodie data correct ?
testClipboardValue('text/unicode', 'about:logo');
// Is the text/html data correct ?
testClipboardValue('text/html', '<img id="logo" src="about:logo">');
var expected = '<img id="logo" src="about:logo">';
if (navigator.platform.indexOf("Win") >= 0) {
expected = "<html><body>\n<!--StartFragment-->" + expected + "<!--EndFragment-->\n</body>\n</html>";
}
testClipboardValue('text/html', expected);
SimpleTest.finish();
}

Просмотреть файл

@ -19,8 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
</div>
<pre id="test">
</pre>
<a href="http://www.example.net?a=b&c=d" id="anchor">foobar</a>
<area href="http://www.example.net?a=b&c=d" id="area">foobar</area>
<script type="application/javascript">
/** Test for Bug 887836 **/
@ -127,20 +125,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
runTest();
}
function testElement(e) {
ok(e, 'element exists');
ok(e.searchParams, "e.searchParams exists!");
ok(e.searchParams.has('a'), "e.searchParams.has('a')");
is(e.searchParams.get('a'), 'b', "e.searchParams.get('a')");
ok(e.searchParams.has('c'), "e.searchParams.has('c')");
is(e.searchParams.get('c'), 'd', "e.searchParams.get('c')");
e.searchParams.set('e', 'f');
ok(e.href.indexOf('e=f') != 1, 'e is right');
runTest();
}
function testEncoding() {
var encoding = [ [ '1', '1' ],
[ 'a b', 'a+b' ],
@ -319,8 +303,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=887836
testCopyURLSearchParams,
testParserURLSearchParams,
testURL,
function() { testElement(document.getElementById('anchor')) },
function() { testElement(document.getElementById('area')) },
testEncoding,
testOrdering,
testDelete,

Просмотреть файл

@ -1549,7 +1549,7 @@ XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
// For non-global instance Xrays there are no other properties, so return
// here for them.
if (type != eGlobalInstance || !GlobalPropertiesAreOwn()) {
if (type != eGlobalInstance) {
return true;
}
} else if (type == eInterface) {
@ -1572,7 +1572,7 @@ XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
// The properties for globals live on the instance, so return here as there
// are no properties on their interface prototype object.
if (type == eGlobalInterfacePrototype && GlobalPropertiesAreOwn()) {
if (type == eGlobalInterfacePrototype) {
return true;
}
}
@ -1659,14 +1659,14 @@ XrayOwnPropertyKeys(JSContext* cx, JS::Handle<JSObject*> wrapper,
if (IsInstance(type)) {
ADD_KEYS_IF_DEFINED(unforgeableMethod);
ADD_KEYS_IF_DEFINED(unforgeableAttribute);
if (type == eGlobalInstance && GlobalPropertiesAreOwn()) {
if (type == eGlobalInstance) {
ADD_KEYS_IF_DEFINED(method);
ADD_KEYS_IF_DEFINED(attribute);
}
} else if (type == eInterface) {
ADD_KEYS_IF_DEFINED(staticMethod);
ADD_KEYS_IF_DEFINED(staticAttribute);
} else if (type != eGlobalInterfacePrototype || !GlobalPropertiesAreOwn()) {
} else if (type != eGlobalInterfacePrototype) {
MOZ_ASSERT(IsInterfacePrototype(type));
ADD_KEYS_IF_DEFINED(method);
ADD_KEYS_IF_DEFINED(attribute);
@ -1757,7 +1757,7 @@ XrayOwnPropertyKeys(JSContext* cx, JS::Handle<JSObject*> wrapper,
}
}
return (type == eGlobalInterfacePrototype && GlobalPropertiesAreOwn()) ||
return type == eGlobalInterfacePrototype ||
XrayOwnNativePropertyKeys(cx, wrapper, nativePropertyHooks, type,
obj, flags, props);
}

Просмотреть файл

@ -3154,15 +3154,6 @@ ConvertExceptionToPromise(JSContext* cx,
JSObject* promiseScope,
JS::MutableHandle<JS::Value> rval);
// While we wait for the outcome of spec discussions on whether properties for
// DOM global objects live on the object or the prototype, we supply this one
// place to switch the behaviour, so we can easily turn this off on branches.
inline bool
GlobalPropertiesAreOwn()
{
return true;
}
#ifdef DEBUG
void
AssertReturnTypeMatchesJitinfo(const JSJitInfo* aJitinfo,

Просмотреть файл

@ -742,10 +742,6 @@ DOMInterfaces = {
'implicitJSContext': [ 'createSession']
},
'MediaKeyStatusMap' : {
'implicitJSContext': [ 'size', 'get', 'has' ]
},
'MediaStream': {
'headerFile': 'DOMMediaStream.h',
'nativeType': 'mozilla::DOMMediaStream'

Просмотреть файл

@ -2822,14 +2822,10 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
isGlobal = self.descriptor.isGlobal() is not None
if not isGlobal and self.properties.hasNonChromeOnly():
properties = "&sNativeProperties"
elif self.properties.hasNonChromeOnly():
properties = "!GlobalPropertiesAreOwn() ? &sNativeProperties : nullptr"
else:
properties = "nullptr"
if not isGlobal and self.properties.hasChromeOnly():
chromeProperties = "nsContentUtils::ThreadsafeIsCallerChrome() ? &sChromeOnlyNativeProperties : nullptr"
elif self.properties.hasChromeOnly():
chromeProperties = "!GlobalPropertiesAreOwn() && nsContentUtils::ThreadsafeIsCallerChrome() ? &sChromeOnlyNativeProperties : nullptr"
else:
chromeProperties = "nullptr"
@ -3687,11 +3683,11 @@ class CGWrapGlobalMethod(CGAbstractMethod):
def definition_body(self):
if self.properties.hasNonChromeOnly():
properties = "GlobalPropertiesAreOwn() ? &sNativeProperties : nullptr"
properties = "&sNativeProperties"
else:
properties = "nullptr"
if self.properties.hasChromeOnly():
chromeProperties = "GlobalPropertiesAreOwn() && nsContentUtils::ThreadsafeIsCallerChrome() ? &sChromeOnlyNativeProperties : nullptr"
chromeProperties = "nsContentUtils::ThreadsafeIsCallerChrome() ? &sChromeOnlyNativeProperties : nullptr"
else:
chromeProperties = "nullptr"

Просмотреть файл

@ -388,7 +388,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
RefPtr<InitializeRunnable> runnable =
new InitializeRunnable(workerPrivate, origin, principalInfo,
privateBrowsing, aRv);
runnable->Dispatch(cx);
runnable->Dispatch(aRv);
}
if (aRv.Failed()) {

Просмотреть файл

@ -9,7 +9,7 @@
#include "mozilla/Logging.h"
extern PRLogModuleInfo* GetCameraLog();
extern mozilla::LogModule* GetCameraLog();
#define DOM_CAMERA_LOG( type, ... ) MOZ_LOG(GetCameraLog(), (mozilla::LogLevel)type, ( __VA_ARGS__ ))
#define DOM_CAMERA_LOGA( ... ) DOM_CAMERA_LOG( mozilla::LogLevel::Error, __VA_ARGS__ )

Просмотреть файл

@ -42,13 +42,10 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCameraManager)
* Set the NSPR_LOG_MODULES environment variable to enable logging
* in a debug build, e.g. NSPR_LOG_MODULES=Camera:5
*/
PRLogModuleInfo*
LogModule*
GetCameraLog()
{
static PRLogModuleInfo *sLog;
if (!sLog) {
sLog = PR_NewLogModule("Camera");
}
static LazyLogModule sLog("Camera");
return sLog;
}

Просмотреть файл

@ -273,8 +273,16 @@ public:
} else {
mode = ExtendMode::REPEAT;
}
Filter filter;
if (state.imageSmoothingEnabled) {
filter = Filter::GOOD;
} else {
filter = Filter::POINT;
}
mPattern.InitSurfacePattern(state.patternStyles[aStyle]->mSurface, mode,
state.patternStyles[aStyle]->mTransform);
state.patternStyles[aStyle]->mTransform, filter);
}
return *mPattern.GetPattern();

Просмотреть файл

@ -679,7 +679,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, ImageData& aImageData,
aCropRect,
aRv,
getter_AddRefs(data));
task->Dispatch(GetCurrentThreadWorkerPrivate()->GetJSContext());
task->Dispatch(aRv);
}
if (NS_WARN_IF(aRv.Failed())) {
@ -1023,7 +1023,7 @@ class CreateImageBitmapFromBlobWorkerTask final : public WorkerSameThreadRunnabl
RefPtr<layers::Image> image = DecodeAndCropBlob(mBlob, mCropRect, mError);
if (NS_WARN_IF(mError.Failed())) {
return false;
return true;
}
image.forget(mImage);
@ -1062,9 +1062,10 @@ private:
RefPtr<DecodeBlobInMainThreadSyncTask> task =
new DecodeBlobInMainThreadSyncTask(mWorkerPrivate, *mBlob, mCropRect,
rv, getter_AddRefs(data));
task->Dispatch(mWorkerPrivate->GetJSContext()); // This is a synchronous call.
task->Dispatch(rv); // This is a synchronous call.
if (NS_WARN_IF(rv.Failed())) {
// XXXbz does this really make sense if we're shutting down? Ah, well.
mPromise->MaybeReject(rv);
return nullptr;
}

Просмотреть файл

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function boom() {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.shadowColor = "green";
ctx.rotate(0.9923);
ctx.transform(6, 0.13807760834183488, 256, -0.39007851257689263, 0.5767177072299453, 64);
ctx.transform(0.61, 0.08697788582345888, 6, 6, 64, 128);
ctx.scale(0.36690500480283633, 6);
ctx.shadowOffsetY = -1.7976931348623157e+308;
ctx.fillText("A",32,0.848476537933684);
}
</script>
</head>
<body onload="boom();"></body>
</html>

Просмотреть файл

@ -23,5 +23,6 @@ load 1099143-1.html
load 1161277-1.html
load 1183363.html
load 1190705.html
load 1223740-1.html
load 1225381-1.html
load texImage2D.html

Просмотреть файл

@ -161,6 +161,7 @@ skip-if = toolkit != 'cocoa'
skip-if = toolkit != 'cocoa'
[test_2d.drawImage.zerocanvas.html]
[test_2d.fill.winding.html]
[test_2d.fill.pattern.imageSmoothingEnabled.html]
# These tests do not pass on any platform; Quartz backend won't pass them
# because we fall back to pixman when one circle doesn't contain the other.
# See bug 512647.

Просмотреть файл

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<title>Canvas test: 2d.fill.pattern.imageSmoothingEnabled</title>
<!-- Testing: That imageSmoothingEnabled is taken into account when doing pattern fills-->
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<canvas id="c" width="128" height="128"><p class="fallback">FAIL (fallback content)</p></canvas>
<img id="img">
<script>
function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
var pixel = ctx.getImageData(x, y, 1, 1);
var pr = pixel.data[0],
pg = pixel.data[1],
pb = pixel.data[2],
pa = pixel.data[3];
ok(r-d <= pr && pr <= r+d &&
g-d <= pg && pg <= g+d &&
b-d <= pb && pb <= b+d &&
a-d <= pa && pa <= a+d,
"pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
}
function isNotPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
var pixel = ctx.getImageData(x, y, 1, 1);
var pr = pixel.data[0],
pg = pixel.data[1],
pb = pixel.data[2],
pa = pixel.data[3];
ok(!(r-d <= pr && pr <= r+d &&
g-d <= pg && pg <= g+d &&
b-d <= pb && pb <= b+d &&
a-d <= pa && pa <= a+d),
"pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; did not expect "+colour+" +/- "+d);
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
var img = document.getElementById("img");
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
img.onload = function () {
ctx.mozImageSmoothingEnabled = false;
ctx.save();
ctx.fillStyle = "rgb(127, 127, 127);";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.scale(16, 16);
ctx.fillStyle = ctx.createPattern(img, 'no-repeat');
ctx.fillRect(0, 0, 8, 8);
ctx.restore();
// Check for nearest filtering.
isPixel(ctx, 0,0, 0,0,0,255, "0,0", "0,0,0,255", 0);
isPixel(ctx, 14,14, 0,0,0,255, "14,14", "0,0,0,255", 0);
isPixel(ctx, 15,15, 0,0,0,255, "15,15", "0,0,0,255", 0);
isPixel(ctx, 16,16, 255,0,0,255, "16,16", "255,0,0,255", 0);
ctx.mozImageSmoothingEnabled = true;
ctx.save();
ctx.fillStyle = "rgb(127, 127, 127);";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.scale(16, 16);
ctx.fillStyle = ctx.createPattern(img, 'no-repeat');
ctx.fillRect(0, 0, 8, 8);
ctx.restore();
// Check that nearest filtering is not happening.
isPixel(ctx, 0,0, 0,0,0,255, "0,0", "0,0,0,255", 0);
isNotPixel(ctx, 14,14, 0,0,0,255, "14,14", "0,0,0,255", 0);
isNotPixel(ctx, 15,15, 0,0,0,255, "15,15", "0,0,0,255", 0);
isNotPixel(ctx, 16,16, 255,0,0,255, "16,16", "255,0,0,255", 0);
isPixel(ctx, 32,32, 255,0,0,255, "32,32", "255,0,0,255", 0);
SimpleTest.finish();
}
});
</script>

Просмотреть файл

@ -1237,7 +1237,7 @@ DataTransfer::CacheExternalDragFormats()
// there isn't a way to get a list of the formats that might be available on
// all platforms, so just check for the types that can actually be imported
// XXXndeakin there are some other formats but those are platform specific.
const char* formats[] = { kFileMime, kHTMLMime, kURLMime, kURLDataMime, kUnicodeMime };
const char* formats[] = { kFileMime, kHTMLMime, kRTFMime, kURLMime, kURLDataMime, kUnicodeMime };
uint32_t count;
dragSession->GetNumDropItems(&count);
@ -1279,7 +1279,7 @@ DataTransfer::CacheExternalClipboardFormats()
// there isn't a way to get a list of the formats that might be available on
// all platforms, so just check for the types that can actually be imported
const char* formats[] = { kFileMime, kHTMLMime, kURLMime, kURLDataMime, kUnicodeMime };
const char* formats[] = { kFileMime, kHTMLMime, kRTFMime, kURLMime, kURLDataMime, kUnicodeMime };
for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) {
// check each format one at a time
@ -1361,7 +1361,14 @@ DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex)
variant->SetAsAString(str);
}
else {
variant->SetAsISupports(data);
nsCOMPtr<nsISupportsCString> supportscstr = do_QueryInterface(data);
if (supportscstr) {
nsAutoCString str;
supportscstr->GetData(str);
variant->SetAsACString(str);
} else {
variant->SetAsISupports(data);
}
}
aItem.mData = variant;

Просмотреть файл

@ -288,6 +288,7 @@ EventStateManager::DeltaAccumulator*
EventStateManager::EventStateManager()
: mLockCursor(0)
, mLastFrameConsumedSetCursor(false)
, mPreLockPoint(0,0)
, mCurrentTarget(nullptr)
// init d&d gesture state machine variables
@ -3527,8 +3528,19 @@ EventStateManager::UpdateCursor(nsPresContext* aPresContext,
nsIFrame::Cursor framecursor;
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
aTargetFrame);
if (NS_FAILED(aTargetFrame->GetCursor(pt, framecursor)))
return; // don't update the cursor if we failed to get it from the frame see bug 118877
// Avoid setting cursor when the mouse is over a windowless pluign.
if (NS_FAILED(aTargetFrame->GetCursor(pt, framecursor))) {
if (XRE_IsContentProcess()) {
mLastFrameConsumedSetCursor = true;
}
return;
}
// Make sure cursors get reset after the mouse leaves a
// windowless plugin frame.
if (mLastFrameConsumedSetCursor) {
ClearCachedWidgetCursor(aTargetFrame);
mLastFrameConsumedSetCursor = false;
}
cursor = framecursor.mCursor;
container = framecursor.mContainer;
haveHotspot = framecursor.mHaveHotspot;

Просмотреть файл

@ -861,6 +861,7 @@ private:
bool dispatchedToContentProcess);
int32_t mLockCursor;
bool mLastFrameConsumedSetCursor;
// Last mouse event refPoint (the offset from the widget's origin in
// device pixels) when mouse was locked, used to restore mouse position

Просмотреть файл

@ -40,7 +40,7 @@ namespace mozilla {
using namespace widget;
PRLogModuleInfo* sIMECOLog = nullptr;
LazyLogModule sIMECOLog("IMEContentObserver");
static const char*
ToChar(bool aBool)
@ -207,9 +207,6 @@ IMEContentObserver::IMEContentObserver()
#ifdef DEBUG
mTextChangeData.Test();
#endif
if (!sIMECOLog) {
sIMECOLog = PR_NewLogModule("IMEContentObserver");
}
}
void

Просмотреть файл

@ -57,7 +57,7 @@ using namespace widget;
* for debug, log the information with LogLevel::Debug. In this case, the log
* should start with "ISM: <method name>(),".
*/
PRLogModuleInfo* sISMLog = nullptr;
LazyLogModule sISMLog("IMEStateManager");
static const char*
GetBoolName(bool aBool)
@ -175,10 +175,6 @@ bool IMEStateManager::sRemoteHasFocus = false;
void
IMEStateManager::Init()
{
if (!sISMLog) {
sISMLog = PR_NewLogModule("IMEStateManager");
}
Preferences::AddBoolVarCache(
&sCheckForIMEUnawareWebApps,
"intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition",

Просмотреть файл

@ -976,8 +976,14 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
// FetchBody on the main thread.
RefPtr<CancelPumpRunnable<Derived>> r =
new CancelPumpRunnable<Derived>(this);
if (!r->Dispatch(mWorkerPrivate->GetJSContext())) {
ErrorResult rv;
r->Dispatch(rv);
if (rv.Failed()) {
NS_WARNING("Could not dispatch CancelPumpRunnable. Nothing we can do here");
// None of our callers are callled directly from JS, so there is no
// point in trying to propagate this failure out of here. And
// localPromise is already rejected. Just suppress the failure.
rv.SuppressException();
}
}
}

Просмотреть файл

@ -29,6 +29,7 @@
#include "nsPrintfCString.h"
#include "nsStreamUtils.h"
#include "nsStringStream.h"
#include "nsHttpChannel.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/workers/Workers.h"
@ -51,7 +52,6 @@ FetchDriver::FetchDriver(InternalRequest* aRequest, nsIPrincipal* aPrincipal,
, mLoadGroup(aLoadGroup)
, mRequest(aRequest)
, mHasBeenCrossSite(false)
, mFoundOpaqueRedirect(false)
, mResponseAvailableCalled(false)
, mFetchCalled(false)
{
@ -236,6 +236,10 @@ FetchDriver::HttpFetch()
return NS_ERROR_UNEXPECTED;
}
if (mRequest->GetRedirectMode() != RequestRedirect::Follow) {
secFlags |= nsILoadInfo::SEC_DONT_FOLLOW_REDIRECTS;
}
// From here on we create a channel and set its properties with the
// information from the InternalRequest. This is an implementation detail.
MOZ_ASSERT(mLoadGroup);
@ -441,7 +445,9 @@ FetchDriver::IsUnsafeRequest()
}
already_AddRefed<InternalResponse>
FetchDriver::BeginAndGetFilteredResponse(InternalResponse* aResponse, nsIURI* aFinalURI)
FetchDriver::BeginAndGetFilteredResponse(InternalResponse* aResponse,
nsIURI* aFinalURI,
bool aFoundOpaqueRedirect)
{
MOZ_ASSERT(aResponse);
nsAutoCString reqURL;
@ -454,7 +460,7 @@ FetchDriver::BeginAndGetFilteredResponse(InternalResponse* aResponse, nsIURI* aF
MOZ_ASSERT(NS_SUCCEEDED(rv));
RefPtr<InternalResponse> filteredResponse;
if (mFoundOpaqueRedirect) {
if (aFoundOpaqueRedirect) {
filteredResponse = aResponse->OpaqueRedirectResponse();
} else {
switch (mRequest->GetResponseTainting()) {
@ -551,10 +557,22 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(aRequest);
bool foundOpaqueRedirect = false;
if (httpChannel) {
uint32_t responseStatus;
httpChannel->GetResponseStatus(&responseStatus);
if (mozilla::net::nsHttpChannel::IsRedirectStatus(responseStatus)) {
if (mRequest->GetRedirectMode() == RequestRedirect::Error) {
FailWithNetworkError();
return NS_BINDING_FAILED;
}
if (mRequest->GetRedirectMode() == RequestRedirect::Manual) {
foundOpaqueRedirect = true;
}
}
nsAutoCString statusText;
httpChannel->GetResponseStatusText(statusText);
@ -660,7 +678,8 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest,
// Resolves fetch() promise which may trigger code running in a worker. Make
// sure the Response is fully initialized before calling this.
mResponse = BeginAndGetFilteredResponse(response, channelURI);
mResponse = BeginAndGetFilteredResponse(response, channelURI,
foundOpaqueRedirect);
nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -743,6 +762,12 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
return NS_OK;
}
// We should only ever get here if we use a "follow" redirect policy,
// or if if we set an "error" policy as a result of a CORS policy.
MOZ_ASSERT(mRequest->GetRedirectMode() == RequestRedirect::Follow ||
(mRequest->GetRedirectMode() == RequestRedirect::Error &&
IsUnsafeRequest()));
// HTTP Fetch step 5, "redirect status", step 1
if (NS_WARN_IF(mRequest->GetRedirectMode() == RequestRedirect::Error)) {
aOldChannel->Cancel(NS_BINDING_FAILED);
@ -763,33 +788,10 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
// HTTP Fetch step 5, "redirect status", step 10 requires us to halt the
// redirect, but successfully return an opaqueredirect Response to the
// initiating Fetch.
if (mRequest->GetRedirectMode() == RequestRedirect::Manual) {
// Ideally we would simply not cancel the old channel and allow it to
// be processed as normal. Unfortunately this is quite fragile and
// other redirect handlers can easily break it for certain use cases.
//
// For example, nsCORSListenerProxy cancels vetoed redirect channels.
// The HTTP cache will also error on vetoed redirects when the
// redirect has been previously cached.
//
// Therefore simulate the completion of the channel to produce the
// opaqueredirect Response and then cancel the original channel. This
// will result in OnStartRequest() getting called twice, but the second
// time will be with an error response (from the Cancel) which will
// be ignored.
MOZ_ASSERT(!mFoundOpaqueRedirect);
mFoundOpaqueRedirect = true;
Unused << OnStartRequest(aOldChannel, nullptr);
Unused << OnStopRequest(aOldChannel, nullptr, NS_OK);
aOldChannel->Cancel(NS_BINDING_FAILED);
return NS_BINDING_FAILED;
}
// The following steps are from HTTP Fetch step 5, "redirect status", step 11
// which requires the RequestRedirect to be "follow".
MOZ_ASSERT(mRequest->GetRedirectMode() == RequestRedirect::Follow);
// which requires the RequestRedirect to be "follow". We asserted that we're
// in either "follow" or "error" mode here.
// HTTP Fetch step 5, "redirect status", steps 11.1 and 11.2 block redirecting
// to a URL with credentials in CORS mode. This is implemented in

Просмотреть файл

@ -83,7 +83,6 @@ private:
RefPtr<FetchDriverObserver> mObserver;
nsCOMPtr<nsIDocument> mDocument;
bool mHasBeenCrossSite;
bool mFoundOpaqueRedirect;
DebugOnly<bool> mResponseAvailableCalled;
DebugOnly<bool> mFetchCalled;
@ -100,7 +99,8 @@ private:
// Returns the filtered response sent to the observer.
// Callers who don't have access to a channel can pass null for aFinalURI.
already_AddRefed<InternalResponse>
BeginAndGetFilteredResponse(InternalResponse* aResponse, nsIURI* aFinalURI);
BeginAndGetFilteredResponse(InternalResponse* aResponse, nsIURI* aFinalURI,
bool aFoundOpaqueRedirect);
// Utility since not all cases need to do any post processing of the filtered
// response.
nsresult FailWithNetworkError();

Просмотреть файл

@ -63,13 +63,11 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLAnchorElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLAnchorElement,
nsGenericHTMLElement)
tmp->Link::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLAnchorElement,
nsGenericHTMLElement)
tmp->Link::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -324,17 +322,13 @@ HTMLAnchorElement::RelList()
NS_IMETHODIMP \
HTMLAnchorElement::Get##_part(nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Get##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Get##_part(a##_part); \
return NS_OK; \
} \
NS_IMETHODIMP \
HTMLAnchorElement::Set##_part(const nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Set##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Set##_part(a##_part); \
return NS_OK; \
}

Просмотреть файл

@ -89,10 +89,8 @@ public:
virtual bool HasDeferredDNSPrefetchRequest() override;
// WebIDL API
void GetHref(nsAString& aValue, ErrorResult& rv)
{
GetHTMLURIAttr(nsGkAtoms::href, aValue);
}
// The XPCOM GetHref is OK for us
void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv)
{
SetHTMLAttr(nsGkAtoms::href, aValue, rv);
@ -156,8 +154,8 @@ public:
// Link::GetOrigin is OK for us
using Link::GetProtocol;
using Link::SetProtocol;
// Link::GetProtocol is OK for us
// Link::SetProtocol is OK for us
// Link::GetUsername is OK for us
// Link::SetUsername is OK for us
@ -165,23 +163,23 @@ public:
// Link::GetPassword is OK for us
// Link::SetPassword is OK for us
using Link::GetHost;
using Link::SetHost;
// Link::Link::GetHost is OK for us
// Link::Link::SetHost is OK for us
using Link::GetHostname;
using Link::SetHostname;
// Link::Link::GetHostname is OK for us
// Link::Link::SetHostname is OK for us
using Link::GetPort;
using Link::SetPort;
// Link::Link::GetPort is OK for us
// Link::Link::SetPort is OK for us
using Link::GetPathname;
using Link::SetPathname;
// Link::Link::GetPathname is OK for us
// Link::Link::SetPathname is OK for us
using Link::GetSearch;
using Link::SetSearch;
// Link::Link::GetSearch is OK for us
// Link::Link::SetSearch is OK for us
using Link::GetHash;
using Link::SetHash;
// Link::Link::GetHash is OK for us
// Link::Link::SetHash is OK for us
// The XPCOM URI decomposition attributes are fine for us
void GetCoords(DOMString& aValue)
@ -224,9 +222,9 @@ public:
{
SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
}
void Stringify(nsAString& aResult, ErrorResult& aError)
void Stringify(nsAString& aResult)
{
GetHref(aResult, aError);
GetHref(aResult);
}
protected:

Просмотреть файл

@ -40,13 +40,11 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLAreaElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLAreaElement,
nsGenericHTMLElement)
tmp->Link::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLAreaElement,
nsGenericHTMLElement)
tmp->Link::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
@ -207,17 +205,13 @@ HTMLAreaElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
NS_IMETHODIMP \
HTMLAreaElement::Get##_part(nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Get##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Get##_part(a##_part); \
return NS_OK; \
} \
NS_IMETHODIMP \
HTMLAreaElement::Set##_part(const nsAString& a##_part) \
{ \
ErrorResult rv; \
Link::Set##_part(a##_part, rv); \
MOZ_ASSERT(!rv.Failed()); \
Link::Set##_part(a##_part); \
return NS_OK; \
}

Просмотреть файл

@ -90,10 +90,7 @@ public:
SetHTMLAttr(nsGkAtoms::shape, aShape, aError);
}
void GetHref(nsAString& aHref, ErrorResult& aError)
{
aError = GetHref(aHref);
}
// The XPCOM GetHref is OK for us
void SetHref(const nsAString& aHref, ErrorResult& aError)
{
aError = SetHref(aHref);
@ -139,8 +136,8 @@ public:
// The Link::GetOrigin is OK for us
using Link::GetProtocol;
using Link::SetProtocol;
// Link::Link::GetProtocol is OK for us
// Link::Link::SetProtocol is OK for us
// The Link::GetUsername is OK for us
// The Link::SetUsername is OK for us
@ -148,23 +145,23 @@ public:
// The Link::GetPassword is OK for us
// The Link::SetPassword is OK for us
using Link::GetHost;
using Link::SetHost;
// Link::Link::GetHost is OK for us
// Link::Link::SetHost is OK for us
using Link::GetHostname;
using Link::SetHostname;
// Link::Link::GetHostname is OK for us
// Link::Link::SetHostname is OK for us
using Link::GetPort;
using Link::SetPort;
// Link::Link::GetPort is OK for us
// Link::Link::SetPort is OK for us
using Link::GetPathname;
using Link::SetPathname;
// Link::Link::GetPathname is OK for us
// Link::Link::SetPathname is OK for us
using Link::GetSearch;
using Link::SetSearch;
// Link::Link::GetSearch is OK for us
// Link::Link::SetSearch is OK for us
using Link::GetHash;
using Link::SetHash;
// Link::Link::GetHash is OK for us
// Link::Link::SetHash is OK for us
// The Link::GetSearchParams is OK for us
@ -178,9 +175,9 @@ public:
SetHTMLBoolAttr(nsGkAtoms::nohref, aValue, aError);
}
void Stringify(nsAString& aResult, ErrorResult& aError)
void Stringify(nsAString& aResult)
{
GetHref(aResult, aError);
GetHref(aResult);
}
protected:

Просмотреть файл

@ -535,12 +535,6 @@ HTMLImageElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
if (aNameSpaceID == kNameSpaceID_None &&
aName == nsGkAtoms::src) {
// This is for dom.disable_image_src_set, which predates "srcset"
// as an attribute. See Bug 773429
if (nsContentUtils::IsImageSrcSetDisabled()) {
return NS_OK;
}
if (InResponsiveMode()) {
if (mResponsiveSelector &&
mResponsiveSelector->Content() == this) {

Просмотреть файл

@ -48,7 +48,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLLinkElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLLinkElement,
nsGenericHTMLElement)
tmp->nsStyleLinkElement::Traverse(cb);
tmp->Link::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImportLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@ -56,7 +55,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLLinkElement,
nsGenericHTMLElement)
tmp->nsStyleLinkElement::Unlink();
tmp->Link::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImportLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

Просмотреть файл

@ -91,8 +91,9 @@
#include <algorithm>
#include <cmath>
static PRLogModuleInfo* gMediaElementLog;
static PRLogModuleInfo* gMediaElementEventsLog;
static mozilla::LazyLogModule gMediaElementLog("nsMediaElement");
static mozilla::LazyLogModule gMediaElementEventsLog("nsMediaElementEvents");
#define LOG(type, msg) MOZ_LOG(gMediaElementLog, type, msg)
#define LOG_EVENT(type, msg) MOZ_LOG(gMediaElementEventsLog, type, msg)
@ -107,12 +108,6 @@ static PRLogModuleInfo* gMediaElementEventsLog;
#include "mozilla/EventStateManager.h"
#if defined(MOZ_B2G) && !defined(MOZ_GRAPHENE)
// This controls the b2g specific of pausing the media element when the
// AudioChannel tells us to mute it.
#define PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
#endif
using namespace mozilla::layers;
using mozilla::net::nsMediaFragmentURIParser;
@ -578,6 +573,7 @@ void
HTMLMediaElement::SetSrcObject(DOMMediaStream* aValue)
{
mSrcAttrStream = aValue;
UpdateAudioChannelPlayingState();
DoLoad();
}
@ -602,6 +598,7 @@ void
HTMLMediaElement::SetMozSrcObject(DOMMediaStream* aValue)
{
mSrcAttrStream = aValue;
UpdateAudioChannelPlayingState();
DoLoad();
}
@ -768,6 +765,7 @@ void HTMLMediaElement::AbortExistingLoads()
FireTimeUpdate(false);
}
DispatchAsyncEvent(NS_LITERAL_STRING("emptied"));
UpdateAudioChannelPlayingState();
}
// We may have changed mPaused, mAutoplaying, and other
@ -1711,6 +1709,7 @@ HTMLMediaElement::Pause(ErrorResult& aRv)
// We changed mPaused and mAutoplaying which can affect AddRemoveSelfReference
AddRemoveSelfReference();
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
if (!oldPaused) {
FireTimeUpdate(false);
@ -2113,13 +2112,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0)
{
if (!gMediaElementLog) {
gMediaElementLog = PR_NewLogModule("nsMediaElement");
}
if (!gMediaElementEventsLog) {
gMediaElementEventsLog = PR_NewLogModule("nsMediaElementEvents");
}
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
mPaused.SetOuter(this);
@ -2317,6 +2309,7 @@ HTMLMediaElement::PlayInternal(bool aCallerIsChrome)
AddRemoveSelfReference();
UpdatePreloadAction();
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
return NS_OK;
}
@ -2897,6 +2890,7 @@ nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
// We may want to suspend the new stream now.
// This will also do an AddRemoveSelfReference.
NotifyOwnerDocumentActivityChangedInternal();
UpdateAudioChannelPlayingState();
if (!mPaused) {
SetPlayedOrSeeked(true);
@ -3993,6 +3987,7 @@ void HTMLMediaElement::CheckAutoplayDataReady()
// We changed mPaused which can affect AddRemoveSelfReference
AddRemoveSelfReference();
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
if (mDecoder) {
SetPlayedOrSeeked(true);
@ -4007,13 +4002,13 @@ void HTMLMediaElement::CheckAutoplayDataReady()
}
bool HTMLMediaElement::IsActive()
bool HTMLMediaElement::IsActive() const
{
nsIDocument* ownerDoc = OwnerDoc();
return ownerDoc && ownerDoc->IsActive() && ownerDoc->IsVisible();
}
bool HTMLMediaElement::IsHidden()
bool HTMLMediaElement::IsHidden() const
{
if (mElementInTreeState == ELEMENT_NOT_INTREE_HAD_INTREE) {
return true;
@ -4192,6 +4187,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement, bool aSuspendE
if (aPauseElement != mPausedForInactiveDocumentOrChannel) {
mPausedForInactiveDocumentOrChannel = aPauseElement;
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
if (aPauseElement) {
if (mMediaSource) {
ReportMSETelemetry();
@ -4251,15 +4247,12 @@ bool HTMLMediaElement::IsBeingDestroyed()
void HTMLMediaElement::NotifyOwnerDocumentActivityChanged()
{
bool pauseElement = NotifyOwnerDocumentActivityChangedInternal();
if (pauseElement && mAudioChannelAgent
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
if (pauseElement && mAudioChannelAgent &&
// On B2G, NotifyOwnerDocumentActivityChangedInternal may return true for
// two reasons: the document no longer being active, or the element being
// paused by the audio channel. However we are only interested in the
// first case here, so we need to filter out the second case.
&& !ComputedMuted()
#endif
) {
(!UseAudioChannelAPI() || !ComputedMuted())) {
// If the element is being paused since we are navigating away from the
// document, notify the audio channel agent.
// Be careful to ignore this event during a docshell frame swap.
@ -4283,15 +4276,13 @@ HTMLMediaElement::NotifyOwnerDocumentActivityChangedInternal()
}
bool pauseElement = !IsActive();
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
// Only pause the element when we start playing. If we pause without playing
// audio, the resource loading would be affected unexpectedly. For example,
// the media element is muted by default, but we don't want this behavior
// interrupting the loading process.
if (mAudioChannelAgent) {
if (UseAudioChannelAPI() && mAudioChannelAgent) {
pauseElement |= ComputedMuted();
}
#endif
SuspendOrResumeElement(pauseElement, !IsActive());
@ -4725,9 +4716,10 @@ nsresult HTMLMediaElement::UpdateChannelMuteState(float aVolume, bool aMuted)
}
}
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
SuspendOrResumeElement(ComputedMuted(), false);
#endif
if (UseAudioChannelAPI()) {
SuspendOrResumeElement(ComputedMuted(), false);
}
return NS_OK;
}
@ -4761,6 +4753,11 @@ HTMLMediaElement::IsPlayingThroughTheAudioChannel() const
return false;
}
// We should consider any bfcached page or inactive document as non-playing.
if (!IsActive()) {
return false;
}
// A loop always is playing
if (HasAttr(kNameSpaceID_None, nsGkAtoms::loop)) {
return true;
@ -4837,9 +4834,9 @@ NS_IMETHODIMP HTMLMediaElement::WindowVolumeChanged(float aVolume, bool aMuted)
UpdateChannelMuteState(aVolume, aMuted);
#ifdef PAUSE_MEDIA_ELEMENT_FROM_AUDIOCHANNEL
mPaused.SetCanPlay(!aMuted);
#endif
if (UseAudioChannelAPI()) {
mPaused.SetCanPlay(!aMuted);
}
return NS_OK;
}

Просмотреть файл

@ -214,9 +214,9 @@ public:
// suspended the channel.
virtual void NotifySuspendedByCache(bool aIsSuspended) final override;
virtual bool IsActive() final override;
virtual bool IsActive() const final override;
virtual bool IsHidden() final override;
virtual bool IsHidden() const final override;
// In order to create overlayImageContainer to support DOMHwMediaStream.
VideoFrameContainer* GetOverlayImageVideoFrameContainer();

Просмотреть файл

@ -40,7 +40,7 @@
#include "nsThreadUtils.h"
#include "nsVideoFrame.h"
static PRLogModuleInfo* gTrackElementLog;
static mozilla::LazyLogModule gTrackElementLog("nsTrackElement");
#define LOG(type, msg) MOZ_LOG(gTrackElementLog, type, msg)
// Replace the usual NS_IMPL_NS_NEW_HTML_ELEMENT(Track) so
@ -76,9 +76,6 @@ static MOZ_CONSTEXPR const char* kKindTableDefaultString = kKindTable[0].tag;
HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
{
if (!gTrackElementLog) {
gTrackElementLog = PR_NewLogModule("nsTrackElement");
}
}
HTMLTrackElement::~HTMLTrackElement()

Просмотреть файл

@ -182,8 +182,7 @@ nsHTMLDNSPrefetch::CancelPrefetch(Link *aElement,
return NS_ERROR_NOT_AVAILABLE;
nsAutoString hostname;
ErrorResult rv;
aElement->GetHostname(hostname, rv);
aElement->GetHostname(hostname);
return CancelPrefetch(hostname, flags, aReason);
}

Просмотреть файл

@ -20994,80 +20994,33 @@ OpenDatabaseOp::MetadataToSpec(DatabaseSpec& aSpec)
AssertIsOnOwningThread();
MOZ_ASSERT(mMetadata);
class MOZ_STACK_CLASS Helper final
{
DatabaseSpec& mSpec;
ObjectStoreSpec* mCurrentObjectStoreSpec;
aSpec.metadata() = mMetadata->mCommonMetadata;
public:
static void
CopyToSpec(const FullDatabaseMetadata* aMetadata, DatabaseSpec& aSpec)
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(aMetadata);
for (auto objectStoreIter = mMetadata->mObjectStores.ConstIter();
!objectStoreIter.Done();
objectStoreIter.Next()) {
FullObjectStoreMetadata* metadata = objectStoreIter.UserData();
MOZ_ASSERT(objectStoreIter.Key());
MOZ_ASSERT(metadata);
aSpec.metadata() = aMetadata->mCommonMetadata;
// XXX This should really be fallible...
ObjectStoreSpec* objectStoreSpec = aSpec.objectStores().AppendElement();
objectStoreSpec->metadata() = metadata->mCommonMetadata;
Helper helper(aSpec);
aMetadata->mObjectStores.EnumerateRead(Enumerate, &helper);
}
private:
explicit Helper(DatabaseSpec& aSpec)
: mSpec(aSpec)
, mCurrentObjectStoreSpec(nullptr)
{ }
static PLDHashOperator
Enumerate(const uint64_t& aKey,
FullObjectStoreMetadata* aValue,
void* aClosure)
{
MOZ_ASSERT(aKey);
MOZ_ASSERT(aValue);
MOZ_ASSERT(aClosure);
auto* helper = static_cast<Helper*>(aClosure);
MOZ_ASSERT(!helper->mCurrentObjectStoreSpec);
for (auto indexIter = metadata->mIndexes.Iter();
!indexIter.Done();
indexIter.Next()) {
FullIndexMetadata* indexMetadata = indexIter.UserData();
MOZ_ASSERT(indexIter.Key());
MOZ_ASSERT(indexMetadata);
// XXX This should really be fallible...
ObjectStoreSpec* objectStoreSpec =
helper->mSpec.objectStores().AppendElement();
objectStoreSpec->metadata() = aValue->mCommonMetadata;
AutoRestore<ObjectStoreSpec*> ar(helper->mCurrentObjectStoreSpec);
helper->mCurrentObjectStoreSpec = objectStoreSpec;
aValue->mIndexes.EnumerateRead(Enumerate, helper);
return PL_DHASH_NEXT;
IndexMetadata* metadata = objectStoreSpec->indexes().AppendElement();
*metadata = indexMetadata->mCommonMetadata;
}
static PLDHashOperator
Enumerate(const uint64_t& aKey, FullIndexMetadata* aValue, void* aClosure)
{
MOZ_ASSERT(aKey);
MOZ_ASSERT(aValue);
MOZ_ASSERT(aClosure);
auto* helper = static_cast<Helper*>(aClosure);
MOZ_ASSERT(helper->mCurrentObjectStoreSpec);
// XXX This should really be fallible...
IndexMetadata* metadata =
helper->mCurrentObjectStoreSpec->indexes().AppendElement();
*metadata = aValue->mCommonMetadata;
return PL_DHASH_NEXT;
}
};
Helper::CopyToSpec(mMetadata, aSpec);
}
}
#ifdef DEBUG
void
@ -21075,110 +21028,6 @@ OpenDatabaseOp::AssertMetadataConsistency(const FullDatabaseMetadata* aMetadata)
{
AssertIsOnBackgroundThread();
class MOZ_STACK_CLASS Helper final
{
const ObjectStoreTable& mOtherObjectStores;
IndexTable* mCurrentOtherIndexTable;
public:
static void
AssertConsistent(const ObjectStoreTable& aThisObjectStores,
const ObjectStoreTable& aOtherObjectStores)
{
Helper helper(aOtherObjectStores);
aThisObjectStores.EnumerateRead(Enumerate, &helper);
}
private:
explicit Helper(const ObjectStoreTable& aOtherObjectStores)
: mOtherObjectStores(aOtherObjectStores)
, mCurrentOtherIndexTable(nullptr)
{ }
static PLDHashOperator
Enumerate(const uint64_t& /* aKey */,
FullObjectStoreMetadata* aThisObjectStore,
void* aClosure)
{
MOZ_ASSERT(aThisObjectStore);
MOZ_ASSERT(!aThisObjectStore->mDeleted);
MOZ_ASSERT(aClosure);
auto* helper = static_cast<Helper*>(aClosure);
MOZ_ASSERT(!helper->mCurrentOtherIndexTable);
auto* otherObjectStore =
MetadataNameOrIdMatcher<FullObjectStoreMetadata>::Match(
helper->mOtherObjectStores, aThisObjectStore->mCommonMetadata.id());
MOZ_ASSERT(otherObjectStore);
MOZ_ASSERT(aThisObjectStore != otherObjectStore);
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.id() ==
otherObjectStore->mCommonMetadata.id());
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.name() ==
otherObjectStore->mCommonMetadata.name());
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.autoIncrement() ==
otherObjectStore->mCommonMetadata.autoIncrement());
MOZ_ASSERT(aThisObjectStore->mCommonMetadata.keyPath() ==
otherObjectStore->mCommonMetadata.keyPath());
// mNextAutoIncrementId and mComittedAutoIncrementId may be modified
// concurrently with this OpenOp, so it is not possible to assert equality
// here.
MOZ_ASSERT(aThisObjectStore->mNextAutoIncrementId <=
otherObjectStore->mNextAutoIncrementId);
MOZ_ASSERT(aThisObjectStore->mComittedAutoIncrementId <=
otherObjectStore->mComittedAutoIncrementId);
MOZ_ASSERT(!otherObjectStore->mDeleted);
MOZ_ASSERT(aThisObjectStore->mIndexes.Count() ==
otherObjectStore->mIndexes.Count());
AutoRestore<IndexTable*> ar(helper->mCurrentOtherIndexTable);
helper->mCurrentOtherIndexTable = &otherObjectStore->mIndexes;
aThisObjectStore->mIndexes.EnumerateRead(Enumerate, helper);
return PL_DHASH_NEXT;
}
static PLDHashOperator
Enumerate(const uint64_t& /* aKey */,
FullIndexMetadata* aThisIndex,
void* aClosure)
{
MOZ_ASSERT(aThisIndex);
MOZ_ASSERT(!aThisIndex->mDeleted);
MOZ_ASSERT(aClosure);
auto* helper = static_cast<Helper*>(aClosure);
MOZ_ASSERT(helper->mCurrentOtherIndexTable);
auto* otherIndex =
MetadataNameOrIdMatcher<FullIndexMetadata>::Match(
*helper->mCurrentOtherIndexTable, aThisIndex->mCommonMetadata.id());
MOZ_ASSERT(otherIndex);
MOZ_ASSERT(aThisIndex != otherIndex);
MOZ_ASSERT(aThisIndex->mCommonMetadata.id() ==
otherIndex->mCommonMetadata.id());
MOZ_ASSERT(aThisIndex->mCommonMetadata.name() ==
otherIndex->mCommonMetadata.name());
MOZ_ASSERT(aThisIndex->mCommonMetadata.keyPath() ==
otherIndex->mCommonMetadata.keyPath());
MOZ_ASSERT(aThisIndex->mCommonMetadata.unique() ==
otherIndex->mCommonMetadata.unique());
MOZ_ASSERT(aThisIndex->mCommonMetadata.multiEntry() ==
otherIndex->mCommonMetadata.multiEntry());
MOZ_ASSERT(!otherIndex->mDeleted);
return PL_DHASH_NEXT;
}
};
const FullDatabaseMetadata* thisDB = mMetadata;
const FullDatabaseMetadata* otherDB = aMetadata;
@ -21203,7 +21052,67 @@ OpenDatabaseOp::AssertMetadataConsistency(const FullDatabaseMetadata* aMetadata)
MOZ_ASSERT(thisDB->mObjectStores.Count() == otherDB->mObjectStores.Count());
Helper::AssertConsistent(thisDB->mObjectStores, otherDB->mObjectStores);
for (auto objectStoreIter = thisDB->mObjectStores.ConstIter();
!objectStoreIter.Done();
objectStoreIter.Next()) {
FullObjectStoreMetadata* thisObjectStore = objectStoreIter.UserData();
MOZ_ASSERT(thisObjectStore);
MOZ_ASSERT(!thisObjectStore->mDeleted);
auto* otherObjectStore =
MetadataNameOrIdMatcher<FullObjectStoreMetadata>::Match(
otherDB->mObjectStores, thisObjectStore->mCommonMetadata.id());
MOZ_ASSERT(otherObjectStore);
MOZ_ASSERT(thisObjectStore != otherObjectStore);
MOZ_ASSERT(thisObjectStore->mCommonMetadata.id() ==
otherObjectStore->mCommonMetadata.id());
MOZ_ASSERT(thisObjectStore->mCommonMetadata.name() ==
otherObjectStore->mCommonMetadata.name());
MOZ_ASSERT(thisObjectStore->mCommonMetadata.autoIncrement() ==
otherObjectStore->mCommonMetadata.autoIncrement());
MOZ_ASSERT(thisObjectStore->mCommonMetadata.keyPath() ==
otherObjectStore->mCommonMetadata.keyPath());
// mNextAutoIncrementId and mComittedAutoIncrementId may be modified
// concurrently with this OpenOp, so it is not possible to assert equality
// here.
MOZ_ASSERT(thisObjectStore->mNextAutoIncrementId <=
otherObjectStore->mNextAutoIncrementId);
MOZ_ASSERT(thisObjectStore->mComittedAutoIncrementId <=
otherObjectStore->mComittedAutoIncrementId);
MOZ_ASSERT(!otherObjectStore->mDeleted);
MOZ_ASSERT(thisObjectStore->mIndexes.Count() ==
otherObjectStore->mIndexes.Count());
for (auto indexIter = thisObjectStore->mIndexes.Iter();
!indexIter.Done();
indexIter.Next()) {
FullIndexMetadata* thisIndex = indexIter.UserData();
MOZ_ASSERT(thisIndex);
MOZ_ASSERT(!thisIndex->mDeleted);
auto* otherIndex =
MetadataNameOrIdMatcher<FullIndexMetadata>::
Match(otherObjectStore->mIndexes, thisIndex->mCommonMetadata.id());
MOZ_ASSERT(otherIndex);
MOZ_ASSERT(thisIndex != otherIndex);
MOZ_ASSERT(thisIndex->mCommonMetadata.id() ==
otherIndex->mCommonMetadata.id());
MOZ_ASSERT(thisIndex->mCommonMetadata.name() ==
otherIndex->mCommonMetadata.name());
MOZ_ASSERT(thisIndex->mCommonMetadata.keyPath() ==
otherIndex->mCommonMetadata.keyPath());
MOZ_ASSERT(thisIndex->mCommonMetadata.unique() ==
otherIndex->mCommonMetadata.unique());
MOZ_ASSERT(thisIndex->mCommonMetadata.multiEntry() ==
otherIndex->mCommonMetadata.multiEntry());
MOZ_ASSERT(!otherIndex->mDeleted);
}
}
}
#endif // DEBUG

Просмотреть файл

@ -262,7 +262,7 @@ IndexedDatabaseManager::~IndexedDatabaseManager()
bool IndexedDatabaseManager::sIsMainProcess = false;
bool IndexedDatabaseManager::sFullSynchronousMode = false;
PRLogModuleInfo* IndexedDatabaseManager::sLoggingModule;
mozilla::LazyLogModule IndexedDatabaseManager::sLoggingModule("IndexedDB");
Atomic<IndexedDatabaseManager::LoggingMode>
IndexedDatabaseManager::sLoggingMode(
@ -284,10 +284,6 @@ IndexedDatabaseManager::GetOrCreate()
if (!gDBManager) {
sIsMainProcess = XRE_IsParentProcess();
if (!sLoggingModule) {
sLoggingModule = PR_NewLogModule("IndexedDB");
}
if (sIsMainProcess && Preferences::GetBool("disk_space_watcher.enabled", false)) {
// See if we're starting up in low disk space conditions.
nsCOMPtr<nsIDiskSpaceWatcher> watcher =
@ -674,7 +670,7 @@ IndexedDatabaseManager::GetLoggingMode()
}
// static
PRLogModuleInfo*
mozilla::LogModule*
IndexedDatabaseManager::GetLoggingModule()
{
MOZ_ASSERT(gDBManager,

Просмотреть файл

@ -19,7 +19,6 @@
#include "nsITimer.h"
class nsIEventTarget;
struct PRLogModuleInfo;
namespace mozilla {
@ -101,7 +100,7 @@ public:
}
#endif
static PRLogModuleInfo*
static mozilla::LogModule*
GetLoggingModule()
#ifdef DEBUG
;
@ -226,7 +225,7 @@ private:
static bool sIsMainProcess;
static bool sFullSynchronousMode;
static PRLogModuleInfo* sLoggingModule;
static LazyLogModule sLoggingModule;
static Atomic<LoggingMode> sLoggingMode;
static mozilla::Atomic<bool> sLowDiskSpaceMode;
};

Просмотреть файл

@ -279,7 +279,7 @@ LoggingHelper(bool aUseProfiler, const char* aFmt, ...)
IndexedDatabaseManager::Logging_Disabled);
MOZ_ASSERT(aFmt);
PRLogModuleInfo* logModule = IndexedDatabaseManager::GetLoggingModule();
mozilla::LogModule* logModule = IndexedDatabaseManager::GetLoggingModule();
MOZ_ASSERT(logModule);
static const mozilla::LogLevel logLevel = LogLevel::Warning;

Просмотреть файл

@ -28,6 +28,10 @@
#include "nsComponentManagerUtils.h"
#include "nsCRT.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::hal;
#ifdef XP_WIN
#include <process.h>
#define getpid _getpid
@ -69,12 +73,10 @@
NameWithComma().get(), \
static_cast<uint64_t>(ChildID()), Pid(), ##__VA_ARGS__)
#else
static PRLogModuleInfo*
static LogModule*
GetPPMLog()
{
static PRLogModuleInfo *sLog;
if (!sLog)
sLog = PR_NewLogModule("ProcessPriorityManager");
static LazyLogModule sLog("ProcessPriorityManager");
return sLog;
}
# define LOG(fmt, ...) \
@ -87,10 +89,6 @@
static_cast<uint64_t>(ChildID()), Pid(), ##__VA_ARGS__))
#endif
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::hal;
namespace {
class ParticularProcessPriorityManager;

Просмотреть файл

@ -161,7 +161,11 @@ MP3TrackDemuxer::DemuxSample() {
media::TimeUnit
MP3TrackDemuxer::SeekPosition() const {
return Duration(mFrameIndex);
TimeUnit pos = Duration(mFrameIndex);
if (Duration() > TimeUnit()) {
pos = std::min(Duration(), pos);
}
return pos;
}
#endif
@ -199,22 +203,22 @@ MP3TrackDemuxer::FastSeek(const TimeUnit& aTime) {
const auto& vbr = mParser.VBRInfo();
if (!aTime.ToMicroseconds()) {
// Quick seek to the beginning of the stream.
mOffset = mFirstFrameOffset;
mFrameIndex = 0;
} else if (vbr.IsTOCPresent()) {
// Use TOC for more precise seeking.
const float durationFrac = static_cast<float>(aTime.ToMicroseconds()) /
Duration().ToMicroseconds();
mOffset = vbr.Offset(durationFrac);
mFrameIndex = FrameIndexFromOffset(vbr.Offset(durationFrac));
} else if (AverageFrameLength() > 0) {
mOffset = mFirstFrameOffset + FrameIndexFromTime(aTime) *
AverageFrameLength();
mFrameIndex = FrameIndexFromTime(aTime);
}
mOffset = OffsetFromFrameIndex(mFrameIndex);
if (mOffset > mFirstFrameOffset && StreamLength() > 0) {
mOffset = std::min(StreamLength() - 1, mOffset);
}
mFrameIndex = FrameIndexFromOffset(mOffset);
mParser.EndFrameSession();
MP3LOG("FastSeek End TOC=%d avgFrameLen=%f mNumParsedFrames=%" PRIu64
@ -240,6 +244,10 @@ MP3TrackDemuxer::ScanUntil(const TimeUnit& aTime) {
FastSeek(aTime);
}
if (Duration(mFrameIndex + 1) > aTime) {
return SeekPosition();
}
MediaByteRange nextRange = FindNextFrame();
while (SkipNextFrame(nextRange) && Duration(mFrameIndex + 1) < aTime) {
nextRange = FindNextFrame();
@ -253,7 +261,7 @@ MP3TrackDemuxer::ScanUntil(const TimeUnit& aTime) {
" mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
aTime, AverageFrameLength(), mNumParsedFrames, mFrameIndex, mOffset);
return Duration(mFrameIndex);
return SeekPosition();
}
RefPtr<MP3TrackDemuxer::SamplesPromise>
@ -363,10 +371,26 @@ MP3TrackDemuxer::Duration(int64_t aNumFrames) const {
return TimeUnit::FromMicroseconds(aNumFrames * usPerFrame);
}
static bool
VerifyFrameConsistency(
const FrameParser::Frame& aFrame1, const FrameParser::Frame& aFrame2) {
const auto& h1 = aFrame1.Header();
const auto& h2 = aFrame2.Header();
return h1.IsValid() && h2.IsValid() &&
h1.Layer() == h2.Layer() &&
h1.SlotSize() == h2.SlotSize() &&
h1.SamplesPerFrame() == h2.SamplesPerFrame() &&
h1.Channels() == h2.Channels() &&
h1.SampleRate() == h2.SampleRate() &&
h1.RawVersion() == h2.RawVersion() &&
h1.RawProtection() == h2.RawProtection();
}
MediaByteRange
MP3TrackDemuxer::FindNextFrame() {
static const int BUFFER_SIZE = 4096;
static const int MAX_SKIPPED_BYTES = 10 * BUFFER_SIZE;
static const int BUFFER_SIZE = 64;
static const int MAX_SKIPPED_BYTES = 1024 * BUFFER_SIZE;
MP3LOGV("FindNext() Begin mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
" mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
@ -400,10 +424,20 @@ MP3TrackDemuxer::FindNextFrame() {
MOZ_ASSERT(foundFrame || bytesToSkip || !reader.Remaining());
reader.DiscardRemaining();
// Advance mOffset by the amount of bytes read and if necessary,
// skip an ID3v2 tag which stretches beyond the current buffer.
NS_ENSURE_TRUE(mOffset + read + bytesToSkip > mOffset, MediaByteRange(0, 0));
mOffset += read + bytesToSkip;
if (foundFrame && mParser.FirstFrame().Length() &&
!VerifyFrameConsistency(mParser.FirstFrame(), mParser.CurrentFrame())) {
// We've likely hit a false-positive, ignore it and proceed with the
// search for the next valid frame.
foundFrame = false;
mOffset = frameHeaderOffset + 1;
mParser.EndFrameSession();
} else {
// Advance mOffset by the amount of bytes read and if necessary,
// skip an ID3v2 tag which stretches beyond the current buffer.
NS_ENSURE_TRUE(mOffset + read + bytesToSkip > mOffset,
MediaByteRange(0, 0));
mOffset += read + bytesToSkip;
}
}
if (!foundFrame || !mParser.CurrentFrame().Length()) {
@ -493,6 +527,22 @@ MP3TrackDemuxer::GetNextFrame(const MediaByteRange& aRange) {
return frame.forget();
}
int64_t
MP3TrackDemuxer::OffsetFromFrameIndex(int64_t aFrameIndex) const {
int64_t offset = 0;
const auto& vbr = mParser.VBRInfo();
if (vbr.NumBytes() && vbr.NumAudioFrames()) {
offset = mFirstFrameOffset + aFrameIndex * vbr.NumBytes().value() /
vbr.NumAudioFrames().value();
} else if (AverageFrameLength() > 0) {
offset = mFirstFrameOffset + aFrameIndex * AverageFrameLength();
}
MP3LOGV("OffsetFromFrameIndex(%" PRId64 ") -> %" PRId64, aFrameIndex, offset);
return std::max<int64_t>(mFirstFrameOffset, offset);
}
int64_t
MP3TrackDemuxer::FrameIndexFromOffset(int64_t aOffset) const {
int64_t frameIndex = 0;
@ -846,7 +896,7 @@ FrameParser::FrameHeader::IsValid(int aPos) const {
if (aPos == frame_header::SYNC2_VERSION_LAYER_PROTECTION) {
return Sync2() == 7 &&
RawVersion() != 1 &&
RawLayer() != 0;
Layer() == 3;
}
if (aPos == frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE) {
return RawBitrate() != 0xF && RawBitrate() != 0 &&
@ -1135,6 +1185,9 @@ ID3Parser::ID3Header::Flags() const {
uint32_t
ID3Parser::ID3Header::Size() const {
if (!IsValid()) {
return 0;
}
return mSize;
}

Просмотреть файл

@ -411,10 +411,13 @@ private:
// Updates post-read meta data.
void UpdateState(const MediaByteRange& aRange);
// Returns the frame index for the given offset.
// Returns the estimated offset for the given frame index.
int64_t OffsetFromFrameIndex(int64_t aFrameIndex) const;
// Returns the estimated frame index for the given offset.
int64_t FrameIndexFromOffset(int64_t aOffset) const;
// Returns the frame index for the given time.
// Returns the estimated frame index for the given time.
int64_t FrameIndexFromTime(const media::TimeUnit& aTime) const;
// Reads aSize bytes into aBuffer from the source starting at aOffset.

Просмотреть файл

@ -117,10 +117,10 @@ public:
};
// Check if the decoder owner is active.
virtual bool IsActive() = 0;
virtual bool IsActive() const = 0;
// Check if the decoder owner is hidden.
virtual bool IsHidden() = 0;
virtual bool IsHidden() const = 0;
// Called by the media decoder and the video frame to get the
// ImageContainer containing the video data.

Просмотреть файл

@ -5,6 +5,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/EMEUtils.h"
#include "mozilla/dom/UnionTypes.h"
namespace mozilla {
@ -112,4 +113,32 @@ ConstructKeySystem(const nsAString& aKeySystem,
aOutKeySystem.Append(aCDMVersion);
}
ArrayData
GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView)
{
MOZ_ASSERT(aBufferOrView.IsArrayBuffer() || aBufferOrView.IsArrayBufferView());
if (aBufferOrView.IsArrayBuffer()) {
const dom::ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
return ArrayData(buffer.Data(), buffer.Length());
} else if (aBufferOrView.IsArrayBufferView()) {
const dom::ArrayBufferView& bufferview = aBufferOrView.GetAsArrayBufferView();
bufferview.ComputeLengthAndData();
return ArrayData(bufferview.Data(), bufferview.Length());
}
return ArrayData(nullptr, 0);
}
void
CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
nsTArray<uint8_t>& aOutData)
{
ArrayData data = GetArrayBufferViewOrArrayBufferData(aBufferOrView);
aOutData.Clear();
if (!data.IsValid()) {
return;
}
aOutData.AppendElements(data.mData, data.mLength);
}
} // namespace mozilla

Просмотреть файл

@ -9,9 +9,14 @@
#include "mozilla/Logging.h"
#include "nsString.h"
#include "nsTArray.h"
namespace mozilla {
namespace dom {
class ArrayBufferViewOrArrayBuffer;
}
#ifndef EME_LOG
LogModule* GetEMELog();
#define EME_LOG(...) MOZ_LOG(GetEMELog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
@ -56,6 +61,49 @@ ConstructKeySystem(const nsAString& aKeySystem,
const nsAString& aCDMVersion,
nsAString& aOutKeySystem);
// Helper function to extract a copy of data coming in from JS in an
// (ArrayBuffer or ArrayBufferView) IDL typed function argument.
//
// Only call this on a properly initialized ArrayBufferViewOrArrayBuffer.
void
CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView,
nsTArray<uint8_t>& aOutData);
struct ArrayData {
explicit ArrayData(const uint8_t* aData, size_t aLength)
: mData(aData)
, mLength(aLength)
{
}
const uint8_t* mData;
const size_t mLength;
bool IsValid() const {
return mData != nullptr && mLength != 0;
}
bool operator== (const nsTArray<uint8_t>& aOther) const {
return mLength == aOther.Length() &&
memcmp(mData, aOther.Elements(), mLength) == 0;
}
};
// Helper function to extract data coming in from JS in an
// (ArrayBuffer or ArrayBufferView) IDL typed function argument.
//
// Be *very* careful with this!
//
// Only use returned ArrayData inside the lifetime of the
// ArrayBufferViewOrArrayBuffer; the ArrayData struct does not contain
// a copy of the data!
//
// And do *not* call out to anything that could call into JavaScript,
// while the ArrayData is live, as then all bets about the data not changing
// are off! No calls into JS, no calls into JS-implemented WebIDL or XPIDL,
// nothing. Beware!
//
// Only call this on a properly initialized ArrayBufferViewOrArrayBuffer.
ArrayData
GetArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aBufferOrView);
} // namespace mozilla
#endif // EME_LOG_H_

Просмотреть файл

@ -54,7 +54,7 @@ MediaKeySession::MediaKeySession(JSContext* aCx,
, mToken(sMediaKeySessionNum++)
, mIsClosed(false)
, mUninitialized(true)
, mKeyStatusMap(new MediaKeyStatusMap(aCx, aParent, aRv))
, mKeyStatusMap(new MediaKeyStatusMap(aParent))
, mExpiration(JS::GenericNaN())
{
EME_LOG("MediaKeySession[%p,''] session Id set", this);
@ -124,7 +124,6 @@ MediaKeySession::Closed() const
return mClosed;
}
void
MediaKeySession::UpdateKeyStatusMap()
{
@ -175,19 +174,26 @@ MediaKeySession::GenerateRequest(const nsAString& aInitDataType,
EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, uninitialized",
this, NS_ConvertUTF16toUTF8(mSessionId).get());
promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
NS_LITERAL_CSTRING("Session is already initialized in MediaKeySession.generateRequest()"));
NS_LITERAL_CSTRING("Session is already initialized in MediaKeySession.generateRequest()"));
return promise.forget();
}
mUninitialized = false;
if (aInitDataType.IsEmpty()) {
promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
NS_LITERAL_CSTRING("Empty initDataType passed to MediaKeySession.generateRequest()"));
EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, empty initDataType",
this, NS_ConvertUTF16toUTF8(mSessionId).get());
return promise.forget();
}
nsTArray<uint8_t> data;
if (aInitDataType.IsEmpty() ||
!CopyArrayBufferViewOrArrayBufferData(aInitData, data)) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
NS_LITERAL_CSTRING("Bad arguments to MediaKeySession.generateRequest()"));
EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, "
"invalid initData or initDataType",
CopyArrayBufferViewOrArrayBufferData(aInitData, data);
if (data.IsEmpty()) {
promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
NS_LITERAL_CSTRING("Empty initData passed to MediaKeySession.generateRequest()"));
EME_LOG("MediaKeySession[%p,'%s'] GenerateRequest() failed, empty initData",
this, NS_ConvertUTF16toUTF8(mSessionId).get());
return promise.forget();
}
@ -282,10 +288,11 @@ MediaKeySession::Update(const ArrayBufferViewOrArrayBuffer& aResponse, ErrorResu
this, NS_ConvertUTF16toUTF8(mSessionId).get());
return promise.forget();
}
if (!CopyArrayBufferViewOrArrayBufferData(aResponse, data)) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
NS_LITERAL_CSTRING("Invalid response buffer"));
EME_LOG("MediaKeySession[%p,'%s'] Update() failed, invalid response buffer",
CopyArrayBufferViewOrArrayBufferData(aResponse, data);
if (data.IsEmpty()) {
promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
NS_LITERAL_CSTRING("Empty response buffer passed to MediaKeySession.update()"));
EME_LOG("MediaKeySession[%p,'%s'] Update() failed, empty response buffer",
this, NS_ConvertUTF16toUTF8(mSessionId).get());
return promise.forget();
}

Просмотреть файл

@ -8,53 +8,26 @@
#include "nsPIDOMWindow.h"
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/EMEUtils.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaKeyStatusMap)
NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaKeyStatusMap)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaKeyStatusMap)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(MediaKeyStatusMap, mParent)
NS_IMPL_CYCLE_COLLECTION_CLASS(MediaKeyStatusMap)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaKeyStatusMap)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
tmp->mMap = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MediaKeyStatusMap)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(MediaKeyStatusMap)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mMap)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
MediaKeyStatusMap::MediaKeyStatusMap(JSContext* aCx,
nsPIDOMWindow* aParent,
ErrorResult& aRv)
MediaKeyStatusMap::MediaKeyStatusMap(nsPIDOMWindow* aParent)
: mParent(aParent)
, mUpdateError(NS_OK)
{
mMap = JS::NewMapObject(aCx);
if (NS_WARN_IF(!mMap)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
mozilla::HoldJSObjects(this);
}
MediaKeyStatusMap::~MediaKeyStatusMap()
{
mozilla::DropJSObjects(this);
}
JSObject*
@ -70,110 +43,63 @@ MediaKeyStatusMap::GetParentObject() const
}
MediaKeyStatus
MediaKeyStatusMap::Get(JSContext* aCx,
const ArrayBufferViewOrArrayBuffer& aKey,
ErrorResult& aRv) const
MediaKeyStatusMap::Get(const ArrayBufferViewOrArrayBuffer& aKey) const
{
if (NS_FAILED(mUpdateError)) {
aRv.Throw(mUpdateError);
ArrayData keyId = GetArrayBufferViewOrArrayBufferData(aKey);
if (!keyId.IsValid()) {
return MediaKeyStatus::Internal_error;
}
JS::Rooted<JSObject*> map(aCx, mMap);
JS::Rooted<JS::Value> key(aCx);
JS::Rooted<JS::Value> val(aCx);
if (!aKey.ToJSVal(aCx, map, &key) ||
!JS::MapGet(aCx, map, key, &val)) {
aRv.Throw(NS_ERROR_FAILURE);
return MediaKeyStatus::Internal_error;
for (const KeyStatus& status : mStatuses) {
if (keyId == status.mKeyId) {
return status.mStatus;
}
}
bool ok;
int index = FindEnumStringIndex<true>(
aCx, val, MediaKeyStatusValues::strings,
"MediaKeyStatus", "Invalid MediaKeyStatus value", &ok);
return ok ? static_cast<MediaKeyStatus>(index) :
MediaKeyStatus::Internal_error;
return MediaKeyStatus::Internal_error;
}
bool
MediaKeyStatusMap::Has(JSContext* aCx,
const ArrayBufferViewOrArrayBuffer& aKey,
ErrorResult& aRv) const
MediaKeyStatusMap::Has(const ArrayBufferViewOrArrayBuffer& aKey) const
{
if (NS_FAILED(mUpdateError)) {
aRv.Throw(mUpdateError);
ArrayData keyId = GetArrayBufferViewOrArrayBufferData(aKey);
if (!keyId.IsValid()) {
return false;
}
JS::Rooted<JSObject*> map(aCx, mMap);
JS::Rooted<JS::Value> key(aCx);
bool result = false;
if (!aKey.ToJSVal(aCx, map, &key) ||
!JS::MapHas(aCx, map, key, &result)) {
aRv.Throw(NS_ERROR_FAILURE);
for (const KeyStatus& status : mStatuses) {
if (keyId == status.mKeyId) {
return true;
}
}
return result;
}
template<decltype(JS::MapKeys) Method>
static void CallMapMethod(JSContext* aCx,
const JS::Heap<JSObject*>& aMap,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv,
nsresult aUpdateError)
{
if (NS_FAILED(aUpdateError)) {
aRv.Throw(aUpdateError);
return;
}
JS::Rooted<JSObject*> map(aCx, aMap);
JS::Rooted<JS::Value> result(aCx);
if (!Method(aCx, map, &result)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
aResult.set(&result.toObject());
}
void
MediaKeyStatusMap::Keys(JSContext* aCx,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv) const
{
CallMapMethod<JS::MapKeys>(aCx, mMap, aResult, aRv, mUpdateError);
}
void
MediaKeyStatusMap::Values(JSContext* aCx,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv) const
{
CallMapMethod<JS::MapValues>(aCx, mMap, aResult, aRv, mUpdateError);
}
void
MediaKeyStatusMap::Entries(JSContext* aCx,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv) const
{
CallMapMethod<JS::MapEntries>(aCx, mMap, aResult, aRv, mUpdateError);
return false;
}
uint32_t
MediaKeyStatusMap::GetSize(JSContext* aCx, ErrorResult& aRv) const
MediaKeyStatusMap::GetIterableLength() const
{
if (NS_FAILED(mUpdateError)) {
aRv.Throw(mUpdateError);
return 0;
}
JS::Rooted<JSObject*> map(aCx, mMap);
return JS::MapSize(aCx, map);
return mStatuses.Length();
}
TypedArrayCreator<ArrayBuffer>
MediaKeyStatusMap::GetKeyAtIndex(uint32_t aIndex) const
{
MOZ_ASSERT(aIndex < GetIterableLength());
return TypedArrayCreator<ArrayBuffer>(mStatuses[aIndex].mKeyId);
}
MediaKeyStatus
MediaKeyStatusMap::GetValueAtIndex(uint32_t aIndex) const
{
MOZ_ASSERT(aIndex < GetIterableLength());
return mStatuses[aIndex].mStatus;
}
uint32_t
MediaKeyStatusMap::Size() const
{
return mStatuses.Length();
}
static MediaKeyStatus
@ -188,58 +114,13 @@ ToMediaKeyStatus(GMPMediaKeyStatus aStatus) {
}
}
static bool
ToJSString(JSContext* aCx, GMPMediaKeyStatus aStatus,
JS::MutableHandle<JS::Value> aResult)
{
auto val = uint32_t(ToMediaKeyStatus(aStatus));
MOZ_ASSERT(val < ArrayLength(MediaKeyStatusValues::strings));
JSString* str = JS_NewStringCopyN(aCx,
MediaKeyStatusValues::strings[val].value,
MediaKeyStatusValues::strings[val].length);
if (!str) {
return false;
}
aResult.setString(str);
return true;
}
nsresult
MediaKeyStatusMap::UpdateInternal(const nsTArray<CDMCaps::KeyStatus>& keys)
{
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(mParent))) {
return NS_ERROR_FAILURE;
}
jsapi.TakeOwnershipOfErrorReporting();
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> map(cx, mMap);
if (!JS::MapClear(cx, map)) {
return NS_ERROR_FAILURE;
}
for (size_t i = 0; i < keys.Length(); i++) {
const auto& ks = keys[i];
JS::Rooted<JS::Value> key(cx);
JS::Rooted<JS::Value> val(cx);
if (!ToJSValue(cx, TypedArrayCreator<ArrayBuffer>(ks.mId), &key) ||
!ToJSString(cx, ks.mStatus, &val) ||
!JS::MapSet(cx, map, key, val)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
return NS_OK;
}
void
MediaKeyStatusMap::Update(const nsTArray<CDMCaps::KeyStatus>& keys)
MediaKeyStatusMap::Update(const nsTArray<CDMCaps::KeyStatus>& aKeys)
{
// Since we can't leave the map in a partial update state, we need
// to remember the error and throw it next time the interface methods
// are called.
mUpdateError = UpdateInternal(keys);
mStatuses.Clear();
for (const auto& key : aKeys) {
mStatuses.InsertElementSorted(KeyStatus(key.mId, ToMediaKeyStatus(key.mStatus)));
}
}
} // namespace dom

Просмотреть файл

@ -23,6 +23,9 @@ namespace dom {
class ArrayBufferViewOrArrayBuffer;
// The MediaKeyStatusMap WebIDL interface; maps a keyId to its status.
// Note that the underlying "map" is stored in an array, since we assume
// that a MediaKeySession won't have many key statuses to report.
class MediaKeyStatusMap final : public nsISupports,
public nsWrapperCache
{
@ -31,9 +34,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaKeyStatusMap)
public:
explicit MediaKeyStatusMap(JSContext* aCx,
nsPIDOMWindow* aParent,
ErrorResult& aRv);
explicit MediaKeyStatusMap(nsPIDOMWindow* aParent);
protected:
~MediaKeyStatusMap();
@ -43,36 +44,48 @@ public:
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
MediaKeyStatus Get(JSContext* aCx,
const ArrayBufferViewOrArrayBuffer& aKey,
ErrorResult& aRv) const;
MediaKeyStatus Get(const ArrayBufferViewOrArrayBuffer& aKey) const;
bool Has(const ArrayBufferViewOrArrayBuffer& aKey) const;
uint32_t Size() const;
bool Has(JSContext* aCx,
const ArrayBufferViewOrArrayBuffer& aKey,
ErrorResult& aRv) const;
void Keys(JSContext* aCx,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv) const;
void Values(JSContext* aCx,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv) const;
void Entries(JSContext* aCx,
JS::MutableHandle<JSObject*> aResult,
ErrorResult& aRv) const;
uint32_t GetSize(JSContext* aCx, ErrorResult& aRv) const;
uint32_t GetIterableLength() const;
TypedArrayCreator<ArrayBuffer> GetKeyAtIndex(uint32_t aIndex) const;
MediaKeyStatus GetValueAtIndex(uint32_t aIndex) const;
void Update(const nsTArray<CDMCaps::KeyStatus>& keys);
private:
nsresult UpdateInternal(const nsTArray<CDMCaps::KeyStatus>& keys);
nsCOMPtr<nsPIDOMWindow> mParent;
JS::Heap<JSObject*> mMap;
nsresult mUpdateError;
struct KeyStatus {
KeyStatus(const nsTArray<uint8_t>& aKeyId,
MediaKeyStatus aStatus)
: mKeyId(aKeyId)
, mStatus(aStatus)
{
}
bool operator== (const KeyStatus& aOther) const {
return aOther.mKeyId == mKeyId;
}
bool operator<(const KeyStatus& aOther) const {
// Copy chromium and compare keys' bytes.
// Update once https://github.com/w3c/encrypted-media/issues/69
// is resolved.
const nsTArray<uint8_t>& other = aOther.mKeyId;
const nsTArray<uint8_t>& self = mKeyId;
size_t length = std::min<size_t>(other.Length(), self.Length());
int cmp = memcmp(self.Elements(), other.Elements(), length);
if (cmp != 0) {
return cmp < 0;
}
return self.Length() <= other.Length();
}
nsTArray<uint8_t> mKeyId;
MediaKeyStatus mStatus;
};
nsTArray<KeyStatus> mStatuses;
};
} // namespace dom

Просмотреть файл

@ -145,9 +145,10 @@ MediaKeys::SetServerCertificate(const ArrayBufferViewOrArrayBuffer& aCert, Error
}
nsTArray<uint8_t> data;
if (!CopyArrayBufferViewOrArrayBufferData(aCert, data)) {
promise->MaybeReject(NS_ERROR_DOM_INVALID_ACCESS_ERR,
NS_LITERAL_CSTRING("Invalid argument to MediaKeys.setServerCertificate()"));
CopyArrayBufferViewOrArrayBufferData(aCert, data);
if (data.IsEmpty()) {
promise->MaybeReject(NS_ERROR_DOM_TYPE_ERR,
NS_LITERAL_CSTRING("Empty certificate passed to MediaKeys.setServerCertificate()"));
return promise.forget();
}
@ -502,23 +503,5 @@ MediaKeys::Bind(HTMLMediaElement* aElement)
return NS_OK;
}
bool
CopyArrayBufferViewOrArrayBufferData(const ArrayBufferViewOrArrayBuffer& aBufferOrView,
nsTArray<uint8_t>& aOutData)
{
if (aBufferOrView.IsArrayBuffer()) {
const ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
aOutData.AppendElements(buffer.Data(), buffer.Length());
} else if (aBufferOrView.IsArrayBufferView()) {
const ArrayBufferView& bufferview = aBufferOrView.GetAsArrayBufferView();
bufferview.ComputeLengthAndData();
aOutData.AppendElements(bufferview.Data(), bufferview.Length());
} else {
return false;
}
return true;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -35,12 +35,6 @@ typedef nsRefPtrHashtable<nsUint32HashKey, dom::DetailedPromise> PromiseHashMap;
typedef nsRefPtrHashtable<nsUint32HashKey, MediaKeySession> PendingKeySessionsHashMap;
typedef uint32_t PromiseId;
// Helper function to extract data coming in from JS in an
// (ArrayBuffer or ArrayBufferView) IDL typed function argument.
bool
CopyArrayBufferViewOrArrayBufferData(const ArrayBufferViewOrArrayBuffer& aBufferOrView,
nsTArray<uint8_t>& aOutData);
// This class is used on the main thread only.
// Note: it's addref/release is not (and can't be) thread safe!
class MediaKeys final : public nsISupports,

Просмотреть файл

@ -25,6 +25,7 @@
#ifdef XP_MACOSX
#include <assert.h>
#ifdef HASH_NODE_ID_WITH_DEVICE_ID
#include <unistd.h>
#include <mach/mach.h>
#include <mach/mach_vm.h>
#endif

Просмотреть файл

@ -36,8 +36,8 @@ public:
virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType) override {}
#endif // MOZ_EME
virtual bool IsActive() override { return true; }
virtual bool IsHidden() override { return false; }
virtual bool IsActive() const override { return true; }
virtual bool IsHidden() const override { return false; }
virtual void DownloadSuspended() override {}
virtual void DownloadResumed(bool aForceNetworkLoading) override {}
virtual void NotifySuspendedByCache(bool aIsSuspended) override {}

Просмотреть файл

@ -61,6 +61,9 @@ MockMediaResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount,
int64_t
MockMediaResource::GetLength()
{
if (mFileHandle == nullptr) {
return -1;
}
fseek(mFileHandle, 0, SEEK_END);
return ftell(mFileHandle);
}

Просмотреть файл

@ -12,6 +12,8 @@
using namespace mozilla;
using namespace mozilla::mp3;
using media::TimeUnit;
// Regular MP3 file mock resource.
class MockMP3MediaResource : public MockMediaResource {
@ -190,6 +192,44 @@ protected:
mTargets.push_back(streamRes);
}
{
MP3Resource res;
res.mFilePath = "small-shot.mp3";
res.mIsVBR = true;
res.mFileSize = 6825;
res.mMPEGLayer = 3;
res.mMPEGVersion = 1;
res.mID3MajorVersion = 4;
res.mID3MinorVersion = 0;
res.mID3Flags = 0;
res.mID3Size = 24;
res.mDuration = 336686;
res.mDurationError = 0.01f;
res.mSeekError = 0.2f;
res.mSampleRate = 44100;
res.mSamplesPerFrame = 1152;
res.mNumSamples = 12;
res.mNumTrailingFrames = 0;
res.mBitrate = 256000;
res.mSlotSize = 1;
res.mPrivate = 0;
const int syncs[] = { 34, 556, 1078, 1601, 2123, 2646, 3168, 3691, 4213,
4736, 5258, 5781, 6303 };
res.mSyncOffsets.insert(res.mSyncOffsets.begin(), syncs, syncs + 13);
// No content length can be estimated for CBR stream resources.
MP3Resource streamRes = res;
streamRes.mFileSize = -1;
res.mResource = new MockMP3MediaResource(res.mFilePath);
res.mDemuxer = new MP3TrackDemuxer(res.mResource);
mTargets.push_back(res);
streamRes.mResource = new MockMP3StreamMediaResource(streamRes.mFilePath);
streamRes.mDemuxer = new MP3TrackDemuxer(streamRes.mResource);
mTargets.push_back(streamRes);
}
for (auto& target: mTargets) {
ASSERT_EQ(NS_OK, target.mResource->Open(nullptr));
ASSERT_TRUE(target.mDemuxer->Init());
@ -307,11 +347,34 @@ TEST_F(MP3DemuxerTest, Duration) {
frameData = target.mDemuxer->DemuxSample();
}
}
// Seek out of range tests.
for (const auto& target: mTargets) {
// Skip tests for stream media resources because of lacking duration.
if (target.mFileSize <= 0) {
continue;
}
target.mDemuxer->Reset();
RefPtr<MediaRawData> frameData(target.mDemuxer->DemuxSample());
ASSERT_TRUE(frameData);
const int64_t duration = target.mDemuxer->Duration().ToMicroseconds();
const int64_t pos = duration + 1e6;
// Attempt to seek 1 second past the end of stream.
target.mDemuxer->Seek(TimeUnit::FromMicroseconds(pos));
// The seek should bring us to the end of the stream.
EXPECT_NEAR(duration, target.mDemuxer->SeekPosition().ToMicroseconds(),
target.mSeekError * duration);
// Since we're at the end of the stream, there should be no frames left.
frameData = target.mDemuxer->DemuxSample();
ASSERT_FALSE(frameData);
}
}
TEST_F(MP3DemuxerTest, Seek) {
using media::TimeUnit;
for (const auto& target: mTargets) {
RefPtr<MediaRawData> frameData(target.mDemuxer->DemuxSample());
ASSERT_TRUE(frameData);

Просмотреть файл

@ -48,6 +48,7 @@ TEST_HARNESS_FILES.gtest += [
'noise.mp3',
'noise_vbr.mp3',
'short-zero-in-moov.mp4',
'small-shot.mp3',
'test.webm',
]

Двоичные данные
dom/media/gtest/small-shot.mp3 Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -7,7 +7,7 @@ load 474744-1.html
HTTP load 481136-1.html # needs to be HTTP to recognize the ogg as an audio file?
load 492286-1.xhtml
load 493915-1.html
load 495794-1.html
skip-if(B2G) load 495794-1.html # in b2g all the media are muted by default
load 576612-1.html
load 752784-1.html
load 789075-1.html

Просмотреть файл

@ -12,6 +12,19 @@
<script class="testbody" type="text/javascript">
var manager = new MediaTestManager;
function ArrayBuffersEqual(a, b) {
if (a.byteLength != b.byteLength) {
return false;
}
var ua = new Uint8Array(a);
var ub = new Uint8Array(b);
for (var i = 0; i < ua.length; i++) {
if (ua[i] != ub[i]) {
return false;
}
}
return true;
}
function KeysChangeFunc(session, keys, token) {
session.keyIdsReceived = [];
@ -23,13 +36,32 @@ function KeysChangeFunc(session, keys, token) {
var session = ev.target;
session.gotKeysChanged = true;
var keyList = [];
var valueList = [];
var map = session.keyStatuses;
for (var [key, val] of map.entries()) {
is(key.constructor, ArrayBuffer, "keyId should be ArrayBuffer");
ok(map.has(key), "MediaKeyStatusMap.has() should work.");
is(map.get(key), val, "MediaKeyStatusMap.get() should work.");
keyList.push(key);
valueList.push(val);
is(val, "usable", token + ": key status should be usable");
var kid = Base64ToHex(window.btoa(ArrayBufferToString(key)));
ok(kid in session.keyIdsReceived, TimeStamp(token) + " session[" + session.sessionId + "].keyIdsReceived contained " + kid + " as expected.");
session.keyIdsReceived[kid] = true;
}
var index = 0;
for (var keyId of map.keys()) {
ok(ArrayBuffersEqual(keyId, keyList[index]), "MediaKeyStatusMap.keys() should correspond to entries");
index++;
}
index = 0;
for (var val of map.values()) {
is(val, valueList[index], "MediaKeyStatusMap.values() should correspond to entries");
index++;
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше