import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1168263 - Exclude perspective transforms from the transform used to convert from screen coordinates to an APZC's coordinate space. r=kats (dab02eb359)
- Bug 1225950 - Remove unnecessary parameter from SetNeedsComposite. r=mchang (0fb6099bd5)
- Bug 1225950 - Make mNeedsComposite a counter rather than a boolean. r=mchang (4d46dba314)
- Bug 1225950 - Force a composite if we have requested one but haven't gotten a vsync in a while. r=mchang (06f0d4553e)
- Bug 1221697 - Add a telemetry probe for time-to-composite. r=kats (c333e2ea87)
- Bug 1213120 - Ensure we don't try to use an uninitialized map. r=BenWa (99069b78fe)
- Bug 1228133 - Guard against a race condition that could result in an illegal pointer access. r=BenWa (65e1393908)
- update, mostly shadow warnings (5ca9c8ec0c)
- Bug 1119106 - Increase the radio button rendering bottom margin on 10.10 so that the button hits its frame more accurately. r=smichaud (2b55533095)
- Bug 1221451: Don't pass nil when an argument is required. r=spohl (7adfcf2543)
- Bug 1153579 - Fix -Wpointer-bool-conversion warning by removing null check of an array address. r=mstange (8c7ad82e8f)
- Bug 1204620 - Don't prepend 'image.' to CUIDraw image names on 10.11. r=stefanh (9a4794ecd4)
- Bug 1181289 - Specify size: small when drawing small scrollbars with CoreUI. r=smichaud (e75bff6036)
- Bug 1138359 - Make the margins of native-themed Cocoa buttons aware of writing mode. r=smontagu (49afef0f00)
- Bug 1220358 - Fix -Wunreachable-code warnings in widget/cocoa. r=spohl (720c720afc)
- fixup widget/ios from EventMessage change (no bug, NPOTB) (ab33d61f95)
- Bug 1217818 - Add support for the mHandledByAPZ flag on touch events as well. r=botond (d4658c671a)
- Bug 1209772 - 'mozregression was installed. please re-run your command.' when running ./mach mozregression. r=ahal (5febef290b)
- Bug 1204787 - Add |mach power|. r=glandium. (5a0d84f480)
- Bug 1214924 - Add "WindowServer" and "kernel" processes to |mach power|'s output. r=BenWa. (89c3a515f7)
- Bug 1197694 - fflush() rapl output so it always appears immediately.  r=erahm. (052568f395)
- Bug 1194560 (follow-up) - Only build rapl on Linux if the arch is x86 or x86-64. r=glandium. (0101937ffa)
- Bug 1198137 - Add some summary stats to tool/power/rapl's output. r=erahm. (53052f366b)
- Bug 1198137 (follow-up) - Add a missing #include to unbreak Mac OS builds on a CLOSED TREE. r=me (27862d34ff)
- Bug 1203834 - Fix's rapl's handling of unsupported power domains. r=glandium. (facb022467)
- Bug 1203811 - Clarify two error messages in tools/power/rapl. r=heycam. (07a6bb847e)
- Bug 1201811 (part 1) - Don't use integer arithmetic when summing totals in rapl. r=erahm. (57a1de1376)
- Bug 1201811 (part 2) - Don't print distribution stats if there was only 1 sample. r=erahm. (e5c085a4df)
- Bug 1222887 - Suppress -Wunreachable-code warning in tools/power. r=njn (4fbbbe81e1)
- Bug 1222352 - Resource Timing - nextHopProtocol does not work in e10s r=nwgh (57029cf33d)
- Bug 1211636 - use ToInteger64 in PopulateFromSuffix. r=bholley (d67e5fe9d1)
- Bug 961049 - Part 2: Remove Utilities.h; r=baku (3c09679a40)
- Bug 961049 - Part 3: Move PersistenceType serializer from indexedDB to quota module; r=baku (021478905a)
- Bug 1186809 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in dom/quota/ with iterators. r=janv. (8933726851)
- Bug 1186809 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in dom/quota/ with iterators. r=janv. (cb7c6f27dc)
- Bug 1186809 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/quota/ with iterators. r=janv. (1ded98347c)
- Bug 1187151 (part 1) - Replace nsBaseHashtable::Enumerate() calls in dom/base/ with iterators. r=khuey. (a409e8590e)
- Bug 1187151 (part 2) - Replace nsBaseHashtable::Enumerate() calls in dom/base/ with iterators. r=janv. (bd4fe93dfc)
- Bug 1187151 (part 3) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (de0f2dda26)
- Bug 1187151 (part 4) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (e72d744118)
- Bug 1187151 (part 5) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (18eddd5225)
- Bug 1187151 (part 6) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (36fb6272e1)
- Bug 1187151 (part 7) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (594438d35f)
- Bug 1187151 (part 8) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (d8de2742d8)
- Bug 1187151 (part 9) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=khuey. (d2b4a29111)
- missing namespace (0b0453cc40)
- Bug 1187701 - add_task function for mochitest chrome and plain; r=jmaher (1c31a40c7c)
- Bug 1223831 - SpecialPowers API to create files in an e10s-compatible way. r=jmaher,baku (a04646cb50)
- Bug 1178526 - Create docshell with packageId from TabContext. r=sicking. (c89edfc7ab)
- Bug 1217694 - Signed package should come from the moz-package-origin specified in its manifest. r=valentin (705aeae07a)
- Bug 1225422 - Update the PrivilegedPackageRoot certificate. r=keeler (2a90eed63c)
- Bug 1204301 - HttpChannelParent needs to be able to GetInterface to an nsIPrompt. r=billm. (4937a2fbbe)
This commit is contained in:
2023-03-13 17:37:42 +08:00
parent 33f0551ea5
commit f7d677cddd
89 changed files with 1433 additions and 628 deletions
+1
View File
@@ -101,6 +101,7 @@ MACH_MODULES = [
'tools/docs/mach_commands.py',
'tools/mercurial/mach_commands.py',
'tools/mach_commands.py',
'tools/power/mach_commands.py',
]
+8 -8
View File
@@ -120,10 +120,10 @@ public:
{
if (aName.EqualsLiteral("appId")) {
nsresult rv;
mOriginAttributes->mAppId = aValue.ToInteger(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
int64_t val = aValue.ToInteger64(&rv);
NS_ENSURE_SUCCESS(rv, false);
NS_ENSURE_TRUE(val <= UINT32_MAX, false);
mOriginAttributes->mAppId = static_cast<uint32_t>(val);
return true;
}
@@ -145,10 +145,10 @@ public:
if (aName.EqualsLiteral("userContextId")) {
nsresult rv;
mOriginAttributes->mUserContextId = aValue.ToInteger(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
int64_t val = aValue.ToInteger64(&rv);
NS_ENSURE_SUCCESS(rv, false);
NS_ENSURE_TRUE(val <= UINT32_MAX, false);
mOriginAttributes->mUserContextId = static_cast<uint32_t>(val);
return true;
}
+3
View File
@@ -49,6 +49,9 @@ LOCAL_INCLUDES += [
'/js/xpconnect/src',
]
if CONFIG['ENABLE_TESTS']:
DIRS += ['tests/gtest']
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
+37
View File
@@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "gtest/gtest.h"
#include "mozilla/BasePrincipal.h"
using mozilla::OriginAttributes;
static void
TestSuffix(const OriginAttributes& attrs)
{
nsAutoCString suffix;
attrs.CreateSuffix(suffix);
OriginAttributes attrsFromSuffix;
attrsFromSuffix.PopulateFromSuffix(suffix);
EXPECT_EQ(attrs, attrsFromSuffix);
}
TEST(OriginAttributes, Suffix_default)
{
OriginAttributes attrs;
TestSuffix(attrs);
}
TEST(OriginAttributes, Suffix_appId_inBrowser)
{
OriginAttributes attrs(1, true);
TestSuffix(attrs);
}
TEST(OriginAttributes, Suffix_maxAppId_inBrowser)
{
OriginAttributes attrs(4294967295, true);
TestSuffix(attrs);
}
+13
View File
@@ -0,0 +1,13 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
UNIFIED_SOURCES += [
'TestOriginAttributes.cpp'
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul-gtest'
+10
View File
@@ -13793,6 +13793,13 @@ nsDocShell::SetIsBrowserInsideApp(uint32_t aContainingAppId)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetIsSignedPackage(const nsAString& aSignedPkg)
{
mSignedPkg = aSignedPkg;
return NS_OK;
}
/* [infallible] */ NS_IMETHODIMP
nsDocShell::GetIsBrowserElement(bool* aIsBrowser)
{
@@ -13900,6 +13907,9 @@ nsDocShell::GetOriginAttributes()
attrs.mInBrowser = true;
}
// Bug 1209162 will address the inheritance of each attributes.
attrs.mSignedPkg = mSignedPkg;
return attrs;
}
+4
View File
@@ -1010,6 +1010,10 @@ protected:
nsString GetInheritedPaymentRequestId();
// The packageId for a signed packaged iff this docShell is created
// for a signed package.
nsString mSignedPkg;
private:
nsCString mForcedCharset;
nsCString mParentCharset;
+7 -1
View File
@@ -46,7 +46,7 @@ interface nsITabParent;
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(41b1cf17-b37b-4a62-9df8-5f67cfecab3f)]
[scriptable, builtinclass, uuid(63adb599-6dc9-4746-972e-c22e9018020b)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@@ -813,6 +813,12 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
void setIsBrowserInsideApp(in unsigned long containingAppId);
/**
* Indicate that this docshell corresponds to a signed package with
* the given packageId.
*/
void setIsSignedPackage(in AString packageId);
/**
* Returns the id of the app associated with this docshell. If this docshell
* is an <iframe mozbrowser> inside an <iframe mozapp>, we return the app's
+4 -13
View File
@@ -124,22 +124,13 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMAttributeMap)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMAttributeMap)
PLDHashOperator
SetOwnerDocumentFunc(nsAttrHashKey::KeyType aKey,
RefPtr<Attr>& aData,
void* aUserArg)
{
nsresult rv = aData->SetOwnerDocument(static_cast<nsIDocument*>(aUserArg));
return NS_FAILED(rv) ? PL_DHASH_STOP : PL_DHASH_NEXT;
}
nsresult
nsDOMAttributeMap::SetOwnerDocument(nsIDocument* aDocument)
{
uint32_t n = mAttributeCache.Enumerate(SetOwnerDocumentFunc, aDocument);
NS_ENSURE_TRUE(n == mAttributeCache.Count(), NS_ERROR_FAILURE);
for (auto iter = mAttributeCache.Iter(); !iter.Done(); iter.Next()) {
nsresult rv = iter.Data()->SetOwnerDocument(aDocument);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
}
return NS_OK;
}
@@ -19,6 +19,7 @@
#include "mozilla/Services.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/unused.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/dom/ipc/BlobChild.h"
+18 -24
View File
@@ -157,32 +157,26 @@ DeleteDatabase(const nsAString& aName,
db->Delete();
}
PLDHashOperator
DeleteDataStoresAppEnumerator(
const uint32_t& aAppId,
nsAutoPtr<DataStoreInfo>& aInfo,
void* aUserData)
static void
DeleteDataStoresHelper(nsClassHashtable<nsStringHashKey, HashApp>& aStores,
uint32_t aAppId)
{
MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
auto* appId = static_cast<uint32_t*>(aUserData);
if (*appId != aAppId) {
return PL_DHASH_NEXT;
for (auto iter1 = aStores.Iter(); !iter1.Done(); iter1.Next()) {
nsAutoPtr<HashApp>& apps = iter1.Data();
for (auto iter2 = apps->Iter(); !iter2.Done(); iter2.Next()) {
if (aAppId == iter2.Key()) {
nsAutoPtr<DataStoreInfo>& info = iter2.Data();
DeleteDatabase(info->mName, info->mManifestURL);
iter2.Remove();
}
}
if (apps->Count() == 0) {
iter1.Remove();
}
}
DeleteDatabase(aInfo->mName, aInfo->mManifestURL);
return PL_DHASH_REMOVE;
}
PLDHashOperator
DeleteDataStoresEnumerator(const nsAString& aName,
nsAutoPtr<HashApp>& aApps,
void* aUserData)
{
MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
aApps->Enumerate(DeleteDataStoresAppEnumerator, aUserData);
return aApps->Count() ? PL_DHASH_NEXT : PL_DHASH_REMOVE;
}
void
@@ -1213,8 +1207,8 @@ DataStoreService::DeleteDataStores(uint32_t aAppId)
{
MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
mStores.Enumerate(DeleteDataStoresEnumerator, &aAppId);
mAccessStores.Enumerate(DeleteDataStoresEnumerator, &aAppId);
DeleteDataStoresHelper(mStores, aAppId);
DeleteDataStoresHelper(mAccessStores, aAppId);
}
NS_IMETHODIMP
+10 -10
View File
@@ -1486,14 +1486,6 @@ HTMLFormElement::RemoveElementFromTableInternal(
return NS_OK;
}
static PLDHashOperator
RemovePastNames(const nsAString& aName,
nsCOMPtr<nsISupports>& aData,
void* aClosure)
{
return aClosure == aData ? PL_DHASH_REMOVE : PL_DHASH_NEXT;
}
nsresult
HTMLFormElement::RemoveElementFromTable(nsGenericHTMLFormElement* aElement,
const nsAString& aName,
@@ -1503,7 +1495,11 @@ HTMLFormElement::RemoveElementFromTable(nsGenericHTMLFormElement* aElement,
// the past names map.
if (aRemoveReason == ElementRemoved) {
uint32_t oldCount = mPastNameLookupTable.Count();
mPastNameLookupTable.Enumerate(RemovePastNames, aElement);
for (auto iter = mPastNameLookupTable.Iter(); !iter.Done(); iter.Next()) {
if (static_cast<void*>(aElement) == iter.Data()) {
iter.Remove();
}
}
if (oldCount != mPastNameLookupTable.Count()) {
++mExpandoAndGeneration.generation;
}
@@ -2525,7 +2521,11 @@ HTMLFormElement::RemoveImageElementFromTable(HTMLImageElement* aElement,
// If the element is being removed from the form, we have to remove it from
// the past names map.
if (aRemoveReason == ElementRemoved) {
mPastNameLookupTable.Enumerate(RemovePastNames, aElement);
for (auto iter = mPastNameLookupTable.Iter(); !iter.Done(); iter.Next()) {
if (static_cast<void*>(aElement) == iter.Data()) {
iter.Remove();
}
}
}
return RemoveElementFromTableInternal(mImageNameLookupTable, aElement, aName);
+36 -59
View File
@@ -14946,46 +14946,6 @@ VersionChangeTransaction::UpdateMetadata(nsresult aResult)
MOZ_ASSERT(!!mActorWasAlive == !!mOpenDatabaseOp->mDatabase);
MOZ_ASSERT_IF(mActorWasAlive, !mOpenDatabaseOp->mDatabaseId.IsEmpty());
class MOZ_STACK_CLASS Helper final
{
public:
static PLDHashOperator
Enumerate(const uint64_t& aKey,
RefPtr<FullObjectStoreMetadata>& aValue,
void* /* aClosure */)
{
MOZ_ASSERT(aKey);
MOZ_ASSERT(aValue);
if (aValue->mDeleted) {
return PL_DHASH_REMOVE;
}
aValue->mIndexes.Enumerate(Enumerate, nullptr);
#ifdef DEBUG
aValue->mIndexes.MarkImmutable();
#endif
return PL_DHASH_NEXT;
}
private:
static PLDHashOperator
Enumerate(const uint64_t& aKey,
RefPtr<FullIndexMetadata>& aValue,
void* /* aClosure */)
{
MOZ_ASSERT(aKey);
MOZ_ASSERT(aValue);
if (aValue->mDeleted) {
return PL_DHASH_REMOVE;
}
return PL_DHASH_NEXT;
}
};
if (IsActorDestroyed() || !mActorWasAlive) {
return;
}
@@ -15002,7 +14962,33 @@ VersionChangeTransaction::UpdateMetadata(nsresult aResult)
if (NS_SUCCEEDED(aResult)) {
// Remove all deleted objectStores and indexes, then mark immutable.
info->mMetadata->mObjectStores.Enumerate(Helper::Enumerate, nullptr);
for (auto objectStoreIter = info->mMetadata->mObjectStores.Iter();
!objectStoreIter.Done();
objectStoreIter.Next()) {
MOZ_ASSERT(objectStoreIter.Key());
RefPtr<FullObjectStoreMetadata>& metadata = objectStoreIter.Data();
MOZ_ASSERT(metadata);
if (metadata->mDeleted) {
objectStoreIter.Remove();
continue;
}
for (auto indexIter = metadata->mIndexes.Iter();
!indexIter.Done();
indexIter.Next()) {
MOZ_ASSERT(indexIter.Key());
RefPtr<FullIndexMetadata>& index = indexIter.Data();
MOZ_ASSERT(index);
if (index->mDeleted) {
indexIter.Remove();
}
}
#ifdef DEBUG
metadata->mIndexes.MarkImmutable();
#endif
}
#ifdef DEBUG
info->mMetadata->mObjectStores.MarkImmutable();
#endif
@@ -15973,22 +15959,6 @@ FileManager::Init(nsIFile* aDirectory,
nsresult
FileManager::Invalidate()
{
class MOZ_STACK_CLASS Helper final
{
public:
static PLDHashOperator
ClearDBRefs(const uint64_t& aKey, FileInfo*& aValue, void* aUserArg)
{
MOZ_ASSERT(aValue);
if (aValue->LockedClearDBRefs()) {
return PL_DHASH_NEXT;
}
return PL_DHASH_REMOVE;
}
};
if (IndexedDatabaseManager::IsClosed()) {
MOZ_ASSERT(false, "Shouldn't be called after shutdown!");
return NS_ERROR_UNEXPECTED;
@@ -15999,7 +15969,14 @@ FileManager::Invalidate()
MOZ_ASSERT(!mInvalidated);
mInvalidated = true;
mFileInfos.Enumerate(Helper::ClearDBRefs, nullptr);
for (auto iter = mFileInfos.Iter(); !iter.Done(); iter.Next()) {
FileInfo* info = iter.Data();
MOZ_ASSERT(info);
if (!info->LockedClearDBRefs()) {
iter.Remove();
}
}
return NS_OK;
}
@@ -16350,7 +16327,7 @@ FileManager::GetUsage(nsIFile* aDirectory, uint64_t* aUsage)
return rv;
}
quota::IncrementUsage(&usage, uint64_t(fileSize));
UsageInfo::IncrementUsage(&usage, uint64_t(fileSize));
}
if (NS_WARN_IF(NS_FAILED(rv))) {
+18 -43
View File
@@ -1021,27 +1021,15 @@ IDBDatabase::NoteFinishedFileActor(PBackgroundIDBDatabaseFileChild* aFileActor)
AssertIsOnOwningThread();
MOZ_ASSERT(aFileActor);
class MOZ_STACK_CLASS Helper final
{
public:
static PLDHashOperator
Remove(nsISupports* aKey,
PBackgroundIDBDatabaseFileChild*& aValue,
void* aClosure)
{
MOZ_ASSERT(aKey);
MOZ_ASSERT(aValue);
MOZ_ASSERT(aClosure);
for (auto iter = mFileActors.Iter(); !iter.Done(); iter.Next()) {
MOZ_ASSERT(iter.Key());
PBackgroundIDBDatabaseFileChild* actor = iter.Data();
MOZ_ASSERT(actor);
if (aValue == static_cast<PBackgroundIDBDatabaseFileChild*>(aClosure)) {
return PL_DHASH_REMOVE;
}
return PL_DHASH_NEXT;
if (actor == aFileActor) {
iter.Remove();
}
};
mFileActors.Enumerate(&Helper::Remove, aFileActor);
}
}
void
@@ -1159,23 +1147,16 @@ IDBDatabase::ExpireFileActors(bool aExpireAll)
{
AssertIsOnOwningThread();
class MOZ_STACK_CLASS Helper final
{
public:
static PLDHashOperator
MaybeExpireFileActors(nsISupports* aKey,
PBackgroundIDBDatabaseFileChild*& aValue,
void* aClosure)
{
MOZ_ASSERT(aKey);
MOZ_ASSERT(aValue);
MOZ_ASSERT(aClosure);
if (mBackgroundActor && mFileActors.Count()) {
for (auto iter = mFileActors.Iter(); !iter.Done(); iter.Next()) {
nsISupports* key = iter.Key();
PBackgroundIDBDatabaseFileChild* actor = iter.Data();
MOZ_ASSERT(key);
MOZ_ASSERT(actor);
const bool expiringAll = *static_cast<bool*>(aClosure);
bool shouldExpire = expiringAll;
bool shouldExpire = aExpireAll;
if (!shouldExpire) {
nsCOMPtr<nsIWeakReference> weakRef = do_QueryInterface(aKey);
nsCOMPtr<nsIWeakReference> weakRef = do_QueryInterface(key);
MOZ_ASSERT(weakRef);
nsCOMPtr<nsISupports> referent = do_QueryReferent(weakRef);
@@ -1183,19 +1164,13 @@ IDBDatabase::ExpireFileActors(bool aExpireAll)
}
if (shouldExpire) {
PBackgroundIDBDatabaseFileChild::Send__delete__(aValue);
PBackgroundIDBDatabaseFileChild::Send__delete__(actor);
if (!expiringAll) {
return PL_DHASH_REMOVE;
if (!aExpireAll) {
iter.Remove();
}
}
return PL_DHASH_NEXT;
}
};
if (mBackgroundActor && mFileActors.Count()) {
mFileActors.Enumerate(&Helper::MaybeExpireFileActors, &aExpireAll);
if (aExpireAll) {
mFileActors.Clear();
}
+2
View File
@@ -9,6 +9,8 @@ include protocol PBackgroundIDBFactoryRequest;
include PBackgroundIDBSharedTypes;
include PBackgroundSharedTypes;
include "mozilla/dom/quota/SerializationHelpers.h";
using struct mozilla::void_t
from "ipc/IPCMessageUtils.h";
@@ -9,6 +9,7 @@ include protocol PBlob;
include DOMTypes;
include "mozilla/dom/indexedDB/SerializationHelpers.h";
include "mozilla/dom/quota/SerializationHelpers.h";
using struct mozilla::null_t
from "ipc/IPCMessageUtils.h";
-9
View File
@@ -13,18 +13,9 @@
#include "mozilla/dom/indexedDB/KeyPath.h"
#include "mozilla/dom/indexedDB/IDBCursor.h"
#include "mozilla/dom/indexedDB/IDBTransaction.h"
#include "mozilla/dom/quota/PersistenceType.h"
namespace IPC {
template <>
struct ParamTraits<mozilla::dom::quota::PersistenceType> :
public ContiguousEnumSerializer<
mozilla::dom::quota::PersistenceType,
mozilla::dom::quota::PERSISTENCE_TYPE_PERSISTENT,
mozilla::dom::quota::PERSISTENCE_TYPE_INVALID>
{ };
template <>
struct ParamTraits<mozilla::dom::indexedDB::Key>
{
+1 -1
View File
@@ -71,7 +71,7 @@ include ProfilerTypes;
// XXX Remove this once bug 1069073 is fixed
include "mozilla/dom/PContentBridgeParent.h";
include "mozilla/dom/indexedDB/SerializationHelpers.h";
include "mozilla/dom/quota/SerializationHelpers.h";
using GeoPosition from "nsGeoPositionIPCSerialiser.h";
+1
View File
@@ -832,6 +832,7 @@ TabChild::NotifyTabContextUpdated()
} else {
docShell->SetIsApp(OwnAppId());
}
docShell->SetIsSignedPackage(OriginAttributesRef().mSignedPkg);
}
}
+1
View File
@@ -20,6 +20,7 @@
#include "mozilla/dom/ipc/BlobParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
#include "nsContentUtils.h"
#include "nsTArrayHelpers.h"
+113 -159
View File
@@ -57,7 +57,6 @@
#include "OriginScope.h"
#include "QuotaObject.h"
#include "UsageInfo.h"
#include "Utilities.h"
// The amount of time, in milliseconds, that our IO thread will stay alive
// after the last event it processes.
@@ -845,6 +844,14 @@ AssertNoUnderflow(T aDest, U aArg)
MOZ_ASSERT(uint64_t(aDest) >= uint64_t(aArg));
}
bool
PatternMatchesOrigin(const nsACString& aPatternString,
const nsACString& aOrigin)
{
// Aren't we smart!
return StringBeginsWith(aOrigin, aPatternString);
}
} // namespace
bool
@@ -2235,51 +2242,8 @@ QuotaManager::CollectOriginsForEviction(
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aLocks.IsEmpty());
class MOZ_STACK_CLASS Closure final
struct MOZ_STACK_CLASS Helper final
{
nsTArray<DirectoryLockImpl*>& mTemporaryStorageLocks;
nsTArray<DirectoryLockImpl*>& mDefaultStorageLocks;
nsTArray<OriginInfo*>& mInactiveOriginInfos;
public:
Closure(nsTArray<DirectoryLockImpl*>& aTemporaryStorageLocks,
nsTArray<DirectoryLockImpl*>& aDefaultStorageLocks,
nsTArray<OriginInfo*>& aInactiveOriginInfos)
: mTemporaryStorageLocks(aTemporaryStorageLocks)
, mDefaultStorageLocks(aDefaultStorageLocks)
, mInactiveOriginInfos(aInactiveOriginInfos)
{ }
static PLDHashOperator
GetInactiveTemporaryStorageOrigins(const nsACString& aKey,
GroupInfoPair* aValue,
void* aUserArg)
{
MOZ_ASSERT(!aKey.IsEmpty());
MOZ_ASSERT(aValue);
MOZ_ASSERT(aUserArg);
auto* closure = static_cast<Closure*>(aUserArg);
RefPtr<GroupInfo> groupInfo =
aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
GetInactiveOriginInfos(groupInfo->mOriginInfos,
closure->mTemporaryStorageLocks,
closure->mInactiveOriginInfos);
}
groupInfo = aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
GetInactiveOriginInfos(groupInfo->mOriginInfos,
closure->mDefaultStorageLocks,
closure->mInactiveOriginInfos);
}
return PL_DHASH_NEXT;
}
private:
static void
GetInactiveOriginInfos(nsTArray<RefPtr<OriginInfo>>& aOriginInfos,
nsTArray<DirectoryLockImpl*>& aLocks,
@@ -2335,14 +2299,31 @@ QuotaManager::CollectOriginsForEviction(
nsTArray<OriginInfo*> inactiveOrigins;
Closure closure(temporaryStorageLocks, defaultStorageLocks, inactiveOrigins);
// Enumerate and process inactive origins. This must be protected by the
// mutex.
MutexAutoLock lock(mQuotaMutex);
mGroupInfoPairs.EnumerateRead(Closure::GetInactiveTemporaryStorageOrigins,
&closure);
for (auto iter = mGroupInfoPairs.Iter(); !iter.Done(); iter.Next()) {
GroupInfoPair* pair = iter.UserData();
MOZ_ASSERT(!iter.Key().IsEmpty());
MOZ_ASSERT(pair);
RefPtr<GroupInfo> groupInfo =
pair->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
Helper::GetInactiveOriginInfos(groupInfo->mOriginInfos,
temporaryStorageLocks,
inactiveOrigins);
}
groupInfo = pair->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
Helper::GetInactiveOriginInfos(groupInfo->mOriginInfos,
defaultStorageLocks,
inactiveOrigins);
}
}
#ifdef DEBUG
// Make sure the array is sorted correctly.
@@ -2556,35 +2537,30 @@ QuotaManager::UpdateOriginAccessTime(PersistenceType aPersistenceType,
}
}
// static
PLDHashOperator
QuotaManager::RemoveQuotaCallback(const nsACString& aKey,
nsAutoPtr<GroupInfoPair>& aValue,
void* aUserArg)
{
NS_ASSERTION(!aKey.IsEmpty(), "Empty key!");
NS_ASSERTION(aValue, "Null pointer!");
RefPtr<GroupInfo> groupInfo =
aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
groupInfo = aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
return PL_DHASH_REMOVE;
}
void
QuotaManager::RemoveQuota()
{
MutexAutoLock lock(mQuotaMutex);
mGroupInfoPairs.Enumerate(RemoveQuotaCallback, nullptr);
for (auto iter = mGroupInfoPairs.Iter(); !iter.Done(); iter.Next()) {
nsAutoPtr<GroupInfoPair>& pair = iter.Data();
MOZ_ASSERT(!iter.Key().IsEmpty(), "Empty key!");
MOZ_ASSERT(pair, "Null pointer!");
RefPtr<GroupInfo> groupInfo =
pair->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
groupInfo = pair->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
groupInfo->LockedRemoveOriginInfos();
}
iter.Remove();
}
NS_ASSERTION(mTemporaryStorageUsage == 0, "Should be zero!");
}
@@ -3997,88 +3973,6 @@ QuotaManager::ClearStoragesForApp(uint32_t aAppId, bool aBrowserOnly)
return NS_OK;
}
// static
PLDHashOperator
QuotaManager::GetOriginsExceedingGroupLimit(const nsACString& aKey,
GroupInfoPair* aValue,
void* aUserArg)
{
NS_ASSERTION(!aKey.IsEmpty(), "Empty key!");
NS_ASSERTION(aValue, "Null pointer!");
uint64_t groupUsage = 0;
RefPtr<GroupInfo> temporaryGroupInfo =
aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (temporaryGroupInfo) {
groupUsage += temporaryGroupInfo->mUsage;
}
RefPtr<GroupInfo> defaultGroupInfo =
aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (defaultGroupInfo) {
groupUsage += defaultGroupInfo->mUsage;
}
if (groupUsage > 0) {
QuotaManager* quotaManager = QuotaManager::Get();
NS_ASSERTION(quotaManager, "Shouldn't be null!");
if (groupUsage > quotaManager->GetGroupLimit()) {
nsTArray<OriginInfo*>* doomedOriginInfos =
static_cast<nsTArray<OriginInfo*>*>(aUserArg);
nsTArray<OriginInfo*> originInfos;
if (temporaryGroupInfo) {
originInfos.AppendElements(temporaryGroupInfo->mOriginInfos);
}
if (defaultGroupInfo) {
originInfos.AppendElements(defaultGroupInfo->mOriginInfos);
}
originInfos.Sort(OriginInfoLRUComparator());
for (uint32_t i = 0; i < originInfos.Length(); i++) {
OriginInfo* originInfo = originInfos[i];
doomedOriginInfos->AppendElement(originInfo);
groupUsage -= originInfo->mUsage;
if (groupUsage <= quotaManager->GetGroupLimit()) {
break;
}
}
}
}
return PL_DHASH_NEXT;
}
// static
PLDHashOperator
QuotaManager::GetAllTemporaryStorageOrigins(const nsACString& aKey,
GroupInfoPair* aValue,
void* aUserArg)
{
NS_ASSERTION(!aKey.IsEmpty(), "Empty key!");
NS_ASSERTION(aValue, "Null pointer!");
nsTArray<OriginInfo*>* originInfos =
static_cast<nsTArray<OriginInfo*>*>(aUserArg);
RefPtr<GroupInfo> groupInfo =
aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
originInfos->AppendElements(groupInfo->mOriginInfos);
}
groupInfo = aValue->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
originInfos->AppendElements(groupInfo->mOriginInfos);
}
return PL_DHASH_NEXT;
}
void
QuotaManager::CheckTemporaryStorageLimits()
{
@@ -4088,8 +3982,53 @@ QuotaManager::CheckTemporaryStorageLimits()
{
MutexAutoLock lock(mQuotaMutex);
mGroupInfoPairs.EnumerateRead(GetOriginsExceedingGroupLimit,
&doomedOriginInfos);
for (auto iter = mGroupInfoPairs.Iter(); !iter.Done(); iter.Next()) {
GroupInfoPair* pair = iter.UserData();
MOZ_ASSERT(!iter.Key().IsEmpty(), "Empty key!");
MOZ_ASSERT(pair, "Null pointer!");
uint64_t groupUsage = 0;
RefPtr<GroupInfo> temporaryGroupInfo =
pair->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (temporaryGroupInfo) {
groupUsage += temporaryGroupInfo->mUsage;
}
RefPtr<GroupInfo> defaultGroupInfo =
pair->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (defaultGroupInfo) {
groupUsage += defaultGroupInfo->mUsage;
}
if (groupUsage > 0) {
QuotaManager* quotaManager = QuotaManager::Get();
MOZ_ASSERT(quotaManager, "Shouldn't be null!");
if (groupUsage > quotaManager->GetGroupLimit()) {
nsTArray<OriginInfo*> originInfos;
if (temporaryGroupInfo) {
originInfos.AppendElements(temporaryGroupInfo->mOriginInfos);
}
if (defaultGroupInfo) {
originInfos.AppendElements(defaultGroupInfo->mOriginInfos);
}
originInfos.Sort(OriginInfoLRUComparator());
for (uint32_t i = 0; i < originInfos.Length(); i++) {
OriginInfo* originInfo = originInfos[i];
doomedOriginInfos.AppendElement(originInfo);
groupUsage -= originInfo->mUsage;
if (groupUsage <= quotaManager->GetGroupLimit()) {
break;
}
}
}
}
}
uint64_t usage = 0;
for (uint32_t index = 0; index < doomedOriginInfos.Length(); index++) {
@@ -4099,8 +4038,23 @@ QuotaManager::CheckTemporaryStorageLimits()
if (mTemporaryStorageUsage - usage > mTemporaryStorageLimit) {
nsTArray<OriginInfo*> originInfos;
mGroupInfoPairs.EnumerateRead(GetAllTemporaryStorageOrigins,
&originInfos);
for (auto iter = mGroupInfoPairs.Iter(); !iter.Done(); iter.Next()) {
GroupInfoPair* pair = iter.UserData();
MOZ_ASSERT(!iter.Key().IsEmpty(), "Empty key!");
MOZ_ASSERT(pair, "Null pointer!");
RefPtr<GroupInfo> groupInfo =
pair->LockedGetGroupInfo(PERSISTENCE_TYPE_TEMPORARY);
if (groupInfo) {
originInfos.AppendElements(groupInfo->mOriginInfos);
}
groupInfo = pair->LockedGetGroupInfo(PERSISTENCE_TYPE_DEFAULT);
if (groupInfo) {
originInfos.AppendElements(groupInfo->mOriginInfos);
}
}
for (uint32_t index = originInfos.Length(); index > 0; index--) {
if (doomedOriginInfos.Contains(originInfos[index - 1])) {
+2 -17
View File
@@ -34,8 +34,8 @@ class nsIRunnable;
namespace mozilla {
namespace dom {
class OptionalContentId;
}
}
} // namespace dom
} // namespace mozilla
BEGIN_QUOTA_NAMESPACE
@@ -469,21 +469,6 @@ private:
const nsACString& aOrigin,
nsAutoCString& _retval);
static PLDHashOperator
RemoveQuotaCallback(const nsACString& aKey,
nsAutoPtr<GroupInfoPair>& aValue,
void* aUserArg);
static PLDHashOperator
GetOriginsExceedingGroupLimit(const nsACString& aKey,
GroupInfoPair* aValue,
void* aUserArg);
static PLDHashOperator
GetAllTemporaryStorageOrigins(const nsACString& aKey,
GroupInfoPair* aValue,
void* aUserArg);
mozilla::Mutex mQuotaMutex;
nsClassHashtable<nsCStringHashKey, GroupInfoPair> mGroupInfoPairs;
+26
View File
@@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_quota_SerializationHelpers_h
#define mozilla_dom_quota_SerializationHelpers_h
#include "ipc/IPCMessageUtils.h"
#include "mozilla/dom/quota/PersistenceType.h"
namespace IPC {
template <>
struct ParamTraits<mozilla::dom::quota::PersistenceType> :
public ContiguousEnumSerializer<
mozilla::dom::quota::PersistenceType,
mozilla::dom::quota::PERSISTENCE_TYPE_PERSISTENT,
mozilla::dom::quota::PERSISTENCE_TYPE_INVALID>
{ };
} // namespace IPC
#endif // mozilla_dom_quota_SerializationHelpers_h
+14 -1
View File
@@ -10,7 +10,7 @@
#include "mozilla/dom/quota/QuotaCommon.h"
#include "mozilla/Atomics.h"
#include "Utilities.h"
#include "mozilla/CheckedInt.h"
BEGIN_QUOTA_NAMESPACE
@@ -79,6 +79,19 @@ public:
mFileUsage = 0;
}
static void
IncrementUsage(uint64_t* aUsage, uint64_t aDelta)
{
MOZ_ASSERT(aUsage);
CheckedUint64 value = *aUsage;
value += aDelta;
if (value.isValid()) {
*aUsage = value.value();
} else {
*aUsage = UINT64_MAX;
}
}
protected:
mozilla::Atomic<bool> mCanceled;
-36
View File
@@ -1,36 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_quota_utilities_h__
#define mozilla_dom_quota_utilities_h__
#include "mozilla/dom/quota/QuotaCommon.h"
BEGIN_QUOTA_NAMESPACE
inline void
IncrementUsage(uint64_t* aUsage, uint64_t aDelta)
{
// Watch for overflow!
if ((UINT64_MAX - *aUsage) < aDelta) {
NS_WARNING("Usage exceeds the maximum!");
*aUsage = UINT64_MAX;
}
else {
*aUsage += aDelta;
}
}
inline bool
PatternMatchesOrigin(const nsACString& aPatternString, const nsACString& aOrigin)
{
// Aren't we smart!
return StringBeginsWith(aOrigin, aPatternString);
}
END_QUOTA_NAMESPACE
#endif // mozilla_dom_quota_utilities_h__
+1 -1
View File
@@ -19,8 +19,8 @@ EXPORTS.mozilla.dom.quota += [
'QuotaCommon.h',
'QuotaManager.h',
'QuotaObject.h',
'SerializationHelpers.h',
'UsageInfo.h',
'Utilities.h',
]
UNIFIED_SOURCES += [
+17 -17
View File
@@ -2684,20 +2684,6 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
return NS_OK;
}
static PLDHashOperator
FirePendingMergeNotification(nsIURI* aKey, nsCOMPtr<nsIObserver>& aObserver, void* aClosure)
{
aObserver->Observe(aKey, "xul-overlay-merged", EmptyString().get());
typedef nsInterfaceHashtable<nsURIHashKey,nsIObserver> table;
table* observers = static_cast<table*>(aClosure);
if (observers) {
observers->Remove(aKey);
}
return PL_DHASH_REMOVE;
}
nsresult
XULDocument::ResumeWalk()
{
@@ -3048,9 +3034,23 @@ XULDocument::DoneWalking()
// Walk the set of pending load notifications and notify any observers.
// See below for detail.
if (mPendingOverlayLoadNotifications)
mPendingOverlayLoadNotifications->Enumerate(
FirePendingMergeNotification, mOverlayLoadObservers.get());
if (mPendingOverlayLoadNotifications) {
nsInterfaceHashtable<nsURIHashKey,nsIObserver>* observers =
mOverlayLoadObservers.get();
for (auto iter = mPendingOverlayLoadNotifications->Iter();
!iter.Done();
iter.Next()) {
nsIURI* aKey = iter.Key();
iter.Data()->Observe(aKey, "xul-overlay-merged",
EmptyString().get());
if (observers) {
observers->Remove(aKey);
}
iter.Remove();
}
}
}
else {
if (mOverlayLoadObservers) {
+19 -41
View File
@@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -238,56 +239,33 @@ nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
return NS_OK;
}
static PLDHashOperator
FlushSkinXBL(nsIURI* aKey, RefPtr<nsXBLDocumentInfo>& aDocInfo, void* aClosure)
{
nsAutoCString str;
aKey->GetPath(str);
PLDHashOperator ret = PL_DHASH_NEXT;
if (!strncmp(str.get(), "/skin", 5)) {
ret = PL_DHASH_REMOVE;
}
return ret;
}
static PLDHashOperator
FlushSkinSheets(nsIURI* aKey, RefPtr<CSSStyleSheet>& aSheet, void* aClosure)
{
nsAutoCString str;
aSheet->GetSheetURI()->GetPath(str);
PLDHashOperator ret = PL_DHASH_NEXT;
if (!strncmp(str.get(), "/skin", 5)) {
// This is a skin binding. Add the key to the list.
ret = PL_DHASH_REMOVE;
}
return ret;
}
static PLDHashOperator
FlushScopedSkinStylesheets(nsIURI* aKey, RefPtr<nsXBLDocumentInfo> &aDocInfo, void* aClosure)
{
aDocInfo->FlushSkinStylesheets();
return PL_DHASH_NEXT;
}
void
nsXULPrototypeCache::FlushSkinFiles()
{
// Flush out skin XBL files from the cache.
mXBLDocTable.Enumerate(FlushSkinXBL, nullptr);
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
nsAutoCString str;
iter.Key()->GetPath(str);
if (strncmp(str.get(), "/skin", 5) == 0) {
iter.Remove();
}
}
// Now flush out our skin stylesheets from the cache.
mStyleSheetTable.Enumerate(FlushSkinSheets, nullptr);
for (auto iter = mStyleSheetTable.Iter(); !iter.Done(); iter.Next()) {
nsAutoCString str;
iter.Data()->GetSheetURI()->GetPath(str);
if (strncmp(str.get(), "/skin", 5) == 0) {
iter.Remove();
}
}
// Iterate over all the remaining XBL and make sure cached
// scoped skin stylesheets are flushed and refetched by the
// prototype bindings.
mXBLDocTable.Enumerate(FlushScopedSkinStylesheets, nullptr);
for (auto iter = mXBLDocTable.Iter(); !iter.Done(); iter.Next()) {
iter.Data()->FlushSkinStylesheets();
}
}
void
+14
View File
@@ -299,6 +299,20 @@ public:
return gfx::Matrix4x4();
}
bool TransformIsPerspective() const
{
MOZ_ASSERT(IsValid());
// mLayer->GetTransformIsPerspective() tells us whether
// mLayer->GetTransform() is a perspective transform. Since
// mLayer->GetTransform() is only used at the bottom layer, we only
// need to check GetTransformIsPerspective() at the bottom layer too.
if (AtBottomLayer()) {
return mLayer->GetTransformIsPerspective();
}
return false;
}
EventRegions GetEventRegions() const
{
MOZ_ASSERT(IsValid());
+4 -2
View File
@@ -590,8 +590,9 @@ APZCTreeManager::UpdateHitTestingTree(TreeBuildingState& aState,
// transform to layer L when we recurse into the children below. If we are at a layer
// with an APZC, such as P, then we reset the ancestorTransform to just PC, to start
// the new accumulation as we go down.
Matrix4x4 transform = aLayer.GetTransform();
Matrix4x4 ancestorTransform = transform;
// If a transform is a perspective transform, it's ignored for this purpose
// (see bug 1168263).
Matrix4x4 ancestorTransform = aLayer.TransformIsPerspective() ? Matrix4x4() : aLayer.GetTransform();
if (!apzc) {
ancestorTransform = ancestorTransform * aAncestorTransform;
}
@@ -695,6 +696,7 @@ APZCTreeManager::ReceiveInputEvent(InputData& aEvent,
switch (aEvent.mInputType) {
case MULTITOUCH_INPUT: {
MultiTouchInput& touchInput = aEvent.AsMultiTouchInput();
touchInput.mHandledByAPZ = true;
result = ProcessTouchInput(touchInput, aOutTargetGuid, aOutInputBlockId);
break;
} case MOUSE_INPUT: {
+2 -1
View File
@@ -1049,7 +1049,8 @@ public:
private:
/* This is the cumulative CSS transform for all the layers from (and including)
* the parent APZC down to (but excluding) this one. */
* the parent APZC down to (but excluding) this one, and excluding any
* perspective transforms. */
Matrix4x4 mAncestorTransform;
+28 -12
View File
@@ -280,8 +280,8 @@ CompositorVsyncScheduler::CompositorVsyncScheduler(CompositorParent* aCompositor
: mCompositorParent(aCompositorParent)
, mLastCompose(TimeStamp::Now())
, mCurrentCompositeTask(nullptr)
, mNeedsComposite(false)
, mIsObservingVsync(false)
, mNeedsComposite(0)
, mVsyncNotificationsSkipped(0)
, mCurrentCompositeTaskMonitor("CurrentCompositeTaskMonitor")
, mSetNeedsCompositeMonitor("SetNeedsCompositeMonitor")
@@ -341,8 +341,18 @@ CompositorVsyncScheduler::ScheduleComposition()
if (mAsapScheduling) {
// Used only for performance testing purposes
PostCompositeTask(TimeStamp::Now());
#ifdef MOZ_WIDGET_ANDROID
} else if (mNeedsComposite >= 2 && mIsObservingVsync) {
// uh-oh, we already requested a composite at least twice so far, and a
// composite hasn't happened yet. It is possible that the vsync observation
// is blocked on the main thread, so let's just composite ASAP and not
// wait for the vsync. Note that this should only ever happen on Fennec
// because there content runs in the same process as the compositor, and so
// content can actually block the main thread in this process.
PostCompositeTask(TimeStamp::Now());
#endif
} else {
SetNeedsComposite(true);
SetNeedsComposite();
}
}
@@ -355,7 +365,7 @@ CompositorVsyncScheduler::CancelCurrentSetNeedsCompositeTask()
mSetNeedsCompositeTask->Cancel();
mSetNeedsCompositeTask = nullptr;
}
mNeedsComposite = false;
mNeedsComposite = 0;
}
/**
@@ -366,13 +376,12 @@ CompositorVsyncScheduler::CancelCurrentSetNeedsCompositeTask()
* How many skipped vsync events until we stop listening to vsync events?
*/
void
CompositorVsyncScheduler::SetNeedsComposite(bool aNeedsComposite)
CompositorVsyncScheduler::SetNeedsComposite()
{
if (!CompositorParent::IsInCompositorThread()) {
MonitorAutoLock lock(mSetNeedsCompositeMonitor);
mSetNeedsCompositeTask = NewRunnableMethod(this,
&CompositorVsyncScheduler::SetNeedsComposite,
aNeedsComposite);
&CompositorVsyncScheduler::SetNeedsComposite);
ScheduleTask(mSetNeedsCompositeTask, 0);
return;
} else {
@@ -380,7 +389,7 @@ CompositorVsyncScheduler::SetNeedsComposite(bool aNeedsComposite)
mSetNeedsCompositeTask = nullptr;
}
mNeedsComposite = aNeedsComposite;
mNeedsComposite++;
if (!mIsObservingVsync && mNeedsComposite) {
ObserveVsync();
}
@@ -419,10 +428,14 @@ CompositorVsyncScheduler::Composite(TimeStamp aVsyncTimestamp)
DispatchTouchEvents(aVsyncTimestamp);
if (mNeedsComposite || mAsapScheduling) {
mNeedsComposite = false;
mNeedsComposite = 0;
mLastCompose = aVsyncTimestamp;
ComposeToTarget(nullptr);
mVsyncNotificationsSkipped = 0;
TimeDuration compositeFrameTotal = TimeStamp::Now() - aVsyncTimestamp;
mozilla::Telemetry::Accumulate(mozilla::Telemetry::COMPOSITE_FRAME_ROUNDTRIP_TIME,
compositeFrameTotal.ToMilliseconds());
} else if (mVsyncNotificationsSkipped++ > gfxPrefs::CompositorUnobserveCount()) {
UnobserveVsync();
}
@@ -1650,11 +1663,14 @@ CompositorParent::SetControllerForLayerTree(uint64_t aLayersId,
/*static*/ APZCTreeManager*
CompositorParent::GetAPZCTreeManager(uint64_t aLayersId)
{
const CompositorParent::LayerTreeState* state = CompositorParent::GetIndirectShadowTree(aLayersId);
if (state && state->mParent) {
return state->mParent->mApzcTreeManager;
EnsureLayerTreeMapReady();
MonitorAutoLock lock(*sIndirectLayerTreesLock);
LayerTreeMap::iterator cit = sIndirectLayerTrees.find(aLayersId);
if (sIndirectLayerTrees.end() == cit) {
return nullptr;
}
return nullptr;
LayerTreeState* lts = &cit->second;
return (lts->mParent ? lts->mParent->mApzcTreeManager.get() : nullptr);
}
float
+2 -2
View File
@@ -101,7 +101,7 @@ class CompositorVsyncScheduler
public:
explicit CompositorVsyncScheduler(CompositorParent* aCompositorParent, nsIWidget* aWidget);
bool NotifyVsync(TimeStamp aVsyncTimestamp);
void SetNeedsComposite(bool aSchedule);
void SetNeedsComposite();
void OnForceComposeToTarget();
void ScheduleTask(CancelableTask*, int);
@@ -159,8 +159,8 @@ private:
#endif
bool mAsapScheduling;
bool mNeedsComposite;
bool mIsObservingVsync;
uint32_t mNeedsComposite;
int32_t mVsyncNotificationsSkipped;
RefPtr<CompositorVsyncDispatcher> mCompositorVsyncDispatcher;
RefPtr<CompositorVsyncScheduler::Observer> mVsyncObserver;
+7 -1
View File
@@ -24,7 +24,7 @@ interface nsIVerificationCallback;
* https://wiki.mozilla.org/FirefoxOS/New_security_model/Packaging
*/
[scriptable, uuid(edf91fee-ef4a-4479-9136-27eb3b7a6312)]
[scriptable, uuid(2963609c-370b-4a76-9858-6f05121d0473)]
interface nsIPackagedAppUtils : nsISupports
{
/**
@@ -55,6 +55,12 @@ interface nsIPackagedAppUtils : nsISupports
* manifest is verified.
*/
readonly attribute ACString packageIdentifier;
/**
* The moz-package-location in the manifest of this signed package.
* Only available after the manifest is verified.
*/
readonly attribute ACString packageOrigin;
};
/**
+1
View File
@@ -10,6 +10,7 @@
#include "mozilla/BasePrincipal.h"
#include "mozilla/ipc/URIUtils.h"
#include "nsCookieService.h"
#include "nsIChannel.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrivateBrowsingChannel.h"
#include "nsNetCID.h"
+3 -1
View File
@@ -172,6 +172,7 @@ struct ParamTraits<mozilla::net::ResourceTimingStruct>
WriteParam(aMsg, aParam.transferSize);
WriteParam(aMsg, aParam.encodedBodySize);
WriteParam(aMsg, aParam.protocolVersion);
}
static bool Read(const Message* aMsg, void** aIter, mozilla::net::ResourceTimingStruct* aResult)
@@ -187,7 +188,8 @@ struct ParamTraits<mozilla::net::ResourceTimingStruct>
ReadParam(aMsg, aIter, &aResult->redirectStart) &&
ReadParam(aMsg, aIter, &aResult->redirectEnd) &&
ReadParam(aMsg, aIter, &aResult->transferSize) &&
ReadParam(aMsg, aIter, &aResult->encodedBodySize);
ReadParam(aMsg, aIter, &aResult->encodedBodySize) &&
ReadParam(aMsg, aIter, &aResult->protocolVersion);
}
};
+7 -2
View File
@@ -144,7 +144,12 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
continue;
}
}
if (!aSerialized.mOriginAttributes.mSignedPkg.IsEmpty() &&
aSerialized.mOriginAttributes.mSignedPkg != tabContext.OriginAttributesRef().mSignedPkg) {
continue;
}
aAttrs = OriginAttributes(appId, inBrowserElement);
aAttrs.mSignedPkg = tabContext.OriginAttributesRef().mSignedPkg;
return nullptr;
}
@@ -295,7 +300,7 @@ NeckoParent::AllocPCookieServiceParent()
return new CookieServiceParent();
}
bool
bool
NeckoParent::DeallocPCookieServiceParent(PCookieServiceParent* cs)
{
delete cs;
@@ -454,7 +459,7 @@ NeckoParent::AllocPTCPSocketParent(const nsString& /* host */,
{
// We actually don't need host/port to construct a TCPSocketParent since
// TCPSocketParent will maintain an internal nsIDOMTCPSocket instance which
// can be delegated to get the host/port.
// can be delegated to get the host/port.
TCPSocketParent* p = new TCPSocketParent();
p->AddIPDLReference();
return p;
@@ -860,6 +860,7 @@ HttpChannelChild::OnStopRequest(const nsresult& channelStatus,
mRedirectEndTimeStamp = timing.redirectEnd;
mTransferSize = timing.transferSize;
mEncodedBodySize = timing.encodedBodySize;
mProtocolVersion = timing.protocolVersion;
nsPerformance* documentPerformance = GetPerformance();
if (documentPerformance) {
@@ -1989,6 +1990,13 @@ HttpChannelChild::RedirectTo(nsIURI *newURI)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
HttpChannelChild::GetProtocolVersion(nsACString& aProtocolVersion)
{
aProtocolVersion = mProtocolVersion;
return NS_OK;
}
//-----------------------------------------------------------------------------
// HttpChannelChild::nsIHttpChannelInternal
//-----------------------------------------------------------------------------
+3
View File
@@ -83,6 +83,7 @@ public:
bool aMerge) override;
NS_IMETHOD SetEmptyRequestHeader(const nsACString& aHeader) override;
NS_IMETHOD RedirectTo(nsIURI *newURI) override;
NS_IMETHOD GetProtocolVersion(nsACString& aProtocolVersion) override;
// nsIHttpChannelInternal
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override;
NS_IMETHOD GetLocalAddress(nsACString& addr) override;
@@ -194,6 +195,8 @@ private:
nsCString mCachedCharset;
nsCOMPtr<nsISupports> mCacheKey;
nsCString mProtocolVersion;
// If ResumeAt is called before AsyncOpen, we need to send extra data upstream
bool mSendResumeAt;
@@ -9,6 +9,7 @@
#include "mozilla/ipc/FileDescriptorSetParent.h"
#include "mozilla/net/HttpChannelParent.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/net/NeckoParent.h"
#include "mozilla/unused.h"
@@ -35,6 +36,9 @@
#include "nsQueryObject.h"
#include "mozilla/BasePrincipal.h"
#include "nsCORSListenerProxy.h"
#include "nsIPrompt.h"
#include "nsIWindowWatcher.h"
#include "nsIDocument.h"
using mozilla::BasePrincipal;
using mozilla::OriginAttributes;
@@ -295,6 +299,35 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
return NS_OK;
}
if (mTabParent && aIID.Equals(NS_GET_IID(nsIPrompt))) {
nsCOMPtr<Element> frameElement = mTabParent->GetOwnerElement();
if (frameElement) {
nsresult rv;
nsCOMPtr<nsIDOMWindow> win =
do_QueryInterface(frameElement->OwnerDoc()->GetWindow(), &rv);
if (NS_WARN_IF(!NS_SUCCEEDED(rv))) {
return rv;
}
nsCOMPtr<nsIWindowWatcher> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
if (NS_WARN_IF(!NS_SUCCEEDED(rv))) {
return rv;
}
nsCOMPtr<nsIPrompt> prompt;
rv = wwatch->GetNewPrompter(win, getter_AddRefs(prompt));
if (NS_WARN_IF(!NS_SUCCEEDED(rv))) {
return rv;
}
prompt.forget(result);
return NS_OK;
}
}
return QueryInterface(aIID, result);
}
@@ -1148,6 +1181,7 @@ HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
mChannel->GetEncodedBodySize(&timing.encodedBodySize);
// decodedBodySize can be computed in the child process so it doesn't need
// to be passed down.
mChannel->GetProtocolVersion(timing.protocolVersion);
if (mIPCClosed || !SendOnStopRequest(aStatusCode, timing))
return NS_ERROR_UNEXPECTED;
+7 -5
View File
@@ -14,6 +14,7 @@ const PACKAGEDAPPUTILS_CID = Components.ID("{fe8f1c2e-3c13-11e5-9a3f-bbf47d1e669
function PackagedAppUtils() {
this.packageIdentifier = '';
this.packageOrigin = '';
}
var DEBUG = 0
@@ -49,19 +50,20 @@ PackagedAppUtils.prototype = {
debug("Signature: " + signature);
try {
// Base64 decode
signature = atob(signature);
// Remove header
let manifestBody = aManifest.substr(aManifest.indexOf('\r\n\r\n') + 4);
debug("manifestBody: " + manifestBody);
// Parse manifest, store resource hashes
let manifestObj = JSON.parse(manifestBody);
this.resources = manifestObj["moz-resources"];
this.packageIdentifier = manifestObj["package-identifier"];
this.packageOrigin = manifestObj["moz-package-origin"];
this.resources = manifestObj["moz-resources"];
// Base64 decode
signature = atob(signature);
} catch (e) {
debug("JSON parsing failure");
debug("Manifest parsing failure");
aCallback.fireVerifiedEvent(true, false);
return;
}
+15 -3
View File
@@ -81,11 +81,13 @@ NS_IMETHODIMP PackagedAppVerifier::Init(nsIPackagedAppVerifierListener* aListene
mIsFirstResource = true;
mManifest = EmptyCString();
nsAutoCString originNoSuffix;
OriginAttributes().PopulateFromOrigin(aPackageOrigin, originNoSuffix);
mBypassVerification = (originNoSuffix ==
OriginAttributes().PopulateFromOrigin(aPackageOrigin, mPackageOrigin);
mBypassVerification = (mPackageOrigin ==
Preferences::GetCString("network.http.signed-packages.trusted-origin"));
LOG(("mBypassVerification = %d\n", mBypassVerification));
LOG(("mPackageOrigin = %s\n", mPackageOrigin.get()));
nsresult rv;
mPackagedAppUtils = do_CreateInstance(NS_PACKAGEDAPPUTILS_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
@@ -359,6 +361,16 @@ PackagedAppVerifier::OnManifestVerified(bool aSuccess)
LOG(("Developer mode! Treat junk signature valid."));
}
if (aSuccess && !mSignature.IsEmpty()) {
// Get the package location from the manifest
nsAutoCString packageOrigin;
mPackagedAppUtils->GetPackageOrigin(packageOrigin);
if (packageOrigin != mPackageOrigin) {
aSuccess = false;
LOG(("moz-package-location doesn't match:\nFrom: %s\nManifest: %s\n", mPackageOrigin.get(), packageOrigin.get()));
}
}
// Only when the manifest verified and package has signature would we
// regard this package is signed.
mIsPackageSigned = aSuccess && !mSignature.IsEmpty();
+1
View File
@@ -26,6 +26,7 @@ struct ResourceTimingStruct : TimingStruct {
TimeStamp redirectEnd;
uint64_t transferSize;
uint64_t encodedBodySize;
nsCString protocolVersion;
};
} // namespace net
@@ -9,6 +9,7 @@
#include "mozilla/unused.h"
#include "SubstitutingProtocolHandler.h"
#include "nsIChannel.h"
#include "nsIIOService.h"
#include "nsIFile.h"
#include "nsNetCID.h"
+4 -2
View File
@@ -24,8 +24,10 @@ skip-if = e10s
skip-if = e10s
[test_user_agent_updates_reset.html]
[test_xhr_method_case.html]
skip-if = e10s
[test_idn_redirect.html]
[test_signed_web_packaged_app.html]
skip-if = e10s || buildapp != 'browser'
[test_web_packaged_app.html]
[test_signed_web_packaged_app_origin.html]
skip-if = e10s || buildapp != 'browser'
skip-if = buildapp == 'b2g' #no ssl support
[test_idn_redirect.html]
@@ -11,73 +11,71 @@ function handleRequest(request, response)
// The package content
// getData formats it as described at http://www.w3.org/TR/web-packaging/#streamable-package-format
var signedPackage = [
"manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgECMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMB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tYyALe34KW3wM9Qm9rb0eViDnVyDiCWkhhQnw5yPg/XQfloug2itRYuCnfUoRt8xfeHgwz2Ymz8cUADn3KpTGCAf4wggH6AgEBMHgwczELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFRydXN0ZWQgVmFsaWQgQ0ECAQIwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MTAwMTIxMTEwNlowIwYJKoZIhvcNAQkEMRYEFHAisUYrrt+gBxYFhZ5KQQusOmN3MA0GCSqGSIb3DQEBAQUABIIBACHW4V0BsPWOvWrGOTRj6mPpNbH/JI1bN2oyqQZrpUQoaBY+BbYxO7TY4Uwe+aeIR/TTPJznOMF/dl3Bna6TPabezU4ylg7TVFI6W7zC5f5DZKp+Xv6uTX6knUzbbW1fkJqMtE8hGUzYXc3/C++Ci6kuOzrpWOhk6DpJHeUO/ioV56H0+QK/oMAjYpEsOohaPqvTPNOBhMQ0OQP3bmuJ6HcjZ/oz96PpzXUPKT1tDe6VykIYkV5NvtC8Tu2lDbYvp9ug3gyDgdyNSV47y5i/iWkzEhsAJB+9Z50wKhplnkxxVHEXkB/6tmfvExvQ28gLd/VbaEGDX2ljCaTSUjhD0o0=\r",
"--7B0MKBI3UH\r",
"Content-Location: manifest.webapp\r",
"Content-Type: application/x-web-app-manifest+json\r",
"\r",
"{",
" \"name\": \"My App\",",
" \"moz-resources\": [",
" {",
" \"src\": \"page2.html\",",
" \"integrity\": \"JREF3JbXGvZ+I1KHtoz3f46ZkeIPrvXtG4VyFQrJ7II=\"",
" },",
" {",
" \"src\": \"index.html\",",
" \"integrity\": \"zEubR310nePwd30NThIuoCxKJdnz7Mf5z+dZHUbH1SE=\"",
" },",
" {",
" \"src\": \"scripts/script.js\",",
" \"integrity\": \"6TqtNArQKrrsXEQWu3D9ZD8xvDRIkhyV6zVdTcmsT5Q=\"",
" },",
" {",
" \"src\": \"scripts/library.js\",",
" \"integrity\": \"TN2ByXZiaBiBCvS4MeZ02UyNi44vED+KjdjLInUl4o8=\"",
" }",
" ],",
" \"moz-permissions\": [",
" {",
" \"systemXHR\": {",
" \"description\": \"Needed to download stuff\"",
" },",
" \"devicestorage:pictures\": {",
" \"description\": \"Need to load pictures\"",
" }",
" }",
" ],",
" \"package-identifier\": \"611FC2FE-491D-4A47-B3B3-43FBDF6F404F\",",
" \"moz-package-location\": \"https://example.com/myapp/app.pak\",",
" \"description\": \"A great app!\"",
"}\r",
"--7B0MKBI3UH\r",
"Content-Location: page2.html\r",
"Content-Type: text/html\r",
"\r",
"<html>",
" page2.html",
"</html>",
"\r",
"--7B0MKBI3UH\r",
"Content-Location: index.html\r",
"Content-Type: text/html\r",
"\r",
"<html>",
" Last updated: 2015/10/01 14:10 PST",
"</html>",
"\r",
"--7B0MKBI3UH\r",
"Content-Location: scripts/script.js\r",
"Content-Type: text/javascript\r",
"\r",
"// script.js",
"\r",
"--7B0MKBI3UH\r",
"Content-Location: scripts/library.js\r",
"Content-Type: text/javascript\r",
"\r",
"// library.js",
"\r",
"--7B0MKBI3UH--"
].join("\n");
var signedPackage = `manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgEEMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MTExOTAzMDEwNVoXDTM1MTExOTAzMDEwNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkN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RydXN0ZWQgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFRydXN0ZWQgVmFsaWQgQ0ECAQQwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MTExOTA2NTUyOFowIwYJKoZIhvcNAQkEMRYEFENKTXRUkdej+EPd/oKRhz0Cp13zMA0GCSqGSIb3DQEBAQUABIIBAGUh2vVwKqidBo7VEaEtjw3Uh1ElXLRPySu5Mmaw3yHgVhq4jAVnqm2Iwpe+C8d3Jb9Vd98NyvZfXFwu+dHKIEmOk0jQFJeO0kShaaWbK0awz08J9tSUz9WTLzNUAHiYgzNlN7j4S6fQ0d1nxW4+I0GSL6ojAsxWyeUW4QbFfuJe01/WlsVSuUBKwU5a1a7enb10OP84cIdXglm+PpKDyzk+sIyj/hyg57QXjvmLT5+QVGLUk4DmLZUGZKwGLeg4ofwGDqAH6Y+6f5wKo/sQkl7/L0n2wl4TsQwDtS7aE6Uu6uswp/du/OwLY6fpTChVfHqn8t96u/swJmMSvF/eq2g=\r
--X3JDIZCX8G\r
Content-Location: manifest.webapp\r
Content-Type: application/x-web-app-manifest+json\r
\r
{
"moz-package-origin": "http://mochi.test:8888",
"name": "My App",
"moz-resources": [
{
"src": "page2.html",
"integrity": "JREF3JbXGvZ+I1KHtoz3f46ZkeIPrvXtG4VyFQrJ7II="
},
{
"src": "index.html",
"integrity": "IjQ2S/V9qsC7wW5uv/Niq40M1aivvqH5+1GKRwUnyRg="
},
{
"src": "scripts/script.js",
"integrity": "6TqtNArQKrrsXEQWu3D9ZD8xvDRIkhyV6zVdTcmsT5Q="
},
{
"src": "scripts/library.js",
"integrity": "TN2ByXZiaBiBCvS4MeZ02UyNi44vED+KjdjLInUl4o8="
}
],
"moz-permissions": [
{
"systemXHR": {
"description": "Needed to download stuff"
},
"devicestorage:pictures": {
"description": "Need to load pictures"
}
}
],
"package-identifier": "09bc9714-7ab6-4320-9d20-fde4c237522c",
"description": "A great app!"
}\r
--X3JDIZCX8G\r
Content-Location: page2.html\r
Content-Type: text/html\r
\r
<html>
page2.html
</html>
\r
--X3JDIZCX8G\r
Content-Location: index.html\r
Content-Type: text/html\r
\r
<html>
Last updated: 2015/10/28
</html>
\r
--X3JDIZCX8G\r
Content-Location: scripts/script.js\r
Content-Type: text/javascript\r
\r
// script.js
\r
--X3JDIZCX8G\r
Content-Location: scripts/library.js\r
Content-Type: text/javascript\r
\r
// library.js
\r
--X3JDIZCX8G--`;
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<title> Web packaged app </title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="application/javascript;version=1.7">
// The test is mainly to verify whether the packageId is populated
// to the child side when loading a signed packaged content.
// Since we have to have chrome priviledge to test if the node principal
// has the expected origin attributes, we have to load and run a script
// in content to get the nodePrincipal and send back to the opener
// to check the origin.
var Cc = SpecialPowers.Cc;
var Ci = SpecialPowers.Ci;
var Cu = SpecialPowers.Cu;
var Cr = SpecialPowers.Cr;
SpecialPowers.pushPrefEnv(
{ "set": [["network.http.enable-packaged-apps", true],
["network.http.signed-packages.enabled", true],
["dom.mozBrowserFramesEnabled", true]] },
() => SpecialPowers.pushPermissions([
{ "type": "browser", "allow": 1, "context": document }
], function() {
runTest();
}));
SimpleTest.waitForExplicitFinish();
function runTest() {
var iframe = document.createElement("iframe");
// 1. We open a remote browser and navigate to a regular content first.
iframe.setAttribute('mozbrowser', 'true');
iframe.setAttribute('remote', 'true');
iframe.setAttribute("src", "http://example.org:80");
iframe.addEventListener("mozbrowserloadend", function loadend(e) {
iframe.removeEventListener("mozbrowserloadend", loadend);
ok(true, "Got mozbrowserloadend");
// 2. Then we navigate to a signed packaged content.
iframe.setAttribute("src", "http://mochi.test:8888/tests/netwerk/test/mochitests/signed_web_packaged_app.sjs!//index.html");
iframe.addEventListener("mozbrowserloadend", function loadend(e) {
iframe.removeEventListener("mozbrowserloadend", loadend);
// 3. Inject a script with chrome priviledge to content to get the nodePrincipal.
// We communicate via message manager with event 'my-e10s-extension-message'.
var mm = SpecialPowers.wrap(iframe)
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
.messageManager;
var fsl = mm.QueryInterface(Ci.nsIFrameScriptLoader);
mm.addMessageListener("get-node-principal-origin", function(message) {
let contentOrigin = message.objects.origin;
// The expected signedPkg is defined in 'signed_web_packaged_app.sjs'.
let kExpectedOrigin =
'http://mochi.test:8888^inBrowser=1&signedPkg=09bc9714-7ab6-4320-9d20-fde4c237522c';
is(contentOrigin, kExpectedOrigin, 'content origin check: ' + contentOrigin);
SimpleTest.finish();
});
// The script we are going to inject to the content.
let frameScript =
`
function getNodePrincipalOrigin() {
sendAsyncMessage("get-node-principal-origin", {}, { origin: content.document.nodePrincipal.origin });
}
`;
fsl.loadFrameScript("data:,(" + frameScript + ")()", true);
});
});
document.body.appendChild(iframe);
}
</script>
</pre>
</body>
</html>
@@ -95,10 +95,10 @@ var testData = {
}
}
var badSignature = "manifest-signature: dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk\r\n";
var goodSignature = "manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgECMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MDkxMDA4MDQzNVoXDTM1MDkxMDA4MDQzNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQ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BwEwHAYJKoZIhvcNAQkFMQ8XDTE1MTAwMTIxMTEwNlowIwYJKoZIhvcNAQkEMRYEFHAisUYrrt+gBxYFhZ5KQQusOmN3MA0GCSqGSIb3DQEBAQUABIIBACHW4V0BsPWOvWrGOTRj6mPpNbH/JI1bN2oyqQZrpUQoaBY+BbYxO7TY4Uwe+aeIR/TTPJznOMF/dl3Bna6TPabezU4ylg7TVFI6W7zC5f5DZKp+Xv6uTX6knUzbbW1fkJqMtE8hGUzYXc3/C++Ci6kuOzrpWOhk6DpJHeUO/ioV56H0+QK/oMAjYpEsOohaPqvTPNOBhMQ0OQP3bmuJ6HcjZ/oz96PpzXUPKT1tDe6VykIYkV5NvtC8Tu2lDbYvp9ug3gyDgdyNSV47y5i/iWkzEhsAJB+9Z50wKhplnkxxVHEXkB/6tmfvExvQ28gLd/VbaEGDX2ljCaTSUjhD0o0=\r\n";
var packageContent = [
function packageContent(origin) {
return [
"--7B0MKBI3UH\r",
"Content-Location: manifest.webapp\r",
"Content-Type: application/x-web-app-manifest+json\r",
@@ -134,7 +134,7 @@ var packageContent = [
" }",
" ],",
" \"package-identifier\": \"611FC2FE-491D-4A47-B3B3-43FBDF6F404F\",",
" \"moz-package-location\": \"https://example.com/myapp/app.pak\",",
" \"moz-package-origin\": \"" + origin + "\",",
" \"description\": \"A great app!\"",
"}\r",
"--7B0MKBI3UH\r",
@@ -167,6 +167,7 @@ var packageContent = [
"\r",
"--7B0MKBI3UH--"
].join("\n");
}
function contentHandler(metadata, response)
{
@@ -184,14 +185,14 @@ function regularContentHandler(metadata, response)
function contentHandlerWithBadSignature(metadata, response)
{
response.setHeader("Content-Type", 'application/package');
var body = badSignature + packageContent;
var body = badSignature + packageContent(uri);
response.bodyOutputStream.write(body, body.length);
}
function contentHandlerWithGoodSignature(metadata, response)
{
response.setHeader("Content-Type", 'application/package');
var body = goodSignature + packageContent;
var body = goodSignature + packageContent(uri);
response.bodyOutputStream.write(body, body.length);
}
@@ -222,7 +223,6 @@ function run_test()
add_test(test_channel_with_bad_signature_from_trusted_origin);
add_test(test_channel_with_bad_signature);
add_test(test_channel_with_good_signature);
// run tests
run_next_test();
+20 -3
View File
@@ -113,7 +113,8 @@ var testData = {
}
}
var signedPackage = [
function signedPackage(origin) {
return [
"manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgECAgECMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEkMCIGA1UEChMbRXhhbXBsZSBUcnVzdGVkIENvcnBvcmF0aW9uMRkwFwYDVQQDExBUcnVzdGVkIFZhbGlkIENBMB4XDTE1MDkxMDA4MDQzNVoXDTM1MDkxMDA4MDQzNVowdDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGjAYBgNVBAMTEVRydXN0ZWQgQ29ycCBDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAts8whjOzEbn/w1xkFJ67af7F/JPujBK91oyJekh2schIMzFau9pY8S1AiJQoJCulOJCJfUc8hBLKBZiGAkii+4Gpx6cVqMLe6C22MdD806Soxn8Dg4dQqbIvPuI4eeVKu5CEk80PW/BaFMmRvRHO62C7PILuH6yZeGHC4P7dTKpsk4CLxh/jRGXLC8jV2BCW0X+3BMbHBg53NoI9s1Gs7KGYnfOHbBP5wEFAa00RjHnubUaCdEBlC8Kl4X7p0S4RGb3rsB08wgFe9EmSZHIgcIm+SuVo7N4qqbI85qo2ulU6J8NN7ZtgMPHzrMhzgAgf/KnqPqwDIxnNmRNJmHTUYwIDAQABozgwNjAMBgNVHRMBAf8EAjAAMBYGA1UdJQEB/wQMMAoGCCsGAQUF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VbaEGDX2ljCaTSUjhD0o0=\r",
"--7B0MKBI3UH\r",
"Content-Location: manifest.webapp\r",
@@ -150,7 +151,7 @@ var signedPackage = [
" }",
" ],",
" \"package-identifier\": \"611FC2FE-491D-4A47-B3B3-43FBDF6F404F\",",
" \"moz-package-location\": \"https://example.com/myapp/app.pak\",",
" \"moz-package-origin\": \"" + origin + "\",",
" \"description\": \"A great app!\"",
"}\r",
"--7B0MKBI3UH\r",
@@ -183,6 +184,7 @@ var signedPackage = [
"\r",
"--7B0MKBI3UH--"
].join("\n");
};
XPCOMUtils.defineLazyGetter(this, "uri", function() {
return "http://localhost:" + httpserver.identity.primaryPort;
@@ -564,7 +566,7 @@ function test_worse_package_5() {
function signedPackagedAppContentHandler(metadata, response)
{
response.setHeader("Content-Type", 'application/package');
var body = signedPackage;
var body = signedPackage(uri);
response.bodyOutputStream.write(body, body.length);
}
@@ -580,13 +582,28 @@ let dummyCacheListener = {
onCacheEntryAvailable: function () {}
};
function setTrustedOrigin() {
let pref = "network.http.signed-packages.trusted-origin";
ok(!!Ci.nsISupportsString, "Ci.nsISupportsString");
let origin = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
origin.data = uri;
gPrefs.setComplexValue(pref, Ci.nsISupportsString, origin);
}
function resetTrustedOrigin() {
gPrefs.clearUserPref("network.http.signed-packages.trusted-origin");
}
function test_signed_package_callback()
{
setTrustedOrigin();
packagePath = "/signedPackage";
let url = uri + packagePath + "!//index.html";
let channel = getChannelForURL(url, {
onStartSignedPackageRequest: function(aPackageId) {
ok(true, "onStartSignedPackageRequest is notifited as expected");
resetTrustedOrigin();
run_next_test();
},
+3 -3
View File
@@ -1,10 +1,11 @@
const header_missing_signature = "header1: content1";
const header_invalid_signature = "header1: content1\r\nmanifest-signature: invalid-signature\r\n";
const header = "manifest-signature: MIIF1AYJKoZIhvcNAQcCoIIFxTCCBcECAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA54wggOaMIICgqADAgEC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LlHa5xDLwifvZtBP2d3c6zHp7gdrGU1u2WTGCAf4wggH6AgEBMHgwczELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MSQwIgYDVQQKExtFeGFtcGxlIFRydXN0ZWQgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFRydXN0ZWQgVmFsaWQgQ0ECAQQwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE1MTExOTAzMDEyM1owIwYJKoZIhvcNAQkEMRYEFJ7c42bSAcIZOL+r8PIsMNAXByYiMA0GCSqGSIb3DQEBAQUABIIBABPrgGwvi9bwgUEqiL9I0UpQsEEjzNvID9iSt9cicB3exQ9z3H2b47P7HOWicdYI4OQ1Gb+1OjGWJWoBbOuF+ty4HNIMlLiq+Mhm82J2fTA9h8v9BohjvjwMSECJHFQR1pp6veCrWqIvkhHLX/GcGZIr5vBmkpkcMpWKT/N8VmuNu/DKHtKiTianAWnFguAruOeL02MfKlg8mNLCQysd6qj5mbLhTvR7mtn6XaRFrHB4VSfYPerzP71/AzhVqlPRLIYQocSkRoAE+eNeMcP6RcEinKRqK0SxqmRWeSiJpkDm+5Hlx7Xs8Qamqiteyr8FN7VjkGByM0IcpH6Bd5h3trQ=\r\n";
const manifest = "Content-Location: manifest.webapp\r\n" +
"Content-Type: application/x-web-app-manifest+json\r\n\r\n" +
`{
"moz-package-origin": "http://mochi.test:8888",
"name": "My App",
"moz-resources": [
{
@@ -13,7 +14,7 @@ const manifest = "Content-Location: manifest.webapp\r\n" +
},
{
"src": "index.html",
"integrity": "zEubR310nePwd30NThIuoCxKJdnz7Mf5z+dZHUbH1SE="
"integrity": "IjQ2S/V9qsC7wW5uv/Niq40M1aivvqH5+1GKRwUnyRg="
},
{
"src": "scripts/script.js",
@@ -35,7 +36,6 @@ const manifest = "Content-Location: manifest.webapp\r\n" +
}
],
"package-identifier": "611FC2FE-491D-4A47-B3B3-43FBDF6F404F",
"moz-package-location": "https://example.com/myapp/app.pak",
"description": "A great app!"
}`;
@@ -177,7 +177,8 @@ function test_invalid_signature(aBypassVerification) {
const kManifestContent = 'Content-Location: manifest.webapp\r\n' +
'Content-Type: application/x-web-app-manifest+json\r\n' +
'\r\n' +
'{ "package-identifier": "' + kPackagedId + '" }';
'{ "package-identifier": "' + kPackagedId + '",\n' +
' "moz-package-origin": "' + kOrigin + '" }';
const expectedCallbacks = [
// URL statusCode verificationResult content
Binary file not shown.
+1
View File
@@ -3,6 +3,7 @@ skip-if = buildapp == 'b2g'
support-files = test-dir/test-file
[test_sample.xul]
[test_sanityAddTask.xul]
[test_sanityChromeUtils.xul]
skip-if = buildapp == 'mulet'
[test_sanityPluginUtils.html]
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window title="Test spawnTawk function"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"/>
<script type="application/javascript">
<![CDATA[
// Check that we can 'add_task' a few times and all tasks run asynchronously before test finishes.
add_task(function* () {
var x = yield Promise.resolve(1);
is(x, 1, "task yields Promise value as expected");
});
add_task(function* () {
var x = yield [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
is(x.join(""), "123", "task yields Promise value as expected");
});
add_task(function* () {
var x = yield (function* () {
return 3;
}());
is(x, 3, "task yields generator function return value as expected");
});
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml" >
</body>
</window>
@@ -2,6 +2,8 @@
skip-if = buildapp == 'mulet' || buildapp == 'b2g'
[test_TestsRunningAfterSimpleTestFinish.html]
skip-if = true #depends on fix for bug 1048446
[test_add_task.html]
[test_createFiles.html]
[test_sanity.html]
[test_sanityException.html]
[test_sanityException2.html]
@@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for mochitest add_task, found in SpawnTask.js</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.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=">Mozilla Bug 1187701</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
<script class="testbody" type="text/javascript">
// Check that we can 'add_task' a few times and all tasks run asynchronously before test finishes.
add_task(function* () {
var x = yield Promise.resolve(1);
is(x, 1, "task yields Promise value as expected");
});
add_task(function* () {
var x = yield [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];
is(x.join(""), "123", "task yields Promise value as expected");
});
add_task(function* () {
var x = yield (function* () {
return 3;
}());
is(x, 3, "task yields generator function return value as expected");
});
</script>
</pre>
</body>
</html>
@@ -0,0 +1,70 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for SpecialPowers.createFiles</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div id="content" class="testbody">
<script type="text/javascript">
// Creating one file, followed by failing to create a file.
function test1() {
let fdata = "this is same data for a file";
SpecialPowers.createFiles([{name: "test1.txt", data:fdata}],
function (files) {
is(files.length, 1, "Created 1 file");
let f = files[0];
is("[object File]", f.toString(), "first thing in array is a file");
is(f.size, fdata.length, "test1 size of first file should be length of its data");
is("test1.txt", f.name, "test1 test file should have the right name");
test2();
},
function (msg) { ok(false, "Should be able to create a file without an error"); test2(); }
);
}
// Failing to create a file, followed by creating a file.
function test2() {
function test3Check(passed) {
ok(passed, "Should trigger the error handler for a bad file name.");
test3();
};
SpecialPowers.createFiles([{name: "/\/\/\/\/\/\/\/\/\/\/\invalidname",}],
function () { test3Check(false); },
function (msg) { test3Check(true); }
);
}
// Creating two files at the same time.
function test3() {
let f1data = "hello";
SpecialPowers.createFiles([{name: "test3_file.txt", data:f1data}, {name: "emptyfile.txt"}],
function (files) {
is(files.length, 2, "Expected two files to be created");
let f1 = files[0];
let f2 = files[1];
is("[object File]", f1.toString(), "first thing in array is a file");
is("[object File]", f2.toString(), "second thing in array is a file");
is("test3_file.txt", f1.name, "first test3 test file should have the right name");
is("emptyfile.txt", f2.name, "second test3 test file should have the right name");
is(f1.size, f1data.length, "size of first file should be length of its data");
is(f2.size, 0, "size of second file should be 0");
SimpleTest.finish();
},
function (msg) {
ok(false, "Failed to create files: " + msg);
SimpleTest.finish();
}
);
};
SimpleTest.waitForExplicitFinish();
test1();
</script>
</div>
</body>
</html>
@@ -1007,6 +1007,8 @@ SimpleTest.finish = function() {
}
var afterCleanup = function() {
SpecialPowers.removeFiles();
if (SpecialPowers.DOMWindowUtils.isTestControllingRefreshes) {
SimpleTest.ok(false, "test left refresh driver under test control");
SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
@@ -11,6 +11,7 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.importGlobalProperties(['File']);
if (typeof(Cc) == "undefined") {
const Cc = Components.classes;
@@ -81,6 +82,8 @@ SpecialPowersObserver.prototype = new SpecialPowersObserverAPI();
this._messageManager.addMessageListener("SPPingService", this);
this._messageManager.addMessageListener("SpecialPowers.Quit", this);
this._messageManager.addMessageListener("SpecialPowers.Focus", this);
this._messageManager.addMessageListener("SpecialPowers.CreateFiles", this);
this._messageManager.addMessageListener("SpecialPowers.RemoveFiles", this);
this._messageManager.addMessageListener("SPPermissionManager", this);
this._messageManager.addMessageListener("SPWebAppService", this);
this._messageManager.addMessageListener("SPObserverService", this);
@@ -94,6 +97,7 @@ SpecialPowersObserver.prototype = new SpecialPowersObserverAPI();
this._messageManager.loadFrameScript(CHILD_SCRIPT_API, true);
this._messageManager.loadFrameScript(CHILD_SCRIPT, true);
this._isFrameScriptLoaded = true;
this._createdFiles = null;
}
};
@@ -140,6 +144,8 @@ SpecialPowersObserver.prototype = new SpecialPowersObserverAPI();
this._messageManager.removeMessageListener("SPPingService", this);
this._messageManager.removeMessageListener("SpecialPowers.Quit", this);
this._messageManager.removeMessageListener("SpecialPowers.Focus", this);
this._messageManager.removeMessageListener("SpecialPowers.CreateFiles", this);
this._messageManager.removeMessageListener("SpecialPowers.RemoveFiles", this);
this._messageManager.removeMessageListener("SPPermissionManager", this);
this._messageManager.removeMessageListener("SPWebAppService", this);
this._messageManager.removeMessageListener("SPObserverService", this);
@@ -208,6 +214,50 @@ getService(Ci.nsIMessageBroadcaster);
case "SpecialPowers.Focus":
aMessage.target.focus();
break;
case "SpecialPowers.CreateFiles":
let filePaths = new Array;
if (!this.createdFiles) {
this._createdFiles = new Array;
}
let createdFiles = this._createdFiles;
try {
aMessage.data.forEach(function(request) {
let testFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
testFile.append(request.name);
let outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE
0666, 0);
if (request.data) {
outStream.write(request.data, request.data.length);
outStream.close();
}
filePaths.push(new File(testFile.path));
createdFiles.push(testFile);
});
aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
.messageManager
.sendAsyncMessage("SpecialPowers.FilesCreated", filePaths);
} catch (e) {
aMessage.target
.QueryInterface(Ci.nsIFrameLoaderOwner)
.frameLoader
.messageManager
.sendAsyncMessage("SpecialPowers.FilesError", e.toString());
}
break;
case "SpecialPowers.RemoveFiles":
if (this._createdFiles) {
this._createdFiles.forEach(function (testFile) {
try {
testFile.remove(false);
} catch (e) {}
});
this._createdFiles = null;
}
break;
default:
return this._receiveMessage(aMessage);
}
@@ -24,6 +24,8 @@ function SpecialPowers(window) {
this._pongHandlers = [];
this._messageListener = this._messageReceived.bind(this);
this._grandChildFrameMM = null;
this._createFilesOnError = null;
this._createFilesOnSuccess = null;
this.SP_SYNC_MESSAGES = ["SPChromeScriptMessage",
"SPLoadChromeScript",
"SPObserverService",
@@ -36,9 +38,13 @@ function SpecialPowers(window) {
this.SP_ASYNC_MESSAGES = ["SpecialPowers.Focus",
"SpecialPowers.Quit",
"SpecialPowers.CreateFiles",
"SpecialPowers.RemoveFiles",
"SPPingService",
"SPQuotaManager"];
addMessageListener("SPPingService", this._messageListener);
addMessageListener("SpecialPowers.FilesCreated", this._messageListener);
addMessageListener("SpecialPowers.FilesError", this._messageListener);
let self = this;
Services.obs.addObserver(function onInnerWindowDestroyed(subject, topic, data) {
var id = subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data;
@@ -46,6 +52,8 @@ function SpecialPowers(window) {
Services.obs.removeObserver(onInnerWindowDestroyed, "inner-window-destroyed");
try {
removeMessageListener("SPPingService", self._messageListener);
removeMessageListener("SpecialPowers.FilesCreated", self._messageListener);
removeMessageListener("SpecialPowers.FilesError", self._messageListener);
} catch (e if e.result == Components.results.NS_ERROR_ILLEGAL_VALUE) {
// Ignore the exception which the message manager has been destroyed.
;
@@ -118,7 +126,26 @@ SpecialPowers.prototype._messageReceived = function(aMessage) {
}
}
break;
case "SpecialPowers.FilesCreated":
var handler = this._createFilesOnSuccess;
this._createFilesOnSuccess = null;
this._createFilesOnError = null;
if (handler) {
handler(aMessage.data);
}
break;
case "SpecialPowers.FilesError":
var handler = this._createFilesOnError;
this._createFilesOnSuccess = null;
this._createFilesOnError = null;
if (handler) {
handler(aMessage.data);
}
break;
}
return true;
};
@@ -126,6 +153,27 @@ SpecialPowers.prototype.quit = function() {
sendAsyncMessage("SpecialPowers.Quit", {});
};
// fileRequests is an array of file requests. Each file request is an object.
// A request must have a field |name|, which gives the base of the name of the
// file to be created in the profile directory. If the request has a |data| field
// then that data will be written to the file.
SpecialPowers.prototype.createFiles = function(fileRequests, onCreation, onError) {
if (this._createFilesOnSuccess || this._createFilesOnError) {
onError("Already waiting for SpecialPowers.createFiles() to finish.");
return;
}
this._createFilesOnSuccess = onCreation;
this._createFilesOnError = onError;
sendAsyncMessage("SpecialPowers.CreateFiles", fileRequests);
};
// Remove the files that were created using |SpecialPowers.createFiles()|.
// This will be automatically called by |SimpleTest.finish()|.
SpecialPowers.prototype.removeFiles = function() {
sendAsyncMessage("SpecialPowers.RemoveFiles", {});
};
SpecialPowers.prototype.executeAfterFlushingMessageQueue = function(aCallback) {
this._pongHandlers.push(aCallback);
sendAsyncMessage("SPPingService", { op: "ping" });
@@ -29,3 +29,6 @@ EXTRA_PP_JS_MODULES += [
FINAL_LIBRARY = 'xul'
CXXFLAGS += CONFIG['TK_CFLAGS']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -16,3 +16,6 @@ SOURCES += [
]
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -33,3 +33,6 @@ FINAL_LIBRARY = 'xul'
with Files('**'):
BUG_COMPONENT = ('Toolkit', 'OS.File')
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
@@ -29,3 +29,6 @@ if not CONFIG['MOZ_DISABLE_PARENTAL_CONTROLS']:
]
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -19,3 +19,6 @@ LOCAL_INCLUDES += [
]
MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -13,3 +13,6 @@ EXTRA_JS_MODULES += [
]
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -48,3 +48,6 @@ EXTRA_PP_JS_MODULES += [
FINAL_LIBRARY = 'xul'
JAR_MANIFESTS += ['jar.mn']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -36,3 +36,6 @@ FINAL_LIBRARY = 'xul'
with Files('**'):
BUG_COMPONENT = ('Toolkit', 'Startup and Profile System')
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
@@ -9,3 +9,6 @@ SOURCES += [
]
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
@@ -105,6 +105,13 @@
"high": "1000",
"n_buckets": 50
},
"COMPOSITE_FRAME_ROUNDTRIP_TIME" : {
"expires_in_version": "never",
"description": "Time from vsync to finishing a composite in milliseconds.",
"kind": "exponential",
"high": "1000",
"n_buckets": 50
},
"CYCLE_COLLECTOR": {
"expires_in_version": "never",
"kind": "exponential",
+3
View File
@@ -20,3 +20,6 @@ EXTRA_COMPONENTS += [
]
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
@@ -20,3 +20,6 @@ JAR_MANIFESTS += ['jar.mn']
with Files('**'):
BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+1
View File
@@ -15,6 +15,7 @@
#include "js/UbiNodeCensus.h"
#include "js/UbiNodeDominatorTree.h"
#include "mozilla/Attributes.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/devtools/AutoMemMap.h"
#include "mozilla/devtools/CoreDump.pb.h"
#include "mozilla/devtools/DeserializedNode.h"
+20 -1
View File
@@ -26,12 +26,16 @@ DIRS += [
if CONFIG['MOZ_UPDATER'] and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
DIRS += ['mozapps/update']
if CONFIG['MOZ_MAINTENANCE_SERVICE']:
if CONFIG['MOZ_MAINTENANCE_SERVICE'] or CONFIG['MOZ_UPDATER'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
# Including mozapps/update/common-standalone allows the maintenance service
# to be built so the maintenance service can be used for things other than
# updating applications.
DIRS += [
'mozapps/update/common-standalone',
]
if CONFIG['MOZ_MAINTENANCE_SERVICE']:
DIRS += [
'components/maintenanceservice'
]
@@ -46,6 +50,21 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['system/androidproxy']
if CONFIG['MOZ_CRASHREPORTER']:
DIRS += ['crashreporter']
elif CONFIG['MOZ_ENABLE_PROFILER_SPS']:
# Profiler requires some crashreporter code,
# so build it even if crashreporter is disabled.
DIRS += [
'crashreporter/breakpad-logging',
'crashreporter/google-breakpad/src/common',
'crashreporter/google-breakpad/src/processor',
]
if CONFIG['OS_ARCH'] == 'Darwin':
DIRS += ['crashreporter/google-breakpad/src/common/mac']
elif CONFIG['OS_ARCH'] == 'Linux':
DIRS += ['crashreporter/google-breakpad/src/common/linux']
with Files('mozapps/installer/windows/*'):
BUG_COMPONENT = ('Toolkit', 'NSIS Installer')
+142
View File
@@ -0,0 +1,142 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function
from distutils.version import StrictVersion
from mach.decorators import (
Command,
CommandArgument,
CommandProvider,
)
from mozbuild.base import (
MachCommandBase,
MachCommandConditions as conditions,
)
def is_osx_10_10_or_greater(cls):
import platform
release = platform.mac_ver()[0]
return release and StrictVersion(release) >= StrictVersion('10.10')
@CommandProvider
class MachCommands(MachCommandBase):
'''
Get system power consumption and related measurements.
'''
def __init__(self, context):
MachCommandBase.__init__(self, context)
@Command('power', category='misc',
conditions=[is_osx_10_10_or_greater],
description='Get system power consumption and related measurements for '
'all running browsers. Available only on Mac OS X 10.10 and above. '
'Requires root access.')
@CommandArgument('-i', '--interval', type=int, default=30000,
help='The sample period, measured in milliseconds. Defaults to 30000.')
def power(self, interval):
import os
import re
import subprocess
rapl = os.path.join(self.topobjdir, 'dist', 'bin', 'rapl')
interval = str(interval)
# Run a trivial command with |sudo| to gain temporary root privileges
# before |rapl| and |powermetrics| are called. This ensures that |rapl|
# doesn't start measuring while |powermetrics| is waiting for the root
# password to be entered.
try:
subprocess.check_call(['sudo', 'true'])
except:
print('\nsudo failed; aborting')
return 1
# This runs rapl in the background because nothing in this script
# depends on the output. This is good because we want |rapl| and
# |powermetrics| to run at the same time.
subprocess.Popen([rapl, '-n', '1', '-i', interval])
lines = subprocess.check_output(['sudo', 'powermetrics',
'--samplers', 'tasks',
'--show-process-coalition',
'--show-process-gpu',
'-n', '1',
'-i', interval])
# When run with --show-process-coalition, |powermetrics| groups outputs
# into process coalitions, each of which has a leader.
#
# For example, when Firefox runs from the dock, its coalition looks
# like this:
#
# org.mozilla.firefox
# firefox
# plugin-container
#
# When Safari runs from the dock:
#
# com.apple.Safari
# Safari
# com.apple.WebKit.Networking
# com.apple.WebKit.WebContent
# com.apple.WebKit.WebContent
#
# When Chrome runs from the dock:
#
# com.google.Chrome
# Google Chrome
# Google Chrome Helper
# Google Chrome Helper
#
# In these cases, we want to print the whole coalition.
#
# Also, when you run any of them from the command line, things are the
# same except that the leader is com.apple.Terminal and there may be
# non-browser processes in the coalition, e.g.:
#
# com.apple.Terminal
# firefox
# plugin-container
# <and possibly other, non-browser processes>
#
# Also, the WindowServer and kernel coalitions and processes are often
# relevant.
#
# We want to print all these but omit uninteresting coalitions. We
# could do this by properly parsing powermetrics output, but it's
# simpler and more robust to just grep for a handful of identifying
# strings.
print() # blank line between |rapl| output and |powermetrics| output
for line in lines.splitlines():
# Search for the following things.
#
# - '^Name' is for the columns headings line.
#
# - 'firefox' and 'plugin-container' are for Firefox
#
# - 'Safari\b' and 'WebKit' are for Safari. The '\b' excludes
# SafariCloudHistoryPush, which is a process that always
# runs, even when Safari isn't open.
#
# - 'Chrome' is for Chrome.
#
# - 'Terminal' is for the terminal. If no browser is running from
# within the terminal, it will show up unnecessarily. This is a
# minor disadvantage of this very simple parsing strategy.
#
# - 'WindowServer' is for the WindowServer.
#
# - 'kernel' is for the kernel.
#
if re.search(r'(^Name|firefox|plugin-container|Safari\b|WebKit|Chrome|Terminal|WindowServer|kernel)', line):
print(line)
return 0
+11 -2
View File
@@ -4,9 +4,18 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if (CONFIG['OS_ARCH'] == 'Darwin' and CONFIG['CPU_ARCH'] == 'x86_64') or \
(CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android'):
do_rapl = False
if CONFIG['OS_ARCH'] == 'Darwin' and CONFIG['CPU_ARCH'] == 'x86_64':
do_rapl = True
if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android' and \
CONFIG['CPU_ARCH'] in ('x86', 'x86_64'):
do_rapl = True
if do_rapl:
SimplePrograms([
'rapl',
])
DISABLE_STL_WRAPPING = True
+129 -20
View File
@@ -34,6 +34,7 @@
#include <assert.h>
#include <getopt.h>
#include <math.h>
#include <signal.h>
#include <stdarg.h>
#include <stdint.h>
@@ -43,6 +44,10 @@
#include <sys/time.h>
#include <unistd.h>
#include <algorithm>
#include <numeric>
#include <vector>
//---------------------------------------------------------------------------
// Utilities
//---------------------------------------------------------------------------
@@ -76,6 +81,19 @@ CmdLineAbort(const char* aMsg)
// A special value that represents an estimate from an unsupported RAPL domain.
static const double kUnsupported_j = -1.0;
// Print to stdout and flush it, so that the output appears immediately even if
// being redirected through |tee| or anything like that.
static void
PrintAndFlush(const char* aFormat, ...)
{
va_list vargs;
va_start(vargs, aFormat);
vfprintf(stdout, aFormat, vargs);
va_end(vargs);
fflush(stdout);
}
//---------------------------------------------------------------------------
// Mac-specific code
//---------------------------------------------------------------------------
@@ -372,12 +390,12 @@ public:
aCores_J = Joules(mPkes->pp0_energy - mPrevPp0Ticks, joulesPerTick);
aGpu_J = mIsGpuSupported
? Joules(mPkes->pp1_energy - mPrevPp1Ticks, joulesPerTick)
: -kUnsupported_j;
: kUnsupported_j;
aRam_J = mIsRamSupported
? Joules(mPkes->ddr_energy - mPrevDdrTicks,
mHasRamUnitsQuirk ? kQuirkyRamJoulesPerTick
: joulesPerTick)
: -kUnsupported_j;
: kUnsupported_j;
mPrevPkgTicks = mPkes->pkg_energy;
mPrevPp0Ticks = mPkes->pp0_energy;
@@ -454,7 +472,9 @@ public:
&config)) {
// Failure is allowed for optional domains.
if (aOptional == NonOptional) {
Abort("failed to open file for non-optional domain '%s'", aName);
Abort("failed to open file for non-optional domain '%s'\n"
"- Is your kernel version 3.14 or later, as required? "
"Run |uname -r| to see.", aName);
}
mIsSupported = false;
return;
@@ -483,8 +503,8 @@ public:
/* group_fd = */ -1, /* flags = */ 0);
if (mFd < 0) {
Abort("perf_event_open() failed\n"
"Did you run as root or "
"set /proc/sys/kernel/perf_event_paranoid to 0?");
"- Did you run as root (e.g. with |sudo|) or set\n"
" /proc/sys/kernel/perf_event_paranoid to 0, as required?");
}
mPrevTicks = 0;
@@ -500,7 +520,7 @@ public:
double EnergyEstimate()
{
if (!mIsSupported) {
return -kUnsupported_j;
return kUnsupported_j;
}
uint64_t thisTicks;
@@ -575,6 +595,17 @@ static double gSampleInterval_sec;
// The platform-specific RAPL-reading machinery.
static RAPL* gRapl;
// All the sampled "total" values, in Watts.
static std::vector<double> gTotals_W;
// Power = Energy / Time, where power is measured in Watts, Energy is measured
// in Joules, and Time is measured in seconds.
static double
JoulesToWatts(double aJoules)
{
return aJoules / gSampleInterval_sec;
}
// "Normalize" here means convert kUnsupported_j to zero so it can be used in
// additive expressions. All printed values are 5 or maybe 6 chars (though 6
// chars would require a value > 100 W, which is unlikely).
@@ -585,12 +616,12 @@ NormalizeAndPrintAsWatts(char* aBuf, double& aValue_J)
aValue_J = 0;
sprintf(aBuf, "%s", " n/a ");
} else {
sprintf(aBuf, "%5.2f", aValue_J / gSampleInterval_sec);
sprintf(aBuf, "%5.2f", JoulesToWatts(aValue_J));
}
}
static void
SigprofHandler(int aSigNum, siginfo_t* aInfo, void* aContext)
SigAlrmHandler(int aSigNum, siginfo_t* aInfo, void* aContext)
{
static int sampleNumber = 1;
@@ -620,15 +651,85 @@ SigprofHandler(int aSigNum, siginfo_t* aInfo, void* aContext)
// other values have been normalized.
char otherStr[kNumStrLen];
double other = pkg_J - cores_J - gpu_J;
NormalizeAndPrintAsWatts(otherStr, other);
double other_J = pkg_J - cores_J - gpu_J;
NormalizeAndPrintAsWatts(otherStr, other_J);
char totalStr[kNumStrLen];
double total = pkg_J + ram_J;
NormalizeAndPrintAsWatts(totalStr, total);
double total_J = pkg_J + ram_J;
NormalizeAndPrintAsWatts(totalStr, total_J);
printf("#%02d %s W = %s (%s + %s + %s) + %s W\n",
sampleNumber++, totalStr, pkgStr, coresStr, gpuStr, otherStr, ramStr);
gTotals_W.push_back(JoulesToWatts(total_J));
// Print and flush so that the output appears immediately even if being
// redirected through |tee| or anything like that.
PrintAndFlush("#%02d %s W = %s (%s + %s + %s) + %s W\n",
sampleNumber++, totalStr, pkgStr, coresStr, gpuStr, otherStr,
ramStr);
}
static void
Finish()
{
size_t n = gTotals_W.size();
// This time calculation assumes that the timers are perfectly accurate which
// is not true but the inaccuracy should be small in practice.
double time = n * gSampleInterval_sec;
printf("\n");
printf("%d sample%s taken over a period of %.3f second%s\n",
int(n), n == 1 ? "" : "s",
n * gSampleInterval_sec, time == 1.0 ? "" : "s");
if (n == 0 || n == 1) {
exit(0);
}
// Compute the mean.
double sum = std::accumulate(gTotals_W.begin(), gTotals_W.end(), 0.0);
double mean = sum / n;
// Compute the *population* standard deviation:
//
// popStdDev = sqrt(Sigma(x - m)^2 / n)
//
// where |x| is the sum variable, |m| is the mean, and |n| is the
// population size.
//
// This is different from the *sample* standard deviation, which divides by
// |n - 1|, and would be appropriate if we were using a random sample of a
// larger population.
double sumOfSquaredDeviations = 0;
for (auto iter = gTotals_W.begin(); iter != gTotals_W.end(); ++iter) {
double deviation = (*iter - mean);
sumOfSquaredDeviations += deviation * deviation;
}
double popStdDev = sqrt(sumOfSquaredDeviations / n);
// Sort so that percentiles can be determined. We use the "Nearest Rank"
// method of determining percentiles, which is simplest to compute and which
// chooses values from those that appear in the input set.
std::sort(gTotals_W.begin(), gTotals_W.end());
printf("\n");
printf("Distribution of 'total' values:\n");
printf(" mean = %5.2f W\n", mean);
printf(" std dev = %5.2f W\n", popStdDev);
printf(" 0th percentile = %5.2f W (min)\n", gTotals_W[0]);
printf(" 5th percentile = %5.2f W\n", gTotals_W[ceil(0.05 * n) - 1]);
printf(" 25th percentile = %5.2f W\n", gTotals_W[ceil(0.25 * n) - 1]);
printf(" 50th percentile = %5.2f W\n", gTotals_W[ceil(0.50 * n) - 1]);
printf(" 75th percentile = %5.2f W\n", gTotals_W[ceil(0.75 * n) - 1]);
printf(" 95th percentile = %5.2f W\n", gTotals_W[ceil(0.95 * n) - 1]);
printf("100th percentile = %5.2f W (max)\n", gTotals_W[n - 1]);
exit(0);
}
static void
SigIntHandler(int aSigNum, siginfo_t* aInfo, void *aContext)
{
Finish();
}
static void
@@ -732,16 +833,23 @@ main(int argc, char** argv)
Abort("new RAPL() failed");
}
// Install the signal handler.
// Install the signal handlers.
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = SigprofHandler;
sa.sa_flags = SA_RESTART | SA_SIGINFO;
if (sigemptyset(&sa.sa_mask) < 0) {
// The extra parens around (0) suppress a -Wunreachable-code warning on OS X
// where sigemptyset() is a macro that can never fail and always returns 0.
if (sigemptyset(&sa.sa_mask) < (0)) {
Abort("sigemptyset() failed");
}
sa.sa_sigaction = SigAlrmHandler;
if (sigaction(SIGALRM, &sa, NULL) < 0) {
Abort("sigaction() failed");
Abort("sigaction(SIGALRM) failed");
}
sa.sa_sigaction = SigIntHandler;
if (sigaction(SIGINT, &sa, NULL) < 0) {
Abort("sigaction(SIGINT) failed");
}
// Set up the timer.
@@ -754,7 +862,7 @@ main(int argc, char** argv)
}
// Print header.
printf(" total W = _pkg_ (cores + _gpu_ + other) + _ram_ W\n");
PrintAndFlush(" total W = _pkg_ (cores + _gpu_ + other) + _ram_ W\n");
// Take samples.
if (sampleCount == 0) {
@@ -767,6 +875,7 @@ main(int argc, char** argv)
}
}
Finish();
return 0;
}
+1 -1
View File
@@ -113,7 +113,7 @@ public:
bool mWantReplyFromContentProcess : 1;
// The event's action will be handled by APZ. The main thread should not
// perform its associated action. This is currently only relevant for
// wheel events.
// wheel and touch events.
bool mHandledByAPZ : 1;
// If the event is being handled in target phase, returns true.
+4
View File
@@ -86,6 +86,7 @@ MouseInput::TransformToLocal(const gfx::Matrix4x4& aTransform)
MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
: InputData(MULTITOUCH_INPUT, aTouchEvent.time, aTouchEvent.timeStamp,
aTouchEvent.modifiers)
, mHandledByAPZ(aTouchEvent.mFlags.mHandledByAPZ)
{
MOZ_ASSERT(NS_IsMainThread(),
"Can only copy from WidgetTouchEvent on main thread");
@@ -162,6 +163,7 @@ MultiTouchInput::ToWidgetTouchEvent(nsIWidget* aWidget) const
event.modifiers = this->modifiers;
event.time = this->mTime;
event.timeStamp = this->mTimeStamp;
event.mFlags.mHandledByAPZ = mHandledByAPZ;
for (size_t i = 0; i < mTouches.Length(); i++) {
*event.touches.AppendElement() = mTouches[i].ToNewDOMTouch();
@@ -204,6 +206,7 @@ MultiTouchInput::ToWidgetMouseEvent(nsIWidget* aWidget) const
event.button = WidgetMouseEvent::eLeftButton;
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
event.modifiers = modifiers;
event.mFlags.mHandledByAPZ = mHandledByAPZ;
if (mouseEventMessage != eMouseMove) {
event.clickCount = 1;
@@ -232,6 +235,7 @@ MultiTouchInput::IndexOfTouch(int32_t aTouchIdentifier)
MultiTouchInput::MultiTouchInput(const WidgetMouseEvent& aMouseEvent)
: InputData(MULTITOUCH_INPUT, aMouseEvent.time, aMouseEvent.timeStamp,
aMouseEvent.modifiers)
, mHandledByAPZ(aMouseEvent.mFlags.mHandledByAPZ)
{
MOZ_ASSERT(NS_IsMainThread(),
"Can only copy from WidgetMouseEvent on main thread");
+6 -2
View File
@@ -208,13 +208,15 @@ public:
MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp,
Modifiers aModifiers)
: InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers),
mType(aType)
: InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers)
, mType(aType)
, mHandledByAPZ(false)
{
}
MultiTouchInput()
: InputData(MULTITOUCH_INPUT)
, mHandledByAPZ(false)
{
}
@@ -222,6 +224,7 @@ public:
: InputData(MULTITOUCH_INPUT, aOther.mTime,
aOther.mTimeStamp, aOther.modifiers)
, mType(aOther.mType)
, mHandledByAPZ(aOther.mHandledByAPZ)
{
mTouches.AppendElements(aOther.mTouches);
}
@@ -246,6 +249,7 @@ public:
MultiTouchType mType;
nsTArray<SingleTouchData> mTouches;
bool mHandledByAPZ;
};
class MouseInput : public InputData
+1
View File
@@ -174,6 +174,7 @@ public:
timeStamp = aOther.timeStamp;
touches.AppendElements(aOther.touches);
mFlags.mCancelable = mMessage != eTouchCancel;
mFlags.mHandledByAPZ = aOther.mFlags.mHandledByAPZ;
MOZ_COUNT_CTOR(WidgetTouchEvent);
}
+2 -2
View File
@@ -1936,8 +1936,8 @@ TextInputHandler::HandleFlagsChanged(NSEvent* aNativeEvent)
timestamp:[aNativeEvent timestamp]
windowNumber:[aNativeEvent windowNumber]
context:[aNativeEvent context]
characters:nil
charactersIgnoringModifiers:nil
characters:@""
charactersIgnoringModifiers:@""
isARepeat:NO
keyCode:keyCode];
DispatchKeyEventForFlagsChanged(event, dispatchKeyDown);
+2 -2
View File
@@ -94,7 +94,7 @@ public:
protected:
virtual ~nsNativeThemeCocoa();
nsIntMargin RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
nsIntMargin DirectionAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame);
nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
CGRect SeparatorAdjustedRect(CGRect aRect, nsIFrame* aLeft,
nsIFrame* aCurrent, nsIFrame* aRight);
@@ -124,7 +124,7 @@ protected:
nsIFrame* aFrame);
void DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
mozilla::EventStates inState, nsIFrame* aFrame,
const NSSize& aIconSize, const NSString* aImageName,
const NSSize& aIconSize, NSString* aImageName,
bool aCenterHorizontally);
void DrawButton(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, bool inIsDefault,
+102 -35
View File
@@ -526,24 +526,24 @@ nsNativeThemeCocoa::nsNativeThemeCocoa()
// before the main event-loop pool is in place
nsAutoreleasePool pool;
mDisclosureButtonCell = [[NSButtonCell alloc] initTextCell:nil];
mDisclosureButtonCell = [[NSButtonCell alloc] initTextCell:@""];
[mDisclosureButtonCell setBezelStyle:NSRoundedDisclosureBezelStyle];
[mDisclosureButtonCell setButtonType:NSPushOnPushOffButton];
[mDisclosureButtonCell setHighlightsBy:NSPushInCellMask];
mHelpButtonCell = [[NSButtonCell alloc] initTextCell:nil];
mHelpButtonCell = [[NSButtonCell alloc] initTextCell:@""];
[mHelpButtonCell setBezelStyle:NSHelpButtonBezelStyle];
[mHelpButtonCell setButtonType:NSMomentaryPushInButton];
[mHelpButtonCell setHighlightsBy:NSPushInCellMask];
mPushButtonCell = [[NSButtonCell alloc] initTextCell:nil];
mPushButtonCell = [[NSButtonCell alloc] initTextCell:@""];
[mPushButtonCell setButtonType:NSMomentaryPushInButton];
[mPushButtonCell setHighlightsBy:NSPushInCellMask];
mRadioButtonCell = [[RadioButtonCell alloc] initTextCell:nil];
mRadioButtonCell = [[RadioButtonCell alloc] initTextCell:@""];
[mRadioButtonCell setButtonType:NSRadioButton];
mCheckboxCell = [[CheckboxCell alloc] initTextCell:nil];
mCheckboxCell = [[CheckboxCell alloc] initTextCell:@""];
[mCheckboxCell setButtonType:NSSwitchButton];
[mCheckboxCell setAllowsMixedState:YES];
@@ -768,10 +768,10 @@ struct CellRenderSettings {
NSSize minimumSizes[3];
// A three-dimensional array,
// with the first dimension being the OS version (only Leopard for the moment),
// with the first dimension being the OS version ([0] 10.6-10.9, [1] 10.10 and above),
// the second being the control size (mini, small, regular), and the third
// being the 4 margin values (left, top, right, bottom).
float margins[1][3][4];
float margins[2][3][4];
};
/*
@@ -867,6 +867,8 @@ static void DrawCellWithSnapping(NSCell *cell,
// Snap to the smaller control size.
controlSize = smallerControlSize;
sizeIndex = smallerControlSizeIndex;
MOZ_ASSERT(sizeIndex < ArrayLength(settings.naturalSizes));
// Resize and center the drawRect.
if (sizes[sizeIndex].width) {
drawRect.origin.x += ceil((destRect.size.width - sizes[sizeIndex].width) / 2);
@@ -885,7 +887,8 @@ static void DrawCellWithSnapping(NSCell *cell,
[cell setControlSize:controlSize];
NSSize minimumSize = settings.minimumSizes ? settings.minimumSizes[sizeIndex] : NSZeroSize;
MOZ_ASSERT(sizeIndex < ArrayLength(settings.minimumSizes));
const NSSize minimumSize = settings.minimumSizes[sizeIndex];
DrawCellWithScaling(cell, cgContext, drawRect, controlSize, sizes[sizeIndex],
minimumSize, settings.margins, view, mirrorHorizontal);
@@ -994,6 +997,11 @@ static const CellRenderSettings radioSettings = {
{0, 0, 0, 0}, // mini
{0, 1, 1, 1}, // small
{0, 0, 0, 0} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{1, 1, 1, 2}, // small
{0, 0, 0, 0} // regular
}
}
};
@@ -1012,6 +1020,11 @@ static const CellRenderSettings checkboxSettings = {
{0, 1, 0, 0}, // mini
{0, 1, 0, 1}, // small
{0, 1, 0, 1} // regular
},
{ // Yosemite
{0, 1, 0, 0}, // mini
{0, 1, 0, 1}, // small
{0, 1, 0, 1} // regular
}
}
};
@@ -1065,6 +1078,11 @@ static const CellRenderSettings searchFieldSettings = {
{0, 0, 0, 0}, // mini
{0, 0, 0, 0}, // small
{0, 0, 0, 0} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{0, 0, 0, 0}, // small
{0, 0, 0, 0} // regular
}
}
};
@@ -1094,17 +1112,17 @@ static const NSSize kCheckmarkSize = NSMakeSize(11, 11);
static const NSSize kMenuarrowSize = nsCocoaFeatures::OnLionOrLater() ?
NSMakeSize(9, 10) : NSMakeSize(8, 10);
static const NSSize kMenuScrollArrowSize = NSMakeSize(10, 8);
static const NSString* kCheckmarkImage = @"image.MenuOnState";
static const NSString* kMenuarrowRightImage = @"image.MenuSubmenu";
static const NSString* kMenuarrowLeftImage = @"image.MenuSubmenuLeft";
static const NSString* kMenuDownScrollArrowImage = @"image.MenuScrollDown";
static const NSString* kMenuUpScrollArrowImage = @"image.MenuScrollUp";
static NSString* kCheckmarkImage = @"MenuOnState";
static NSString* kMenuarrowRightImage = @"MenuSubmenu";
static NSString* kMenuarrowLeftImage = @"MenuSubmenuLeft";
static NSString* kMenuDownScrollArrowImage = @"MenuScrollDown";
static NSString* kMenuUpScrollArrowImage = @"MenuScrollUp";
static const CGFloat kMenuIconIndent = 6.0f;
void
nsNativeThemeCocoa::DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
EventStates inState, nsIFrame* aFrame,
const NSSize& aIconSize, const NSString* aImageName,
const NSSize& aIconSize, NSString* aImageName,
bool aCenterHorizontally)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@@ -1134,10 +1152,16 @@ nsNativeThemeCocoa::DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect,
NSString* backgroundTypeKey = !otherKeysAndValues ? @"kCUIBackgroundTypeMenu" :
!isDisabled && isActive ? @"backgroundTypeDark" : @"backgroundTypeLight";
NSString* imageName = aImageName;
if (!nsCocoaFeatures::OnElCapitanOrLater()) {
// Pre-10.11, image names are prefixed with "image."
imageName = [@"image." stringByAppendingString:aImageName];
}
NSMutableArray* keys = [NSMutableArray arrayWithObjects:@"backgroundTypeKey",
@"imageNameKey", @"state", @"widget", @"is.flipped", nil];
NSMutableArray* values = [NSMutableArray arrayWithObjects: backgroundTypeKey,
aImageName, state, @"image", [NSNumber numberWithBool:YES], nil];
imageName, state, @"image", [NSNumber numberWithBool:YES], nil];
if (otherKeysAndValues) { // Earlier versions used one more key-value pair.
[keys insertObject:@"imageIsGrayscaleKey" atIndex:1];
@@ -1175,6 +1199,11 @@ static const CellRenderSettings pushButtonSettings = {
{0, 0, 0, 0}, // mini
{4, 0, 4, 1}, // small
{5, 0, 5, 2} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{4, 0, 4, 1}, // small
{5, 0, 5, 2} // regular
}
}
};
@@ -1443,6 +1472,11 @@ static const CellRenderSettings dropdownSettings = {
{1, 1, 2, 1}, // mini
{3, 0, 3, 1}, // small
{3, 0, 3, 0} // regular
},
{ // Yosemite
{1, 1, 2, 1}, // mini
{3, 0, 3, 1}, // small
{3, 0, 3, 0} // regular
}
}
};
@@ -1463,6 +1497,11 @@ static const CellRenderSettings editableMenulistSettings = {
{0, 0, 2, 2}, // mini
{0, 0, 3, 2}, // small
{0, 1, 3, 3} // regular
},
{ // Yosemite
{0, 0, 2, 2}, // mini
{0, 0, 3, 2}, // small
{0, 1, 3, 3} // regular
}
}
};
@@ -1507,6 +1546,11 @@ static const CellRenderSettings spinnerSettings = {
{0, 0, 0, 0}, // mini
{0, 0, 0, 0}, // small
{0, 0, 0, 0} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{0, 0, 0, 0}, // small
{0, 0, 0, 0} // regular
}
}
};
@@ -1673,6 +1717,11 @@ static const CellRenderSettings progressSettings[2][2] = {
{0, 0, 0, 0}, // mini
{1, 1, 1, 1}, // small
{1, 0, 1, 0} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{1, 1, 1, 1}, // small
{1, 0, 1, 0} // regular
}
}
}
@@ -1694,6 +1743,11 @@ static const CellRenderSettings progressSettings[2][2] = {
{0, 0, 0, 0}, // mini
{1, 1, 1, 1}, // small
{1, 1, 1, 1} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{1, 1, 1, 1}, // small
{1, 1, 1, 1} // regular
}
}
},
@@ -1712,6 +1766,11 @@ static const CellRenderSettings progressSettings[2][2] = {
{0, 0, 0, 0}, // mini
{1, 1, 1, 1}, // small
{0, 1, 0, 1} // regular
},
{ // Yosemite
{0, 0, 0, 0}, // mini
{1, 1, 1, 1}, // small
{0, 1, 0, 1} // regular
}
}
}
@@ -1757,6 +1816,11 @@ static const CellRenderSettings meterSetting = {
{1, 1, 1, 1}, // mini
{1, 1, 1, 1}, // small
{1, 1, 1, 1} // regular
},
{ // Yosemite
{1, 1, 1, 1}, // mini
{1, 1, 1, 1}, // small
{1, 1, 1, 1} // regular
}
}
};
@@ -2818,6 +2882,8 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
BOOL isOverlay = nsLookAndFeel::UseOverlayScrollbars();
BOOL isHorizontal = (aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL);
BOOL isRolledOver = IsParentScrollbarRolledOver(aFrame);
nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame);
bool isSmall = (scrollbarFrame && scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
if (isOverlay && (!nsCocoaFeatures::OnMountainLionOrLater() || !isRolledOver)) {
if (isHorizontal) {
macRect.origin.y += 4;
@@ -2836,7 +2902,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
RenderWithCoreUILegacy(macRect, cgContext,
[NSDictionary dictionaryWithObjectsAndKeys:
(isOverlay ? @"kCUIWidgetOverlayScrollBar" : @"scrollbar"), @"widget",
@"regular", @"size",
(isSmall ? @"small" : @"regular"), @"size",
(isRolledOver ? @"rollover" : @"normal"), @"state",
(isHorizontal ? @"kCUIOrientHorizontal" : @"kCUIOrientVertical"), @"kCUIOrientationKey",
(isOnTopOfDarkBackground ? @"kCUIVariantWhite" : @""), @"kCUIVariantKey",
@@ -2866,6 +2932,8 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
BOOL isOverlay = nsLookAndFeel::UseOverlayScrollbars();
if (!isOverlay || IsParentScrollbarRolledOver(aFrame)) {
BOOL isHorizontal = (aWidgetType == NS_THEME_SCROLLBAR_TRACK_HORIZONTAL);
nsIFrame* scrollbarFrame = GetParentScrollbarFrame(aFrame);
bool isSmall = (scrollbarFrame && scrollbarFrame->StyleDisplay()->mAppearance == NS_THEME_SCROLLBAR_SMALL);
if (isOverlay && !nsCocoaFeatures::OnMountainLionOrLater()) {
// On OSX 10.7, scrollbars don't grow when hovered.
// The adjustments below were obtained by trial and error.
@@ -2884,7 +2952,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
RenderWithCoreUILegacy(macRect, cgContext,
[NSDictionary dictionaryWithObjectsAndKeys:
(isOverlay ? @"kCUIWidgetOverlayScrollBar" : @"scrollbar"), @"widget",
@"regular", @"size",
(isSmall ? @"small" : @"regular"), @"size",
(isHorizontal ? @"kCUIOrientHorizontal" : @"kCUIOrientVertical"), @"kCUIOrientationKey",
(isOnTopOfDarkBackground ? @"kCUIVariantWhite" : @""), @"kCUIVariantKey",
[NSNumber numberWithBool:YES], @"noindicator",
@@ -2975,15 +3043,16 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
}
nsIntMargin
nsNativeThemeCocoa::RTLAwareMargin(const nsIntMargin& aMargin, nsIFrame* aFrame)
nsNativeThemeCocoa::DirectionAwareMargin(const nsIntMargin& aMargin,
nsIFrame* aFrame)
{
if (IsFrameRTL(aFrame)) {
// Return a copy of aMargin w/ right & left reversed:
return nsIntMargin(aMargin.top, aMargin.left,
aMargin.bottom, aMargin.right);
}
return aMargin;
// Assuming aMargin was originally specified for a horizontal LTR context,
// reinterpret the values as logical, and then map to physical coords
// according to aFrame's actual writing mode.
WritingMode wm = aFrame->GetWritingMode();
nsMargin m = LogicalMargin(wm, aMargin.top, aMargin.right, aMargin.bottom,
aMargin.left).GetPhysicalMargin(wm);
return nsIntMargin(m.top, m.right, m.bottom, m.left);
}
static const nsIntMargin kAquaDropdownBorder(1, 22, 2, 5);
@@ -3004,16 +3073,16 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
case NS_THEME_BUTTON:
{
if (IsButtonTypeMenu(aFrame)) {
*aResult = RTLAwareMargin(kAquaDropdownBorder, aFrame);
*aResult = DirectionAwareMargin(kAquaDropdownBorder, aFrame);
} else {
aResult->SizeTo(1, 7, 3, 7);
*aResult = DirectionAwareMargin(nsIntMargin(1, 7, 3, 7), aFrame);
}
break;
}
case NS_THEME_TOOLBAR_BUTTON:
{
aResult->SizeTo(1, 4, 1, 4);
*aResult = DirectionAwareMargin(nsIntMargin(1, 4, 1, 4), aFrame);
break;
}
@@ -3028,11 +3097,11 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_BUTTON:
*aResult = RTLAwareMargin(kAquaDropdownBorder, aFrame);
*aResult = DirectionAwareMargin(kAquaDropdownBorder, aFrame);
break;
case NS_THEME_DROPDOWN_TEXTFIELD:
*aResult = RTLAwareMargin(kAquaComboboxBorder, aFrame);
*aResult = DirectionAwareMargin(kAquaComboboxBorder, aFrame);
break;
case NS_THEME_NUMBER_INPUT:
@@ -3055,7 +3124,7 @@ nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
break;
case NS_THEME_SEARCHFIELD:
*aResult = RTLAwareMargin(kAquaSearchfieldBorder, aFrame);
*aResult = DirectionAwareMargin(kAquaSearchfieldBorder, aFrame);
break;
case NS_THEME_LISTBOX:
@@ -3546,7 +3615,7 @@ nsNativeThemeCocoa::WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
case NS_THEME_METERBAR:
case NS_THEME_METERBAR_CHUNK:
case NS_THEME_MAC_VIBRANCY_LIGHT:
case NS_THEME_MAC_VIBRANCY_DARK:\
case NS_THEME_MAC_VIBRANCY_DARK:
*aShouldRepaint = false;
return NS_OK;
}
@@ -3701,7 +3770,6 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
case NS_THEME_SCROLLBAR_NON_DISAPPEARING:
return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
break;
case NS_THEME_RESIZER:
{
@@ -3717,8 +3785,8 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a
nsIScrollableFrame* scrollFrame = do_QueryFrame(parentFrame);
return (!nsLookAndFeel::UseOverlayScrollbars() &&
scrollFrame && scrollFrame->GetScrollbarVisibility());
break;
}
case NS_THEME_FOCUS_OUTLINE:
return true;
@@ -3745,7 +3813,6 @@ nsNativeThemeCocoa::WidgetIsContainer(uint8_t aWidgetType)
case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN:
case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED:
return false;
break;
}
return true;
}
+1 -1
View File
@@ -108,7 +108,7 @@ void
GeckoTouchDispatcher::NotifyTouch(MultiTouchInput& aTouch, TimeStamp aEventTime)
{
if (mCompositorVsyncScheduler) {
mCompositorVsyncScheduler->SetNeedsComposite(true);
mCompositorVsyncScheduler->SetNeedsComposite();
}
if (aTouch.mType == MultiTouchInput::MULTITOUCH_MOVE) {
+4 -3
View File
@@ -6,9 +6,9 @@
toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']
if toolkit in ('cocoa', 'qt', 'gonk', 'uikit'):
if toolkit in ('cocoa', 'qt', 'android', 'gonk', 'uikit'):
DIRS += [toolkit]
if toolkit in ('qt', 'gonk', 'gtk2', 'gtk3'):
if toolkit in ('qt', 'android', 'gonk', 'gtk2', 'gtk3'):
EXPORTS += ['nsIPrintDialogService.h']
if toolkit == 'windows':
@@ -202,7 +202,8 @@ if toolkit in ('cocoa', 'windows'):
'nsBaseClipboard.cpp',
]
if toolkit in ('qt', 'gtk2', 'gtk3', 'cocoa', 'windows', 'gonk', 'uikit'):
if toolkit in {'qt', 'gtk2', 'gtk3', 'cocoa', 'windows',
'android', 'gonk', 'uikit'}:
UNIFIED_SOURCES += [
'nsBaseFilePicker.cpp',
]
+3
View File
@@ -64,3 +64,6 @@ CXXFLAGS += CONFIG['MOZ_QT_CFLAGS']
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
CFLAGS += CONFIG['MOZ_QT_CFLAGS']
CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+3
View File
@@ -17,3 +17,6 @@ FINAL_LIBRARY = 'xul'
LOCAL_INCLUDES += [
'/widget',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wshadow']
+4 -4
View File
@@ -88,12 +88,12 @@ private:
- (void)widgetDestroyed;
// Tear down this ChildView
- (void)delayedTearDown;
- (void)sendMouseEvent:(int) aType point:(LayoutDeviceIntPoint)aPoint widget:(nsWindow*)aWindow;
- (void)sendMouseEvent:(EventMessage) aType point:(LayoutDeviceIntPoint)aPoint widget:(nsWindow*)aWindow;
- (void)handleTap:(UITapGestureRecognizer *)sender;
- (BOOL)isUsingMainThreadOpenGL;
- (void)drawUsingOpenGL;
- (void)drawUsingOpenGLCallback;
- (void)sendTouchEvent:(int) aType touches:(NSSet*)aTouches widget:(nsWindow*)aWindow;
- (void)sendTouchEvent:(EventMessage) aType touches:(NSSet*)aTouches widget:(nsWindow*)aWindow;
// Event handling (UIResponder)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
@@ -138,7 +138,7 @@ private:
[self release];
}
- (void)sendMouseEvent:(int) aType point:(LayoutDeviceIntPoint)aPoint widget:(nsWindow*)aWindow
- (void)sendMouseEvent:(EventMessage) aType point:(LayoutDeviceIntPoint)aPoint widget:(nsWindow*)aWindow
{
WidgetMouseEvent event(true, aType, aWindow,
WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
@@ -164,7 +164,7 @@ private:
}
}
- (void)sendTouchEvent:(int) aType touches:(NSSet*)aTouches widget:(nsWindow*)aWindow
- (void)sendTouchEvent:(EventMessage) aType touches:(NSSet*)aTouches widget:(nsWindow*)aWindow
{
WidgetTouchEvent event(true, aType, aWindow);
//XXX: I think nativeEvent.timestamp * 1000 is probably usable here but