Merge mozilla-central to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2015-09-02 14:52:27 +02:00
Родитель 1e8a551445 22484bfe22
Коммит 3f7d220b6b
215 изменённых файлов: 4105 добавлений и 1590 удалений

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

@ -1042,14 +1042,17 @@ refRelationSetCB(AtkObject *aAtkObj)
AccessibleWrap*
GetAccessibleWrap(AtkObject* aAtkObj)
{
NS_ENSURE_TRUE(IS_MAI_OBJECT(aAtkObj), nullptr);
bool isMAIObject = IS_MAI_OBJECT(aAtkObj);
NS_ENSURE_TRUE(isMAIObject || MAI_IS_ATK_SOCKET(aAtkObj),
nullptr);
// Make sure its native is an AccessibleWrap not a proxy.
if (MAI_ATK_OBJECT(aAtkObj)->accWrap & IS_PROXY)
uintptr_t accWrapPtr = isMAIObject ?
MAI_ATK_OBJECT(aAtkObj)->accWrap :
reinterpret_cast<uintptr_t>(MAI_ATK_SOCKET(aAtkObj)->accWrap);
if (accWrapPtr & IS_PROXY)
return nullptr;
AccessibleWrap* accWrap =
reinterpret_cast<AccessibleWrap*>(MAI_ATK_OBJECT(aAtkObj)->accWrap);
AccessibleWrap* accWrap = reinterpret_cast<AccessibleWrap*>(accWrapPtr);
// Check if the accessible was deconstructed.
if (!accWrap)
@ -1067,7 +1070,8 @@ GetAccessibleWrap(AtkObject* aAtkObj)
ProxyAccessible*
GetProxy(AtkObject* aObj)
{
if (!aObj || !(MAI_ATK_OBJECT(aObj)->accWrap & IS_PROXY))
if (!aObj || !IS_MAI_OBJECT(aObj) ||
!(MAI_ATK_OBJECT(aObj)->accWrap & IS_PROXY))
return nullptr;
return reinterpret_cast<ProxyAccessible*>(MAI_ATK_OBJECT(aObj)->accWrap

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

@ -21,35 +21,6 @@ const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type"
bool AtkSocketAccessible::gCanEmbed = FALSE;
extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
extern "C" GType mai_atk_socket_get_type(void);
/* MaiAtkSocket */
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type ())
#define MAI_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
#define MAI_IS_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
#define MAI_IS_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
typedef struct _MaiAtkSocket
{
AtkSocket parent;
AccessibleWrap* accWrap;
} MaiAtkSocket;
typedef struct _MaiAtkSocketClass
{
AtkSocketClass parent_class;
} MaiAtkSocketClass;
G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
AtkSocketAccessible::g_atk_socket_type, 0,
@ -86,7 +57,7 @@ RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
{
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
return refAccessibleAtPointHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
aX, aY, aCoordType);
}
@ -99,7 +70,7 @@ GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
if (!MAI_IS_ATK_SOCKET(aComponent))
return;
getExtentsHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
aX, aY, aWidth, aHeight, aCoordType);
}
}

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

@ -34,9 +34,9 @@ void valueInterfaceInitCB(AtkValueIface *aIface);
/**
* XXX these should live in a file of utils for atk.
*/
AtkObject* refAccessibleAtPointHelper(mozilla::a11y::AccessibleWrap* aAccWrap,
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj,
gint aX, gint aY, AtkCoordType aCoordType);
void getExtentsHelper(mozilla::a11y::AccessibleWrap* aAccWrap,
void getExtentsHelper(AtkObject* aAtkObj,
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoordType);

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

@ -34,6 +34,36 @@ class ProxyAccessible;
MaiAtkObjectClass))
GType mai_atk_object_get_type(void);
GType mai_util_get_type();
extern "C" GType mai_atk_socket_get_type(void);
/* MaiAtkSocket */
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type ())
#define MAI_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
#define MAI_IS_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
#define MAI_IS_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
typedef struct _MaiAtkSocket
{
AtkSocket parent;
mozilla::a11y::AccessibleWrap* accWrap;
} MaiAtkSocket;
typedef struct _MaiAtkSocketClass
{
AtkSocketClass parent_class;
} MaiAtkSocketClass;
mozilla::a11y::AccessibleWrap* GetAccessibleWrap(AtkObject* aAtkObj);
mozilla::a11y::ProxyAccessible* GetProxy(AtkObject* aAtkObj);
AtkObject* GetWrapperFor(mozilla::a11y::ProxyAccessible* aProxy);

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

@ -11,6 +11,7 @@
#include "nsCoreUtils.h"
#include "nsMai.h"
#include "mozilla/Likely.h"
#include "mozilla/a11y/ProxyAccessible.h"
using namespace mozilla::a11y;
@ -20,7 +21,7 @@ static AtkObject*
refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
AtkCoordType aCoordType)
{
return refAccessibleAtPointHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
return refAccessibleAtPointHelper(ATK_OBJECT(aComponent),
aAccX, aAccY, aCoordType);
}
@ -28,73 +29,109 @@ static void
getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
{
getExtentsHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
getExtentsHelper(ATK_OBJECT(aComponent),
aX, aY, aWidth, aHeight, aCoordType);
}
static gboolean
grabFocusCB(AtkComponent* aComponent)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
if (!accWrap)
return FALSE;
AtkObject* atkObject = ATK_OBJECT(aComponent);
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
if (accWrap) {
accWrap->TakeFocus();
return TRUE;
}
accWrap->TakeFocus();
return TRUE;
ProxyAccessible* proxy = GetProxy(atkObject);
if (proxy) {
proxy->TakeFocus();
return TRUE;
}
return FALSE;
}
}
AtkObject*
refAccessibleAtPointHelper(AccessibleWrap* aAccWrap, gint aX, gint aY,
refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
AtkCoordType aCoordType)
{
if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
return nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (accWrap) {
if (accWrap->IsDefunct() || nsAccUtils::MustPrune(accWrap)) {
return nullptr;
}
// Accessible::ChildAtPoint(x,y) is in screen pixels.
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
aX += winCoords.x;
aY += winCoords.y;
// Accessible::ChildAtPoint(x,y) is in screen pixels.
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
aX += winCoords.x;
aY += winCoords.y;
}
Accessible* accAtPoint = accWrap->ChildAtPoint(aX, aY,
Accessible::eDirectChild);
if (!accAtPoint) {
return nullptr;
}
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accAtPoint);
if (atkObj) {
g_object_ref(atkObj);
}
return atkObj;
}
Accessible* accAtPoint = aAccWrap->ChildAtPoint(aX, aY,
Accessible::eDirectChild);
if (!accAtPoint)
return nullptr;
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
ProxyAccessible* result =
proxy->AccessibleAtPoint(aX, aY, aCoordType == ATK_XY_WINDOW);
AtkObject* atkObj = result ? GetWrapperFor(result) : nullptr;
if (atkObj) {
g_object_ref(atkObj);
}
return atkObj;
}
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accAtPoint);
if (atkObj)
g_object_ref(atkObj);
return atkObj;
return nullptr;
}
void
getExtentsHelper(AccessibleWrap* aAccWrap,
getExtentsHelper(AtkObject* aAtkObj,
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoordType)
{
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
*aX = *aY = *aWidth = *aHeight = 0;
if (!aAccWrap || aAccWrap->IsDefunct())
return;
if (accWrap) {
if (accWrap->IsDefunct()) {
return;
}
nsIntRect screenRect = aAccWrap->Bounds();
if (screenRect.IsEmpty())
return;
nsIntRect screenRect = accWrap->Bounds();
if (screenRect.IsEmpty())
return;
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
}
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
return;
}
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
proxy->Extents(aCoordType == ATK_XY_WINDOW, aX, aY, aWidth, aHeight);
}
}
void

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

@ -1792,42 +1792,6 @@ DocAccessibleChild::RecvFocusedChild(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvChildAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const uint32_t& aWhich,
uint64_t* aChild,
bool* aOk)
{
*aChild = 0;
*aOk = false;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct() && !nsAccUtils::MustPrune(acc)) {
Accessible* child =
acc->ChildAtPoint(aX, aY,
static_cast<Accessible::EWhichChildAtPoint>(aWhich));
if (child) {
*aChild = reinterpret_cast<uint64_t>(child->UniqueID());
*aOk = true;
}
}
return true;
}
bool
DocAccessibleChild::RecvBounds(const uint64_t& aID,
nsIntRect* aRect)
{
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct()) {
*aRect = acc->Bounds();
}
return false;
}
bool
DocAccessibleChild::RecvLanguage(const uint64_t& aID,
nsString* aLocale)
@ -1906,5 +1870,71 @@ DocAccessibleChild::RecvURLDocTypeMimeType(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvAccessibleAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const bool& aNeedsScreenCoords,
const uint32_t& aWhich,
uint64_t* aResult,
bool* aOk)
{
*aResult = 0;
*aOk = false;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct() && !nsAccUtils::MustPrune(acc)) {
int32_t x = aX;
int32_t y = aY;
if (aNeedsScreenCoords) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
x += winCoords.x;
y += winCoords.y;
}
Accessible* result =
acc->ChildAtPoint(x, y,
static_cast<Accessible::EWhichChildAtPoint>(aWhich));
if (result) {
*aResult = reinterpret_cast<uint64_t>(result->UniqueID());
*aOk = true;
}
}
return true;
}
bool
DocAccessibleChild::RecvExtents(const uint64_t& aID,
const bool& aNeedsScreenCoords,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight)
{
*aX = 0;
*aY = 0;
*aWidth = 0;
*aHeight = 0;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct() && !nsAccUtils::MustPrune(acc)) {
nsIntRect screenRect = acc->Bounds();
if (!screenRect.IsEmpty()) {
if (aNeedsScreenCoords) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
}
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
}
}
return true;
}
}
}

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

@ -448,15 +448,6 @@ public:
uint64_t* aChild,
bool* aOk) override;
virtual bool RecvChildAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const uint32_t& aWhich,
uint64_t* aChild,
bool* aOk) override;
virtual bool RecvBounds(const uint64_t& aID, nsIntRect* aRect) override;
virtual bool RecvLanguage(const uint64_t& aID, nsString* aLocale) override;
virtual bool RecvDocType(const uint64_t& aID, nsString* aType) override;
virtual bool RecvTitle(const uint64_t& aID, nsString* aTitle) override;
@ -466,6 +457,21 @@ public:
nsString* aURL,
nsString* aDocType,
nsString* aMimeType) override;
virtual bool RecvAccessibleAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const bool& aNeedsScreenCoords,
const uint32_t& aWhich,
uint64_t* aResult,
bool* aOk) override;
virtual bool RecvExtents(const uint64_t& aID,
const bool& aNeedsScreenCoords,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) override;
private:
Accessible* IdToAccessible(const uint64_t& aID) const;

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

@ -233,9 +233,6 @@ child:
returns(uint64_t aChild);
prio(high) sync FocusedChild(uint64_t aID)
returns(uint64_t aChild, bool aOk);
prio(high) sync ChildAtPoint(uint64_t aID, int32_t aX, int32_t aY, uint32_t aWhich)
returns(uint64_t aChild, bool aOk);
prio(high) sync Bounds(uint64_t aID) returns(nsIntRect aRect);
prio(high) sync Language(uint64_t aID) returns(nsString aLocale);
prio(high) sync DocType(uint64_t aID) returns(nsString aType);
@ -243,6 +240,12 @@ child:
prio(high) sync URL(uint64_t aID) returns(nsString aURL);
prio(high) sync MimeType(uint64_t aID) returns(nsString aMime);
prio(high) sync URLDocTypeMimeType(uint64_t aID) returns(nsString aURL, nsString aDocType, nsString aMimeType);
prio(high) sync AccessibleAtPoint(uint64_t aID, int32_t aX, int32_t aY, bool aNeedsScreenCoords, uint32_t aWhich)
returns(uint64_t aResult, bool aOk);
prio(high) sync Extents(uint64_t aID, bool aNeedsScreenCoords)
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
};
}

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

@ -1019,9 +1019,9 @@ ProxyAccessible::ChildAtPoint(int32_t aX, int32_t aY,
{
uint64_t childID = 0;
bool ok = false;
unused << mDoc->SendChildAtPoint(mID, aX, aY,
static_cast<uint32_t>(aWhichChild),
&childID, &ok);
unused << mDoc->SendAccessibleAtPoint(mID, aX, aY, false,
static_cast<uint32_t>(aWhichChild),
&childID, &ok);
return ok ? mDoc->GetAccessible(childID) : nullptr;
}
@ -1029,7 +1029,9 @@ nsIntRect
ProxyAccessible::Bounds()
{
nsIntRect rect;
unused << mDoc->SendBounds(mID, &rect);
unused << mDoc->SendExtents(mID, false,
&(rect.x), &(rect.y),
&(rect.width), &(rect.height));
return rect;
}
@ -1070,6 +1072,26 @@ ProxyAccessible::URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
unused << mDoc->SendURLDocTypeMimeType(mID, &aURL, &aDocType, &aMimeType);
}
ProxyAccessible*
ProxyAccessible::AccessibleAtPoint(int32_t aX, int32_t aY,
bool aNeedsScreenCoords)
{
uint64_t childID = 0;
bool ok = false;
unused <<
mDoc->SendAccessibleAtPoint(mID, aX, aY, aNeedsScreenCoords,
static_cast<uint32_t>(Accessible::eDirectChild),
&childID, &ok);
return ok ? mDoc->GetAccessible(childID) : nullptr;
}
void
ProxyAccessible::Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight)
{
unused << mDoc->SendExtents(mID, aNeedsScreenCoords, aX, aY, aWidth, aHeight);
}
Accessible*
ProxyAccessible::OuterDocOfRemoteBrowser() const
{

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

@ -319,6 +319,12 @@ public:
void URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
nsString& aMimeType);
ProxyAccessible* AccessibleAtPoint(int32_t aX, int32_t aY,
bool aNeedsScreenCoords);
void Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight);
/**
* Allow the platform to store a pointers worth of data on us.
*/

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="2d58f4b9206b50b8fda0d5036da6f0c62608db7c"/>

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

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="51ebaf824cc634665c5efcae95b8301ad1758c5e"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="b4f6fd4afd03161f53c7d2a663750f94762bd238"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="05a36844c1046a1eb07d5b1325f85ed741f961ea">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -19,7 +19,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="2d58f4b9206b50b8fda0d5036da6f0c62608db7c"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="e935894ef5f27e2f04b9e929a45a958e6288a223">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -1,9 +1,9 @@
{
"git": {
"git_revision": "b75979ec8862bd5799a7c42e938d3f67be38d6ae",
"git_revision": "e2fab8f6ac345ecde10a1350e699be9ceb6987d6",
"remote": "https://git.mozilla.org/releases/gaia.git",
"branch": ""
},
"revision": "f919c5b5f0f0b6fd3ef3346850710edafa2a615b",
"revision": "1ab9e5d9915dc22fed71384a53dc565bce1709aa",
"repo_path": "integration/gaia-central"
}

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

@ -17,7 +17,7 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="5ef30994f4778b4052e58a4383dbe7890048c87e"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="51ebaf824cc634665c5efcae95b8301ad1758c5e"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="b4f6fd4afd03161f53c7d2a663750f94762bd238"/>

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

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="05a36844c1046a1eb07d5b1325f85ed741f961ea">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="b75979ec8862bd5799a7c42e938d3f67be38d6ae"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="e2fab8f6ac345ecde10a1350e699be9ceb6987d6"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="e9e2923fd6cab93cf88b4b9ada82225e44fe6635"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="1b3591a50ed352fc6ddb77462b7b35d0bfa555a3"/>

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

@ -1019,13 +1019,7 @@ DiagnosticsMatcher::DiagnosticsMatcher() {
// lambda, where the declaration they reference is not inside the lambda.
// This excludes arguments and local variables, leaving only captured
// variables.
astMatcher.addMatcher(
lambdaExpr(hasDescendant(
declRefExpr(hasType(pointerType(pointee(isRefCounted()))),
to(decl().bind("decl")))
.bind("declref")),
unless(hasDescendant(decl(equalsBoundNode("decl"))))),
&refCountedInsideLambdaChecker);
astMatcher.addMatcher(lambdaExpr().bind("lambda"), &refCountedInsideLambdaChecker);
// Older clang versions such as the ones used on the infra recognize these
// conversions as 'operator _Bool', but newer clang versions recognize these
@ -1252,11 +1246,19 @@ void DiagnosticsMatcher::RefCountedInsideLambdaChecker::run(
"Refcounted variable %0 of type %1 cannot be captured by a lambda");
unsigned noteID = Diag.getDiagnosticIDs()->getCustomDiagID(
DiagnosticIDs::Note, "Please consider using a smart pointer");
const DeclRefExpr *declref = Result.Nodes.getNodeAs<DeclRefExpr>("declref");
const LambdaExpr *Lambda = Result.Nodes.getNodeAs<LambdaExpr>("lambda");
Diag.Report(declref->getLocStart(), errorID)
<< declref->getFoundDecl() << declref->getType()->getPointeeType();
Diag.Report(declref->getLocStart(), noteID);
for (const LambdaCapture Capture : Lambda->captures()) {
if (Capture.capturesVariable()) {
QualType Pointee = Capture.getCapturedVar()->getType()->getPointeeType();
if (!Pointee.isNull() && isClassRefCounted(Pointee)) {
Diag.Report(Capture.getLocation(), errorID)
<< Capture.getCapturedVar() << Pointee;
Diag.Report(Capture.getLocation(), noteID);
}
}
}
}
void DiagnosticsMatcher::ExplicitOperatorBoolChecker::run(

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

@ -67,9 +67,9 @@ void foo() {
take(argsp);
take(localsp);
});
take([ptr](R* argptr) {
take([ptr](R* argptr) { // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
R* localptr;
ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
ptr->method();
argptr->method();
localptr->method();
});
@ -79,9 +79,9 @@ void foo() {
argsp->method();
localsp->method();
});
take([ptr](R* argptr) {
take([ptr](R* argptr) { // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
R* localptr;
take(ptr); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
take(ptr);
take(argptr);
take(localptr);
});

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

@ -2852,7 +2852,7 @@ Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor,
(!aVisitor.mEvent->mFlags.mIsTrusted &&
(aVisitor.mEvent->mMessage != eMouseClick) &&
(aVisitor.mEvent->mMessage != eKeyPress) &&
(aVisitor.mEvent->mMessage != NS_UI_ACTIVATE)) ||
(aVisitor.mEvent->mMessage != eLegacyDOMActivate)) ||
!aVisitor.mPresContext ||
aVisitor.mEvent->mFlags.mMultipleActionsPrevented) {
return false;
@ -2869,9 +2869,9 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor)
// IMPORTANT: this switch and the switch below it must be kept in sync!
switch (aVisitor.mEvent->mMessage) {
case eMouseOver:
case NS_FOCUS_CONTENT:
case eFocus:
case eMouseOut:
case NS_BLUR_CONTENT:
case eBlur:
break;
default:
return NS_OK;
@ -2892,7 +2892,7 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor)
case eMouseOver:
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
// FALL THROUGH
case NS_FOCUS_CONTENT: {
case eFocus: {
InternalFocusEvent* focusEvent = aVisitor.mEvent->AsFocusEvent();
if (!focusEvent || !focusEvent->isRefocus) {
nsAutoString target;
@ -2907,7 +2907,7 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor)
case eMouseOut:
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
// FALL THROUGH
case NS_BLUR_CONTENT:
case eBlur:
rv = LeaveLink(aVisitor.mPresContext);
if (NS_SUCCEEDED(rv)) {
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
@ -2931,7 +2931,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
switch (aVisitor.mEvent->mMessage) {
case eMouseDown:
case eMouseClick:
case NS_UI_ACTIVATE:
case eLegacyDOMActivate:
case eKeyPress:
break;
default:
@ -2985,7 +2985,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
nsEventStatus status = nsEventStatus_eIgnore;
// DOMActive event should be trusted since the activation is actually
// occurred even if the cause is an untrusted click event.
InternalUIEvent actEvent(true, NS_UI_ACTIVATE, mouseEvent);
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
actEvent.detail = 1;
rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
@ -2996,7 +2996,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor)
}
break;
}
case NS_UI_ACTIVATE:
case eLegacyDOMActivate:
{
if (aVisitor.mEvent->originalTarget == this) {
nsAutoString target;

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

@ -69,6 +69,7 @@ EventSource::EventSource(nsPIDOMWindow* aOwnerWindow) :
mLastConvertionResult(NS_OK),
mReadyState(CONNECTING),
mScriptLine(0),
mScriptColumn(0),
mInnerWindowID(0)
{
}
@ -205,7 +206,8 @@ EventSource::Init(nsISupports* aOwner,
// The conditional here is historical and not necessarily sane.
if (JSContext *cx = nsContentUtils::GetCurrentJSContext()) {
nsJSUtils::GetCallingLocation(cx, mScriptFile, &mScriptLine);
nsJSUtils::GetCallingLocation(cx, mScriptFile, &mScriptLine,
&mScriptColumn);
mInnerWindowID = nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx);
}
@ -987,7 +989,7 @@ EventSource::PrintErrorOnConsole(const char *aBundleURI,
rv = errObj->InitWithWindowID(message,
mScriptFile,
EmptyString(),
mScriptLine, 0,
mScriptLine, mScriptColumn,
nsIScriptError::errorFlag,
"Event Source", mInnerWindowID);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -255,12 +255,14 @@ protected:
// Event Source owner information:
// - the script file name
// - source code line number where the Event Source object was constructed.
// - source code line number and column number where the Event Source object
// was constructed.
// - the ID of the inner window where the script lives. Note that this may not
// be the same as the Event Source owner window.
// These attributes are used for error reporting.
nsString mScriptFile;
uint32_t mScriptLine;
uint32_t mScriptColumn;
uint64_t mInnerWindowID;
private:

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

@ -806,12 +806,12 @@ nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor)
// selectstart
bool stopEvent = false;
switch (aVisitor.mEvent->mMessage) {
case NS_IMAGE_ABORT:
case NS_LOAD_ERROR:
case NS_FORM_SELECTED:
case NS_FORM_CHANGE:
case NS_LOAD:
case NS_FORM_RESET:
case eImageAbort:
case eLoadError:
case eFormSelect:
case eFormChange:
case eLoad:
case eFormReset:
case eResize:
case eScroll:
stopEvent = true;
@ -843,7 +843,7 @@ nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor)
// The load event is special in that we don't ever propagate it
// to chrome.
nsCOMPtr<nsPIDOMWindow> win = OwnerDoc()->GetWindow();
EventTarget* parentTarget = win && aVisitor.mEvent->mMessage != NS_LOAD
EventTarget* parentTarget = win && aVisitor.mEvent->mMessage != eLoad
? win->GetParentTarget() : nullptr;
aVisitor.mParentTarget = parentTarget;

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

@ -92,6 +92,7 @@ public:
, mCloseEventWasClean(false)
, mCloseEventCode(nsIWebSocketChannel::CLOSE_ABNORMAL)
, mScriptLine(0)
, mScriptColumn(0)
, mInnerWindowID(0)
, mWorkerPrivate(nullptr)
#ifdef DEBUG
@ -121,6 +122,7 @@ public:
nsTArray<nsString>& aProtocolArray,
const nsACString& aScriptFile,
uint32_t aScriptLine,
uint32_t aScriptColumn,
ErrorResult& aRv,
bool* aConnectionFailed);
@ -197,12 +199,14 @@ public:
// Web Socket owner information:
// - the script file name, UTF8 encoded.
// - source code line number where the Web Socket object was constructed.
// - source code line number and column number where the Web Socket object
// was constructed.
// - the ID of the inner window where the script lives. Note that this may not
// be the same as the Web Socket owner window.
// These attributes are used for error reporting.
nsCString mScriptFile;
uint32_t mScriptLine;
uint32_t mScriptColumn;
uint64_t mInnerWindowID;
WorkerPrivate* mWorkerPrivate;
@ -370,13 +374,14 @@ WebSocketImpl::PrintErrorOnConsole(const char *aBundleURI,
if (mInnerWindowID) {
rv = errorObject->InitWithWindowID(message,
NS_ConvertUTF8toUTF16(mScriptFile),
EmptyString(), mScriptLine, 0,
EmptyString(), mScriptLine,
mScriptColumn,
nsIScriptError::errorFlag, "Web Socket",
mInnerWindowID);
} else {
rv = errorObject->Init(message,
NS_ConvertUTF8toUTF16(mScriptFile),
EmptyString(), mScriptLine, 0,
EmptyString(), mScriptLine, mScriptColumn,
nsIScriptError::errorFlag, "Web Socket");
}
@ -1036,6 +1041,7 @@ public:
InitRunnable(WebSocketImpl* aImpl, const nsAString& aURL,
nsTArray<nsString>& aProtocolArray,
const nsACString& aScriptFile, uint32_t aScriptLine,
uint32_t aScriptColumn,
ErrorResult& aRv, bool* aConnectionFailed)
: WebSocketMainThreadRunnable(aImpl->mWorkerPrivate)
, mImpl(aImpl)
@ -1043,6 +1049,7 @@ public:
, mProtocolArray(aProtocolArray)
, mScriptFile(aScriptFile)
, mScriptLine(aScriptLine)
, mScriptColumn(aScriptColumn)
, mRv(aRv)
, mConnectionFailed(aConnectionFailed)
{
@ -1074,7 +1081,7 @@ protected:
}
mImpl->Init(jsapi.cx(), principal, mURL, mProtocolArray, mScriptFile,
mScriptLine, mRv, mConnectionFailed);
mScriptLine, mScriptColumn, mRv, mConnectionFailed);
return true;
}
@ -1084,7 +1091,7 @@ protected:
MOZ_ASSERT(aTopLevelWorkerPrivate && !aTopLevelWorkerPrivate->GetWindow());
mImpl->Init(nullptr, aTopLevelWorkerPrivate->GetPrincipal(), mURL,
mProtocolArray, mScriptFile, mScriptLine, mRv,
mProtocolArray, mScriptFile, mScriptLine, mScriptColumn, mRv,
mConnectionFailed);
return true;
}
@ -1096,6 +1103,7 @@ protected:
nsTArray<nsString>& mProtocolArray;
nsCString mScriptFile;
uint32_t mScriptLine;
uint32_t mScriptColumn;
ErrorResult& mRv;
bool* mConnectionFailed;
};
@ -1217,7 +1225,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
if (NS_IsMainThread()) {
webSocket->mImpl->Init(aGlobal.Context(), principal, aUrl, protocolArray,
EmptyCString(), 0, aRv, &connectionFailed);
EmptyCString(), 0, 0, aRv, &connectionFailed);
} else {
// In workers we have to keep the worker alive using a feature in order to
// dispatch messages correctly.
@ -1226,15 +1234,16 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
return nullptr;
}
unsigned lineno;
unsigned lineno, column;
JS::AutoFilename file;
if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno)) {
if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno,
&column)) {
NS_WARNING("Failed to get line number and filename in workers.");
}
nsRefPtr<InitRunnable> runnable =
new InitRunnable(webSocket->mImpl, aUrl, protocolArray,
nsAutoCString(file.get()), lineno, aRv,
nsAutoCString(file.get()), lineno, column, aRv,
&connectionFailed);
runnable->Dispatch(aGlobal.Context());
}
@ -1395,6 +1404,7 @@ WebSocketImpl::Init(JSContext* aCx,
nsTArray<nsString>& aProtocolArray,
const nsACString& aScriptFile,
uint32_t aScriptLine,
uint32_t aScriptColumn,
ErrorResult& aRv,
bool* aConnectionFailed)
{
@ -1434,14 +1444,16 @@ WebSocketImpl::Init(JSContext* aCx,
if (mWorkerPrivate) {
mScriptFile = aScriptFile;
mScriptLine = aScriptLine;
mScriptColumn = aScriptColumn;
} else {
MOZ_ASSERT(aCx);
unsigned lineno;
unsigned lineno, column;
JS::AutoFilename file;
if (JS::DescribeScriptedCaller(aCx, &file, &lineno)) {
if (JS::DescribeScriptedCaller(aCx, &file, &lineno, &column)) {
mScriptFile = file.get();
mScriptLine = lineno;
mScriptColumn = column;
}
}

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

@ -3502,7 +3502,7 @@ nsContentUtils::ReportToConsoleNonLocalized(const nsAString& aErrorText,
if (!aLineNumber) {
JSContext *cx = GetCurrentJSContext();
if (cx) {
nsJSUtils::GetCallingLocation(cx, spec, &aLineNumber);
nsJSUtils::GetCallingLocation(cx, spec, &aLineNumber, &aColumnNumber);
}
}
if (spec.IsEmpty() && aURI)
@ -5464,8 +5464,8 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
// For draggesture and dragstart events, the data transfer object is
// created before the event fires, so it should already be set. For other
// drag events, get the object from the drag session.
NS_ASSERTION(aDragEvent->mMessage != NS_DRAGDROP_GESTURE &&
aDragEvent->mMessage != NS_DRAGDROP_START,
NS_ASSERTION(aDragEvent->mMessage != eLegacyDragGesture &&
aDragEvent->mMessage != eDragStart,
"draggesture event created without a dataTransfer");
nsCOMPtr<nsIDragSession> dragSession = GetDragSession();
@ -5492,8 +5492,8 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
}
bool isCrossDomainSubFrameDrop = false;
if (aDragEvent->mMessage == NS_DRAGDROP_DROP ||
aDragEvent->mMessage == NS_DRAGDROP_DRAGDROP) {
if (aDragEvent->mMessage == eDrop ||
aDragEvent->mMessage == eLegacyDragDrop) {
isCrossDomainSubFrameDrop = CheckForSubFrameDrop(dragSession, aDragEvent);
}
@ -5507,16 +5507,15 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
// for the dragenter and dragover events, initialize the drop effect
// from the drop action, which platform specific widget code sets before
// the event is fired based on the keyboard state.
if (aDragEvent->mMessage == NS_DRAGDROP_ENTER ||
aDragEvent->mMessage == NS_DRAGDROP_OVER) {
if (aDragEvent->mMessage == eDragEnter || aDragEvent->mMessage == eDragOver) {
uint32_t action, effectAllowed;
dragSession->GetDragAction(&action);
aDragEvent->dataTransfer->GetEffectAllowedInt(&effectAllowed);
aDragEvent->dataTransfer->SetDropEffectInt(FilterDropEffect(action, effectAllowed));
}
else if (aDragEvent->mMessage == NS_DRAGDROP_DROP ||
aDragEvent->mMessage == NS_DRAGDROP_DRAGDROP ||
aDragEvent->mMessage == NS_DRAGDROP_END) {
else if (aDragEvent->mMessage == eDrop ||
aDragEvent->mMessage == eLegacyDragDrop ||
aDragEvent->mMessage == eDragEnd) {
// For the drop and dragend events, set the drop effect based on the
// last value that the dropEffect had. This will have been set in
// EventStateManager::PostHandleEvent for the last dragenter or

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

@ -299,25 +299,6 @@ nsDOMWindowUtils::UpdateLayerTree()
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::SetCSSViewport(float aWidthPx, float aHeightPx)
{
MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
if (!(aWidthPx >= 0.0 && aHeightPx >= 0.0)) {
return NS_ERROR_ILLEGAL_VALUE;
}
nsIPresShell* presShell = GetPresShell();
if (!presShell) {
return NS_ERROR_FAILURE;
}
nsLayoutUtils::SetCSSViewport(presShell, CSSSize(aWidthPx, aHeightPx));
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetViewportInfo(uint32_t aDisplayWidth,
uint32_t aDisplayHeight,

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

@ -8146,7 +8146,7 @@ nsDocument::PreHandleEvent(EventChainPreVisitor& aVisitor)
aVisitor.mForceContentDispatch = true;
// Load events must not propagate to |window| object, see bug 335251.
if (aVisitor.mEvent->mMessage != NS_LOAD) {
if (aVisitor.mEvent->mMessage != eLoad) {
nsGlobalWindow* window = static_cast<nsGlobalWindow*>(GetWindow());
aVisitor.mParentTarget =
window ? window->GetTargetForEventTargetChain() : nullptr;

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

@ -966,7 +966,7 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow)
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
if (presShell) {
SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell,
SendFocusOrBlurEvent(eBlur, presShell,
oldFocusedContent->GetComposedDoc(),
oldFocusedContent, 1, false);
}
@ -1682,7 +1682,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
if (mActiveWindow)
window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell,
SendFocusOrBlurEvent(eBlur, presShell,
content->GetComposedDoc(), content, 1, false);
}
@ -1729,9 +1729,9 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear,
// the document isn't null in case someone closed it during the blur above
nsIDocument* doc = window->GetExtantDoc();
if (doc)
SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell, doc, doc, 1, false);
SendFocusOrBlurEvent(eBlur, presShell, doc, doc, 1, false);
if (mFocusedWindow == nullptr)
SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell, doc, window, 1, false);
SendFocusOrBlurEvent(eBlur, presShell, doc, window, 1, false);
// check if a different window was focused
result = (mFocusedWindow == nullptr && mActiveWindow);
@ -1857,10 +1857,10 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
GetFocusMoveActionCause(aFlags));
}
if (doc)
SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, doc,
SendFocusOrBlurEvent(eFocus, presShell, doc,
doc, aFlags & FOCUSMETHOD_MASK, aWindowRaised);
if (mFocusedWindow == aWindow && mFocusedContent == nullptr)
SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, doc,
SendFocusOrBlurEvent(eFocus, presShell, doc,
aWindow, aFlags & FOCUSMETHOD_MASK, aWindowRaised);
}
@ -1908,7 +1908,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
if (!aWindowRaised)
aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0);
SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell,
SendFocusOrBlurEvent(eFocus, presShell,
aContent->GetComposedDoc(),
aContent, aFlags & FOCUSMETHOD_MASK,
aWindowRaised, isRefocus);
@ -2001,8 +2001,7 @@ nsFocusManager::SendFocusOrBlurEvent(EventMessage aEventMessage,
bool aWindowRaised,
bool aIsRefocus)
{
NS_ASSERTION(aEventMessage == NS_FOCUS_CONTENT ||
aEventMessage == NS_BLUR_CONTENT,
NS_ASSERTION(aEventMessage == eFocus || aEventMessage == eBlur,
"Wrong event type for SendFocusOrBlurEvent");
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
@ -2042,7 +2041,7 @@ nsFocusManager::SendFocusOrBlurEvent(EventMessage aEventMessage,
#ifdef ACCESSIBILITY
nsAccessibilityService* accService = GetAccService();
if (accService) {
if (aEventMessage == NS_FOCUS_CONTENT) {
if (aEventMessage == eFocus) {
accService->NotifyOfDOMFocus(aTarget);
} else {
accService->NotifyOfDOMBlur(aTarget);

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

@ -280,7 +280,7 @@ protected:
/**
* Fires a focus or blur event at aTarget.
*
* aEventMessage should be either NS_FOCUS_CONTENT or NS_BLUR_CONTENT.
* aEventMessage should be either eFocus or eBlur.
* For blur events, aFocusMethod should normally be non-zero.
*
* aWindowRaised should only be true if called from WindowRaised.

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

@ -157,7 +157,6 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, bool aNetworkCreated)
, mObservingOwnerContent(false)
, mVisible(true)
{
ResetPermissionManagerStatus();
mRemoteFrame = ShouldUseRemoteProcess();
}
@ -409,6 +408,9 @@ nsFrameLoader::ReallyStartLoadingInternal()
mURIToLoad = nullptr;
NS_ENSURE_SUCCESS(rv, rv);
// Track the appId's reference count if this frame is in-process
ResetPermissionManagerStatus();
return NS_OK;
}
@ -2705,7 +2707,9 @@ nsFrameLoader::ResetPermissionManagerStatus()
{
// The resetting of the permissions status can run only
// in the main process.
if (XRE_IsContentProcess()) {
// only in-main-process && in-process frame is handled here and all other
// cases are handled by ContentParent.
if (XRE_IsContentProcess() || mRemoteFrame) {
return;
}

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

@ -663,12 +663,12 @@ GetParamsForMessage(JSContext* aCx,
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
nsAutoString filename;
uint32_t lineno = 0;
nsJSUtils::GetCallingLocation(aCx, filename, &lineno);
uint32_t lineno = 0, column = 0;
nsJSUtils::GetCallingLocation(aCx, filename, &lineno, &column);
nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
error->Init(NS_LITERAL_STRING("Sending message that cannot be cloned. Are you trying to send an XPCOM object?"),
filename, EmptyString(),
lineno, 0, nsIScriptError::warningFlag, "chrome javascript");
filename, EmptyString(), lineno, column,
nsIScriptError::warningFlag, "chrome javascript");
console->LogMessage(error);
}

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

@ -49,8 +49,8 @@ public:
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override
{
MOZ_ASSERT(IsInNativeAnonymousSubtree());
if (aVisitor.mEvent->mMessage == NS_LOAD ||
aVisitor.mEvent->mMessage == NS_LOAD_ERROR) {
if (aVisitor.mEvent->mMessage == eLoad ||
aVisitor.mEvent->mMessage == eLoadError) {
// Don't propagate the events to the parent.
return NS_OK;
}

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

@ -3086,7 +3086,7 @@ nsGlobalWindow::PreHandleEvent(EventChainPreVisitor& aVisitor)
}
} else if (msg == eMouseDown && aVisitor.mEvent->mFlags.mIsTrusted) {
gMouseDown = true;
} else if ((msg == eMouseUp || msg == NS_DRAGDROP_END) &&
} else if ((msg == eMouseUp || msg == eDragEnd) &&
aVisitor.mEvent->mFlags.mIsTrusted) {
gMouseDown = false;
if (gDragServiceDisabled) {
@ -3265,8 +3265,8 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
// Return early if there is nothing to do.
switch (aVisitor.mEvent->mMessage) {
case eResize:
case NS_PAGE_UNLOAD:
case NS_LOAD:
case eUnload:
case eLoad:
break;
default:
return NS_OK;
@ -3280,7 +3280,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
if (aVisitor.mEvent->mMessage == eResize) {
mIsHandlingResizeEvent = false;
} else if (aVisitor.mEvent->mMessage == NS_PAGE_UNLOAD &&
} else if (aVisitor.mEvent->mMessage == eUnload &&
aVisitor.mEvent->mFlags.mIsTrusted) {
// Execute bindingdetached handlers before we tear ourselves
// down.
@ -3288,7 +3288,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
mDoc->BindingManager()->ExecuteDetachedHandlers();
}
mIsDocumentLoaded = false;
} else if (aVisitor.mEvent->mMessage == NS_LOAD &&
} else if (aVisitor.mEvent->mMessage == eLoad &&
aVisitor.mEvent->mFlags.mIsTrusted) {
// This is page load event since load events don't propagate to |window|.
// @see nsDocument::PreHandleEvent.
@ -3302,7 +3302,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor)
// onload event for the frame element.
nsEventStatus status = nsEventStatus_eIgnore;
WidgetEvent event(aVisitor.mEvent->mFlags.mIsTrusted, NS_LOAD);
WidgetEvent event(aVisitor.mEvent->mFlags.mIsTrusted, eLoad);
event.mFlags.mBubbles = false;
// Most of the time we could get a pres context to pass in here,

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

@ -35,10 +35,10 @@ using namespace mozilla::dom;
bool
nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
uint32_t* aLineno)
uint32_t* aLineno, uint32_t* aColumn)
{
JS::AutoFilename filename;
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno)) {
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, aColumn)) {
return false;
}
@ -48,10 +48,10 @@ nsJSUtils::GetCallingLocation(JSContext* aContext, nsACString& aFilename,
bool
nsJSUtils::GetCallingLocation(JSContext* aContext, nsAString& aFilename,
uint32_t* aLineno)
uint32_t* aLineno, uint32_t* aColumn)
{
JS::AutoFilename filename;
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno)) {
if (!JS::DescribeScriptedCaller(aContext, &filename, aLineno, aColumn)) {
return false;
}

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

@ -35,9 +35,11 @@ class nsJSUtils
{
public:
static bool GetCallingLocation(JSContext* aContext, nsACString& aFilename,
uint32_t* aLineno);
uint32_t* aLineno = nullptr,
uint32_t* aColumn = nullptr);
static bool GetCallingLocation(JSContext* aContext, nsAString& aFilename,
uint32_t* aLineno);
uint32_t* aLineno = nullptr,
uint32_t* aColumn = nullptr);
static nsIScriptGlobalObject *GetStaticScriptGlobal(JSObject* aObj);

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

@ -59,10 +59,10 @@ nsScriptElement::ScriptEvaluated(nsresult aResult,
nsContentUtils::GetContextForContent(cont);
nsEventStatus status = nsEventStatus_eIgnore;
EventMessage message = NS_SUCCEEDED(aResult) ? NS_LOAD : NS_LOAD_ERROR;
EventMessage message = NS_SUCCEEDED(aResult) ? eLoad : eLoadError;
WidgetEvent event(true, message);
// Load event doesn't bubble.
event.mFlags.mBubbles = (message != NS_LOAD);
event.mFlags.mBubbles = (message != eLoad);
EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status);
}

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

@ -64,6 +64,7 @@ const COMMAND_MAP = {
'cut': 'cmd_cut',
'copy': 'cmd_copyAndCollapseToEnd',
'copyImage': 'cmd_copyImage',
'copyLink': 'cmd_copyLink',
'paste': 'cmd_paste',
'selectall': 'cmd_selectAll'
};
@ -865,7 +866,13 @@ BrowserElementChild.prototype = {
var elem = e.target;
var menuData = {systemTargets: [], contextmenu: null};
var ctxMenuId = null;
var hasImgElement = false;
var copyableElements = {
image: false,
link: false,
hasElements: function() {
return this.image || this.link;
}
};
// Set the event target as the copy image command needs it to
// determine what was context-clicked on.
@ -884,20 +891,22 @@ BrowserElementChild.prototype = {
ctxMenuId = elem.getAttribute('contextmenu');
}
// Enable copy image option
// Enable copy image/link option
if (elem.nodeName == 'IMG') {
hasImgElement = true;
copyableElements.image = true;
} else if (elem.nodeName == 'A') {
copyableElements.link = true;
}
elem = elem.parentNode;
}
if (ctxMenuId || hasImgElement) {
if (ctxMenuId || copyableElements.hasElements()) {
var menu = null;
if (ctxMenuId) {
menu = e.target.ownerDocument.getElementById(ctxMenuId);
}
menuData.contextmenu = this._buildMenuObj(menu, '', hasImgElement);
menuData.contextmenu = this._buildMenuObj(menu, '', copyableElements);
}
// Pass along the position where the context menu should be located
@ -1235,6 +1244,10 @@ BrowserElementChild.prototype = {
// Set command
data.json.command = 'copyImage';
this._recvDoCommand(data);
} else if (data.json.menuitem == 'copy-link') {
// Set command
data.json.command = 'copyLink';
this._recvDoCommand(data);
} else if (data.json.menuitem in this._ctxHandlers) {
this._ctxHandlers[data.json.menuitem].click();
this._ctxHandlers = {};
@ -1244,7 +1257,7 @@ BrowserElementChild.prototype = {
}
},
_buildMenuObj: function(menu, idPrefix, hasImgElement) {
_buildMenuObj: function(menu, idPrefix, copyableElements) {
var menuObj = {type: 'menu', items: []};
// Customized context menu
if (menu) {
@ -1263,8 +1276,14 @@ BrowserElementChild.prototype = {
}
}
}
// Note: Display "Copy Link" first in order to make sure "Copy Image" is
// put together with other image options if elem is an image link.
// "Copy Link" menu item
if (copyableElements.link) {
menuObj.items.push({id: 'copy-link'});
}
// "Copy Image" menu item
if (hasImgElement) {
if (copyableElements.image) {
menuObj.items.push({id: 'copy-image'});
}

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

@ -24,7 +24,7 @@ function checkEmptyContextMenu() {
function checkInnerContextMenu() {
sendContextMenuTo('#inner-link', function onContextMenu(detail) {
is(detail.systemTargets.length, 1, 'Includes anchor data');
is(detail.contextmenu.items.length, 2, 'Inner clicks trigger correct menu');
is(detail.contextmenu.items.length, 3, 'Inner clicks trigger correct menu');
var target = detail.systemTargets[0];
is(target.nodeName, 'A', 'Reports correct nodeName');
is(target.data.uri, 'foo.html', 'Reports correct uri');

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

@ -139,7 +139,6 @@ UNIFIED_SOURCES += [
]
LOCAL_INCLUDES += [
'../..', # Support `#include "mfbt/RefPtr.h"`
'/js/xpconnect/wrappers',
]

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

@ -68,40 +68,41 @@ const char DataTransfer::sEffects[8][9] = {
"none", "copy", "move", "copyMove", "link", "copyLink", "linkMove", "all"
};
DataTransfer::DataTransfer(nsISupports* aParent, uint32_t aEventType,
DataTransfer::DataTransfer(nsISupports* aParent, EventMessage aEventMessage,
bool aIsExternal, int32_t aClipboardType)
: mParent(aParent),
mEventType(aEventType),
mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED),
mCursorState(false),
mReadOnly(true),
mIsExternal(aIsExternal),
mUserCancelled(false),
mIsCrossDomainSubFrameDrop(false),
mClipboardType(aClipboardType),
mDragImageX(0),
mDragImageY(0)
: mParent(aParent)
, mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE)
, mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
, mEventMessage(aEventMessage)
, mCursorState(false)
, mReadOnly(true)
, mIsExternal(aIsExternal)
, mUserCancelled(false)
, mIsCrossDomainSubFrameDrop(false)
, mClipboardType(aClipboardType)
, mDragImageX(0)
, mDragImageY(0)
{
// For these events, we want to be able to add data to the data transfer, so
// clear the readonly state. Otherwise, the data is already present. For
// external usage, cache the data from the native clipboard or drag.
if (aEventType == NS_CUT ||
aEventType == NS_COPY ||
aEventType == NS_DRAGDROP_START ||
aEventType == NS_DRAGDROP_GESTURE) {
if (aEventMessage == NS_CUT ||
aEventMessage == NS_COPY ||
aEventMessage == eDragStart ||
aEventMessage == eLegacyDragGesture) {
mReadOnly = false;
} else if (mIsExternal) {
if (aEventType == NS_PASTE) {
if (aEventMessage == NS_PASTE) {
CacheExternalClipboardFormats();
} else if (aEventType >= NS_DRAGDROP_EVENT_START && aEventType <= NS_DRAGDROP_LEAVE) {
} else if (aEventMessage >= eDragDropEventFirst &&
aEventMessage <= eDragDropEventLast) {
CacheExternalDragFormats();
}
}
}
DataTransfer::DataTransfer(nsISupports* aParent,
uint32_t aEventType,
EventMessage aEventMessage,
const uint32_t aEffectAllowed,
bool aCursorState,
bool aIsExternal,
@ -112,20 +113,20 @@ DataTransfer::DataTransfer(nsISupports* aParent,
Element* aDragImage,
uint32_t aDragImageX,
uint32_t aDragImageY)
: mParent(aParent),
mEventType(aEventType),
mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
mEffectAllowed(aEffectAllowed),
mCursorState(aCursorState),
mReadOnly(true),
mIsExternal(aIsExternal),
mUserCancelled(aUserCancelled),
mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop),
mClipboardType(aClipboardType),
mItems(aItems),
mDragImage(aDragImage),
mDragImageX(aDragImageX),
mDragImageY(aDragImageY)
: mParent(aParent)
, mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE)
, mEffectAllowed(aEffectAllowed)
, mEventMessage(aEventMessage)
, mCursorState(aCursorState)
, mReadOnly(true)
, mIsExternal(aIsExternal)
, mUserCancelled(aUserCancelled)
, mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop)
, mClipboardType(aClipboardType)
, mItems(aItems)
, mDragImage(aDragImage)
, mDragImageX(aDragImageX)
, mDragImageY(aDragImageY)
{
MOZ_ASSERT(mParent);
// The items are copied from aItems into mItems. There is no need to copy
@ -133,8 +134,8 @@ DataTransfer::DataTransfer(nsISupports* aParent,
// draggesture and dragstart events are the only times when items are
// modifiable, but those events should have been using the first constructor
// above.
NS_ASSERTION(aEventType != NS_DRAGDROP_GESTURE &&
aEventType != NS_DRAGDROP_START,
NS_ASSERTION(aEventMessage != eLegacyDragGesture &&
aEventMessage != eDragStart,
"invalid event type for DataTransfer constructor");
}
@ -268,8 +269,9 @@ DataTransfer::GetMozUserCancelled(bool* aUserCancelled)
FileList*
DataTransfer::GetFiles(ErrorResult& aRv)
{
if (mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP &&
mEventType != NS_PASTE) {
if (mEventMessage != eDrop &&
mEventMessage != eLegacyDragDrop &&
mEventMessage != NS_PASTE) {
return nullptr;
}
@ -541,7 +543,8 @@ DataTransfer::MozTypesAt(uint32_t aIndex, ErrorResult& aRv)
{
// Only the first item is valid for clipboard events
if (aIndex > 0 &&
(mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
(mEventMessage == NS_CUT || mEventMessage == NS_COPY ||
mEventMessage == NS_PASTE)) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr;
}
@ -581,7 +584,8 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
// Only the first item is valid for clipboard events
if (aIndex > 0 &&
(mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
(mEventMessage == NS_CUT || mEventMessage == NS_COPY ||
mEventMessage == NS_PASTE)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -599,8 +603,8 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
// only allow access to the data with the same principal.
nsIPrincipal* principal = nullptr;
if (mIsCrossDomainSubFrameDrop ||
(mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP &&
mEventType != NS_PASTE &&
(mEventMessage != eDrop && mEventMessage != eLegacyDragDrop &&
mEventMessage != NS_PASTE &&
!nsContentUtils::IsCallerChrome())) {
principal = nsContentUtils::SubjectPrincipal();
}
@ -692,7 +696,8 @@ DataTransfer::MozSetDataAt(const nsAString& aFormat, nsIVariant* aData,
// Only the first item is valid for clipboard events
if (aIndex > 0 &&
(mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
(mEventMessage == NS_CUT || mEventMessage == NS_COPY ||
mEventMessage == NS_PASTE)) {
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
@ -737,7 +742,8 @@ DataTransfer::MozClearDataAt(const nsAString& aFormat, uint32_t aIndex,
// Only the first item is valid for clipboard events
if (aIndex > 0 &&
(mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
(mEventMessage == NS_CUT || mEventMessage == NS_COPY ||
mEventMessage == NS_PASTE)) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return;
}
@ -752,8 +758,8 @@ DataTransfer::MozClearDataAtHelper(const nsAString& aFormat, uint32_t aIndex,
MOZ_ASSERT(!mReadOnly);
MOZ_ASSERT(aIndex < mItems.Length());
MOZ_ASSERT(aIndex == 0 ||
(mEventType != NS_CUT && mEventType != NS_COPY &&
mEventType != NS_PASTE));
(mEventMessage != NS_CUT && mEventMessage != NS_COPY &&
mEventMessage != NS_PASTE));
nsAutoString format;
GetRealFormat(aFormat, format);
@ -938,12 +944,12 @@ DataTransfer::AddElement(nsIDOMElement* aElement)
}
nsresult
DataTransfer::Clone(nsISupports* aParent, uint32_t aEventType,
DataTransfer::Clone(nsISupports* aParent, EventMessage aEventMessage,
bool aUserCancelled, bool aIsCrossDomainSubFrameDrop,
DataTransfer** aNewDataTransfer)
{
DataTransfer* newDataTransfer =
new DataTransfer(aParent, aEventType, mEffectAllowed, mCursorState,
new DataTransfer(aParent, aEventMessage, mEffectAllowed, mCursorState,
mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop,
mClipboardType, mItems, mDragImage, mDragImageX,
mDragImageY);
@ -1252,7 +1258,8 @@ DataTransfer::CacheExternalDragFormats()
void
DataTransfer::CacheExternalClipboardFormats()
{
NS_ASSERTION(mEventType == NS_PASTE, "caching clipboard data for invalid event");
NS_ASSERTION(mEventMessage == NS_PASTE,
"caching clipboard data for invalid event");
// Called during the constructor for paste events to cache the formats
// available on the clipboard. As with CacheExternalDragFormats, the
@ -1293,7 +1300,7 @@ DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex)
}
// only drag and paste events should be calling FillInExternalData
NS_ASSERTION(mEventType != NS_CUT && mEventType != NS_COPY,
NS_ASSERTION(mEventMessage != NS_CUT && mEventMessage != NS_COPY,
"clipboard event with empty data");
NS_ConvertUTF16toUTF8 utf8format(aItem.mFormat);
@ -1311,7 +1318,7 @@ DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex)
trans->Init(nullptr);
trans->AddDataFlavor(format);
if (mEventType == NS_PASTE) {
if (mEventMessage == NS_PASTE) {
MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0");
nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1");

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

@ -18,6 +18,7 @@
#include "nsAutoPtr.h"
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/Promise.h"
@ -75,7 +76,7 @@ protected:
// this constructor is used only by the Clone method to copy the fields as
// needed to a new data transfer.
DataTransfer(nsISupports* aParent,
uint32_t aEventType,
EventMessage aEventMessage,
const uint32_t aEffectAllowed,
bool aCursorState,
bool aIsExternal,
@ -95,8 +96,6 @@ public:
// Constructor for DataTransfer.
//
// aEventType is an event constant (such as NS_DRAGDROP_START)
//
// aIsExternal must only be true when used to create a dataTransfer for a
// paste or a drag that was started without using a data transfer. The
// latter will occur when an external drag occurs, that is, a drag where the
@ -104,8 +103,8 @@ public:
// service directly. For clipboard operations, aClipboardType indicates
// which clipboard to use, from nsIClipboard, or -1 for non-clipboard operations,
// or if access to the system clipboard should not be allowed.
DataTransfer(nsISupports* aParent, uint32_t aEventType, bool aIsExternal,
int32_t aClipboardType);
DataTransfer(nsISupports* aParent, EventMessage aEventMessage,
bool aIsExternal, int32_t aClipboardType);
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
nsISupports* GetParentObject()
@ -222,8 +221,9 @@ public:
return mDragImage;
}
nsresult Clone(nsISupports* aParent, uint32_t aEventType, bool aUserCancelled,
bool aIsCrossDomainSubFrameDrop, DataTransfer** aResult);
nsresult Clone(nsISupports* aParent, EventMessage aEventMessage,
bool aUserCancelled, bool aIsCrossDomainSubFrameDrop,
DataTransfer** aResult);
protected:
@ -254,14 +254,15 @@ protected:
nsCOMPtr<nsISupports> mParent;
// the event type this data transfer is for. This will correspond to an
// event->mMessage value.
uint32_t mEventType;
// the drop effect and effect allowed
uint32_t mDropEffect;
uint32_t mEffectAllowed;
// the event message this data transfer is for. This will correspond to an
// event->mMessage value.
EventMessage mEventMessage;
// Indicates the behavior of the cursor during drag operations
bool mCursorState;

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

@ -716,12 +716,12 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
switch(aEvent->mMessage) {
case NS_FORM_SELECTED :
case eFormSelect:
if (PopupAllowedForEvent("select")) {
abuse = openControlled;
}
break;
case NS_FORM_CHANGE :
case eFormChange:
if (PopupAllowedForEvent("change")) {
abuse = openControlled;
}
@ -753,7 +753,7 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
switch(aEvent->mMessage) {
case NS_FORM_CHANGE :
case eFormChange:
if (PopupAllowedForEvent("change")) {
abuse = openControlled;
}
@ -853,12 +853,12 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent)
// nsPresShell::HandleEventInternal() for details.
if (EventStateManager::IsHandlingUserInput()) {
switch(aEvent->mMessage) {
case NS_FORM_SUBMIT :
case eFormSubmit:
if (PopupAllowedForEvent("submit")) {
abuse = openControlled;
}
break;
case NS_FORM_RESET :
case eFormReset:
if (PopupAllowedForEvent("reset")) {
abuse = openControlled;
}

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

@ -1339,8 +1339,8 @@ EventListenerManager::HasUnloadListeners()
uint32_t count = mListeners.Length();
for (uint32_t i = 0; i < count; ++i) {
Listener* listener = &mListeners.ElementAt(i);
if (listener->mEventMessage == NS_PAGE_UNLOAD ||
listener->mEventMessage == NS_BEFORE_PAGE_UNLOAD) {
if (listener->mEventMessage == eUnload ||
listener->mEventMessage == eBeforeUnload) {
return true;
}
}

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

@ -149,7 +149,7 @@
#endif /* BEFOREUNLOAD_EVENT */
EVENT(abort,
NS_IMAGE_ABORT,
eImageAbort,
EventNameType_All,
eBasicEventClass)
EVENT(canplay,
@ -161,7 +161,7 @@ EVENT(canplaythrough,
EventNameType_HTML,
eBasicEventClass)
EVENT(change,
NS_FORM_CHANGE,
eFormChange,
EventNameType_HTMLXUL,
eBasicEventClass)
EVENT(click,
@ -179,31 +179,31 @@ EVENT(dblclick,
EventNameType_HTMLXUL,
eMouseEventClass)
EVENT(drag,
NS_DRAGDROP_DRAG,
eDrag,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(dragend,
NS_DRAGDROP_END,
eDragEnd,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(dragenter,
NS_DRAGDROP_ENTER,
eDragEnter,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(dragleave,
NS_DRAGDROP_LEAVE,
eDragLeave,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(dragover,
NS_DRAGDROP_OVER,
eDragOver,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(dragstart,
NS_DRAGDROP_START,
eDragStart,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(drop,
NS_DRAGDROP_DROP,
eDrop,
EventNameType_HTMLXUL,
eDragEventClass)
EVENT(durationchange,
@ -223,7 +223,7 @@ EVENT(input,
EventNameType_HTMLXUL,
eEditorInputEventClass)
EVENT(invalid,
NS_FORM_INVALID,
eFormInvalid,
EventNameType_HTMLXUL,
eBasicEventClass)
EVENT(keydown,
@ -374,7 +374,7 @@ EVENT(ratechange,
EventNameType_HTML,
eBasicEventClass)
EVENT(reset,
NS_FORM_RESET,
eFormReset,
EventNameType_HTMLXUL,
eBasicEventClass)
EVENT(seeked,
@ -386,7 +386,7 @@ EVENT(seeking,
EventNameType_HTML,
eBasicEventClass)
EVENT(select,
NS_FORM_SELECTED,
eFormSelect,
EventNameType_HTMLXUL,
eBasicEventClass)
EVENT(show,
@ -398,7 +398,7 @@ EVENT(stalled,
EventNameType_HTML,
eBasicEventClass)
EVENT(submit,
NS_FORM_SUBMIT,
eFormSubmit,
EventNameType_HTMLXUL,
eBasicEventClass)
EVENT(suspend,
@ -444,19 +444,19 @@ EVENT(afterscriptexecute,
eBasicEventClass)
FORWARDED_EVENT(blur,
NS_BLUR_CONTENT,
eBlur,
EventNameType_HTMLXUL,
eFocusEventClass)
ERROR_EVENT(error,
NS_LOAD_ERROR,
eLoadError,
EventNameType_All,
eBasicEventClass)
FORWARDED_EVENT(focus,
NS_FOCUS_CONTENT,
eFocus,
EventNameType_HTMLXUL,
eFocusEventClass)
FORWARDED_EVENT(load,
NS_LOAD,
eLoad,
EventNameType_All,
eBasicEventClass)
FORWARDED_EVENT(resize,
@ -477,11 +477,11 @@ WINDOW_EVENT(beforeprint,
EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly,
eBasicEventClass)
BEFOREUNLOAD_EVENT(beforeunload,
NS_BEFORE_PAGE_UNLOAD,
eBeforeUnload,
EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly,
eBasicEventClass)
WINDOW_EVENT(hashchange,
NS_HASHCHANGE,
eHashChange,
EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly,
eBasicEventClass)
WINDOW_EVENT(languagechange,
@ -512,7 +512,7 @@ WINDOW_EVENT(pageshow,
EventNameType_HTMLBodyOrFramesetOnly,
eBasicEventClass)
WINDOW_EVENT(popstate,
NS_POPSTATE,
ePopState,
EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly,
eBasicEventClass)
// Not supported yet
@ -522,7 +522,7 @@ WINDOW_EVENT(popstate,
// Not supported yet
// WINDOW_EVENT(undo)
WINDOW_EVENT(unload,
NS_PAGE_UNLOAD,
eUnload,
(EventNameType_XUL | EventNameType_SVGSVG |
EventNameType_HTMLBodyOrFramesetOnly),
eBasicEventClass)
@ -581,7 +581,7 @@ TOUCH_EVENT(touchcancel,
eTouchEventClass)
DOCUMENT_ONLY_EVENT(readystatechange,
NS_READYSTATECHANGE,
eReadyStateChange,
EventNameType_HTMLXUL,
eBasicEventClass)
@ -620,15 +620,15 @@ NON_IDL_EVENT(DOMSubtreeModified,
eMutationEventClass)
NON_IDL_EVENT(DOMActivate,
NS_UI_ACTIVATE,
eLegacyDOMActivate,
EventNameType_HTMLXUL,
eUIEventClass)
NON_IDL_EVENT(DOMFocusIn,
NS_UI_FOCUSIN,
eLegacyDOMFocusIn,
EventNameType_HTMLXUL,
eUIEventClass)
NON_IDL_EVENT(DOMFocusOut,
NS_UI_FOCUSOUT,
eLegacyDOMFocusOut,
EventNameType_HTMLXUL,
eUIEventClass)
@ -720,15 +720,15 @@ NON_IDL_EVENT(commandupdate,
EventNameType_XUL,
eBasicEventClass)
NON_IDL_EVENT(dragexit,
NS_DRAGDROP_EXIT,
eDragExit,
EventNameType_XUL,
eDragEventClass)
NON_IDL_EVENT(dragdrop,
NS_DRAGDROP_DRAGDROP,
eLegacyDragDrop,
EventNameType_XUL,
eDragEventClass)
NON_IDL_EVENT(draggesture,
NS_DRAGDROP_GESTURE,
eLegacyDragGesture,
EventNameType_XUL,
eDragEventClass)
NON_IDL_EVENT(overflow,

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

@ -646,16 +646,16 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext,
FlushPendingEvents(aPresContext);
break;
}
case NS_DRAGDROP_GESTURE:
case eLegacyDragGesture:
if (Prefs::ClickHoldContextMenu()) {
// an external drag gesture event came in, not generated internally
// by Gecko. Make sure we get rid of the click-hold timer.
KillClickHoldTimer();
}
break;
case NS_DRAGDROP_OVER:
// NS_DRAGDROP_DROP is fired before NS_DRAGDROP_DRAGDROP so send
// the enter/exit events before NS_DRAGDROP_DROP.
case eDragOver:
// eDrop is fired before eLegacyDragDrop so send the enter/exit events
// before eDrop.
GenerateDragDropEnterExit(aPresContext, aEvent->AsDragEvent());
break;
@ -1193,9 +1193,9 @@ CrossProcessSafeEvent(const WidgetEvent& aEvent)
}
case eDragEventClass:
switch (aEvent.mMessage) {
case NS_DRAGDROP_OVER:
case NS_DRAGDROP_EXIT:
case NS_DRAGDROP_DROP:
case eDragOver:
case eDragExit:
case eDrop:
return true;
default:
break;
@ -1637,7 +1637,7 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
return;
nsRefPtr<DataTransfer> dataTransfer =
new DataTransfer(window, NS_DRAGDROP_START, false, -1);
new DataTransfer(window, eDragStart, false, -1);
nsCOMPtr<nsISelection> selection;
nsCOMPtr<nsIContent> eventContent, targetContent;
@ -1663,11 +1663,11 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
// get the widget from the target frame
WidgetDragEvent startEvent(aEvent->mFlags.mIsTrusted,
NS_DRAGDROP_START, widget);
eDragStart, widget);
FillInEventFromGestureDown(&startEvent);
WidgetDragEvent gestureEvent(aEvent->mFlags.mIsTrusted,
NS_DRAGDROP_GESTURE, widget);
eLegacyDragGesture, widget);
FillInEventFromGestureDown(&gestureEvent);
startEvent.dataTransfer = gestureEvent.dataTransfer = dataTransfer;
@ -1726,7 +1726,7 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
}
}
// Note that frame event handling doesn't care about NS_DRAGDROP_GESTURE,
// Note that frame event handling doesn't care about eLegacyDragGesture,
// which is just as well since we don't really know which frame to
// send it to
@ -3171,8 +3171,8 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
break;
case NS_DRAGDROP_ENTER:
case NS_DRAGDROP_OVER:
case eDragEnter:
case eDragOver:
{
NS_ASSERTION(aEvent->mClass == eDragEventClass, "Expected a drag event");
@ -3261,13 +3261,13 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// For now, do this only for dragover.
//XXXsmaug dragenter needs some more work.
if (aEvent->mMessage == NS_DRAGDROP_OVER && !isChromeDoc) {
if (aEvent->mMessage == eDragOver && !isChromeDoc) {
// Someone has called preventDefault(), check whether is was on
// content or chrome.
dragSession->SetOnlyChromeDrop(
!dragEvent->mDefaultPreventedOnContent);
}
} else if (aEvent->mMessage == NS_DRAGDROP_OVER && !isChromeDoc) {
} else if (aEvent->mMessage == eDragOver && !isChromeDoc) {
// No one called preventDefault(), so handle drop only in chrome.
dragSession->SetOnlyChromeDrop(true);
}
@ -3286,7 +3286,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
break;
case NS_DRAGDROP_DROP:
case eDrop:
{
// now fire the dragdrop event, for compatibility with XUL
if (mCurrentTarget && nsEventStatus_eConsumeNoDefault != *aStatus) {
@ -3296,7 +3296,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsCOMPtr<nsIWidget> widget = mCurrentTarget->GetNearestWidget();
WidgetDragEvent event(aEvent->mFlags.mIsTrusted,
NS_DRAGDROP_DRAGDROP, widget);
eLegacyDragDrop, widget);
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
event.refPoint = mouseEvent->refPoint;
@ -3319,9 +3319,9 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
ClearGlobalActiveContent(this);
break;
}
case NS_DRAGDROP_EXIT:
case eDragExit:
// make sure to fire the enter and exit_synth events after the
// NS_DRAGDROP_EXIT event, otherwise we'll clean up too early
// eDragExit event, otherwise we'll clean up too early
GenerateDragDropEnterExit(presContext, aEvent->AsDragEvent());
break;
@ -4299,7 +4299,7 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
nsCOMPtr<nsIContent> targetBeforeEvent = mCurrentTargetContent;
switch(aDragEvent->mMessage) {
case NS_DRAGDROP_OVER:
case eDragOver:
{
// when dragging from one frame to another, events are fired in the
// order: dragexit, dragenter, dragleave
@ -4316,16 +4316,16 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
getter_AddRefs(lastContent));
FireDragEnterOrExit(sLastDragOverFrame->PresContext(),
aDragEvent, NS_DRAGDROP_EXIT,
aDragEvent, eDragExit,
targetContent, lastContent, sLastDragOverFrame);
}
FireDragEnterOrExit(aPresContext, aDragEvent, NS_DRAGDROP_ENTER,
FireDragEnterOrExit(aPresContext, aDragEvent, eDragEnter,
lastContent, targetContent, mCurrentTarget);
if (sLastDragOverFrame) {
FireDragEnterOrExit(sLastDragOverFrame->PresContext(),
aDragEvent, NS_DRAGDROP_LEAVE,
aDragEvent, eDragLeave,
targetContent, lastContent, sLastDragOverFrame);
}
@ -4334,7 +4334,7 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
}
break;
case NS_DRAGDROP_EXIT:
case eDragExit:
{
//This is actually the window mouse exit event.
if (sLastDragOverFrame) {
@ -4344,10 +4344,10 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext,
nsRefPtr<nsPresContext> lastDragOverFramePresContext = sLastDragOverFrame->PresContext();
FireDragEnterOrExit(lastDragOverFramePresContext,
aDragEvent, NS_DRAGDROP_EXIT,
aDragEvent, eDragExit,
nullptr, lastContent, sLastDragOverFrame);
FireDragEnterOrExit(lastDragOverFramePresContext,
aDragEvent, NS_DRAGDROP_LEAVE,
aDragEvent, eDragLeave,
nullptr, lastContent, sLastDragOverFrame);
sLastDragOverFrame = nullptr;
@ -4393,17 +4393,15 @@ EventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext,
}
// adjust the drag hover if the dragenter event was cancelled or this is a drag exit
if (status == nsEventStatus_eConsumeNoDefault ||
aMessage == NS_DRAGDROP_EXIT) {
SetContentState((aMessage == NS_DRAGDROP_ENTER) ?
aTargetContent : nullptr,
if (status == nsEventStatus_eConsumeNoDefault || aMessage == eDragExit) {
SetContentState((aMessage == eDragEnter) ? aTargetContent : nullptr,
NS_EVENT_STATE_DRAGOVER);
}
// collect any changes to moz cursor settings stored in the event's
// data transfer.
if (aMessage == NS_DRAGDROP_LEAVE || aMessage == NS_DRAGDROP_EXIT ||
aMessage == NS_DRAGDROP_ENTER) {
if (aMessage == eDragLeave || aMessage == eDragExit ||
aMessage == eDragEnter) {
UpdateDragDataTransfer(&event);
}
}
@ -4610,8 +4608,7 @@ already_AddRefed<nsIContent>
EventStateManager::GetEventTargetContent(WidgetEvent* aEvent)
{
if (aEvent &&
(aEvent->mMessage == NS_FOCUS_CONTENT ||
aEvent->mMessage == NS_BLUR_CONTENT)) {
(aEvent->mMessage == eFocus || aEvent->mMessage == eBlur)) {
nsCOMPtr<nsIContent> content = GetFocusedContent();
return content.forget();
}

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

@ -17,7 +17,7 @@ FocusEvent::FocusEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalFocusEvent* aEvent)
: UIEvent(aOwner, aPresContext,
aEvent ? aEvent : new InternalFocusEvent(false, NS_FOCUS_CONTENT))
aEvent ? aEvent : new InternalFocusEvent(false, eFocus))
{
if (aEvent) {
mEventIsInternal = false;

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

@ -185,7 +185,7 @@ WheelTransaction::OnEvent(WidgetEvent* aEvent)
}
return;
case eMouseMove:
case NS_DRAGDROP_OVER: {
case eDragOver: {
WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
if (mouseEvent->IsReal()) {
// If the cursor is moving to be outside the frame,
@ -215,7 +215,7 @@ WheelTransaction::OnEvent(WidgetEvent* aEvent)
case eMouseDoubleClick:
case eMouseClick:
case eContextMenu:
case NS_DRAGDROP_DROP:
case eDrop:
EndTransaction();
return;
default:

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

@ -222,7 +222,7 @@ HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
bool outerActivateEvent =
((mouseEvent && mouseEvent->IsLeftClickEvent()) ||
(aVisitor.mEvent->mMessage == NS_UI_ACTIVATE &&
(aVisitor.mEvent->mMessage == eLegacyDOMActivate &&
!mInInternalActivate));
if (outerActivateEvent) {
@ -252,7 +252,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
if (mouseEvent && mouseEvent->IsLeftClickEvent()) {
// DOMActive event should be trusted since the activation is actually
// occurred even if the cause is an untrusted click event.
InternalUIEvent actEvent(true, NS_UI_ACTIVATE, mouseEvent);
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
actEvent.detail = 1;
nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
@ -370,7 +370,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
if (mForm && (mType == NS_FORM_BUTTON_SUBMIT ||
mType == NS_FORM_BUTTON_RESET)) {
InternalFormEvent event(true,
(mType == NS_FORM_BUTTON_RESET) ? NS_FORM_RESET : NS_FORM_SUBMIT);
(mType == NS_FORM_BUTTON_RESET) ? eFormReset : eFormSubmit);
event.originator = this;
nsEventStatus status = nsEventStatus_eIgnore;
@ -382,7 +382,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
//
// Using presShell to dispatch the event. It makes sure that
// event is not handled if the window is being destroyed.
if (presShell && (event.mMessage != NS_FORM_SUBMIT ||
if (presShell && (event.mMessage != eFormSubmit ||
mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate) ||
// We know the element is a submit control, if this check is moved,
// make sure formnovalidate is used only if it's a submit control.

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

@ -256,7 +256,7 @@ HTMLFormElement::Submit(ErrorResult& aRv)
mPendingSubmission = nullptr;
}
aRv = DoSubmitOrReset(nullptr, NS_FORM_SUBMIT);
aRv = DoSubmitOrReset(nullptr, eFormSubmit);
}
NS_IMETHODIMP
@ -270,7 +270,7 @@ HTMLFormElement::Submit()
NS_IMETHODIMP
HTMLFormElement::Reset()
{
InternalFormEvent event(true, NS_FORM_RESET);
InternalFormEvent event(true, eFormReset);
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), nullptr, &event);
return NS_OK;
}
@ -493,7 +493,7 @@ HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
aVisitor.mWantsWillHandleEvent = true;
if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
uint32_t msg = aVisitor.mEvent->mMessage;
if (msg == NS_FORM_SUBMIT) {
if (msg == eFormSubmit) {
if (mGeneratingSubmit) {
aVisitor.mCanHandle = false;
return NS_OK;
@ -504,8 +504,7 @@ HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
// that means that if there are scripted submissions, the
// latest one will be deferred until after the exit point of the handler.
mDeferSubmission = true;
}
else if (msg == NS_FORM_RESET) {
} else if (msg == eFormReset) {
if (mGeneratingReset) {
aVisitor.mCanHandle = false;
return NS_OK;
@ -522,8 +521,8 @@ HTMLFormElement::WillHandleEvent(EventChainPostVisitor& aVisitor)
// If this is the bubble stage and there is a nested form below us which
// received a submit event we do *not* want to handle the submit event
// for this form too.
if ((aVisitor.mEvent->mMessage == NS_FORM_SUBMIT ||
aVisitor.mEvent->mMessage == NS_FORM_RESET) &&
if ((aVisitor.mEvent->mMessage == eFormSubmit ||
aVisitor.mEvent->mMessage == eFormReset) &&
aVisitor.mEvent->mFlags.mInBubblingPhase &&
aVisitor.mEvent->originalTarget != static_cast<nsIContent*>(this)) {
aVisitor.mEvent->mFlags.mPropagationStopped = true;
@ -536,17 +535,16 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->originalTarget == static_cast<nsIContent*>(this)) {
EventMessage msg = aVisitor.mEvent->mMessage;
if (msg == NS_FORM_SUBMIT) {
if (msg == eFormSubmit) {
// let the form know not to defer subsequent submissions
mDeferSubmission = false;
}
if (aVisitor.mEventStatus == nsEventStatus_eIgnore) {
switch (msg) {
case NS_FORM_RESET:
case NS_FORM_SUBMIT:
{
if (mPendingSubmission && msg == NS_FORM_SUBMIT) {
case eFormReset:
case eFormSubmit: {
if (mPendingSubmission && msg == eFormSubmit) {
// tell the form to forget a possible pending submission.
// the reason is that the script returned true (the event was
// ignored) so if there is a stored submission, it will miss
@ -561,7 +559,7 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
break;
}
} else {
if (msg == NS_FORM_SUBMIT) {
if (msg == eFormSubmit) {
// tell the form to flush a possible pending submission.
// the reason is that the script returned false (the event was
// not ignored) so if there is a stored submission, it needs to
@ -570,10 +568,9 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
}
}
if (msg == NS_FORM_SUBMIT) {
if (msg == eFormSubmit) {
mGeneratingSubmit = false;
}
else if (msg == NS_FORM_RESET) {
} else if (msg == eFormReset) {
mGeneratingReset = false;
}
}
@ -582,7 +579,7 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
nsresult
HTMLFormElement::DoSubmitOrReset(WidgetEvent* aEvent,
int32_t aMessage)
EventMessage aMessage)
{
// Make sure the presentation is up-to-date
nsIDocument* doc = GetComposedDoc();
@ -593,11 +590,11 @@ HTMLFormElement::DoSubmitOrReset(WidgetEvent* aEvent,
// JBK Don't get form frames anymore - bug 34297
// Submit or Reset the form
if (NS_FORM_RESET == aMessage) {
if (eFormReset == aMessage) {
return DoReset();
}
if (NS_FORM_SUBMIT == aMessage) {
if (eFormSubmit == aMessage) {
// Don't submit if we're not in a document or if we're in
// a sandboxed frame and form submit is disabled.
if (!doc || (doc->GetSandboxFlags() & SANDBOXED_FORMS)) {

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

@ -452,7 +452,7 @@ protected:
};
nsresult DoSubmitOrReset(WidgetEvent* aEvent,
int32_t aMessage);
EventMessage aMessage);
nsresult DoReset();
// Async callback to handle removal of our default submit

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

@ -2817,7 +2817,7 @@ HTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext)
// If there's only one text control, just submit the form
// Hold strong ref across the event
nsRefPtr<mozilla::dom::HTMLFormElement> form = mForm;
InternalFormEvent event(true, NS_FORM_SUBMIT);
InternalFormEvent event(true, eFormSubmit);
nsEventStatus status = nsEventStatus_eIgnore;
shell->HandleDOMEventWithTarget(mForm, &event, &status);
}
@ -2987,7 +2987,7 @@ HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext)
// If already handling select event, don't dispatch a second.
if (!mHandlingSelectEvent) {
WidgetEvent event(nsContentUtils::IsCallerChrome(), NS_FORM_SELECTED);
WidgetEvent event(nsContentUtils::IsCallerChrome(), eFormSelect);
mHandlingSelectEvent = true;
EventDispatcher::Dispatch(static_cast<nsIContent*>(this),
@ -3087,7 +3087,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
bool outerActivateEvent =
((mouseEvent && mouseEvent->IsLeftClickEvent()) ||
(aVisitor.mEvent->mMessage == NS_UI_ACTIVATE && !mInInternalActivate));
(aVisitor.mEvent->mMessage == eLegacyDOMActivate && !mInInternalActivate));
if (outerActivateEvent) {
aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT;
@ -3162,7 +3162,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
aVisitor.mItemFlags |= mType;
// Fire onchange (if necessary), before we do the blur, bug 357684.
if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->mMessage == eBlur) {
// Experimental mobile types rely on the system UI to prevent users to not
// set invalid values but we have to be extra-careful. Especially if the
// option has been enabled on desktop.
@ -3177,8 +3177,8 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
}
if (mType == NS_FORM_INPUT_RANGE &&
(aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT ||
aVisitor.mEvent->mMessage == NS_BLUR_CONTENT)) {
(aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eBlur)) {
// Just as nsGenericHTMLFormElementWithState::PreHandleEvent calls
// nsIFormControlFrame::SetFocus, we handle focus here.
nsIFrame* frame = GetPrimaryFrame();
@ -3231,9 +3231,9 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
StopNumberControlSpinnerSpin();
}
}
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT ||
aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT) {
if (aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eBlur) {
if (aVisitor.mEvent->mMessage == eFocus) {
// Tell our frame it's getting focus so that it can make sure focus
// is moved to our anonymous text control.
nsNumberControlFrame* numberControlFrame =
@ -3299,7 +3299,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
numberControlFrame->HandlingInputEvent(false);
}
}
else if (aVisitor.mEvent->mMessage == NS_FORM_CHANGE) {
else if (aVisitor.mEvent->mMessage == eFormChange) {
// We cancel the DOM 'change' event that is fired for any change to our
// anonymous text control since we fire our own 'change' events and
// content shouldn't be seeing two 'change' events. Besides that we
@ -3587,15 +3587,15 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
return MaybeInitPickers(aVisitor);
}
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT ||
aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT &&
if (aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eBlur) {
if (aVisitor.mEvent->mMessage == eFocus &&
MayFireChangeOnBlur() &&
!mIsDraggingRange) { // StartRangeThumbDrag already set mFocusedValue
GetValue(mFocusedValue);
}
if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->mMessage == eBlur) {
if (mIsDraggingRange) {
FinishRangeThumbDrag();
} else if (mNumberControlSpinnerIsSpinning) {
@ -3603,7 +3603,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
}
}
UpdateValidityUIBits(aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT);
UpdateValidityUIBits(aVisitor.mEvent->mMessage == eFocus);
UpdateState(true);
}
@ -3630,7 +3630,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
!ShouldPreventDOMActivateDispatch(aVisitor.mEvent->originalTarget)) {
// DOMActive event should be trusted since the activation is actually
// occurred even if the cause is an untrusted click event.
InternalUIEvent actEvent(true, NS_UI_ACTIVATE, mouseEvent);
InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent);
actEvent.detail = 1;
nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
@ -3745,9 +3745,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
}
} else if (nsEventStatus_eIgnore == aVisitor.mEventStatus) {
switch (aVisitor.mEvent->mMessage) {
case NS_FOCUS_CONTENT:
{
case eFocus: {
// see if we should select the contents of the textbox. This happens
// for text and password fields when the field was focused by the
// keyboard or a navigation, the platform allows it, and it wasn't
@ -4015,7 +4013,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
case NS_FORM_INPUT_IMAGE:
if (mForm) {
InternalFormEvent event(true,
(mType == NS_FORM_INPUT_RESET) ? NS_FORM_RESET : NS_FORM_SUBMIT);
(mType == NS_FORM_INPUT_RESET) ? eFormReset : eFormSubmit);
event.originator = this;
nsEventStatus status = nsEventStatus_eIgnore;
@ -4027,7 +4025,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
// pres shell. See bug 125624.
// TODO: removing this code and have the submit event sent by the
// form, see bug 592124.
if (presShell && (event.mMessage != NS_FORM_SUBMIT ||
if (presShell && (event.mMessage != eFormSubmit ||
mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate) ||
// We know the element is a submit control, if this check is moved,
// make sure formnovalidate is used only if it's a submit control.

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

@ -216,11 +216,11 @@ HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement,
return;
}
switch (aEvent->mMessage) {
case NS_FOCUS_CONTENT: {
case eFocus: {
OnFocusBlurPlugin(aElement, true);
break;
}
case NS_BLUR_CONTENT: {
case eBlur: {
OnFocusBlurPlugin(aElement, false);
break;
}
@ -292,7 +292,7 @@ HTMLObjectElement::UnbindFromTree(bool aDeep,
{
#ifdef XP_MACOSX
// When a page is reloaded (when an nsIDocument's content is removed), the
// focused element isn't necessarily sent an NS_BLUR_CONTENT event. See
// focused element isn't necessarily sent an eBlur event. See
// nsFocusManager::ContentRemoved(). This means that a widget may think it
// still contains a focused plugin when it doesn't -- which in turn can
// disable text input in the browser window. See bug 1137229.

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

@ -1511,7 +1511,7 @@ HTMLSelectElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
nsresult
HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT) {
if (aVisitor.mEvent->mMessage == eFocus) {
// If the invalid UI is shown, we should show it while focused and
// update the invalid/valid UI.
mCanShowInvalidUI = !IsValid() && ShouldShowValidityUI();
@ -1522,7 +1522,7 @@ HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
// We don't have to update NS_EVENT_STATE_MOZ_UI_INVALID nor
// NS_EVENT_STATE_MOZ_UI_VALID given that the states should not change.
} else if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
} else if (aVisitor.mEvent->mMessage == eBlur) {
mCanShowInvalidUI = true;
mCanShowValidUI = true;

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

@ -164,7 +164,7 @@ HTMLSharedObjectElement::UnbindFromTree(bool aDeep,
{
#ifdef XP_MACOSX
// When a page is reloaded (when an nsIDocument's content is removed), the
// focused element isn't necessarily sent an NS_BLUR_CONTENT event. See
// focused element isn't necessarily sent an eBlur event. See
// nsFocusManager::ContentRemoved(). This means that a widget may think it
// still contains a focused plugin when it doesn't -- which in turn can
// disable text input in the browser window. See bug 1137229.

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

@ -137,7 +137,7 @@ HTMLTextAreaElement::Select()
}
nsEventStatus status = nsEventStatus_eIgnore;
WidgetGUIEvent event(true, NS_FORM_SELECTED, nullptr);
WidgetGUIEvent event(true, eFormSelect, nullptr);
// XXXbz HTMLInputElement guards against this reentering; shouldn't we?
EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
&event, nullptr, &status);
@ -486,7 +486,7 @@ HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
// Don't dispatch a second select event if we are already handling
// one.
if (aVisitor.mEvent->mMessage == NS_FORM_SELECTED) {
if (aVisitor.mEvent->mMessage == eFormSelect) {
if (mHandlingSelect) {
return NS_OK;
}
@ -506,7 +506,7 @@ HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
}
// Fire onchange (if necessary), before we do the blur, bug 370521.
if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->mMessage == eBlur) {
FireChangeEventIfNeeded();
}
@ -534,13 +534,13 @@ HTMLTextAreaElement::FireChangeEventIfNeeded()
nsresult
HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
{
if (aVisitor.mEvent->mMessage == NS_FORM_SELECTED) {
if (aVisitor.mEvent->mMessage == eFormSelect) {
mHandlingSelect = false;
}
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT ||
aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) {
if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT) {
if (aVisitor.mEvent->mMessage == eFocus ||
aVisitor.mEvent->mMessage == eBlur) {
if (aVisitor.mEvent->mMessage == eFocus) {
// If the invalid UI is shown, we should show it while focusing (and
// update). Otherwise, we should not.
GetValueInternal(mFocusedValue, true);
@ -549,7 +549,7 @@ HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
// If neither invalid UI nor valid UI is shown, we shouldn't show the valid
// UI while typing.
mCanShowValidUI = ShouldShowValidityUI();
} else { // NS_BLUR_CONTENT
} else { // eBlur
mCanShowInvalidUI = true;
mCanShowValidUI = true;
}

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

@ -2251,8 +2251,7 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
{
if (aVisitor.mEvent->mFlags.mIsTrusted) {
switch (aVisitor.mEvent->mMessage) {
case NS_FOCUS_CONTENT:
{
case eFocus: {
// Check to see if focus has bubbled up from a form control's
// child textfield or button. If that's the case, don't focus
// this parent file control -- leave focus on the child.
@ -2262,8 +2261,7 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor)
formControlFrame->SetFocus(true, true);
break;
}
case NS_BLUR_CONTENT:
{
case eBlur: {
nsIFormControlFrame* formControlFrame = GetFormControlFrame(true);
if (formControlFrame)
formControlFrame->SetFocus(false, false);

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

@ -819,7 +819,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection*
if (presShell)
{
nsEventStatus status = nsEventStatus_eIgnore;
WidgetEvent event(true, NS_FORM_SELECTED);
WidgetEvent event(true, eFormSelect);
presShell->HandleEventWithTarget(&event, mFrame, content, &status);
}

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

@ -187,6 +187,7 @@ class IDBDatabase::LogWarningRunnable final
nsCString mMessageName;
nsString mFilename;
uint32_t mLineNumber;
uint32_t mColumnNumber;
uint64_t mInnerWindowID;
bool mIsChrome;
@ -194,11 +195,13 @@ public:
LogWarningRunnable(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber,
uint32_t aColumnNumber,
bool aIsChrome,
uint64_t aInnerWindowID)
: mMessageName(aMessageName)
, mFilename(aFilename)
, mLineNumber(aLineNumber)
, mColumnNumber(aColumnNumber)
, mInnerWindowID(aInnerWindowID)
, mIsChrome(aIsChrome)
{
@ -209,6 +212,7 @@ public:
LogWarning(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber,
uint32_t aColumnNumber,
bool aIsChrome,
uint64_t aInnerWindowID);
@ -959,10 +963,10 @@ IDBDatabase::AbortTransactions(bool aShouldWarn)
MOZ_ASSERT(transaction);
nsString filename;
uint32_t lineNo;
transaction->GetCallerLocation(filename, &lineNo);
uint32_t lineNo, column;
transaction->GetCallerLocation(filename, &lineNo, &column);
aDatabase->LogWarning(kWarningMessage, filename, lineNo);
aDatabase->LogWarning(kWarningMessage, filename, lineNo, column);
}
}
};
@ -1337,7 +1341,8 @@ IDBDatabase::Invalidate()
void
IDBDatabase::LogWarning(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber)
uint32_t aLineNumber,
uint32_t aColumnNumber)
{
AssertIsOnOwningThread();
MOZ_ASSERT(aMessageName);
@ -1346,6 +1351,7 @@ IDBDatabase::LogWarning(const char* aMessageName,
LogWarningRunnable::LogWarning(aMessageName,
aFilename,
aLineNumber,
aColumnNumber,
mFactory->IsChrome(),
mFactory->InnerWindowID());
} else {
@ -1353,6 +1359,7 @@ IDBDatabase::LogWarning(const char* aMessageName,
new LogWarningRunnable(aMessageName,
aFilename,
aLineNumber,
aColumnNumber,
mFactory->IsChrome(),
mFactory->InnerWindowID());
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(runnable)));
@ -1628,6 +1635,7 @@ IDBDatabase::
LogWarningRunnable::LogWarning(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber,
uint32_t aColumnNumber,
bool aIsChrome,
uint64_t aInnerWindowID)
{
@ -1664,7 +1672,7 @@ LogWarningRunnable::LogWarning(const char* aMessageName,
aFilename,
/* aSourceLine */ EmptyString(),
aLineNumber,
/* aColumnNumber */ 0,
aColumnNumber,
nsIScriptError::warningFlag,
category,
aInnerWindowID)));
@ -1674,7 +1682,7 @@ LogWarningRunnable::LogWarning(const char* aMessageName,
aFilename,
/* aSourceLine */ EmptyString(),
aLineNumber,
/* aColumnNumber */ 0,
aColumnNumber,
nsIScriptError::warningFlag,
category.get())));
}
@ -1693,6 +1701,7 @@ LogWarningRunnable::Run()
LogWarning(mMessageName.get(),
mFilename,
mLineNumber,
mColumnNumber,
mIsChrome,
mInnerWindowID);

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

@ -313,7 +313,8 @@ private:
void
LogWarning(const char* aMessageName,
const nsAString& aFilename,
uint32_t aLineNumber);
uint32_t aLineNumber,
uint32_t aColumnNumber);
};
} // namespace indexedDB

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

@ -92,6 +92,7 @@ IDBRequest::InitMembers()
mLoggingSerialNumber = NextSerialNumber();
mErrorCode = NS_OK;
mLineNo = 0;
mColumn = 0;
mHaveResultOrErrorCode = false;
}
@ -104,7 +105,7 @@ IDBRequest::Create(IDBDatabase* aDatabase,
aDatabase->AssertIsOnOwningThread();
nsRefPtr<IDBRequest> request = new IDBRequest(aDatabase);
CaptureCaller(request->mFilename, &request->mLineNo);
CaptureCaller(request->mFilename, &request->mLineNo, &request->mColumn);
request->mTransaction = aTransaction;
request->SetScriptOwner(aDatabase->GetScriptOwner());
@ -168,13 +169,15 @@ IDBRequest::SetLoggingSerialNumber(uint64_t aLoggingSerialNumber)
}
void
IDBRequest::CaptureCaller(nsAString& aFilename, uint32_t* aLineNo)
IDBRequest::CaptureCaller(nsAString& aFilename, uint32_t* aLineNo,
uint32_t* aColumn)
{
MOZ_ASSERT(aFilename.IsEmpty());
MOZ_ASSERT(aLineNo);
MOZ_ASSERT(aColumn);
ThreadsafeAutoJSContext cx;
nsJSUtils::GetCallingLocation(cx, aFilename, aLineNo);
nsJSUtils::GetCallingLocation(cx, aFilename, aLineNo, aColumn);
}
void
@ -271,13 +274,16 @@ IDBRequest::GetErrorAfterResult() const
#endif // DEBUG
void
IDBRequest::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const
IDBRequest::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
uint32_t* aColumn) const
{
AssertIsOnOwningThread();
MOZ_ASSERT(aLineNo);
MOZ_ASSERT(aColumn);
aFilename = mFilename;
*aLineNo = mLineNo;
*aColumn = mColumn;
}
IDBRequestReadyState
@ -516,7 +522,7 @@ IDBOpenDBRequest::CreateForWindow(IDBFactory* aFactory,
MOZ_ASSERT(aScriptOwner);
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, aOwner);
CaptureCaller(request->mFilename, &request->mLineNo);
CaptureCaller(request->mFilename, &request->mLineNo, &request->mColumn);
request->SetScriptOwner(aScriptOwner);
@ -533,7 +539,7 @@ IDBOpenDBRequest::CreateForJS(IDBFactory* aFactory,
MOZ_ASSERT(aScriptOwner);
nsRefPtr<IDBOpenDBRequest> request = new IDBOpenDBRequest(aFactory, nullptr);
CaptureCaller(request->mFilename, &request->mLineNo);
CaptureCaller(request->mFilename, &request->mLineNo, &request->mColumn);
request->SetScriptOwner(aScriptOwner);

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

@ -63,6 +63,7 @@ protected:
uint64_t mLoggingSerialNumber;
nsresult mErrorCode;
uint32_t mLineNo;
uint32_t mColumn;
bool mHaveResultOrErrorCode;
public:
@ -82,7 +83,7 @@ public:
IDBTransaction* aTransaction);
static void
CaptureCaller(nsAString& aFilename, uint32_t* aLineNo);
CaptureCaller(nsAString& aFilename, uint32_t* aLineNo, uint32_t* aColumn);
static uint64_t
NextSerialNumber();
@ -130,7 +131,8 @@ public:
GetError(ErrorResult& aRv);
void
GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const;
GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
uint32_t* aColumn) const;
bool
IsPending() const

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

@ -82,6 +82,7 @@ IDBTransaction::IDBTransaction(IDBDatabase* aDatabase,
, mAbortCode(NS_OK)
, mPendingRequestCount(0)
, mLineNo(0)
, mColumn(0)
, mReadyState(IDBTransaction::INITIAL)
, mMode(aMode)
, mCreating(false)
@ -186,7 +187,7 @@ IDBTransaction::CreateVersionChange(
emptyObjectStoreNames,
VERSION_CHANGE);
aOpenRequest->GetCallerLocation(transaction->mFilename,
&transaction->mLineNo);
&transaction->mLineNo, &transaction->mColumn);
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
@ -219,7 +220,8 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
nsRefPtr<IDBTransaction> transaction =
new IDBTransaction(aDatabase, aObjectStoreNames, aMode);
IDBRequest::CaptureCaller(transaction->mFilename, &transaction->mLineNo);
IDBRequest::CaptureCaller(transaction->mFilename, &transaction->mLineNo,
&transaction->mColumn);
transaction->SetScriptOwner(aDatabase->GetScriptOwner());
@ -492,13 +494,16 @@ IDBTransaction::IsOpen() const
}
void
IDBTransaction::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const
IDBTransaction::GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
uint32_t* aColumn) const
{
AssertIsOnOwningThread();
MOZ_ASSERT(aLineNo);
MOZ_ASSERT(aColumn);
aFilename = mFilename;
*aLineNo = mLineNo;
*aColumn = mColumn;
}
already_AddRefed<IDBObjectStore>

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

@ -100,6 +100,7 @@ private:
nsString mFilename;
uint32_t mLineNo;
uint32_t mColumn;
ReadyState mReadyState;
Mode mMode;
@ -205,7 +206,8 @@ public:
}
void
GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo) const;
GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
uint32_t* aColumn) const;
// 'Get' prefix is to avoid name collisions with the enum
Mode

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

@ -480,7 +480,7 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor,
ThreadsafeAutoJSContext cx;
RootedDictionary<ErrorEventInit> init(cx);
request->GetCallerLocation(init.mFilename, &init.mLineno);
request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno);
init.mMessage = errorName;
init.mCancelable = true;
@ -556,7 +556,7 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor,
init.mFilename,
/* aSourceLine */ EmptyString(),
init.mLineno,
/* aColumnNumber */ 0,
init.mColno,
nsIScriptError::errorFlag,
category,
innerWindowID)));
@ -566,7 +566,7 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor,
init.mFilename,
/* aSourceLine */ EmptyString(),
init.mLineno,
/* aColumnNumber */ 0,
init.mColno,
nsIScriptError::errorFlag,
category.get())));
}

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

@ -49,7 +49,7 @@ interface nsIJSRAIIHelper;
interface nsIContentPermissionRequest;
interface nsIObserver;
[scriptable, uuid(6ddc9a79-18cd-4dbc-9975-68928e6c9857)]
[scriptable, uuid(a30a95ac-3b95-4251-88dc-8efa89ba9f9c)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -106,15 +106,6 @@ interface nsIDOMWindowUtils : nsISupports {
*/
void updateLayerTree();
/**
* Set the CSS viewport to be |widthPx| x |heightPx| in units of CSS
* pixels, regardless of the size of the enclosing widget/view.
* This will trigger reflow.
*
* The caller of this method must have chrome privileges.
*/
void setCSSViewport(in float aWidthPx, in float aHeightPx);
/**
* Information retrieved from the <meta name="viewport"> tag.
* See nsContentUtils::GetViewportInfo for more information.

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

@ -12,7 +12,6 @@
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include "nsIObserverService.h"
using namespace mozilla::ipc;
using namespace mozilla::jsipc;
@ -21,8 +20,7 @@ namespace mozilla {
namespace dom {
NS_IMPL_ISUPPORTS(ContentBridgeChild,
nsIContentChild,
nsIObserver)
nsIContentChild)
ContentBridgeChild::ContentBridgeChild(Transport* aTransport)
: mTransport(aTransport)
@ -36,10 +34,6 @@ ContentBridgeChild::~ContentBridgeChild()
void
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
{
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
os->RemoveObserver(this, "content-child-shutdown");
}
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
@ -55,11 +49,6 @@ ContentBridgeChild::Create(Transport* aTransport, ProcessId aOtherPid)
DebugOnly<bool> ok = bridge->Open(aTransport, aOtherPid, XRE_GetIOMessageLoop());
MOZ_ASSERT(ok);
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os) {
os->AddObserver(bridge, "content-child-shutdown", false);
}
return bridge;
}
@ -180,16 +169,5 @@ ContentBridgeChild::DeallocPBlobChild(PBlobChild* aActor)
return nsIContentChild::DeallocPBlobChild(aActor);
}
NS_IMETHODIMP
ContentBridgeChild::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
if (!strcmp(aTopic, "content-child-shutdown")) {
Close();
}
return NS_OK;
}
} // namespace dom
} // namespace mozilla

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

@ -9,20 +9,17 @@
#include "mozilla/dom/PContentBridgeChild.h"
#include "mozilla/dom/nsIContentChild.h"
#include "nsIObserver.h"
namespace mozilla {
namespace dom {
class ContentBridgeChild final : public PContentBridgeChild
, public nsIContentChild
, public nsIObserver
{
public:
explicit ContentBridgeChild(Transport* aTransport);
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
static ContentBridgeChild*
Create(Transport* aTransport, ProcessId aOtherProcess);

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

@ -163,6 +163,17 @@ ContentBridgeParent::DeallocPBrowserParent(PBrowserParent* aParent)
return nsIContentParent::DeallocPBrowserParent(aParent);
}
void
ContentBridgeParent::NotifyTabDestroyed()
{
int32_t numLiveTabs = ManagedPBrowserParent().Length();
if (numLiveTabs == 1) {
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeParent::Close));
}
}
// This implementation is identical to ContentParent::GetCPOWManager but we can't
// move it to nsIContentParent because it calls ManagedPJavaScriptParent() which
// only exists in PContentParent and PContentBridgeParent.

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

@ -28,6 +28,8 @@ public:
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
void DeferredDestroy();
virtual bool IsContentBridgeParent() override { return true; }
void NotifyTabDestroyed();
static ContentBridgeParent*
Create(Transport* aTransport, ProcessId aOtherProcess);

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

@ -2809,7 +2809,7 @@ ContentChild::RecvInvokeDragSession(nsTArray<IPCDataTransfer>&& aTransfers,
if (session) {
session->SetDragAction(aAction);
nsCOMPtr<DataTransfer> dataTransfer =
new DataTransfer(nullptr, NS_DRAGDROP_START, false, -1);
new DataTransfer(nullptr, eDragStart, false, -1);
for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
auto& items = aTransfers[i].items();
for (uint32_t j = 0; j < items.Length(); ++j) {

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

@ -1468,7 +1468,9 @@ ContentParent::Init()
}
Preferences::AddStrongObserver(this, "");
if (obs) {
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", nullptr);
nsAutoString cpId;
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", cpId.get());
}
#ifdef ACCESSIBILITY
@ -1843,11 +1845,12 @@ ContentParent::OnBeginSyncTransaction() {
if (!sDisableUnsafeCPOWWarnings) {
if (console && cx) {
nsAutoString filename;
uint32_t lineno = 0;
nsJSUtils::GetCallingLocation(cx, filename, &lineno);
uint32_t lineno = 0, column = 0;
nsJSUtils::GetCallingLocation(cx, filename, &lineno, &column);
nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
error->Init(NS_LITERAL_STRING("unsafe CPOW usage"), filename, EmptyString(),
lineno, 0, nsIScriptError::warningFlag, "chrome javascript");
error->Init(NS_LITERAL_STRING("unsafe CPOW usage"), filename,
EmptyString(), lineno, column,
nsIScriptError::warningFlag, "chrome javascript");
console->LogMessage(error);
} else {
NS_WARNING("Unsafe synchronous IPC message");
@ -2057,7 +2060,9 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
}
#endif
}
obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", nullptr);
nsAutoString cpId;
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get());
}
// Remove any and all idle listeners.
@ -2085,10 +2090,35 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
// least until after the current task finishes running.
NS_DispatchToCurrentThread(new DelayedDeleteContentParentTask(this));
// Destroy any processes created by this ContentParent
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
// Release the appId's reference count of any processes
// created by this ContentParent and the frame opened by this ContentParent
// if this ContentParent crashes.
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
nsTArray<ContentParentId> childIDArray =
cpm->GetAllChildProcessById(this->ChildID());
if (why == AbnormalShutdown) {
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
if(permMgr) {
// Release the appId's reference count of its child-processes
for (uint32_t i = 0; i < childIDArray.Length(); i++) {
nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(childIDArray[i]);
for (uint32_t j = 0 ; j < tabCtxs.Length() ; j++) {
if (tabCtxs[j].OwnOrContainingAppId() != nsIScriptSecurityManager::NO_APP_ID) {
permMgr->ReleaseAppId(tabCtxs[j].OwnOrContainingAppId());
}
}
}
// Release the appId's reference count belong to itself
nsTArray<TabContext> tabCtxs = cpm->GetTabContextByContentProcess(mChildID);
for (uint32_t i = 0; i < tabCtxs.Length() ; i++) {
if (tabCtxs[i].OwnOrContainingAppId()!= nsIScriptSecurityManager::NO_APP_ID) {
permMgr->ReleaseAppId(tabCtxs[i].OwnOrContainingAppId());
}
}
}
}
// Destroy any processes created by this ContentParent
for(uint32_t i = 0; i < childIDArray.Length(); i++) {
ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
MessageLoop::current()->PostTask(
@ -2104,23 +2134,33 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
}
void
ContentParent::NotifyTabDestroying(PBrowserParent* aTab)
ContentParent::NotifyTabDestroying(const TabId& aTabId,
const ContentParentId& aCpId)
{
if (XRE_IsParentProcess()) {
// There can be more than one PBrowser for a given app process
// because of popup windows. PBrowsers can also destroy
// concurrently. When all the PBrowsers are destroying, kick off
// another task to ensure the child process *really* shuts down,
// even if the PBrowsers themselves never finish destroying.
int32_t numLiveTabs = ManagedPBrowserParent().Length();
++mNumDestroyingTabs;
if (mNumDestroyingTabs != numLiveTabs) {
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
ContentParent* cp = cpm->GetContentProcessById(aCpId);
if (!cp) {
return;
}
++cp->mNumDestroyingTabs;
nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(aCpId);
if (static_cast<size_t>(cp->mNumDestroyingTabs) != tabIds.Length()) {
return;
}
// We're dying now, so prevent this content process from being
// recycled during its shutdown procedure.
MarkAsDead();
StartForceKillTimer();
cp->MarkAsDead();
cp->StartForceKillTimer();
} else {
ContentChild::GetSingleton()->SendNotifyTabDestroying(aTabId, aCpId);
}
}
void
@ -2142,16 +2182,15 @@ ContentParent::StartForceKillTimer()
}
void
ContentParent::NotifyTabDestroyed(PBrowserParent* aTab,
ContentParent::NotifyTabDestroyed(const TabId& aTabId,
bool aNotifiedDestroying)
{
if (aNotifiedDestroying) {
--mNumDestroyingTabs;
}
TabId id = static_cast<TabParent*>(aTab)->GetTabId();
nsTArray<PContentPermissionRequestParent*> parentArray =
nsContentPermissionUtils::GetContentPermissionRequestParentById(id);
nsContentPermissionUtils::GetContentPermissionRequestParentById(aTabId);
// Need to close undeleted ContentPermissionRequestParents before tab is closed.
for (auto& permissionRequestParent : parentArray) {
@ -2164,7 +2203,9 @@ ContentParent::NotifyTabDestroyed(PBrowserParent* aTab,
// There can be more than one PBrowser for a given app process
// because of popup windows. When the last one closes, shut
// us down.
if (ManagedPBrowserParent().Length() == 1) {
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(this->ChildID());
if (tabIds.Length() == 1) {
// In the case of normal shutdown, send a shutdown message to child to
// allow it to perform shutdown tasks.
MessageLoop::current()->PostTask(
@ -4899,8 +4940,12 @@ ContentParent::AllocateTabId(const TabId& aOpenerTabId,
{
TabId tabId;
if (XRE_IsParentProcess()) {
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
tabId = cpm->AllocateTabId(aOpenerTabId, aContext, aCpId);
// Add appId's reference count in oop case
if (tabId) {
PermissionManagerAddref(aCpId, tabId);
}
}
else {
ContentChild::GetSingleton()->SendAllocateTabId(aOpenerTabId,
@ -4913,14 +4958,27 @@ ContentParent::AllocateTabId(const TabId& aOpenerTabId,
/*static*/ void
ContentParent::DeallocateTabId(const TabId& aTabId,
const ContentParentId& aCpId)
const ContentParentId& aCpId,
bool aMarkedDestroying)
{
if (XRE_IsParentProcess()) {
// Release appId's reference count in oop case
if (aTabId) {
PermissionManagerRelease(aCpId, aTabId);
}
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
ContentParent* cp = cpm->GetContentProcessById(aCpId);
cp->NotifyTabDestroyed(aTabId, aMarkedDestroying);
ContentProcessManager::GetSingleton()->DeallocateTabId(aCpId,
aTabId);
}
else {
ContentChild::GetSingleton()->SendDeallocateTabId(aTabId);
ContentChild::GetSingleton()->SendDeallocateTabId(aTabId,
aCpId,
aMarkedDestroying);
}
}
@ -4938,9 +4996,19 @@ ContentParent::RecvAllocateTabId(const TabId& aOpenerTabId,
}
bool
ContentParent::RecvDeallocateTabId(const TabId& aTabId)
ContentParent::RecvDeallocateTabId(const TabId& aTabId,
const ContentParentId& aCpId,
const bool& aMarkedDestroying)
{
DeallocateTabId(aTabId, this->ChildID());
DeallocateTabId(aTabId, aCpId, aMarkedDestroying);
return true;
}
bool
ContentParent::RecvNotifyTabDestroying(const TabId& aTabId,
const ContentParentId& aCpId)
{
NotifyTabDestroying(aTabId, aCpId);
return true;
}
@ -5044,9 +5112,9 @@ ContentParent::MaybeInvokeDragSession(TabParent* aParent)
session->GetDataTransfer(getter_AddRefs(domTransfer));
nsCOMPtr<DataTransfer> transfer = do_QueryInterface(domTransfer);
if (!transfer) {
// Pass NS_DRAGDROP_DROP to get DataTransfer with external
// Pass eDrop to get DataTransfer with external
// drag formats cached.
transfer = new DataTransfer(nullptr, NS_DRAGDROP_DROP, true, -1);
transfer = new DataTransfer(nullptr, eDrop, true, -1);
session->SetDataTransfer(transfer);
}
// Note, even though this fills the DataTransfer object with
@ -5111,6 +5179,38 @@ ContentParent::DeallocPContentPermissionRequestParent(PContentPermissionRequestP
return true;
}
/* static */ bool
ContentParent::PermissionManagerAddref(const ContentParentId& aCpId,
const TabId& aTabId)
{
MOZ_ASSERT(XRE_IsParentProcess(),
"Call PermissionManagerAddref in content process!");
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
uint32_t appId = cpm->GetAppIdByProcessAndTabId(aCpId, aTabId);
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
if (appId != nsIScriptSecurityManager::NO_APP_ID && permMgr) {
permMgr->AddrefAppId(appId);
return true;
}
return false;
}
/* static */ bool
ContentParent::PermissionManagerRelease(const ContentParentId& aCpId,
const TabId& aTabId)
{
MOZ_ASSERT(XRE_IsParentProcess(),
"Call PermissionManagerRelease in content process!");
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
uint32_t appId = cpm->GetAppIdByProcessAndTabId(aCpId, aTabId);
nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
if (appId != nsIScriptSecurityManager::NO_APP_ID && permMgr) {
permMgr->ReleaseAppId(appId);
return true;
}
return false;
}
bool
ContentParent::RecvGetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration* aConfig)
{

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

@ -212,9 +212,10 @@ public:
virtual bool KillChild() override;
/** Notify that a tab is beginning its destruction sequence. */
void NotifyTabDestroying(PBrowserParent* aTab);
static void NotifyTabDestroying(const TabId& aTabId,
const ContentParentId& aCpId);
/** Notify that a tab was destroyed during normal operation. */
void NotifyTabDestroyed(PBrowserParent* aTab,
void NotifyTabDestroyed(const TabId& aTabId,
bool aNotifiedDestroying);
TestShellParent* CreateTestShell();
@ -227,7 +228,21 @@ public:
const IPCTabContext& aContext,
const ContentParentId& aCpId);
static void
DeallocateTabId(const TabId& aTabId, const ContentParentId& aCpId);
DeallocateTabId(const TabId& aTabId,
const ContentParentId& aCpId,
bool aMarkedDestroying);
/*
* Add the appId's reference count by the given ContentParentId and TabId
*/
static bool
PermissionManagerAddref(const ContentParentId& aCpId, const TabId& aTabId);
/*
* Release the appId's reference count by the given ContentParentId and TabId
*/
static bool
PermissionManagerRelease(const ContentParentId& aCpId, const TabId& aTabId);
static bool
GetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration& aConfig);
@ -356,7 +371,12 @@ public:
const ContentParentId& aCpId,
TabId* aTabId) override;
virtual bool RecvDeallocateTabId(const TabId& aTabId) override;
virtual bool RecvDeallocateTabId(const TabId& aTabId,
const ContentParentId& aCpId,
const bool& aMarkedDestroying) override;
virtual bool RecvNotifyTabDestroying(const TabId& aTabId,
const ContentParentId& aCpId) override;
nsTArray<TabContext> GetManagedTabContext();

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

@ -12,6 +12,7 @@
#include "mozilla/ClearOnShutdown.h"
#include "nsPrintfCString.h"
#include "nsIScriptSecurityManager.h"
// XXX need another bug to move this to a common header.
#ifdef DISABLE_ASSERTS_FOR_FUZZING
@ -334,5 +335,40 @@ ContentProcessManager::GetTopLevelTabParentByProcessAndTabId(const ContentParent
return GetTabParentByProcessAndTabId(currentCpId, currentTabId);
}
nsTArray<TabId>
ContentProcessManager::GetTabParentsByProcessId(const ContentParentId& aChildCpId)
{
MOZ_ASSERT(NS_IsMainThread());
nsTArray<TabId> tabIdList;
auto iter = mContentParentMap.find(aChildCpId);
if (NS_WARN_IF(iter == mContentParentMap.end())) {
ASSERT_UNLESS_FUZZING();
return Move(tabIdList);
}
for (auto remoteFrameIter = iter->second.mRemoteFrames.begin();
remoteFrameIter != iter->second.mRemoteFrames.end();
++remoteFrameIter) {
tabIdList.AppendElement(remoteFrameIter->first);
}
return Move(tabIdList);
}
uint32_t
ContentProcessManager::GetAppIdByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId)
{
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
if (aChildCpId && aChildTabId) {
TabContext tabContext;
if (GetTabContextByProcessAndTabId(aChildCpId, aChildTabId, &tabContext)) {
appId = tabContext.OwnOrContainingAppId();
}
}
return appId;
}
} // namespace dom
} // namespace mozilla

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

@ -110,6 +110,13 @@ public:
const TabId& aChildTabId,
/*out*/ TabId* aOpenerTabId);
/**
* Get all TabParents' Ids managed by the givent content process.
* Return empty array when TabParent couldn't be found via aChildCpId
*/
nsTArray<TabId>
GetTabParentsByProcessId(const ContentParentId& aChildCpId);
/**
* Get the TabParent by the given content process and tab id.
* Return nullptr when TabParent couldn't be found via aChildCpId
@ -135,6 +142,15 @@ public:
GetTopLevelTabParentByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId);
/**
* Return appId by given TabId and ContentParentId.
* It will return nsIScriptSecurityManager::NO_APP_ID
* if the given tab is not an app.
*/
uint32_t
GetAppIdByProcessAndTabId(const ContentParentId& aChildCpId,
const TabId& aChildTabId);
private:
static StaticAutoPtr<ContentProcessManager> sSingleton;
TabId mUniqueId;

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

@ -991,8 +991,15 @@ parent:
*/
sync AllocateTabId(TabId openerTabId, IPCTabContext context, ContentParentId cpId)
returns (TabId tabId);
async DeallocateTabId(TabId tabId);
async DeallocateTabId(TabId tabId,
ContentParentId cpId,
bool aMarkedDestroying);
/**
* Tell the chrome process there is a destruction of PBrowser(Tab)
*/
async NotifyTabDestroying(TabId tabId,
ContentParentId cpId);
/**
* Starts an offline application cache update.
* @param manifestURI

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

@ -2183,19 +2183,19 @@ TabChild::RecvRealDragEvent(const WidgetDragEvent& aEvent,
}
}
if (aEvent.mMessage == NS_DRAGDROP_DROP) {
if (aEvent.mMessage == eDrop) {
bool canDrop = true;
if (!dragSession || NS_FAILED(dragSession->GetCanDrop(&canDrop)) ||
!canDrop) {
localEvent.mMessage = NS_DRAGDROP_EXIT;
localEvent.mMessage = eDragExit;
}
} else if (aEvent.mMessage == NS_DRAGDROP_OVER) {
} else if (aEvent.mMessage == eDragOver) {
nsCOMPtr<nsIDragService> dragService =
do_GetService("@mozilla.org/widget/dragservice;1");
if (dragService) {
// This will dispatch 'drag' event at the source if the
// drag transaction started in this process.
dragService->FireDragEventAtSource(NS_DRAGDROP_DRAG);
dragService->FireDragEventAtSource(eDrag);
}
}

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

@ -436,12 +436,8 @@ TabParent::IsVisible()
}
void
TabParent::Destroy()
TabParent::DestroyInternal()
{
if (mIsDestroyed) {
return;
}
IMEStateManager::OnTabParentDestroying(this);
RemoveWindowListeners();
@ -455,11 +451,6 @@ TabParent::Destroy()
RemoveTabParentFromTable(frame->GetLayersId());
frame->Destroy();
}
mIsDestroyed = true;
if (XRE_IsParentProcess()) {
Manager()->AsContentParent()->NotifyTabDestroying(this);
}
// Let all PluginWidgets know we are tearing down. Prevents
// these objects from sending async events after the child side
@ -468,6 +459,24 @@ TabParent::Destroy()
for (uint32_t idx = 0; idx < kids.Length(); ++idx) {
static_cast<mozilla::plugins::PluginWidgetParent*>(kids[idx])->ParentDestroy();
}
}
void
TabParent::Destroy()
{
if (mIsDestroyed) {
return;
}
DestroyInternal();
mIsDestroyed = true;
if (XRE_IsParentProcess()) {
ContentParent::NotifyTabDestroying(this->GetTabId(), Manager()->AsContentParent()->ChildID());
} else {
ContentParent::NotifyTabDestroying(this->GetTabId(), Manager()->ChildID());
}
mMarkedDestroying = true;
}
@ -476,12 +485,15 @@ bool
TabParent::Recv__delete__()
{
if (XRE_IsParentProcess()) {
Manager()->AsContentParent()->NotifyTabDestroyed(this, mMarkedDestroying);
ContentParent::DeallocateTabId(mTabId,
Manager()->AsContentParent()->ChildID());
Manager()->AsContentParent()->ChildID(),
mMarkedDestroying);
}
else {
ContentParent::DeallocateTabId(mTabId, ContentParentId(0));
Manager()->AsContentBridgeParent()->NotifyTabDestroyed();
ContentParent::DeallocateTabId(mTabId,
Manager()->ChildID(),
mMarkedDestroying);
}
return true;
@ -494,6 +506,22 @@ TabParent::ActorDestroy(ActorDestroyReason why)
// case of a crash.
IMEStateManager::OnTabParentDestroying(this);
// Prevent executing ContentParent::NotifyTabDestroying in
// TabParent::Destroy() called by frameLoader->DestroyComplete() below
// when tab crashes in contentprocess because ContentParent::ActorDestroy()
// in main process will be triggered before this function
// and remove the process information that
// ContentParent::NotifyTabDestroying need from mContentParentMap.
// When tab crashes in content process,
// there is no need to call ContentParent::NotifyTabDestroying
// because the jobs in ContentParent::NotifyTabDestroying
// will be done by ContentParent::ActorDestroy.
if (XRE_IsContentProcess() && why == AbnormalShutdown && !mIsDestroyed) {
DestroyInternal();
mIsDestroyed = true;
}
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader(true);
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (frameLoader) {

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

@ -491,6 +491,7 @@ protected:
LayoutDeviceIntPoint mChromeOffset;
private:
void DestroyInternal();
already_AddRefed<nsFrameLoader> GetFrameLoader(bool aUseCachedFrameLoaderAfterDestroy = false) const;
nsRefPtr<nsIContentParent> mManager;
void TryCacheDPIAndScale();

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

@ -10,6 +10,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentBridgeParent.h"
#include "mozilla/dom/PTabContext.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/StructuredCloneUtils.h"
@ -46,6 +47,13 @@ nsIContentParent::AsContentParent()
return static_cast<ContentParent*>(this);
}
ContentBridgeParent*
nsIContentParent::AsContentBridgeParent()
{
MOZ_ASSERT(IsContentBridgeParent());
return static_cast<ContentBridgeParent*>(this);
}
PJavaScriptParent*
nsIContentParent::AllocPJavaScriptParent()
{

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

@ -38,6 +38,7 @@ class BlobConstructorParams;
class BlobImpl;
class BlobParent;
class ContentParent;
class ContentBridgeParent;
class IPCTabContext;
class PBlobParent;
class PBrowserParent;
@ -77,6 +78,8 @@ public:
virtual bool IsContentParent() { return false; }
ContentParent* AsContentParent();
virtual bool IsContentBridgeParent() { return false; }
ContentBridgeParent* AsContentBridgeParent();
protected: // methods
bool CanOpenBrowser(const IPCTabContext& aContext);

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

@ -0,0 +1,55 @@
var gBasePath = "tests/dom/ipc/tests/";
function handleRequest(request, response) {
var query = getQuery(request);
var testToken = '';
if ('testToken' in query) {
testToken = query.testToken;
}
var template = '';
if ('template' in query) {
template = query.template;
}
var template = gBasePath + template;
response.setHeader("Content-Type", "application/x-web-app-manifest+json", false);
response.write(readTemplate(template).replace(/TESTTOKEN/g, testToken));
}
// Copy-pasted incantations. There ought to be a better way to synchronously read
// a file into a string, but I guess we're trying to discourage that.
function readTemplate(path) {
var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("CurWorkD", Components.interfaces.nsILocalFile);
var fis = Components.classes['@mozilla.org/network/file-input-stream;1'].
createInstance(Components.interfaces.nsIFileInputStream);
var cis = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Components.interfaces.nsIConverterInputStream);
var split = path.split("/");
for(var i = 0; i < split.length; ++i) {
file.append(split[i]);
}
fis.init(file, -1, -1, false);
cis.init(fis, "UTF-8", 0, 0);
var data = "";
let str = {};
let read = 0;
do {
read = cis.readString(0xffffffff, str); // read as much as we can and put it in str.value
data += str.value;
} while (read != 0);
cis.close();
return data;
}
function getQuery(request) {
var query = {};
request.queryString.split('&').forEach(function (val) {
var [name, value] = val.split('=');
query[name] = unescape(value);
});
return query;
}

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

@ -0,0 +1,6 @@
{
"name": "Nested-OOP",
"description": "Nested-OOP test app used for mochitest.",
"launch_path": "/tests/dom/ipc/tests/TESTTOKEN",
"icons": { "128": "default_icon" }
}

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

@ -21,3 +21,39 @@ skip-if = true # bug 1166923
skip-if = toolkit == 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf
[test_CrashService_crash.html]
skip-if = !(crashreporter && !e10s && (toolkit == 'gtk2' || toolkit == 'gtk3' || toolkit == 'cocoa' || toolkit == 'windows') && (buildapp != 'b2g' || toolkit == 'gonk') && (buildapp != 'mulet')) # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
[test_permission_for_in_process_app.html]
skip-if = e10s || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
test_permission_helper.js
[test_permission_for_oop_app.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
test_permission_helper.js
test_permission_embed.html
test_permission_framescript.js
[test_permission_for_nested_oop_app.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
test_permission_helper.js
test_permission_embed.html
test_permission_framescript.js
[test_permission_for_two_oop_apps.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
test_permission_helper.js
test_permission_embed.html
test_permission_framescript.js
[test_permission_when_oop_app_crashes.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
test_permission_helper.js
test_permission_embed.html
test_permission_framescript.js

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

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>oop-test apps</title>
<script type="application/javascript">
"use strict";
var queryString = decodeURIComponent(window.location.hash.substring(1));
// test-target-app
var APP_URL = "http://example.org";
var APP_MANIFEST = "http://example.org/manifest.webapp";
var APP_IFRAME_ID = "test-target";
function removeAppFrame(){
var ifr = document.getElementById(APP_IFRAME_ID);
ifr.remove();
}
function allocateAppFrame(source, manifestURL, useRemote) {
var ifr = document.createElement('iframe');
ifr.setAttribute('id', APP_IFRAME_ID);
ifr.setAttribute('remote', useRemote? "true" : "false");
ifr.setAttribute('mozbrowser', 'true');
ifr.setAttribute('mozapp', manifestURL);
ifr.setAttribute('src', source);
ifr.addEventListener('mozbrowserloadend', function () {
if (queryString == "crash") {
// Send a crash request to parent-process
sendMessgeToParent('crash');
} else {
removeAppFrame();
}
});
document.body.appendChild(ifr);
}
function sendMessgeToParent(msg) {
window.alert(msg);
}
</script>
</head>
<body>
<script>
allocateAppFrame(APP_URL, APP_MANIFEST, true);
</script>
</body>
</html>

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

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1114507
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1114507</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114507">Mozilla Bug1114507</a>
<p id="display"></p>
<div id="container" style="display: none"></div>
<script type="text/javascript" src="test_permission_helper.js"></script>
<script type="application/javascript">
// Put all the tests in order
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
// +-------------------------------------------+
// | Test 1: Open and close a in-process |
// | test-target-app in chrome-process |
// +-------------------------------------------+
//
// level
// 1 chrome process <-- app is here
// Add permission to app
function () {
addPermissionToApp(APP_URL, APP_MANIFEST);
},
test1
];
runTests();
</script>
</body>
</html>

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

@ -0,0 +1,75 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1114507
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1114507</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114507">Mozilla Bug1114507</a>
<p id="display"></p>
<div id="container" style="display: none"></div>
<script type="text/javascript" src="test_permission_helper.js"></script>
<script type="application/javascript">
// Put all the tests in order
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
// ****************************************************
// Setup the enviroment for testing nested-oop cases: *
// test 3,4,5 *
// ****************************************************
// Install the app
installApp,
// Allow permission for embedApp to open mozbrowser and mozapp
function() {
var appId = gAppsService.getAppLocalIdByManifestURL(embedAppHostedManifestURL);
var context = { url: embedApp.origin,
appId: appId,
isInBrowserElement: false };
setupOpenAppPermission(context, runTests);
},
// +-------------------------------------------+
// | Test 3: Open a test-target-app on 3rd |
// | level child-process then close it |
// +-------------------------------------------+
//
// level
// 1 chrome process
// |
// 2 child process
// |
// 3 child process <-- app is here
// Add permission to app
function() {
addPermissionToApp(APP_URL, APP_MANIFEST);
},
test3,
// Remove the child-process on 2nd level
function() {
var afterShutdown = function() {
runTests();
};
afterContentShutdown(1, afterShutdown);
removeAppFrame(APP_IFRAME_ID);
},
uninstallApp
];
runTests();
</script>
</body>
</html>

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

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1114507
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1114507</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114507">Mozilla Bug1114507</a>
<p id="display"></p>
<div id="container" style="display: none"></div>
<script type="text/javascript" src="test_permission_helper.js"></script>
<script type="application/javascript">
// Put all the tests in order
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
// +------------------------------------------+
// | Test 2: Open and close a test-target-app |
// | on 2nd level child-process |
// +------------------------------------------+
//
// level
// 1 chrome process
// |
// 2 child process <-- app is here
// Add permission to app
function() {
addPermissionToApp(APP_URL, APP_MANIFEST);
},
test2,
];
runTests();
</script>
</body>
</html>

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

@ -0,0 +1,88 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1114507
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1114507</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114507">Mozilla Bug1114507</a>
<p id="display"></p>
<div id="container" style="display: none"></div>
<script type="text/javascript" src="test_permission_helper.js"></script>
<script type="application/javascript">
// Put all the tests in order
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
// ****************************************************
// Setup the enviroment for testing nested-oop cases: *
// test 3,4,5 *
// ****************************************************
// Install the app
installApp,
// Allow permission for embedApp to open mozbrowser and mozapp
function() {
var appId = gAppsService.getAppLocalIdByManifestURL(embedAppHostedManifestURL);
var context = { url: embedApp.origin,
appId: appId,
isInBrowserElement: false };
setupOpenAppPermission(context, runTests);
},
// +---------------------------------------------------------+
// | Test 4: Open two test-target-app on 2nd and 3rd level |
// | child-processes then close the one on 3rd level |
// +---------------------------------------------------------+
//
// level
// 1 chrome process
// / \
// 2 child process child process <-- app is here
// /
// 3 child process <-- app is here
// Add permission to app
function() {
addPermissionToApp(APP_URL, APP_MANIFEST);
},
test4,
// Remove another test-target-app on 2nd level process
function() {
var afterShutdown = function() {
// We expect there is no permission for the test-target-app now
runNextIfAppHasPermission(4, false, APP_URL, APP_MANIFEST);
};
// Test permission after test-target-app
// on 2nd level process is killed
afterContentShutdown(1, afterShutdown);
removeAppFrame(APP_IFRAME_ID2);
},
// Remove the last child-process on 2nd level
function() {
var afterShutdown = function() {
runTests();
};
afterContentShutdown(1, afterShutdown);
removeAppFrame(APP_IFRAME_ID);
},
uninstallApp
];
runTests();
</script>
</body>
</html>

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

@ -0,0 +1,31 @@
Components.utils.import("resource://gre/modules/Services.jsm");
let cm = Services.crashmanager;
var cpIdList = [];
var shutdownObs = {
observe: function(subject, topic, data) {
if (topic == 'ipc:content-shutdown') {
var index = cpIdList.indexOf(parseInt(data));
if (index > -1) {
cpIdList.splice(index, 1);
sendAsyncMessage('content-shutdown', '');
}
}
}
};
var createdObs = {
observe: function(subject, topic, data) {
if (topic == 'ipc:content-created') {
cpIdList.push(parseInt(data));
sendAsyncMessage('content-created', '');
}
}
};
addMessageListener('crashreporter-status', function(message) {
sendAsyncMessage('crashreporter-enable', !!cm);
});
Services.obs.addObserver(shutdownObs, 'ipc:content-shutdown', false);
Services.obs.addObserver(createdObs, 'ipc:content-created', false);

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

@ -0,0 +1,362 @@
"use strict";
// Used to access the DOM node in this test
const DOM_PARENT_ID = "container";
const DOM_PARENT = document.getElementById(DOM_PARENT_ID);
const APP_IFRAME_ID = "appFrame";
const APP_IFRAME_ID2 = "appFrame2";
// Settings for testing the permission
const SESSION_PERSIST_MINUTES = 10;
const PERMISSION_TYPE = "geolocation";
const permManager = SpecialPowers.Cc["@mozilla.org/permissionmanager;1"]
.getService(SpecialPowers.Ci.nsIPermissionManager);
// Used to access App's information like appId
const gAppsService = SpecialPowers.Cc["@mozilla.org/AppsService;1"]
.getService(SpecialPowers.Ci.nsIAppsService);
// Target-app for this testing
const APP_URL = "http://example.org";
const APP_MANIFEST = "http://example.org/manifest.webapp";
// Used to embed a remote app that open the test-target-app above
const embedAppHostedManifestURL = window.location.origin +
'/tests/dom/ipc/tests/file_app.sjs?testToken=test_permission_embed.html&template=file_app.template.webapp';
var embedApp;
// Used to add listener for ipc:content-shutdown that
// will be triggered after ContentParent::DeallocateTabId
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('test_permission_framescript.js'));
// Delay reporting a result until after finish() got called
SimpleTest.waitForExplicitFinish();
// Allow tests to disable the per platform app validity checks
SpecialPowers.setAllAppsLaunchable(true);
// Run tests in order
function runTests() {
if (!tests.length) {
ok(true, "pass all tests!");
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
function test1() {
allocateAppFrame(APP_IFRAME_ID, DOM_PARENT, APP_URL, APP_MANIFEST);
var appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST);
if (!SpecialPowers.hasPermission( PERMISSION_TYPE,
{ url: APP_URL,
appId: appId,
isInBrowserElement: false })) {
errorHandler('[test 1] App should have permission: ' + PERMISSION_TYPE);
}
removeAppFrame(APP_IFRAME_ID);
// We expect there is no permission for the test-target-app
// after removing the in-process iframe embedding this app
runNextIfAppHasPermission(1, false, APP_URL, APP_MANIFEST);
}
function test2() {
var afterShutdown = function () {
// We expect there is no permission for the test-target-app
// after removing the remote iframe embedding this app
runNextIfAppHasPermission(2, false, APP_URL, APP_MANIFEST);
};
// Test permission after the child-process containing
// test-target-app is killed
afterContentShutdown(1, afterShutdown);
allocateAppFrame(APP_IFRAME_ID, DOM_PARENT, APP_URL, APP_MANIFEST, true);
var appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST);
if (!SpecialPowers.hasPermission( PERMISSION_TYPE,
{ url: APP_URL,
appId: appId,
isInBrowserElement: false })) {
errorHandler('[test 2] App should have permission: ' + PERMISSION_TYPE);
}
removeAppFrame(APP_IFRAME_ID);
}
function test3() {
var afterGrandchildShutdown = function () {
// We expect there is no permission for the test-target-app
// after removing the remote iframe embedding this app
runNextIfAppHasPermission(3, false, APP_URL, APP_MANIFEST);
};
// Test permission after the grandchild-process
// containing test-target-app is killed
afterContentShutdown(1, afterGrandchildShutdown);
allocateAppFrame(APP_IFRAME_ID,
DOM_PARENT,
embedApp.manifest.launch_path,
embedApp.manifestURL,
true);
var appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST);
if (!SpecialPowers.hasPermission(PERMISSION_TYPE,
{ url: APP_URL,
appId: appId,
isInBrowserElement: false })) {
errorHandler('[test 3] App should have permission: ' + PERMISSION_TYPE);
}
}
function test4() {
var afterGrandchildShutdown = function () {
// We expect there is still a permission for the test-target-app
// after killing test-target-app on 3rd-level process
runNextIfAppHasPermission(4, true, APP_URL, APP_MANIFEST);
};
// Test permission after the grandchild-process
// containing test-target-app is killed
afterContentShutdown(1, afterGrandchildShutdown);
// Open a child process(2nd level) and a grandchild process(3rd level)
// that contains a test-target-app
allocateAppFrame(APP_IFRAME_ID,
DOM_PARENT,
embedApp.manifest.launch_path,
embedApp.manifestURL,
true);
// Open another child process that contains
// another test-target-app(2nd level)
allocateAppFrame(APP_IFRAME_ID2,
DOM_PARENT,
APP_URL,
APP_MANIFEST,
true);
var appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST);
if (!SpecialPowers.hasPermission(PERMISSION_TYPE,
{ url: APP_URL,
appId: appId,
isInBrowserElement: false })) {
errorHandler('[test 4] App should have permission: ' + PERMISSION_TYPE);
}
}
function test5() {
var afterShutdown = function () {
// We expect there is no permission for the test-target-app
// after crashing its parent-process
runNextIfAppHasPermission(5, false, APP_URL, APP_MANIFEST);
};
// Test permission after the parent-process of test-target-app is crashed.
afterContentShutdown(2, afterShutdown);
allocateAppFrame(APP_IFRAME_ID,
DOM_PARENT,
embedApp.manifest.launch_path + '#' + encodeURIComponent('crash'),
embedApp.manifestURL,
true);
var appId = gAppsService.getAppLocalIdByManifestURL(APP_MANIFEST);
if (!SpecialPowers.hasPermission( PERMISSION_TYPE,
{ url: APP_URL,
appId: appId,
isInBrowserElement: false })) {
errorHandler('[test 5] App should have permission: ' + PERMISSION_TYPE);
}
// Crash the child-process on 2nd level after
// the grandchild process on 3rd is allocated
var handler = {'crash': function() {
gScript.sendAsyncMessage("crashreporter-status", {});
getCrashReporterStatus(function(enable) {
if (enable) {
SimpleTest.expectChildProcessCrash();
}
crashChildProcess(APP_IFRAME_ID);
});
}
};
receiveMessageFromChildFrame(APP_IFRAME_ID, handler);
}
// Setup the prefrences and permissions.
// This function should be called before any tests
function setupPrefsAndPermissions() {
SpecialPowers.pushPrefEnv({"set": [
["dom.mozBrowserFramesEnabled", true],
["dom.ipc.tabs.nested.enabled", true],
["dom.ipc.tabs.disabled", false]]},
function() {
var autoManageApp = function () {
SpecialPowers.setAllAppsLaunchable(true);
// No confirmation needed when an app is installed and uninstalled.
SpecialPowers.autoConfirmAppInstall(() => {
// This callback should trigger the first test
SpecialPowers.autoConfirmAppUninstall(runTests);
});
};
setupOpenAppPermission(document, autoManageApp);
}
);
}
function setupOpenAppPermission(ctx, callback) {
SpecialPowers.pushPermissions([
{ "type": "browser", "allow": true, "context": ctx}, // for mozbrowser
{ "type": "embed-apps", "allow": true, "context": ctx }, // for mozapp
{ "type": "webapps-manage", "allow": true, "context": ctx }], // for (un)installing apps
function checkPermissions() {
if (SpecialPowers.hasPermission("browser", ctx) &&
SpecialPowers.hasPermission("embed-apps", ctx) &&
SpecialPowers.hasPermission("webapps-manage", ctx)) {
callback();
} else {
errorHandler(">> At least one of required permissions to open app is disallowed!\n");
}
});
}
function installApp() {
// Install App from manifest
var request = navigator.mozApps.install(embedAppHostedManifestURL);
request.onerror = cbError;
request.onsuccess = function() {
// Get installed app
embedApp = request.result; // Assign to global variable
runTests();
}
}
function uninstallApp() {
var request = navigator.mozApps.mgmt.uninstall(embedApp);
request.onerror = cbError;
request.onsuccess = function() {
info("uninstall app susseccfully!");
runTests();
}
}
function removeAppFrame(id) {
var ifr = document.getElementById(id);
ifr.remove();
}
function allocateAppFrame(id, parentNode, appSRC, manifestURL, useRemote = false) {
var ifr = document.createElement('iframe');
ifr.setAttribute('id', id);
ifr.setAttribute('remote', useRemote? "true" : "false");
ifr.setAttribute('mozbrowser', 'true');
ifr.setAttribute('mozapp', manifestURL);
ifr.setAttribute('src', appSRC);
parentNode.appendChild(ifr);
}
function receiveMessageFromChildFrame(id, handlers) {
var ifr = document.getElementById(id);
ifr.addEventListener('mozbrowsershowmodalprompt', function (recvMsg) {
var msg = recvMsg.detail.message;
handlers[msg]();
});
}
function addPermissionToApp(appURL, manifestURL) {
var appId = gAppsService.getAppLocalIdByManifestURL(manifestURL);
// Get the time now. This is used for permission manager's expire_time
var now = Number(Date.now());
// Add app's permission asynchronously
SpecialPowers.pushPermissions([
{ "type":PERMISSION_TYPE,
"allow": 1,
"expireType":permManager.EXPIRE_SESSION,
"expireTime":now + SESSION_PERSIST_MINUTES*60*1000,
"context": { url: appURL,
appId: appId,
isInBrowserElement:false }
}
], function() {
runTests();
});
}
function runNextIfAppHasPermission(round, expect, appURL, manifestURL) {
var appId = gAppsService.getAppLocalIdByManifestURL(manifestURL);
var hasPerm = SpecialPowers.hasPermission(PERMISSION_TYPE,
{ url: appURL,
appId: appId,
isInBrowserElement: false });
var result = (expect==hasPerm);
if (result) {
runTests();
} else {
errorHandler( '[test ' + round + '] App should ' + ((expect)? '':'NOT ') +
'have permission: ' + PERMISSION_TYPE);
}
}
function afterContentShutdown(times, callback) {
// handle the message from test_permission_framescript.js
var num = 0;
gScript.addMessageListener('content-shutdown', function onShutdown(data) {
num += 1;
if (num >= times) {
gScript.removeMessageListener('content-shutdown', onShutdown);
callback();
}
});
}
function getCrashReporterStatus(callback) {
gScript.addMessageListener('crashreporter-enable', function getStatus(data) {
gScript.removeMessageListener('crashreporter-enable', getStatus);
callback(data);
});
}
// Inject a frame script that crashes the content process
function crashChildProcess(frameId) {
var child = document.getElementById(frameId);
var mm = SpecialPowers.getBrowserFrameMessageManager(child);
var childFrameScriptStr =
'function ContentScriptScope() {' +
'var Cu = Components.utils;' +
'Cu.import("resource://gre/modules/ctypes.jsm");' +
'var crash = function() {' +
'var zero = new ctypes.intptr_t(8);' +
'var badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));' +
'badptr.contents;' +
'};' +
'privateNoteIntentionalCrash();' +
'crash();' +
'}';
mm.loadFrameScript('data:,new ' + childFrameScriptStr, false);
}
function errorHandler(errMsg) {
ok(false, errMsg);
SimpleTest.finish();
}
function cbError(e) {
errorHandler("Error callback invoked: " + this.error.name);
}

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

@ -0,0 +1,67 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1114507
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1114507</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1114507">Mozilla Bug1114507</a>
<p id="display"></p>
<div id="container" style="display: none"></div>
<script type="text/javascript" src="test_permission_helper.js"></script>
<script type="application/javascript">
// Put all the tests in order
var tests = [
// Setup preferences and permissions
setupPrefsAndPermissions,
// ****************************************************
// Setup the enviroment for testing nested-oop cases: *
// test 3,4,5 *
// ****************************************************
// Install the app
installApp,
// Allow permission for embedApp to open mozbrowser and mozapp
function() {
var appId = gAppsService.getAppLocalIdByManifestURL(embedAppHostedManifestURL);
var context = { url: embedApp.origin,
appId: appId,
isInBrowserElement: false };
setupOpenAppPermission(context, runTests);
},
// +-----------------------------------------------+
// | Test 5: Open a test-target-app on 3rd level |
// | process then crash its parent-process |
// +-----------------------------------------------+
//
// level
// 1 chrome process
// |
// 2 child process <-- crash this process
// |
// 3 child process <-- app is here
// Add permission to app
function() {
addPermissionToApp(APP_URL, APP_MANIFEST);
},
test5,
uninstallApp
];
runTests();
</script>
</body>
</html>

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

@ -137,7 +137,7 @@ var checkAllTrackStats = pc => {
// renegotiation test.
var commandsPeerConnectionInitial = [
function PC_SETUP_SIGNALING_CLIENT(test) {
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
test.setupSignalingClient();
test.registerSignalingCallback("ice_candidate", function (message) {
var pc = test.pcRemote ? test.pcRemote : test.pcLocal;
@ -215,21 +215,21 @@ var commandsPeerConnectionOfferAnswer = [
},
function PC_LOCAL_STEEPLECHASE_SIGNAL_EXPECTED_LOCAL_TRACKS(test) {
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
send_message({"type": "local_expected_tracks",
"expected_tracks": test.pcLocal.expectedLocalTrackInfoById});
}
},
function PC_REMOTE_STEEPLECHASE_SIGNAL_EXPECTED_LOCAL_TRACKS(test) {
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
send_message({"type": "remote_expected_tracks",
"expected_tracks": test.pcRemote.expectedLocalTrackInfoById});
}
},
function PC_LOCAL_GET_EXPECTED_REMOTE_TRACKS(test) {
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
return test.getSignalingMessage("remote_expected_tracks").then(
message => {
test.pcLocal.expectedRemoteTrackInfoById = message.expected_tracks;
@ -242,7 +242,7 @@ var commandsPeerConnectionOfferAnswer = [
},
function PC_REMOTE_GET_EXPECTED_REMOTE_TRACKS(test) {
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
return test.getSignalingMessage("local_expected_tracks").then(
message => {
test.pcRemote.expectedRemoteTrackInfoById = message.expected_tracks;
@ -262,7 +262,7 @@ var commandsPeerConnectionOfferAnswer = [
},
function PC_LOCAL_STEEPLECHASE_SIGNAL_OFFER(test) {
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
send_message({"type": "offer",
"offer": test.originalOffer,
"offer_constraints": test.pcLocal.constraints,
@ -282,7 +282,7 @@ var commandsPeerConnectionOfferAnswer = [
},
function PC_REMOTE_GET_OFFER(test) {
if (!test.steeplechase) {
if (!test.testOptions.steeplechase) {
test._local_offer = test.originalOffer;
test._offer_constraints = test.pcLocal.constraints;
test._offer_options = test.pcLocal.offerOptions;
@ -324,7 +324,7 @@ var commandsPeerConnectionOfferAnswer = [
.then(answer => {
is(test.pcRemote.signalingState, HAVE_REMOTE_OFFER,
"Remote createAnswer does not change signaling state");
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
send_message({"type": "answer",
"answer": test.originalAnswer,
"answer_constraints": test.pcRemote.constraints});
@ -343,7 +343,7 @@ var commandsPeerConnectionOfferAnswer = [
},
function PC_LOCAL_GET_ANSWER(test) {
if (!test.steeplechase) {
if (!test.testOptions.steeplechase) {
test._remote_answer = test.originalAnswer;
test._answer_constraints = test.pcRemote.constraints;
return Promise.resolve();
@ -410,13 +410,13 @@ var commandsPeerConnectionOfferAnswer = [
function PC_LOCAL_CHECK_STATS(test) {
return test.pcLocal.getStats().then(stats => {
test.pcLocal.checkStats(stats, test.steeplechase);
test.pcLocal.checkStats(stats, test.testOptions.steeplechase);
});
},
function PC_REMOTE_CHECK_STATS(test) {
return test.pcRemote.getStats().then(stats => {
test.pcRemote.checkStats(stats, test.steeplechase);
test.pcRemote.checkStats(stats, test.testOptions.steeplechase);
});
},

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

@ -23,7 +23,7 @@
function PC_REMOTE_SETUP_ICE_HANDLER(test) {
test.pcRemote.setupIceCandidateHandler(test);
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
test.pcRemote.endOfTrickleIce.then(() => {
send_message({"type": "end_of_trickle_ice"});
});

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

@ -36,7 +36,7 @@
function PC_REMOTE_SETUP_ICE_HANDLER(test) {
test.pcRemote.setupIceCandidateHandler(test);
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
test.pcRemote.endOfTrickleIce.then(() => {
send_message({"type": "end_of_trickle_ice"});
});

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

@ -27,7 +27,7 @@
[
function PC_LOCAL_SETUP_ICE_HANDLER(test) {
test.pcLocal.setupIceCandidateHandler(test);
if (test.steeplechase) {
if (test.testOptions.steeplechase) {
test.pcLocal.endOfTrickleIce.then(() => {
send_message({"type": "end_of_trickle_ice"});
});

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

@ -1706,7 +1706,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
}
if (eventType.EqualsLiteral("MozPerformDelayedBlur")) {
if (mShouldBlurOnActivate) {
WidgetGUIEvent blurEvent(true, NS_BLUR_CONTENT, nullptr);
WidgetGUIEvent blurEvent(true, eBlur, nullptr);
ProcessEvent(blurEvent);
mShouldBlurOnActivate = false;
}
@ -1749,8 +1749,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent)
if (dragEvent && mInstance) {
WidgetEvent* ievent = aEvent->GetInternalNSEvent();
if (ievent && ievent->mFlags.mIsTrusted &&
ievent->mMessage != NS_DRAGDROP_ENTER &&
ievent->mMessage != NS_DRAGDROP_OVER) {
ievent->mMessage != eDragEnter && ievent->mMessage != eDragOver) {
aEvent->PreventDefault();
}
@ -1830,8 +1829,8 @@ CocoaEventTypeForEvent(const WidgetGUIEvent& anEvent, nsIFrame* aObjectFrame)
return NPCocoaEventKeyDown;
case eKeyUp:
return NPCocoaEventKeyUp;
case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT:
case eFocus:
case eBlur:
return NPCocoaEventFocusChanged;
case NS_MOUSE_SCROLL:
return NPCocoaEventScrollWheel;
@ -1935,9 +1934,9 @@ TranslateToNPCocoaEvent(WidgetGUIEvent* anEvent, nsIFrame* aObjectFrame)
}
break;
}
case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT:
cocoaEvent.data.focus.hasFocus = (anEvent->mMessage == NS_FOCUS_CONTENT);
case eFocus:
case eBlur:
cocoaEvent.data.focus.hasFocus = (anEvent->mMessage == eFocus);
break;
default:
break;
@ -1975,8 +1974,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// focus unless it lost focus within the window. For example, ignore a blur
// event if it's coming due to the plugin's window deactivating.
nsCOMPtr<nsIContent> content = do_QueryReferent(mContent);
if (anEvent.mMessage == NS_BLUR_CONTENT &&
ContentIsFocusedWithinWindow(content)) {
if (anEvent.mMessage == eBlur && ContentIsFocusedWithinWindow(content)) {
mShouldBlurOnActivate = true;
return nsEventStatus_eIgnore;
}
@ -1985,8 +1983,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// it focus. This might happen if it has focus, its window is blurred, then the
// window is made active again. The plugin never lost in-window focus, so it
// shouldn't get a focus event again.
if (anEvent.mMessage == NS_FOCUS_CONTENT &&
mLastContentFocused == true) {
if (anEvent.mMessage == eFocus && mLastContentFocused == true) {
mShouldBlurOnActivate = false;
return nsEventStatus_eIgnore;
}
@ -1994,9 +1991,8 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
// Now, if we're going to send a focus event, update mLastContentFocused and
// tell any plugins in our window that we have taken focus, so they should
// perform any delayed blurs.
if (anEvent.mMessage == NS_FOCUS_CONTENT ||
anEvent.mMessage == NS_BLUR_CONTENT) {
mLastContentFocused = (anEvent.mMessage == NS_FOCUS_CONTENT);
if (anEvent.mMessage == eFocus || anEvent.mMessage == eBlur) {
mLastContentFocused = (anEvent.mMessage == eFocus);
mShouldBlurOnActivate = false;
PerformDelayedBlurs();
}
@ -2123,13 +2119,13 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
}
else if (!pPluginEvent) {
switch (anEvent.mMessage) {
case NS_FOCUS_CONTENT:
case eFocus:
pluginEvent.event = WM_SETFOCUS;
pluginEvent.wParam = 0;
pluginEvent.lParam = 0;
pPluginEvent = &pluginEvent;
break;
case NS_BLUR_CONTENT:
case eBlur:
pluginEvent.event = WM_KILLFOCUS;
pluginEvent.wParam = 0;
pluginEvent.lParam = 0;
@ -2322,12 +2318,11 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
default:
switch (anEvent.mMessage) {
case NS_FOCUS_CONTENT:
case NS_BLUR_CONTENT:
case eFocus:
case eBlur:
{
XFocusChangeEvent &event = pluginEvent.xfocus;
event.type =
anEvent.mMessage == NS_FOCUS_CONTENT ? FocusIn : FocusOut;
event.type = anEvent.mMessage == eFocus ? FocusIn : FocusOut;
// information lost:
event.mode = -1;
event.detail = NotifyDetailNone;

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