From 6cd09e7148b8435b1f5c51a1797bc786be0d9f05 Mon Sep 17 00:00:00 2001 From: Roy Tam Date: Sat, 8 Jun 2019 07:49:15 +0800 Subject: [PATCH] import change from rmottola/Arctic-Fox: - Bug 1143518 - Remove the TryCapture path which is now obsolete. (5b1b50333) - Bug 1112040 - Report invalid regular expressions to the console. (909f196ee) - Bug 1143010 - Stopping a mochitest-browser run is rocket science. (c7c482690) - Bug 1110487 P1 Fix some non-unified bustage before adding new code. (e8c3346a4) - Bug 1140051 Avoid Cache shutdown assert when Manager alive, but not active (1fd5d21d2) --- dom/base/nsContentUtils.cpp | 7 ++- dom/cache/ActorChild.cpp | 4 ++ dom/cache/ActorChild.h | 1 + dom/cache/Manager.cpp | 42 +++++++++++--- dom/ipc/TabParent.cpp | 66 ---------------------- dom/ipc/TabParent.h | 27 --------- dom/promise/PromiseNativeHandler.h | 1 + gfx/layers/apz/util/APZCCallbackHelper.cpp | 19 +------ testing/mochitest/runtests.py | 3 + widget/gonk/nsWindow.cpp | 22 ++------ 10 files changed, 54 insertions(+), 138 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 548c48d169..76a8e932e9 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -6517,6 +6517,11 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern, AutoJSAPI jsapi; jsapi.Init(); JSContext* cx = jsapi.cx(); + + // Failure to create or run the regexp results in the invalid pattern + // matching, but we can still report the error to the console. + jsapi.TakeOwnershipOfErrorReporting(); + // We can use the junk scope here, because we're just using it for // regexp evaluation, not actual script execution. JSAutoCompartment ac(cx, xpc::UnprivilegedJunkScope()); @@ -6530,7 +6535,6 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern, static_cast(aPattern.BeginWriting()), aPattern.Length(), 0)); if (!re) { - JS_ClearPendingException(cx); return true; } @@ -6539,7 +6543,6 @@ nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern, if (!JS_ExecuteRegExpNoStatics(cx, re, static_cast(aValue.BeginWriting()), aValue.Length(), &idx, true, &rval)) { - JS_ClearPendingException(cx); return true; } diff --git a/dom/cache/ActorChild.cpp b/dom/cache/ActorChild.cpp index 581073f3f8..917e4a8174 100644 --- a/dom/cache/ActorChild.cpp +++ b/dom/cache/ActorChild.cpp @@ -43,6 +43,10 @@ ActorChild::FeatureNotified() const return mFeature && mFeature->Notified(); } +ActorChild::ActorChild() +{ +} + ActorChild::~ActorChild() { MOZ_ASSERT(!mFeature); diff --git a/dom/cache/ActorChild.h b/dom/cache/ActorChild.h index eeb9c9a629..263e7805ae 100644 --- a/dom/cache/ActorChild.h +++ b/dom/cache/ActorChild.h @@ -34,6 +34,7 @@ public: FeatureNotified() const; protected: + ActorChild(); ~ActorChild(); private: diff --git a/dom/cache/Manager.cpp b/dom/cache/Manager.cpp index 66c09487f9..e8b5e54755 100644 --- a/dom/cache/Manager.cpp +++ b/dom/cache/Manager.cpp @@ -6,6 +6,7 @@ #include "mozilla/dom/cache/Manager.h" +#include "mozilla/AutoRestore.h" #include "mozilla/Mutex.h" #include "mozilla/StaticMutex.h" #include "mozilla/StaticPtr.h" @@ -197,9 +198,7 @@ public: MOZ_ALWAYS_TRUE(sFactory->mManagerList.RemoveElement(aManager)); // clean up the factory singleton if there are no more managers - if (sFactory->mManagerList.IsEmpty()) { - DestroyInstance(); - } + MaybeDestroyInstance(); } static void @@ -236,6 +235,7 @@ public: private: Factory() + : mInSyncShutdown(false) { MOZ_COUNT_CTOR(cache::Manager::Factory); } @@ -244,6 +244,7 @@ private: { MOZ_COUNT_DTOR(cache::Manager::Factory); MOZ_ASSERT(mManagerList.IsEmpty()); + MOZ_ASSERT(!mInSyncShutdown); } static nsresult @@ -264,7 +265,7 @@ private: // Cannot use ClearOnShutdown() because we're on the background thread. // This is automatically cleared when Factory::Remove() calls - // DestroyInstance(). + // MaybeDestroyInstance(). MOZ_ASSERT(!sBackgroundThread); sBackgroundThread = NS_GetCurrentThread(); } @@ -285,11 +286,19 @@ private: } static void - DestroyInstance() + MaybeDestroyInstance() { mozilla::ipc::AssertIsOnBackgroundThread(); MOZ_ASSERT(sFactory); + // If the factory is is still in use then we cannot delete yet. This + // could be due to managers still existing or because we are in the + // middle of shutting down. We need to be careful not to delete ourself + // synchronously during shutdown. + if (!sFactory->mManagerList.IsEmpty() || sFactory->mInSyncShutdown) { + return; + } + // Be clear about what we are locking. sFactory is bg thread only, so // we don't need to lock it here. Just protect sBackgroundThread. { @@ -320,11 +329,21 @@ private: MOZ_ASSERT(!sFactory->mManagerList.IsEmpty()); - ManagerList::ForwardIterator iter(sFactory->mManagerList); - while (iter.HasMore()) { - nsRefPtr manager = iter.GetNext(); - manager->Shutdown(); + { + // Note that we are synchronously calling shutdown code here. If any + // of the shutdown code synchronously decides to delete the Factory + // we need to delay that delete until the end of this method. + AutoRestore restore(sFactory->mInSyncShutdown); + sFactory->mInSyncShutdown = true; + + ManagerList::ForwardIterator iter(sFactory->mManagerList); + while (iter.HasMore()) { + nsRefPtr manager = iter.GetNext(); + manager->Shutdown(); + } } + + MaybeDestroyInstance(); } class ShutdownAllRunnable MOZ_FINAL : public nsRunnable @@ -363,6 +382,11 @@ private: // PBackground thread only. typedef nsTObserverArray ManagerList; ManagerList mManagerList; + + // This flag is set when we are looping through the list and calling + // Shutdown() on each Manager. We need to be careful not to synchronously + // trigger the deletion of the factory while still executing this loop. + bool mInSyncShutdown; }; // static diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index d0fc559956..de1a0367b0 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -236,8 +236,6 @@ private: namespace mozilla { namespace dom { -TabParent* sEventCapturer; - TabParent *TabParent::mIMETabParent = nullptr; TabParent::LayerToTabParentTable* TabParent::sLayerToTabParentTable = nullptr; @@ -262,7 +260,6 @@ TabParent::TabParent(nsIContentParent* aManager, , mIMECompositionStart(0) , mIMESeqno(0) , mIMECompositionRectOffset(0) - , mEventCaptureDepth(0) , mRect(0, 0, 0, 0) , mDimensions(0, 0) , mOrientation(0) @@ -401,9 +398,6 @@ TabParent::Recv__delete__() void TabParent::ActorDestroy(ActorDestroyReason why) { - if (sEventCapturer == this) { - sEventCapturer = nullptr; - } if (mIMETabParent == this) { mIMETabParent = nullptr; } @@ -1325,22 +1319,7 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event) return false; } if (event.message == NS_TOUCH_START) { - // Adjust the widget coordinates to be relative to our frame. - nsRefPtr frameLoader = GetFrameLoader(); - if (!frameLoader) { - // No frame anymore? - sEventCapturer = nullptr; - return false; - } - mChildProcessOffsetAtTouchStart = GetChildProcessOffset(); - - MOZ_ASSERT((!sEventCapturer && mEventCaptureDepth == 0) || - (sEventCapturer == this && mEventCaptureDepth > 0)); - // We want to capture all remaining touch events in this series - // for fast-path dispatch. - sEventCapturer = this; - ++mEventCaptureDepth; } // PresShell::HandleEventInternal adds touches on touch end/cancel. This @@ -1373,41 +1352,6 @@ bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event) PBrowserParent::SendRealTouchEvent(event, guid, blockId); } -/*static*/ TabParent* -TabParent::GetEventCapturer() -{ - return sEventCapturer; -} - -bool -TabParent::TryCapture(const WidgetGUIEvent& aEvent) -{ - MOZ_ASSERT(sEventCapturer == this && mEventCaptureDepth > 0); - - if (aEvent.mClass != eTouchEventClass) { - // Only capture of touch events is implemented, for now. - return false; - } - - WidgetTouchEvent event(*aEvent.AsTouchEvent()); - - bool isTouchPointUp = (event.message == NS_TOUCH_END || - event.message == NS_TOUCH_CANCEL); - if (event.message == NS_TOUCH_START || isTouchPointUp) { - // Let the DOM see touch start/end events so that its touch-point - // state stays consistent. - if (isTouchPointUp && 0 == --mEventCaptureDepth) { - // All event series are un-captured, don't try to catch any - // more. - sEventCapturer = nullptr; - } - return false; - } - - SendRealTouchEvent(event); - return true; -} - bool TabParent::RecvSyncMessage(const nsString& aMessage, const ClonedMessageData& aData, @@ -2551,11 +2495,6 @@ TabParent::GetLoadContext() return loadContext.forget(); } -/* Be careful if you call this method while proceding a real touch event. For - * example sending a touchstart during a real touchend may results into - * a busted mEventCaptureDepth and following touch events may not do what you - * expect. - */ NS_IMETHODIMP TabParent::InjectTouchEvent(const nsAString& aType, uint32_t* aIdentifiers, @@ -2615,11 +2554,6 @@ TabParent::InjectTouchEvent(const nsAString& aType, event.touches.AppendElement(t); } - if ((msg == NS_TOUCH_END || msg == NS_TOUCH_CANCEL) && sEventCapturer) { - WidgetGUIEvent* guiEvent = event.AsGUIEvent(); - TryCapture(*guiEvent); - } - SendRealTouchEvent(event); return NS_OK; } diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 1736a72177..cd9b79f15b 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -103,30 +103,6 @@ public: nsIXULBrowserWindow* GetXULBrowserWindow(); - /** - * Return the TabParent that has decided it wants to capture an - * event series for fast-path dispatch to its subprocess, if one - * has. - * - * DOM event dispatch and widget are free to ignore capture - * requests from TabParents; the end result wrt remote content is - * (must be) always the same, albeit usually slower without - * subprocess capturing. This allows frontends/widget backends to - * "opt in" to faster cross-process dispatch. - */ - static TabParent* GetEventCapturer(); - /** - * If this is the current event capturer, give this a chance to - * capture the event. If it was captured, return true, false - * otherwise. Un-captured events should follow normal DOM - * dispatch; captured events should result in no further - * processing from the caller of TryCapture(). - * - * It's an error to call TryCapture() if this isn't the event - * capturer. - */ - bool TryCapture(const WidgetGUIEvent& aEvent); - void Destroy(); virtual bool RecvMoveFocus(const bool& aForward) override; @@ -441,9 +417,6 @@ protected: LayoutDeviceIntRect mIMECaretRect; LayoutDeviceIntRect mIMEEditorRect; - // The number of event series we're currently capturing. - int32_t mEventCaptureDepth; - nsIntRect mRect; ScreenIntSize mDimensions; ScreenOrientation mOrientation; diff --git a/dom/promise/PromiseNativeHandler.h b/dom/promise/PromiseNativeHandler.h index 833e065a11..7cb40e3bc6 100644 --- a/dom/promise/PromiseNativeHandler.h +++ b/dom/promise/PromiseNativeHandler.h @@ -8,6 +8,7 @@ #define mozilla_dom_PromiseNativeHandler_h #include "nsISupports.h" +#include "js/TypeDecls.h" namespace mozilla { namespace dom { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 30070ad326..39c042cc55 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -415,23 +415,10 @@ APZCCallbackHelper::ApplyCallbackTransform(WidgetTouchEvent& aEvent, nsEventStatus APZCCallbackHelper::DispatchWidgetEvent(WidgetGUIEvent& aEvent) { - if (!aEvent.widget) - return nsEventStatus_eConsumeNoDefault; - - // A nested process may be capturing events. - if (TabParent* capturer = TabParent::GetEventCapturer()) { - if (capturer->TryCapture(aEvent)) { - // Only touch events should be captured, and touch events from a parent - // process should not make it here. Capture for those is done elsewhere - // (for gonk, in nsWindow::DispatchTouchInputViaAPZ). - MOZ_ASSERT(!XRE_IsParentProcess()); - - return nsEventStatus_eConsumeNoDefault; - } + nsEventStatus status = nsEventStatus_eConsumeNoDefault; + if (aEvent.widget) { + aEvent.widget->DispatchEvent(&aEvent, status); } - nsEventStatus status; - NS_ENSURE_SUCCESS(aEvent.widget->DispatchEvent(&aEvent, status), - nsEventStatus_eConsumeNoDefault); return status; } diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index f958c40330..f778a4d169 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -2016,6 +2016,9 @@ class Mochitest(MochitestUtilsMixin): # Dump the logging buffer self.message_logger.dump_buffered() + if result == -1: + break + # printing total number of tests if options.browserChrome: print "TEST-INFO | checking window state" diff --git a/widget/gonk/nsWindow.cpp b/widget/gonk/nsWindow.cpp index 02d8e5e5b7..396325152d 100644 --- a/widget/gonk/nsWindow.cpp +++ b/widget/gonk/nsWindow.cpp @@ -308,24 +308,10 @@ nsWindow::DispatchTouchEventForAPZ(const MultiTouchInput& aInput, // Convert it to an event we can send to Goanna WidgetTouchEvent event = aInput.ToWidgetTouchEvent(this); - // If there is an event capturing child process, send it directly there. - // This happens if we already sent a touchstart event through the root - // process hit test and it ended up going to a child process. The event - // capturing process should get all subsequent touch events in the same - // event block. In this case the TryCapture call below will return true, - // and the child process will take care of responding to the event as needed - // so we don't need to do anything else here. - if (TabParent* capturer = TabParent::GetEventCapturer()) { - InputAPZContext context(aGuid, aInputBlockId); - if (capturer->TryCapture(event)) { - return; - } - } - - // If it didn't get captured, dispatch the event into the goanna root process - // for "normal" flow. The event might get sent to the child process still, - // but if it doesn't we need to notify the APZ of various things. All of - // that happens in DispatchEventForAPZ + // Dispatch the event into the gecko root process for "normal" flow. + // The event might get sent to a child process, but if it doesn't we need to + // notify the APZ of various things. All of that happens in + // ProcessUntransformedAPZEvent ProcessUntransformedAPZEvent(&event, aGuid, aInputBlockId); }