author | Boris Zbarsky <bzbarsky@mit.edu> |
Fri, 20 Apr 2018 00:49:29 -0400 | |
changeset 414731 | 3f6f6c68e211b11ade14bf6cddd38426c73c63b0 |
parent 414730 | a8a18e514b3d582939adb8173b540eedabbc06d6 |
child 414732 | 491b4ebcc48a57315d0e19b31e99d8a62f911f5e |
push id | 33876 |
push user | dluca@mozilla.com |
push date | Fri, 20 Apr 2018 23:00:46 +0000 |
treeherder | mozilla-central@39ccabfd7d07 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | masayuki |
bugs | 1455055 |
milestone | 61.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/xbl/nsXBLEventHandler.cpp +++ b/dom/xbl/nsXBLEventHandler.cpp @@ -5,16 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsCOMPtr.h" #include "nsAtom.h" #include "nsIDOMEventListener.h" #include "nsXBLPrototypeHandler.h" #include "nsContentUtils.h" #include "mozilla/dom/Event.h" // for Event +#include "mozilla/dom/EventBinding.h" // for Event #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/KeyboardEvent.h" #include "mozilla/TextEvents.h" using namespace mozilla; using namespace mozilla::dom; nsXBLEventHandler::nsXBLEventHandler(nsXBLPrototypeHandler* aHandler) @@ -31,44 +32,42 @@ NS_IMPL_ISUPPORTS(nsXBLEventHandler, nsI NS_IMETHODIMP nsXBLEventHandler::HandleEvent(Event* aEvent) { if (!mProtoHandler) return NS_ERROR_FAILURE; uint8_t phase = mProtoHandler->GetPhase(); if (phase == NS_PHASE_TARGET) { - uint16_t eventPhase; - aEvent->GetEventPhase(&eventPhase); - if (eventPhase != nsIDOMEvent::AT_TARGET) + if (aEvent->EventPhase() != EventBinding::AT_TARGET) { return NS_OK; + } } if (!EventMatched(aEvent)) return NS_OK; - mProtoHandler->ExecuteHandler(aEvent->InternalDOMEvent()->GetCurrentTarget(), - aEvent); + mProtoHandler->ExecuteHandler(aEvent->GetCurrentTarget(), aEvent); return NS_OK; } nsXBLMouseEventHandler::nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler) : nsXBLEventHandler(aHandler) { } nsXBLMouseEventHandler::~nsXBLMouseEventHandler() { } bool -nsXBLMouseEventHandler::EventMatched(nsIDOMEvent* aEvent) +nsXBLMouseEventHandler::EventMatched(Event* aEvent) { - MouseEvent* mouse = aEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouse = aEvent->AsMouseEvent(); return mouse && mProtoHandler->MouseEventMatched(mouse); } nsXBLKeyEventHandler::nsXBLKeyEventHandler(nsAtom* aEventType, uint8_t aPhase, uint8_t aType) : mEventType(aEventType), mPhase(aPhase), mType(aType), @@ -124,23 +123,22 @@ nsXBLKeyEventHandler::ExecuteMatchedHand NS_IMETHODIMP nsXBLKeyEventHandler::HandleEvent(Event* aEvent) { uint32_t count = mProtoHandlers.Length(); if (count == 0) return NS_ERROR_FAILURE; if (mPhase == NS_PHASE_TARGET) { - uint16_t eventPhase; - aEvent->GetEventPhase(&eventPhase); - if (eventPhase != nsIDOMEvent::AT_TARGET) + if (aEvent->EventPhase() != EventBinding::AT_TARGET) { return NS_OK; + } } - RefPtr<KeyboardEvent> key = aEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr<KeyboardEvent> key = aEvent->AsKeyboardEvent(); if (!key) { return NS_OK; } WidgetKeyboardEvent* nativeKeyboardEvent = aEvent->WidgetEventPtr()->AsKeyboardEvent(); MOZ_ASSERT(nativeKeyboardEvent); AutoShortcutKeyCandidateArray shortcutKeys;
--- a/dom/xbl/nsXBLEventHandler.h +++ b/dom/xbl/nsXBLEventHandler.h @@ -13,16 +13,17 @@ #include "nsTArray.h" class nsAtom; class nsXBLPrototypeHandler; namespace mozilla { struct IgnoreModifierState; namespace dom { +class Event; class KeyboardEvent; } // namespace dom } // namespace mozilla class nsXBLEventHandler : public nsIDOMEventListener { public: explicit nsXBLEventHandler(nsXBLPrototypeHandler* aHandler); @@ -32,30 +33,30 @@ public: NS_DECL_NSIDOMEVENTLISTENER protected: virtual ~nsXBLEventHandler(); nsXBLPrototypeHandler* mProtoHandler; private: nsXBLEventHandler(); - virtual bool EventMatched(nsIDOMEvent* aEvent) + virtual bool EventMatched(mozilla::dom::Event* aEvent) { return true; } }; class nsXBLMouseEventHandler : public nsXBLEventHandler { public: explicit nsXBLMouseEventHandler(nsXBLPrototypeHandler* aHandler); virtual ~nsXBLMouseEventHandler(); private: - bool EventMatched(nsIDOMEvent* aEvent) override; + bool EventMatched(mozilla::dom::Event* aEvent) override; }; class nsXBLKeyEventHandler : public nsIDOMEventListener { typedef mozilla::IgnoreModifierState IgnoreModifierState; public: nsXBLKeyEventHandler(nsAtom* aEventType, uint8_t aPhase, uint8_t aType);
--- a/dom/xbl/nsXBLPrototypeHandler.cpp +++ b/dom/xbl/nsXBLPrototypeHandler.cpp @@ -270,20 +270,17 @@ nsXBLPrototypeHandler::ExecuteHandler(Ev bool isXULKey = !!(mType & NS_HANDLER_TYPE_XUL); bool isXBLCommand = !!(mType & NS_HANDLER_TYPE_XBL_COMMAND); NS_ASSERTION(!(isXULKey && isXBLCommand), "can't be both a key and xbl command handler"); // XUL handlers and commands shouldn't be triggered by non-trusted // events. if (isXULKey || isXBLCommand) { - bool trustedEvent = false; - aEvent->GetIsTrusted(&trustedEvent); - - if (!trustedEvent) + if (!aEvent->IsTrusted()) return NS_OK; } if (isXBLCommand) { return DispatchXBLCommand(aTarget, aEvent); } // If we're executing on a XUL key element, just dispatch a command @@ -452,26 +449,24 @@ nsXBLPrototypeHandler::EnsureEventHandle if (pWindow) { pWindow->CacheXBLPrototypeHandler(this, aHandler); } return NS_OK; } nsresult -nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, nsIDOMEvent* aEvent) +nsXBLPrototypeHandler::DispatchXBLCommand(EventTarget* aTarget, Event* aEvent) { // This is a special-case optimization to make command handling fast. // It isn't really a part of XBL, but it helps speed things up. if (aEvent) { // See if preventDefault has been set. If so, don't execute. - bool preventDefault = false; - aEvent->GetDefaultPrevented(&preventDefault); - if (preventDefault) { + if (aEvent->DefaultPrevented()) { return NS_OK; } bool dispatchStopped = aEvent->IsDispatchStopped(); if (dispatchStopped) { return NS_OK; } } @@ -562,32 +557,32 @@ nsXBLPrototypeHandler::DispatchXBLComman if (controller) controller->DoCommand(command.get()); return NS_OK; } nsresult -nsXBLPrototypeHandler::DispatchXULKeyCommand(nsIDOMEvent* aEvent) +nsXBLPrototypeHandler::DispatchXULKeyCommand(Event* aEvent) { nsCOMPtr<Element> handlerElement = GetHandlerElement(); NS_ENSURE_STATE(handlerElement); if (handlerElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled, nsGkAtoms::_true, eCaseMatters)) { // Don't dispatch command events for disabled keys. return NS_OK; } aEvent->PreventDefault(); // Copy the modifiers from the key event. - RefPtr<KeyboardEvent> keyEvent = aEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr<KeyboardEvent> keyEvent = aEvent->AsKeyboardEvent(); if (!keyEvent) { NS_ERROR("Trying to execute a key handler for a non-key event!"); return NS_ERROR_FAILURE; } // XXX We should use mozilla::Modifiers for supporting all modifiers. bool isAlt = keyEvent->AltKey();
--- a/dom/xbl/nsXBLPrototypeHandler.h +++ b/dom/xbl/nsXBLPrototypeHandler.h @@ -14,28 +14,28 @@ #include "nsCOMPtr.h" #include "nsIController.h" #include "nsAutoPtr.h" #include "nsXBLEventHandler.h" #include "nsIWeakReference.h" #include "nsCycleCollectionParticipant.h" #include "js/TypeDecls.h" -class nsIDOMEvent; class nsIContent; class nsIObjectInputStream; class nsIObjectOutputStream; class nsXBLPrototypeBinding; namespace mozilla { struct IgnoreModifierState; namespace dom { class AutoJSAPI; +class Event; class EventTarget; class KeyboardEvent; class MouseEvent; class UIEvent; } // namespace dom namespace layers { class KeyboardShortcut; @@ -191,18 +191,19 @@ protected: const char16_t* aClickCount=nullptr, const char16_t* aGroup=nullptr, const char16_t* aPreventDefault=nullptr, const char16_t* aAllowUntrusted=nullptr); void ReportKeyConflict(const char16_t* aKey, const char16_t* aModifiers, mozilla::dom::Element* aElement, const char *aMessageName); void GetEventType(nsAString& type); bool ModifiersMatchMask(mozilla::dom::UIEvent* aEvent, const IgnoreModifierState& aIgnoreModifierState); - nsresult DispatchXBLCommand(mozilla::dom::EventTarget* aTarget, nsIDOMEvent* aEvent); - nsresult DispatchXULKeyCommand(nsIDOMEvent* aEvent); + nsresult DispatchXBLCommand(mozilla::dom::EventTarget* aTarget, + mozilla::dom::Event* aEvent); + nsresult DispatchXULKeyCommand(mozilla::dom::Event* aEvent); nsresult EnsureEventHandler(mozilla::dom::AutoJSAPI& jsapi, nsAtom* aName, JS::MutableHandle<JSObject*> aHandler); Modifiers GetModifiers() const; Modifiers GetModifiersMask() const; static int32_t KeyToMask(int32_t key); static int32_t AccelKeyMask();
--- a/dom/xbl/nsXBLService.cpp +++ b/dom/xbl/nsXBLService.cpp @@ -269,18 +269,17 @@ nsresult nsXBLStreamListener::HandleEvent(Event* aEvent) { nsresult rv = NS_OK; uint32_t i; uint32_t count = mBindingRequests.Length(); // Get the binding document; note that we don't hold onto it in this object // to avoid creating a cycle - Event* event = aEvent->InternalDOMEvent(); - EventTarget* target = event->GetCurrentTarget(); + EventTarget* target = aEvent->GetCurrentTarget(); nsCOMPtr<nsIDocument> bindingDocument = do_QueryInterface(target); NS_ASSERTION(bindingDocument, "Event not targeted at document?!"); // See if we're still alive. nsCOMPtr<nsIDocument> doc(do_QueryReferent(mBoundDocument)); if (!doc) { NS_WARNING("XBL load did not complete until after document went away! Modal dialog bug?\n"); }
--- a/dom/xbl/nsXBLWindowKeyHandler.cpp +++ b/dom/xbl/nsXBLWindowKeyHandler.cpp @@ -28,16 +28,17 @@ #include "mozilla/EventStateManager.h" #include "mozilla/HTMLEditor.h" #include "mozilla/Move.h" #include "mozilla/Preferences.h" #include "mozilla/StaticPtr.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" +#include "mozilla/dom/EventBinding.h" #include "mozilla/dom/KeyboardEvent.h" #include "mozilla/layers/KeyboardMap.h" using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; class nsXBLSpecialDocInfo : public nsIObserver @@ -483,23 +484,20 @@ nsXBLWindowKeyHandler::ConvertEventToDOM MOZ_ASSERT_UNREACHABLE( "All event messages which this instance listens to should be handled"); return nullptr; } NS_IMETHODIMP nsXBLWindowKeyHandler::HandleEvent(Event* aEvent) { - RefPtr<KeyboardEvent> keyEvent = - aEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr<KeyboardEvent> keyEvent = aEvent->AsKeyboardEvent(); NS_ENSURE_TRUE(keyEvent, NS_ERROR_INVALID_ARG); - uint16_t eventPhase; - aEvent->GetEventPhase(&eventPhase); - if (eventPhase == nsIDOMEvent::CAPTURING_PHASE) { + if (aEvent->EventPhase() == EventBinding::CAPTURING_PHASE) { if (aEvent->WidgetEventPtr()->mFlags.mInSystemGroup) { HandleEventOnCaptureInSystemEventGroup(keyEvent); } else { HandleEventOnCaptureInDefaultEventGroup(keyEvent); } return NS_OK; }