diff --git a/configure.in b/configure.in index 5cca6d4cd7..def965f976 100644 --- a/configure.in +++ b/configure.in @@ -2950,7 +2950,7 @@ dnl Checks for library functions. dnl ======================================================== AC_PROG_GCC_TRADITIONAL AC_FUNC_MEMCMP -AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf) +AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo) dnl check for clock_gettime(), the CLOCK_MONOTONIC clock AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC), diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 471c41ef6c..603d44009e 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -2905,7 +2905,7 @@ Element::CheckHandleEventForLinksPrecondition(EventChainVisitor& aVisitor, (!aVisitor.mEvent->mFlags.mIsTrusted && (aVisitor.mEvent->mMessage != eMouseClick) && (aVisitor.mEvent->mMessage != eKeyPress) && - (aVisitor.mEvent->mMessage != NS_UI_ACTIVATE)) || + (aVisitor.mEvent->mMessage != eLegacyDOMActivate)) || !aVisitor.mPresContext || aVisitor.mEvent->mFlags.mMultipleActionsPrevented) { return false; @@ -2922,9 +2922,9 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor) // IMPORTANT: this switch and the switch below it must be kept in sync! switch (aVisitor.mEvent->mMessage) { case eMouseOver: - case NS_FOCUS_CONTENT: + case eFocus: case eMouseOut: - case NS_BLUR_CONTENT: + case eBlur: break; default: return NS_OK; @@ -2945,7 +2945,7 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor) case eMouseOver: aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; // FALL THROUGH - case NS_FOCUS_CONTENT: { + case eFocus: { InternalFocusEvent* focusEvent = aVisitor.mEvent->AsFocusEvent(); if (!focusEvent || !focusEvent->isRefocus) { nsAutoString target; @@ -2960,7 +2960,7 @@ Element::PreHandleEventForLinks(EventChainPreVisitor& aVisitor) case eMouseOut: aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; // FALL THROUGH - case NS_BLUR_CONTENT: + case eBlur: rv = LeaveLink(aVisitor.mPresContext); if (NS_SUCCEEDED(rv)) { aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true; @@ -2984,7 +2984,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) switch (aVisitor.mEvent->mMessage) { case eMouseDown: case eMouseClick: - case NS_UI_ACTIVATE: + case eLegacyDOMActivate: case eKeyPress: break; default: @@ -3038,7 +3038,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) nsEventStatus status = nsEventStatus_eIgnore; // DOMActive event should be trusted since the activation is actually // occurred even if the cause is an untrusted click event. - InternalUIEvent actEvent(true, NS_UI_ACTIVATE, mouseEvent); + InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent); actEvent.detail = 1; rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status); @@ -3049,7 +3049,7 @@ Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) } break; } - case NS_UI_ACTIVATE: + case eLegacyDOMActivate: { if (aVisitor.mEvent->originalTarget == this) { nsAutoString target; diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 3179e1bf52..719f3e14ef 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -679,8 +679,8 @@ nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor) bool isAnonForEvents = IsRootOfChromeAccessOnlySubtree(); if ((aVisitor.mEvent->mMessage == eMouseOver || aVisitor.mEvent->mMessage == eMouseOut || - aVisitor.mEvent->mMessage == NS_POINTER_OVER || - aVisitor.mEvent->mMessage == NS_POINTER_OUT) && + aVisitor.mEvent->mMessage == ePointerOver || + aVisitor.mEvent->mMessage == ePointerOut) && // Check if we should stop event propagation when event has just been // dispatched or when we're about to propagate from // chrome access only subtree or if we are about to propagate out of @@ -806,12 +806,12 @@ nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor) // selectstart bool stopEvent = false; switch (aVisitor.mEvent->mMessage) { - case NS_IMAGE_ABORT: - case NS_LOAD_ERROR: - case NS_FORM_SELECTED: - case NS_FORM_CHANGE: - case NS_LOAD: - case NS_FORM_RESET: + case eImageAbort: + case eLoadError: + case eFormSelect: + case eFormChange: + case eLoad: + case eFormReset: case eResize: case eScroll: case NS_SELECT_START: @@ -843,7 +843,7 @@ nsIContent::PreHandleEvent(EventChainPreVisitor& aVisitor) // The load event is special in that we don't ever propagate it // to chrome. nsCOMPtr win = OwnerDoc()->GetWindow(); - EventTarget* parentTarget = win && aVisitor.mEvent->mMessage != NS_LOAD + EventTarget* parentTarget = win && aVisitor.mEvent->mMessage != eLoad ? win->GetParentTarget() : nullptr; aVisitor.mParentTarget = parentTarget; diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index ce0891c72e..3fb408e1ff 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5448,7 +5448,7 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent) // created before the event fires, so it should already be set. For other // drag events, get the object from the drag session. NS_ASSERTION(aDragEvent->mMessage != NS_DRAGDROP_GESTURE && - aDragEvent->mMessage != NS_DRAGDROP_START, + aDragEvent->mMessage != eDragStart, "draggesture event created without a dataTransfer"); nsCOMPtr dragSession = GetDragSession(); @@ -5475,7 +5475,7 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent) } bool isCrossDomainSubFrameDrop = false; - if (aDragEvent->mMessage == NS_DRAGDROP_DROP || + if (aDragEvent->mMessage == eDrop || aDragEvent->mMessage == NS_DRAGDROP_DRAGDROP) { isCrossDomainSubFrameDrop = CheckForSubFrameDrop(dragSession, aDragEvent); } @@ -5497,7 +5497,7 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent) aDragEvent->dataTransfer->GetEffectAllowedInt(&effectAllowed); aDragEvent->dataTransfer->SetDropEffectInt(FilterDropEffect(action, effectAllowed)); } - else if (aDragEvent->mMessage == NS_DRAGDROP_DROP || + else if (aDragEvent->mMessage == eDrop || aDragEvent->mMessage == NS_DRAGDROP_DRAGDROP || aDragEvent->mMessage == NS_DRAGDROP_END) { // For the drop and dragend events, set the drop effect based on the @@ -7849,7 +7849,7 @@ nsContentUtils::SendMouseEvent(nsCOMPtr aPresShell, else if (aType.EqualsLiteral("mouseout")) msg = eMouseExitFromWidget; else if (aType.EqualsLiteral("contextmenu")) { - msg = NS_CONTEXTMENU; + msg = eContextMenu; contextMenuKey = (aButton == 0); } else if (aType.EqualsLiteral("MozMouseHittest")) msg = eMouseHitTest; diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index c12f07f6da..2ec2ef3275 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -700,15 +700,15 @@ nsDOMWindowUtils::SendPointerEventCommon(const nsAString& aType, EventMessage msg; if (aType.EqualsLiteral("pointerdown")) { - msg = NS_POINTER_DOWN; + msg = ePointerDown; } else if (aType.EqualsLiteral("pointerup")) { - msg = NS_POINTER_UP; + msg = ePointerUp; } else if (aType.EqualsLiteral("pointermove")) { - msg = NS_POINTER_MOVE; + msg = ePointerMove; } else if (aType.EqualsLiteral("pointerover")) { - msg = NS_POINTER_OVER; + msg = ePointerOver; } else if (aType.EqualsLiteral("pointerout")) { - msg = NS_POINTER_OUT; + msg = ePointerOut; } else { return NS_ERROR_FAILURE; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index ed343cdc18..c43f4db4ad 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -8106,7 +8106,7 @@ nsDocument::PreHandleEvent(EventChainPreVisitor& aVisitor) aVisitor.mForceContentDispatch = true; // Load events must not propagate to |window| object, see bug 335251. - if (aVisitor.mEvent->mMessage != NS_LOAD) { + if (aVisitor.mEvent->mMessage != eLoad) { nsGlobalWindow* window = static_cast(GetWindow()); aVisitor.mParentTarget = window ? window->GetTargetForEventTargetChain() : nullptr; diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index fc4c6f81f4..ea569f1261 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -963,7 +963,7 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow) window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); if (presShell) { - SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell, + SendFocusOrBlurEvent(eBlur, presShell, oldFocusedContent->GetComposedDoc(), oldFocusedContent, 1, false); } @@ -1678,7 +1678,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, if (mActiveWindow) window->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); - SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell, + SendFocusOrBlurEvent(eBlur, presShell, content->GetComposedDoc(), content, 1, false); } @@ -1725,9 +1725,9 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, // the document isn't null in case someone closed it during the blur above nsIDocument* doc = window->GetExtantDoc(); if (doc) - SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell, doc, doc, 1, false); + SendFocusOrBlurEvent(eBlur, presShell, doc, doc, 1, false); if (mFocusedWindow == nullptr) - SendFocusOrBlurEvent(NS_BLUR_CONTENT, presShell, doc, window, 1, false); + SendFocusOrBlurEvent(eBlur, presShell, doc, window, 1, false); // check if a different window was focused result = (mFocusedWindow == nullptr && mActiveWindow); @@ -1853,10 +1853,10 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, GetFocusMoveActionCause(aFlags)); } if (doc) - SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, doc, + SendFocusOrBlurEvent(eFocus, presShell, doc, doc, aFlags & FOCUSMETHOD_MASK, aWindowRaised); if (mFocusedWindow == aWindow && mFocusedContent == nullptr) - SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, doc, + SendFocusOrBlurEvent(eFocus, presShell, doc, aWindow, aFlags & FOCUSMETHOD_MASK, aWindowRaised); } @@ -1904,7 +1904,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, if (!aWindowRaised) aWindow->UpdateCommands(NS_LITERAL_STRING("focus"), nullptr, 0); - SendFocusOrBlurEvent(NS_FOCUS_CONTENT, presShell, + SendFocusOrBlurEvent(eFocus, presShell, aContent->GetComposedDoc(), aContent, aFlags & FOCUSMETHOD_MASK, aWindowRaised, isRefocus); @@ -1997,8 +1997,7 @@ nsFocusManager::SendFocusOrBlurEvent(EventMessage aEventMessage, bool aWindowRaised, bool aIsRefocus) { - NS_ASSERTION(aEventMessage == NS_FOCUS_CONTENT || - aEventMessage == NS_BLUR_CONTENT, + NS_ASSERTION(aEventMessage == eFocus || aEventMessage == eBlur, "Wrong event type for SendFocusOrBlurEvent"); nsCOMPtr eventTarget = do_QueryInterface(aTarget); @@ -2038,7 +2037,7 @@ nsFocusManager::SendFocusOrBlurEvent(EventMessage aEventMessage, #ifdef ACCESSIBILITY nsAccessibilityService* accService = GetAccService(); if (accService) { - if (aEventMessage == NS_FOCUS_CONTENT) { + if (aEventMessage == eFocus) { accService->NotifyOfDOMFocus(aTarget); } else { accService->NotifyOfDOMBlur(aTarget); diff --git a/dom/base/nsFocusManager.h b/dom/base/nsFocusManager.h index 73fa2e9cf0..a2aad11dce 100644 --- a/dom/base/nsFocusManager.h +++ b/dom/base/nsFocusManager.h @@ -280,7 +280,7 @@ protected: /** * Fires a focus or blur event at aTarget. * - * aEventMessage should be either NS_FOCUS_CONTENT or NS_BLUR_CONTENT. + * aEventMessage should be either eFocus or eBlur. * For blur events, aFocusMethod should normally be non-zero. * * aWindowRaised should only be true if called from WindowRaised. diff --git a/dom/base/nsGenConImageContent.cpp b/dom/base/nsGenConImageContent.cpp index 5a8f5e26fb..0dbfa08ea3 100644 --- a/dom/base/nsGenConImageContent.cpp +++ b/dom/base/nsGenConImageContent.cpp @@ -49,8 +49,8 @@ public: virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override { MOZ_ASSERT(IsInNativeAnonymousSubtree()); - if (aVisitor.mEvent->mMessage == NS_LOAD || - aVisitor.mEvent->mMessage == NS_LOAD_ERROR) { + if (aVisitor.mEvent->mMessage == eLoad || + aVisitor.mEvent->mMessage == eLoadError) { // Don't propagate the events to the parent. return NS_OK; } diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 90f6fee629..57b0e64ec4 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3260,8 +3260,8 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor) // Return early if there is nothing to do. switch (aVisitor.mEvent->mMessage) { case eResize: - case NS_PAGE_UNLOAD: - case NS_LOAD: + case eUnload: + case eLoad: break; default: return NS_OK; @@ -3275,7 +3275,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor) if (aVisitor.mEvent->mMessage == eResize) { mIsHandlingResizeEvent = false; - } else if (aVisitor.mEvent->mMessage == NS_PAGE_UNLOAD && + } else if (aVisitor.mEvent->mMessage == eUnload && aVisitor.mEvent->mFlags.mIsTrusted) { // Execute bindingdetached handlers before we tear ourselves // down. @@ -3283,7 +3283,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor) mDoc->BindingManager()->ExecuteDetachedHandlers(); } mIsDocumentLoaded = false; - } else if (aVisitor.mEvent->mMessage == NS_LOAD && + } else if (aVisitor.mEvent->mMessage == eLoad && aVisitor.mEvent->mFlags.mIsTrusted) { // This is page load event since load events don't propagate to |window|. // @see nsDocument::PreHandleEvent. @@ -3297,7 +3297,7 @@ nsGlobalWindow::PostHandleEvent(EventChainPostVisitor& aVisitor) // onload event for the frame element. nsEventStatus status = nsEventStatus_eIgnore; - WidgetEvent event(aVisitor.mEvent->mFlags.mIsTrusted, NS_LOAD); + WidgetEvent event(aVisitor.mEvent->mFlags.mIsTrusted, eLoad); event.mFlags.mBubbles = false; // Most of the time we could get a pres context to pass in here, diff --git a/dom/base/nsScriptElement.cpp b/dom/base/nsScriptElement.cpp index ef7ec836f0..a63557151e 100644 --- a/dom/base/nsScriptElement.cpp +++ b/dom/base/nsScriptElement.cpp @@ -59,10 +59,10 @@ nsScriptElement::ScriptEvaluated(nsresult aResult, nsContentUtils::GetContextForContent(cont); nsEventStatus status = nsEventStatus_eIgnore; - EventMessage message = NS_SUCCEEDED(aResult) ? NS_LOAD : NS_LOAD_ERROR; + EventMessage message = NS_SUCCEEDED(aResult) ? eLoad : eLoadError; WidgetEvent event(true, message); // Load event doesn't bubble. - event.mFlags.mBubbles = (message != NS_LOAD); + event.mFlags.mBubbles = (message != eLoad); EventDispatcher::Dispatch(cont, presContext, &event, nullptr, &status); } diff --git a/dom/events/DataTransfer.cpp b/dom/events/DataTransfer.cpp index bbea2f2b73..464edfda74 100644 --- a/dom/events/DataTransfer.cpp +++ b/dom/events/DataTransfer.cpp @@ -68,40 +68,41 @@ const char DataTransfer::sEffects[8][9] = { "none", "copy", "move", "copyMove", "link", "copyLink", "linkMove", "all" }; -DataTransfer::DataTransfer(nsISupports* aParent, uint32_t aEventType, +DataTransfer::DataTransfer(nsISupports* aParent, EventMessage aEventMessage, bool aIsExternal, int32_t aClipboardType) - : mParent(aParent), - mEventType(aEventType), - mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE), - mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED), - mCursorState(false), - mReadOnly(true), - mIsExternal(aIsExternal), - mUserCancelled(false), - mIsCrossDomainSubFrameDrop(false), - mClipboardType(aClipboardType), - mDragImageX(0), - mDragImageY(0) + : mParent(aParent) + , mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE) + , mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) + , mEventMessage(aEventMessage) + , mCursorState(false) + , mReadOnly(true) + , mIsExternal(aIsExternal) + , mUserCancelled(false) + , mIsCrossDomainSubFrameDrop(false) + , mClipboardType(aClipboardType) + , mDragImageX(0) + , mDragImageY(0) { // For these events, we want to be able to add data to the data transfer, so // clear the readonly state. Otherwise, the data is already present. For // external usage, cache the data from the native clipboard or drag. - if (aEventType == NS_CUT || - aEventType == NS_COPY || - aEventType == NS_DRAGDROP_START || - aEventType == NS_DRAGDROP_GESTURE) { + if (aEventMessage == NS_CUT || + aEventMessage == NS_COPY || + aEventMessage == eDragStart || + aEventMessage == NS_DRAGDROP_GESTURE) { mReadOnly = false; } else if (mIsExternal) { - if (aEventType == NS_PASTE) { + if (aEventMessage == NS_PASTE) { CacheExternalClipboardFormats(); - } else if (aEventType >= NS_DRAGDROP_EVENT_START && aEventType <= NS_DRAGDROP_LEAVE) { + } else if (aEventMessage >= eDragDropEventFirst && + aEventMessage <= eDragDropEventLast) { CacheExternalDragFormats(); } } } DataTransfer::DataTransfer(nsISupports* aParent, - uint32_t aEventType, + EventMessage aEventMessage, const uint32_t aEffectAllowed, bool aCursorState, bool aIsExternal, @@ -112,20 +113,20 @@ DataTransfer::DataTransfer(nsISupports* aParent, Element* aDragImage, uint32_t aDragImageX, uint32_t aDragImageY) - : mParent(aParent), - mEventType(aEventType), - mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE), - mEffectAllowed(aEffectAllowed), - mCursorState(aCursorState), - mReadOnly(true), - mIsExternal(aIsExternal), - mUserCancelled(aUserCancelled), - mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop), - mClipboardType(aClipboardType), - mItems(aItems), - mDragImage(aDragImage), - mDragImageX(aDragImageX), - mDragImageY(aDragImageY) + : mParent(aParent) + , mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE) + , mEffectAllowed(aEffectAllowed) + , mEventMessage(aEventMessage) + , mCursorState(aCursorState) + , mReadOnly(true) + , mIsExternal(aIsExternal) + , mUserCancelled(aUserCancelled) + , mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop) + , mClipboardType(aClipboardType) + , mItems(aItems) + , mDragImage(aDragImage) + , mDragImageX(aDragImageX) + , mDragImageY(aDragImageY) { MOZ_ASSERT(mParent); // The items are copied from aItems into mItems. There is no need to copy @@ -133,8 +134,8 @@ DataTransfer::DataTransfer(nsISupports* aParent, // draggesture and dragstart events are the only times when items are // modifiable, but those events should have been using the first constructor // above. - NS_ASSERTION(aEventType != NS_DRAGDROP_GESTURE && - aEventType != NS_DRAGDROP_START, + NS_ASSERTION(aEventMessage != NS_DRAGDROP_GESTURE && + aEventMessage != eDragStart, "invalid event type for DataTransfer constructor"); } @@ -268,8 +269,9 @@ DataTransfer::GetMozUserCancelled(bool* aUserCancelled) FileList* DataTransfer::GetFiles(ErrorResult& aRv) { - if (mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP && - mEventType != NS_PASTE) { + if (mEventMessage != eDrop && + mEventMessage != NS_DRAGDROP_DRAGDROP && + mEventMessage != NS_PASTE) { return nullptr; } @@ -524,7 +526,8 @@ DataTransfer::MozTypesAt(uint32_t aIndex, ErrorResult& aRv) const { // Only the first item is valid for clipboard events if (aIndex > 0 && - (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) { + (mEventMessage == NS_CUT || mEventMessage == NS_COPY || + mEventMessage == NS_PASTE)) { aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); return nullptr; } @@ -582,7 +585,8 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex, // Only the first item is valid for clipboard events if (aIndex > 0 && - (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) { + (mEventMessage == NS_CUT || mEventMessage == NS_COPY || + mEventMessage == NS_PASTE)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } @@ -611,8 +615,9 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex, // only allow access to the data with the same principal. nsIPrincipal* principal = nullptr; if (mIsCrossDomainSubFrameDrop || - (mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP && - mEventType != NS_PASTE && + (mEventMessage != eDrop && + mEventMessage != NS_DRAGDROP_DRAGDROP && + mEventMessage != NS_PASTE && !nsContentUtils::IsCallerChrome())) { principal = nsContentUtils::SubjectPrincipal(); } @@ -703,7 +708,8 @@ DataTransfer::MozSetDataAt(const nsAString& aFormat, nsIVariant* aData, // Only the first item is valid for clipboard events if (aIndex > 0 && - (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) { + (mEventMessage == NS_CUT || mEventMessage == NS_COPY || + mEventMessage == NS_PASTE)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } @@ -756,7 +762,8 @@ DataTransfer::MozClearDataAt(const nsAString& aFormat, uint32_t aIndex, // Only the first item is valid for clipboard events if (aIndex > 0 && - (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) { + (mEventMessage == NS_CUT || mEventMessage == NS_COPY || + mEventMessage == NS_PASTE)) { aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); return; } @@ -771,8 +778,8 @@ DataTransfer::MozClearDataAtHelper(const nsAString& aFormat, uint32_t aIndex, MOZ_ASSERT(!mReadOnly); MOZ_ASSERT(aIndex < mItems.Length()); MOZ_ASSERT(aIndex == 0 || - (mEventType != NS_CUT && mEventType != NS_COPY && - mEventType != NS_PASTE)); + (mEventMessage != NS_CUT && mEventMessage != NS_COPY && + mEventMessage != NS_PASTE)); nsAutoString format; GetRealFormat(aFormat, format); @@ -954,12 +961,12 @@ DataTransfer::AddElement(nsIDOMElement* aElement) } nsresult -DataTransfer::Clone(nsISupports* aParent, uint32_t aEventType, +DataTransfer::Clone(nsISupports* aParent, EventMessage aEventMessage, bool aUserCancelled, bool aIsCrossDomainSubFrameDrop, DataTransfer** aNewDataTransfer) { DataTransfer* newDataTransfer = - new DataTransfer(aParent, aEventType, mEffectAllowed, mCursorState, + new DataTransfer(aParent, aEventMessage, mEffectAllowed, mCursorState, mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop, mClipboardType, mItems, mDragImage, mDragImageX, mDragImageY); @@ -1268,7 +1275,8 @@ DataTransfer::CacheExternalDragFormats() void DataTransfer::CacheExternalClipboardFormats() { - NS_ASSERTION(mEventType == NS_PASTE, "caching clipboard data for invalid event"); + NS_ASSERTION(mEventMessage == NS_PASTE, + "caching clipboard data for invalid event"); // Called during the constructor for paste events to cache the formats // available on the clipboard. As with CacheExternalDragFormats, the @@ -1309,7 +1317,7 @@ DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex) } // only drag and paste events should be calling FillInExternalData - NS_ASSERTION(mEventType != NS_CUT && mEventType != NS_COPY, + NS_ASSERTION(mEventMessage != NS_CUT && mEventMessage != NS_COPY, "clipboard event with empty data"); NS_ConvertUTF16toUTF8 utf8format(aItem.mFormat); @@ -1327,7 +1335,7 @@ DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex) trans->Init(nullptr); trans->AddDataFlavor(format); - if (mEventType == NS_PASTE) { + if (mEventMessage == NS_PASTE) { MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0"); nsCOMPtr clipboard = do_GetService("@mozilla.org/widget/clipboard;1"); diff --git a/dom/events/DataTransfer.h b/dom/events/DataTransfer.h index 3926c031eb..f2a3afcc4d 100644 --- a/dom/events/DataTransfer.h +++ b/dom/events/DataTransfer.h @@ -18,6 +18,7 @@ #include "nsAutoPtr.h" #include "mozilla/Attributes.h" +#include "mozilla/EventForwards.h" #include "mozilla/dom/File.h" #include "mozilla/dom/Promise.h" @@ -75,7 +76,7 @@ protected: // this constructor is used only by the Clone method to copy the fields as // needed to a new data transfer. DataTransfer(nsISupports* aParent, - uint32_t aEventType, + EventMessage aEventMessage, const uint32_t aEffectAllowed, bool aCursorState, bool aIsExternal, @@ -95,8 +96,6 @@ public: // Constructor for DataTransfer. // - // aEventType is an event constant (such as NS_DRAGDROP_START) - // // aIsExternal must only be true when used to create a dataTransfer for a // paste or a drag that was started without using a data transfer. The // latter will occur when an external drag occurs, that is, a drag where the @@ -104,8 +103,8 @@ public: // service directly. For clipboard operations, aClipboardType indicates // which clipboard to use, from nsIClipboard, or -1 for non-clipboard operations, // or if access to the system clipboard should not be allowed. - DataTransfer(nsISupports* aParent, uint32_t aEventType, bool aIsExternal, - int32_t aClipboardType); + DataTransfer(nsISupports* aParent, EventMessage aEventMessage, + bool aIsExternal, int32_t aClipboardType); virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; nsISupports* GetParentObject() @@ -222,8 +221,9 @@ public: return mDragImage; } - nsresult Clone(nsISupports* aParent, uint32_t aEventType, bool aUserCancelled, - bool aIsCrossDomainSubFrameDrop, DataTransfer** aResult); + nsresult Clone(nsISupports* aParent, EventMessage aEventMessage, + bool aUserCancelled, bool aIsCrossDomainSubFrameDrop, + DataTransfer** aResult); protected: @@ -254,14 +254,15 @@ protected: nsCOMPtr mParent; - // the event type this data transfer is for. This will correspond to an - // event->mMessage value. - uint32_t mEventType; // the drop effect and effect allowed uint32_t mDropEffect; uint32_t mEffectAllowed; + // the event message this data transfer is for. This will correspond to an + // event->mMessage value. + EventMessage mEventMessage; + // Indicates the behavior of the cursor during drag operations bool mCursorState; diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index ae7713b204..30a716bec7 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -716,12 +716,12 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent) // nsPresShell::HandleEventInternal() for details. if (EventStateManager::IsHandlingUserInput()) { switch(aEvent->mMessage) { - case NS_FORM_SELECTED : + case eFormSelect: if (PopupAllowedForEvent("select")) { abuse = openControlled; } break; - case NS_FORM_CHANGE : + case eFormChange: if (PopupAllowedForEvent("change")) { abuse = openControlled; } @@ -753,7 +753,7 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent) // nsPresShell::HandleEventInternal() for details. if (EventStateManager::IsHandlingUserInput()) { switch(aEvent->mMessage) { - case NS_FORM_CHANGE : + case eFormChange: if (PopupAllowedForEvent("change")) { abuse = openControlled; } @@ -853,12 +853,12 @@ Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent) // nsPresShell::HandleEventInternal() for details. if (EventStateManager::IsHandlingUserInput()) { switch(aEvent->mMessage) { - case NS_FORM_SUBMIT : + case eFormSubmit: if (PopupAllowedForEvent("submit")) { abuse = openControlled; } break; - case NS_FORM_RESET : + case eFormReset: if (PopupAllowedForEvent("reset")) { abuse = openControlled; } diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index f963eda39d..3368b28883 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -1369,8 +1369,8 @@ EventListenerManager::HasUnloadListeners() uint32_t count = mListeners.Length(); for (uint32_t i = 0; i < count; ++i) { Listener* listener = &mListeners.ElementAt(i); - if (listener->mEventMessage == NS_PAGE_UNLOAD || - listener->mEventMessage == NS_BEFORE_PAGE_UNLOAD) { + if (listener->mEventMessage == eUnload || + listener->mEventMessage == eBeforeUnload) { return true; } } diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 88048c081a..09cc1b15d9 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -149,7 +149,7 @@ #endif /* BEFOREUNLOAD_EVENT */ EVENT(abort, - NS_IMAGE_ABORT, + eImageAbort, EventNameType_All, eBasicEventClass) EVENT(canplay, @@ -161,7 +161,7 @@ EVENT(canplaythrough, EventNameType_HTML, eBasicEventClass) EVENT(change, - NS_FORM_CHANGE, + eFormChange, EventNameType_HTMLXUL, eBasicEventClass) EVENT(click, @@ -169,7 +169,7 @@ EVENT(click, EventNameType_All, eMouseEventClass) EVENT(contextmenu, - NS_CONTEXTMENU, + eContextMenu, EventNameType_HTMLXUL, eMouseEventClass) // Not supported yet @@ -191,7 +191,7 @@ EVENT(dragenter, EventNameType_HTMLXUL, eDragEventClass) EVENT(dragleave, - NS_DRAGDROP_LEAVE, + eDragLeave, EventNameType_HTMLXUL, eDragEventClass) EVENT(dragover, @@ -199,11 +199,11 @@ EVENT(dragover, EventNameType_HTMLXUL, eDragEventClass) EVENT(dragstart, - NS_DRAGDROP_START, + eDragStart, EventNameType_HTMLXUL, eDragEventClass) EVENT(drop, - NS_DRAGDROP_DROP, + eDrop, EventNameType_HTMLXUL, eDragEventClass) EVENT(durationchange, @@ -223,7 +223,7 @@ EVENT(input, EventNameType_HTMLXUL, eEditorInputEventClass) EVENT(invalid, - NS_FORM_INVALID, + eFormInvalid, EventNameType_HTMLXUL, eBasicEventClass) EVENT(keydown, @@ -311,15 +311,15 @@ EVENT(mozpointerlockerror, EventNameType_HTML, eBasicEventClass) EVENT(pointerdown, - NS_POINTER_DOWN, + ePointerDown, EventNameType_All, ePointerEventClass) EVENT(pointermove, - NS_POINTER_MOVE, + ePointerMove, EventNameType_All, ePointerEventClass) EVENT(pointerup, - NS_POINTER_UP, + ePointerUp, EventNameType_All, ePointerEventClass) EVENT(pointercancel, @@ -327,15 +327,15 @@ EVENT(pointercancel, EventNameType_All, ePointerEventClass) EVENT(pointerover, - NS_POINTER_OVER, + ePointerOver, EventNameType_All, ePointerEventClass) EVENT(pointerout, - NS_POINTER_OUT, + ePointerOut, EventNameType_All, ePointerEventClass) EVENT(pointerenter, - NS_POINTER_ENTER, + ePointerEnter, EventNameType_All, ePointerEventClass) EVENT(pointerleave, @@ -378,7 +378,7 @@ EVENT(ratechange, EventNameType_HTML, eBasicEventClass) EVENT(reset, - NS_FORM_RESET, + eFormReset, EventNameType_HTMLXUL, eBasicEventClass) EVENT(seeked, @@ -390,7 +390,7 @@ EVENT(seeking, EventNameType_HTML, eBasicEventClass) EVENT(select, - NS_FORM_SELECTED, + eFormSelect, EventNameType_HTMLXUL, eBasicEventClass) EVENT(show, @@ -402,7 +402,7 @@ EVENT(stalled, EventNameType_HTML, eBasicEventClass) EVENT(submit, - NS_FORM_SUBMIT, + eFormSubmit, EventNameType_HTMLXUL, eBasicEventClass) EVENT(suspend, @@ -452,19 +452,19 @@ EVENT(afterscriptexecute, eBasicEventClass) FORWARDED_EVENT(blur, - NS_BLUR_CONTENT, + eBlur, EventNameType_HTMLXUL, eFocusEventClass) ERROR_EVENT(error, - NS_LOAD_ERROR, + eLoadError, EventNameType_All, eBasicEventClass) FORWARDED_EVENT(focus, - NS_FOCUS_CONTENT, + eFocus, EventNameType_HTMLXUL, eFocusEventClass) FORWARDED_EVENT(load, - NS_LOAD, + eLoad, EventNameType_All, eBasicEventClass) FORWARDED_EVENT(resize, @@ -485,11 +485,11 @@ WINDOW_EVENT(beforeprint, EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly, eBasicEventClass) BEFOREUNLOAD_EVENT(beforeunload, - NS_BEFORE_PAGE_UNLOAD, + eBeforeUnload, EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly, eBasicEventClass) WINDOW_EVENT(hashchange, - NS_HASHCHANGE, + eHashChange, EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly, eBasicEventClass) WINDOW_EVENT(languagechange, @@ -520,7 +520,7 @@ WINDOW_EVENT(pageshow, EventNameType_HTMLBodyOrFramesetOnly, eBasicEventClass) WINDOW_EVENT(popstate, - NS_POPSTATE, + ePopState, EventNameType_XUL | EventNameType_HTMLBodyOrFramesetOnly, eBasicEventClass) // Not supported yet @@ -530,7 +530,7 @@ WINDOW_EVENT(popstate, // Not supported yet // WINDOW_EVENT(undo) WINDOW_EVENT(unload, - NS_PAGE_UNLOAD, + eUnload, (EventNameType_XUL | EventNameType_SVGSVG | EventNameType_HTMLBodyOrFramesetOnly), eBasicEventClass) @@ -589,7 +589,7 @@ TOUCH_EVENT(touchcancel, eTouchEventClass) DOCUMENT_ONLY_EVENT(readystatechange, - NS_READYSTATECHANGE, + eReadyStateChange, EventNameType_HTMLXUL, eBasicEventClass) DOCUMENT_ONLY_EVENT(selectionchange, @@ -636,15 +636,15 @@ NON_IDL_EVENT(DOMSubtreeModified, eMutationEventClass) NON_IDL_EVENT(DOMActivate, - NS_UI_ACTIVATE, + eLegacyDOMActivate, EventNameType_HTMLXUL, eUIEventClass) NON_IDL_EVENT(DOMFocusIn, - NS_UI_FOCUSIN, + eLegacyDOMFocusIn, EventNameType_HTMLXUL, eUIEventClass) NON_IDL_EVENT(DOMFocusOut, - NS_UI_FOCUSOUT, + eLegacyDOMFocusOut, EventNameType_HTMLXUL, eUIEventClass) diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 9ad032f48f..0dcb12256a 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -520,7 +520,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (node && (aEvent->mMessage == eKeyUp || aEvent->mMessage == eMouseUp || aEvent->mMessage == NS_WHEEL_WHEEL || aEvent->mMessage == NS_TOUCH_END || - aEvent->mMessage == NS_POINTER_UP)) { + aEvent->mMessage == ePointerUp)) { nsIDocument* doc = node->OwnerDoc(); while (doc && !doc->UserHasInteracted()) { doc->SetUserHasInteracted(true); @@ -559,7 +559,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, *aStatus = nsEventStatus_eIgnore; switch (aEvent->mMessage) { - case NS_CONTEXTMENU: + case eContextMenu: if (sIsPointerLocked) { return NS_ERROR_DOM_INVALID_STATE_ERR; } @@ -646,8 +646,8 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, break; } case eMouseMove: - case NS_POINTER_DOWN: - case NS_POINTER_MOVE: { + case ePointerDown: + case ePointerMove: { // on the Mac, GenerateDragGesture() may not return until the drag // has completed and so |aTargetFrame| may have been deleted (moving // a bookmark, for example). If this is the case, however, we know @@ -670,8 +670,8 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, } break; case NS_DRAGDROP_OVER: - // NS_DRAGDROP_DROP is fired before NS_DRAGDROP_DRAGDROP so send - // the enter/exit events before NS_DRAGDROP_DROP. + // eDrop is fired before NS_DRAGDROP_DRAGDROP so send + // the enter/exit events before eDrop. GenerateDragDropEnterExit(aPresContext, aEvent->AsDragEvent()); break; @@ -1190,7 +1190,7 @@ CrossProcessSafeEvent(const WidgetEvent& aEvent) case eMouseDown: case eMouseUp: case eMouseMove: - case NS_CONTEXTMENU: + case eContextMenu: case eMouseEnterIntoWidget: case eMouseExitFromWidget: return true; @@ -1211,7 +1211,7 @@ CrossProcessSafeEvent(const WidgetEvent& aEvent) switch (aEvent.mMessage) { case NS_DRAGDROP_OVER: case NS_DRAGDROP_EXIT: - case NS_DRAGDROP_DROP: + case eDrop: return true; default: break; @@ -1468,7 +1468,7 @@ EventStateManager::FireContextClick() if (allowedToDispatch) { // init the event while mCurrentTarget is still good - WidgetMouseEvent event(true, NS_CONTEXTMENU, targetWidget, + WidgetMouseEvent event(true, eContextMenu, targetWidget, WidgetMouseEvent::eReal); event.clickCount = 1; FillInEventFromGestureDown(&event); @@ -1494,7 +1494,7 @@ EventStateManager::FireContextClick() nullptr, &status); // We don't need to dispatch to frame handling because no frames - // watch NS_CONTEXTMENU except for nsMenuFrame and that's only for + // watch eContextMenu except for nsMenuFrame and that's only for // dismissal. That's just as well since we don't really know // which frame to send it to. } @@ -1653,7 +1653,7 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext, return; nsRefPtr dataTransfer = - new DataTransfer(window, NS_DRAGDROP_START, false, -1); + new DataTransfer(window, eDragStart, false, -1); nsCOMPtr selection; nsCOMPtr eventContent, targetContent; @@ -1679,7 +1679,7 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext, // get the widget from the target frame WidgetDragEvent startEvent(aEvent->mFlags.mIsTrusted, - NS_DRAGDROP_START, widget); + eDragStart, widget); FillInEventFromGestureDown(&startEvent); WidgetDragEvent gestureEvent(aEvent->mFlags.mIsTrusted, @@ -3024,7 +3024,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext, // This break was commented specially // break; } - case NS_POINTER_UP: { + case ePointerUp: { WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent(); // After UP/Cancel Touch pointers become invalid so we can remove relevant helper from Table // Mouse/Pen pointers are valid all the time (not only between down/up) @@ -3302,7 +3302,7 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext, } break; - case NS_DRAGDROP_DROP: + case eDrop: { // now fire the dragdrop event, for compatibility with XUL if (mCurrentTarget && nsEventStatus_eConsumeNoDefault != *aStatus) { @@ -3891,8 +3891,7 @@ public: ~EnterLeaveDispatcher() { - if (mEventMessage == eMouseEnter || - mEventMessage == NS_POINTER_ENTER) { + if (mEventMessage == eMouseEnter || mEventMessage == ePointerEnter) { for (int32_t i = mTargets.Count() - 1; i >= 0; --i) { mESM->DispatchMouseOrPointerEvent(mMouseEvent, mEventMessage, mTargets[i], mRelatedTarget); @@ -3973,7 +3972,7 @@ EventStateManager::NotifyMouseOut(WidgetMouseEvent* aMouseEvent, isPointer ? ePointerLeave : eMouseLeave); // Fire mouseout - DispatchMouseOrPointerEvent(aMouseEvent, isPointer ? ePointerLeave : eMouseOut, + DispatchMouseOrPointerEvent(aMouseEvent, isPointer ? ePointerOut : eMouseOut, wrapper->mLastOverElement, aMovingInto); wrapper->mLastOverFrame = nullptr; @@ -4030,7 +4029,7 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, Maybe enterDispatcher; if (dispatch) { enterDispatcher.emplace(this, aContent, lastOverElement, aMouseEvent, - isPointer ? NS_POINTER_ENTER : eMouseEnter); + isPointer ? ePointerEnter : eMouseEnter); } NotifyMouseOut(aMouseEvent, aContent); @@ -4047,7 +4046,7 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, // Fire mouseover wrapper->mLastOverFrame = DispatchMouseOrPointerEvent(aMouseEvent, - isPointer ? NS_POINTER_OVER : eMouseOver, + isPointer ? ePointerOver : eMouseOver, aContent, lastOverElement); wrapper->mLastOverElement = aContent; } else { @@ -4169,8 +4168,8 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent) sLastRefPoint = aMouseEvent->refPoint; } - case NS_POINTER_MOVE: - case NS_POINTER_DOWN: + case ePointerMove: + case ePointerDown: { // Get the target content target (mousemove target == mouseover target) nsCOMPtr targetElement = GetEventTargetContent(aMouseEvent); @@ -4185,7 +4184,7 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent) } } break; - case NS_POINTER_UP: + case ePointerUp: { // Get the target content target (mousemove target == mouseover target) nsCOMPtr targetElement = GetEventTargetContent(aMouseEvent); @@ -4346,7 +4345,7 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext, if (sLastDragOverFrame) { FireDragEnterOrExit(sLastDragOverFrame->PresContext(), - aDragEvent, NS_DRAGDROP_LEAVE, + aDragEvent, eDragLeave, targetContent, lastContent, sLastDragOverFrame); } @@ -4368,7 +4367,7 @@ EventStateManager::GenerateDragDropEnterExit(nsPresContext* aPresContext, aDragEvent, NS_DRAGDROP_EXIT, nullptr, lastContent, sLastDragOverFrame); FireDragEnterOrExit(lastDragOverFramePresContext, - aDragEvent, NS_DRAGDROP_LEAVE, + aDragEvent, eDragLeave, nullptr, lastContent, sLastDragOverFrame); sLastDragOverFrame = nullptr; @@ -4423,7 +4422,7 @@ EventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext, // collect any changes to moz cursor settings stored in the event's // data transfer. - if (aMessage == NS_DRAGDROP_LEAVE || aMessage == NS_DRAGDROP_EXIT || + if (aMessage == eDragLeave || aMessage == NS_DRAGDROP_EXIT || aMessage == NS_DRAGDROP_ENTER) { UpdateDragDataTransfer(&event); } @@ -4641,8 +4640,7 @@ already_AddRefed EventStateManager::GetEventTargetContent(WidgetEvent* aEvent) { if (aEvent && - (aEvent->mMessage == NS_FOCUS_CONTENT || - aEvent->mMessage == NS_BLUR_CONTENT)) { + (aEvent->mMessage == eFocus || aEvent->mMessage == eBlur)) { nsCOMPtr content = GetFocusedContent(); return content.forget(); } diff --git a/dom/events/FocusEvent.cpp b/dom/events/FocusEvent.cpp index 4f3732dcac..61b1166fed 100644 --- a/dom/events/FocusEvent.cpp +++ b/dom/events/FocusEvent.cpp @@ -17,7 +17,7 @@ FocusEvent::FocusEvent(EventTarget* aOwner, nsPresContext* aPresContext, InternalFocusEvent* aEvent) : UIEvent(aOwner, aPresContext, - aEvent ? aEvent : new InternalFocusEvent(false, NS_FOCUS_CONTENT)) + aEvent ? aEvent : new InternalFocusEvent(false, eFocus)) { if (aEvent) { mEventIsInternal = false; diff --git a/dom/events/WheelHandlingHelper.cpp b/dom/events/WheelHandlingHelper.cpp index f16eb4c975..092e90453f 100644 --- a/dom/events/WheelHandlingHelper.cpp +++ b/dom/events/WheelHandlingHelper.cpp @@ -214,8 +214,8 @@ WheelTransaction::OnEvent(WidgetEvent* aEvent) case eMouseDown: case eMouseDoubleClick: case eMouseClick: - case NS_CONTEXTMENU: - case NS_DRAGDROP_DROP: + case eContextMenu: + case eDrop: EndTransaction(); return; default: diff --git a/dom/fetch/InternalRequest.cpp b/dom/fetch/InternalRequest.cpp index c4382c1a44..2baed642b1 100644 --- a/dom/fetch/InternalRequest.cpp +++ b/dom/fetch/InternalRequest.cpp @@ -210,8 +210,9 @@ InternalRequest::MapContentPolicyTypeToRequestContext(nsContentPolicyType aConte return context; } +// static bool -InternalRequest::IsNavigationRequest() const +InternalRequest::IsNavigationContentPolicy(nsContentPolicyType aContentPolicyType) { // https://fetch.spec.whatwg.org/#navigation-request-context // @@ -219,17 +220,22 @@ InternalRequest::IsNavigationRequest() const // "iframe", "internal" (as long as context frame type is not "none"), // "location", "metarefresh", and "prerender". // - // TODO: include equivalent check for "form" context - // TODO: include equivalent check for "prerender" context - return mContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT || - mContentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT || - mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME || - mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME || - mContentPolicyType == nsIContentPolicy::TYPE_REFRESH; + // Note, all of these request types are effectively initiated by nsDocShell. + // + // The TYPE_REFRESH is used in some code paths for metarefresh, but will not + // be seen during the actual load. Instead the new load gets a normal + // nsDocShell policy type. We include it here in case this utility method + // is called before the load starts. + return aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT || + aContentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT || + aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME || + aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME || + aContentPolicyType == nsIContentPolicy::TYPE_REFRESH; } +// static bool -InternalRequest::IsWorkerRequest() const +InternalRequest::IsWorkerContentPolicy(nsContentPolicyType aContentPolicyType) { // https://fetch.spec.whatwg.org/#worker-request-context // @@ -239,8 +245,20 @@ InternalRequest::IsWorkerRequest() const // Note, service workers are not included here because currently there is // no way to generate a Request with a "serviceworker" RequestContext. // ServiceWorker scripts cannot be intercepted. - return mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_WORKER || - mContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER; + return aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_WORKER || + aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER; +} + +bool +InternalRequest::IsNavigationRequest() const +{ + return IsNavigationContentPolicy(mContentPolicyType); +} + +bool +InternalRequest::IsWorkerRequest() const +{ + return IsWorkerContentPolicy(mContentPolicyType); } bool @@ -249,5 +267,63 @@ InternalRequest::IsClientRequest() const return IsNavigationRequest() || IsWorkerRequest(); } +// static +RequestMode +InternalRequest::MapChannelToRequestMode(nsIChannel* aChannel) +{ + MOZ_ASSERT(aChannel); + + nsCOMPtr loadInfo; + MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aChannel->GetLoadInfo(getter_AddRefs(loadInfo)))); + + // RequestMode deviates from our internal security mode for navigations. + // While navigations normally allow cross origin we must set a same-origin + // RequestMode to get the correct service worker interception restrictions + // in place. + // TODO: remove the worker override once securityMode is fully implemented (bug 1189945) + nsContentPolicyType contentPolicy = loadInfo->InternalContentPolicyType(); + if (IsNavigationContentPolicy(contentPolicy) || + IsWorkerContentPolicy(contentPolicy)) { + return RequestMode::Same_origin; + } + + uint32_t securityMode; + MOZ_ALWAYS_TRUE(NS_SUCCEEDED(loadInfo->GetSecurityMode(&securityMode))); + + switch(securityMode) { + case nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS: + case nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED: + return RequestMode::Same_origin; + case nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS: + case nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL: + return RequestMode::No_cors; + case nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS: + // TODO: Check additional flag force-preflight after bug 1199693 (bug 1189945) + return RequestMode::Cors; + default: + // TODO: assert never reached after CorsMode flag removed (bug 1189945) + MOZ_ASSERT(securityMode == nsILoadInfo::SEC_NORMAL); + break; + } + + // TODO: remove following code once securityMode is fully implemented (bug 1189945) + + // We only support app:// protocol interception in non-release builds. +#ifndef RELEASE_BUILD + nsCOMPtr jarChannel = do_QueryInterface(aChannel); + if (jarChannel) { + return RequestMode::No_cors; + } +#endif + + nsCOMPtr httpChannel = do_QueryInterface(aChannel); + + uint32_t corsMode; + MOZ_ALWAYS_TRUE(NS_SUCCEEDED(httpChannel->GetCorsMode(&corsMode))); + + // This cast is valid due to static asserts in ServiceWorkerManager.cpp. + return static_cast(corsMode); +} + } // namespace dom } // namespace mozilla diff --git a/dom/fetch/InternalRequest.h b/dom/fetch/InternalRequest.h index 9cc8aa6932..8c9d842386 100644 --- a/dom/fetch/InternalRequest.h +++ b/dom/fetch/InternalRequest.h @@ -377,6 +377,8 @@ public: bool IsClientRequest() const; + static RequestMode + MapChannelToRequestMode(nsIChannel* aChannel); private: // Does not copy mBodyStream. Use fallible Clone() for complete copy. @@ -387,6 +389,12 @@ private: static RequestContext MapContentPolicyTypeToRequestContext(nsContentPolicyType aContentPolicyType); + static bool + IsNavigationContentPolicy(nsContentPolicyType aContentPolicyType); + + static bool + IsWorkerContentPolicy(nsContentPolicyType aContentPolicyType); + nsCString mMethod; // mURL always stores the url with the ref stripped nsCString mURL; diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index 7e0bef9318..a5543608c5 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -227,7 +227,7 @@ HTMLButtonElement::PreHandleEvent(EventChainPreVisitor& aVisitor) WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent(); bool outerActivateEvent = ((mouseEvent && mouseEvent->IsLeftClickEvent()) || - (aVisitor.mEvent->mMessage == NS_UI_ACTIVATE && + (aVisitor.mEvent->mMessage == eLegacyDOMActivate && !mInInternalActivate)); if (outerActivateEvent) { @@ -257,7 +257,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) if (mouseEvent && mouseEvent->IsLeftClickEvent()) { // DOMActive event should be trusted since the activation is actually // occurred even if the cause is an untrusted click event. - InternalUIEvent actEvent(true, NS_UI_ACTIVATE, mouseEvent); + InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent); actEvent.detail = 1; nsCOMPtr shell = aVisitor.mPresContext->GetPresShell(); @@ -359,7 +359,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) SetContentState(nullptr, NS_EVENT_STATE_HOVER); aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault; } - break; + break; default: break; @@ -368,7 +368,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) if (mForm && (mType == NS_FORM_BUTTON_SUBMIT || mType == NS_FORM_BUTTON_RESET)) { InternalFormEvent event(true, - (mType == NS_FORM_BUTTON_RESET) ? NS_FORM_RESET : NS_FORM_SUBMIT); + (mType == NS_FORM_BUTTON_RESET) ? eFormReset : eFormSubmit); event.originator = this; nsEventStatus status = nsEventStatus_eIgnore; @@ -380,7 +380,7 @@ HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // // Using presShell to dispatch the event. It makes sure that // event is not handled if the window is being destroyed. - if (presShell && (event.mMessage != NS_FORM_SUBMIT || + if (presShell && (event.mMessage != eFormSubmit || mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate) || // We know the element is a submit control, if this check is moved, // make sure formnovalidate is used only if it's a submit control. diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index 3fce0b989e..f71293643f 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -269,7 +269,7 @@ HTMLFormElement::Submit(ErrorResult& aRv) mPendingSubmission = nullptr; } - aRv = DoSubmitOrReset(nullptr, NS_FORM_SUBMIT); + aRv = DoSubmitOrReset(nullptr, eFormSubmit); } NS_IMETHODIMP @@ -283,7 +283,7 @@ HTMLFormElement::Submit() NS_IMETHODIMP HTMLFormElement::Reset() { - InternalFormEvent event(true, NS_FORM_RESET); + InternalFormEvent event(true, eFormReset); EventDispatcher::Dispatch(static_cast(this), nullptr, &event); return NS_OK; } @@ -506,7 +506,7 @@ HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) aVisitor.mWantsWillHandleEvent = true; if (aVisitor.mEvent->originalTarget == static_cast(this)) { uint32_t msg = aVisitor.mEvent->mMessage; - if (msg == NS_FORM_SUBMIT) { + if (msg == eFormSubmit) { if (mGeneratingSubmit) { aVisitor.mCanHandle = false; return NS_OK; @@ -517,8 +517,7 @@ HTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) // that means that if there are scripted submissions, the // latest one will be deferred until after the exit point of the handler. mDeferSubmission = true; - } - else if (msg == NS_FORM_RESET) { + } else if (msg == eFormReset) { if (mGeneratingReset) { aVisitor.mCanHandle = false; return NS_OK; @@ -535,8 +534,8 @@ HTMLFormElement::WillHandleEvent(EventChainPostVisitor& aVisitor) // If this is the bubble stage and there is a nested form below us which // received a submit event we do *not* want to handle the submit event // for this form too. - if ((aVisitor.mEvent->mMessage == NS_FORM_SUBMIT || - aVisitor.mEvent->mMessage == NS_FORM_RESET) && + if ((aVisitor.mEvent->mMessage == eFormSubmit || + aVisitor.mEvent->mMessage == eFormReset) && aVisitor.mEvent->mFlags.mInBubblingPhase && aVisitor.mEvent->originalTarget != static_cast(this)) { aVisitor.mEvent->mFlags.mPropagationStopped = true; @@ -549,17 +548,16 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { if (aVisitor.mEvent->originalTarget == static_cast(this)) { EventMessage msg = aVisitor.mEvent->mMessage; - if (msg == NS_FORM_SUBMIT) { + if (msg == eFormSubmit) { // let the form know not to defer subsequent submissions mDeferSubmission = false; } if (aVisitor.mEventStatus == nsEventStatus_eIgnore) { switch (msg) { - case NS_FORM_RESET: - case NS_FORM_SUBMIT: - { - if (mPendingSubmission && msg == NS_FORM_SUBMIT) { + case eFormReset: + case eFormSubmit: { + if (mPendingSubmission && msg == eFormSubmit) { // tell the form to forget a possible pending submission. // the reason is that the script returned true (the event was // ignored) so if there is a stored submission, it will miss @@ -574,7 +572,7 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor) break; } } else { - if (msg == NS_FORM_SUBMIT) { + if (msg == eFormSubmit) { // tell the form to flush a possible pending submission. // the reason is that the script returned false (the event was // not ignored) so if there is a stored submission, it needs to @@ -583,10 +581,9 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor) } } - if (msg == NS_FORM_SUBMIT) { + if (msg == eFormSubmit) { mGeneratingSubmit = false; - } - else if (msg == NS_FORM_RESET) { + } else if (msg == eFormReset) { mGeneratingReset = false; } } @@ -595,7 +592,7 @@ HTMLFormElement::PostHandleEvent(EventChainPostVisitor& aVisitor) nsresult HTMLFormElement::DoSubmitOrReset(WidgetEvent* aEvent, - int32_t aMessage) + EventMessage aMessage) { // Make sure the presentation is up-to-date nsIDocument* doc = GetComposedDoc(); @@ -606,11 +603,11 @@ HTMLFormElement::DoSubmitOrReset(WidgetEvent* aEvent, // JBK Don't get form frames anymore - bug 34297 // Submit or Reset the form - if (NS_FORM_RESET == aMessage) { + if (eFormReset == aMessage) { return DoReset(); } - if (NS_FORM_SUBMIT == aMessage) { + if (eFormSubmit == aMessage) { // Don't submit if we're not in a document or if we're in // a sandboxed frame and form submit is disabled. if (!doc || (doc->GetSandboxFlags() & SANDBOXED_FORMS)) { diff --git a/dom/html/HTMLFormElement.h b/dom/html/HTMLFormElement.h index 26b688d029..f577b11bba 100644 --- a/dom/html/HTMLFormElement.h +++ b/dom/html/HTMLFormElement.h @@ -452,7 +452,7 @@ protected: }; nsresult DoSubmitOrReset(WidgetEvent* aEvent, - int32_t aMessage); + EventMessage aMessage); nsresult DoReset(); // Async callback to handle removal of our default submit diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 9a2d606a74..245307b1c3 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -2809,7 +2809,7 @@ HTMLInputElement::MaybeSubmitForm(nsPresContext* aPresContext) // If there's only one text control, just submit the form // Hold strong ref across the event nsRefPtr form = mForm; - InternalFormEvent event(true, NS_FORM_SUBMIT); + InternalFormEvent event(true, eFormSubmit); nsEventStatus status = nsEventStatus_eIgnore; shell->HandleDOMEventWithTarget(mForm, &event, &status); } @@ -2980,7 +2980,7 @@ HTMLInputElement::DispatchSelectEvent(nsPresContext* aPresContext) // If already handling select event, don't dispatch a second. if (!mHandlingSelectEvent) { - WidgetEvent event(nsContentUtils::IsCallerChrome(), NS_FORM_SELECTED); + WidgetEvent event(nsContentUtils::IsCallerChrome(), eFormSelect); mHandlingSelectEvent = true; EventDispatcher::Dispatch(static_cast(this), @@ -3080,7 +3080,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent(); bool outerActivateEvent = ((mouseEvent && mouseEvent->IsLeftClickEvent()) || - (aVisitor.mEvent->mMessage == NS_UI_ACTIVATE && !mInInternalActivate)); + (aVisitor.mEvent->mMessage == eLegacyDOMActivate && !mInInternalActivate)); if (outerActivateEvent) { aVisitor.mItemFlags |= NS_OUTER_ACTIVATE_EVENT; @@ -3155,7 +3155,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) aVisitor.mItemFlags |= mType; // Fire onchange (if necessary), before we do the blur, bug 357684. - if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { + if (aVisitor.mEvent->mMessage == eBlur) { // Experimental mobile types rely on the system UI to prevent users to not // set invalid values but we have to be extra-careful. Especially if the // option has been enabled on desktop. @@ -3169,8 +3169,8 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } if (mType == NS_FORM_INPUT_RANGE && - (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT || - aVisitor.mEvent->mMessage == NS_BLUR_CONTENT)) { + (aVisitor.mEvent->mMessage == eFocus || + aVisitor.mEvent->mMessage == eBlur)) { // Just as nsGenericHTMLFormElementWithState::PreHandleEvent calls // nsIFormControlFrame::SetFocus, we handle focus here. nsIFrame* frame = GetPrimaryFrame(); @@ -3223,9 +3223,9 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) StopNumberControlSpinnerSpin(); } } - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT || - aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT) { + if (aVisitor.mEvent->mMessage == eFocus || + aVisitor.mEvent->mMessage == eBlur) { + if (aVisitor.mEvent->mMessage == eFocus) { // Tell our frame it's getting focus so that it can make sure focus // is moved to our anonymous text control. nsNumberControlFrame* numberControlFrame = @@ -3289,7 +3289,7 @@ HTMLInputElement::PreHandleEvent(EventChainPreVisitor& aVisitor) numberControlFrame->HandlingInputEvent(false); } } - else if (aVisitor.mEvent->mMessage == NS_FORM_CHANGE) { + else if (aVisitor.mEvent->mMessage == eFormChange) { // We cancel the DOM 'change' event that is fired for any change to our // anonymous text control since we fire our own 'change' events and // content shouldn't be seeing two 'change' events. Besides that we @@ -3576,15 +3576,15 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) return MaybeInitPickers(aVisitor); } - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT || - aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT && + if (aVisitor.mEvent->mMessage == eFocus || + aVisitor.mEvent->mMessage == eBlur) { + if (aVisitor.mEvent->mMessage == eFocus && MayFireChangeOnBlur() && !mIsDraggingRange) { // StartRangeThumbDrag already set mFocusedValue GetValue(mFocusedValue); } - if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { + if (aVisitor.mEvent->mMessage == eBlur) { if (mIsDraggingRange) { FinishRangeThumbDrag(); } else if (mNumberControlSpinnerIsSpinning) { @@ -3592,7 +3592,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) } } - UpdateValidityUIBits(aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT); + UpdateValidityUIBits(aVisitor.mEvent->mMessage == eFocus); UpdateState(true); } @@ -3619,7 +3619,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) !ShouldPreventDOMActivateDispatch(aVisitor.mEvent->originalTarget)) { // DOMActive event should be trusted since the activation is actually // occurred even if the cause is an untrusted click event. - InternalUIEvent actEvent(true, NS_UI_ACTIVATE, mouseEvent); + InternalUIEvent actEvent(true, eLegacyDOMActivate, mouseEvent); actEvent.detail = 1; nsCOMPtr shell = aVisitor.mPresContext->GetPresShell(); @@ -3734,9 +3734,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) } } else if (nsEventStatus_eIgnore == aVisitor.mEventStatus) { switch (aVisitor.mEvent->mMessage) { - - case NS_FOCUS_CONTENT: - { + case eFocus: { // see if we should select the contents of the textbox. This happens // for text and password fields when the field was focused by the // keyboard or a navigation, the platform allows it, and it wasn't @@ -3991,7 +3989,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) case NS_FORM_INPUT_IMAGE: if (mForm) { InternalFormEvent event(true, - (mType == NS_FORM_INPUT_RESET) ? NS_FORM_RESET : NS_FORM_SUBMIT); + (mType == NS_FORM_INPUT_RESET) ? eFormReset : eFormSubmit); event.originator = this; nsEventStatus status = nsEventStatus_eIgnore; @@ -4003,7 +4001,7 @@ HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // pres shell. See bug 125624. // TODO: removing this code and have the submit event sent by the // form, see bug 592124. - if (presShell && (event.mMessage != NS_FORM_SUBMIT || + if (presShell && (event.mMessage != eFormSubmit || mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate) || // We know the element is a submit control, if this check is moved, // make sure formnovalidate is used only if it's a submit control. diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index 31647430dc..5f918d05d3 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -211,11 +211,11 @@ HTMLObjectElement::HandleFocusBlurPlugin(Element* aElement, return; } switch (aEvent->mMessage) { - case NS_FOCUS_CONTENT: { + case eFocus: { OnFocusBlurPlugin(aElement, true); break; } - case NS_BLUR_CONTENT: { + case eBlur: { OnFocusBlurPlugin(aElement, false); break; } @@ -287,7 +287,7 @@ HTMLObjectElement::UnbindFromTree(bool aDeep, { #ifdef XP_MACOSX // When a page is reloaded (when an nsIDocument's content is removed), the - // focused element isn't necessarily sent an NS_BLUR_CONTENT event. See + // focused element isn't necessarily sent an eBlur event. See // nsFocusManager::ContentRemoved(). This means that a widget may think it // still contains a focused plugin when it doesn't -- which in turn can // disable text input in the browser window. See bug 1137229. diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp index 1f8cc1a81e..89208c6cad 100644 --- a/dom/html/HTMLSelectElement.cpp +++ b/dom/html/HTMLSelectElement.cpp @@ -1520,7 +1520,7 @@ HTMLSelectElement::PreHandleEvent(EventChainPreVisitor& aVisitor) nsresult HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT) { + if (aVisitor.mEvent->mMessage == eFocus) { // If the invalid UI is shown, we should show it while focused and // update the invalid/valid UI. mCanShowInvalidUI = !IsValid() && ShouldShowValidityUI(); @@ -1531,7 +1531,7 @@ HTMLSelectElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // We don't have to update NS_EVENT_STATE_MOZ_UI_INVALID nor // NS_EVENT_STATE_MOZ_UI_VALID given that the states should not change. - } else if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { + } else if (aVisitor.mEvent->mMessage == eBlur) { mCanShowInvalidUI = true; mCanShowValidUI = true; diff --git a/dom/html/HTMLSharedObjectElement.cpp b/dom/html/HTMLSharedObjectElement.cpp index a7679d2be9..bb2df743db 100644 --- a/dom/html/HTMLSharedObjectElement.cpp +++ b/dom/html/HTMLSharedObjectElement.cpp @@ -164,7 +164,7 @@ HTMLSharedObjectElement::UnbindFromTree(bool aDeep, { #ifdef XP_MACOSX // When a page is reloaded (when an nsIDocument's content is removed), the - // focused element isn't necessarily sent an NS_BLUR_CONTENT event. See + // focused element isn't necessarily sent an eBlur event. See // nsFocusManager::ContentRemoved(). This means that a widget may think it // still contains a focused plugin when it doesn't -- which in turn can // disable text input in the browser window. See bug 1137229. diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp index eca1d6bcdf..1ccd24e171 100644 --- a/dom/html/HTMLTextAreaElement.cpp +++ b/dom/html/HTMLTextAreaElement.cpp @@ -137,7 +137,7 @@ HTMLTextAreaElement::Select() } nsEventStatus status = nsEventStatus_eIgnore; - WidgetGUIEvent event(true, NS_FORM_SELECTED, nullptr); + WidgetGUIEvent event(true, eFormSelect, nullptr); // XXXbz HTMLInputElement guards against this reentering; shouldn't we? EventDispatcher::Dispatch(static_cast(this), presContext, &event, nullptr, &status); @@ -484,7 +484,7 @@ HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor) // Don't dispatch a second select event if we are already handling // one. - if (aVisitor.mEvent->mMessage == NS_FORM_SELECTED) { + if (aVisitor.mEvent->mMessage == eFormSelect) { if (mHandlingSelect) { return NS_OK; } @@ -504,7 +504,7 @@ HTMLTextAreaElement::PreHandleEvent(EventChainPreVisitor& aVisitor) } // Fire onchange (if necessary), before we do the blur, bug 370521. - if (aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { + if (aVisitor.mEvent->mMessage == eBlur) { FireChangeEventIfNeeded(); } @@ -532,13 +532,13 @@ HTMLTextAreaElement::FireChangeEventIfNeeded() nsresult HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { - if (aVisitor.mEvent->mMessage == NS_FORM_SELECTED) { + if (aVisitor.mEvent->mMessage == eFormSelect) { mHandlingSelect = false; } - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT || - aVisitor.mEvent->mMessage == NS_BLUR_CONTENT) { - if (aVisitor.mEvent->mMessage == NS_FOCUS_CONTENT) { + if (aVisitor.mEvent->mMessage == eFocus || + aVisitor.mEvent->mMessage == eBlur) { + if (aVisitor.mEvent->mMessage == eFocus) { // If the invalid UI is shown, we should show it while focusing (and // update). Otherwise, we should not. GetValueInternal(mFocusedValue, true); @@ -547,7 +547,7 @@ HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) // If neither invalid UI nor valid UI is shown, we shouldn't show the valid // UI while typing. mCanShowValidUI = ShouldShowValidityUI(); - } else { // NS_BLUR_CONTENT + } else { // eBlur mCanShowInvalidUI = true; mCanShowValidUI = true; } diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 0a9b771247..ea930d9750 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2252,8 +2252,7 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) { if (aVisitor.mEvent->mFlags.mIsTrusted) { switch (aVisitor.mEvent->mMessage) { - case NS_FOCUS_CONTENT: - { + case eFocus: { // Check to see if focus has bubbled up from a form control's // child textfield or button. If that's the case, don't focus // this parent file control -- leave focus on the child. @@ -2263,8 +2262,7 @@ nsGenericHTMLFormElement::PreHandleEvent(EventChainPreVisitor& aVisitor) formControlFrame->SetFocus(true, true); break; } - case NS_BLUR_CONTENT: - { + case eBlur: { nsIFormControlFrame* formControlFrame = GetFormControlFrame(true); if (formControlFrame) formControlFrame->SetFocus(false, false); @@ -2454,10 +2452,10 @@ nsGenericHTMLFormElement::IsElementDisabledForEvents(EventMessage aMessage, case eMouseOut: case eMouseEnter: case eMouseLeave: - case NS_POINTER_MOVE: - case NS_POINTER_OVER: - case NS_POINTER_OUT: - case NS_POINTER_ENTER: + case ePointerMove: + case ePointerOver: + case ePointerOut: + case ePointerEnter: case ePointerLeave: case NS_WHEEL_WHEEL: case NS_MOUSE_SCROLL: diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index 439c5051c9..799a43ec42 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -822,7 +822,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* if (presShell) { nsEventStatus status = nsEventStatus_eIgnore; - WidgetEvent event(true, NS_FORM_SELECTED); + WidgetEvent event(true, eFormSelect); presShell->HandleEventWithTarget(&event, mFrame, content, &status); } diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 23a1680011..ebf14e3caf 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -2819,7 +2819,7 @@ ContentChild::RecvInvokeDragSession(nsTArray&& aTransfers, if (session) { session->SetDragAction(aAction); nsCOMPtr dataTransfer = - new DataTransfer(nullptr, NS_DRAGDROP_START, false, -1); + new DataTransfer(nullptr, eDragStart, false, -1); for (uint32_t i = 0; i < aTransfers.Length(); ++i) { auto& items = aTransfers[i].items(); for (uint32_t j = 0; j < items.Length(); ++j) { diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index c58188a259..cb97c9616c 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -5114,9 +5114,9 @@ ContentParent::MaybeInvokeDragSession(TabParent* aParent) session->GetDataTransfer(getter_AddRefs(domTransfer)); nsCOMPtr transfer = do_QueryInterface(domTransfer); if (!transfer) { - // Pass NS_DRAGDROP_DROP to get DataTransfer with external + // Pass eDrop to get DataTransfer with external // drag formats cached. - transfer = new DataTransfer(nullptr, NS_DRAGDROP_DROP, true, -1); + transfer = new DataTransfer(nullptr, eDrop, true, -1); session->SetDataTransfer(transfer); } // Note, even though this fills the DataTransfer object with diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 7a380dfebe..b3a045c242 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2194,7 +2194,7 @@ TabChild::RecvRealDragEvent(const WidgetDragEvent& aEvent, } } - if (aEvent.mMessage == NS_DRAGDROP_DROP) { + if (aEvent.mMessage == eDrop) { bool canDrop = true; if (!dragSession || NS_FAILED(dragSession->GetCanDrop(&canDrop)) || !canDrop) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index a107046f07..7daef459ff 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -1686,7 +1686,7 @@ nsPluginInstanceOwner::HandleEvent(nsIDOMEvent* aEvent) } if (eventType.EqualsLiteral("MozPerformDelayedBlur")) { if (mShouldBlurOnActivate) { - WidgetGUIEvent blurEvent(true, NS_BLUR_CONTENT, nullptr); + WidgetGUIEvent blurEvent(true, eBlur, nullptr); ProcessEvent(blurEvent); mShouldBlurOnActivate = false; } @@ -1810,8 +1810,8 @@ CocoaEventTypeForEvent(const WidgetGUIEvent& anEvent, nsIFrame* aObjectFrame) return NPCocoaEventKeyDown; case eKeyUp: return NPCocoaEventKeyUp; - case NS_FOCUS_CONTENT: - case NS_BLUR_CONTENT: + case eFocus: + case eBlur: return NPCocoaEventFocusChanged; case NS_MOUSE_SCROLL: return NPCocoaEventScrollWheel; @@ -1915,9 +1915,9 @@ TranslateToNPCocoaEvent(WidgetGUIEvent* anEvent, nsIFrame* aObjectFrame) } break; } - case NS_FOCUS_CONTENT: - case NS_BLUR_CONTENT: - cocoaEvent.data.focus.hasFocus = (anEvent->mMessage == NS_FOCUS_CONTENT); + case eFocus: + case eBlur: + cocoaEvent.data.focus.hasFocus = (anEvent->mMessage == eFocus); break; default: break; @@ -1955,8 +1955,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) // focus unless it lost focus within the window. For example, ignore a blur // event if it's coming due to the plugin's window deactivating. nsCOMPtr content = do_QueryReferent(mContent); - if (anEvent.mMessage == NS_BLUR_CONTENT && - ContentIsFocusedWithinWindow(content)) { + if (anEvent.mMessage == eBlur && ContentIsFocusedWithinWindow(content)) { mShouldBlurOnActivate = true; return nsEventStatus_eIgnore; } @@ -1965,8 +1964,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) // it focus. This might happen if it has focus, its window is blurred, then the // window is made active again. The plugin never lost in-window focus, so it // shouldn't get a focus event again. - if (anEvent.mMessage == NS_FOCUS_CONTENT && - mLastContentFocused == true) { + if (anEvent.mMessage == eFocus && mLastContentFocused == true) { mShouldBlurOnActivate = false; return nsEventStatus_eIgnore; } @@ -1974,9 +1972,8 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) // Now, if we're going to send a focus event, update mLastContentFocused and // tell any plugins in our window that we have taken focus, so they should // perform any delayed blurs. - if (anEvent.mMessage == NS_FOCUS_CONTENT || - anEvent.mMessage == NS_BLUR_CONTENT) { - mLastContentFocused = (anEvent.mMessage == NS_FOCUS_CONTENT); + if (anEvent.mMessage == eFocus || anEvent.mMessage == eBlur) { + mLastContentFocused = (anEvent.mMessage == eFocus); mShouldBlurOnActivate = false; PerformDelayedBlurs(); } @@ -2103,13 +2100,13 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) } else if (!pPluginEvent) { switch (anEvent.mMessage) { - case NS_FOCUS_CONTENT: + case eFocus: pluginEvent.event = WM_SETFOCUS; pluginEvent.wParam = 0; pluginEvent.lParam = 0; pPluginEvent = &pluginEvent; break; - case NS_BLUR_CONTENT: + case eBlur: pluginEvent.event = WM_KILLFOCUS; pluginEvent.wParam = 0; pluginEvent.lParam = 0; @@ -2302,12 +2299,11 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent) default: switch (anEvent.mMessage) { - case NS_FOCUS_CONTENT: - case NS_BLUR_CONTENT: + case eFocus: + case eBlur: { XFocusChangeEvent &event = pluginEvent.xfocus; - event.type = - anEvent.mMessage == NS_FOCUS_CONTENT ? FocusIn : FocusOut; + event.type = anEvent.mMessage == eFocus ? FocusIn : FocusOut; // information lost: event.mode = -1; event.detail = NotifyDetailNone; diff --git a/dom/workers/ServiceWorkerEvents.cpp b/dom/workers/ServiceWorkerEvents.cpp index 3cfb4899c3..fef9967292 100644 --- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -150,7 +150,7 @@ class RespondWithHandler final : public PromiseNativeHandler nsMainThreadPtrHandle mInterceptedChannel; nsMainThreadPtrHandle mServiceWorker; const RequestMode mRequestMode; - const bool mIsClientRequest; + const DebugOnly mIsClientRequest; const bool mIsNavigationRequest; public: NS_DECL_ISUPPORTS @@ -271,8 +271,6 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle aValu // If one of the following conditions is true, return a network error: // * response's type is "error". // * request's mode is not "no-cors" and response's type is "opaque". - // * request is a client request and response's type is neither "basic" - // nor "default". // * request is not a navigation request and response's type is // "opaqueredirect". @@ -281,19 +279,13 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle aValu return; } + MOZ_ASSERT_IF(mIsClientRequest, mRequestMode == RequestMode::Same_origin); + if (response->Type() == ResponseType::Opaque && mRequestMode != RequestMode::No_cors) { autoCancel.SetCancelStatus(NS_ERROR_BAD_OPAQUE_INTERCEPTION_REQUEST_MODE); return; } - // TODO: remove this case as its no longer in the spec (bug 1184967) - if (mIsClientRequest && response->Type() != ResponseType::Basic && - response->Type() != ResponseType::Default && - response->Type() != ResponseType::Opaqueredirect) { - autoCancel.SetCancelStatus(NS_ERROR_CLIENT_REQUEST_OPAQUE_INTERCEPTION); - return; - } - if (!mIsNavigationRequest && response->Type() == ResponseType::Opaqueredirect) { autoCancel.SetCancelStatus(NS_ERROR_BAD_OPAQUE_REDIRECT_INTERCEPTION); return; diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 1da07085d2..5f201853f2 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -3714,22 +3714,7 @@ public: nsCOMPtr internalChannel = do_QueryInterface(httpChannel); NS_ENSURE_TRUE(internalChannel, NS_ERROR_NOT_AVAILABLE); - uint32_t corsMode; - internalChannel->GetCorsMode(&corsMode); - switch (corsMode) { - case nsIHttpChannelInternal::CORS_MODE_SAME_ORIGIN: - mRequestMode = RequestMode::Same_origin; - break; - case nsIHttpChannelInternal::CORS_MODE_NO_CORS: - mRequestMode = RequestMode::No_cors; - break; - case nsIHttpChannelInternal::CORS_MODE_CORS: - case nsIHttpChannelInternal::CORS_MODE_CORS_WITH_FORCED_PREFLIGHT: - mRequestMode = RequestMode::Cors; - break; - default: - MOZ_CRASH("Unexpected CORS mode"); - } + mRequestMode = InternalRequest::MapChannelToRequestMode(channel); // This is safe due to static_asserts at top of file. uint32_t redirectMode; @@ -3762,6 +3747,8 @@ public: mMethod = "GET"; + mRequestMode = InternalRequest::MapChannelToRequestMode(channel); + if (loadFlags & nsIRequest::LOAD_ANONYMOUS) { mRequestCredentials = RequestCredentials::Omit; } diff --git a/dom/workers/test/serviceworkers/fetch/origin/https/origin_test.js b/dom/workers/test/serviceworkers/fetch/origin/https/origin_test.js index cf9bdae973..ddbf02d4c6 100644 --- a/dom/workers/test/serviceworkers/fetch/origin/https/origin_test.js +++ b/dom/workers/test/serviceworkers/fetch/origin/https/origin_test.js @@ -4,8 +4,7 @@ self.addEventListener("install", function(event) { event.waitUntil( self.caches.open("origin-cache") .then(c => { - return c.add(new Request(prefix + 'index-https.sjs', - { redirect: 'manual' })); + return c.add(prefix + 'index-https.sjs'); }) ); }); diff --git a/dom/workers/test/serviceworkers/fetch/origin/https/realindex.html^headers^ b/dom/workers/test/serviceworkers/fetch/origin/https/realindex.html^headers^ new file mode 100644 index 0000000000..5ed82fd065 --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/origin/https/realindex.html^headers^ @@ -0,0 +1 @@ +Access-Control-Allow-Origin: https://example.com diff --git a/dom/workers/test/serviceworkers/fetch/origin/origin_test.js b/dom/workers/test/serviceworkers/fetch/origin/origin_test.js index a68dac0eca..c9ef3ac0d5 100644 --- a/dom/workers/test/serviceworkers/fetch/origin/origin_test.js +++ b/dom/workers/test/serviceworkers/fetch/origin/origin_test.js @@ -6,10 +6,8 @@ self.addEventListener("install", function(event) { .then(c => { return Promise.all( [ - c.add(new Request(prefix + 'index.sjs', - { redirect: 'manual' } )), - c.add(new Request(prefix + 'index-to-https.sjs', - { redirect: 'manual' } )) + c.add(prefix + 'index.sjs'), + c.add(prefix + 'index-to-https.sjs') ] ); }) diff --git a/dom/workers/test/serviceworkers/fetch/origin/realindex.html^headers^ b/dom/workers/test/serviceworkers/fetch/origin/realindex.html^headers^ new file mode 100644 index 0000000000..3a6a85d894 --- /dev/null +++ b/dom/workers/test/serviceworkers/fetch/origin/realindex.html^headers^ @@ -0,0 +1 @@ +Access-Control-Allow-Origin: http://mochi.test:8888 diff --git a/dom/workers/test/serviceworkers/mochitest.ini b/dom/workers/test/serviceworkers/mochitest.ini index f3d928b421..aaa955898c 100644 --- a/dom/workers/test/serviceworkers/mochitest.ini +++ b/dom/workers/test/serviceworkers/mochitest.ini @@ -54,11 +54,13 @@ support-files = fetch/origin/index.sjs fetch/origin/index-to-https.sjs fetch/origin/realindex.html + fetch/origin/realindex.html^headers^ fetch/origin/register.html fetch/origin/unregister.html fetch/origin/origin_test.js fetch/origin/https/index-https.sjs fetch/origin/https/realindex.html + fetch/origin/https/realindex.html^headers^ fetch/origin/https/register.html fetch/origin/https/unregister.html fetch/origin/https/origin_test.js diff --git a/dom/xml/XMLDocument.cpp b/dom/xml/XMLDocument.cpp index d39bf35011..d93a782fc8 100644 --- a/dom/xml/XMLDocument.cpp +++ b/dom/xml/XMLDocument.cpp @@ -583,7 +583,7 @@ XMLDocument::EndLoad() // Generate a document load event for the case when an XML // document was loaded as pure data without any presentation // attached to it. - WidgetEvent event(true, NS_LOAD); + WidgetEvent event(true, eLoad); EventDispatcher::Dispatch(static_cast(this), nullptr, &event); } } diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 7c05acf002..339fc67d18 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -1277,8 +1277,8 @@ nsXULElement::PreHandleEvent(EventChainPreVisitor& aVisitor) (aVisitor.mEvent->mMessage == eMouseClick || aVisitor.mEvent->mMessage == eMouseDoubleClick || aVisitor.mEvent->mMessage == NS_XUL_COMMAND || - aVisitor.mEvent->mMessage == NS_CONTEXTMENU || - aVisitor.mEvent->mMessage == NS_DRAGDROP_START || + aVisitor.mEvent->mMessage == eContextMenu || + aVisitor.mEvent->mMessage == eDragStart || aVisitor.mEvent->mMessage == NS_DRAGDROP_GESTURE)) { // Don't propagate these events from native anonymous scrollbar. aVisitor.mCanHandle = true; diff --git a/editor/libeditor/nsEditorEventListener.cpp b/editor/libeditor/nsEditorEventListener.cpp index 9644378c10..544cfe7cea 100644 --- a/editor/libeditor/nsEditorEventListener.cpp +++ b/editor/libeditor/nsEditorEventListener.cpp @@ -386,7 +386,7 @@ nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent) return DragExit(dragEvent); } // drop - case NS_DRAGDROP_DROP: { + case eDrop: { nsCOMPtr dragEvent = do_QueryInterface(aEvent); return Drop(dragEvent); } @@ -454,10 +454,10 @@ nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent) return MouseClick(mouseEvent); } // focus - case NS_FOCUS_CONTENT: + case eFocus: return Focus(aEvent); // blur - case NS_BLUR_CONTENT: + case eBlur: return Blur(aEvent); // text case NS_COMPOSITION_CHANGE: diff --git a/editor/libeditor/nsHTMLEditorEventListener.cpp b/editor/libeditor/nsHTMLEditorEventListener.cpp index 36025daebd..7e2aed530a 100644 --- a/editor/libeditor/nsHTMLEditorEventListener.cpp +++ b/editor/libeditor/nsHTMLEditorEventListener.cpp @@ -86,7 +86,7 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent) // Detect only "context menu" click // XXX This should be easier to do! - // But eDOMEvents_contextmenu and NS_CONTEXTMENU is not exposed in any event + // But eDOMEvents_contextmenu and eContextMenu is not exposed in any event // interface :-( int16_t buttonNumber; nsresult rv = aMouseEvent->GetButton(&buttonNumber); diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 425ec16e4e..7c421e3d48 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -914,8 +914,8 @@ APZCTreeManager::UpdateWheelTransaction(WidgetInputEvent& aEvent) case eMouseDown: case eMouseDoubleClick: case eMouseClick: - case NS_CONTEXTMENU: - case NS_DRAGDROP_DROP: + case eContextMenu: + case eDrop: txn->EndTransaction(); return; default: diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index da6a1ff20a..21b60cbc4e 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -981,7 +981,7 @@ nsDocumentViewer::LoadComplete(nsresult aStatus) if(window && (NS_SUCCEEDED(aStatus) || aStatus == NS_ERROR_PARSED_DATA_CACHED)) { nsEventStatus status = nsEventStatus_eIgnore; - WidgetEvent event(true, NS_LOAD); + WidgetEvent event(true, eLoad); event.mFlags.mBubbles = false; event.mFlags.mCancelable = false; // XXX Dispatching to |window|, but using |document| as the target. @@ -1390,7 +1390,7 @@ nsDocumentViewer::PageHide(bool aIsUnload) // Now, fire an Unload event to the document... nsEventStatus status = nsEventStatus_eIgnore; - WidgetEvent event(true, NS_PAGE_UNLOAD); + WidgetEvent event(true, eUnload); event.mFlags.mBubbles = false; // XXX Dispatching to |window|, but using |document| as the target. event.target = mDocument; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 84dea61875..126b445895 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -6338,14 +6338,14 @@ PresShell::UpdateActivePointerState(WidgetGUIEvent* aEvent) new PointerInfo(false, mouseEvent->inputSource, true)); } break; - case NS_POINTER_DOWN: + case ePointerDown: // In this case we switch pointer to active state if (WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent()) { gActivePointersIds->Put(pointerEvent->pointerId, new PointerInfo(true, pointerEvent->inputSource, pointerEvent->isPrimary)); } break; - case NS_POINTER_UP: + case ePointerUp: // In this case we remove information about pointer or turn off active state if (WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent()) { if(pointerEvent->inputSource != nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) { @@ -6659,13 +6659,13 @@ DispatchPointerFromMouseOrTouch(PresShell* aShell, if (mouseEvent->buttons == 0) { button = -1; } - pointerMessage = NS_POINTER_MOVE; + pointerMessage = ePointerMove; break; case eMouseUp: - pointerMessage = NS_POINTER_UP; + pointerMessage = ePointerUp; break; case eMouseDown: - pointerMessage = NS_POINTER_DOWN; + pointerMessage = ePointerDown; break; default: return NS_OK; @@ -6685,13 +6685,13 @@ DispatchPointerFromMouseOrTouch(PresShell* aShell, // copy the event switch (touchEvent->mMessage) { case NS_TOUCH_MOVE: - pointerMessage = NS_POINTER_MOVE; + pointerMessage = ePointerMove; break; case NS_TOUCH_END: - pointerMessage = NS_POINTER_UP; + pointerMessage = ePointerUp; break; case NS_TOUCH_START: - pointerMessage = NS_POINTER_DOWN; + pointerMessage = ePointerDown; break; case NS_TOUCH_CANCEL: pointerMessage = ePointerCancel; @@ -7427,7 +7427,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, } if (aEvent->mClass == ePointerEventClass && - aEvent->mMessage != NS_POINTER_DOWN) { + aEvent->mMessage != ePointerDown) { if (WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent()) { uint32_t pointerId = pointerEvent->pointerId; nsIContent* pointerCapturingContent = GetPointerCapturingContent(pointerId); @@ -7442,10 +7442,10 @@ PresShell::HandleEvent(nsIFrame* aFrame, frame = capturingFrame; } - if (pointerEvent->mMessage == NS_POINTER_UP || + if (pointerEvent->mMessage == ePointerUp || pointerEvent->mMessage == ePointerCancel) { // Implicitly releasing capture for given pointer. - // ePointerLostCapture should be send after NS_POINTER_UP or + // ePointerLostCapture should be send after ePointerUp or // ePointerCancel. releasePointerCaptureCaller.SetTarget(pointerId, pointerCapturingContent); } @@ -7873,7 +7873,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus) isHandlingUserInput = true; break; - case NS_DRAGDROP_DROP: { + case eDrop: { nsCOMPtr session = nsContentUtils::GetDragSession(); if (session) { bool onlyChromeDrop = false; @@ -7896,7 +7896,7 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, nsEventStatus* aStatus) } } - if (aEvent->mMessage == NS_CONTEXTMENU) { + if (aEvent->mMessage == eContextMenu) { WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); if (mouseEvent->context == WidgetMouseEvent::eContextMenuKey && !AdjustContextMenuKeyEvent(mouseEvent)) { diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 2238584a36..814f666fdc 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -103,7 +103,7 @@ nsImageBoxFrameEvent::Run() void FireImageDOMEvent(nsIContent* aContent, EventMessage aMessage) { - NS_ASSERTION(aMessage == NS_LOAD || aMessage == NS_LOAD_ERROR, + NS_ASSERTION(aMessage == eLoad || aMessage == eLoadError, "invalid message"); nsCOMPtr event = new nsImageBoxFrameEvent(aContent, aMessage); @@ -735,13 +735,13 @@ nsImageBoxFrame::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus) { if (NS_SUCCEEDED(aStatus)) { // Fire an onload DOM event. - FireImageDOMEvent(mContent, NS_LOAD); + FireImageDOMEvent(mContent, eLoad); } else { // Fire an onerror DOM event. mIntrinsicSize.SizeTo(0, 0); PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY); - FireImageDOMEvent(mContent, NS_LOAD_ERROR); + FireImageDOMEvent(mContent, eLoadError); } return NS_OK; diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index a0bf10540c..669288225e 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -434,7 +434,7 @@ nsMenuFrame::HandleEvent(nsPresContext* aPresContext, (aEvent->mMessage == eMouseUp && aEvent->AsMouseEvent()->button == WidgetMouseEvent::eRightButton) && #else - aEvent->mMessage == NS_CONTEXTMENU && + aEvent->mMessage == eContextMenu && #endif onmenu && !IsMenu() && !IsDisabled()) { // if this menu is a context menu it accepts right-clicks...fire away! diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index bdb1821d9c..58cd8d9861 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -2709,7 +2709,7 @@ nsTreeBodyFrame::HandleEvent(nsPresContext* aPresContext, // Indicate that the drop is allowed by preventing the default behaviour. if (mSlots->mDropAllowed) *aEventStatus = nsEventStatus_eConsumeNoDefault; - } else if (aEvent->mMessage == NS_DRAGDROP_DROP) { + } else if (aEvent->mMessage == eDrop) { // this event was meant for another frame, so ignore it if (!mSlots) return NS_OK; diff --git a/testing/web-platform/mozilla/meta/service-workers/service-worker/__dir__.ini b/testing/web-platform/mozilla/meta/service-workers/service-worker/__dir__.ini new file mode 100644 index 0000000000..57c38e8b32 --- /dev/null +++ b/testing/web-platform/mozilla/meta/service-workers/service-worker/__dir__.ini @@ -0,0 +1,3 @@ +prefs: [dom.serviceWorkers.enabled: true, + dom.serviceWorkers.interception.enabled: true, + dom.serviceWorkers.interception.opaque.enabled: true] diff --git a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-frame-resource.https.html.ini b/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-frame-resource.https.html.ini deleted file mode 100644 index 1245221223..0000000000 --- a/testing/web-platform/mozilla/meta/service-workers/service-worker/fetch-frame-resource.https.html.ini +++ /dev/null @@ -1,10 +0,0 @@ -[fetch-frame-resource.https.html] - type: testharness - [CORS type response could be loaded in the iframe.] - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1184967 - expected: FAIL - - [CORS type response could be loaded in the new window.] - bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1184967 - expected: FAIL - diff --git a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-frame-resource.https.html b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-frame-resource.https.html index fca530b4c5..156880faa1 100644 --- a/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-frame-resource.https.html +++ b/testing/web-platform/mozilla/tests/service-workers/service-worker/fetch-frame-resource.https.html @@ -14,6 +14,63 @@ if (window.testRunner) { testRunner.setCanOpenWindows(); } +function getLoadedObject(win, contentFunc, closeFunc) { + return new Promise(function(resolve) { + function done(contentString) { + var result = null; + // fetch-access-control.py returns a string like "report( )". + // Eval the returned string with a report functionto get the json + // object. + try { + function report(obj) { result = obj }; + eval(contentString); + } catch(e) { + // just resolve null if we get unexpected page content + } + closeFunc(win); + resolve(result); + } + + // We can't catch the network error on window. So we use the timer. + var timeout = setTimeout(function() { + // Failure pages are considered cross-origin in some browsers. This + // means you cannot even .resolve() the window because the check for + // the .then property will throw. Instead, treat cross-origin + // failure pages as the empty string which will fail to parse as the + // expected json result. + var content = ''; + try { + content = contentFunc(win); + } catch(e) { + // use default empty string for cross-domain window + } + done(content); + }, 5000); + + win.onload = function() { + clearTimeout(timeout); + var content = contentFunc(win); + done(content); + }; + }); +} + +function getLoadedFrameAsObject(frame) { + return getLoadedObject(frame, function(f) { + return f.contentDocument.body.textContent; + }, function(f) { + f.parentNode.removeChild(f); + }); +} + +function getLoadedWindowAsObject(win) { + return getLoadedObject(win, function(w) { + return w.document.body.textContent + }, function(w) { + w.close(); + }); +} + async_test(function(t) { var scope = 'resources/fetch-frame-resource/frame-basic'; service_worker_unregister_and_register(t, worker, scope) @@ -21,16 +78,18 @@ async_test(function(t) { return wait_for_state(t, reg.installing, 'activated'); }) .then(function() { - return with_iframe( + var frame = document.createElement('iframe'); + frame.src = scope + '?url=' + - encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); + encodeURIComponent(host_info['HTTPS_ORIGIN'] + path); + document.body.appendChild(frame); + return getLoadedFrameAsObject(frame); }) - .then(function(frame) { - assert_not_equals( - frame.contentDocument.body.textContent, - '', + .then(function(result) { + assert_equals( + result.jsonpResult, + 'success', 'Basic type response could be loaded in the iframe.'); - frame.remove(); return service_worker_unregister_and_done(t, scope); }) .catch(unreached_rejection(t)); @@ -46,24 +105,20 @@ async_test(function(t) { var frame = document.createElement('iframe'); frame.src = scope + '?mode=cors&url=' + - encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + - '?ACAOrigin=' + host_info['HTTP_ORIGIN']); + encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + path + + '?ACAOrigin=' + host_info['HTTPS_ORIGIN']); document.body.appendChild(frame); - // We can't catch the network error on iframe. So we use the timer. - return new Promise(function(resolve) { - setTimeout(function() { resolve(frame); }, 1000); - }); + return getLoadedFrameAsObject(frame); }) - .then(function(frame) { + .then(function(result) { assert_equals( - frame.contentDocument.body.textContent, - '', - 'CORS type response could not be loaded in the iframe.'); - frame.remove(); + result.jsonpResult, + 'success', + 'CORS type response could be loaded in the iframe.'); return service_worker_unregister_and_done(t, scope); }) .catch(unreached_rejection(t)); - }, 'CORS type response could not be loaded in the iframe.'); + }, 'CORS type response could be loaded in the iframe.'); async_test(function(t) { var scope = 'resources/fetch-frame-resource/frame-opaque'; @@ -75,19 +130,15 @@ async_test(function(t) { var frame = document.createElement('iframe'); frame.src = scope + '?mode=no-cors&url=' + - encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path); + encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + path); document.body.appendChild(frame); - // We can't catch the network error on iframe. So we use the timer. - return new Promise(function(resolve) { - setTimeout(function() { resolve(frame); }, 1000); - }); + return getLoadedFrameAsObject(frame); }) - .then(function(frame) { + .then(function(result) { assert_equals( - frame.contentDocument.body.textContent, - '', + result, + null, 'Opaque type response could not be loaded in the iframe.'); - frame.remove(); return service_worker_unregister_and_done(t, scope); }) .catch(unreached_rejection(t)); @@ -100,19 +151,16 @@ async_test(function(t) { return wait_for_state(t, reg.installing, 'activated'); }) .then(function() { - return new Promise(function(resolve) { - var win = window.open( - scope + '?url=' + - encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); - win.onload = function() { resolve(win); }; - }); + var win = window.open( + scope + '?url=' + + encodeURIComponent(host_info['HTTPS_ORIGIN'] + path)); + return getLoadedWindowAsObject(win); }) - .then(function(win) { - assert_not_equals( - win.document.body.textContent, - '', + .then(function(result) { + assert_equals( + result.jsonpResult, + 'success', 'Basic type response could be loaded in the new window.'); - win.close(); return service_worker_unregister_and_done(t, scope); }) .catch(unreached_rejection(t)); @@ -127,23 +175,19 @@ async_test(function(t) { .then(function() { var win = window.open( scope + '?mode=cors&url=' + - encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + - '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); - // We can't catch the network error on window. So we use the timer. - return new Promise(function(resolve) { - setTimeout(function() { resolve(win); }, 1000); - }); + encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + path + + '?ACAOrigin=' + host_info['HTTPS_ORIGIN'])); + return getLoadedWindowAsObject(win); }) - .then(function(win) { + .then(function(result) { assert_equals( - win.document.body.textContent, - '', - 'CORS type response could not be loaded in the new window.'); - win.close(); + result.jsonpResult, + 'success', + 'CORS type response could be loaded in the new window.'); return service_worker_unregister_and_done(t, scope); }) .catch(unreached_rejection(t)); - }, 'CORS type response could not be loaded in the new window.'); + }, 'CORS type response could be loaded in the new window.'); async_test(function(t) { var scope = 'resources/fetch-frame-resource/window-opaque'; @@ -154,18 +198,14 @@ async_test(function(t) { .then(function() { var win = window.open( scope + '?mode=no-cors&url=' + - encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path)); - // We can't catch the network error on window. So we use the timer. - return new Promise(function(resolve) { - setTimeout(function() { resolve(win); }, 1000); - }); + encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + path)); + return getLoadedWindowAsObject(win); }) - .then(function(win) { + .then(function(result) { assert_equals( - win.document.body.textContent, - '', + result, + null, 'Opaque type response could not be loaded in the new window.'); - win.close(); return service_worker_unregister_and_done(t, scope); }) .catch(unreached_rejection(t)); diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 7a19ddeb68..7bedc86fbf 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -64,55 +64,55 @@ NS_EVENT_MESSAGE(eMouseLongTap, eMouseEventFirst + 36) // Pointer spec events NS_EVENT_MESSAGE(ePointerEventFirst, 4400) -NS_EVENT_MESSAGE(NS_POINTER_MOVE, ePointerEventFirst) -NS_EVENT_MESSAGE(NS_POINTER_UP, ePointerEventFirst + 1) -NS_EVENT_MESSAGE(NS_POINTER_DOWN, ePointerEventFirst + 2) -NS_EVENT_MESSAGE(NS_POINTER_OVER, ePointerEventFirst + 22) -NS_EVENT_MESSAGE(NS_POINTER_OUT, ePointerEventFirst + 23) -NS_EVENT_MESSAGE(NS_POINTER_ENTER, ePointerEventFirst + 24) +NS_EVENT_MESSAGE(ePointerMove, ePointerEventFirst) +NS_EVENT_MESSAGE(ePointerUp, ePointerEventFirst + 1) +NS_EVENT_MESSAGE(ePointerDown, ePointerEventFirst + 2) +NS_EVENT_MESSAGE(ePointerOver, ePointerEventFirst + 22) +NS_EVENT_MESSAGE(ePointerOut, ePointerEventFirst + 23) +NS_EVENT_MESSAGE(ePointerEnter, ePointerEventFirst + 24) NS_EVENT_MESSAGE(ePointerLeave, ePointerEventFirst + 25) NS_EVENT_MESSAGE(ePointerCancel, ePointerEventFirst + 26) NS_EVENT_MESSAGE(ePointerGotCapture, ePointerEventFirst + 27) NS_EVENT_MESSAGE(ePointerLostCapture, ePointerEventFirst + 28) NS_EVENT_MESSAGE(ePointerEventLast, ePointerLostCapture) -NS_EVENT_MESSAGE(NS_CONTEXTMENU_MESSAGE_START, 500) -NS_EVENT_MESSAGE(NS_CONTEXTMENU, NS_CONTEXTMENU_MESSAGE_START) +NS_EVENT_MESSAGE(eContextMenuFirst, 500) +NS_EVENT_MESSAGE(eContextMenu, eContextMenuFirst) -NS_EVENT_MESSAGE(NS_STREAM_EVENT_START, 1100) -NS_EVENT_MESSAGE(NS_LOAD, NS_STREAM_EVENT_START) -NS_EVENT_MESSAGE(NS_PAGE_UNLOAD, NS_STREAM_EVENT_START + 1) -NS_EVENT_MESSAGE(NS_HASHCHANGE, NS_STREAM_EVENT_START + 2) -NS_EVENT_MESSAGE(NS_IMAGE_ABORT, NS_STREAM_EVENT_START + 3) -NS_EVENT_MESSAGE(NS_LOAD_ERROR, NS_STREAM_EVENT_START + 4) -NS_EVENT_MESSAGE(NS_POPSTATE, NS_STREAM_EVENT_START + 5) -NS_EVENT_MESSAGE(NS_BEFORE_PAGE_UNLOAD, NS_STREAM_EVENT_START + 6) -NS_EVENT_MESSAGE(NS_PAGE_RESTORE, NS_STREAM_EVENT_START + 7) -NS_EVENT_MESSAGE(NS_READYSTATECHANGE, NS_STREAM_EVENT_START + 8) +NS_EVENT_MESSAGE(eStreamEventFirst, 1100) +NS_EVENT_MESSAGE(eLoad, eStreamEventFirst) +NS_EVENT_MESSAGE(eUnload, eStreamEventFirst + 1) +NS_EVENT_MESSAGE(eHashChange, eStreamEventFirst + 2) +NS_EVENT_MESSAGE(eImageAbort, eStreamEventFirst + 3) +NS_EVENT_MESSAGE(eLoadError, eStreamEventFirst + 4) +NS_EVENT_MESSAGE(ePopState, eStreamEventFirst + 5) +NS_EVENT_MESSAGE(eBeforeUnload, eStreamEventFirst + 6) +NS_EVENT_MESSAGE(eReadyStateChange, eStreamEventFirst + 8) -NS_EVENT_MESSAGE(NS_FORM_EVENT_START, 1200) -NS_EVENT_MESSAGE(NS_FORM_SUBMIT, NS_FORM_EVENT_START) -NS_EVENT_MESSAGE(NS_FORM_RESET, NS_FORM_EVENT_START + 1) -NS_EVENT_MESSAGE(NS_FORM_CHANGE, NS_FORM_EVENT_START + 2) -NS_EVENT_MESSAGE(NS_FORM_SELECTED, NS_FORM_EVENT_START + 3) -NS_EVENT_MESSAGE(NS_FORM_INVALID, NS_FORM_EVENT_START + 4) +NS_EVENT_MESSAGE(eFormEventFirst, 1200) +NS_EVENT_MESSAGE(eFormSubmit, eFormEventFirst) +NS_EVENT_MESSAGE(eFormReset, eFormEventFirst + 1) +NS_EVENT_MESSAGE(eFormChange, eFormEventFirst + 2) +NS_EVENT_MESSAGE(eFormSelect, eFormEventFirst + 3) +NS_EVENT_MESSAGE(eFormInvalid, eFormEventFirst + 4) //Need separate focus/blur notifications for non-native widgets -NS_EVENT_MESSAGE(NS_FOCUS_EVENT_START, 1300) -NS_EVENT_MESSAGE(NS_FOCUS_CONTENT, NS_FOCUS_EVENT_START) -NS_EVENT_MESSAGE(NS_BLUR_CONTENT, NS_FOCUS_EVENT_START + 1) +NS_EVENT_MESSAGE(eFocusEventFirst, 1300) +NS_EVENT_MESSAGE(eFocus, eFocusEventFirst) +NS_EVENT_MESSAGE(eBlur, eFocusEventFirst + 1) -NS_EVENT_MESSAGE(NS_DRAGDROP_EVENT_START, 1400) -NS_EVENT_MESSAGE(NS_DRAGDROP_ENTER, NS_DRAGDROP_EVENT_START) -NS_EVENT_MESSAGE(NS_DRAGDROP_OVER, NS_DRAGDROP_EVENT_START + 1) -NS_EVENT_MESSAGE(NS_DRAGDROP_EXIT, NS_DRAGDROP_EVENT_START + 2) -NS_EVENT_MESSAGE(NS_DRAGDROP_DRAGDROP, NS_DRAGDROP_EVENT_START + 3) -NS_EVENT_MESSAGE(NS_DRAGDROP_GESTURE, NS_DRAGDROP_EVENT_START + 4) -NS_EVENT_MESSAGE(NS_DRAGDROP_DRAG, NS_DRAGDROP_EVENT_START + 5) -NS_EVENT_MESSAGE(NS_DRAGDROP_END, NS_DRAGDROP_EVENT_START + 6) -NS_EVENT_MESSAGE(NS_DRAGDROP_START, NS_DRAGDROP_EVENT_START + 7) -NS_EVENT_MESSAGE(NS_DRAGDROP_DROP, NS_DRAGDROP_EVENT_START + 8) -NS_EVENT_MESSAGE(NS_DRAGDROP_LEAVE, NS_DRAGDROP_EVENT_START + 9) +NS_EVENT_MESSAGE(eDragDropEventFirst, 1400) +NS_EVENT_MESSAGE(NS_DRAGDROP_ENTER, eDragDropEventFirst) +NS_EVENT_MESSAGE(NS_DRAGDROP_OVER, eDragDropEventFirst + 1) +NS_EVENT_MESSAGE(NS_DRAGDROP_EXIT, eDragDropEventFirst + 2) +NS_EVENT_MESSAGE(NS_DRAGDROP_DRAGDROP, eDragDropEventFirst + 3) +NS_EVENT_MESSAGE(NS_DRAGDROP_GESTURE, eDragDropEventFirst + 4) +NS_EVENT_MESSAGE(NS_DRAGDROP_DRAG, eDragDropEventFirst + 5) +NS_EVENT_MESSAGE(NS_DRAGDROP_END, eDragDropEventFirst + 6) +NS_EVENT_MESSAGE(eDragStart, eDragDropEventFirst + 7) +NS_EVENT_MESSAGE(eDrop, eDragDropEventFirst + 8) +NS_EVENT_MESSAGE(eDragLeave, eDragDropEventFirst + 9) +NS_EVENT_MESSAGE(eDragDropEventLast, eDragLeave) // Events for popups NS_EVENT_MESSAGE(NS_XUL_EVENT_START, 1500) @@ -176,12 +176,15 @@ NS_EVENT_MESSAGE(NS_COMPOSITION_COMMIT_AS_IS, NS_COMPOSITION_EVENT_START + 4) // Its mRanges should be nullptr. NS_EVENT_MESSAGE(NS_COMPOSITION_COMMIT, NS_COMPOSITION_EVENT_START + 5) -// UI events -NS_EVENT_MESSAGE(NS_UI_EVENT_START, 2500) -// this is not to be confused with NS_ACTIVATE! -NS_EVENT_MESSAGE(NS_UI_ACTIVATE, NS_UI_EVENT_START) -NS_EVENT_MESSAGE(NS_UI_FOCUSIN, NS_UI_EVENT_START + 1) -NS_EVENT_MESSAGE(NS_UI_FOCUSOUT, NS_UI_EVENT_START + 2) +// Following events are defined for deprecated DOM events which are using +// InternalUIEvent class. +NS_EVENT_MESSAGE(eLegacyUIEventFirst, 2500) +// DOMActivate (mapped with the DOM event and used internally) +NS_EVENT_MESSAGE(eLegacyDOMActivate, eLegacyUIEventFirst) +// DOMFocusIn (only mapped with the DOM event) +NS_EVENT_MESSAGE(eLegacyDOMFocusIn, eLegacyUIEventFirst + 1) +// DOMFocusOut (only mapped with the DOM event) +NS_EVENT_MESSAGE(eLegacyDOMFocusOut, eLegacyUIEventFirst + 2) // pagetransition events NS_EVENT_MESSAGE(NS_PAGETRANSITION_START, 2700) diff --git a/widget/MouseEvents.h b/widget/MouseEvents.h index 0186f1c6ea..dd9cdea54b 100644 --- a/widget/MouseEvents.h +++ b/widget/MouseEvents.h @@ -229,7 +229,7 @@ public: mFlags.mBubbles = false; mFlags.mCancelable = false; break; - case NS_CONTEXTMENU: + case eContextMenu: button = (context == eNormal) ? eRightButton : eLeftButton; break; default: @@ -240,10 +240,10 @@ public: #ifdef DEBUG virtual ~WidgetMouseEvent() { - NS_WARN_IF_FALSE(mMessage != NS_CONTEXTMENU || + NS_WARN_IF_FALSE(mMessage != eContextMenu || button == ((context == eNormal) ? eRightButton : eLeftButton), - "Wrong button set to NS_CONTEXTMENU event?"); + "Wrong button set to eContextMenu event?"); } #endif @@ -287,7 +287,7 @@ public: */ bool IsContextMenuKeyEvent() const { - return mMessage == NS_CONTEXTMENU && context == eContextMenuKey; + return mMessage == eContextMenu && context == eContextMenuKey; } /** @@ -323,7 +323,7 @@ public: { mFlags.mCancelable = (aMessage != NS_DRAGDROP_EXIT && - aMessage != NS_DRAGDROP_LEAVE && + aMessage != eDragLeave && aMessage != NS_DRAGDROP_END); } @@ -625,7 +625,7 @@ public: void UpdateFlags() { switch (mMessage) { - case NS_POINTER_ENTER: + case ePointerEnter: case ePointerLeave: mFlags.mBubbles = false; mFlags.mCancelable = false; diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index ed9a958b9f..148b91d2c9 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -106,9 +106,9 @@ WidgetEvent::HasDragEventMessage() const case NS_DRAGDROP_GESTURE: case NS_DRAGDROP_DRAG: case NS_DRAGDROP_END: - case NS_DRAGDROP_START: - case NS_DRAGDROP_DROP: - case NS_DRAGDROP_LEAVE: + case eDragStart: + case eDrop: + case eDragLeave: return true; default: return false; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index dc04e0c8bb..c86118973f 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -5081,7 +5081,7 @@ PanGestureTypeForEvent(NSEvent* aEvent) return nil; } - WidgetMouseEvent geckoEvent(true, NS_CONTEXTMENU, mGeckoChild, + WidgetMouseEvent geckoEvent(true, eContextMenu, mGeckoChild, WidgetMouseEvent::eReal); [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent]; geckoEvent.button = WidgetMouseEvent::eRightButton; @@ -5726,8 +5726,7 @@ PanGestureTypeForEvent(NSEvent* aEvent) // cancelled or not as there isn't actually a means to stop the drag mDragService->FireDragEventAtSource(NS_DRAGDROP_DRAG); dragSession->SetCanDrop(false); - } - else if (aMessage == NS_DRAGDROP_DROP) { + } else if (aMessage == eDrop) { // We make the assumption that the dragOver handlers have correctly set // the |canDrop| property of the Drag Session. bool canDrop = false; @@ -5792,7 +5791,7 @@ PanGestureTypeForEvent(NSEvent* aEvent) return [self dragOperationFromDragAction:dragAction]; } case NS_DRAGDROP_EXIT: - case NS_DRAGDROP_DROP: { + case eDrop: { nsCOMPtr sourceNode; dragSession->GetSourceNode(getter_AddRefs(sourceNode)); if (!sourceNode) { @@ -5852,7 +5851,7 @@ PanGestureTypeForEvent(NSEvent* aEvent) - (BOOL)performDragOperation:(id )sender { nsAutoRetainCocoaObject kungFuDeathGrip(self); - BOOL handled = [self doDragAction:NS_DRAGDROP_DROP sender:sender] != NSDragOperationNone; + BOOL handled = [self doDragAction:eDrop sender:sender] != NSDragOperationNone; NS_IF_RELEASE(mDragService); return handled; } diff --git a/widget/gtk/nsDragService.cpp b/widget/gtk/nsDragService.cpp index b874037ece..b6d09f0166 100644 --- a/widget/gtk/nsDragService.cpp +++ b/widget/gtk/nsDragService.cpp @@ -2007,7 +2007,7 @@ nsDragService::DispatchDropEvent() if (mTargetWindow->IsDestroyed()) return FALSE; - EventMessage msg = mCanDrop ? NS_DRAGDROP_DROP : NS_DRAGDROP_EXIT; + EventMessage msg = mCanDrop ? eDrop : NS_DRAGDROP_EXIT; mTargetWindow->DispatchDragEvent(msg, mTargetWindowPoint, mTargetTime); diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 0e0478ba14..2fe666523b 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2693,7 +2693,7 @@ nsWindow::OnButtonPressEvent(GdkEventButton *aEvent) // right menu click on linux should also pop up a context menu if (domButton == WidgetMouseEvent::eRightButton && MOZ_LIKELY(!mIsDestroyed)) { - WidgetMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this, + WidgetMouseEvent contextMenuEvent(true, eContextMenu, this, WidgetMouseEvent::eReal); InitButtonEvent(contextMenuEvent, aEvent); contextMenuEvent.pressure = mLastMotionPressure; @@ -2958,7 +2958,7 @@ nsWindow::OnKeyPressEvent(GdkEventKey *aEvent) // before we dispatch a key, check if it's the context menu key. // If so, send a context menu key event instead. if (is_context_menu_key(event)) { - WidgetMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this, + WidgetMouseEvent contextMenuEvent(true, eContextMenu, this, WidgetMouseEvent::eReal, WidgetMouseEvent::eContextMenuKey); diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index eb7bdc4975..6def3c9fc1 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -2601,20 +2601,20 @@ case _value: eventName.AssignLiteral(_name) ; break switch(aGuiEvent->mMessage) { - _ASSIGN_eventName(NS_BLUR_CONTENT,"NS_BLUR_CONTENT"); + _ASSIGN_eventName(eBlur,"eBlur"); _ASSIGN_eventName(NS_DRAGDROP_GESTURE,"NS_DND_GESTURE"); - _ASSIGN_eventName(NS_DRAGDROP_DROP,"NS_DND_DROP"); + _ASSIGN_eventName(eDrop,"eDrop"); _ASSIGN_eventName(NS_DRAGDROP_ENTER,"NS_DND_ENTER"); _ASSIGN_eventName(NS_DRAGDROP_EXIT,"NS_DND_EXIT"); _ASSIGN_eventName(NS_DRAGDROP_OVER,"NS_DND_OVER"); _ASSIGN_eventName(NS_EDITOR_INPUT,"NS_EDITOR_INPUT"); - _ASSIGN_eventName(NS_FOCUS_CONTENT,"NS_FOCUS_CONTENT"); - _ASSIGN_eventName(NS_FORM_SELECTED,"NS_FORM_SELECTED"); - _ASSIGN_eventName(NS_FORM_CHANGE,"NS_FORM_CHANGE"); - _ASSIGN_eventName(NS_FORM_RESET,"NS_FORM_RESET"); - _ASSIGN_eventName(NS_FORM_SUBMIT,"NS_FORM_SUBMIT"); - _ASSIGN_eventName(NS_IMAGE_ABORT,"NS_IMAGE_ABORT"); - _ASSIGN_eventName(NS_LOAD_ERROR,"NS_LOAD_ERROR"); + _ASSIGN_eventName(eFocus,"eFocus"); + _ASSIGN_eventName(eFormSelect,"eFormSelect"); + _ASSIGN_eventName(eFormChange,"eFormChange"); + _ASSIGN_eventName(eFormReset,"eFormReset"); + _ASSIGN_eventName(eFormSubmit,"eFormSubmit"); + _ASSIGN_eventName(eImageAbort,"eImageAbort"); + _ASSIGN_eventName(eLoadError,"eLoadError"); _ASSIGN_eventName(eKeyDown,"eKeyDown"); _ASSIGN_eventName(eKeyPress,"eKeyPress"); _ASSIGN_eventName(eKeyUp,"eKeyUp"); @@ -2625,13 +2625,13 @@ case _value: eventName.AssignLiteral(_name) ; break _ASSIGN_eventName(eMouseClick,"eMouseClick"); _ASSIGN_eventName(eMouseDoubleClick,"eMouseDoubleClick"); _ASSIGN_eventName(eMouseMove,"eMouseMove"); - _ASSIGN_eventName(NS_LOAD,"NS_LOAD"); - _ASSIGN_eventName(NS_POPSTATE,"NS_POPSTATE"); + _ASSIGN_eventName(eLoad,"eLoad"); + _ASSIGN_eventName(ePopState,"ePopState"); _ASSIGN_eventName(NS_BEFORE_SCRIPT_EXECUTE,"NS_BEFORE_SCRIPT_EXECUTE"); _ASSIGN_eventName(NS_AFTER_SCRIPT_EXECUTE,"NS_AFTER_SCRIPT_EXECUTE"); - _ASSIGN_eventName(NS_PAGE_UNLOAD,"NS_PAGE_UNLOAD"); - _ASSIGN_eventName(NS_HASHCHANGE,"NS_HASHCHANGE"); - _ASSIGN_eventName(NS_READYSTATECHANGE,"NS_READYSTATECHANGE"); + _ASSIGN_eventName(eUnload,"eUnload"); + _ASSIGN_eventName(eHashChange,"eHashChange"); + _ASSIGN_eventName(eReadyStateChange,"eReadyStateChange"); _ASSIGN_eventName(NS_XUL_BROADCAST, "NS_XUL_BROADCAST"); _ASSIGN_eventName(NS_XUL_COMMAND_UPDATE, "NS_XUL_COMMAND_UPDATE"); diff --git a/widget/qt/nsWindow.cpp b/widget/qt/nsWindow.cpp index d384797a2f..538aa8dde8 100644 --- a/widget/qt/nsWindow.cpp +++ b/widget/qt/nsWindow.cpp @@ -1006,7 +1006,7 @@ nsWindow::mousePressEvent(QMouseEvent* aEvent) // Right click on linux should also pop up a context menu. if (event.button == WidgetMouseEvent::eRightButton && MOZ_LIKELY(!mIsDestroyed)) { - WidgetMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this, + WidgetMouseEvent contextMenuEvent(true, eContextMenu, this, WidgetMouseEvent::eReal); InitMouseEvent(contextMenuEvent, aEvent, 1); DispatchEvent(&contextMenuEvent, status); @@ -1140,7 +1140,7 @@ nsWindow::keyPressEvent(QKeyEvent* aEvent) // Before we dispatch a key, check if it's the context menu key. // If so, send a context menu key event instead. if (IsContextMenuKeyEvent(aEvent)) { - WidgetMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this, + WidgetMouseEvent contextMenuEvent(true, eContextMenu, this, WidgetMouseEvent::eReal, WidgetMouseEvent::eContextMenuKey); return DispatchEvent(&contextMenuEvent); diff --git a/widget/windows/nsNativeDragTarget.cpp b/widget/windows/nsNativeDragTarget.cpp index ffab0c402b..3592e56815 100644 --- a/widget/windows/nsNativeDragTarget.cpp +++ b/widget/windows/nsNativeDragTarget.cpp @@ -229,7 +229,7 @@ nsNativeDragTarget::ProcessDrag(EventMessage aEventMessage, *pdwEffect = DROPEFFECT_NONE; } - if (aEventMessage != NS_DRAGDROP_DROP) { + if (aEventMessage != eDrop) { // Get the cached drag effect from the drag service, the data member should // have been set by whoever handled the WidgetGUIEvent or nsIDOMEvent on // drags. @@ -439,7 +439,7 @@ nsNativeDragTarget::Drop(LPDATAOBJECT pData, nsCOMPtr serv = mDragService; // Now process the native drag state and then dispatch the event - ProcessDrag(NS_DRAGDROP_DROP, grfKeyState, aPT, pdwEffect); + ProcessDrag(eDrop, grfKeyState, aPT, pdwEffect); nsCOMPtr currentDragSession; serv->GetCurrentSession(getter_AddRefs(currentDragSession)); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 1e079cbf21..02cdc900d5 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -3839,7 +3839,7 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam, WidgetMouseEvent event(true, aEventMessage, this, WidgetMouseEvent::eReal, aIsContextMenuKey ? WidgetMouseEvent::eContextMenuKey : WidgetMouseEvent::eNormal); - if (aEventMessage == NS_CONTEXTMENU && aIsContextMenuKey) { + if (aEventMessage == eContextMenu && aIsContextMenuKey) { nsIntPoint zero(0, 0); InitEvent(event, &zero); } else { @@ -4990,7 +4990,7 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam, pos = lParamToClient(lParam); } - result = DispatchMouseEvent(NS_CONTEXTMENU, wParam, pos, contextMenukey, + result = DispatchMouseEvent(eContextMenu, wParam, pos, contextMenukey, contextMenukey ? WidgetMouseEvent::eLeftButton : WidgetMouseEvent::eRightButton, diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index b79b364d06..618634001d 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -175,6 +175,7 @@ public: }; NS_IMPL_ISUPPORTS(ResidentUniqueReporter, nsIMemoryReporter) +#ifdef HAVE_MALLINFO #define HAVE_SYSTEM_HEAP_REPORTER 1 nsresult SystemHeapSize(int64_t* aSizeOut) @@ -194,6 +195,7 @@ SystemHeapSize(int64_t* aSizeOut) *aSizeOut = size_t(info.hblkhd) + size_t(info.uordblks); return NS_OK; } +#endif #elif defined(__DragonFly__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) \