Merge inbound to mozilla-central. a=merge

This commit is contained in:
Csoregi Natalia 2018-07-19 19:09:50 +03:00
Родитель 83ae44a8c1 c68cebacd6
Коммит 8384a65194
21 изменённых файлов: 193 добавлений и 122 удалений

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

@ -14,6 +14,7 @@
#include "mozilla/dom/DocGroup.h"
#include "nsHTMLTags.h"
#include "jsapi.h"
#include "xpcprivate.h"
#include "nsGlobalWindow.h"
namespace mozilla {
@ -92,6 +93,9 @@ CustomElementCallback::Call()
static_cast<LifecycleAttributeChangedCallback *>(mCallback.get())->Call(mThisObject,
mArgs.name, mArgs.oldValue, mArgs.newValue, mArgs.namespaceURI);
break;
case nsIDocument::eGetCustomInterface:
MOZ_ASSERT_UNREACHABLE("Don't call GetCustomInterface through callback");
break;
}
}
@ -475,6 +479,10 @@ CustomElementRegistry::CreateCustomElementCallback(
func = aDefinition->mCallbacks->mAttributeChangedCallback.Value();
}
break;
case nsIDocument::eGetCustomInterface:
MOZ_ASSERT_UNREACHABLE("Don't call GetCustomInterface through callback");
break;
}
// If there is no such callback, stop.
@ -831,7 +839,8 @@ CustomElementRegistry::Define(JSContext* aCx,
* 10.3. Let lifecycleCallbacks be a map with the four keys
* "connectedCallback", "disconnectedCallback", "adoptedCallback", and
* "attributeChangedCallback", each of which belongs to an entry whose
* value is null.
* value is null. The 'getCustomInterface' callback is also included
* for chrome usage.
* 10.4. For each of the four keys callbackName in lifecycleCallbacks:
* 1. Let callbackValue be Get(prototype, callbackName). Rethrow any
* exceptions.
@ -1161,6 +1170,51 @@ CustomElementRegistry::Upgrade(Element* aElement,
aElement->SetCustomElementDefinition(aDefinition);
}
already_AddRefed<nsISupports>
CustomElementRegistry::CallGetCustomInterface(Element* aElement,
const nsIID& aIID)
{
MOZ_ASSERT(aElement);
if (nsContentUtils::IsChromeDoc(aElement->OwnerDoc())) {
CustomElementDefinition* definition = aElement->GetCustomElementDefinition();
if (definition && definition->mCallbacks &&
definition->mCallbacks->mGetCustomInterfaceCallback.WasPassed() &&
definition->mLocalName == aElement->NodeInfo()->NameAtom()) {
LifecycleGetCustomInterfaceCallback* func =
definition->mCallbacks->mGetCustomInterfaceCallback.Value();
JS::Rooted<JSObject*> customInterface(RootingCx());
nsCOMPtr<nsIJSID> iid = nsJSID::NewID(aIID);
func->Call(aElement, iid, &customInterface);
if (customInterface) {
RefPtr<nsXPCWrappedJS> wrappedJS;
nsresult rv =
nsXPCWrappedJS::GetNewOrUsed(customInterface,
NS_GET_IID(nsISupports),
getter_AddRefs(wrappedJS));
if (NS_SUCCEEDED(rv) && wrappedJS) {
// Check if the returned object implements the desired interface.
nsCOMPtr<nsISupports> retval;
if (NS_SUCCEEDED(wrappedJS->QueryInterface(aIID,
getter_AddRefs(retval)))) {
return retval.forget();
}
}
}
}
}
// Otherwise, check if the element supports the interface directly, and just use that.
nsCOMPtr<nsISupports> supports;
if (NS_SUCCEEDED(aElement->QueryInterface(aIID, getter_AddRefs(supports)))) {
return supports.forget();
}
return nullptr;
}
//-----------------------------------------------------
// CustomElementReactionsStack
@ -1372,6 +1426,11 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementDefinition)
cb.NoteXPCOMChild(callbacks->mAdoptedCallback.Value());
}
if (callbacks->mGetCustomInterfaceCallback.WasPassed()) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCallbacks->mGetCustomInterfaceCallback");
cb.NoteXPCOMChild(callbacks->mGetCustomInterfaceCallback.Value());
}
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mConstructor");
cb.NoteXPCOMChild(tmp->mConstructor);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END

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

@ -416,6 +416,20 @@ public:
*/
static void Upgrade(Element* aElement, CustomElementDefinition* aDefinition, ErrorResult& aRv);
/**
* To allow native code to call methods of chrome-implemented custom elements,
* a helper method may be defined in the custom element called
* 'getCustomInterfaceCallback'. This method takes an IID and returns an
* object which implements an XPCOM interface. If there is no
* getCustomInterfaceCallback or the callback doesn't return an object,
* QueryInterface is called on aElement to see if this interface is
* implemented directly.
*
* This returns null if aElement is not from a chrome document.
*/
static already_AddRefed<nsISupports> CallGetCustomInterface(
Element* aElement, const nsIID& aIID);
/**
* Registers an unresolved custom element that is a candidate for
* upgrade. |aTypeName| is the name of the custom element type, if it is not

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

@ -4304,6 +4304,16 @@ Element::UpdateIntersectionObservation(DOMIntersectionObserver* aObserver, int32
return updated;
}
template<class T> void
Element::GetCustomInterface(nsGetterAddRefs<T> aResult)
{
nsCOMPtr<nsISupports> iface =
CustomElementRegistry::CallGetCustomInterface(this, NS_GET_TEMPLATE_IID(T));
if (iface) {
CallQueryInterface(iface, static_cast<T**>(aResult));
}
}
void
Element::ClearServoData(nsIDocument* aDoc) {
MOZ_ASSERT(aDoc);

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

@ -1987,6 +1987,14 @@ private:
*/
MOZ_CAN_RUN_SCRIPT nsRect GetClientAreaRect();
/**
* GetCustomInterface is somewhat like a GetInterface, but it is expected
* that the implementation is provided by a custom element or via the
* the XBL implements keyword. To use this, create a public method that
* wraps a call to GetCustomInterface.
*/
template<class T> void GetCustomInterface(nsGetterAddRefs<T> aResult);
// Prevent people from doing pointless checks/casts on Element instances.
void IsElement() = delete;
void AsElement() = delete;

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

@ -12430,6 +12430,10 @@ nsIDocument::SetUserHasInteracted(bool aUserHasInteracted)
MOZ_LOG(gUserInteractionPRLog, LogLevel::Debug,
("Document %p has been interacted by user.", this));
mUserHasInteracted = aUserHasInteracted;
if (aUserHasInteracted) {
MaybeAllowStorageForOpener();
}
}
void
@ -12443,7 +12447,6 @@ nsIDocument::NotifyUserGestureActivation()
LogLevel::Debug,
("Document %p has been activated by user.", this));
doc->mUserGestureActivated = true;
doc->MaybeAllowStorageForOpener();
doc = doc->GetSameTypeParentDocument();
}
}
@ -12470,7 +12473,7 @@ nsIDocument::MaybeAllowStorageForOpener()
}
nsCOMPtr<nsPIDOMWindowOuter> outerOpener = outer->GetOpener();
if (NS_WARN_IF(!outerOpener)) {
if (!outerOpener) {
return;
}

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

@ -3083,7 +3083,8 @@ public:
eConnected,
eDisconnected,
eAdopted,
eAttributeChanged
eAttributeChanged,
eGetCustomInterface
};
nsIDocument* GetTopLevelContentDocument();

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

@ -3421,5 +3421,7 @@ nsHTMLDocument::GetFormsAndFormControls(nsContentList** aFormList,
void
nsHTMLDocument::UserInteractionForTesting()
{
NotifyUserGestureActivation();
if (!UserHasInteracted()) {
SetUserHasInteracted(true);
}
}

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

@ -294,13 +294,17 @@ interface nsIContentSecurityPolicy : nsISerializable
*
* Calls to this may trigger violation reports when queried, so
* this value should not be cached.
*
* aOriginalURIIfRedirect must be passed only if this loading is the result
* of a redirect. In this case, aOriginalURIIfRedirect must be the original
* URL.
*/
short shouldLoad(in nsContentPolicyType aContentType,
in nsIURI aContentLocation,
in nsIURI aRequestOrigin,
in nsISupports aContext,
in ACString aMimeTypeGuess,
in nsISupports aExtra);
in nsIURI aOriginalURIIfRedirect);
%{ C++
// nsIObserver topic to fire when the policy encounters a violation.

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

@ -161,7 +161,7 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
nsIURI* aRequestOrigin,
nsISupports* aRequestContext,
const nsACString& aMimeTypeGuess,
nsISupports* aExtra,
nsIURI* aOriginalURIIfRedirect,
int16_t* outDecision)
{
if (CSPCONTEXTLOGENABLED()) {
@ -226,17 +226,11 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
}
}
// aExtra holds the original URI of the channel if the
// channel got redirected (until we fix Bug 1332422).
nsCOMPtr<nsIURI> originalURI = do_QueryInterface(aExtra);
bool wasRedirected = originalURI;
bool permitted = permitsInternal(dir,
nullptr, // aTriggeringElement
aContentLocation,
originalURI,
aOriginalURIIfRedirect,
nonce,
wasRedirected,
isPreload,
false, // allow fallback to default-src
true, // send violation reports
@ -264,9 +258,8 @@ bool
nsCSPContext::permitsInternal(CSPDirective aDir,
Element* aTriggeringElement,
nsIURI* aContentLocation,
nsIURI* aOriginalURI,
nsIURI* aOriginalURIIfRedirect,
const nsAString& aNonce,
bool aWasRedirected,
bool aIsPreload,
bool aSpecific,
bool aSendViolationReports,
@ -280,7 +273,7 @@ nsCSPContext::permitsInternal(CSPDirective aDir,
if (!mPolicies[p]->permits(aDir,
aContentLocation,
aNonce,
aWasRedirected,
!!aOriginalURIIfRedirect,
aSpecific,
aParserCreated,
violatedDirective)) {
@ -299,7 +292,7 @@ nsCSPContext::permitsInternal(CSPDirective aDir,
(aSendContentLocationInViolationReports ?
aContentLocation : nullptr),
BlockedContentSource::eUnknown, /* a BlockedContentSource */
aOriginalURI, /* in case of redirect originalURI is not null */
aOriginalURIIfRedirect, /* in case of redirect originalURI is not null */
violatedDirective,
p, /* policy index */
EmptyString(), /* no observer subject */
@ -1568,7 +1561,6 @@ nsCSPContext::PermitsAncestry(nsIDocShell* aDocShell, bool* outPermitsAncestry)
ancestorsArray[a],
nullptr, // no redirect here.
EmptyString(), // no nonce
false, // no redirect here.
false, // not a preload.
true, // specific, do not use default-src
true, // send violation reports
@ -1598,7 +1590,6 @@ nsCSPContext::Permits(Element* aTriggeringElement,
aURI,
nullptr, // no original (pre-redirect) URI
EmptyString(), // no nonce
false, // not redirected.
false, // not a preload.
aSpecific,
true, // send violation reports

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

@ -147,9 +147,8 @@ class nsCSPContext : public nsIContentSecurityPolicy
bool permitsInternal(CSPDirective aDir,
mozilla::dom::Element* aTriggeringElement,
nsIURI* aContentLocation,
nsIURI* aOriginalURI,
nsIURI* aOriginalURIIfRedirect,
const nsAString& aNonce,
bool aWasRedirected,
bool aIsPreload,
bool aSpecific,
bool aSendViolationReports,

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

@ -184,13 +184,12 @@ CSPService::ShouldLoad(nsIURI *aContentLocation,
if (preloadCsp) {
// obtain the enforcement decision
// (don't pass aExtra, we use that slot for redirects)
rv = preloadCsp->ShouldLoad(contentType,
aContentLocation,
requestOrigin,
requestContext,
aMimeTypeGuess,
nullptr, // aExtra
nullptr, // no redirect, aOriginal URL is null.
aDecision);
NS_ENSURE_SUCCESS(rv, rv);
@ -209,13 +208,12 @@ CSPService::ShouldLoad(nsIURI *aContentLocation,
if (csp) {
// obtain the enforcement decision
// (don't pass aExtra, we use that slot for redirects)
rv = csp->ShouldLoad(contentType,
aContentLocation,
requestOrigin,
requestContext,
aMimeTypeGuess,
nullptr,
nullptr, // no redirect, aOriginal URL is null.
aDecision);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -320,13 +318,13 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
loadInfo->LoadingPrincipal()->GetPreloadCsp(getter_AddRefs(preloadCsp));
if (preloadCsp) {
// Pass originalURI as aExtra to indicate the redirect
// Pass originalURI to indicate the redirect
preloadCsp->ShouldLoad(policyType, // load type per nsIContentPolicy (uint32_t)
newUri, // nsIURI
nullptr, // nsIURI
requestContext, // nsISupports
EmptyCString(), // ACString - MIME guess
originalUri, // aExtra
originalUri, // Original nsIURI
&aDecision);
// if the preload policy already denied the load, then there
@ -344,13 +342,13 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
loadInfo->LoadingPrincipal()->GetCsp(getter_AddRefs(csp));
if (csp) {
// Pass originalURI as aExtra to indicate the redirect
// Pass originalURI to indicate the redirect
csp->ShouldLoad(policyType, // load type per nsIContentPolicy (uint32_t)
newUri, // nsIURI
nullptr, // nsIURI
requestContext, // nsISupports
EmptyCString(), // ACString - MIME guess
originalUri, // aExtra
originalUri, // Original nsIURI
&aDecision);
}

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

@ -153,7 +153,7 @@ CSP_LogMessage(const nsAString& aMessage,
// E.g. 'aSourceLine' might be: 'onclick attribute on DIV element'.
// In such cases we append 'aSourceLine' directly to the error message.
if (!aSourceLine.IsEmpty()) {
cspMsg.AppendLiteral(" Source: ");
cspMsg.AppendLiteral(u" Source: ");
cspMsg.Append(aSourceLine);
cspMsg.AppendLiteral(u".");
}

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

@ -378,7 +378,6 @@ nsMixedContentBlocker::ShouldLoad(nsIURI* aContentLocation,
requestingLocation,
requestingContext,
aMimeGuess,
nullptr, // aExtra,
requestPrincipal,
aDecision);
return rv;
@ -428,7 +427,6 @@ nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect,
nsIURI* aRequestingLocation,
nsISupports* aRequestingContext,
const nsACString& aMimeGuess,
nsISupports* aExtra,
nsIPrincipal* aRequestPrincipal,
int16_t* aDecision)
{

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

@ -65,7 +65,6 @@ public:
nsIURI* aRequestingLocation,
nsISupports* aRequestingContext,
const nsACString& aMimeGuess,
nsISupports* aExtra,
nsIPrincipal* aRequestPrincipal,
int16_t* aDecision);
static void AccumulateMixedContentHSTS(nsIURI* aURI,

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

@ -10,6 +10,8 @@
* liability, trademark and document use rules apply.
*/
interface IID;
callback LifecycleConnectedCallback = void();
callback LifecycleDisconnectedCallback = void();
callback LifecycleAdoptedCallback = void(Document? oldDocument,
@ -18,10 +20,12 @@ callback LifecycleAttributeChangedCallback = void(DOMString attrName,
DOMString? oldValue,
DOMString? newValue,
DOMString? namespaceURI);
callback LifecycleGetCustomInterfaceCallback = object?(IID iid);
dictionary LifecycleCallbacks {
LifecycleConnectedCallback connectedCallback;
LifecycleDisconnectedCallback disconnectedCallback;
LifecycleAdoptedCallback adoptedCallback;
LifecycleAttributeChangedCallback attributeChangedCallback;
[ChromeOnly] LifecycleGetCustomInterfaceCallback getCustomInterfaceCallback;
};

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

@ -692,7 +692,6 @@ ShouldLoadCachedImage(imgRequest* aImgRequest,
requestingLocation,
aLoadingContext,
EmptyCString(), //mime guess
nullptr,
aTriggeringPrincipal,
&decision);
if (NS_FAILED(rv) || !NS_CP_ACCEPTED(decision)) {

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

@ -2560,12 +2560,7 @@ nsXULPopupManager::GetPreviousMenuItem(nsContainerFrame* aParent,
bool
nsXULPopupManager::IsValidMenuItem(nsIContent* aContent, bool aOnPopup)
{
if (aContent->IsXULElement()) {
if (!aContent->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menuitem)) {
return false;
}
}
else if (!aOnPopup || !aContent->IsHTMLElement(nsGkAtoms::option)) {
if (!aContent->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menuitem)) {
return false;
}

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

@ -191,22 +191,7 @@ nsTreeBodyFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState)
int32_t desiredRows;
if (MOZ_UNLIKELY(!baseElement)) {
desiredRows = 0;
}
else if (baseElement->IsHTMLElement(nsGkAtoms::select)) {
min.width = CalcMaxRowWidth();
nsAutoString size;
baseElement->GetAttr(kNameSpaceID_None, nsGkAtoms::size, size);
if (!size.IsEmpty()) {
nsresult err;
desiredRows = size.ToInteger(&err);
mHasFixedRowCount = true;
mPageLength = desiredRows;
}
else {
desiredRows = 1;
}
} else {
// tree
nsAutoString rows;
baseElement->GetAttr(kNameSpaceID_None, nsGkAtoms::rows, rows);
if (!rows.IsEmpty()) {
@ -1738,22 +1723,6 @@ nsTreeBodyFrame::IsCellCropped(int32_t aRow, nsTreeColumn* aCol, bool *_retval)
return NS_OK;
}
void
nsTreeBodyFrame::MarkDirtyIfSelect()
{
nsIContent* baseElement = GetBaseElement();
if (baseElement && baseElement->IsHTMLElement(nsGkAtoms::select)) {
// If we are an intrinsically sized select widget, we may need to
// resize, if the widest item was removed or a new item was added.
// XXX optimize this more
mStringWidth = -1;
PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_IS_DIRTY);
}
}
nsresult
nsTreeBodyFrame::CreateTimer(const LookAndFeel::IntID aID,
nsTimerCallbackFunc aFunc, int32_t aType,
@ -1812,9 +1781,7 @@ nsTreeBodyFrame::RowCountChanged(int32_t aIndex, int32_t aCount)
if (mTopRowIndex == 0) {
// Just update the scrollbar and return.
if (FullScrollbarsUpdate(false)) {
MarkDirtyIfSelect();
}
FullScrollbarsUpdate(false);
return NS_OK;
}
@ -1841,9 +1808,7 @@ nsTreeBodyFrame::RowCountChanged(int32_t aIndex, int32_t aCount)
}
}
if (FullScrollbarsUpdate(needsInvalidation)) {
MarkDirtyIfSelect();
}
FullScrollbarsUpdate(needsInvalidation);
return NS_OK;
}
@ -4250,13 +4215,8 @@ nsTreeBodyFrame::GetBaseElement()
nsIFrame* parent = GetParent();
while (parent) {
nsIContent* content = parent->GetContent();
if (content) {
dom::NodeInfo* ni = content->NodeInfo();
if (ni->Equals(nsGkAtoms::tree, kNameSpaceID_XUL) ||
(ni->Equals(nsGkAtoms::select) &&
content->IsHTMLElement()))
return content->AsElement();
if (content && content->IsXULElement(nsGkAtoms::tree)) {
return content->AsElement();
}
parent = parent->GetParent();

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

@ -191,7 +191,7 @@ public:
nsITreeBoxObject* GetTreeBoxObject() const { return mTreeBoxObject; }
// Get the base element, <tree> or <select>
// Get the base element, <tree>
mozilla::dom::Element* GetBaseElement();
bool GetVerticalOverflow() const { return mVerticalOverflow; }
@ -421,9 +421,6 @@ protected:
int16_t* aOrient,
int16_t* aScrollLines);
// Mark ourselves dirty if we're a select widget
void MarkDirtyIfSelect();
void InvalidateDropFeedback(int32_t aRow, int16_t aOrientation) {
InvalidateRow(aRow);
if (aOrientation != nsITreeView::DROP_ON)

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

@ -106,11 +106,11 @@ MOZ_END_EXTERN_C
*
* (1) the matching infallible operator delete immediately below
* (2) the matching system |operator delete(void*, std::nothrow)|
* (3) the matching system |operator delete(void*) throw(std::bad_alloc)|
* (3) the matching system |operator delete(void*) noexcept(false)|
*
* NB: these are declared |throw(std::bad_alloc)|, though they will never
* NB: these are declared |noexcept(false)|, though they will never
* throw that exception. This declaration is consistent with the rule
* that |::operator new() throw(std::bad_alloc)| will never return NULL.
* that |::operator new() noexcept(false)| will never return NULL.
*
* NB: mozilla::fallible can be used instead of std::nothrow.
*/
@ -124,26 +124,6 @@ MOZ_END_EXTERN_C
# define MOZALLOC_EXPORT_NEW
#endif
#if defined(_MSC_VER)
/*
* Suppress build warning spam (bug 578546).
*/
#if _MSC_VER < 1912
#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS
#else
#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS throw()
#endif
#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS
#else
/*
* C++11 has deprecated exception-specifications in favour of |noexcept|.
*/
#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS noexcept(true)
#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS noexcept(false)
#endif
#define MOZALLOC_THROW_BAD_ALLOC MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS
MOZALLOC_EXPORT_NEW
#if defined(__GNUC__) && !defined(__clang__) && defined(__SANITIZE_ADDRESS__)
/* gcc's asan somehow doesn't like always_inline on this function. */
@ -151,49 +131,49 @@ __attribute__((gnu_inline)) inline
#else
MOZ_ALWAYS_INLINE_EVEN_DEBUG
#endif
void* operator new(size_t size) MOZALLOC_THROW_BAD_ALLOC
void* operator new(size_t size) noexcept(false)
{
return moz_xmalloc(size);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void* operator new(size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void* operator new(size_t size, const std::nothrow_t&) noexcept(true)
{
return malloc_impl(size);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void* operator new[](size_t size) MOZALLOC_THROW_BAD_ALLOC
void* operator new[](size_t size) noexcept(false)
{
return moz_xmalloc(size);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void* operator new[](size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void* operator new[](size_t size, const std::nothrow_t&) noexcept(true)
{
return malloc_impl(size);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void operator delete(void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void operator delete(void* ptr) noexcept(true)
{
return free_impl(ptr);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void operator delete(void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void operator delete(void* ptr, const std::nothrow_t&) noexcept(true)
{
return free_impl(ptr);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void operator delete[](void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void operator delete[](void* ptr) noexcept(true)
{
return free_impl(ptr);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void operator delete[](void* ptr, const std::nothrow_t&) noexcept(true)
{
return free_impl(ptr);
}
@ -202,13 +182,13 @@ void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_E
// We provide the global sized delete overloads unconditionally because the
// MSVC runtime headers do, despite compiling with /Zc:sizedDealloc-
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void operator delete(void* ptr, size_t /*size*/) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void operator delete(void* ptr, size_t /*size*/) noexcept(true)
{
return free_impl(ptr);
}
MOZALLOC_EXPORT_NEW MOZ_ALWAYS_INLINE_EVEN_DEBUG
void operator delete[](void* ptr, size_t /*size*/) MOZALLOC_THROW_IF_HAS_EXCEPTIONS
void operator delete[](void* ptr, size_t /*size*/) noexcept(true)
{
return free_impl(ptr);
}

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

@ -2,6 +2,8 @@
* 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/. */
/* globals MozQueryInterface */
"use strict";
// This is loaded into all XUL windows. Wrap in a block to prevent
@ -59,6 +61,54 @@ class MozXULElement extends XULElement {
range.selectNodeContents(doc.querySelector("box"));
return range.extractContents();
}
/**
* Indicate that a class defining an element implements one or more
* XPCOM interfaces. The custom element getCustomInterface is added
* as well as an implementation of QueryInterface.
*
* The supplied class should implement the properties and methods of
* all of the interfaces that are specified.
*
* @param cls
* The class that implements the interface.
* @param names
* Array of interface names
*/
static implementCustomInterface(cls, ifaces) {
cls.prototype.QueryInterface = ChromeUtils.generateQI(ifaces);
cls.prototype.getCustomInterfaceCallback = function getCustomInterfaceCallback(iface) {
if (ifaces.includes(Ci[Components.interfacesByID[iface.number]])) {
return getInterfaceProxy(this);
}
return null;
};
}
}
/**
* Given an object, add a proxy that reflects interface implementations
* onto the object itself.
*/
function getInterfaceProxy(obj) {
if (!obj._customInterfaceProxy) {
obj._customInterfaceProxy = new Proxy(obj, {
get(target, prop, receiver) {
let propOrMethod = target[prop];
if (typeof propOrMethod == "function") {
if (propOrMethod instanceof MozQueryInterface) {
return Reflect.get(target, prop, receiver);
}
return function(...args) {
return propOrMethod.apply(target, args);
};
}
return propOrMethod;
}
});
}
return obj._customInterfaceProxy;
}
// Attach the base class to the window so other scripts can use it: