This commit is contained in:
Ryan VanderMeulen 2013-08-16 15:34:19 -04:00
Родитель bcb62c402d a79ecbd978
Коммит f8e4a72725
101 изменённых файлов: 1955 добавлений и 618 удалений

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

@ -36,6 +36,7 @@ MOCHITEST_FILES = \
test_offline_gzip.html \
test_offlineNotification.html \
video.ogg \
offlineByDefault.js \
$(NULL)
# test_contextmenu.html and test_contextmenu_input are disabled on Linux due to bug 513558

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

@ -14,6 +14,7 @@ registerCleanupFunction(function() {
var principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
Services.perms.removeFromPrincipal(principal, "offline-app");
Services.prefs.clearUserPref("offline-apps.quota.warn");
Services.prefs.clearUserPref("offline-apps.allow_by_default");
});
// Check that the "preferences" UI is opened and showing which websites have
@ -70,5 +71,6 @@ function test() {
PopupNotifications.panel.firstElementChild.button.click();
}, true);
Services.prefs.setBoolPref("offline-apps.allow_by_default", false);
gBrowser.contentWindow.location = URL;
}

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

@ -0,0 +1,17 @@
var offlineByDefault = {
defaultValue: false,
prefBranch: SpecialPowers.Cc["@mozilla.org/preferences-service;1"].getService(SpecialPowers.Ci.nsIPrefBranch),
set: function(allow) {
try {
this.defaultValue = this.prefBranch.getBoolPref("offline-apps.allow_by_default");
} catch (e) {
this.defaultValue = false
}
this.prefBranch.setBoolPref("offline-apps.allow_by_default", allow);
},
reset: function() {
this.prefBranch.setBoolPref("offline-apps.allow_by_default", this.defaultValue);
}
}
offlineByDefault.set(false);

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

@ -6,6 +6,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=462856
<head>
<title>Test offline app notification</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="offlineByDefault.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="loaded()">
@ -52,6 +53,8 @@ window.addEventListener("message", function(event) {
pm.removeFromPrincipal(principal1, "offline-app");
pm.removeFromPrincipal(principal2, "offline-app");
offlineByDefault.reset();
SimpleTest.finish();
}
}, false);

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

@ -13,6 +13,7 @@ cache, it can be fetched from the cache successfully.
src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="offlineByDefault.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="loaded()">
@ -46,6 +47,7 @@ function finishTest() {
window.removeEventListener("message", handleMessageEvents, false);
offlineByDefault.reset();
SimpleTest.finish();
}

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

@ -1503,6 +1503,12 @@ public:
*/
static bool OfflineAppAllowed(nsIPrincipal *aPrincipal);
/**
* If offline-apps.allow_by_default is true, we set offline-app permission
* for the principal and return true. Otherwise false.
*/
static bool MaybeAllowOfflineAppByDefault(nsIPrincipal *aPrincipal);
/**
* Increases the count of blockers preventing scripts from running.
* NOTE: You might want to use nsAutoScriptBlocker rather than calling

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

@ -1061,8 +1061,11 @@ nsContentSink::ProcessOfflineManifest(const nsAString& aManifestSpec)
action = CACHE_SELECTION_RESELECT_WITHOUT_MANIFEST;
}
else {
// Only continue if the document has permission to use offline APIs.
if (!nsContentUtils::OfflineAppAllowed(mDocument->NodePrincipal())) {
// Only continue if the document has permission to use offline APIs or
// when preferences indicate to permit it automatically.
if (!nsContentUtils::OfflineAppAllowed(mDocument->NodePrincipal()) &&
!nsContentUtils::MaybeAllowOfflineAppByDefault(mDocument->NodePrincipal()) &&
!nsContentUtils::OfflineAppAllowed(mDocument->NodePrincipal())) {
return;
}

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

@ -1405,6 +1405,38 @@ nsContentUtils::OfflineAppAllowed(nsIPrincipal *aPrincipal)
return NS_SUCCEEDED(rv) && allowed;
}
bool
nsContentUtils::MaybeAllowOfflineAppByDefault(nsIPrincipal *aPrincipal)
{
if (!Preferences::GetRootBranch())
return false;
nsresult rv;
bool allowedByDefault;
rv = Preferences::GetRootBranch()->GetBoolPref(
"offline-apps.allow_by_default", &allowedByDefault);
if (NS_FAILED(rv))
return false;
if (!allowedByDefault)
return false;
nsCOMPtr<nsIPermissionManager> permissionManager =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
if (!permissionManager)
return false;
rv = permissionManager->AddFromPrincipal(
aPrincipal, "offline-app", nsIPermissionManager::ALLOW_ACTION,
nsIPermissionManager::EXPIRE_NEVER, 0);
if (NS_FAILED(rv))
return false;
// We have added the permission
return true;
}
// static
void
nsContentUtils::Shutdown()
@ -3191,9 +3223,12 @@ nsContentUtils::IsEventAttributeName(nsIAtom* aName, int32_t aType)
uint32_t
nsContentUtils::GetEventId(nsIAtom* aName)
{
if (aName) {
EventNameMapping mapping;
if (sAtomEventTable->Get(aName, &mapping))
if (sAtomEventTable->Get(aName, &mapping)) {
return mapping.mId;
}
}
return NS_USER_DEFINED_EVENT;
}

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

@ -2170,13 +2170,15 @@ nsINode::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
#define EVENT(name_, id_, type_, struct_) \
EventHandlerNonNull* nsINode::GetOn##name_() { \
nsEventListenerManager *elm = GetListenerManager(false); \
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_) : nullptr; \
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_, EmptyString()) \
: nullptr; \
} \
void nsINode::SetOn##name_(EventHandlerNonNull* handler, \
ErrorResult& error) { \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(nsGkAtoms::on##name_, handler); \
error = elm->SetEventHandler(nsGkAtoms::on##name_, \
EmptyString(), handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
} \

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

@ -48,18 +48,16 @@ public:
ErrorResult& aRv);
bool DispatchEvent(nsDOMEvent& aEvent, ErrorResult& aRv);
// Note, this takes the type in onfoo form!
EventHandlerNonNull* GetEventHandler(const nsAString& aType)
{
nsCOMPtr<nsIAtom> type = do_GetAtom(aType);
return GetEventHandler(type);
return GetEventHandler(type, EmptyString());
}
// Note, this takes the type in onfoo form!
void SetEventHandler(const nsAString& aType, EventHandlerNonNull* aHandler,
ErrorResult& rv)
{
nsCOMPtr<nsIAtom> type = do_GetAtom(aType);
return SetEventHandler(type, aHandler, rv);
}
ErrorResult& rv);
// Note, for an event 'foo' aType will be 'onfoo'.
virtual void EventListenerAdded(nsIAtom* aType) {}
@ -71,9 +69,10 @@ public:
virtual nsIDOMWindow* GetOwnerGlobal() = 0;
protected:
EventHandlerNonNull* GetEventHandler(nsIAtom* aType);
void SetEventHandler(nsIAtom* aType, EventHandlerNonNull* aHandler,
ErrorResult& rv);
EventHandlerNonNull* GetEventHandler(nsIAtom* aType,
const nsAString& aTypeString);
void SetEventHandler(nsIAtom* aType, const nsAString& aTypeString,
EventHandlerNonNull* aHandler, ErrorResult& rv);
};
NS_DEFINE_STATIC_IID_ACCESSOR(EventTarget, NS_EVENTTARGET_IID)

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

@ -23,17 +23,34 @@ EventTarget::RemoveEventListener(const nsAString& aType,
}
EventHandlerNonNull*
EventTarget::GetEventHandler(nsIAtom* aType)
EventTarget::GetEventHandler(nsIAtom* aType, const nsAString& aTypeString)
{
nsEventListenerManager* elm = GetListenerManager(false);
return elm ? elm->GetEventHandler(aType) : nullptr;
return elm ? elm->GetEventHandler(aType, aTypeString) : nullptr;
}
void
EventTarget::SetEventHandler(nsIAtom* aType, EventHandlerNonNull* aHandler,
EventTarget::SetEventHandler(const nsAString& aType,
EventHandlerNonNull* aHandler,
ErrorResult& rv)
{
rv = GetListenerManager(true)->SetEventHandler(aType, aHandler);
if (NS_IsMainThread()) {
nsCOMPtr<nsIAtom> type = do_GetAtom(aType);
return SetEventHandler(type, EmptyString(), aHandler, rv);
}
return SetEventHandler(nullptr,
Substring(aType, 2), // Remove "on"
aHandler, rv);
}
void
EventTarget::SetEventHandler(nsIAtom* aType, const nsAString& aTypeString,
EventHandlerNonNull* aHandler,
ErrorResult& rv)
{
rv = GetListenerManager(true)->SetEventHandler(aType,
aTypeString,
aHandler);
}
} // namespace dom

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

@ -58,6 +58,7 @@ nsDOMEvent::ConstructorInit(mozilla::dom::EventTarget* aOwner,
{
SetIsDOMBinding();
SetOwner(aOwner);
mIsMainThreadEvent = mOwner || NS_IsMainThread();
mPrivateDataDuplicated = false;
@ -222,19 +223,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
// nsIDOMEventInterface
NS_METHOD nsDOMEvent::GetType(nsAString& aType)
{
if (!mCachedType.IsEmpty()) {
aType = mCachedType;
if (!mIsMainThreadEvent || !mEvent->typeString.IsEmpty()) {
aType = mEvent->typeString;
return NS_OK;
}
const char* name = GetEventName(mEvent->message);
if (name) {
CopyASCIItoUTF16(name, aType);
mCachedType = aType;
return NS_OK;
} else if (mEvent->message == NS_USER_DEFINED_EVENT && mEvent->userType) {
aType = Substring(nsDependentAtomString(mEvent->userType), 2); // Remove "on"
mCachedType = aType;
mEvent->typeString = aType;
return NS_OK;
}
@ -460,9 +460,15 @@ nsDOMEvent::PreventDefault()
void
nsDOMEvent::SetEventType(const nsAString& aEventTypeArg)
{
if (mIsMainThreadEvent) {
mEvent->userType =
nsContentUtils::GetEventIdAndAtom(aEventTypeArg, mEvent->eventStructType,
&(mEvent->message));
} else {
mEvent->userType = nullptr;
mEvent->message = NS_USER_DEFINED_EVENT;
mEvent->typeString = aEventTypeArg;
}
}
NS_IMETHODIMP
@ -489,7 +495,6 @@ nsDOMEvent::InitEvent(const nsAString& aEventTypeArg, bool aCanBubbleArg, bool a
// re-dispatching it.
mEvent->target = nullptr;
mEvent->originalTarget = nullptr;
mCachedType = aEventTypeArg;
return NS_OK;
}

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

@ -185,9 +185,9 @@ protected:
nsRefPtr<nsPresContext> mPresContext;
nsCOMPtr<mozilla::dom::EventTarget> mExplicitOriginalTarget;
nsCOMPtr<nsPIDOMWindow> mOwner; // nsPIDOMWindow for now.
nsString mCachedType;
bool mEventIsInternal;
bool mPrivateDataDuplicated;
bool mIsMainThreadEvent;
};
#define NS_FORWARD_TO_NSDOMEVENT \

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

@ -292,7 +292,7 @@ nsDOMEventTargetHelper::SetEventHandler(nsIAtom* aType,
handler = new EventHandlerNonNull(callable);
}
ErrorResult rv;
SetEventHandler(aType, handler, rv);
SetEventHandler(aType, EmptyString(), handler, rv);
return rv.ErrorCode();
}
@ -301,7 +301,7 @@ nsDOMEventTargetHelper::GetEventHandler(nsIAtom* aType,
JSContext* aCx,
JS::Value* aValue)
{
EventHandlerNonNull* handler = GetEventHandler(aType);
EventHandlerNonNull* handler = GetEventHandler(aType, EmptyString());
if (handler) {
*aValue = JS::ObjectValue(*handler->Callable());
} else {

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

@ -168,12 +168,21 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsDOMEventTargetHelper,
#define IMPL_EVENT_HANDLER(_event) \
inline mozilla::dom::EventHandlerNonNull* GetOn##_event() \
{ \
return GetEventHandler(nsGkAtoms::on##_event); \
if (NS_IsMainThread()) { \
return GetEventHandler(nsGkAtoms::on##_event, EmptyString()); \
} \
return GetEventHandler(nullptr, NS_LITERAL_STRING(#_event)); \
} \
inline void SetOn##_event(mozilla::dom::EventHandlerNonNull* aCallback, \
mozilla::ErrorResult& aRv) \
{ \
SetEventHandler(nsGkAtoms::on##_event, aCallback, aRv); \
if (NS_IsMainThread()) { \
SetEventHandler(nsGkAtoms::on##_event, EmptyString(), \
aCallback, aRv); \
} else { \
SetEventHandler(nullptr, NS_LITERAL_STRING(#_event), \
aCallback, aRv); \
} \
}
/* Use this macro to declare functions that forward the behavior of this

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

@ -52,64 +52,27 @@ private:
class nsEventTargetChainItem
{
private:
nsEventTargetChainItem(EventTarget* aTarget,
nsEventTargetChainItem* aChild = nullptr);
// This is the ETCI recycle pool, which is used to avoid some malloc/free
// churn. It's implemented as a linked list.
static nsEventTargetChainItem* sEtciRecyclePool;
static uint32_t sNumRecycledEtcis;
static const uint32_t kMaxNumRecycledEtcis = 128;
nsEventTargetChainItem(EventTarget* aTarget);
public:
static nsEventTargetChainItem* Create(EventTarget* aTarget,
nsEventTargetChainItem()
: mFlags(0), mItemFlags(0)
{
}
static nsEventTargetChainItem* Create(nsTArray<nsEventTargetChainItem>& aChain,
EventTarget* aTarget,
nsEventTargetChainItem* aChild = nullptr)
{
// Allocate from the ETCI recycle pool if possible.
void* place = nullptr;
if (sNumRecycledEtcis > 0) {
MOZ_ASSERT(sEtciRecyclePool);
place = sEtciRecyclePool;
sEtciRecyclePool = sEtciRecyclePool->mNext;
--sNumRecycledEtcis;
} else {
place = malloc(sizeof(nsEventTargetChainItem));
}
return place
? ::new (place) nsEventTargetChainItem(aTarget, aChild)
: nullptr;
MOZ_ASSERT(!aChild || &aChain.ElementAt(aChain.Length() - 1) == aChild);
return new (aChain.AppendElement()) nsEventTargetChainItem(aTarget);
}
static void Destroy(nsEventTargetChainItem* aItem)
static void DestroyLast(nsTArray<nsEventTargetChainItem>& aChain,
nsEventTargetChainItem* aItem)
{
// ::Destroy deletes ancestor chain.
nsEventTargetChainItem* item = aItem;
if (item->mChild) {
item->mChild->mParent = nullptr;
item->mChild = nullptr;
}
// Put destroyed ETCIs into the recycle pool if it's not already full.
while (item) {
nsEventTargetChainItem* parent = item->mParent;
item->~nsEventTargetChainItem();
if (sNumRecycledEtcis < kMaxNumRecycledEtcis) {
item->mNext = sEtciRecyclePool;
sEtciRecyclePool = item;
++sNumRecycledEtcis;
} else {
free(item);
}
item = parent;
}
}
static void ShutdownRecyclePool()
{
while (sEtciRecyclePool) {
nsEventTargetChainItem* tmp = sEtciRecyclePool;
sEtciRecyclePool = sEtciRecyclePool->mNext;
free(tmp);
}
uint32_t lastIndex = aChain.Length() - 1;
MOZ_ASSERT(&aChain[lastIndex] == aItem);
aChain.RemoveElementAt(lastIndex);
}
bool IsValid()
@ -181,7 +144,8 @@ public:
* and system event group and calls also PostHandleEvent for each
* item in the chain.
*/
nsresult HandleEventTargetChain(nsEventChainPostVisitor& aVisitor,
static void HandleEventTargetChain(nsTArray<nsEventTargetChainItem>& aChain,
nsEventChainPostVisitor& aVisitor,
nsDispatchingCallback* aCallback,
ELMCreationDetector& aCd,
nsCxPusher* aPusher);
@ -233,21 +197,7 @@ public:
nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor,
nsCxPusher* aPusher);
static uint32_t MaxEtciCount() { return sMaxEtciCount; }
static void ResetMaxEtciCount()
{
MOZ_ASSERT(!sCurrentEtciCount, "Wrong time to call ResetMaxEtciCount()!");
sMaxEtciCount = 0;
}
nsCOMPtr<EventTarget> mTarget;
nsEventTargetChainItem* mChild;
union {
nsEventTargetChainItem* mParent;
// This is used only when recycling ETCIs.
nsEventTargetChainItem* mNext;
};
uint16_t mFlags;
uint16_t mItemFlags;
nsCOMPtr<nsISupports> mItemData;
@ -255,22 +205,12 @@ public:
nsCOMPtr<EventTarget> mNewTarget;
// Cache mTarget's event listener manager.
nsRefPtr<nsEventListenerManager> mManager;
static uint32_t sMaxEtciCount;
static uint32_t sCurrentEtciCount;
};
nsEventTargetChainItem* nsEventTargetChainItem::sEtciRecyclePool = nullptr;
uint32_t nsEventTargetChainItem::sNumRecycledEtcis = 0;
nsEventTargetChainItem::nsEventTargetChainItem(EventTarget* aTarget,
nsEventTargetChainItem* aChild)
: mTarget(aTarget), mChild(aChild), mParent(nullptr), mFlags(0), mItemFlags(0)
nsEventTargetChainItem::nsEventTargetChainItem(EventTarget* aTarget)
: mTarget(aTarget), mFlags(0), mItemFlags(0)
{
MOZ_ASSERT(!aTarget || mTarget == aTarget->GetTargetForEventTargetChain());
if (mChild) {
mChild->mParent = this;
}
}
nsresult
@ -297,8 +237,9 @@ nsEventTargetChainItem::PostHandleEvent(nsEventChainPostVisitor& aVisitor,
return NS_OK;
}
nsresult
void
nsEventTargetChainItem::HandleEventTargetChain(
nsTArray<nsEventTargetChainItem>& aChain,
nsEventChainPostVisitor& aVisitor,
nsDispatchingCallback* aCallback,
ELMCreationDetector& aCd,
@ -306,50 +247,49 @@ nsEventTargetChainItem::HandleEventTargetChain(
{
// Save the target so that it can be restored later.
nsCOMPtr<EventTarget> firstTarget = aVisitor.mEvent->target;
uint32_t chainLength = aChain.Length();
// Capture
nsEventTargetChainItem* item = this;
aVisitor.mEvent->mFlags.mInCapturePhase = true;
aVisitor.mEvent->mFlags.mInBubblingPhase = false;
while (item->mChild) {
for (uint32_t i = chainLength - 1; i > 0; --i) {
nsEventTargetChainItem& item = aChain[i];
if ((!aVisitor.mEvent->mFlags.mNoContentDispatch ||
item->ForceContentDispatch()) &&
item.ForceContentDispatch()) &&
!aVisitor.mEvent->mFlags.mPropagationStopped) {
item->HandleEvent(aVisitor, aCd, aPusher);
item.HandleEvent(aVisitor, aCd, aPusher);
}
if (item->GetNewTarget()) {
if (item.GetNewTarget()) {
// item is at anonymous boundary. Need to retarget for the child items.
nsEventTargetChainItem* nextTarget = item->mChild;
while (nextTarget) {
EventTarget* newTarget = nextTarget->GetNewTarget();
for (uint32_t j = i; j > 0; --j) {
uint32_t childIndex = j - 1;
EventTarget* newTarget = aChain[childIndex].GetNewTarget();
if (newTarget) {
aVisitor.mEvent->target = newTarget;
break;
}
nextTarget = nextTarget->mChild;
}
}
item = item->mChild;
}
// Target
aVisitor.mEvent->mFlags.mInBubblingPhase = true;
nsEventTargetChainItem& targetItem = aChain[0];
if (!aVisitor.mEvent->mFlags.mPropagationStopped &&
(!aVisitor.mEvent->mFlags.mNoContentDispatch ||
item->ForceContentDispatch())) {
item->HandleEvent(aVisitor, aCd, aPusher);
targetItem.ForceContentDispatch())) {
targetItem.HandleEvent(aVisitor, aCd, aPusher);
}
if (aVisitor.mEvent->mFlags.mInSystemGroup) {
item->PostHandleEvent(aVisitor, aPusher);
targetItem.PostHandleEvent(aVisitor, aPusher);
}
// Bubble
aVisitor.mEvent->mFlags.mInCapturePhase = false;
item = item->mParent;
while (item) {
EventTarget* newTarget = item->GetNewTarget();
for (uint32_t i = 1; i < chainLength; ++i) {
nsEventTargetChainItem& item = aChain[i];
EventTarget* newTarget = item.GetNewTarget();
if (newTarget) {
// Item is at anonymous boundary. Need to retarget for the current item
// and for parent items.
@ -358,15 +298,14 @@ nsEventTargetChainItem::HandleEventTargetChain(
if (aVisitor.mEvent->mFlags.mBubbles || newTarget) {
if ((!aVisitor.mEvent->mFlags.mNoContentDispatch ||
item->ForceContentDispatch()) &&
item.ForceContentDispatch()) &&
!aVisitor.mEvent->mFlags.mPropagationStopped) {
item->HandleEvent(aVisitor, aCd, aPusher);
item.HandleEvent(aVisitor, aCd, aPusher);
}
if (aVisitor.mEvent->mFlags.mInSystemGroup) {
item->PostHandleEvent(aVisitor, aPusher);
item.PostHandleEvent(aVisitor, aPusher);
}
}
item = item->mParent;
}
aVisitor.mEvent->mFlags.mInBubblingPhase = false;
@ -390,7 +329,8 @@ nsEventTargetChainItem::HandleEventTargetChain(
// Setting back the target which was used also for default event group.
aVisitor.mEvent->target = firstTarget;
aVisitor.mEvent->mFlags.mInSystemGroup = true;
HandleEventTargetChain(aVisitor,
HandleEventTargetChain(aChain,
aVisitor,
aCallback,
aCd,
aPusher);
@ -401,17 +341,11 @@ nsEventTargetChainItem::HandleEventTargetChain(
aVisitor.mEvent->mFlags.mPropagationStopped = false;
aVisitor.mEvent->mFlags.mImmediatePropagationStopped = false;
}
return NS_OK;
}
void NS_ShutdownEventTargetChainItemRecyclePool()
{
nsEventTargetChainItem::ShutdownRecyclePool();
}
nsEventTargetChainItem*
EventTargetChainItemForChromeTarget(nsINode* aNode,
EventTargetChainItemForChromeTarget(nsTArray<nsEventTargetChainItem>& aChain,
nsINode* aNode,
nsEventTargetChainItem* aChild = nullptr)
{
if (!aNode->IsInDoc()) {
@ -422,11 +356,11 @@ EventTargetChainItemForChromeTarget(nsINode* aNode,
NS_ENSURE_TRUE(piTarget, nullptr);
nsEventTargetChainItem* etci =
nsEventTargetChainItem::Create(piTarget->GetTargetForEventTargetChain(),
nsEventTargetChainItem::Create(aChain,
piTarget->GetTargetForEventTargetChain(),
aChild);
NS_ENSURE_TRUE(etci, nullptr);
if (!etci->IsValid()) {
nsEventTargetChainItem::Destroy(etci);
nsEventTargetChainItem::DestroyLast(aChain, etci);
return nullptr;
}
return etci;
@ -522,12 +456,13 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
// event dispatching is finished.
nsRefPtr<nsPresContext> kungFuDeathGrip(aPresContext);
nsTArray<nsEventTargetChainItem> chain(128);
// Create the event target chain item for the event target.
nsEventTargetChainItem* targetEtci =
nsEventTargetChainItem::Create(target->GetTargetForEventTargetChain());
NS_ENSURE_TRUE(targetEtci, NS_ERROR_OUT_OF_MEMORY);
nsEventTargetChainItem::Create(chain, target->GetTargetForEventTargetChain());
if (!targetEtci->IsValid()) {
nsEventTargetChainItem::Destroy(targetEtci);
nsEventTargetChainItem::DestroyLast(chain, targetEtci);
return NS_ERROR_FAILURE;
}
@ -570,8 +505,8 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
if (!preVisitor.mCanHandle && preVisitor.mAutomaticChromeDispatch && content) {
// Event target couldn't handle the event. Try to propagate to chrome.
nsEventTargetChainItem::Destroy(targetEtci);
targetEtci = EventTargetChainItemForChromeTarget(content);
nsEventTargetChainItem::DestroyLast(chain, targetEtci);
targetEtci = EventTargetChainItemForChromeTarget(chain, content);
NS_ENSURE_STATE(targetEtci);
targetEtci->PreHandleEvent(preVisitor);
}
@ -584,12 +519,9 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
while (preVisitor.mParentTarget) {
EventTarget* parentTarget = preVisitor.mParentTarget;
nsEventTargetChainItem* parentEtci =
nsEventTargetChainItem::Create(preVisitor.mParentTarget, topEtci);
if (!parentEtci) {
rv = NS_ERROR_OUT_OF_MEMORY;
break;
}
nsEventTargetChainItem::Create(chain, preVisitor.mParentTarget, topEtci);
if (!parentEtci->IsValid()) {
nsEventTargetChainItem::DestroyLast(chain, parentEtci);
rv = NS_ERROR_FAILURE;
break;
}
@ -606,14 +538,15 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
if (preVisitor.mCanHandle) {
topEtci = parentEtci;
} else {
nsEventTargetChainItem::Destroy(parentEtci);
nsEventTargetChainItem::DestroyLast(chain, parentEtci);
parentEtci = nullptr;
if (preVisitor.mAutomaticChromeDispatch && content) {
// Even if the current target can't handle the event, try to
// propagate to chrome.
nsCOMPtr<nsINode> disabledTarget = do_QueryInterface(parentTarget);
if (disabledTarget) {
parentEtci = EventTargetChainItemForChromeTarget(disabledTarget,
parentEtci = EventTargetChainItemForChromeTarget(chain,
disabledTarget,
topEtci);
if (parentEtci) {
parentEtci->PreHandleEvent(preVisitor);
@ -631,17 +564,17 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
if (NS_SUCCEEDED(rv)) {
if (aTargets) {
aTargets->Clear();
nsEventTargetChainItem* item = targetEtci;
while(item) {
aTargets->AppendObject(item->CurrentTarget()->GetTargetForDOMEvent());
item = item->mParent;
aTargets->SetCapacity(chain.Length());
for (uint32_t i = 0; i < chain.Length(); ++i) {
aTargets->AppendObject(chain[i].CurrentTarget()->GetTargetForDOMEvent());
}
} else {
// Event target chain is created. Handle the chain.
nsEventChainPostVisitor postVisitor(preVisitor);
nsCxPusher pusher;
ELMCreationDetector cd;
rv = topEtci->HandleEventTargetChain(postVisitor,
nsEventTargetChainItem::HandleEventTargetChain(chain,
postVisitor,
aCallback,
cd,
&pusher);
@ -655,7 +588,9 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget,
}
}
nsEventTargetChainItem::Destroy(targetEtci);
// Note, nsEventTargetChainItem objects are deleted when the chain goes out of
// the scope.
targetEtci = nullptr;
aEvent->mFlags.mIsBeingDispatched = false;

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

@ -59,9 +59,11 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::hal;
#define EVENT_TYPE_EQUALS(ls, type, userType, allEvents) \
#define EVENT_TYPE_EQUALS(ls, type, userType, typeString, allEvents) \
((ls->mEventType == type && \
(ls->mEventType != NS_USER_DEFINED_EVENT || ls->mTypeAtom == userType)) || \
(ls->mEventType != NS_USER_DEFINED_EVENT || \
(mIsMainThreadELM && ls->mTypeAtom == userType) || \
(!mIsMainThreadELM && ls->mTypeString.Equals(typeString)))) || \
(allEvents && ls->mAllEvents))
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
@ -111,12 +113,13 @@ nsEventListenerManager::nsEventListenerManager(EventTarget* aTarget) :
mMayHaveTouchEventListener(false),
mMayHaveMouseEnterLeaveEventListener(false),
mClearingListeners(false),
mIsMainThreadELM(NS_IsMainThread()),
mNoListenerForEvent(0),
mTarget(aTarget)
{
NS_ASSERTION(aTarget, "unexpected null pointer");
if (NS_IsMainThread()) {
if (mIsMainThreadELM) {
++sMainThreadCreatedCount;
}
}
@ -223,11 +226,14 @@ nsEventListenerManager::AddEventListenerInternal(
const EventListenerHolder& aListener,
uint32_t aType,
nsIAtom* aTypeAtom,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aHandler,
bool aAllEvents)
{
NS_ABORT_IF_FALSE((aType && aTypeAtom) || aAllEvents, "Missing type");
MOZ_ASSERT((NS_IsMainThread() && aType && aTypeAtom) || // Main thread
(!NS_IsMainThread() && aType && !aTypeString.IsEmpty()) || // non-main-thread
aAllEvents, "Missing type"); // all-events listener
if (!aListener || mClearingListeners) {
return;
@ -244,7 +250,7 @@ nsEventListenerManager::AddEventListenerInternal(
if (ls->mListener == aListener &&
ls->mListenerIsHandler == aHandler &&
ls->mFlags == aFlags &&
EVENT_TYPE_EQUALS(ls, aType, aTypeAtom, aAllEvents)) {
EVENT_TYPE_EQUALS(ls, aType, aTypeAtom, aTypeString, aAllEvents)) {
return;
}
}
@ -254,7 +260,9 @@ nsEventListenerManager::AddEventListenerInternal(
ls = aAllEvents ? mListeners.InsertElementAt(0) : mListeners.AppendElement();
ls->mListener = aListener;
MOZ_ASSERT(aType < PR_UINT16_MAX);
ls->mEventType = aType;
ls->mTypeString = aTypeString;
ls->mTypeAtom = aTypeAtom;
ls->mFlags = aFlags;
ls->mListenerIsHandler = aHandler;
@ -457,6 +465,7 @@ nsEventListenerManager::RemoveEventListenerInternal(
const EventListenerHolder& aListener,
uint32_t aType,
nsIAtom* aUserType,
const nsAString& aTypeString,
const EventListenerFlags& aFlags,
bool aAllEvents)
{
@ -477,7 +486,7 @@ nsEventListenerManager::RemoveEventListenerInternal(
for (uint32_t i = 0; i < count; ++i) {
ls = &mListeners.ElementAt(i);
if (EVENT_TYPE_EQUALS(ls, aType, aUserType, aAllEvents)) {
if (EVENT_TYPE_EQUALS(ls, aType, aUserType, aTypeString, aAllEvents)) {
++typeCount;
if (ls->mListener == aListener &&
ls->mFlags.EqualsIgnoringTrustness(aFlags)) {
@ -519,15 +528,23 @@ nsEventListenerManager::RemoveEventListenerInternal(
}
}
static inline bool
ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent)
bool
nsEventListenerManager::ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent)
{
// This is slightly different from EVENT_TYPE_EQUALS in that it returns
// true even when aEvent->message == NS_USER_DEFINED_EVENT and
// aLs=>mEventType != NS_USER_DEFINED_EVENT as long as the atoms are the same
return (aEvent->message == NS_USER_DEFINED_EVENT ?
(aLs->mTypeAtom == aEvent->userType) :
(aLs->mEventType == aEvent->message)) || aLs->mAllEvents;
if (aLs->mAllEvents) {
return true;
}
if (aEvent->message == NS_USER_DEFINED_EVENT) {
if (mIsMainThreadELM) {
return aLs->mTypeAtom == aEvent->userType;
}
return aLs->mTypeString.Equals(aEvent->typeString);
}
MOZ_ASSERT(mIsMainThreadELM);
return aLs->mEventType == aEvent->message;
}
void
@ -535,9 +552,10 @@ nsEventListenerManager::AddEventListenerByType(const EventListenerHolder& aListe
const nsAString& aType,
const EventListenerFlags& aFlags)
{
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
nsCOMPtr<nsIAtom> atom =
mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
uint32_t type = nsContentUtils::GetEventId(atom);
AddEventListenerInternal(aListener, type, atom, aFlags);
AddEventListenerInternal(aListener, type, atom, aType, aFlags);
}
void
@ -546,14 +564,16 @@ nsEventListenerManager::RemoveEventListenerByType(
const nsAString& aType,
const EventListenerFlags& aFlags)
{
nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
nsCOMPtr<nsIAtom> atom =
mIsMainThreadELM ? do_GetAtom(NS_LITERAL_STRING("on") + aType) : nullptr;
uint32_t type = nsContentUtils::GetEventId(atom);
RemoveEventListenerInternal(aListener, type, atom, aFlags);
RemoveEventListenerInternal(aListener, type, atom, aType, aFlags);
}
nsListenerStruct*
nsEventListenerManager::FindEventHandler(uint32_t aEventType,
nsIAtom* aTypeAtom)
nsIAtom* aTypeAtom,
const nsAString& aTypeString)
{
// Run through the listeners for this type and see if a script
// listener is registered
@ -562,7 +582,7 @@ nsEventListenerManager::FindEventHandler(uint32_t aEventType,
for (uint32_t i = 0; i < count; ++i) {
ls = &mListeners.ElementAt(i);
if (ls->mListenerIsHandler &&
EVENT_TYPE_EQUALS(ls, aEventType, aTypeAtom, false)) {
EVENT_TYPE_EQUALS(ls, aEventType, aTypeAtom, aTypeString, false)) {
return ls;
}
}
@ -573,6 +593,7 @@ nsresult
nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeObject,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents,
nsListenerStruct **aListenerStruct)
@ -582,7 +603,7 @@ nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
nsresult rv = NS_OK;
uint32_t eventType = nsContentUtils::GetEventId(aName);
nsListenerStruct* ls = FindEventHandler(eventType, aName);
nsListenerStruct* ls = FindEventHandler(eventType, aName, aTypeString);
if (!ls) {
// If we didn't find a script listener or no listeners existed
@ -596,9 +617,10 @@ nsEventListenerManager::SetEventHandlerInternal(nsIScriptContext *aContext,
if (NS_SUCCEEDED(rv)) {
EventListenerHolder holder(scriptListener);
AddEventListenerInternal(holder, eventType, aName, flags, true);
AddEventListenerInternal(holder, eventType, aName, aTypeString, flags,
true);
ls = FindEventHandler(eventType, aName);
ls = FindEventHandler(eventType, aName, aTypeString);
}
} else {
nsIJSEventListener* scriptListener = ls->GetJSListener();
@ -753,8 +775,8 @@ nsEventListenerManager::SetEventHandler(nsIAtom *aName,
global->GetGlobalJSObject());
nsListenerStruct *ls;
rv = SetEventHandlerInternal(context, scope, aName, nsEventHandler(),
aPermitUntrustedEvents, &ls);
rv = SetEventHandlerInternal(context, scope, aName, EmptyString(),
nsEventHandler(), aPermitUntrustedEvents, &ls);
NS_ENSURE_SUCCESS(rv, rv);
if (!aDeferCompilation) {
@ -765,14 +787,15 @@ nsEventListenerManager::SetEventHandler(nsIAtom *aName,
}
void
nsEventListenerManager::RemoveEventHandler(nsIAtom* aName)
nsEventListenerManager::RemoveEventHandler(nsIAtom* aName,
const nsAString& aTypeString)
{
if (mClearingListeners) {
return;
}
uint32_t eventType = nsContentUtils::GetEventId(aName);
nsListenerStruct* ls = FindEventHandler(eventType, aName);
nsListenerStruct* ls = FindEventHandler(eventType, aName, aTypeString);
if (ls) {
mListeners.RemoveElementAt(uint32_t(ls - &mListeners.ElementAt(0)));
@ -1084,8 +1107,8 @@ nsEventListenerManager::AddListenerForAllEvents(nsIDOMEventListener* aListener,
flags.mAllowUntrustedEvents = aWantsUntrusted;
flags.mInSystemGroup = aSystemEventGroup;
EventListenerHolder holder(aListener);
AddEventListenerInternal(holder, NS_EVENT_TYPE_ALL, nullptr, flags,
false, true);
AddEventListenerInternal(holder, NS_EVENT_TYPE_ALL, nullptr, EmptyString(),
flags, false, true);
}
void
@ -1097,8 +1120,8 @@ nsEventListenerManager::RemoveListenerForAllEvents(nsIDOMEventListener* aListene
flags.mCapture = aUseCapture;
flags.mInSystemGroup = aSystemEventGroup;
EventListenerHolder holder(aListener);
RemoveEventListenerInternal(holder, NS_EVENT_TYPE_ALL, nullptr, flags,
true);
RemoveEventListenerInternal(holder, NS_EVENT_TYPE_ALL, nullptr, EmptyString(),
flags, true);
}
bool
@ -1219,10 +1242,11 @@ nsEventListenerManager::HasUnloadListeners()
nsresult
nsEventListenerManager::SetEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString,
EventHandlerNonNull* aHandler)
{
if (!aHandler) {
RemoveEventHandler(aEventName);
RemoveEventHandler(aEventName, aTypeString);
return NS_OK;
}
@ -1230,15 +1254,17 @@ nsEventListenerManager::SetEventHandler(nsIAtom* aEventName,
// handlers.
nsListenerStruct *ignored;
return SetEventHandlerInternal(nullptr, JS::NullPtr(), aEventName,
nsEventHandler(aHandler),
!nsContentUtils::IsCallerChrome(), &ignored);
aTypeString, nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome(),
&ignored);
}
nsresult
nsEventListenerManager::SetEventHandler(OnErrorEventHandlerNonNull* aHandler)
{
if (!aHandler) {
RemoveEventHandler(nsGkAtoms::onerror);
RemoveEventHandler(nsGkAtoms::onerror, EmptyString());
return NS_OK;
}
@ -1246,15 +1272,17 @@ nsEventListenerManager::SetEventHandler(OnErrorEventHandlerNonNull* aHandler)
// handlers.
nsListenerStruct *ignored;
return SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onerror,
nsEventHandler(aHandler),
!nsContentUtils::IsCallerChrome(), &ignored);
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome(),
&ignored);
}
nsresult
nsEventListenerManager::SetEventHandler(BeforeUnloadEventHandlerNonNull* aHandler)
{
if (!aHandler) {
RemoveEventHandler(nsGkAtoms::onbeforeunload);
RemoveEventHandler(nsGkAtoms::onbeforeunload, EmptyString());
return NS_OK;
}
@ -1262,15 +1290,18 @@ nsEventListenerManager::SetEventHandler(BeforeUnloadEventHandlerNonNull* aHandle
// handlers.
nsListenerStruct *ignored;
return SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onbeforeunload,
nsEventHandler(aHandler),
!nsContentUtils::IsCallerChrome(), &ignored);
EmptyString(), nsEventHandler(aHandler),
!mIsMainThreadELM ||
!nsContentUtils::IsCallerChrome(),
&ignored);
}
const nsEventHandler*
nsEventListenerManager::GetEventHandlerInternal(nsIAtom *aEventName)
nsEventListenerManager::GetEventHandlerInternal(nsIAtom *aEventName,
const nsAString& aTypeString)
{
uint32_t eventType = nsContentUtils::GetEventId(aEventName);
nsListenerStruct* ls = FindEventHandler(eventType, aEventName);
nsListenerStruct* ls = FindEventHandler(eventType, aEventName, aTypeString);
if (!ls) {
return nullptr;

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

@ -163,8 +163,9 @@ typedef enum
struct nsListenerStruct
{
mozilla::dom::EventListenerHolder mListener;
nsCOMPtr<nsIAtom> mTypeAtom;
uint32_t mEventType;
nsCOMPtr<nsIAtom> mTypeAtom; // for the main thread
nsString mTypeString; // for non-main-threads
uint16_t mEventType;
uint8_t mListenerType;
bool mListenerIsHandler : 1;
bool mHandlerIsString : 1;
@ -298,7 +299,7 @@ public:
/**
* Remove the current "inline" event listener for aName.
*/
void RemoveEventHandler(nsIAtom *aName);
void RemoveEventHandler(nsIAtom *aName, const nsAString& aTypeString);
void HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
@ -432,7 +433,8 @@ protected:
/**
* Find the nsListenerStruct for the "inline" event listener for aTypeAtom.
*/
nsListenerStruct* FindEventHandler(uint32_t aEventType, nsIAtom* aTypeAtom);
nsListenerStruct* FindEventHandler(uint32_t aEventType, nsIAtom* aTypeAtom,
const nsAString& aTypeString);
/**
* Set the "inline" event listener for aName to aHandler. aHandler may be
@ -445,6 +447,7 @@ protected:
nsresult SetEventHandlerInternal(nsIScriptContext *aContext,
JS::Handle<JSObject*> aScopeGlobal,
nsIAtom* aName,
const nsAString& aTypeString,
const nsEventHandler& aHandler,
bool aPermitUntrustedEvents,
nsListenerStruct **aListenerStruct);
@ -459,6 +462,7 @@ public:
* aHandler is null, this will actually remove the event listener
*/
nsresult SetEventHandler(nsIAtom* aEventName,
const nsAString& aTypeString,
mozilla::dom::EventHandlerNonNull* aHandler);
nsresult SetEventHandler(mozilla::dom::OnErrorEventHandlerNonNull* aHandler);
nsresult SetEventHandler(mozilla::dom::BeforeUnloadEventHandlerNonNull* aHandler);
@ -472,20 +476,23 @@ public:
* OnErrorEventHandlerNonNull for some event targets and EventHandlerNonNull
* for others.
*/
mozilla::dom::EventHandlerNonNull* GetEventHandler(nsIAtom *aEventName)
mozilla::dom::EventHandlerNonNull* GetEventHandler(nsIAtom *aEventName,
const nsAString& aTypeString)
{
const nsEventHandler* handler = GetEventHandlerInternal(aEventName);
const nsEventHandler* handler =
GetEventHandlerInternal(aEventName, aTypeString);
return handler ? handler->EventHandler() : nullptr;
}
mozilla::dom::OnErrorEventHandlerNonNull* GetOnErrorEventHandler()
{
const nsEventHandler* handler = GetEventHandlerInternal(nsGkAtoms::onerror);
const nsEventHandler* handler =
GetEventHandlerInternal(nsGkAtoms::onerror, EmptyString());
return handler ? handler->OnErrorEventHandler() : nullptr;
}
mozilla::dom::BeforeUnloadEventHandlerNonNull* GetOnBeforeUnloadEventHandler()
{
const nsEventHandler* handler =
GetEventHandlerInternal(nsGkAtoms::onbeforeunload);
GetEventHandlerInternal(nsGkAtoms::onbeforeunload, EmptyString());
return handler ? handler->BeforeUnloadEventHandler() : nullptr;
}
@ -494,7 +501,8 @@ protected:
* Helper method for implementing the various Get*EventHandler above. Will
* return null if we don't have an event handler for this event name.
*/
const nsEventHandler* GetEventHandlerInternal(nsIAtom* aEventName);
const nsEventHandler* GetEventHandlerInternal(nsIAtom* aEventName,
const nsAString& aTypeString);
void AddEventListener(const nsAString& aType,
const mozilla::dom::EventListenerHolder& aListener,
@ -508,6 +516,7 @@ protected:
const mozilla::dom::EventListenerHolder& aListener,
uint32_t aType,
nsIAtom* aTypeAtom,
const nsAString& aTypeString,
const mozilla::dom::EventListenerFlags& aFlags,
bool aHandler = false,
bool aAllEvents = false);
@ -515,6 +524,7 @@ protected:
const mozilla::dom::EventListenerHolder& aListener,
uint32_t aType,
nsIAtom* aUserType,
const nsAString& aTypeString,
const mozilla::dom::EventListenerFlags& aFlags,
bool aAllEvents = false);
void RemoveAllListeners();
@ -523,6 +533,8 @@ protected:
nsPIDOMWindow* GetInnerWindowForTarget();
already_AddRefed<nsPIDOMWindow> GetTargetAsInnerWindow() const;
bool ListenerCanHandle(nsListenerStruct* aLs, nsEvent* aEvent);
uint32_t mMayHavePaintEventListener : 1;
uint32_t mMayHaveMutationListeners : 1;
uint32_t mMayHaveCapturingListeners : 1;
@ -531,7 +543,8 @@ protected:
uint32_t mMayHaveTouchEventListener : 1;
uint32_t mMayHaveMouseEnterLeaveEventListener : 1;
uint32_t mClearingListeners : 1;
uint32_t mNoListenerForEvent : 24;
uint32_t mIsMainThreadELM : 1;
uint32_t mNoListenerForEvent : 23;
nsAutoTObserverArray<nsListenerStruct, 2> mListeners;
mozilla::dom::EventTarget* mTarget; //WEAK

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

@ -1010,7 +1010,7 @@ nsGenericHTMLElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
else if (IsEventAttributeName(aAttribute)) {
nsEventListenerManager* manager = GetListenerManager(false);
if (manager) {
manager->RemoveEventHandler(aAttribute);
manager->RemoveEventHandler(aAttribute, EmptyString());
}
}
}

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

@ -286,7 +286,7 @@ AudioNodeStream::ObtainInputBlock(AudioChunk& aTmpChunk, uint32_t aPortIndex)
}
AudioChunk* chunk = &a->mLastChunks[mInputs[i]->OutputNumber()];
MOZ_ASSERT(chunk);
if (chunk->IsNull()) {
if (chunk->IsNull() || chunk->mChannelData.IsEmpty()) {
continue;
}

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

@ -2929,6 +2929,7 @@ void MediaDecoderStateMachine::QueueMetadata(int64_t aPublishTime,
metadata->mChannels = aChannels;
metadata->mRate = aRate;
metadata->mHasAudio = aHasAudio;
metadata->mHasVideo = aHasVideo;
metadata->mTags = aTags;
mMetadataManager.QueueMetadata(metadata);
}

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

@ -666,7 +666,7 @@ nsSVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsIAtom* aName,
nsEventListenerManager* manager = GetListenerManager(false);
if (manager) {
nsIAtom* eventName = GetEventNameForAttr(aName);
manager->RemoveEventHandler(eventName);
manager->RemoveEventHandler(eventName, EmptyString());
}
return;
}

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

@ -703,14 +703,16 @@ public:
mozilla::dom::EventHandlerNonNull* GetOn##name_() \
{ \
nsEventListenerManager *elm = GetListenerManager(false); \
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_) : nullptr; \
return elm ? elm->GetEventHandler(nsGkAtoms::on##name_, EmptyString()) \
: nullptr; \
} \
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler, \
mozilla::ErrorResult& error) \
{ \
nsEventListenerManager *elm = GetListenerManager(true); \
if (elm) { \
error = elm->SetEventHandler(nsGkAtoms::on##name_, handler); \
error = elm->SetEventHandler(nsGkAtoms::on##name_, EmptyString(), \
handler); \
} else { \
error.Throw(NS_ERROR_OUT_OF_MEMORY); \
} \

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

@ -84,7 +84,6 @@ nsDOMOfflineResourceList::nsDOMOfflineResourceList(nsIURI *aManifestURI,
, mManifestURI(aManifestURI)
, mDocumentURI(aDocumentURI)
, mExposeCacheUpdateStatus(true)
, mDontSetDocumentCache(false)
, mStatus(nsIDOMOfflineResourceList::IDLE)
, mCachedKeys(nullptr)
, mCachedKeysCount(0)
@ -429,6 +428,11 @@ nsDOMOfflineResourceList::GetStatus(uint16_t *aStatus)
}
}
if (mAvailableApplicationCache) {
*aStatus = nsIDOMOfflineResourceList::UPDATEREADY;
return NS_OK;
}
*aStatus = mStatus;
return NS_OK;
}
@ -455,10 +459,6 @@ nsDOMOfflineResourceList::Update()
window, getter_AddRefs(update));
NS_ENSURE_SUCCESS(rv, rv);
// Since we are invoking the cache update, cache on the document must not
// be updated until swapCache() method is called on applicationCache object.
mDontSetDocumentCache = true;
return NS_OK;
}
@ -488,6 +488,8 @@ nsDOMOfflineResourceList::SwapCache()
mAvailableApplicationCache->GetClientID(availClientId);
if (availClientId == currClientId)
return NS_ERROR_DOM_INVALID_STATE_ERR;
} else if (mStatus != OBSOLETE) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
ClearCachedKeys();
@ -629,16 +631,36 @@ nsDOMOfflineResourceList::UpdateStateChanged(nsIOfflineCacheUpdate *aUpdate,
NS_IMETHODIMP
nsDOMOfflineResourceList::ApplicationCacheAvailable(nsIApplicationCache *aApplicationCache)
{
mAvailableApplicationCache = aApplicationCache;
nsCOMPtr<nsIApplicationCache> currentAppCache = GetDocumentAppCache();
if (currentAppCache) {
// Document already has a cache, we cannot override it. swapCache is
// here to do it on demand.
// If the newly available cache is identical to the current cache, then
// just ignore this event.
if (aApplicationCache == currentAppCache) {
return NS_OK;
}
nsCString currClientId, availClientId;
currentAppCache->GetClientID(currClientId);
aApplicationCache->GetClientID(availClientId);
if (availClientId == currClientId) {
return NS_OK;
}
mAvailableApplicationCache = aApplicationCache;
return NS_OK;
}
if (!mDontSetDocumentCache) {
nsCOMPtr<nsIApplicationCacheContainer> appCacheContainer =
GetDocumentAppCacheContainer();
if (appCacheContainer)
if (appCacheContainer) {
appCacheContainer->SetApplicationCache(aApplicationCache);
}
mAvailableApplicationCache = nullptr;
return NS_OK;
}
@ -737,14 +759,12 @@ nsDOMOfflineResourceList::UpdateCompleted(nsIOfflineCacheUpdate *aUpdate)
mCacheUpdate->RemoveObserver(this);
mCacheUpdate = nullptr;
mDontSetDocumentCache = false;
if (NS_SUCCEEDED(rv) && succeeded && !partial) {
mStatus = nsIDOMOfflineResourceList::IDLE;
if (isUpgrade) {
mStatus = nsIDOMOfflineResourceList::UPDATEREADY;
SendEvent(NS_LITERAL_STRING(UPDATEREADY_STR));
} else {
mStatus = nsIDOMOfflineResourceList::IDLE;
SendEvent(NS_LITERAL_STRING(CACHED_STR));
}
}

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

@ -157,7 +157,6 @@ private:
nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
bool mExposeCacheUpdateStatus;
bool mDontSetDocumentCache;
uint16_t mStatus;
// The set of dynamic keys for this application cache object.

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

@ -12,6 +12,10 @@ applicationCache.oncached = function() {
parent.frameOnUpdate("same", true, applicationCache.status);
}
applicationCache.onnoupdate = function() {
parent.frameOnUpdate("same", true, applicationCache.status);
}
</script>
</head>

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

@ -28,8 +28,7 @@ function startTest()
testScriptPresence("namespace1/sub2/script2.js", "scriptNo2Function();", true);
testScriptPresence("namespace2/script3.js", "scriptNo3Function();", true);
opener.OfflineTest.teardown();
opener.OfflineTest.finish();
opener.OfflineTest.teardownAndFinish();
window.close(window);
}

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

@ -16,16 +16,15 @@ function manifestUpdated()
var foreign2cache = appCacheService.chooseApplicationCache(
"http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html", OfflineTest.loadContext());
OfflineTest.ok(foreign2cache, "Foreign 2 cache present, chosen for foreign2.html");
OfflineTest.is(foreign2cache.manifestURI.asciiSpec, "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest")
window.opener.OfflineTest.ok(foreign2cache, "Foreign 2 cache present, chosen for foreign2.html");
window.opener.OfflineTest.is(foreign2cache.manifestURI.asciiSpec, "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest")
var foreign1cache = OfflineTest.getActiveCache(
"http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
OfflineTest.ok(foreign1cache, "Foreign 1 cache loaded");
window.opener.OfflineTest.ok(foreign1cache, "Foreign 1 cache loaded");
foreign1cache.discard();
OfflineTest.teardown();
OfflineTest.finish();
window.opener.onDone();
}
function onLoaded()
@ -33,36 +32,33 @@ function onLoaded()
var appCacheService = SpecialPowers.Components.classes["@mozilla.org/network/application-cache-service;1"]
.getService(SpecialPowers.Ci.nsIApplicationCacheService);
var foreign1cache = OfflineTest.getActiveCache(
var foreign1cache = window.opener.OfflineTest.getActiveCache(
"http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
OfflineTest.ok(foreign1cache, "Foreign 1 cache loaded");
window.opener.OfflineTest.ok(foreign1cache, "Foreign 1 cache loaded");
var foreign2cache = OfflineTest.getActiveCache(
var foreign2cache = window.opener.OfflineTest.getActiveCache(
"http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest");
OfflineTest.ok(!foreign2cache, "Foreign 2 cache not present");
window.opener.OfflineTest.ok(!foreign2cache, "Foreign 2 cache not present");
foreign1cache = appCacheService.chooseApplicationCache(
"http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html", OfflineTest.loadContext());
OfflineTest.ok(!foreign1cache, "foreign2.html not chosen from foreign1 cache");
"http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html", window.opener.OfflineTest.loadContext());
window.opener.OfflineTest.ok(!foreign1cache, "foreign2.html not chosen from foreign1 cache");
try
{
OfflineTest.ok(applicationCache.status == SpecialPowers.Ci.nsIDOMOfflineResourceList.UNCACHED,
window.opener.OfflineTest.ok(applicationCache.status == SpecialPowers.Ci.nsIDOMOfflineResourceList.UNCACHED,
"there is no associated application cache");
}
catch (ex)
{
OfflineTest.ok(false, "applicationCache.status must not throw an exception");
window.opener.OfflineTest.ok(false, "applicationCache.status must not throw an exception");
}
}
if (OfflineTest.setup())
{
applicationCache.onerror = OfflineTest.failEvent;
applicationCache.onupdateready = OfflineTest.failEvent;
applicationCache.onnoupdate = OfflineTest.failEvent;
applicationCache.oncached = OfflineTest.priv(manifestUpdated);
}
applicationCache.onerror = window.opener.OfflineTest.failEvent;
applicationCache.onupdateready = window.opener.OfflineTest.failEvent;
applicationCache.onnoupdate = window.opener.OfflineTest.failEvent;
applicationCache.oncached = window.opener.OfflineTest.priv(manifestUpdated);
</script>

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

@ -12,7 +12,7 @@
// (since we don't get those events)
function doneLoading()
{
window.top.childFinished();
window.parent.childFinished();
}
if (OfflineTest.setupChild()) {

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

@ -58,6 +58,8 @@ fetch: function(callback)
var OfflineTest = {
_allowedByDefault: false,
_hasSlave: false,
// The window where test results should be sent.
@ -71,6 +73,11 @@ _SJSsStated: [],
setupChild: function()
{
if (this._allowedByDefault) {
this._masterWindow = window;
return true;
}
if (window.parent.OfflineTest._hasSlave) {
return false;
}
@ -91,6 +98,17 @@ setup: function()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
try {
this._allowedByDefault = prefBranch.getBoolPref("offline-apps.allow_by_default");
} catch (e) {}
if (this._allowedByDefault) {
this._masterWindow = window;
return true;
}
if (!window.opener || !window.opener.OfflineTest ||
!window.opener.OfflineTest._hasSlave) {
// Offline applications must be toplevel windows and have the
@ -126,8 +144,15 @@ setup: function()
return true;
},
teardown: function()
teardownAndFinish: function()
{
this.teardown(function(self) { self.finish(); });
},
teardown: function(callback)
{
// First wait for any pending scheduled updates to finish
this.waitForUpdates(function(self) {
// Remove the offline-app permission we gave ourselves.
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -144,17 +169,21 @@ teardown: function()
pm.removeFromPrincipal(principal, "offline-app");
// Clear all overrides on the server
for (override in this._pathOverrides)
this.deleteData(this._pathOverrides[override]);
for (statedSJS in this._SJSsStated)
this.setSJSState(this._SJSsStated[statedSJS], "");
for (override in self._pathOverrides)
self.deleteData(self._pathOverrides[override]);
for (statedSJS in self._SJSsStated)
self.setSJSState(self._SJSsStated[statedSJS], "");
this.clear();
self.clear();
callback(self);
});
},
finish: function()
{
if (this._masterWindow) {
if (this._allowedByDefault) {
SimpleTest.executeSoon(SimpleTest.finish);
} else if (this._masterWindow) {
// Slave window: pass control back to master window, close itself.
this._masterWindow.SimpleTest.executeSoon(this._masterWindow.OfflineTest.finish);
window.close();
@ -196,6 +225,48 @@ clear: function()
}
},
waitForUpdates: function(callback)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var self = this;
var observer = {
notified: false,
observe: function(subject, topic, data) {
if (subject) {
subject.QueryInterface(SpecialPowers.Ci.nsIOfflineCacheUpdate);
dump("Update of " + subject.manifestURI.spec + " finished\n");
}
SimpleTest.executeSoon(function() {
if (observer.notified) {
return;
}
var updateservice = SpecialPowers.Cc["@mozilla.org/offlinecacheupdate-service;1"]
.getService(SpecialPowers.Ci.nsIOfflineCacheUpdateService);
var updatesPending = updateservice.numUpdates;
if (updatesPending == 0) {
try {
SpecialPowers.removeObserver(observer, "offline-cache-update-completed");
} catch(ex) {}
dump("All pending updates done\n");
observer.notified = true;
callback(self);
return;
}
dump("Waiting for " + updateservice.numUpdates + " update(s) to finish\n");
});
}
}
SpecialPowers.addObserver(observer, "offline-cache-update-completed", false);
// Call now to check whether there are some updates scheduled
observer.observe();
},
failEvent: function(e)
{
OfflineTest.ok(false, "Unexpected event: " + e.type);
@ -237,7 +308,19 @@ waitForAdd: function(url, onFinished) {
manifestURL: function(overload)
{
var manifestURLspec = overload || window.top.document.documentElement.getAttribute("manifest");
var manifestURLspec;
if (overload) {
manifestURLspec = overload;
} else {
var win = window;
while (win && !win.document.documentElement.getAttribute("manifest")) {
if (win == win.parent)
break;
win = win.parent;
}
if (win)
manifestURLspec = win.document.documentElement.getAttribute("manifest");
}
var ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService)
@ -267,8 +350,9 @@ getActiveCache: function(overload)
getActiveSession: function()
{
var cache = this.getActiveCache();
if (!cache)
if (!cache) {
return null;
}
var cacheService = Cc["@mozilla.org/network/cache-service;1"]
.getService(Ci.nsICacheService);
@ -302,6 +386,7 @@ checkCacheEntries: function(entries, callback)
checkCache: function(url, expectEntry, callback)
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var cacheSession = this.getActiveSession();
this._checkCache(cacheSession, url, expectEntry, callback);
},
@ -310,11 +395,11 @@ _checkCache: function(cacheSession, url, expectEntry, callback)
{
if (!cacheSession) {
if (expectEntry) {
this.ok(false, url + " should exist in the offline cache");
this.ok(false, url + " should exist in the offline cache (no session)");
} else {
this.ok(true, url + " should not exist in the offline cache");
this.ok(true, url + " should not exist in the offline cache (no session)");
}
setTimeout(this.priv(callback), 0);
if (callback) setTimeout(this.priv(callback), 0);
return;
}
@ -346,7 +431,7 @@ _checkCache: function(cacheSession, url, expectEntry, callback)
OfflineTest.ok(false, "got invalid error for " + url);
}
}
setTimeout(OfflineTest.priv(callback), 0);
if (callback) setTimeout(OfflineTest.priv(callback), 0);
}
};

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

@ -11,8 +11,7 @@
var gGotChecking = false;
function finishTest() {
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function handleError() {

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

@ -17,8 +17,7 @@ var gTimeoutId;
function finish()
{
gTestWin.close();
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function error()

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

@ -16,10 +16,16 @@
<script class="testbody" type="text/javascript">
var result = new Array();
var expectedUpdates = 2;
var expectedUpdates = 3; // 2 iframes and our self
init();
function onUpdatePassed()
{
if (!(--expectedUpdates))
SimpleTest.executeSoon(finish);
}
function init()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -35,6 +41,9 @@ function init()
.getService(Ci.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(uri);
pm.addFromPrincipal(principal, "offline-app", Ci.nsIPermissionManager.ALLOW_ACTION);
applicationCache.oncached = onUpdatePassed;
applicationCache.onnoupdate = onUpdatePassed;
}
function frameOnLoad(frameid, status)
@ -52,8 +61,7 @@ function frameOnUpdate(frameid, ok, status)
result[frameid].updateOK = ok;
result[frameid].cacheStatus = status;
if (!(--expectedUpdates))
finish();
onUpdatePassed();
}
function finish()
@ -87,10 +95,12 @@ function finish()
.getNoAppCodebasePrincipal(uri);
pm.removeFromPrincipal(principal, "offline-app");
OfflineTest.waitForUpdates(function() {
cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest");
cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs");
SimpleTest.finish();
});
}
function cleanCache(manifestURL)
@ -98,6 +108,7 @@ function cleanCache(manifestURL)
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var cache = OfflineTest.getActiveCache(manifestURL);
dump("Discarding cache for " + manifestURL + " cache=" + cache + "\n");
if (cache)
cache.discard();
}

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

@ -15,10 +15,10 @@ function manifestUpdated()
function onFallbackLoad(fallbackIdentification)
{
OfflineTest.is(fallbackIdentification, 1, "Got correct fallback for namespace1");
OfflineTest.is(fallbackIdentification, 1, "Got correct fallback for namespace1 (2)");
OfflineTest.teardown();
OfflineTest.finish();
applicationCache.onerror = function() {}; // the update invoked by the iframe will finish after we discard the cache, ignore error
OfflineTest.teardownAndFinish();
}
SimpleTest.waitForExplicitFinish();
@ -26,7 +26,6 @@ SimpleTest.waitForExplicitFinish();
if (OfflineTest.setup()) {
applicationCache.onerror = OfflineTest.failEvent;
applicationCache.onupdateready = OfflineTest.failEvent;
applicationCache.onnoupdate = OfflineTest.failEvent;
applicationCache.oncached = OfflineTest.priv(manifestUpdated);
}

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

@ -31,8 +31,7 @@ function finishTheTest()
{
OfflineTest.is(gImageLoaded[1], true, "Image from a different origin not cointained in the offline cache has loaded");
OfflineTest.is(gImageLoaded[2], true, "Image not cointained in the offline cache has loaded");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
if (OfflineTest.setup()) {

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

@ -19,46 +19,44 @@ ok(applicationCache.mozItems.length == 0,
function updateCanceled()
{
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest", false);
OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false);
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false);
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest", false, null);
OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false, null);
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false, null);
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/nonexistent744719?010", false);
OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/nonexistent744719?010", false, null);
var URL = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/subresource744719.html?";
OfflineTest.checkCache(URL + "001", false);
OfflineTest.checkCache(URL + "002", false);
OfflineTest.checkCache(URL + "003", false);
OfflineTest.checkCache(URL + "004", false);
OfflineTest.checkCache(URL + "005", false);
OfflineTest.checkCache(URL + "006", false);
OfflineTest.checkCache(URL + "007", false);
OfflineTest.checkCache(URL + "008", false);
OfflineTest.checkCache(URL + "009", false);
OfflineTest.checkCache(URL + "011", false);
OfflineTest.checkCache(URL + "012", false);
OfflineTest.checkCache(URL + "013", false);
OfflineTest.checkCache(URL + "014", false);
OfflineTest.checkCache(URL + "015", false);
OfflineTest.checkCache(URL + "016", false);
OfflineTest.checkCache(URL + "017", false);
OfflineTest.checkCache(URL + "018", false);
OfflineTest.checkCache(URL + "019", false);
OfflineTest.checkCache(URL + "020", false);
OfflineTest.checkCache(URL + "021", false);
OfflineTest.checkCache(URL + "022", false);
OfflineTest.checkCache(URL + "023", false);
OfflineTest.checkCache(URL + "024", false);
OfflineTest.checkCache(URL + "025", false);
OfflineTest.checkCache(URL + "026", false);
OfflineTest.checkCache(URL + "027", false);
OfflineTest.checkCache(URL + "028", false);
OfflineTest.checkCache(URL + "029", false);
OfflineTest.checkCache(URL + "030", false);
OfflineTest.checkCache(URL + "001", false, null);
OfflineTest.checkCache(URL + "002", false, null);
OfflineTest.checkCache(URL + "003", false, null);
OfflineTest.checkCache(URL + "004", false, null);
OfflineTest.checkCache(URL + "005", false, null);
OfflineTest.checkCache(URL + "006", false, null);
OfflineTest.checkCache(URL + "007", false, null);
OfflineTest.checkCache(URL + "008", false, null);
OfflineTest.checkCache(URL + "009", false, null);
OfflineTest.checkCache(URL + "011", false, null);
OfflineTest.checkCache(URL + "012", false, null);
OfflineTest.checkCache(URL + "013", false, null);
OfflineTest.checkCache(URL + "014", false, null);
OfflineTest.checkCache(URL + "015", false, null);
OfflineTest.checkCache(URL + "016", false, null);
OfflineTest.checkCache(URL + "017", false, null);
OfflineTest.checkCache(URL + "018", false, null);
OfflineTest.checkCache(URL + "019", false, null);
OfflineTest.checkCache(URL + "020", false, null);
OfflineTest.checkCache(URL + "021", false, null);
OfflineTest.checkCache(URL + "022", false, null);
OfflineTest.checkCache(URL + "023", false, null);
OfflineTest.checkCache(URL + "024", false, null);
OfflineTest.checkCache(URL + "025", false, null);
OfflineTest.checkCache(URL + "026", false, null);
OfflineTest.checkCache(URL + "027", false, null);
OfflineTest.checkCache(URL + "028", false, null);
OfflineTest.checkCache(URL + "029", false, null);
OfflineTest.checkCache(URL + "030", false, null);
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
if (OfflineTest.setup()) {

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

@ -52,11 +52,9 @@ function manifestUpdated()
OfflineTest.checkCache(URL + "027", true);
OfflineTest.checkCache(URL + "028", true);
OfflineTest.checkCache(URL + "029", true);
OfflineTest.checkCache(URL + "030", true);
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.checkCache(URL + "030", true, function() {
OfflineTest.teardownAndFinish();
});
}
if (OfflineTest.setup()) {

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

@ -35,8 +35,7 @@ function manifestUpdated()
OfflineTest.checkCacheEntries(
entries,
function() {
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
});
}

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

@ -18,15 +18,13 @@ var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
function manifestCached () {
OfflineTest.ok(false, "The update was supposed to be canceled");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function onError () {
OfflineTest.ok(true, "Expected error: Update canceled");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function onProgress () {
@ -43,6 +41,7 @@ function onProgress () {
if (OfflineTest.setup()) {
applicationCache.onerror = OfflineTest.priv(onError);
applicationCache.onnoupdate = OfflineTest.failEvent;
applicationCache.onprogress = OfflineTest.priv(onProgress);
applicationCache.oncached = OfflineTest.priv(manifestCached);
}

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

@ -18,8 +18,7 @@ var gCacheContents = null;
function finish()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function manifestUpdatedAgain()

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

@ -96,8 +96,7 @@ function onFallbackLoad(fallbackIdentification)
function finishTest()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function finalize()

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

@ -19,9 +19,11 @@
* chosen by foreign.html page.
*/
var win;
function manifestUpdated()
{
var appCacheService = SpecialPowers.Components.classes["@mozilla.org/network/application-cache-service;1"]
var appCacheService = SpecialPowers.Cc["@mozilla.org/network/application-cache-service;1"]
.getService(SpecialPowers.Ci.nsIApplicationCacheService);
foreign1cache = appCacheService.chooseApplicationCache(
@ -30,7 +32,13 @@ function manifestUpdated()
OfflineTest.ok(foreign1cache, "foreign2.html chosen from foreign1 cache");
OfflineTest.is(foreign1cache.manifestURI.asciiSpec, "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest")
window.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html";
win = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html");
}
function onDone() // called by the open window after stuff is finished
{
win.close();
OfflineTest.teardownAndFinish();
}
SimpleTest.waitForExplicitFinish();

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

@ -13,8 +13,7 @@ var gGotDownloading = false;
function finishTest()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function noUpdate()

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

@ -32,8 +32,7 @@ var errorReceived = false;
function finish() {
obs.notifyObservers(updateService, "disk-space-watcher", "free");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
if (OfflineTest.setup()) {
@ -46,7 +45,6 @@ if (OfflineTest.setup()) {
aUpdate.removeObserver(this);
errorReceived = true;
OfflineTest.ok(true, "Expected error. Update canceled");
finish();
break;
case Ci.nsIOfflineCacheUpdateObserver.STATE_FINISHED:
OfflineTest.ok(errorReceived,

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

@ -22,8 +22,7 @@ var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
function finish() {
obs.notifyObservers(updateService, "disk-space-watcher", "free");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function onError() {

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

@ -12,8 +12,7 @@ var gGotChecking = false;
var gGotDownloading = false;
function finishTest() {
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function handleError() {

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

@ -23,8 +23,7 @@ function checkEntries() {
function childFinished()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
if (OfflineTest.setup()) {

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

@ -99,8 +99,7 @@ function finalize()
OfflineTest.is(gGotDynamicVersion, 1, "Dynamic entry loaded");
OfflineTest.ok(gGotOnError, "Got onerror event invoked by implicit page load in offline mode");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
}

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

@ -15,8 +15,7 @@ function manifestUpdated()
xhr.send();
OfflineTest.is(xhr.status, 200, "Should have fallen back.");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
if (OfflineTest.setup()) {

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

@ -25,8 +25,7 @@ function manifestError()
function finish()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
SimpleTest.waitForExplicitFinish();

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

@ -108,8 +108,7 @@ function manifestError()
function finish()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
SimpleTest.waitForExplicitFinish();

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

@ -9,8 +9,7 @@
function finish()
{
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
function failAndFinish(e)

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

@ -49,8 +49,7 @@ function removeItem()
false,
function() {
// We're done
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
});
}

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

@ -68,8 +68,7 @@ function manifestUpdated()
observe: function(subject, topic, data) {
OfflineTest.is(topic, "offline-cache-update-unavailable", "No update avail (2)");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
});
}

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

@ -38,7 +38,7 @@ function waitForLocations(frames, doneFunc)
if (frame)
// toString() might cause problems when this test will
// completely be changed to test IDN behavior.
OfflineTest.waitForAdd(frame.location.toString(), function()
OfflineTest.waitForAdd(frame, function()
{
waitForLocations(frames, doneFunc);
}
@ -94,7 +94,7 @@ function frameLoad(version)
{
var call = gCallOnUpdatingFrameLoad;
gCallOnUpdatingFrameLoad = null;
OfflineTest.priv(call)();
SimpleTest.executeSoon(OfflineTest.priv(call));
}
}
@ -112,12 +112,15 @@ function manifestCached()
OfflineTest.is(gStep, 0, "Got manifestCached in step 0, gStep=" + gStep);
reloadLocations([fallbackFrame1, fallbackFrame2]);
waitForLocations([fallbackFrame1, fallbackFrame2],
fallbackLoaded);
waitForLocations(
["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html"],
fallbackLoaded
);
}
function fallbackLoaded()
{
dump("in fallbackLoaded\n");
applicationCache.mozAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
OfflineTest.waitForAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
dynamicLoaded);
@ -126,7 +129,7 @@ function fallbackLoaded()
function dynamicLoaded()
{
window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html");
// window.onload invokes implicitLoaded()
// window.applicationCache.noupdate invokes implicitLoaded()
}
function implicitLoaded(aWindow, errorOccured)
@ -237,8 +240,8 @@ function manifestUpdated()
OfflineTest.setSJSState("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs", "second");
gGotFrameVersion = 0;
gCallOnUpdatingFrameLoad = function() {applicationCache.update();};
updatingFrame.location.reload();
// Since the frame is offline-cached, reload of it invokes update
});
break;
@ -298,6 +301,7 @@ function manifestNoUpdate()
applicationCache.onnoupdate = null;
OfflineTest.ok(gStep == 3, "Got manifestNoUpdate in step 3, gStep=" + gStep);
++gStep;
OfflineTest.is(applicationCache.status, SpecialPowers.Ci.nsIDOMOfflineResourceList.UPDATEREADY,
"we have associated application cache and update is pending (4)");
@ -314,8 +318,7 @@ function checkNewVersionOfIFrame()
{
OfflineTest.is(gGotFrameVersion, 2, "IFrame version 2");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
// End of the test function chain

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

@ -12,8 +12,7 @@ function manifestUpdated()
{
OfflineTest.ok(true, "Application cache updated.");
OfflineTest.teardown();
OfflineTest.finish();
OfflineTest.teardownAndFinish();
}
if (OfflineTest.setup()) {

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

@ -29,7 +29,8 @@ class BasicCanvasLayer : public CopyableCanvasLayer,
{
public:
BasicCanvasLayer(BasicLayerManager* aLayerManager) :
CopyableCanvasLayer(aLayerManager, static_cast<BasicImplData*>(this))
CopyableCanvasLayer(aLayerManager,
static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{ }
virtual void SetVisibleRegion(const nsIntRegion& aRegion)

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

@ -14,7 +14,8 @@ namespace layers {
class BasicColorLayer : public ColorLayer, public BasicImplData {
public:
BasicColorLayer(BasicLayerManager* aLayerManager) :
ColorLayer(aLayerManager, static_cast<BasicImplData*>(this))
ColorLayer(aLayerManager,
static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(BasicColorLayer);
}

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

@ -178,7 +178,8 @@ class BasicContainerLayer : public ContainerLayer, public BasicImplData {
public:
BasicContainerLayer(BasicLayerManager* aManager) :
ContainerLayer(aManager, static_cast<BasicImplData*>(this))
ContainerLayer(aManager,
static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(BasicContainerLayer);
mSupportsComponentAlphaChildren = true;

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

@ -22,7 +22,8 @@ namespace layers {
class BasicImageLayer : public ImageLayer, public BasicImplData {
public:
BasicImageLayer(BasicLayerManager* aLayerManager) :
ImageLayer(aLayerManager, static_cast<BasicImplData*>(this)),
ImageLayer(aLayerManager,
static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST())),
mSize(-1, -1)
{
MOZ_COUNT_CTOR(BasicImageLayer);

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

@ -41,7 +41,8 @@ class BasicReadbackLayer : public ReadbackLayer,
{
public:
BasicReadbackLayer(BasicLayerManager* aLayerManager) :
ReadbackLayer(aLayerManager, static_cast<BasicImplData*>(this))
ReadbackLayer(aLayerManager,
static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(BasicReadbackLayer);
}

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

@ -19,7 +19,8 @@ public:
typedef ThebesLayerBuffer::ContentType ContentType;
BasicThebesLayer(BasicLayerManager* aLayerManager) :
ThebesLayer(aLayerManager, static_cast<BasicImplData*>(this)),
ThebesLayer(aLayerManager,
static_cast<BasicImplData*>(MOZ_THIS_IN_INITIALIZER_LIST())),
mContentClient(nullptr)
{
MOZ_COUNT_CTOR(BasicThebesLayer);

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

@ -28,7 +28,8 @@ class ClientCanvasLayer : public CopyableCanvasLayer,
typedef CanvasClient::CanvasClientType CanvasClientType;
public:
ClientCanvasLayer(ClientLayerManager* aLayerManager) :
CopyableCanvasLayer(aLayerManager, static_cast<ClientLayer*>(this))
CopyableCanvasLayer(aLayerManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(ClientCanvasLayer);
}

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

@ -15,7 +15,8 @@ class ClientColorLayer : public ColorLayer,
public ClientLayer {
public:
ClientColorLayer(ClientLayerManager* aLayerManager) :
ColorLayer(aLayerManager, static_cast<ClientLayer*>(this))
ColorLayer(aLayerManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(ClientColorLayer);
}

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

@ -139,7 +139,8 @@ class ClientContainerLayer : public ContainerLayer,
public:
ClientContainerLayer(ClientLayerManager* aManager) :
ContainerLayer(aManager, static_cast<ClientLayer*>(this))
ContainerLayer(aManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(ClientContainerLayer);
mSupportsComponentAlphaChildren = true;
@ -250,7 +251,8 @@ class ClientRefLayer : public RefLayer,
public ClientLayer {
public:
ClientRefLayer(ClientLayerManager* aManager) :
RefLayer(aManager, static_cast<ClientLayer*>(this))
RefLayer(aManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
{
MOZ_COUNT_CTOR(ClientRefLayer);
}

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

@ -17,7 +17,8 @@ class ClientImageLayer : public ImageLayer,
public ClientLayer {
public:
ClientImageLayer(ClientLayerManager* aLayerManager)
: ImageLayer(aLayerManager, static_cast<ClientLayer*>(this))
: ImageLayer(aLayerManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
, mImageClientTypeContainer(BUFFER_UNKNOWN)
{
MOZ_COUNT_CTOR(ClientImageLayer);

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

@ -20,7 +20,8 @@ public:
typedef ThebesLayerBuffer::ContentType ContentType;
ClientThebesLayer(ClientLayerManager* aLayerManager) :
ThebesLayer(aLayerManager, static_cast<ClientLayer*>(this)),
ThebesLayer(aLayerManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST())),
mContentClient(nullptr)
{
MOZ_COUNT_CTOR(ClientThebesLayer);

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

@ -14,7 +14,8 @@ namespace layers {
ClientTiledThebesLayer::ClientTiledThebesLayer(ClientLayerManager* const aManager)
: ThebesLayer(aManager, static_cast<ClientLayer*>(this))
: ThebesLayer(aManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()))
, mContentClient()
{
MOZ_COUNT_CTOR(ClientTiledThebesLayer);

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

@ -171,8 +171,8 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
mRefPtrMonitor("RefPtrMonitor"),
mMonitor("AsyncPanZoomController"),
mTouchListenerTimeoutTask(nullptr),
mX(this),
mY(this),
mX(MOZ_THIS_IN_INITIALIZER_LIST()),
mY(MOZ_THIS_IN_INITIALIZER_LIST()),
mAllowZoom(true),
mMinZoom(MIN_ZOOM),
mMaxZoom(MAX_ZOOM),

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

@ -247,7 +247,8 @@ static const char *gPrefLangNames[] = {
};
gfxPlatform::gfxPlatform()
: mAzureCanvasBackendCollector(this, &gfxPlatform::GetAzureBackendInfo)
: mAzureCanvasBackendCollector(MOZ_THIS_IN_INITIALIZER_LIST(),
&gfxPlatform::GetAzureBackendInfo)
, mDrawLayerBorders(false)
, mDrawTileBorders(false)
, mDrawBigImageBorders(false)

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

@ -906,17 +906,6 @@ class Value
Value(const Value& v) = default;
#endif
/*
* clang 4.1 doesn't corectly create a default assignment operator
* for this class, so we need to explicitly declare one.
*/
#if defined(__clang__) && (__clang_major__ == 4) && (__clang_minor__ <= 1)
Value &operator=(const Value &r) {
data = r.data;
return *this;
}
#endif
/*** Mutators ***/
void setNull() {

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

@ -892,6 +892,16 @@ DisableSPSProfiling(JSContext *cx, unsigned argc, jsval *vp)
return true;
}
static bool
EnableOsiPointRegisterChecks(JSContext *, unsigned, jsval *vp)
{
#ifdef CHECK_OSIPOINT_REGISTERS
ion::js_IonOptions.checkOsiPointRegisters = true;
#endif
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return true;
}
static bool
DisplayName(JSContext *cx, unsigned argc, jsval *vp)
{
@ -1136,6 +1146,11 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
"disableSPSProfiling()",
" Disables SPS instrumentation"),
JS_FN_HELP("enableOsiPointRegisterChecks", EnableOsiPointRegisterChecks, 0, 0,
"enableOsiPointRegisterChecks()",
"Emit extra code to verify live regs at the start of a VM call are not\n"
"modified before its OsiPoint."),
JS_FN_HELP("displayName", DisplayName, 1, 0,
"displayName(fn)",
" Gets the display name for a function, which can possibly be a guessed or\n"

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

@ -1,3 +1,5 @@
enableOsiPointRegisterChecks();
function convertToInt(str) {
return str | 0;
}

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

@ -1,3 +1,5 @@
enableOsiPointRegisterChecks();
function DiagModule(stdlib, foreign) {
"use asm";

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

@ -0,0 +1,14 @@
var o = {
valueOf: function() {}
};
var threw = false;
function test(t) {
try {
for (x[t++] in o) {}
} catch (err) {
assertEq(t, 3.14);
threw = true;
}
}
test(3.14);
assertEq(threw, true);

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

@ -1,3 +1,4 @@
enableOsiPointRegisterChecks();
gczeal(4);
eval("(function() { " + "\

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

@ -818,6 +818,25 @@ CodeGenerator::visitOsiPoint(LOsiPoint *lir)
LSafepoint *safepoint = lir->associatedSafepoint();
JS_ASSERT(!safepoint->osiCallPointOffset());
safepoint->setOsiCallPointOffset(osiCallPointOffset);
#ifdef DEBUG
// There should be no movegroups or other instructions between
// an instruction and its OsiPoint. This is necessary because
// we use the OsiPoint's snapshot from within VM calls.
for (LInstructionReverseIterator iter(current->rbegin(lir)); iter != current->rend(); iter++) {
if (*iter == lir || iter->isNop())
continue;
JS_ASSERT(!iter->isMoveGroup());
JS_ASSERT(iter->safepoint() == safepoint);
break;
}
#endif
#ifdef CHECK_OSIPOINT_REGISTERS
if (shouldVerifyOsiPointRegs(safepoint))
verifyOsiPointRegs(safepoint);
#endif
return true;
}
@ -2717,6 +2736,20 @@ CodeGenerator::generateBody()
return false;
}
#ifdef CHECK_OSIPOINT_REGISTERS
if (iter->safepoint() && shouldVerifyOsiPointRegs(iter->safepoint())) {
// Set checkRegs to 0. If we perform a VM call, the instruction
// will set it to 1.
GeneralRegisterSet allRegs(GeneralRegisterSet::All());
Register scratch = allRegs.takeAny();
masm.push(scratch);
masm.loadJitActivation(scratch);
Address checkRegs(scratch, JitActivation::offsetOfCheckRegs());
masm.store32(Imm32(0), checkRegs);
masm.pop(scratch);
}
#endif
if (!callTraceLIR(i, *iter))
return false;

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

@ -92,6 +92,14 @@ struct IonOptions
// Default: true iff there are at least two CPUs available
bool parallelCompilation;
#ifdef CHECK_OSIPOINT_REGISTERS
// Emit extra code to verify live regs at the start of a VM call
// are not modified before its OsiPoint.
//
// Default: false
bool checkOsiPointRegisters;
#endif
// How many invocations or loop iterations are needed before functions
// are compiled with the baseline compiler.
//
@ -207,6 +215,9 @@ struct IonOptions
uce(true),
eaa(true),
parallelCompilation(false),
#ifdef CHECK_OSIPOINT_REGISTERS
checkOsiPointRegisters(false),
#endif
baselineUsesBeforeCompile(10),
usesBeforeCompile(1000),
usesBeforeInliningFactor(.125),

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

@ -291,14 +291,14 @@ IonFrameIterator::machineState() const
SafepointReader reader(ionScript(), safepoint());
uintptr_t *spill = spillBase();
// see CodeGeneratorShared::saveLive, we are only copying GPRs for now, FPUs
// are stored after but are not saved in the safepoint. This means that we
// are unable to restore any FPUs registers from an OOL VM call. This can
// cause some trouble for f.arguments.
MachineState machine;
for (GeneralRegisterBackwardIterator iter(reader.allSpills()); iter.more(); iter++)
for (GeneralRegisterBackwardIterator iter(reader.allGprSpills()); iter.more(); iter++)
machine.setRegisterLocation(*iter, --spill);
double *floatSpill = reinterpret_cast<double *>(spill);
for (FloatRegisterBackwardIterator iter(reader.allFloatSpills()); iter.more(); iter++)
machine.setRegisterLocation(*iter, --floatSpill);
return machine;
}
@ -779,7 +779,7 @@ MarkIonJSFrame(JSTracer *trc, const IonFrameIterator &frame)
uintptr_t *spill = frame.spillBase();
GeneralRegisterSet gcRegs = safepoint.gcSpills();
GeneralRegisterSet valueRegs = safepoint.valueSpills();
for (GeneralRegisterBackwardIterator iter(safepoint.allSpills()); iter.more(); iter++) {
for (GeneralRegisterBackwardIterator iter(safepoint.allGprSpills()); iter.more(); iter++) {
--spill;
if (gcRegs.has(*iter))
gc::MarkGCThingRoot(trc, reinterpret_cast<void **>(spill), "ion-gc-spill");
@ -812,7 +812,7 @@ MarkIonJSFrame(JSTracer *trc, const IonFrameIterator &frame)
GeneralRegisterSet slotsRegs = safepoint.slotsOrElementsSpills();
spill = frame.spillBase();
for (GeneralRegisterBackwardIterator iter(safepoint.allSpills()); iter.more(); iter++) {
for (GeneralRegisterBackwardIterator iter(safepoint.allGprSpills()); iter.more(); iter++) {
--spill;
if (slotsRegs.has(*iter))
trc->runtime->gcNursery.forwardBufferPointer(reinterpret_cast<HeapSlot **>(spill));
@ -1021,6 +1021,16 @@ MarkIonExitFrame(JSTracer *trc, const IonFrameIterator &frame)
static void
MarkJitActivation(JSTracer *trc, const JitActivationIterator &activations)
{
#ifdef CHECK_OSIPOINT_REGISTERS
if (js_IonOptions.checkOsiPointRegisters) {
// GC can modify spilled registers, breaking our register checks.
// To handle this, we disable these checks for the current VM call
// when a GC happens.
JitActivation *activation = activations.activation()->asJit();
activation->setCheckRegs(false);
}
#endif
for (IonFrameIterator frames(activations); !frames.done(); ++frames) {
switch (frames.type()) {
case IonFrame_Exit:

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

@ -204,6 +204,10 @@ IsNullOrUndefined(MIRType type)
#ifdef DEBUG
// Track the pipeline of opcodes which has produced a snapshot.
#define TRACK_SNAPSHOTS 1
// Make sure registers are not modified between an instruction and
// its OsiPoint.
#define CHECK_OSIPOINT_REGISTERS 1
#endif
} // namespace ion

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

@ -985,6 +985,12 @@ class LSafepoint : public TempObject
// The subset of liveRegs which contains gcthing pointers.
GeneralRegisterSet gcRegs_;
#ifdef CHECK_OSIPOINT_REGISTERS
// Temp regs of the current instruction. This set is never written to the
// safepoint; it's only used by assertions during compilation.
RegisterSet tempRegs_;
#endif
// Offset to a position in the safepoint stream, or
// INVALID_SAFEPOINT_OFFSET.
uint32_t safepointOffset_;
@ -1029,6 +1035,14 @@ class LSafepoint : public TempObject
const RegisterSet &liveRegs() const {
return liveRegs_;
}
#ifdef CHECK_OSIPOINT_REGISTERS
void addTempRegister(AnyRegister reg) {
tempRegs_.addUnchecked(reg);
}
const RegisterSet &tempRegs() const {
return tempRegs_;
}
#endif
void addGcRegister(Register reg) {
gcRegs_.addUnchecked(reg);
}

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

@ -309,6 +309,25 @@ LinearScanAllocator::moveInputAlloc(CodePosition pos, LAllocation *from, LAlloca
return moves->add(from, to);
}
static inline void
SetOsiPointUses(LiveInterval *interval, CodePosition defEnd, const LAllocation &allocation)
{
// Moves are inserted after OsiPoint instructions. This function sets
// any OsiPoint uses of this interval to the allocation of the value
// before the move.
JS_ASSERT(interval->index() == 0);
for (UsePositionIterator usePos(interval->usesBegin());
usePos != interval->usesEnd();
usePos++)
{
if (usePos->pos > defEnd)
break;
*static_cast<LAllocation *>(usePos->use) = allocation;
}
}
/*
* This function takes the allocations assigned to the live intervals and
* erases all virtual registers in the function with the allocations
@ -349,24 +368,17 @@ LinearScanAllocator::reifyAllocations()
LDefinition *def = reg->def();
LAllocation *spillFrom;
// Insert the moves after any OsiPoint or Nop instructions
// following this one. See minimalDefEnd for more info.
CodePosition defEnd = minimalDefEnd(reg->ins());
if (def->policy() == LDefinition::PRESET && def->output()->isRegister()) {
AnyRegister fixedReg = def->output()->toRegister();
LiveInterval *from = fixedIntervals[fixedReg.code()];
// Insert the move after any OsiPoint or Nop instructions
// following this one. See minimalDefEnd for more info.
CodePosition defEnd = minimalDefEnd(reg->ins());
// If we just skipped an OsiPoint, and it uses this vreg, it
// should use the fixed register instead.
for (UsePositionIterator usePos(interval->usesBegin());
usePos != interval->usesEnd();
usePos++)
{
if (usePos->pos > defEnd)
break;
*static_cast<LAllocation *>(usePos->use) = LAllocation(fixedReg);
}
// If we insert the move after an OsiPoint that uses this vreg,
// it should use the fixed register instead.
SetOsiPointUses(interval, defEnd, LAllocation(fixedReg));
if (!moveAfter(defEnd, from, interval))
return false;
@ -401,11 +413,14 @@ LinearScanAllocator::reifyAllocations()
if (reg->mustSpillAtDefinition() && !reg->ins()->isPhi() &&
(*reg->canonicalSpill() != *spillFrom))
{
// Insert a spill at the input of the next instruction. Control
// instructions never have outputs, so the next instruction is
// always valid. Note that we explicitly ignore phis, which
// should have been handled in resolveControlFlow().
LMoveGroup *moves = getMoveGroupAfter(outputOf(reg->ins()));
// If we move the spill after an OsiPoint, the OsiPoint should
// use the original location instead.
SetOsiPointUses(interval, defEnd, *spillFrom);
// Insert a spill after this instruction (or after any OsiPoint
// or Nop instructions). Note that we explicitly ignore phis,
// which should have been handled in resolveControlFlow().
LMoveGroup *moves = getMoveGroupAfter(defEnd);
if (!moves->add(spillFrom, reg->canonicalSpill()))
return false;
}

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

@ -625,6 +625,11 @@ class LiveRangeAllocator : public RegisterAllocator
LSafepoint *safepoint = ins->safepoint();
safepoint->addLiveRegister(a->toRegister());
#ifdef CHECK_OSIPOINT_REGISTERS
if (reg->isTemp())
safepoint->addTempRegister(a->toRegister());
#endif
}
}

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

@ -357,8 +357,7 @@ class RegisterAllocator
// Compute the shortest interval that captures vregs defined by ins.
// Watch for instructions that are followed by an OSI point and/or Nop.
// If moves are introduced between the instruction and the OSI point then
// safepoint information for the instruction may be incorrect. This is
// pretty disgusting and should be fixed somewhere else in the compiler.
// safepoint information for the instruction may be incorrect.
while (true) {
LInstruction *next = insData[outputOf(ins).next()].ins();
if (!next->isNop() && !next->isOsiPoint())

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

@ -85,6 +85,21 @@ struct FloatRegister {
}
};
class RegisterDump
{
protected: // Silence Clang warning.
uintptr_t regs_[Registers::Total];
double fpregs_[FloatRegisters::Total];
public:
static size_t offsetOfRegister(Register reg) {
return offsetof(RegisterDump, regs_) + reg.code() * sizeof(uintptr_t);
}
static size_t offsetOfRegister(FloatRegister reg) {
return offsetof(RegisterDump, fpregs_) + reg.code() * sizeof(double);
}
};
// Information needed to recover machine register state.
class MachineState
{

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

@ -52,12 +52,13 @@ void
SafepointWriter::writeGcRegs(LSafepoint *safepoint)
{
GeneralRegisterSet gc = safepoint->gcRegs();
GeneralRegisterSet spilled = safepoint->liveRegs().gprs();
GeneralRegisterSet spilledGpr = safepoint->liveRegs().gprs();
FloatRegisterSet spilledFloat = safepoint->liveRegs().fpus();
GeneralRegisterSet slots = safepoint->slotsOrElementsRegs();
GeneralRegisterSet valueRegs;
WriteRegisterMask(stream_, spilled.bits());
if (!spilled.empty()) {
WriteRegisterMask(stream_, spilledGpr.bits());
if (!spilledGpr.empty()) {
WriteRegisterMask(stream_, gc.bits());
WriteRegisterMask(stream_, slots.bits());
@ -68,12 +69,14 @@ SafepointWriter::writeGcRegs(LSafepoint *safepoint)
}
// GC registers are a subset of the spilled registers.
JS_ASSERT((valueRegs.bits() & ~spilled.bits()) == 0);
JS_ASSERT((gc.bits() & ~spilled.bits()) == 0);
JS_ASSERT((valueRegs.bits() & ~spilledGpr.bits()) == 0);
JS_ASSERT((gc.bits() & ~spilledGpr.bits()) == 0);
WriteRegisterMask(stream_, spilledFloat.bits());
#ifdef DEBUG
if (IonSpewEnabled(IonSpew_Safepoints)) {
for (GeneralRegisterForwardIterator iter(spilled); iter.more(); iter++) {
for (GeneralRegisterForwardIterator iter(spilledGpr); iter.more(); iter++) {
const char *type = gc.has(*iter)
? "gc"
: slots.has(*iter)
@ -83,6 +86,8 @@ SafepointWriter::writeGcRegs(LSafepoint *safepoint)
: "any";
IonSpew(IonSpew_Safepoints, " %s reg: %s", type, (*iter).name());
}
for (FloatRegisterForwardIterator iter(spilledFloat); iter.more(); iter++)
IonSpew(IonSpew_Safepoints, " float reg: %s", (*iter).name());
}
#endif
}
@ -332,12 +337,12 @@ SafepointReader::SafepointReader(IonScript *script, const SafepointIndex *si)
{
osiCallPointOffset_ = stream_.readUnsigned();
// gcSpills is a subset of allSpills.
allSpills_ = GeneralRegisterSet(stream_.readUnsigned());
if (allSpills_.empty()) {
gcSpills_ = allSpills_;
valueSpills_ = allSpills_;
slotsOrElementsSpills_ = allSpills_;
// gcSpills is a subset of allGprSpills.
allGprSpills_ = GeneralRegisterSet(stream_.readUnsigned());
if (allGprSpills_.empty()) {
gcSpills_ = allGprSpills_;
valueSpills_ = allGprSpills_;
slotsOrElementsSpills_ = allGprSpills_;
} else {
gcSpills_ = GeneralRegisterSet(stream_.readUnsigned());
slotsOrElementsSpills_ = GeneralRegisterSet(stream_.readUnsigned());
@ -346,6 +351,8 @@ SafepointReader::SafepointReader(IonScript *script, const SafepointIndex *si)
#endif
}
allFloatSpills_ = FloatRegisterSet(stream_.readUnsigned());
advanceFromGcRegs();
}

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

@ -67,7 +67,8 @@ class SafepointReader
GeneralRegisterSet gcSpills_;
GeneralRegisterSet valueSpills_;
GeneralRegisterSet slotsOrElementsSpills_;
GeneralRegisterSet allSpills_;
GeneralRegisterSet allGprSpills_;
FloatRegisterSet allFloatSpills_;
uint32_t nunboxSlotsRemaining_;
uint32_t slotsOrElementsSlotsRemaining_;
@ -95,8 +96,11 @@ class SafepointReader
GeneralRegisterSet valueSpills() const {
return valueSpills_;
}
GeneralRegisterSet allSpills() const {
return allSpills_;
GeneralRegisterSet allGprSpills() const {
return allGprSpills_;
}
FloatRegisterSet allFloatSpills() const {
return allFloatSpills_;
}
uint32_t osiReturnPointOffset() const;

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

@ -422,6 +422,159 @@ CodeGeneratorShared::markOsiPoint(LOsiPoint *ins, uint32_t *callPointOffset)
return osiIndices_.append(OsiIndex(*callPointOffset, so));
}
#ifdef CHECK_OSIPOINT_REGISTERS
template <class Op>
static void
HandleRegisterDump(Op op, MacroAssembler &masm, RegisterSet liveRegs, Register activation,
Register scratch)
{
const size_t baseOffset = JitActivation::offsetOfRegs();
// Handle live GPRs.
for (GeneralRegisterIterator iter(liveRegs.gprs()); iter.more(); iter++) {
Register reg = *iter;
Address dump(activation, baseOffset + RegisterDump::offsetOfRegister(reg));
if (reg == activation) {
// To use the original value of the activation register (that's
// now on top of the stack), we need the scratch register.
masm.push(scratch);
masm.loadPtr(Address(StackPointer, sizeof(uintptr_t)), scratch);
op(scratch, dump);
masm.pop(scratch);
} else {
op(reg, dump);
}
}
// Handle live FPRs.
for (FloatRegisterIterator iter(liveRegs.fpus()); iter.more(); iter++) {
FloatRegister reg = *iter;
Address dump(activation, baseOffset + RegisterDump::offsetOfRegister(reg));
op(reg, dump);
}
}
class StoreOp
{
MacroAssembler &masm;
public:
StoreOp(MacroAssembler &masm)
: masm(masm)
{}
void operator()(Register reg, Address dump) {
masm.storePtr(reg, dump);
}
void operator()(FloatRegister reg, Address dump) {
masm.storeDouble(reg, dump);
}
};
static void
StoreAllLiveRegs(MacroAssembler &masm, RegisterSet liveRegs)
{
// Store a copy of all live registers before performing the call.
// When we reach the OsiPoint, we can use this to check nothing
// modified them in the meantime.
// Load pointer to the JitActivation in a scratch register.
GeneralRegisterSet allRegs(GeneralRegisterSet::All());
Register scratch = allRegs.takeAny();
masm.push(scratch);
masm.loadJitActivation(scratch);
Address checkRegs(scratch, JitActivation::offsetOfCheckRegs());
masm.store32(Imm32(1), checkRegs);
StoreOp op(masm);
HandleRegisterDump<StoreOp>(op, masm, liveRegs, scratch, allRegs.getAny());
masm.pop(scratch);
}
class VerifyOp
{
MacroAssembler &masm;
Label *failure_;
public:
VerifyOp(MacroAssembler &masm, Label *failure)
: masm(masm), failure_(failure)
{}
void operator()(Register reg, Address dump) {
masm.branchPtr(Assembler::NotEqual, dump, reg, failure_);
}
void operator()(FloatRegister reg, Address dump) {
masm.loadDouble(dump, ScratchFloatReg);
masm.branchDouble(Assembler::DoubleNotEqual, ScratchFloatReg, reg, failure_);
}
};
static void
OsiPointRegisterCheckFailed()
{
// Any live register captured by a safepoint (other than temp registers)
// must remain unchanged between the call and the OsiPoint instruction.
MOZ_ASSUME_UNREACHABLE("Modified registers between VM call and OsiPoint");
}
void
CodeGeneratorShared::verifyOsiPointRegs(LSafepoint *safepoint)
{
// Ensure the live registers stored by callVM did not change between
// the call and this OsiPoint. Try-catch relies on this invariant.
// Load pointer to the JitActivation in a scratch register.
GeneralRegisterSet allRegs(GeneralRegisterSet::All());
Register scratch = allRegs.takeAny();
masm.push(scratch);
masm.loadJitActivation(scratch);
// If we should not check registers (because the instruction did not call
// into the VM, or a GC happened), we're done.
Label failure, done;
Address checkRegs(scratch, JitActivation::offsetOfCheckRegs());
masm.branch32(Assembler::Equal, checkRegs, Imm32(0), &done);
// Ignore temp registers. Some instructions (like LValueToInt32) modify
// temps after calling into the VM. This is fine because no other
// instructions (including this OsiPoint) will depend on them.
RegisterSet liveRegs = safepoint->liveRegs();
liveRegs = RegisterSet::Intersect(liveRegs, RegisterSet::Not(safepoint->tempRegs()));
VerifyOp op(masm, &failure);
HandleRegisterDump<VerifyOp>(op, masm, liveRegs, scratch, allRegs.getAny());
masm.jump(&done);
masm.bind(&failure);
masm.setupUnalignedABICall(0, scratch);
masm.callWithABI(JS_FUNC_TO_DATA_PTR(void *, OsiPointRegisterCheckFailed));
masm.breakpoint();
masm.bind(&done);
masm.pop(scratch);
}
bool
CodeGeneratorShared::shouldVerifyOsiPointRegs(LSafepoint *safepoint)
{
if (!js_IonOptions.checkOsiPointRegisters)
return false;
if (gen->info().executionMode() != SequentialExecution)
return false;
if (safepoint->liveRegs().empty(true) && safepoint->liveRegs().empty(false))
return false; // No registers to check.
return true;
}
#endif
// Before doing any call to Cpp, you should ensure that volatile
// registers are evicted by the register allocator.
bool
@ -455,6 +608,11 @@ CodeGeneratorShared::callVM(const VMFunction &fun, LInstruction *ins, const Regi
if (!wrapper)
return false;
#ifdef CHECK_OSIPOINT_REGISTERS
if (shouldVerifyOsiPointRegs(ins->safepoint()))
StoreAllLiveRegs(masm, ins->safepoint()->liveRegs());
#endif
// Call the wrapper function. The wrapper is in charge to unwind the stack
// when returning from the call. Failures are handled with exceptions based
// on the return value of the C functions. To guard the outcome of the

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

@ -200,6 +200,11 @@ class CodeGeneratorShared : public LInstructionVisitor
return index;
}
#ifdef CHECK_OSIPOINT_REGISTERS
bool shouldVerifyOsiPointRegs(LSafepoint *safepoint);
void verifyOsiPointRegs(LSafepoint *safepoint);
#endif
public:
// This is needed by addCache to update the cache with the jump
// informations provided by the out-of-line path.

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

@ -1291,6 +1291,14 @@ class JitActivation : public Activation
bool firstFrameIsConstructing_;
bool active_;
#ifdef CHECK_OSIPOINT_REGISTERS
protected:
// Used to verify that live registers don't change between a VM call and
// the OsiPoint that follows it. Protected to silence Clang warning.
uint32_t checkRegs_;
RegisterDump regs_;
#endif
public:
JitActivation(JSContext *cx, bool firstFrameIsConstructing, bool active = true);
~JitActivation();
@ -1309,6 +1317,18 @@ class JitActivation : public Activation
bool firstFrameIsConstructing() const {
return firstFrameIsConstructing_;
}
#ifdef CHECK_OSIPOINT_REGISTERS
void setCheckRegs(bool check) {
checkRegs_ = check;
}
static size_t offsetOfCheckRegs() {
return offsetof(JitActivation, checkRegs_);
}
static size_t offsetOfRegs() {
return offsetof(JitActivation, regs_);
}
#endif
};
// A filtering of the ActivationIterator to only stop at JitActivations.

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

@ -6180,7 +6180,9 @@ PresShell::HandleEvent(nsIFrame *aFrame,
// mouse out events at the root EventStateManager.
if (!captureRetarget && !isWindowLevelMouseExit) {
nsPoint eventPoint;
uint32_t flags;
if (aEvent->message == NS_TOUCH_START) {
flags |= INPUT_IGNORE_ROOT_SCROLL_FRAME;
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
// if this is a continuing session, ensure that all these events are
// in the same document by taking the target of the events already in
@ -6199,7 +6201,6 @@ PresShell::HandleEvent(nsIFrame *aFrame,
int32_t id = touch->Identifier();
if (!gCaptureTouchList.Get(id, nullptr)) {
// find the target for this touch
uint32_t flags = 0;
eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
touch->mRefPoint,
frame);
@ -6261,7 +6262,6 @@ PresShell::HandleEvent(nsIFrame *aFrame,
} else {
eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, frame);
}
uint32_t flags = 0;
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<nsMouseEvent*>(aEvent)->ignoreRootScrollFrame) {
flags |= INPUT_IGNORE_ROOT_SCROLL_FRAME;

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

@ -119,8 +119,6 @@ using namespace mozilla::system;
#include "nsDocument.h"
#include "mozilla/dom/HTMLVideoElement.h"
extern void NS_ShutdownEventTargetChainItemRecyclePool();
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
@ -378,8 +376,6 @@ nsLayoutStatics::Shutdown()
nsRegion::ShutdownStatic();
NS_ShutdownEventTargetChainItemRecyclePool();
HTMLInputElement::DestroyUploadLastDir();
nsLayoutUtils::Shutdown();

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

@ -1,6 +1,16 @@
#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
import android.app.Activity;
import android.content.SharedPreferences;
import java.lang.reflect.Method;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* This test will test if doorhangers are displayed and dismissed
The test will test:
* geolocation doorhangers - sharing and not sharing the location dismisses the doorhanger
@ -65,6 +75,45 @@ public class testDoorHanger extends BaseTest {
// Make sure doorhanger is hidden
mAsserter.is(mSolo.searchText(GEO_MESSAGE), false, "Geolocation doorhanger notification is hidden when opening a new tab");
boolean offlineAllowedByDefault = true;
try {
// Save offline-allow-by-default preferences first
JSONArray getPrefData = new JSONArray();
getPrefData.put("offline-apps.allow_by_default");
JSONObject message = new JSONObject();
message.put("requestId", "testDoorHanger");
message.put("preferences", getPrefData);
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
mActions.sendGeckoEvent("Preferences:Get", message.toString());
JSONObject data = null;
String requestId = "";
// Wait until we get the correct "Preferences:Data" event
while (!requestId.equals("testDoorHanger")) {
data = new JSONObject(eventExpecter.blockForEventData());
requestId = data.getString("requestId");
}
eventExpecter.unregisterListener();
JSONArray preferences = data.getJSONArray("preferences");
if (preferences.length() > 0) {
JSONObject pref = (JSONObject) preferences.get(0);
offlineAllowedByDefault = pref.getBoolean("value");
}
// Turn off offline-allow-by-default
JSONObject jsonPref = new JSONObject();
jsonPref.put("name", "offline-apps.allow_by_default");
jsonPref.put("type", "bool");
jsonPref.put("value", false);
mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString());
} catch (JSONException e) {
mAsserter.ok(false, "exception getting preference", e.toString());
}
// Load offline storage page
loadUrl(OFFLINE_STORAGE_URL);
waitForText(OFFLINE_MESSAGE);
@ -84,6 +133,18 @@ public class testDoorHanger extends BaseTest {
loadUrl(OFFLINE_STORAGE_URL);
mAsserter.is(mSolo.searchText(OFFLINE_MESSAGE), false, "Offline storage doorhanger is no longer triggered");
try {
// Revert offline setting
JSONObject jsonPref = new JSONObject();
jsonPref.put("name", "offline-apps.allow_by_default");
jsonPref.put("type", "boolean");
jsonPref.put("value", offlineAllowedByDefault);
mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString());
} catch (JSONException e) {
mAsserter.ok(false, "exception setting preference", e.toString());
}
// Load login page
loadUrl(LOGIN_URL);
waitForText(LOGIN_MESSAGE);

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

@ -61,6 +61,8 @@ pref("browser.cache.disk_cache_ssl", true);
pref("browser.cache.check_doc_frequency", 3);
pref("browser.cache.offline.enable", true);
// enable offline apps by default, disable prompt
pref("offline-apps.allow_by_default", true);
// offline cache capacity in kilobytes
pref("browser.cache.offline.capacity", 512000);

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

@ -45,7 +45,7 @@
<a href="http://www.mozilla.org/MPL/2.0/FAQ.html">FAQ</a> to help
you understand it. The remainder of the software which is not
under the MPL is available under one of a variety of other
permissive licenses. Those that require reproduction
free and open source licenses. Those that require reproduction
of the license text in the distribution are given below.
(Note: your copy of this product may not contain code covered by one
or more of the licenses listed here, depending on the exact product
@ -56,6 +56,9 @@
<li><a href="about:license#mpl">Mozilla Public License 2.0</a>
<br><br>
</li>
<li><a href="about:license#lgpl">GNU Lesser General Public License 2.1</a>
<br><br>
</li>
<li><a href="about:license#ACE">ACE License</a></li>
<li><a href="about:license#android">Android Open Source License</a></li>
<li><a href="about:license#angle">ANGLE License</a></li>
@ -580,6 +583,562 @@
<hr>
<h1 id="lgpl">GNU Lesser General Public License 2.1</h1>
<p>This product contains code from the following LGPLed libraries:</p>
<ul>
<li><a href="http://www.surina.net/soundtouch/">libsoundtouch</a>
</ul>
<pre>
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
</pre>
<h3><a id="SEC2">Preamble</a></h3>
<p>
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
</p>
<p>
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
</p>
<p>
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
</p>
<p>
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
</p>
<p>
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
</p>
<p>
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
</p>
<p>
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
</p>
<p>
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
</p>
<p>
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
</p>
<p>
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
</p>
<p>
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
</p>
<p>
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
</p>
<p>
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
</p>
<p>
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
</p>
<p>
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
</p>
<h3><a id="SEC3">TERMS AND CONDITIONS FOR COPYING,
DISTRIBUTION AND MODIFICATION</a></h3>
<p>
<strong>0.</strong>
This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
</p>
<p>
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
</p>
<p>
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
</p>
<p>
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
</p>
<p>
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
</p>
<p>
<strong>1.</strong>
You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
</p>
<p>
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
</p>
<p>
<strong>2.</strong>
You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
</p>
<ul>
<li><strong>a)</strong>
The modified work must itself be a software library.</li>
<li><strong>b)</strong>
You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.</li>
<li><strong>c)</strong>
You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.</li>
<li><strong>d)</strong>
If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
<p>
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)</p></li>
</ul>
<p>
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be
reasonably considered independent and separate works in themselves, then
this License, and its terms, do not apply to those sections when you
distribute them as separate works. But when you distribute the same
sections as part of a whole which is a work based on the Library, the
distribution of the whole must be on the terms of this License, whose
permissions for other licensees extend to the entire whole, and thus to
each and every part regardless of who wrote it.
</p>
<p>
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works
based on the Library.
</p>
<p>
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of
this License.
</p>
<p>
<strong>3.</strong>
You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
</p>
<p>
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
</p>
<p>
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
</p>
<p>
<strong>4.</strong>
You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
</p>
<p>
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
</p>
<p>
<strong>5.</strong>
A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
</p>
<p>
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
</p>
<p>
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
</p>
<p>
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
</p>
<p>
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
</p>
<p>
<strong>6.</strong>
As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
</p>
<p>
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
</p>
<ul>
<li><strong>a)</strong> Accompany the work with the complete
corresponding machine-readable source code for the Library
including whatever changes were used in the work (which must be
distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete
machine-readable "work that uses the Library", as object code
and/or source code, so that the user can modify the Library and
then relink to produce a modified executable containing the
modified Library. (It is understood that the user who changes the
contents of definitions files in the Library will not necessarily
be able to recompile the application to use the modified
definitions.)</li>
<li><strong>b)</strong> Use a suitable shared library mechanism
for linking with the Library. A suitable mechanism is one that
(1) uses at run time a copy of the library already present on the
user's computer system, rather than copying library functions into
the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the
modified version is interface-compatible with the version that the
work was made with.</li>
<li><strong>c)</strong> Accompany the work with a written offer,
valid for at least three years, to give the same user the
materials specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.</li>
<li><strong>d)</strong> If distribution of the work is made by
offering access to copy from a designated place, offer equivalent
access to copy the above specified materials from the same
place.</li>
<li><strong>e)</strong> Verify that the user has already received
a copy of these materials or that you have already sent this user
a copy.</li>
</ul>
<p>
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
</p>
<p>
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
</p>
<p>
<strong>7.</strong> You may place library facilities that are a work
based on the Library side-by-side in a single library together with
other library facilities not covered by this License, and distribute
such a combined library, provided that the separate distribution of
the work based on the Library and of the other library facilities is
otherwise permitted, and provided that you do these two things:
</p>
<ul>
<li><strong>a)</strong> Accompany the combined library with a copy
of the same work based on the Library, uncombined with any other
library facilities. This must be distributed under the terms of
the Sections above.</li>
<li><strong>b)</strong> Give prominent notice with the combined
library of the fact that part of it is a work based on the
Library, and explaining where to find the accompanying uncombined
form of the same work.</li>
</ul>
<p>
<strong>8.</strong> You may not copy, modify, sublicense, link with,
or distribute the Library except as expressly provided under this
License. Any attempt otherwise to copy, modify, sublicense, link
with, or distribute the Library is void, and will automatically
terminate your rights under this License. However, parties who have
received copies, or rights, from you under this License will not have
their licenses terminated so long as such parties remain in full
compliance.
</p>
<p>
<strong>9.</strong>
You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
</p>
<p>
<strong>10.</strong>
Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
</p>
<p>
<strong>11.</strong>
If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
</p>
<p>
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
</p>
<p>
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
</p>
<p>
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
</p>
<p>
<strong>12.</strong>
If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
</p>
<p>
<strong>13.</strong>
The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
</p>
<p>
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
</p>
<p>
<strong>14.</strong>
If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
</p>
<p>
<strong>NO WARRANTY</strong>
</p>
<p>
<strong>15.</strong>
BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
</p>
<p>
<strong>16.</strong>
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
</p>
<hr>
<h1><a id="ACE"></a>ACE License</h1>
<p>This license applies to the file

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

@ -686,22 +686,14 @@ OfflineAppPermForURI(nsIURI *aURI,
const char *permName = pinned ? "pin-app" : "offline-app";
permissionManager->TestExactPermission(innerURI, permName, &perm);
if (perm == nsIPermissionManager::UNKNOWN_ACTION && !pinned) {
static const char kPrefName[] = "offline-apps.allow_by_default";
if (aPrefBranch) {
aPrefBranch->GetBoolPref(kPrefName, aAllowed);
} else {
*aAllowed = Preferences::GetBool(kPrefName, false);
}
return NS_OK;
}
if (perm == nsIPermissionManager::ALLOW_ACTION ||
perm == nsIOfflineCacheUpdateService::ALLOW_NO_WARN) {
*aAllowed = true;
}
// offline-apps.allow_by_default is now effective at the cache selection
// algorithm code (nsContentSink).
return NS_OK;
}

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

@ -53,6 +53,7 @@ CMMSRCS = \
GfxInfo.mm \
WidgetTraceEvent.mm \
NativeKeyBindings.mm \
nsColorPicker.mm \
$(NULL)
ifeq (x86_64,$(TARGET_CPU))

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

@ -0,0 +1,42 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsColorPicker_h_
#define nsColorPicker_h_
#include "nsIColorPicker.h"
#include "nsString.h"
#include "nsCOMPtr.h"
class nsIColorPickerShownCallback;
class nsIDOMWindow;
@class NSColorPanelWrapper;
@class NSColor;
class nsColorPicker MOZ_FINAL : public nsIColorPicker
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDOMWindow* aParent, const nsAString& aTitle,
const nsAString& aInitialColor);
NS_IMETHOD Open(nsIColorPickerShownCallback* aCallback);
// For NSColorPanelWrapper.
void Update(NSColor* aColor);
void Done();
private:
static NSColor* GetNSColorFromHexString(const nsAString& aColor);
static void GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult);
nsString mTitle;
nsString mColor;
NSColorPanelWrapper* mColorPanel;
nsCOMPtr<nsIColorPickerShownCallback> mCallback;
};
#endif // nsColorPicker_h_

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

@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#import <Cocoa/Cocoa.h>
#include "nsColorPicker.h"
#include "nsCocoaUtils.h"
using namespace mozilla;
static unsigned int
HexStrToInt(NSString* str)
{
unsigned int result = 0;
for (unsigned int i = 0; i < [str length]; ++i) {
char c = [str characterAtIndex:i];
result *= 16;
if (c >= '0' && c <= '9') {
result += c - '0';
} else if (c >= 'A' && c <= 'F') {
result += 10 + (c - 'A');
} else {
result += 10 + (c - 'a');
}
}
return result;
}
@interface NSColorPanelWrapper : NSObject <NSWindowDelegate>
{
NSColorPanel* mColorPanel;
nsColorPicker* mColorPicker;
}
- (id)initWithPicker:(nsColorPicker*)aPicker;
- (void)open:(NSColor*)aInitialColor title:(NSString*)aTitle;
- (void)colorChanged:(NSColorPanel*)aPanel;
@end
@implementation NSColorPanelWrapper
- (id)initWithPicker:(nsColorPicker*)aPicker
{
mColorPicker = aPicker;
mColorPanel = [NSColorPanel sharedColorPanel];
self = [super init];
return self;
}
- (void)open:(NSColor*)aInitialColor title:(NSString*)aTitle
{
[mColorPanel setTitle:aTitle];
[mColorPanel setColor:aInitialColor];
[mColorPanel setTarget:self];
[mColorPanel setAction:@selector(colorChanged:)];
[mColorPanel setDelegate:self];
[mColorPanel makeKeyAndOrderFront:nil];
}
- (void)colorChanged:(NSColorPanel*)aPanel
{
mColorPicker->Update([mColorPanel color]);
}
- (void)windowWillClose:(NSNotification*)aNotification
{
mColorPicker->Done();
}
- (void)dealloc
{
if ([mColorPanel delegate] == self) {
[mColorPanel setTarget:nil];
[mColorPanel setAction:nil];
[mColorPanel setDelegate:nil];
}
mColorPanel = nil;
mColorPicker = nullptr;
[super dealloc];
}
@end
NS_IMPL_ISUPPORTS1(nsColorPicker, nsIColorPicker)
NS_IMETHODIMP
nsColorPicker::Init(nsIDOMWindow* aParent, const nsAString& aTitle,
const nsAString& aInitialColor)
{
mTitle = aTitle;
mColor = aInitialColor;
mColorPanel = [[NSColorPanelWrapper alloc] initWithPicker:this];
return NS_OK;
}
/* static */ NSColor*
nsColorPicker::GetNSColorFromHexString(const nsAString& aColor)
{
NSString* str = nsCocoaUtils::ToNSString(aColor);
double red = HexStrToInt([str substringWithRange:NSMakeRange(1, 2)]) / 255.0;
double green = HexStrToInt([str substringWithRange:NSMakeRange(3, 2)]) / 255.0;
double blue = HexStrToInt([str substringWithRange:NSMakeRange(5, 2)]) / 255.0;
return [NSColor colorWithDeviceRed: red green: green blue: blue alpha: 1.0];
}
/* static */ void
nsColorPicker::GetHexStringFromNSColor(NSColor* aColor, nsAString& aResult)
{
CGFloat redFloat, greenFloat, blueFloat;
[aColor getRed: &redFloat green: &greenFloat blue: &blueFloat alpha: nil];
nsCocoaUtils::GetStringForNSString([NSString stringWithFormat:@"#%02x%02x%02x",
(int)(redFloat * 255),
(int)(greenFloat * 255),
(int)(blueFloat * 255)],
aResult);
}
NS_IMETHODIMP
nsColorPicker::Open(nsIColorPickerShownCallback* aCallback)
{
MOZ_ASSERT(aCallback);
mCallback = aCallback;
[mColorPanel open:GetNSColorFromHexString(mColor)
title:nsCocoaUtils::ToNSString(mTitle)];
NS_ADDREF_THIS();
return NS_OK;
}
void
nsColorPicker::Update(NSColor* aColor)
{
GetHexStringFromNSColor(aColor, mColor);
mCallback->Update(mColor);
}
void
nsColorPicker::Done()
{
mCallback->Done(EmptyString());
mCallback = nullptr;
[mColorPanel release];
NS_RELEASE_THIS();
}

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

@ -15,6 +15,7 @@
#include "nsAppShell.h"
#include "nsAppShellSingleton.h"
#include "nsFilePicker.h"
#include "nsColorPicker.h"
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
@ -37,6 +38,7 @@
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCocoaWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildView)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPicker)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
@ -133,6 +135,7 @@ NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
NS_DEFINE_NAMED_CID(NS_POPUP_CID);
NS_DEFINE_NAMED_CID(NS_CHILD_CID);
NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
NS_DEFINE_NAMED_CID(NS_SOUND_CID);
NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
@ -163,6 +166,7 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_POPUP_CID, false, NULL, nsCocoaWindowConstructor },
{ &kNS_CHILD_CID, false, NULL, nsChildViewConstructor },
{ &kNS_FILEPICKER_CID, false, NULL, nsFilePickerConstructor },
{ &kNS_COLORPICKER_CID, false, NULL, nsColorPickerConstructor },
{ &kNS_APPSHELL_CID, false, NULL, nsAppShellConstructor },
{ &kNS_SOUND_CID, false, NULL, nsSoundConstructor },
{ &kNS_TRANSFERABLE_CID, false, NULL, nsTransferableConstructor },
@ -197,6 +201,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/widgets/popup/mac;1", &kNS_POPUP_CID },
{ "@mozilla.org/widgets/childwindow/mac;1", &kNS_CHILD_CID },
{ "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID },
{ "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID },
{ "@mozilla.org/widget/appshell/mac;1", &kNS_APPSHELL_CID },
{ "@mozilla.org/sound;1", &kNS_SOUND_CID },
{ "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },

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