author | Kyle Huey <khuey@kylehuey.com> |
Mon, 30 Jun 2014 16:02:02 -0700 | |
changeset 191614 | 1f60138bce8d9a9dbd0dc553cd5413872c83b11b |
parent 191613 | 481efa4412432859a6607d62a90bbb3347387e78 |
child 191615 | e6377ca32f3dd9e7a3e0c28dc48e7e19b0949be6 |
push id | 27055 |
push user | cbook@mozilla.com |
push date | Tue, 01 Jul 2014 12:01:46 +0000 |
treeherder | mozilla-central@4a9353b5762d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 1031051 |
milestone | 33.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -82,17 +82,16 @@ #include "nsIDocument.h" #include "Crypto.h" #ifndef MOZ_DISABLE_CRYPTOLEGACY #include "nsIDOMCryptoLegacy.h" #endif #include "nsIDOMDocument.h" #include "nsIDOMElement.h" #include "nsIDOMEvent.h" -#include "nsIDOMPopStateEvent.h" #include "nsIDOMOfflineResourceList.h" #include "nsPIDOMStorage.h" #include "nsDOMString.h" #include "nsIEmbeddingSiteWindow.h" #include "nsThreadUtils.h" #include "nsILoadContext.h" #include "nsIMarkupDocumentViewer.h" #include "nsIPresShell.h" @@ -211,16 +210,17 @@ #include "prrng.h" #include "nsSandboxFlags.h" #include "TimeChangeObserver.h" #include "mozilla/dom/AudioContext.h" #include "mozilla/dom/BrowserElementDictionariesBinding.h" #include "mozilla/dom/Console.h" #include "mozilla/dom/FunctionBinding.h" #include "mozilla/dom/HashChangeEvent.h" +#include "mozilla/dom/PopStateEvent.h" #include "mozilla/dom/PopupBlockedEvent.h" #include "mozilla/dom/WindowBinding.h" #include "nsITabChild.h" #include "mozilla/dom/MediaQueryList.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/NavigatorBinding.h" #ifdef HAVE_SIDEBAR #include "mozilla/dom/ExternalBinding.h" @@ -10152,41 +10152,43 @@ nsGlobalWindow::DispatchSyncPopState() // Obtain a presentation shell for use in creating a popstate event. nsIPresShell *shell = mDoc->GetShell(); nsRefPtr<nsPresContext> presContext; if (shell) { presContext = shell->GetPresContext(); } - // Create a new popstate event - nsCOMPtr<nsIDOMEvent> domEvent; - rv = EventDispatcher::CreateEvent(this, presContext, nullptr, - NS_LITERAL_STRING("popstateevent"), - getter_AddRefs(domEvent)); - NS_ENSURE_SUCCESS(rv, rv); - - // Initialize the popstate event, which does bubble but isn't cancellable. - nsCOMPtr<nsIDOMPopStateEvent> popstateEvent = do_QueryInterface(domEvent); - rv = popstateEvent->InitPopStateEvent(NS_LITERAL_STRING("popstate"), - true, false, - stateObj); - NS_ENSURE_SUCCESS(rv, rv); - - domEvent->SetTrusted(true); - - nsCOMPtr<EventTarget> outerWindow = - do_QueryInterface(GetOuterWindow()); - NS_ENSURE_TRUE(outerWindow, NS_ERROR_UNEXPECTED); - - rv = domEvent->SetTarget(outerWindow); - NS_ENSURE_SUCCESS(rv, rv); + bool result = true; + nsPIDOMWindow* outerWindow = GetOuterWindow(); + nsCOMPtr<EventTarget> outerWindowET = do_QueryInterface(outerWindow); + NS_ENSURE_TRUE(outerWindowET, NS_ERROR_FAILURE); + + AutoJSAPI jsapi; + result = jsapi.Init(outerWindow); + NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); + + JSContext* cx = jsapi.cx(); + JS::Rooted<JS::Value> stateJSValue(cx, JS::NullValue()); + result = stateObj ? VariantToJsval(cx, stateObj, &stateJSValue) : true; + NS_ENSURE_TRUE(result, NS_ERROR_FAILURE); + + RootedDictionary<PopStateEventInit> init(cx); + init.mBubbles = true; + init.mCancelable = false; + init.mState = stateJSValue; + + nsRefPtr<PopStateEvent> event = + PopStateEvent::Constructor(outerWindowET, NS_LITERAL_STRING("popstate"), + init); + event->SetTrusted(true); + event->SetTarget(outerWindowET); bool dummy; // default action - return DispatchEvent(popstateEvent, &dummy); + return DispatchEvent(event, &dummy); } // Find an nsICanvasFrame under aFrame. Only search the principal // child lists. aFrame must be non-null. static nsCanvasFrame* FindCanvasFrame(nsIFrame* aFrame) { nsCanvasFrame* canvasFrame = do_QueryFrame(aFrame); if (canvasFrame) {
--- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -13,16 +13,17 @@ #include "nsINode.h" #include "nsPIDOMWindow.h" #include "GeckoProfiler.h" #include "GeneratedEvents.h" #include "mozilla/ContentEvents.h" #include "mozilla/dom/CloseEvent.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/HashChangeEvent.h" +#include "mozilla/dom/PopStateEvent.h" #include "mozilla/dom/StorageEvent.h" #include "mozilla/dom/TouchEvent.h" #include "mozilla/EventDispatcher.h" #include "mozilla/EventListenerManager.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/MiscEvents.h" #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" @@ -813,25 +814,34 @@ EventDispatcher::CreateEvent(EventTarget if (aEventType.LowerCaseEqualsLiteral("beforeunloadevent")) return NS_NewDOMBeforeUnloadEvent(aDOMEvent, aOwner, aPresContext, nullptr); if (aEventType.LowerCaseEqualsLiteral("pagetransition")) return NS_NewDOMPageTransitionEvent(aDOMEvent, aOwner, aPresContext, nullptr); if (aEventType.LowerCaseEqualsLiteral("domtransaction")) return NS_NewDOMDOMTransactionEvent(aDOMEvent, aOwner, aPresContext, nullptr); if (aEventType.LowerCaseEqualsLiteral("scrollareaevent")) return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext, nullptr); - if (aEventType.LowerCaseEqualsLiteral("popstateevent")) - return NS_NewDOMPopStateEvent(aDOMEvent, aOwner, aPresContext, nullptr); if (aEventType.LowerCaseEqualsLiteral("closeevent")) { CloseEventInit init; nsRefPtr<CloseEvent> event = CloseEvent::Constructor(aOwner, EmptyString(), init); event.forget(aDOMEvent); return NS_OK; } + // XXXkhuey Chrome supports popstateevent here, even though it provides no + // initPopStateEvent method. This is nuts ... but copying it is unlikely to + // break the web. + if (aEventType.LowerCaseEqualsLiteral("popstateevent")) { + AutoJSContext cx; + RootedDictionary<PopStateEventInit> init(cx); + nsRefPtr<PopStateEvent> event = + PopStateEvent::Constructor(aOwner, EmptyString(), init); + event.forget(aDOMEvent); + return NS_OK; + } if (aEventType.LowerCaseEqualsLiteral("touchevent") && TouchEvent::PrefEnabled()) return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext, nullptr); if (aEventType.LowerCaseEqualsLiteral("hashchangeevent")) { HashChangeEventInit init; nsRefPtr<HashChangeEvent> event = HashChangeEvent::Constructor(aOwner, EmptyString(), init); event.forget(aDOMEvent);
--- a/dom/interfaces/events/moz.build +++ b/dom/interfaces/events/moz.build @@ -24,17 +24,16 @@ XPIDL_SOURCES += [ 'nsIDOMMessageEvent.idl', 'nsIDOMMouseEvent.idl', 'nsIDOMMouseScrollEvent.idl', 'nsIDOMMutationEvent.idl', 'nsIDOMNotifyPaintEvent.idl', 'nsIDOMNSEvent.idl', 'nsIDOMPageTransitionEvent.idl', 'nsIDOMPaintRequest.idl', - 'nsIDOMPopStateEvent.idl', 'nsIDOMRecordErrorEvent.idl', 'nsIDOMScrollAreaEvent.idl', 'nsIDOMSimpleGestureEvent.idl', 'nsIDOMSmartCardEvent.idl', 'nsIDOMStyleRuleChangeEvent.idl', 'nsIDOMStyleSheetApplicableStateChangeEvent.idl', 'nsIDOMStyleSheetChangeEvent.idl', 'nsIDOMTouchEvent.idl',
deleted file mode 100644 --- a/dom/interfaces/events/nsIDOMPopStateEvent.idl +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- 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/. */ - -#include "nsIDOMEvent.idl" - -interface nsIVariant; - -[builtinclass, uuid(f0def4a3-0eb3-4c08-b476-582e37b8564b)] -interface nsIDOMPopStateEvent : nsIDOMEvent -{ - /** - * The state associated with this popstate event - */ - readonly attribute nsIVariant state; - - void initPopStateEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIVariant stateArg); -};
--- a/dom/tests/mochitest/general/test_bug653364.html +++ b/dom/tests/mochitest/general/test_bug653364.html @@ -23,16 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cg gotPopState = 0; document.addEventListener("popState", function(e) { gotPopState = 1; is(e.state.foo, 'bar', "PopState event should have state we set."); is(e.isTrusted, false, "PopState event shouldn't be trusted."); }, true); -let ps = document.createEvent("PopStateEvent"); -ps.initPopStateEvent("popState", true, false, {'foo': 'bar'}); +let ps = new PopStateEvent("popState", { bubbles: true, + cancelable: false, + state: {'foo': 'bar'} }); document.documentElement.dispatchEvent(ps); is(gotPopState, 1, 'Document received PopState event.'); </script> </body> </html>
--- a/dom/webidl/PopStateEvent.webidl +++ b/dom/webidl/PopStateEvent.webidl @@ -1,24 +1,16 @@ /* -*- 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/. */ -[Constructor(DOMString type, optional PopStateEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"] +[Constructor(DOMString type, optional PopStateEventInit eventInitDict)] interface PopStateEvent : Event { - [Throws] readonly attribute any state; - - // initPopStateEvent is a Gecko specific deprecated method. - [Throws] - void initPopStateEvent(DOMString type, - boolean canBubble, - boolean cancelable, - any state); }; dictionary PopStateEventInit : EventInit { any state = null; };
--- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -642,16 +642,17 @@ GENERATED_EVENTS_WEBIDL_FILES = [ 'MozClirModeEvent.webidl', 'MozContactChangeEvent.webidl', 'MozEmergencyCbModeEvent.webidl', 'MozInterAppMessageEvent.webidl', 'MozMmsEvent.webidl', 'MozOtaStatusEvent.webidl', 'MozSmsEvent.webidl', 'MozStkCommandEvent.webidl', + 'PopStateEvent.webidl', 'PopupBlockedEvent.webidl', 'ProgressEvent.webidl', 'RTCDataChannelEvent.webidl', 'RTCPeerConnectionIceEvent.webidl', 'RTCPeerConnectionIdentityErrorEvent.webidl', 'RTCPeerConnectionIdentityEvent.webidl', 'TrackEvent.webidl', 'UserProximityEvent.webidl',
--- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -7,17 +7,16 @@ and should be in nsIDOM<name>.idl file and which should have <name>Init dictionary for the event constructor. """ simple_events = [ 'MozSettingsEvent', 'CustomEvent', 'PageTransitionEvent', 'DOMTransactionEvent', - 'PopStateEvent', 'DeviceOrientationEvent', 'MozApplicationEvent', 'SmartCardEvent', 'StyleRuleChangeEvent', 'StyleSheetChangeEvent', 'StyleSheetApplicableStateChangeEvent', #ifdef MOZ_WEBSPEECH 'SpeechSynthesisEvent',
--- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp +++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp @@ -118,17 +118,16 @@ #include "nsIDOMNode.h" #include "nsIDOMNodeIterator.h" #include "nsIDOMNotifyPaintEvent.h" #include "nsIDOMNSEvent.h" #include "nsIDOMOfflineResourceList.h" #include "nsIDOMPageTransitionEvent.h" #include "nsIDOMPaintRequest.h" #include "nsIDOMParser.h" -#include "nsIDOMPopStateEvent.h" #include "nsIDOMProcessingInstruction.h" #include "nsIDOMRange.h" #include "nsIDOMRecordErrorEvent.h" #include "nsIDOMRect.h" #include "nsIDOMScreen.h" #include "nsIDOMScrollAreaEvent.h" #include "nsIDOMSerializer.h" #include "nsIDOMSimpleGestureEvent.h" @@ -273,17 +272,16 @@ #include "mozilla/dom/MozSettingsEventBinding.h" #include "mozilla/dom/NodeIteratorBinding.h" #include "mozilla/dom/NodeBinding.h" #include "mozilla/dom/NotifyPaintEventBinding.h" #include "mozilla/dom/EventBinding.h" #include "mozilla/dom/OfflineResourceListBinding.h" #include "mozilla/dom/PageTransitionEventBinding.h" #include "mozilla/dom/PaintRequestBinding.h" -#include "mozilla/dom/PopStateEventBinding.h" #include "mozilla/dom/PositionErrorBinding.h" #include "mozilla/dom/ProcessingInstructionBinding.h" #include "mozilla/dom/RangeBinding.h" #include "mozilla/dom/RecordErrorEventBinding.h" #include "mozilla/dom/RectBinding.h" #include "mozilla/dom/ScreenBinding.h" #include "mozilla/dom/SelectionBinding.h" #include "mozilla/dom/ScrollAreaEventBinding.h" @@ -481,17 +479,16 @@ const ComponentsInterfaceShimEntry kComp DEFINE_SHIM(NodeIterator), DEFINE_SHIM(Node), DEFINE_SHIM(NotifyPaintEvent), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMNSEvent, Event), DEFINE_SHIM(OfflineResourceList), DEFINE_SHIM(PageTransitionEvent), DEFINE_SHIM(PaintRequest), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMParser, DOMParser), - DEFINE_SHIM(PopStateEvent), DEFINE_SHIM(ProcessingInstruction), DEFINE_SHIM(Range), DEFINE_SHIM(RecordErrorEvent), DEFINE_SHIM(Rect), DEFINE_SHIM(Screen), DEFINE_SHIM(ScrollAreaEvent), DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer), DEFINE_SHIM(SimpleGestureEvent),