merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2015-05-26 12:07:11 +02:00
Родитель fa34ccca1f 838880e42a
Коммит a9bac08932
19 изменённых файлов: 300 добавлений и 208 удалений

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

@ -1,4 +1,4 @@
const gTestRoot = getRootDirectory(gTestPath);
const gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
const gStyleSheet = "bug839103.css";
var gTab = null;

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

@ -4242,7 +4242,7 @@ nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
event->SetTarget(this); \
nsRefPtr<AsyncEventDispatcher> asyncDispatcher = \
new AsyncEventDispatcher(this, event); \
asyncDispatcher->mDispatchChromeOnly = true; \
asyncDispatcher->mOnlyChromeDispatch = true; \
asyncDispatcher->PostDOMEvent(); \
} while (0);

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

@ -23,7 +23,7 @@ using namespace dom;
AsyncEventDispatcher::AsyncEventDispatcher(EventTarget* aTarget,
WidgetEvent& aEvent)
: mTarget(aTarget)
, mDispatchChromeOnly(false)
, mOnlyChromeDispatch(false)
{
MOZ_ASSERT(mTarget);
EventDispatcher::CreateEvent(aTarget, nullptr, &aEvent, EmptyString(),
@ -36,44 +36,19 @@ AsyncEventDispatcher::AsyncEventDispatcher(EventTarget* aTarget,
NS_IMETHODIMP
AsyncEventDispatcher::Run()
{
if (mEvent) {
if (mDispatchChromeOnly) {
MOZ_ASSERT(mEvent->InternalDOMEvent()->IsTrusted());
nsCOMPtr<nsINode> node = do_QueryInterface(mTarget);
MOZ_ASSERT(node, "ChromeOnly dispatch supported with Node targets only!");
nsPIDOMWindow* window = node->OwnerDoc()->GetWindow();
if (!window) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<EventTarget> target = window->GetParentTarget();
if (!target) {
return NS_ERROR_INVALID_ARG;
}
EventDispatcher::DispatchDOMEvent(target, nullptr, mEvent,
nullptr, nullptr);
} else {
bool defaultActionEnabled; // This is not used because the caller is async
mTarget->DispatchEvent(mEvent, &defaultActionEnabled);
}
} else {
if (mDispatchChromeOnly) {
nsCOMPtr<nsINode> node = do_QueryInterface(mTarget);
MOZ_ASSERT(node, "ChromeOnly dispatch supported with Node targets only!");
nsContentUtils::DispatchChromeEvent(node->OwnerDoc(), node, mEventType,
mBubbles, false);
} else {
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMEvent(getter_AddRefs(event), mTarget, nullptr, nullptr);
nsresult rv = event->InitEvent(mEventType, mBubbles, false);
NS_ENSURE_SUCCESS(rv, rv);
event->SetTrusted(true);
bool dummy;
mTarget->DispatchEvent(event, &dummy);
}
nsCOMPtr<nsIDOMEvent> event = mEvent;
if (!event) {
NS_NewDOMEvent(getter_AddRefs(event), mTarget, nullptr, nullptr);
nsresult rv = event->InitEvent(mEventType, mBubbles, false);
NS_ENSURE_SUCCESS(rv, rv);
event->SetTrusted(true);
}
if (mOnlyChromeDispatch) {
MOZ_ASSERT(event->InternalDOMEvent()->IsTrusted());
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
}
bool dummy;
mTarget->DispatchEvent(event, &dummy);
return NS_OK;
}

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

@ -28,12 +28,18 @@ namespace mozilla {
class AsyncEventDispatcher : public nsRunnable
{
public:
/**
* If aOnlyChromeDispatch is true, the event is dispatched to only
* chrome node. In that case, if aTarget is already a chrome node,
* the event is dispatched to it, otherwise the dispatch path starts
* at the first chrome ancestor of that target.
*/
AsyncEventDispatcher(nsINode* aTarget, const nsAString& aEventType,
bool aBubbles, bool aDispatchChromeOnly)
bool aBubbles, bool aOnlyChromeDispatch)
: mTarget(aTarget)
, mEventType(aEventType)
, mBubbles(aBubbles)
, mDispatchChromeOnly(aDispatchChromeOnly)
, mOnlyChromeDispatch(aOnlyChromeDispatch)
{
}
@ -42,14 +48,14 @@ public:
: mTarget(aTarget)
, mEventType(aEventType)
, mBubbles(aBubbles)
, mDispatchChromeOnly(false)
, mOnlyChromeDispatch(false)
{
}
AsyncEventDispatcher(dom::EventTarget* aTarget, nsIDOMEvent* aEvent)
: mTarget(aTarget)
, mEvent(aEvent)
, mDispatchChromeOnly(false)
, mOnlyChromeDispatch(false)
{
}
@ -63,7 +69,7 @@ public:
nsCOMPtr<nsIDOMEvent> mEvent;
nsString mEventType;
bool mBubbles;
bool mDispatchChromeOnly;
bool mOnlyChromeDispatch;
};
class LoadBlockingAsyncEventDispatcher final : public AsyncEventDispatcher

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

@ -481,6 +481,13 @@ Event::StopImmediatePropagation()
return NS_OK;
}
NS_IMETHODIMP
Event::StopCrossProcessForwarding()
{
mEvent->mFlags.mNoCrossProcessBoundaryForwarding = true;
return NS_OK;
}
NS_IMETHODIMP
Event::GetIsTrusted(bool* aIsTrusted)
{

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

@ -309,6 +309,7 @@ private:
NS_IMETHOD GetCancelable(bool* aCancelable) override { return _to GetCancelable(aCancelable); } \
NS_IMETHOD GetTimeStamp(DOMTimeStamp* aTimeStamp) override { return _to GetTimeStamp(aTimeStamp); } \
NS_IMETHOD StopPropagation(void) override { return _to StopPropagation(); } \
NS_IMETHOD StopCrossProcessForwarding(void) override { return _to StopCrossProcessForwarding(); } \
NS_IMETHOD PreventDefault(void) override { return _to PreventDefault(); } \
NS_IMETHOD InitEvent(const nsAString& eventTypeArg, bool canBubbleArg, bool cancelableArg) override { return _to InitEvent(eventTypeArg, canBubbleArg, cancelableArg); } \
NS_IMETHOD GetDefaultPrevented(bool* aDefaultPrevented) override { return _to GetDefaultPrevented(aDefaultPrevented); } \

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

@ -40,7 +40,7 @@ class EventTarget;
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[builtinclass, uuid(02d54f52-a1f5-4ad2-b560-36f14012935e)]
[builtinclass, uuid(63857daf-c084-4ea6-a8b9-6812e3176991)]
interface nsIDOMEvent : nsISupports
{
// PhaseType
@ -213,6 +213,7 @@ interface nsIDOMEvent : nsISupports
[notxpcom] boolean Deserialize(in ConstIPCMessagePtr aMsg, out voidPtr aIter);
[noscript,notxpcom] void SetOwner(in EventTargetPtr aOwner);
[notxpcom] DOMEventPtr InternalDOMEvent();
[noscript] void stopCrossProcessForwarding();
};
%{C++

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

@ -21,7 +21,7 @@
*/
/*exported EXPORTED_SYMBOLS */
/*JSLint options in comment below: */
/*globals Components, XPCOMUtils*/
/*globals Components, XPCOMUtils, Intl*/
'use strict';
this.EXPORTED_SYMBOLS = ['ManifestProcessor']; // jshint ignore:line
const imports = {};
@ -100,6 +100,7 @@ ManifestProcessor.prototype = {
const extractor = new ManifestValueExtractor(console);
const imgObjProcessor = new ImgObjProcessor(console, extractor);
const processedManifest = {
'lang': processLangMember(rawManifest),
'start_url': processStartURLMember(rawManifest, manifestURL, docURL),
'display': processDisplayMember(rawManifest),
'orientation': processOrientationMember(rawManifest),
@ -246,7 +247,26 @@ ManifestProcessor.prototype = {
};
return extractor.extractColorValue(spec);
}
function processLangMember(aManifest) {
const spec = {
objectName: 'manifest',
object: aManifest,
property: 'lang',
expectedType: 'string',
trim: true
};
let tag = extractor.extractValue(spec);
// TODO: Check if tag is structurally valid.
// Cannot do this because we don't support Intl API on Android.
// https://bugzilla.mozilla.org/show_bug.cgi?id=864843
// https://github.com/tc39/ecma402/issues/5
// TODO: perform canonicalization on the tag.
// Can't do this today because there is no direct means to
// access canonicalization algorithms through Intl API.
// https://github.com/tc39/ecma402/issues/5
return tag;
}
}
};
this.ManifestProcessor = ManifestProcessor; // jshint ignore:line

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

@ -3,7 +3,6 @@ support-files =
common.js
resource.sjs
manifestLoader.html
[test_ImageObjectProcessor_background_color.html]
[test_ImageObjectProcessor_density.html]
[test_ImageObjectProcessor_sizes.html]
@ -12,8 +11,9 @@ support-files =
[test_ManifestProcessor_display.html]
[test_ManifestProcessor_icons.html]
[test_ManifestProcessor_JSON.html]
[test_ManifestProcessor_lang.html]
[test_ManifestProcessor_name_and_short_name.html]
[test_ManifestProcessor_orientation.html]
[test_ManifestProcessor_start_url.html]
[test_ManifestProcessor_scope.html]
[test_ManifestProcessor_splash_screens.html]
[test_ManifestProcessor_start_url.html]

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

@ -0,0 +1,112 @@
<!DOCTYPE HTML>
<!--
Bug 1143879 - Implement lang member of Web manifest
https://bugzilla.mozilla.org/show_bug.cgi?id=1143879
-->
<meta charset="utf-8">
<title>Test for Bug 1143879 - Implement lang member of Web manifest</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script src="common.js"></script>
<script>
/**
* lang member
* https://w3c.github.io/manifest/#lang-member
**/
/*globals is, typeTests, data, processor, seperators, lineTerminators, todo_is*/
'use strict';
// Type checks: checks that only strings are accepted.
for (var type of typeTests) {
var expected = `Expect non-string to be undefined.`;
data.jsonText = JSON.stringify({
lang: type
});
var result = processor.process(data);
is(result.lang, undefined, expected);
}
// Test valid language tags - derived from IANA and BCP-47 spec
// and our Intl.js implementation.
var validTags = [
'aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', 'ar', 'as', 'av', 'ay', 'az',
'ba', 'be', 'bg', 'bh', 'bi', 'bm', 'bn', 'bo', 'br', 'bs', 'ca', 'ce',
'ch', 'co', 'cr', 'cs', 'cu', 'cv', 'cy', 'da', 'de', 'dv', 'dz', 'ee',
'el', 'en', 'eo', 'es', 'et', 'eu', 'fa', 'ff', 'fi', 'fj', 'fo', 'fr',
'fy', 'ga', 'gd', 'gl', 'gn', 'gu', 'gv', 'ha', 'he', 'hi', 'ho', 'hr',
'ht', 'hu', 'hy', 'hz', 'ia', 'id', 'ie', 'ig', 'ik', 'in', 'io',
'is', 'it', 'iu', 'iw', 'ja', 'ji', 'jv', 'jw', 'ka', 'kg', 'ki', 'kj',
'kk', 'kl', 'km', 'kn', 'ko', 'kr', 'ks', 'ku', 'kv', 'kw', 'ky', 'la',
'lb', 'lg', 'li', 'ln', 'lo', 'lt', 'lu', 'lv', 'mg', 'mh', 'mi', 'mk',
'ml', 'mn', 'mo', 'mr', 'ms', 'mt', 'my', 'na', 'nb', 'nd', 'ne', 'ng',
'nl', 'nn', 'no', 'nr', 'nv', 'ny', 'oc', 'oj', 'om', 'or', 'os', 'pa',
'pi', 'pl', 'ps', 'pt', 'qu', 'rm', 'rn', 'ro', 'ru', 'rw', 'sa', 'sc',
'sd', 'se', 'sg', 'sh', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'sr',
'ss', 'st', 'su', 'sv', 'sw', 'ta', 'te', 'tg', 'th', 'ti', 'tk', 'tl',
'tn', 'to', 'tr', 'ts', 'tt', 'tw', 'ty', 'ug', 'uk', 'ur', 'uz', 've',
'vi', 'vo', 'wa', 'wo', 'xh', 'yi', 'yo', 'za', 'zh', 'zu', 'en-US',
'jp-JS', 'pt-PT', 'pt-BR', 'de-CH', 'de-DE-1901', 'es-419', 'sl-IT-nedis',
'en-US-boont', 'mn-Cyrl-MN', 'x-fr-CH', 'sr-Cyrl', 'sr-Latn',
'hy-Latn-IT-arevela', 'zh-TW', 'en-GB-boont-r-extended-sequence-x-private',
'zh-nan-hans-bu-variant2-variant1-u-ca-chinese-t-zh-latn-x-private',
'zh-cmn-Hans-CN', 'cmn-Hans-CN', 'zh-yue-HK', 'yue-HK',
'de-CH-x-phonebk', 'az-Arab-x-AZE-derbend', 'x-whatever',
'qaa-Qaaa-QM-x-southern'
];
for (var tag of validTags) {
var expected = `Expect lang to be ${tag}.`;
data.jsonText = JSON.stringify({
lang: tag
});
var result = processor.process(data);
is(result.lang, tag, expected);
}
// trim tests - check that language tags get trimmed properly.
for (var tag of validTags) {
var expected = `Expect trimmed tag to be returned.`;
var expandedtag = seperators + lineTerminators + tag;
expandedtag += lineTerminators + seperators;
data.jsonText = JSON.stringify({
lang: expandedtag
});
var result = processor.process(data);
is(result.lang, tag, expected);
}
//Invalid language tags, derived from BCP-47 and made up.
var invalidTags = [
'de-419-DE', ' a-DE ', 'ar-a-aaa-b-bbb-a-ccc', 'sdafsdfaadsfdsf', 'i',
'i-phone', 'en US', 'EN-*-US-JP', 'JA-INVALID-TAG', '123123123'
];
for (var item of invalidTags) {
var expected = `Expect invalid tag (${item}) to be treated as undefined.`;
data.jsonText = JSON.stringify({
lang: item
});
var result = processor.process(data);
todo_is(result.lang, undefined, expected);
}
// Canonical form conversion tests. We convert the following tags, which are in
// canonical form, to upper case and expect the processor to return them
// in canonical form.
var canonicalTags = [
'jp-JS', 'pt-PT', 'pt-BR', 'de-CH', 'de-DE-1901', 'es-419', 'sl-IT-nedis',
'en-US-boont', 'mn-Cyrl-MN', 'x-fr-CH', 'sr-Cyrl', 'sr-Latn',
'hy-Latn-IT-arevela', 'zh-TW', 'en-GB-boont-r-extended-sequence-x-private',
'zh-cmn-Hans-CN', 'cmn-Hans-CN', 'zh-yue-HK', 'yue-HK',
'de-CH-x-phonebk', 'az-Arab-x-AZE-derbend', 'x-whatever',
'qaa-Qaaa-QM-x-southern'
];
for (var tag of canonicalTags) {
var uppedTag = tag.toUpperCase();
var expected = `Expect tag (${uppedTag}) to be in canonical form (${tag}).`;
data.jsonText = JSON.stringify({
lang: uppedTag
});
var result = processor.process(data);
todo_is(result.lang, tag, expected);
}
</script>

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

@ -159,11 +159,6 @@ private:
nsRefPtr<MediaStream> mStream;
};
OutputStreamData::OutputStreamData()
{
//
}
OutputStreamData::~OutputStreamData()
{
mListener->Forget();
@ -195,6 +190,33 @@ DecodedStream::DestroyData()
{
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
// Avoid the redundant blocking to output stream.
if (!mData) {
return;
}
// All streams are having their SourceMediaStream disconnected, so they
// need to be explicitly blocked again.
auto& outputStreams = OutputStreams();
for (int32_t i = outputStreams.Length() - 1; i >= 0; --i) {
OutputStreamData& os = outputStreams[i];
// Explicitly remove all existing ports.
// This is not strictly necessary but it's good form.
MOZ_ASSERT(os.mPort, "Double-delete of the ports!");
os.mPort->Destroy();
os.mPort = nullptr;
// During cycle collection, nsDOMMediaStream can be destroyed and send
// its Destroy message before this decoder is destroyed. So we have to
// be careful not to send any messages after the Destroy().
if (os.mStream->IsDestroyed()) {
// Probably the DOM MediaStream was GCed. Clean up.
outputStreams.RemoveElementAt(i);
} else {
os.mStream->ChangeExplicitBlockerCount(1);
}
}
mData = nullptr;
}
@ -204,7 +226,18 @@ DecodedStream::RecreateData(int64_t aInitialTime, SourceMediaStream* aStream)
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
MOZ_ASSERT(!mData);
mData.reset(new DecodedStreamData(aInitialTime, aStream));
// Note that the delay between removing ports in DestroyDecodedStream
// and adding new ones won't cause a glitch since all graph operations
// between main-thread stable states take effect atomically.
auto& outputStreams = OutputStreams();
for (int32_t i = outputStreams.Length() - 1; i >= 0; --i) {
OutputStreamData& os = outputStreams[i];
MOZ_ASSERT(!os.mStream->IsDestroyed(), "Should've been removed in DestroyData()");
Connect(&os);
}
}
nsTArray<OutputStreamData>&
@ -220,4 +253,35 @@ DecodedStream::GetReentrantMonitor()
return mMonitor;
}
void
DecodedStream::Connect(OutputStreamData* aStream)
{
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
NS_ASSERTION(!aStream->mPort, "Already connected?");
// The output stream must stay in sync with the decoded stream, so if
// either stream is blocked, we block the other.
aStream->mPort = aStream->mStream->AllocateInputPort(mData->mStream,
MediaInputPort::FLAG_BLOCK_INPUT | MediaInputPort::FLAG_BLOCK_OUTPUT);
// Unblock the output stream now. While it's connected to DecodedStream,
// DecodedStream is responsible for controlling blocking.
aStream->mStream->ChangeExplicitBlockerCount(-1);
}
void
DecodedStream::Connect(ProcessedMediaStream* aStream, bool aFinishWhenEnded)
{
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
OutputStreamData* os = OutputStreams().AppendElement();
os->Init(this, aStream);
Connect(os);
if (aFinishWhenEnded) {
// Ensure that aStream finishes the moment mDecodedStream does.
aStream->SetAutofinish(true);
}
}
} // namespace mozilla

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

@ -19,7 +19,6 @@ class SourceMediaStream;
class ProcessedMediaStream;
class DecodedStream;
class DecodedStreamGraphListener;
class OutputStreamData;
class OutputStreamListener;
class ReentrantMonitor;
@ -82,11 +81,6 @@ public:
class OutputStreamData {
public:
// Compiler-generated default constructor needs the complete definition
// of OutputStreamListener when constructing OutputStreamData. Provide our
// own default constructor for forward declaration of OutputStreamListener
// to work.
OutputStreamData();
~OutputStreamData();
void Init(DecodedStream* aDecodedStream, ProcessedMediaStream* aStream);
nsRefPtr<ProcessedMediaStream> mStream;
@ -103,8 +97,11 @@ public:
void RecreateData(int64_t aInitialTime, SourceMediaStream* aStream);
nsTArray<OutputStreamData>& OutputStreams();
ReentrantMonitor& GetReentrantMonitor();
void Connect(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
private:
void Connect(OutputStreamData* aStream);
UniquePtr<DecodedStreamData> mData;
// Data about MediaStreams that are being fed by the decoder.
nsTArray<OutputStreamData> mOutputStreams;

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

@ -289,19 +289,6 @@ void MediaDecoder::SetVolume(double aVolume)
mVolume = aVolume;
}
void MediaDecoder::ConnectDecodedStreamToOutputStream(OutputStreamData* aStream)
{
NS_ASSERTION(!aStream->mPort, "Already connected?");
// The output stream must stay in sync with the decoded stream, so if
// either stream is blocked, we block the other.
aStream->mPort = aStream->mStream->AllocateInputPort(GetDecodedStream()->mStream,
MediaInputPort::FLAG_BLOCK_INPUT | MediaInputPort::FLAG_BLOCK_OUTPUT);
// Unblock the output stream now. While it's connected to mDecodedStream,
// mDecodedStream is responsible for controlling blocking.
aStream->mStream->ChangeExplicitBlockerCount(-1);
}
void MediaDecoder::UpdateDecodedStream()
{
MOZ_ASSERT(NS_IsMainThread());
@ -316,40 +303,6 @@ void MediaDecoder::UpdateDecodedStream()
}
}
void MediaDecoder::DestroyDecodedStream()
{
MOZ_ASSERT(NS_IsMainThread());
GetReentrantMonitor().AssertCurrentThreadIn();
// Avoid the redundant blocking to output stream.
if (!GetDecodedStream()) {
return;
}
// All streams are having their SourceMediaStream disconnected, so they
// need to be explicitly blocked again.
auto& outputStreams = OutputStreams();
for (int32_t i = outputStreams.Length() - 1; i >= 0; --i) {
OutputStreamData& os = outputStreams[i];
// Explicitly remove all existing ports.
// This is not strictly necessary but it's good form.
MOZ_ASSERT(os.mPort, "Double-delete of the ports!");
os.mPort->Destroy();
os.mPort = nullptr;
// During cycle collection, nsDOMMediaStream can be destroyed and send
// its Destroy message before this decoder is destroyed. So we have to
// be careful not to send any messages after the Destroy().
if (os.mStream->IsDestroyed()) {
// Probably the DOM MediaStream was GCed. Clean up.
outputStreams.RemoveElementAt(i);
} else {
os.mStream->ChangeExplicitBlockerCount(1);
}
}
mDecodedStream.DestroyData();
}
void MediaDecoder::UpdateStreamBlockingForStateMachinePlaying()
{
GetReentrantMonitor().AssertCurrentThreadIn();
@ -382,20 +335,10 @@ void MediaDecoder::RecreateDecodedStream(int64_t aStartTimeUSecs,
if (!aGraph) {
aGraph = GetDecodedStream()->mStream->Graph();
}
DestroyDecodedStream();
mDecodedStream.DestroyData();
mDecodedStream.RecreateData(aStartTimeUSecs, aGraph->CreateSourceStream(nullptr));
// Note that the delay between removing ports in DestroyDecodedStream
// and adding new ones won't cause a glitch since all graph operations
// between main-thread stable states take effect atomically.
auto& outputStreams = OutputStreams();
for (int32_t i = outputStreams.Length() - 1; i >= 0; --i) {
OutputStreamData& os = outputStreams[i];
MOZ_ASSERT(!os.mStream->IsDestroyed(),
"Should've been removed in DestroyDecodedStream()");
ConnectDecodedStreamToOutputStream(&os);
}
UpdateStreamBlockingForStateMachinePlaying();
GetDecodedStream()->mHaveBlockedForPlayState = mPlayState != PLAY_STATE_PLAYING;
@ -418,13 +361,7 @@ void MediaDecoder::AddOutputStream(ProcessedMediaStream* aStream,
if (!GetDecodedStream()) {
RecreateDecodedStream(mLogicalPosition, aStream->Graph());
}
OutputStreamData* os = OutputStreams().AppendElement();
os->Init(&mDecodedStream, aStream);
ConnectDecodedStreamToOutputStream(os);
if (aFinishWhenEnded) {
// Ensure that aStream finishes the moment mDecodedStream does.
aStream->SetAutofinish(true);
}
mDecodedStream.Connect(aStream, aFinishWhenEnded);
}
// This can be called before Load(), in which case our mDecoderStateMachine
@ -575,7 +512,7 @@ MediaDecoder::~MediaDecoder()
// Don't destroy the decoded stream until destructor in order to keep the
// invariant that the decoded stream is always available in capture mode.
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
DestroyDecodedStream();
mDecodedStream.DestroyData();
}
MediaMemoryTracker::RemoveMediaDecoder(this);
UnpinForSeek();

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

@ -395,18 +395,8 @@ public:
// replaying after the input as ended. In the latter case, the new source is
// not connected to streams created by captureStreamUntilEnded.
/**
* Connects mDecodedStream->mStream to aStream->mStream.
*/
void ConnectDecodedStreamToOutputStream(OutputStreamData* aStream);
void UpdateDecodedStream();
/**
* Disconnects mDecodedStream->mStream from all outputs and clears
* mDecodedStream.
*/
void DestroyDecodedStream();
/**
* Recreates mDecodedStream. Call this to create mDecodedStream at first,
* and when seeking, to ensure a new stream is set up with fresh buffers.
@ -421,12 +411,6 @@ public:
*/
void UpdateStreamBlockingForStateMachinePlaying();
nsTArray<OutputStreamData>& OutputStreams()
{
GetReentrantMonitor().AssertCurrentThreadIn();
return mDecodedStream.OutputStreams();
}
DecodedStreamData* GetDecodedStream()
{
GetReentrantMonitor().AssertCurrentThreadIn();

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

@ -47,7 +47,7 @@ bool
MediaOmxCommonDecoder::CheckDecoderCanOffloadAudio()
{
return (mCanOffloadAudio && !mFallbackToStateMachine &&
!OutputStreams().Length() && mPlaybackRate == 1.0);
!GetDecodedStream() && mPlaybackRate == 1.0);
}
void

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

@ -208,9 +208,9 @@ IMFYCbCrImage::GetD3D9TextureClient(CompositableClient* aClient)
TextureClient*
IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
{
ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11MediaDevice();
ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11ImageBridgeDevice();
if (!device ||
aClient->GetForwarder()->GetCompositorBackendType() != LayersBackend::LAYERS_D3D11) {
aClient->GetForwarder()->GetCompositorBackendType() != LayersBackend::LAYERS_D3D11) {
IDirect3DDevice9* d3d9device = gfxWindowsPlatform::GetPlatform()->GetD3D9Device();
if (d3d9device && aClient->GetForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D9) {

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

@ -411,7 +411,6 @@ NS_IMPL_ISUPPORTS(D3D9SharedTextureReporter, nsIMemoryReporter)
gfxWindowsPlatform::gfxWindowsPlatform()
: mD3D11DeviceInitialized(false)
, mIsWARP(false)
, mCanInitMediaDevice(false)
, mHasDeviceReset(false)
{
mUseClearTypeForDownloadableFonts = UNINITIALIZED_VALUE;
@ -1600,55 +1599,15 @@ gfxWindowsPlatform::GetD3D11ContentDevice()
}
ID3D11Device*
gfxWindowsPlatform::GetD3D11MediaDevice()
gfxWindowsPlatform::GetD3D11ImageBridgeDevice()
{
if (mD3D11MediaDevice) {
return mD3D11MediaDevice;
if (mD3D11DeviceInitialized) {
return mD3D11ImageBridgeDevice;
}
if (!mCanInitMediaDevice) {
return nullptr;
}
InitD3D11Devices();
mCanInitMediaDevice = false;
nsModuleHandle d3d11Module(LoadLibrarySystem32(L"d3d11.dll"));
decltype(D3D11CreateDevice)* d3d11CreateDevice = (decltype(D3D11CreateDevice)*)
GetProcAddress(d3d11Module, "D3D11CreateDevice");
MOZ_ASSERT(d3d11CreateDevice);
nsTArray<D3D_FEATURE_LEVEL> featureLevels;
if (IsWin8OrLater()) {
featureLevels.AppendElement(D3D_FEATURE_LEVEL_11_1);
}
featureLevels.AppendElement(D3D_FEATURE_LEVEL_11_0);
featureLevels.AppendElement(D3D_FEATURE_LEVEL_10_1);
featureLevels.AppendElement(D3D_FEATURE_LEVEL_10_0);
featureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
RefPtr<IDXGIAdapter1> adapter = GetDXGIAdapter();
MOZ_ASSERT(adapter);
HRESULT hr = E_INVALIDARG;
MOZ_SEH_TRY{
hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
featureLevels.Elements(), featureLevels.Length(),
D3D11_SDK_VERSION, byRef(mD3D11MediaDevice), nullptr, nullptr);
} MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
mD3D11MediaDevice = nullptr;
}
d3d11Module.disown();
if (FAILED(hr)) {
return nullptr;
}
mD3D11MediaDevice->SetExceptionMode(0);
return mD3D11MediaDevice;
return mD3D11ImageBridgeDevice;
}
@ -1776,19 +1735,11 @@ bool DoesD3D11DeviceWork(ID3D11Device *device)
// See bug 1083071. On some drivers, Direct3D 11 CreateShaderResourceView fails
// with E_OUTOFMEMORY.
bool DoesD3D11TextureSharingWork(ID3D11Device *device)
bool DoesD3D11TextureSharingWorkInternal(ID3D11Device *device, DXGI_FORMAT format, UINT bindflags)
{
static bool checked = false;
static bool result = false;
if (checked)
return result;
checked = true;
if (gfxPrefs::Direct2DForceEnabled() ||
gfxPrefs::LayersAccelerationForceEnabled())
{
result = true;
return true;
}
@ -1813,13 +1764,13 @@ bool DoesD3D11TextureSharingWork(ID3D11Device *device)
desc.Height = 32;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
desc.Format = format;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.CPUAccessFlags = 0;
desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
desc.BindFlags = bindflags;
if (FAILED(device->CreateTexture2D(&desc, NULL, byRef(texture)))) {
return false;
}
@ -1860,10 +1811,22 @@ bool DoesD3D11TextureSharingWork(ID3D11Device *device)
return false;
}
result = true;
return true;
}
bool DoesD3D11TextureSharingWork(ID3D11Device *device)
{
static bool checked;
static bool result;
if (checked)
return result;
checked = true;
result = DoesD3D11TextureSharingWorkInternal(device, DXGI_FORMAT_B8G8R8A8_UNORM, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE);
return result;
}
void
gfxWindowsPlatform::InitD3D11Devices()
{
@ -2035,7 +1998,27 @@ gfxWindowsPlatform::InitD3D11Devices()
}
if (!useWARP) {
mCanInitMediaDevice = true;
hr = E_INVALIDARG;
MOZ_SEH_TRY{
hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr,
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
featureLevels.Elements(), featureLevels.Length(),
D3D11_SDK_VERSION, byRef(mD3D11ImageBridgeDevice), nullptr, nullptr);
} MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
mD3D11ImageBridgeDevice = nullptr;
}
if (FAILED(hr)) {
d3d11Module.disown();
return;
}
mD3D11ImageBridgeDevice->SetExceptionMode(0);
if (!DoesD3D11TextureSharingWorkInternal(mD3D11ImageBridgeDevice, DXGI_FORMAT_A8_UNORM, D3D11_BIND_SHADER_RESOURCE)) {
mD3D11ImageBridgeDevice = nullptr;
}
}
// We leak these everywhere and we need them our entire runtime anyway, let's

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

@ -244,7 +244,8 @@ public:
#endif
ID3D11Device *GetD3D11Device();
ID3D11Device *GetD3D11ContentDevice();
ID3D11Device *GetD3D11MediaDevice();
// Device to be used on the ImageBridge thread
ID3D11Device *GetD3D11ImageBridgeDevice();
// Create a D3D11 device to be used for DXVA decoding.
mozilla::TemporaryRef<ID3D11Device> CreateD3D11DecoderDevice();
@ -294,11 +295,10 @@ private:
nsRefPtr<mozilla::layers::DeviceManagerD3D9> mDeviceManager;
mozilla::RefPtr<ID3D11Device> mD3D11Device;
mozilla::RefPtr<ID3D11Device> mD3D11ContentDevice;
mozilla::RefPtr<ID3D11Device> mD3D11MediaDevice;
mozilla::RefPtr<ID3D11Device> mD3D11ImageBridgeDevice;
bool mD3D11DeviceInitialized;
mozilla::RefPtr<mozilla::layers::ReadbackManagerD3D11> mD3D11ReadbackManager;
bool mIsWARP;
bool mCanInitMediaDevice;
bool mHasDeviceReset;
DeviceResetReason mDeviceResetReason;

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

@ -2178,6 +2178,7 @@ nsXULPopupManager::HandleKeyboardEventWithKeyCode(
if (keyCode == nsIDOMKeyEvent::DOM_VK_ESCAPE) {
HidePopup(aTopVisibleMenuItem->Content(), false, false, false, true);
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
}
return true;
@ -2249,6 +2250,7 @@ nsXULPopupManager::HandleKeyboardEventWithKeyCode(
if (consume) {
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
}
return true;
@ -2449,6 +2451,7 @@ nsXULPopupManager::KeyUp(nsIDOMKeyEvent* aKeyEvent)
}
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
return NS_OK; // I am consuming event
@ -2507,6 +2510,7 @@ nsXULPopupManager::KeyDown(nsIDOMKeyEvent* aKeyEvent)
// Since a menu was open, stop propagation of the event to keep other event
// listeners from becoming confused.
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
return NS_OK;
}
@ -2528,6 +2532,7 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEvent* aKeyEvent)
HandleShortcutNavigation(keyEvent, nullptr);
if (consume) {
aKeyEvent->StopPropagation();
aKeyEvent->StopCrossProcessForwarding();
aKeyEvent->PreventDefault();
}