mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
967126c55b
- Bug 1162211 Use sqlite private cache mode in Cache API. r=ehsan (7d91c65569) - Bug 1220308 Cache API should teardown DOM objects when Worker hits Terminating status. r=baku (a50fd37df1) - Bug 1144214 - Fix DeleteOrphanedBodyAction so that it doesn't orphan cache files if the action is canceled; r=bkelly (df310a4915) - Bug 1243849 - Restore support for accessing the Cache API from app://URLs and also for storing requests/responses with app:// URLs within it; r=bkelly (07144da733) - Bug 1199434 - Fire an event when the print engine encounters an error. r=smaug (e714d1f979) - Bug 1230092. Make nsIDOMCustomEvent no longer inherit from nsIDOMEvent, so that CustomEvent doesn't end up with multiple inheritance from nsIDOMEvent. r=smaug (cd8e1b5ff5) - Bug 1177927: Use nsFrameList::GetLength() instead of manual iteration to count pages in nsPrintEngine. r=tn (ddcdde1201) - Bug 1177927: Use nsFrameList::GetLength() instead of manual iteration to count pages in nsPrintEngine. r=tn (6b8944ab43) - Bug 1196896 - add CSSLexer.performEOFFixup. r=heycam, r=bz (c5159fc644) - Bug 1153378 - Move local variable in behind #ifndef MOZILLA_XPCOMRT_API. r=jesup (8e5a9c1c48) - Bug 1227396: P1. Remove TimestampedMediaByteRange object. r=cpearce (1fae1c62c5) - Bug 1201404 - Implement minimal gtests to exercise the MPEG4 parser - r=rillian (2a47ebc9e4) - Bug 1187067 - Added gtests using the bug's test file, running simple checks and many parsing runs to catch parser crashes. r=rillian (71027a9572) - Bug 1138992: P2. Add gtest. r=kentuckyfriedtakahe (672e0975a1) - Bug 1200326 - P 1 - Moved test case contents from test source into separate file - r=rillian (e3cdcdd121) - Bug 1200326 - part 2 - Parse subsets of the input stream - r=rillian (c72577319e) - Bug 1200326 - p3 - Test case filenames are now in a list, to allow adding more tests - r=rillian (e8a21b4842) - Bug 1200326 - p4 - Added test case from bug 1200326, with more checks - r=rillian (8befb8260f) - Bug 1204580 - p1: Added test case files. r=rillian (6573cf686d) - Bug 1181213 - Added Added mp4 test case to libstagefright gtest - r=rillian (1278f9dc75) - Bug 1181719 - p1: Added mp4 test case to libstagefright gtest - r=rillian (7ea78da4d9) - Bug 1181223 - p1: Added mp4 test case to libstagefright gtest - r=rillian (14f0b6c719) - Bug 1156505 - p1: Added test case file from bug. r=rillian (9d188b3c6a) - Bug 1181220 - p1: Added mp4 test case to libstagefright gtest - r=rillian (b98029cb8e) - Bug 1181215 - p1: Added mp4 test case to libstagefright gtest - r=rillian (2c20d374b7) - Bug 1185230 - p1: Added mp4 test case to libstagefright gtest - r=rillian (e848ebec16) - Bug 1216748 - p1. Added test case with different 'covr' sizes - r=rillian (1c0097dc85) - Bug 1224019 - Disable Stagefright subset gtests - r=jya, rs=botond (5ee3e6319c) - Bug 1227396: P2. Rename some MediaByteRange methods. r=cpearce (3d14aeb56b) - Bug 1227396: P3. Add IntervalSet::LastInterval method. r=gerald (96b8503a26) - Bug 1227396: P4. Add IntervalSet::Clear method. r=gerald (460ff0cd8f) - Bug 1227396: P5. Make Interval::Span ignore empty interval. r=gerald (ba16de0a91) - Bug 1227396: P6. Replace MediaByteBuffer with Interval<int64_t>. r=cpearce (eed5d5ca5c) - Bug 1227396: P7. Replace nsTArray<MediaByteRange> with dedicated MediaByteRangeSet object. r=cpearce (ea59b05aea) - Bug 1188150 - ADTSContainerParser gtest. r=jya (6a4a061647) - Bug 1227396: P8. Replace MediaByteRange with Interval<int64_t> typedef. r=cpearce (4d3e657b3b) - Bug 1219047 - Call rust mp4parser with logging. r=kinetik (70abf59813) - Bug 1220882 - Use LazyLogModule in MP4Metadata. r=kinetik (3443b56be3) - Bug 1220885 - Add telemetry probe for rust mp4parse success. r=kinetik p=ally (c012bd11bf) - Bug 1174356 - Add missing MediaData include. r=jya (bfe6182cfe) - Bug 1227396: P9. Remove unnecessary monitor. r=cpearce (4f156658c4) - Bug 1227396: P10: Remove stray function definition. r=cpearce (4c1641560c) - Bug 1227396: P11. Add IntervalSet::operator- operand. r=gerald (b56ceb52f4) - Bug 1227396: P12. Use MediaByteRangeSet capabilities to filter already processed data. r=cpearce (098d8852d9) - Bug 1227396: P13. Refactor how MP4 buffered range is calculated. r=cpearce (66711bd76f) - Bug 1227396: P14. Reduce memory usage of sample index for audio tracks. r=cpearce (e1c36bd791) - Bug 1197007: Turn off optimization for GMPLoaderImpl::Load. r=cpearce (5df0a365c7) - Bug 1208892 - Replace the uses of memset to clean up data in GMPLoader::Load with an inline memset; r=cpearce (ce4f3a3a64) - Bug 1187031: Move back to using USER_LOCKDOWN for the GMP sandbox policy on Windows. r=aklotz (53c39be48d) - Bug 1214018 - p1: Using vector to pass machine id - r=cpearce (19782ec5b3) - Bug 1214018 - p2: Import machine_id_mac.cc from Chromium repo - r=cpearce (000d4734ab) - Bug 1214018 - p3: Modify machine_id_mac for FF build - r=cpearce (41818ddc72) - Bug 1214018 - p4: Use machine_id_mac in GMPLoader - r=cpearce (4af56e5a6e) - Bug 1220326 - Wipe stack after Mac node id generation. r=jrmuizel (8c94ddab25) - Bug 1181718 - Fallible allocation of blank audio data - r=jya (7867407417) - Bug 1229963 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in dom/media/; r=cpearce (796241f002) - Bug 1229965 - Use MakeUniqueFallible in blank decoder - r=jya (bac70f5c80) - Bug 1139256 - remove the assertion in AudioStream::GetPositionInFramesUnlocked(). See bug 1139256 comment 4 for the detail. r=kinetik. (6e386c7b00) - missing bits (1dc7b00da3) - Bug 1185115: P2. replace all stagefright::Vector with nsTArray. r=kentuckyfriedtakahe (de4e57b4cd) - Bug 1181223 - p2: Handle wrong saio/saiz size instead of assuming it is correct - r=rillian (59f5afa21f) - Bug 1138992: P1. Ignore ctts version if we have 0 samples in the table. r=kentuckyfriedtakahe (efb86ce02d) - Bug 1216845 - Check fallible allocations - r=rillian (fac4210e2a) - Bug 1229615 - Compare track counts between rust and stagefright. r=rillian (1b7ee2e4a8) - Bug 1219475 - Fix a comparison warning. r=gerald (2efe7f952d) - Bug 1181719 - p2: Check numBitsLeft before each getBits - r=rillian (f7bd7039ed) - Bug 1187067 - Null-check mLastTrack before dereferencing it - r=rillian (e2d99073ff) - Bug 1181220 - p2: Check if MIME types are valid - r=rillian (c1d1254f6d) - Bug 1185230 - p2: Store MPEG4Source::mTimescale as uint32_t - r=rillian (21d124ab25) - Bug 1207909 - p1: Fixed ALOGV statement - r=jya (0aef385b41) - Bug 1207909 - p2: Fixed a warning (uninitialized 'err') and typo - r=jya (a9c157feda) - partial remove of hack (59ca36fbd4) - Bug 1156505 - p2: Null-check sampleTable before use. r=rillian (ab18d1d939) - Bug 1181215 - p2: Better track verification - r=rillian (d61d5914aa) - Bug 1210319 - p1. Removed unused code - r=rillian (4c0b33fc59) - Bug 1210319 - p2. Minor intf clean-up, RIP trex - r=rillian (27aaf6ae80) - Bug 1229134: Check that memory allocation actually succeeded. r=gerald (b6587bc900) - Bug 1209388: [mp3] Remove AppleMP3Reader. r=kentuckyfriedtakahe (e81f265901) - Bug 1198576 - Remove MediaCodecReader. r=bwu (e867950ff4) - Bug 1191833: P1. Properly check webm mimetype against codec type. r=cpearce (9b27b8064a) - Bug 1229605: [MSE] Allow webm/audio independently of video. r=kentuckyfriedtakahe (7b79dfaf4c) - Bug 1229339: Partial revert of commit c15c9f37f. r=cpearce (90fa115b64)
307 lines
11 KiB
C++
307 lines
11 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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 "TabParent.h"
|
|
|
|
// TabParent.h transitively includes <windows.h>, which does
|
|
// #define CreateEvent CreateEventW
|
|
// That messes up our call to EventDispatcher::CreateEvent below.
|
|
|
|
#ifdef CreateEvent
|
|
#undef CreateEvent
|
|
#endif
|
|
|
|
#include "BrowserElementParent.h"
|
|
#include "BrowserElementAudioChannel.h"
|
|
#include "mozilla/EventDispatcher.h"
|
|
#include "mozilla/dom/HTMLIFrameElement.h"
|
|
#include "mozilla/dom/ToJSValue.h"
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
#include "nsVariant.h"
|
|
#include "mozilla/dom/BrowserElementDictionariesBinding.h"
|
|
#include "mozilla/dom/CustomEvent.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::dom;
|
|
|
|
namespace {
|
|
|
|
using mozilla::BrowserElementParent;
|
|
/**
|
|
* Create an <iframe mozbrowser> owned by the same document as
|
|
* aOpenerFrameElement.
|
|
*/
|
|
already_AddRefed<HTMLIFrameElement>
|
|
CreateIframe(Element* aOpenerFrameElement, const nsAString& aName, bool aRemote)
|
|
{
|
|
nsNodeInfoManager *nodeInfoManager =
|
|
aOpenerFrameElement->OwnerDoc()->NodeInfoManager();
|
|
|
|
RefPtr<NodeInfo> nodeInfo =
|
|
nodeInfoManager->GetNodeInfo(nsGkAtoms::iframe,
|
|
/* aPrefix = */ nullptr,
|
|
kNameSpaceID_XHTML,
|
|
nsIDOMNode::ELEMENT_NODE);
|
|
|
|
RefPtr<HTMLIFrameElement> popupFrameElement =
|
|
static_cast<HTMLIFrameElement*>(
|
|
NS_NewHTMLIFrameElement(nodeInfo.forget(), mozilla::dom::NOT_FROM_PARSER));
|
|
|
|
popupFrameElement->SetMozbrowser(true);
|
|
|
|
// Copy the opener frame's mozapp attribute to the popup frame.
|
|
if (aOpenerFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozapp)) {
|
|
nsAutoString mozapp;
|
|
aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::mozapp, mozapp);
|
|
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::mozapp,
|
|
mozapp, /* aNotify = */ false);
|
|
}
|
|
|
|
// Copy the opener frame's parentApp attribute to the popup frame.
|
|
if (aOpenerFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::parentapp)) {
|
|
nsAutoString parentApp;
|
|
aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::parentapp,
|
|
parentApp);
|
|
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::parentapp,
|
|
parentApp, /* aNotify = */ false);
|
|
}
|
|
|
|
// Copy the window name onto the iframe.
|
|
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
|
|
aName, /* aNotify = */ false);
|
|
|
|
// Indicate whether the iframe is should be remote.
|
|
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::Remote,
|
|
aRemote ? NS_LITERAL_STRING("true") :
|
|
NS_LITERAL_STRING("false"),
|
|
/* aNotify = */ false);
|
|
|
|
// Copy the opener frame's mozprivatebrowsing attribute to the popup frame.
|
|
nsAutoString mozprivatebrowsing;
|
|
if (aOpenerFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing,
|
|
mozprivatebrowsing)) {
|
|
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing,
|
|
mozprivatebrowsing, /* aNotify = */ false);
|
|
}
|
|
|
|
return popupFrameElement.forget();
|
|
}
|
|
|
|
bool
|
|
DispatchCustomDOMEvent(Element* aFrameElement, const nsAString& aEventName,
|
|
JSContext* cx, JS::Handle<JS::Value> aDetailValue,
|
|
nsEventStatus *aStatus)
|
|
{
|
|
NS_ENSURE_TRUE(aFrameElement, false);
|
|
nsIPresShell *shell = aFrameElement->OwnerDoc()->GetShell();
|
|
RefPtr<nsPresContext> presContext;
|
|
if (shell) {
|
|
presContext = shell->GetPresContext();
|
|
}
|
|
|
|
RefPtr<CustomEvent> event =
|
|
NS_NewDOMCustomEvent(aFrameElement, presContext, nullptr);
|
|
|
|
ErrorResult res;
|
|
event->InitCustomEvent(cx,
|
|
aEventName,
|
|
/* bubbles = */ true,
|
|
/* cancelable = */ true,
|
|
aDetailValue,
|
|
res);
|
|
if (res.Failed()) {
|
|
return false;
|
|
}
|
|
event->SetTrusted(true);
|
|
// Dispatch the event.
|
|
// We don't initialize aStatus here, as our callers have already done so.
|
|
nsresult rv =
|
|
EventDispatcher::DispatchDOMEvent(aFrameElement, nullptr, event,
|
|
presContext, aStatus);
|
|
return NS_SUCCEEDED(rv);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
namespace mozilla {
|
|
|
|
/**
|
|
* Dispatch a mozbrowseropenwindow event to the given opener frame element.
|
|
* The "popup iframe" (event.detail.frameElement) will be |aPopupFrameElement|.
|
|
*
|
|
* Returns true iff there were no unexpected failures and the window.open call
|
|
* was accepted by the embedder.
|
|
*/
|
|
/*static*/
|
|
BrowserElementParent::OpenWindowResult
|
|
BrowserElementParent::DispatchOpenWindowEvent(Element* aOpenerFrameElement,
|
|
Element* aPopupFrameElement,
|
|
const nsAString& aURL,
|
|
const nsAString& aName,
|
|
const nsAString& aFeatures)
|
|
{
|
|
// Dispatch a CustomEvent at aOpenerFrameElement with a detail object
|
|
// (OpenWindowEventDetail) containing aPopupFrameElement, aURL, aName, and
|
|
// aFeatures.
|
|
|
|
// Create the event's detail object.
|
|
OpenWindowEventDetail detail;
|
|
if (aURL.IsEmpty()) {
|
|
// URL should never be empty. Assign about:blank as default.
|
|
detail.mUrl = NS_LITERAL_STRING("about:blank");
|
|
} else {
|
|
detail.mUrl = aURL;
|
|
}
|
|
detail.mName = aName;
|
|
detail.mFeatures = aFeatures;
|
|
detail.mFrameElement = aPopupFrameElement;
|
|
|
|
AutoJSContext cx;
|
|
JS::Rooted<JS::Value> val(cx);
|
|
|
|
nsIGlobalObject* sgo = aPopupFrameElement->OwnerDoc()->GetScopeObject();
|
|
if (!sgo) {
|
|
return BrowserElementParent::OPEN_WINDOW_IGNORED;
|
|
}
|
|
|
|
JS::Rooted<JSObject*> global(cx, sgo->GetGlobalJSObject());
|
|
JSAutoCompartment ac(cx, global);
|
|
if (!ToJSValue(cx, detail, &val)) {
|
|
MOZ_CRASH("Failed to convert dictionary to JS::Value due to OOM.");
|
|
return BrowserElementParent::OPEN_WINDOW_IGNORED;
|
|
}
|
|
|
|
// Do not dispatch a mozbrowseropenwindow event of a widget to its embedder
|
|
nsCOMPtr<nsIMozBrowserFrame> browserFrame =
|
|
do_QueryInterface(aOpenerFrameElement);
|
|
if (browserFrame && browserFrame->GetReallyIsWidget()) {
|
|
return BrowserElementParent::OPEN_WINDOW_CANCELLED;
|
|
}
|
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
|
bool dispatchSucceeded =
|
|
DispatchCustomDOMEvent(aOpenerFrameElement,
|
|
NS_LITERAL_STRING("mozbrowseropenwindow"),
|
|
cx,
|
|
val, &status);
|
|
|
|
if (dispatchSucceeded) {
|
|
if (aPopupFrameElement->IsInDoc()) {
|
|
return BrowserElementParent::OPEN_WINDOW_ADDED;
|
|
} else if (status == nsEventStatus_eConsumeNoDefault) {
|
|
// If the frame was not added to a document, report to callers whether
|
|
// preventDefault was called on or not
|
|
return BrowserElementParent::OPEN_WINDOW_CANCELLED;
|
|
}
|
|
}
|
|
|
|
return BrowserElementParent::OPEN_WINDOW_IGNORED;
|
|
}
|
|
|
|
/*static*/
|
|
BrowserElementParent::OpenWindowResult
|
|
BrowserElementParent::OpenWindowOOP(TabParent* aOpenerTabParent,
|
|
TabParent* aPopupTabParent,
|
|
const nsAString& aURL,
|
|
const nsAString& aName,
|
|
const nsAString& aFeatures)
|
|
{
|
|
// Create an iframe owned by the same document which owns openerFrameElement.
|
|
nsCOMPtr<Element> openerFrameElement = aOpenerTabParent->GetOwnerElement();
|
|
NS_ENSURE_TRUE(openerFrameElement,
|
|
BrowserElementParent::OPEN_WINDOW_IGNORED);
|
|
RefPtr<HTMLIFrameElement> popupFrameElement =
|
|
CreateIframe(openerFrameElement, aName, /* aRemote = */ true);
|
|
|
|
// Normally an <iframe> element will try to create a frameLoader when the
|
|
// page touches iframe.contentWindow or sets iframe.src.
|
|
//
|
|
// But in our case, we want to delay the creation of the frameLoader until
|
|
// we've verified that the popup has gone through successfully. If the popup
|
|
// is "blocked" by the embedder, we don't want to load the popup's url.
|
|
//
|
|
// Therefore we call DisallowCreateFrameLoader() on the element and call
|
|
// AllowCreateFrameLoader() only after we've verified that the popup was
|
|
// allowed.
|
|
popupFrameElement->DisallowCreateFrameLoader();
|
|
|
|
OpenWindowResult opened =
|
|
DispatchOpenWindowEvent(openerFrameElement, popupFrameElement,
|
|
aURL, aName, aFeatures);
|
|
|
|
if (opened != BrowserElementParent::OPEN_WINDOW_ADDED) {
|
|
return opened;
|
|
}
|
|
|
|
// The popup was not blocked, so hook up the frame element and the popup tab
|
|
// parent, and return success.
|
|
aPopupTabParent->SetOwnerElement(popupFrameElement);
|
|
popupFrameElement->AllowCreateFrameLoader();
|
|
popupFrameElement->CreateRemoteFrameLoader(aPopupTabParent);
|
|
return opened;
|
|
}
|
|
|
|
/* static */
|
|
BrowserElementParent::OpenWindowResult
|
|
BrowserElementParent::OpenWindowInProcess(nsIDOMWindow* aOpenerWindow,
|
|
nsIURI* aURI,
|
|
const nsAString& aName,
|
|
const nsACString& aFeatures,
|
|
nsIDOMWindow** aReturnWindow)
|
|
{
|
|
*aReturnWindow = nullptr;
|
|
|
|
// If we call window.open from an <iframe> inside an <iframe mozbrowser>,
|
|
// it's as though the top-level document inside the <iframe mozbrowser>
|
|
// called window.open. (Indeed, in the OOP case, the inner <iframe> lives
|
|
// out-of-process, so we couldn't touch it if we tried.)
|
|
//
|
|
// GetScriptableTop gets us the <iframe mozbrowser>'s window; we'll use its
|
|
// frame element, rather than aOpenerWindow's frame element, as our "opener
|
|
// frame element" below.
|
|
nsCOMPtr<nsPIDOMWindow> openerWindow = do_QueryInterface(aOpenerWindow);
|
|
nsCOMPtr<nsPIDOMWindow> win = openerWindow->GetScriptableTop();
|
|
|
|
nsCOMPtr<Element> openerFrameElement = win->GetFrameElementInternal();
|
|
NS_ENSURE_TRUE(openerFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
|
|
|
|
|
|
RefPtr<HTMLIFrameElement> popupFrameElement =
|
|
CreateIframe(openerFrameElement, aName, /* aRemote = */ false);
|
|
NS_ENSURE_TRUE(popupFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
|
|
|
|
nsAutoCString spec;
|
|
if (aURI) {
|
|
aURI->GetSpec(spec);
|
|
}
|
|
|
|
OpenWindowResult opened =
|
|
DispatchOpenWindowEvent(openerFrameElement, popupFrameElement,
|
|
NS_ConvertUTF8toUTF16(spec),
|
|
aName,
|
|
NS_ConvertUTF8toUTF16(aFeatures));
|
|
|
|
if (opened != BrowserElementParent::OPEN_WINDOW_ADDED) {
|
|
return opened;
|
|
}
|
|
|
|
// Return popupFrameElement's window.
|
|
nsCOMPtr<nsIFrameLoader> frameLoader;
|
|
popupFrameElement->GetFrameLoader(getter_AddRefs(frameLoader));
|
|
NS_ENSURE_TRUE(frameLoader, BrowserElementParent::OPEN_WINDOW_IGNORED);
|
|
|
|
nsCOMPtr<nsIDocShell> docshell;
|
|
frameLoader->GetDocShell(getter_AddRefs(docshell));
|
|
NS_ENSURE_TRUE(docshell, BrowserElementParent::OPEN_WINDOW_IGNORED);
|
|
|
|
nsCOMPtr<nsIDOMWindow> window = docshell->GetWindow();
|
|
window.forget(aReturnWindow);
|
|
|
|
return !!*aReturnWindow ? opened : BrowserElementParent::OPEN_WINDOW_CANCELLED;
|
|
}
|
|
|
|
} // namespace mozilla
|