mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
fb9b106168
- Bug 1154563 - Drop the unused argument of WorkerPrivate::Close(); r=baku (366f353f9f) - Bug 1178721 - Implement SuspendWorkersForWindow;r=khuey (a49bc9a306) - Bug 1207490 - Part 6: Remove use of expression closure from browser/devtools/. r=vporof (1c4d153319) - Bug 1198982: Don't fail the SW load for an importScripts failure. r=bkelly (948f5dca94) - Bug 1160890 - Part 1: Remove unneeded code from ImportScripts(). r=smaug (e31f7c82eb) - Bug 1160890 - Part 2: ImportScripts() should return muted errors with 3rd party scripts. r=smaug (347e54a605) - Bug 1188141: Make Worker error events not bubble. r=baku (509fd46933) - Bug 1160890, r=smaug (0ce3ee09d6) - Bug 1208687: Only discard events from the outermost queue. r=ehsan (bce722c16b) - Bug 949376 - MessageEvent::initMessageEvent, r=smaug (8878e51c91) - Bug 1214772 - Part 2: Make FetchEvent inherit from ExtendableEvent; r=bzbarsky (edff91f7fb) - Bug 1218131 - Mark FetchEvent.request as SameObject; r=bzbarsky (1f79b94838) - Bug 1188545 - Add tests for service workers' lifetime management. r=nsm (9bac3b9f2d) - Bug 1218135 - Remove FetchEvent.client; r=bzbarsky (e95e4e5326) - Bug 1218151 - Make FetchEventInit.isReload default to false; r=bzbarsky (795d597a3b) - Bug 1218621 - Keep the service worker alive while the promise passed to FetchEvent.respondWith() settles; r=catalinb (653633c136) - Bug 1212636 - Add a better error message for the content corrupcted error caused by the Promise being passed to FetchEvent.respondWith; r=bkelly (d6ebabc2f2) - Bug 1215140 P4 Make service worker respondWith() use channel ConsoleReportCollector. r=bz (0e07f364d4) - Bug 1218499 - Make FetchEvent.request nullable; r=bzbarsky (850630ea6d) - Bug 1179397 - Disallow FetchEvent.respondWith() when the dispatch flag is unset; r=jdm (2e57abf1c6) - Bug 1215140 P5 Report the line number where respondWith() was called. r=bz (484e385ce3) - Bug 1161239 - Emit a warning if the respondWith handler is resolved with a non-Object value; r=baku (cf2779f827) - Bug 1181054 - Part 1: Move FormFillIterator and FormDataParser to FetchUtil.cpp; r=bkelly (9f62174f72) - Bug 1181054 - Part 2: Refactor the code to extract an HTTP header from a buffer from FormDataParser; r=bkelly (7f57f76ce1) - Bug 1181054 - Part 3: Correctly handle upload channels that have embedded body headers when dispatching a FetchEvent; r=bkelly (ebbfac4419) - ug 1181054 - Part 4: Make fetch-event.https.html pass; r=bkelly (b2d88a3f5b) - Bug 1215140 P6 Update service worker interception error strings to include detailed parameters. r=bz (7918278f09) - Bug 1219852 P1 Extract common JS values for rejected respondWith() promises. r=bz (12a6beed6c) - Bug 1219852 P2 Report non-response values passed to FetchEvent.respondWith(). r=bz (69fdad9d5f) - Bug 1207068 - Implement ExtendableMessageEvent interface. r=baku (29fd7c1c59) - Bug 1224061: Make Event::InitEvent infallible. r=smaug Bug 1224061 followup to fix bustage. r=me on a CLOSED TREE IGNORE IDL (b4fc91b14b) - Bug 1205109 - Make pushsubscriptionchange extendable. r=mt (abb45ac864) - Bug 1207491 - Part 8: Remove use of expression closure from browser/omponents/nsBrowserContentHandler.js. r=Gijs (98dcb2cbee) - Bug 1182571: Followup bustage fix from merge fail. CLOSED TREE (5062c88996) - Bug 1213646: Allow URI_IS_UI_RESOURCE and safe about: URIs when SEC_ALLOW_CHROME is set. r=bz (6ca4e2322f) - Bug 1191645 - Use channel->asycnOpen2 in dom/base/nsSyncLoadService.cpp. r=sicking (3fbd471f6b) - Bug 1194526 - Use channel->asycnOpen2 in dom/base/nsScriptLoader.cpp (r=sicking) (7207efa45b) - Bug 1084009 - Part 1/3 - Parse sync scripts off the main thread. r=smaug (72f4d5c749) - Bug 1084009 - Part 2/3 - Only parse scripts off-main-thread on multicore systems. r=luke (ffb7e2270e) - Bug 1209193 - Cache PR_GetNumberOfProcessors when checking to do off-main-thread script compilation. r=luke (c514373ad7) - Bug 663570 - MetaCSP Part 7: CSP preload validation (r=bz) (5398116f85) - Bug 1207863 - Fix ScopeIter iterating a strict eval frame that errored out before its CallObject was allocated. (r=jorendorff) (ae38882b7c) - Bug 1223006 - Fix some typo in spidermonkey's comments. r=nbp (7d49536a0f) - Bug 1223490 - Use stable hashing for InnerViewTable; r=jonco (12b4329982)
216 lines
5.9 KiB
C++
216 lines
5.9 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/dom/TextTrackList.h"
|
|
#include "mozilla/dom/TextTrackListBinding.h"
|
|
#include "mozilla/dom/TrackEvent.h"
|
|
#include "nsThreadUtils.h"
|
|
#include "mozilla/dom/TextTrackCue.h"
|
|
#include "mozilla/dom/TextTrackManager.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(TextTrackList,
|
|
DOMEventTargetHelper,
|
|
mTextTracks,
|
|
mTextTrackManager)
|
|
|
|
NS_IMPL_ADDREF_INHERITED(TextTrackList, DOMEventTargetHelper)
|
|
NS_IMPL_RELEASE_INHERITED(TextTrackList, DOMEventTargetHelper)
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TextTrackList)
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
|
|
|
TextTrackList::TextTrackList(nsPIDOMWindow* aOwnerWindow)
|
|
: DOMEventTargetHelper(aOwnerWindow)
|
|
{
|
|
}
|
|
|
|
TextTrackList::TextTrackList(nsPIDOMWindow* aOwnerWindow,
|
|
TextTrackManager* aTextTrackManager)
|
|
: DOMEventTargetHelper(aOwnerWindow)
|
|
, mTextTrackManager(aTextTrackManager)
|
|
{
|
|
}
|
|
|
|
TextTrackList::~TextTrackList()
|
|
{
|
|
}
|
|
|
|
void
|
|
TextTrackList::UpdateAndGetShowingCues(nsTArray<RefPtr<TextTrackCue> >& aCues)
|
|
{
|
|
nsTArray< RefPtr<TextTrackCue> > cues;
|
|
for (uint32_t i = 0; i < Length(); i++) {
|
|
TextTrackMode mode = mTextTracks[i]->Mode();
|
|
// If the mode is hidden then we just need to update the active cue list,
|
|
// we don't need to show it on the video.
|
|
if (mode == TextTrackMode::Hidden) {
|
|
mTextTracks[i]->UpdateActiveCueList();
|
|
} else if (mode == TextTrackMode::Showing) {
|
|
// If the mode is showing then we need to update the cue list and show it
|
|
// on the video. GetActiveCueArray() calls UpdateActiveCueList() so we
|
|
// don't need to call it explicitly.
|
|
mTextTracks[i]->GetActiveCueArray(cues);
|
|
aCues.AppendElements(cues);
|
|
}
|
|
}
|
|
}
|
|
|
|
JSObject*
|
|
TextTrackList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return TextTrackListBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
TextTrack*
|
|
TextTrackList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
|
{
|
|
aFound = aIndex < mTextTracks.Length();
|
|
if (!aFound) {
|
|
return nullptr;
|
|
}
|
|
return mTextTracks[aIndex];
|
|
}
|
|
|
|
TextTrack*
|
|
TextTrackList::operator[](uint32_t aIndex)
|
|
{
|
|
return mTextTracks.SafeElementAt(aIndex, nullptr);
|
|
}
|
|
|
|
already_AddRefed<TextTrack>
|
|
TextTrackList::AddTextTrack(TextTrackKind aKind,
|
|
const nsAString& aLabel,
|
|
const nsAString& aLanguage,
|
|
TextTrackMode aMode,
|
|
TextTrackReadyState aReadyState,
|
|
TextTrackSource aTextTrackSource,
|
|
const CompareTextTracks& aCompareTT)
|
|
{
|
|
RefPtr<TextTrack> track = new TextTrack(GetOwner(), this, aKind, aLabel,
|
|
aLanguage, aMode, aReadyState,
|
|
aTextTrackSource);
|
|
AddTextTrack(track, aCompareTT);
|
|
return track.forget();
|
|
}
|
|
|
|
void
|
|
TextTrackList::AddTextTrack(TextTrack* aTextTrack,
|
|
const CompareTextTracks& aCompareTT)
|
|
{
|
|
if (mTextTracks.InsertElementSorted(aTextTrack, aCompareTT)) {
|
|
aTextTrack->SetTextTrackList(this);
|
|
CreateAndDispatchTrackEventRunner(aTextTrack, NS_LITERAL_STRING("addtrack"));
|
|
}
|
|
}
|
|
|
|
TextTrack*
|
|
TextTrackList::GetTrackById(const nsAString& aId)
|
|
{
|
|
nsAutoString id;
|
|
for (uint32_t i = 0; i < Length(); i++) {
|
|
mTextTracks[i]->GetId(id);
|
|
if (aId.Equals(id)) {
|
|
return mTextTracks[i];
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void
|
|
TextTrackList::RemoveTextTrack(TextTrack* aTrack)
|
|
{
|
|
if (mTextTracks.RemoveElement(aTrack)) {
|
|
CreateAndDispatchTrackEventRunner(aTrack, NS_LITERAL_STRING("removetrack"));
|
|
}
|
|
}
|
|
|
|
void
|
|
TextTrackList::DidSeek()
|
|
{
|
|
for (uint32_t i = 0; i < mTextTracks.Length(); i++) {
|
|
mTextTracks[i]->SetDirty();
|
|
}
|
|
}
|
|
|
|
class TrackEventRunner final: public nsRunnable
|
|
{
|
|
public:
|
|
TrackEventRunner(TextTrackList* aList, nsIDOMEvent* aEvent)
|
|
: mList(aList)
|
|
, mEvent(aEvent)
|
|
{}
|
|
|
|
NS_IMETHOD Run() override
|
|
{
|
|
return mList->DispatchTrackEvent(mEvent);
|
|
}
|
|
|
|
private:
|
|
RefPtr<TextTrackList> mList;
|
|
RefPtr<nsIDOMEvent> mEvent;
|
|
};
|
|
|
|
nsresult
|
|
TextTrackList::DispatchTrackEvent(nsIDOMEvent* aEvent)
|
|
{
|
|
return DispatchTrustedEvent(aEvent);
|
|
}
|
|
|
|
void
|
|
TextTrackList::CreateAndDispatchChangeEvent()
|
|
{
|
|
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
|
|
|
|
event->InitEvent(NS_LITERAL_STRING("change"), false, false);
|
|
event->SetTrusted(true);
|
|
|
|
nsCOMPtr<nsIRunnable> eventRunner = new TrackEventRunner(this, event);
|
|
NS_DispatchToMainThread(eventRunner);
|
|
}
|
|
|
|
void
|
|
TextTrackList::CreateAndDispatchTrackEventRunner(TextTrack* aTrack,
|
|
const nsAString& aEventName)
|
|
{
|
|
nsCOMPtr<nsIThread> thread;
|
|
nsresult rv = NS_GetMainThread(getter_AddRefs(thread));
|
|
if (NS_FAILED(rv)) {
|
|
// If we are not able to get the main-thread object we are shutting down.
|
|
return;
|
|
}
|
|
|
|
TrackEventInit eventInit;
|
|
eventInit.mTrack.SetValue().SetAsTextTrack() = aTrack;
|
|
RefPtr<TrackEvent> event =
|
|
TrackEvent::Constructor(this, aEventName, eventInit);
|
|
|
|
// Dispatch the TrackEvent asynchronously.
|
|
rv = thread->Dispatch(do_AddRef(new TrackEventRunner(this, event)),
|
|
NS_DISPATCH_NORMAL);
|
|
|
|
// If we are shutting down this can file but it's still ok.
|
|
NS_WARN_IF(NS_FAILED(rv));
|
|
}
|
|
|
|
HTMLMediaElement*
|
|
TextTrackList::GetMediaElement()
|
|
{
|
|
if (mTextTrackManager) {
|
|
return mTextTrackManager->mMediaElement;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void
|
|
TextTrackList::SetTextTrackManager(TextTrackManager* aTextTrackManager)
|
|
{
|
|
mTextTrackManager = aTextTrackManager;
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|