mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1014657 - Port DOMStorageEvent to WebIDL and remove nsIDOMStorageEvent, r=smaug, f=ms2ger
This commit is contained in:
parent
5a9355d5a0
commit
29df09f67c
@ -11148,12 +11148,15 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
nsIPrincipal *principal;
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIDOMStorageEvent> event = do_QueryInterface(aSubject, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<StorageEvent> event = static_cast<StorageEvent*>(aSubject);
|
||||
if (!event) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMStorage> changingStorage;
|
||||
rv = event->GetStorageArea(getter_AddRefs(changingStorage));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDOMStorage> changingStorage = event->GetStorageArea();
|
||||
if (!changingStorage) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool fireMozStorageChanged = false;
|
||||
principal = GetPrincipal();
|
||||
@ -11221,16 +11224,16 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
|
||||
// Clone the storage event included in the observer notification. We want
|
||||
// to dispatch clones rather than the original event.
|
||||
rv = CloneStorageEvent(fireMozStorageChanged ?
|
||||
NS_LITERAL_STRING("MozStorageChanged") :
|
||||
NS_LITERAL_STRING("storage"),
|
||||
event);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<StorageEvent> newEvent =
|
||||
CloneStorageEvent(fireMozStorageChanged ?
|
||||
NS_LITERAL_STRING("MozStorageChanged") :
|
||||
NS_LITERAL_STRING("storage"),
|
||||
event);
|
||||
|
||||
event->SetTrusted(true);
|
||||
newEvent->SetTrusted(true);
|
||||
|
||||
if (fireMozStorageChanged) {
|
||||
WidgetEvent* internalEvent = event->GetInternalNSEvent();
|
||||
WidgetEvent* internalEvent = newEvent->GetInternalNSEvent();
|
||||
internalEvent->mFlags.mOnlyChromeDispatch = true;
|
||||
}
|
||||
|
||||
@ -11239,12 +11242,12 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
// store the domain in which the change happened and fire the
|
||||
// events if we're ever thawed.
|
||||
|
||||
mPendingStorageEvents.AppendObject(event);
|
||||
mPendingStorageEvents.AppendElement(newEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool defaultActionEnabled;
|
||||
DispatchEvent((nsIDOMStorageEvent *)event, &defaultActionEnabled);
|
||||
DispatchEvent(newEvent, &defaultActionEnabled);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -11319,37 +11322,22 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
already_AddRefed<StorageEvent>
|
||||
nsGlobalWindow::CloneStorageEvent(const nsAString& aType,
|
||||
nsCOMPtr<nsIDOMStorageEvent>& aEvent)
|
||||
const nsRefPtr<StorageEvent>& aEvent)
|
||||
{
|
||||
nsresult rv;
|
||||
StorageEventInit dict;
|
||||
|
||||
bool canBubble;
|
||||
bool cancelable;
|
||||
nsAutoString key;
|
||||
nsAutoString oldValue;
|
||||
nsAutoString newValue;
|
||||
nsAutoString url;
|
||||
nsCOMPtr<nsIDOMStorage> storageArea;
|
||||
dict.mBubbles = aEvent->Bubbles();
|
||||
dict.mCancelable = aEvent->Cancelable();
|
||||
aEvent->GetKey(dict.mKey);
|
||||
aEvent->GetOldValue(dict.mOldValue);
|
||||
aEvent->GetNewValue(dict.mNewValue);
|
||||
aEvent->GetUrl(dict.mUrl);
|
||||
dict.mStorageArea = aEvent->GetStorageArea();
|
||||
|
||||
nsCOMPtr<nsIDOMEvent> domEvent = do_QueryInterface(aEvent, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
domEvent->GetBubbles(&canBubble);
|
||||
domEvent->GetCancelable(&cancelable);
|
||||
|
||||
aEvent->GetKey(key);
|
||||
aEvent->GetOldValue(oldValue);
|
||||
aEvent->GetNewValue(newValue);
|
||||
aEvent->GetUrl(url);
|
||||
aEvent->GetStorageArea(getter_AddRefs(storageArea));
|
||||
|
||||
NS_NewDOMStorageEvent(getter_AddRefs(domEvent), this, nullptr, nullptr);
|
||||
aEvent = do_QueryInterface(domEvent);
|
||||
return aEvent->InitStorageEvent(aType, canBubble, cancelable,
|
||||
key, oldValue, newValue,
|
||||
url, storageArea);
|
||||
nsRefPtr<StorageEvent> event = StorageEvent::Constructor(this, aType, dict);
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -11357,7 +11345,7 @@ nsGlobalWindow::FireDelayedDOMEvents()
|
||||
{
|
||||
FORWARD_TO_INNER(FireDelayedDOMEvents, (), NS_ERROR_UNEXPECTED);
|
||||
|
||||
for (int32_t i = 0; i < mPendingStorageEvents.Count(); ++i) {
|
||||
for (uint32_t i = 0, len = mPendingStorageEvents.Length(); i < len; ++i) {
|
||||
Observe(mPendingStorageEvents[i], "dom-storage2-changed", nullptr);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,8 @@
|
||||
#include "nsSize.h"
|
||||
#include "mozFlushType.h"
|
||||
#include "prclist.h"
|
||||
#include "nsIDOMStorageEvent.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
@ -1336,8 +1337,9 @@ protected:
|
||||
|
||||
inline int32_t DOMMinTimeoutValue() const;
|
||||
|
||||
nsresult CloneStorageEvent(const nsAString& aType,
|
||||
nsCOMPtr<nsIDOMStorageEvent>& aEvent);
|
||||
already_AddRefed<mozilla::dom::StorageEvent>
|
||||
CloneStorageEvent(const nsAString& aType,
|
||||
const nsRefPtr<mozilla::dom::StorageEvent>& aEvent);
|
||||
|
||||
// Outer windows only.
|
||||
nsDOMWindowList* GetWindowList();
|
||||
@ -1522,7 +1524,7 @@ protected:
|
||||
// These member variables are used on both inner and the outer windows.
|
||||
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
|
||||
|
||||
typedef nsCOMArray<nsIDOMStorageEvent> nsDOMStorageEventArray;
|
||||
typedef nsTArray<nsRefPtr<mozilla::dom::StorageEvent>> nsDOMStorageEventArray;
|
||||
nsDOMStorageEventArray mPendingStorageEvents;
|
||||
|
||||
uint32_t mTimeoutsSuspendDepth;
|
||||
|
@ -832,9 +832,7 @@ EventDispatcher::CreateEvent(EventTarget* aOwner,
|
||||
return NS_NewDOMMozSmsEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
if (aEventType.LowerCaseEqualsLiteral("mozmmsevent"))
|
||||
return NS_NewDOMMozMmsEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
if (aEventType.LowerCaseEqualsLiteral("storageevent")) {
|
||||
return NS_NewDOMStorageEvent(aDOMEvent, aOwner, aPresContext, nullptr);
|
||||
}
|
||||
|
||||
// NEW EVENT TYPES SHOULD NOT BE ADDED HERE; THEY SHOULD USE ONLY EVENT
|
||||
// CONSTRUCTORS
|
||||
|
||||
|
@ -550,9 +550,6 @@ is(receivedEvent, e, "Wrong event!");
|
||||
|
||||
// StorageEvent
|
||||
|
||||
e = document.createEvent("StorageEvent");
|
||||
ok(e, "Should have created an event!");
|
||||
|
||||
try {
|
||||
e = new StorageEvent();
|
||||
} catch(exp) {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMStorage.idl',
|
||||
'nsIDOMStorageEvent.idl',
|
||||
'nsIDOMStorageManager.idl',
|
||||
]
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
/* -*- Mode: IDL; 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/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
/**
|
||||
* Interface for a client side storage. See
|
||||
* http://dev.w3.org/html5/webstorage/#the-storage-event
|
||||
* for more information.
|
||||
*
|
||||
* Event sent to a window when a storage area changes.
|
||||
*/
|
||||
|
||||
interface nsIDOMStorage;
|
||||
|
||||
[builtinclass, uuid(85f04275-4679-4e89-b43f-142bbbab1e89)]
|
||||
interface nsIDOMStorageEvent : nsIDOMEvent
|
||||
{
|
||||
/**
|
||||
* Attribute represents the key being changed. The key attribute is null
|
||||
* when change has been invoked by the storage clear() method.
|
||||
*/
|
||||
readonly attribute DOMString key;
|
||||
|
||||
/**
|
||||
* The original value of the key. The oldValue is null when the change
|
||||
* has been invoked by storage clear() method or the key has been newly
|
||||
* added and therefor doesn't have any previous value.
|
||||
*/
|
||||
readonly attribute DOMString oldValue;
|
||||
|
||||
/**
|
||||
* The new value of the key. The newValue is null when the change
|
||||
* has been invoked by storage clear() method or the key has been removed
|
||||
* from the storage.
|
||||
*/
|
||||
readonly attribute DOMString newValue;
|
||||
|
||||
/**
|
||||
* Represents the address of the document whose key changed.
|
||||
*/
|
||||
readonly attribute DOMString url;
|
||||
|
||||
/**
|
||||
* Represents the Storage object that was affected.
|
||||
*/
|
||||
readonly attribute nsIDOMStorage storageArea;
|
||||
|
||||
/**
|
||||
* Initialize the event in a manner analogous to the similarly-named method
|
||||
* in the DOM Events interfaces.
|
||||
*/
|
||||
void initStorageEvent(in DOMString typeArg,
|
||||
in boolean canBubbleArg,
|
||||
in boolean cancelableArg,
|
||||
in DOMString keyArg,
|
||||
in DOMString oldValueArg,
|
||||
in DOMString newValueArg,
|
||||
in DOMString urlArg,
|
||||
in nsIDOMStorage storageAreaArg);
|
||||
};
|
@ -7,7 +7,7 @@
|
||||
#include "DOMStorageCache.h"
|
||||
#include "DOMStorageManager.h"
|
||||
|
||||
#include "nsIDOMStorageEvent.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
@ -190,23 +190,19 @@ DOMStorage::BroadcastChangeNotification(const nsSubstring& aKey,
|
||||
const nsSubstring& aOldValue,
|
||||
const nsSubstring& aNewValue)
|
||||
{
|
||||
nsCOMPtr<nsIDOMEvent> domEvent;
|
||||
StorageEventInit dict;
|
||||
dict.mBubbles = false;
|
||||
dict.mCancelable = false;
|
||||
dict.mKey = aKey;
|
||||
dict.mNewValue = aNewValue;
|
||||
dict.mOldValue = aOldValue;
|
||||
dict.mStorageArea = static_cast<nsIDOMStorage*>(this);
|
||||
dict.mUrl = mDocumentURI;
|
||||
|
||||
// Note, this DOM event should never reach JS. It is cloned later in
|
||||
// nsGlobalWindow.
|
||||
NS_NewDOMStorageEvent(getter_AddRefs(domEvent), nullptr, nullptr, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDOMStorageEvent> event = do_QueryInterface(domEvent);
|
||||
nsresult rv = event->InitStorageEvent(NS_LITERAL_STRING("storage"),
|
||||
false,
|
||||
false,
|
||||
aKey,
|
||||
aOldValue,
|
||||
aNewValue,
|
||||
mDocumentURI,
|
||||
static_cast<nsIDOMStorage*>(this));
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
nsRefPtr<StorageEvent> event =
|
||||
StorageEvent::Constructor(nullptr, NS_LITERAL_STRING("storage"), dict);
|
||||
|
||||
nsRefPtr<StorageNotifierRunnable> r =
|
||||
new StorageNotifierRunnable(event,
|
||||
|
@ -11,7 +11,7 @@
|
||||
*/
|
||||
interface Storage;
|
||||
|
||||
[Constructor(DOMString type, optional StorageEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
|
||||
[Constructor(DOMString type, optional StorageEventInit eventInitDict)]
|
||||
interface StorageEvent : Event
|
||||
{
|
||||
readonly attribute DOMString? key;
|
||||
@ -19,17 +19,6 @@ interface StorageEvent : Event
|
||||
readonly attribute DOMString? newValue;
|
||||
readonly attribute DOMString? url;
|
||||
readonly attribute Storage? storageArea;
|
||||
|
||||
// initStorageEvent is a Gecko specific deprecated method.
|
||||
[Throws]
|
||||
void initStorageEvent(DOMString type,
|
||||
boolean canBubble,
|
||||
boolean cancelable,
|
||||
DOMString? key,
|
||||
DOMString? oldValue,
|
||||
DOMString? newValue,
|
||||
DOMString? url,
|
||||
Storage? storageArea);
|
||||
};
|
||||
|
||||
dictionary StorageEventInit : EventInit
|
||||
|
@ -534,7 +534,6 @@ WEBIDL_FILES += [
|
||||
'ProgressEvent.webidl',
|
||||
'RecordErrorEvent.webidl',
|
||||
'SmartCardEvent.webidl',
|
||||
'StorageEvent.webidl',
|
||||
'StyleRuleChangeEvent.webidl',
|
||||
'StyleSheetApplicableStateChangeEvent.webidl',
|
||||
'StyleSheetChangeEvent.webidl',
|
||||
@ -641,6 +640,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
|
||||
'RTCPeerConnectionIceEvent.webidl',
|
||||
'RTCPeerConnectionIdentityErrorEvent.webidl',
|
||||
'RTCPeerConnectionIdentityEvent.webidl',
|
||||
'StorageEvent.webidl',
|
||||
'TrackEvent.webidl',
|
||||
'UserProximityEvent.webidl',
|
||||
'USSDReceivedEvent.webidl',
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
simple_events = [
|
||||
'ProgressEvent',
|
||||
'StorageEvent',
|
||||
'MozSettingsEvent',
|
||||
'CustomEvent',
|
||||
'PageTransitionEvent',
|
||||
|
@ -152,7 +152,6 @@
|
||||
#include "nsIDOMSpeechRecognitionEvent.h"
|
||||
#include "nsIDOMSpeechSynthesisEvent.h"
|
||||
#endif // MOZ_WEBSPEECH
|
||||
#include "nsIDOMStorageEvent.h"
|
||||
#include "nsIDOMStyleSheet.h"
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMStyleRuleChangeEvent.h"
|
||||
@ -510,7 +509,6 @@ const ComponentsInterfaceShimEntry kComponentsInterfaceShimMap[] =
|
||||
DEFINE_SHIM(SpeechRecognitionEvent),
|
||||
DEFINE_SHIM(SpeechSynthesisEvent),
|
||||
#endif // MOZ_WEBSPEECH
|
||||
DEFINE_SHIM(StorageEvent),
|
||||
DEFINE_SHIM(StyleSheet),
|
||||
DEFINE_SHIM(StyleSheetList),
|
||||
DEFINE_SHIM(StyleRuleChangeEvent),
|
||||
|
Loading…
Reference in New Issue
Block a user