mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
795ba7b999
- Bug 1222092. Don't let sFocusedIMEWidget keep an nsIWidget alive during shutdown. r=masayuki (f604e32bda) - Bug 1186795 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in widget/ with iterators. r=roc. (65077bd952) - Bug 1186795 (part 2) - Replace nsBaseHashtable::EnumerateRead() calls in widget/ with iterators. r=roc. (b468993d9a) - Bug 1186795 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in widget/ with iterators. r=roc. (29946ed0ce) - Bug 1217251 - Add APZThreadUtils::RunDelayedTaskOnCurrentThread(). r=kats (0a89e92202) - Bug 1223946 - Part 1: Clean up and support needed for converting WidgetWheelEvent to ScrollWheelInput. r=kats (faf54e7920) - Bug 1223946 - Part 2: Ensure wheel event from nsDOMWindowUtil is dispatched on correct thread. r=kats (571d591345) - Bug 1210912 - fix widget leak in LookupRegisteredPluginWindow; r=roc (f224933634) - Bug 1188225 - Implement ChromeProcessController::HandleDoubleTap. r=botond (ffc65ffec1) - Bug 1221371 - Remove unnecessary explicit copies of nsTArray. r=billm (3178318eb5) - Bug 1218991 - Save initial zoom constraints to be used once compositor is created r=kats (4017bdc17d) - Bug 1217818 - Add some more logging to more easily diagnose issues. r=botond (2a1480e209) - Bug 1219898 - Remove use of gPreventMouseEvents in APZ event state-tracking code. r=botond (d6877aaedf) - Bug 1211612 - Add DragInputBlock for async scrollbars. r=kats (6bfbcccead) - Bug 1225007 (part 1, attempt 3) - Use LayoutDevicePixel more in Cocoa widget code. r=kats. (e4078ce0ad) - Bug 1225007 (part 2, attempt 3) - Use LayoutDevicePixel more in Cocoa widget code. r=kats. (0db998bf01) - Bug 1214662 - Fix compile error for enabling APZES_LOG. r=botond (c316ba99cd) - Bug 1223296 - Clear element activation if a contextmenu is displayed. r=botond (e362ffcf8d) - Bug 1217818 - Minor refactoring to reuse a function. r=botond (c0c29e2b90) - Bug 1217818 - Ignore injected touchstart events for the purposes of prevent-default notifications back to APZ. r=botond (b740525b61) - Bug 1223296 - Turn HandlePanStart into a more generic function that can be called from other places. r=botond (d10991094a) - Bug 1223296 - Fire the MozMouseHittest event even if the C++ APZ is enabled. r=rbarker,botond (cdd7523a3b) - Bug 1184890 part.1 SelectionChangeDataBase and TextChangeDataBase should have a flag which indicates whether the change occurred during composition or not r=smaug (e10f782acb) - Bug 1184890 part.2 IMContextWrapper shouldn't commit composition when a selection change notification occurred before starting current composition r=m_kato (8f377bfc36) - Bug 1184890 part.3 TSFTextStore shouldn't commit composition when a selection change notification occurred before starting current composition r=m_kato (b55102256e) - Bug 1216177 - Remove the remaining nsRefPtr forward declarations; r=froydnj (a3674552c3) - Bug 1225571 - Move the code to update the SPCSPS from repaint request handling to when the resolution is updated in the presShell. r=botond (a7d1909ed5) - bug 1181823 - convert test_ev_certs.js, test_keysize_ev.js, and test_validity.js to generate certificates at build time r=Cykesiopka r=mgoodwin (19a2678625) - Bug 1189166 - Cleanup some PSM test generation files post Bug 1181823. r=dkeeler (fad638b365) - Bug 1170388 - Removed an outdated workaround for old clang versions in the static analysis plugin. r=mystor (0c8e0229e7) - Bug 1208814 - Part 1: Add an analysis to prevent default copy constructors from being called on refcounted objects, r=ehsan (6a8605808e) - Bug 1208814 - Part 2: Don't use the default copy constructor in nsNavHistoryQuery::Clone(), r=ehsan (6de5b8a04c) - Bug 1201314 - Make most of std:: non-memmovable for static analysis purposes. r=mystor r=ehsan (3a50302fb6) - fix refptr (70035b7976) - Bug 1223966: Don't claim we support NSTextInput interface. r=masayuki (ab702c6718) - Bug 431620 - Remove unused function GetToggledKeyState [r=roc] (0c7140855c) - bug 1203312 - convert tlsserver to generate certificates at build time r=Cykesiopka,mgoodwin (ada3c01c00) - Bug 1194419 - Remove signature algorithm duplicate use in serial number determination in pycert. r=keeler (37c2fbe839) - Bug 1210180 - Force the view to update when we recycle a Vibrancy view. r=mstange (33490daf1f) - Bug 1142393 - Make menus look correct when 'Reduce transparency' is set. r=smichaud (0d8a1b9b7f) - Bug 1119106 - Add an explanatory comment. r=smichaud (1e44196dad) - Bug 1119106 - Increase the maximum focus ring width on 10.10 to 7 pixels. r=smichaud (1af85f99e8) - Bug 1119106 - Give these enums better names. r=smichaud (65886bdab6) - Bug 1153579 - Fix -Wsign-compare warnings in nsNativeThemeCocoa.mm about int and size_t. r=mstange (d682b281df) - some crash reporter stuff (3157fa0f2d) - bug 726483 remove unnecessary DispatchResized() parameters r=roc (02051fd152) - Bug 1208829 - Make FromUnknownRegion() actually work, and add ToUnknownRegion(). r=mstange (5a087ad3aa) - Bug 1180564: Don't implement NSTextInput any more, just NSTextInputClient. r=masayuki (7611a0d77c) - Bug 1180564: insertNewline should use TextInputHandler::InsertText() instead of using insertText of NSTextInput protocol r=masayuki (dc11c738b9) - Bug 1124408 - Report cocoa view focus correctly when sheets are exposed. r=masayuki,smichaud (34a6a32d8b) - Bug 1138678 - Ignore NOTIFY_IME_OF_BLUR when establishing secure input mode. r=masayuki (4d7b10e8a2) - Bug 1148196 - Crashes at -[ChildView keyDown:] related to secure input. r=masayuki (0cbd54b9cf) - Bug 1211352 part.1 IMEContentObserver should be created when a plugin has focus r=smaug (4500259e6f) - Bug 1211352 part.2 PuppetWidget shouldn't send notifications which are not wanted by the parent process r=m_kato (2557aa51b2) - Bug 1007063 - Show virtual (on-screen) keyboard in Windows 8 and higher when text fields are focused if physical keyboards are not present. r=jimm r=masayuki r=m_kato (9d2c1e62d0) - Bug 1211352 part.3 nsIWidget::GetIMEupdatePreference() for each platform should not request any notifications while a plugin has focus r=m_kato (1aa357bc9d) - Bug 1211352 part.4 PuppetWidget::GetIMEUpdatePreference() should request only position change notifications while a plugin has focus r=m_kato (470fb900d6) - Bug 1211352 part.5 PuppetWidget should cache only the focused editor rect information while a plugin has focus r=m_kato (73e7521d3c) - Bug 1223366 - Update event.buttons on GDK_BUTTON_RELEASE [r=karlt] (107c793c5a) - bug 726483 keep an extra reference to the window r=roc (4e6756939f) - Bug 1186745 part 1 - Add LeakRefPtr for pointer leaking by default. r=froydnj (b7260528df) - Bug 1186745 part 2 - Move nsThreadSyncDispatch class to its own header file. r=froydnj (f408ef41da) - Bug 1186745 part 3 - Make nsThreadSyncDispatch leak the sync task by default when Run() is not called. r=froydnj (17092e33ab) - Bug 1186745 part 4 - Make TracedRunnable accept an already_AddRefed instead of a raw pointer. r=froydnj (8e59e1d0c9) - Bug 1186745 part 5 - Make nsThread::Dispatch() always leak the event if it fails. r=froydnj (220b91529a) - Bug 1186745 part 6 - Fix event leak when using NS_DispatchToCurrentThread. r=froydnj (55a4177f2e) - some crashreporter stuff (a5a59bd6ac) - bug 726483 avoid DispatchResized() during size-allocate r=roc (08ae527f93) - Bug 1212733, cache dnd window state instead of using gtk_window_get_type_hint, r=karlt (c9ee119926) - Bug 1131978 - Acknowledge GDK's scale factor in scale calculation. r=karlt (7280d547b8) - bug 1180008 provide gtk_window_get_window_type for old GTK versions r=glandium (3f7f17ac69) - Bug 1174374 - gdk_cursor_new() is deprecated in 3.16. Use gdk_cursor_new_for_display(). r=karlt (90e2e738f7)
350 lines
9.8 KiB
C++
350 lines
9.8 KiB
C++
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "base/message_loop.h"
|
|
|
|
#include "nsBaseAppShell.h"
|
|
#if defined(MOZ_CRASHREPORTER)
|
|
#include "nsExceptionHandler.h"
|
|
#endif
|
|
#include "nsThreadUtils.h"
|
|
#include "nsIObserverService.h"
|
|
#include "nsServiceManagerUtils.h"
|
|
#include "mozilla/Services.h"
|
|
|
|
// When processing the next thread event, the appshell may process native
|
|
// events (if not in performance mode), which can result in suppressing the
|
|
// next thread event for at most this many ticks:
|
|
#define THREAD_EVENT_STARVATION_LIMIT PR_MillisecondsToInterval(10)
|
|
|
|
NS_IMPL_ISUPPORTS(nsBaseAppShell, nsIAppShell, nsIThreadObserver, nsIObserver)
|
|
|
|
nsBaseAppShell::nsBaseAppShell()
|
|
: mSuspendNativeCount(0)
|
|
, mEventloopNestingLevel(0)
|
|
, mBlockedWait(nullptr)
|
|
, mFavorPerf(0)
|
|
, mNativeEventPending(false)
|
|
, mStarvationDelay(0)
|
|
, mSwitchTime(0)
|
|
, mLastNativeEventTime(0)
|
|
, mEventloopNestingState(eEventloopNone)
|
|
, mRunning(false)
|
|
, mExiting(false)
|
|
, mBlockNativeEvent(false)
|
|
{
|
|
}
|
|
|
|
nsBaseAppShell::~nsBaseAppShell()
|
|
{
|
|
}
|
|
|
|
nsresult
|
|
nsBaseAppShell::Init()
|
|
{
|
|
// Configure ourselves as an observer for the current thread:
|
|
|
|
nsCOMPtr<nsIThreadInternal> threadInt =
|
|
do_QueryInterface(NS_GetCurrentThread());
|
|
NS_ENSURE_STATE(threadInt);
|
|
|
|
threadInt->SetObserver(this);
|
|
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
|
mozilla::services::GetObserverService();
|
|
if (obsSvc)
|
|
obsSvc->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
|
return NS_OK;
|
|
}
|
|
|
|
// Called by nsAppShell's native event callback
|
|
void
|
|
nsBaseAppShell::NativeEventCallback()
|
|
{
|
|
if (!mNativeEventPending.exchange(false))
|
|
return;
|
|
|
|
// If DoProcessNextNativeEvent is on the stack, then we assume that we can
|
|
// just unwind and let nsThread::ProcessNextEvent process the next event.
|
|
// However, if we are called from a nested native event loop (maybe via some
|
|
// plug-in or library function), then go ahead and process Gecko events now.
|
|
if (mEventloopNestingState == eEventloopXPCOM) {
|
|
mEventloopNestingState = eEventloopOther;
|
|
// XXX there is a tiny risk we will never get a new NativeEventCallback,
|
|
// XXX see discussion in bug 389931.
|
|
return;
|
|
}
|
|
|
|
// nsBaseAppShell::Run is not being used to pump events, so this may be
|
|
// our only opportunity to process pending gecko events.
|
|
|
|
nsIThread *thread = NS_GetCurrentThread();
|
|
bool prevBlockNativeEvent = mBlockNativeEvent;
|
|
if (mEventloopNestingState == eEventloopOther) {
|
|
if (!NS_HasPendingEvents(thread))
|
|
return;
|
|
// We're in a nested native event loop and have some gecko events to
|
|
// process. While doing that we block processing native events from the
|
|
// appshell - instead, we want to get back to the nested native event
|
|
// loop ASAP (bug 420148).
|
|
mBlockNativeEvent = true;
|
|
}
|
|
|
|
IncrementEventloopNestingLevel();
|
|
EventloopNestingState prevVal = mEventloopNestingState;
|
|
NS_ProcessPendingEvents(thread, THREAD_EVENT_STARVATION_LIMIT);
|
|
mProcessedGeckoEvents = true;
|
|
mEventloopNestingState = prevVal;
|
|
mBlockNativeEvent = prevBlockNativeEvent;
|
|
|
|
// Continue processing pending events later (we don't want to starve the
|
|
// embedders event loop).
|
|
if (NS_HasPendingEvents(thread))
|
|
DoProcessMoreGeckoEvents();
|
|
|
|
DecrementEventloopNestingLevel();
|
|
}
|
|
|
|
// Note, this is currently overidden on windows, see comments in nsAppShell for
|
|
// details.
|
|
void
|
|
nsBaseAppShell::DoProcessMoreGeckoEvents()
|
|
{
|
|
OnDispatchedEvent(nullptr);
|
|
}
|
|
|
|
|
|
// Main thread via OnProcessNextEvent below
|
|
bool
|
|
nsBaseAppShell::DoProcessNextNativeEvent(bool mayWait)
|
|
{
|
|
// The next native event to be processed may trigger our NativeEventCallback,
|
|
// in which case we do not want it to process any thread events since we'll
|
|
// do that when this function returns.
|
|
//
|
|
// If the next native event is not our NativeEventCallback, then we may end
|
|
// up recursing into this function.
|
|
//
|
|
// However, if the next native event is not our NativeEventCallback, but it
|
|
// results in another native event loop, then our NativeEventCallback could
|
|
// fire and it will see mEventloopNestingState as eEventloopOther.
|
|
//
|
|
EventloopNestingState prevVal = mEventloopNestingState;
|
|
mEventloopNestingState = eEventloopXPCOM;
|
|
|
|
IncrementEventloopNestingLevel();
|
|
bool result = ProcessNextNativeEvent(mayWait);
|
|
DecrementEventloopNestingLevel();
|
|
|
|
mEventloopNestingState = prevVal;
|
|
return result;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// nsIAppShell methods:
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::Run(void)
|
|
{
|
|
NS_ENSURE_STATE(!mRunning); // should not call Run twice
|
|
mRunning = true;
|
|
|
|
nsIThread *thread = NS_GetCurrentThread();
|
|
|
|
MessageLoop::current()->Run();
|
|
|
|
NS_ProcessPendingEvents(thread);
|
|
|
|
mRunning = false;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::Exit(void)
|
|
{
|
|
if (mRunning && !mExiting) {
|
|
MessageLoop::current()->Quit();
|
|
}
|
|
mExiting = true;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::FavorPerformanceHint(bool favorPerfOverStarvation,
|
|
uint32_t starvationDelay)
|
|
{
|
|
mStarvationDelay = PR_MillisecondsToInterval(starvationDelay);
|
|
if (favorPerfOverStarvation) {
|
|
++mFavorPerf;
|
|
} else {
|
|
--mFavorPerf;
|
|
mSwitchTime = PR_IntervalNow();
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::SuspendNative()
|
|
{
|
|
++mSuspendNativeCount;
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::ResumeNative()
|
|
{
|
|
--mSuspendNativeCount;
|
|
NS_ASSERTION(mSuspendNativeCount >= 0, "Unbalanced call to nsBaseAppShell::ResumeNative!");
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::GetEventloopNestingLevel(uint32_t* aNestingLevelResult)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aNestingLevelResult);
|
|
|
|
*aNestingLevelResult = mEventloopNestingLevel;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------
|
|
// nsIThreadObserver methods:
|
|
|
|
// Called from any thread
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::OnDispatchedEvent(nsIThreadInternal *thr)
|
|
{
|
|
if (mBlockNativeEvent)
|
|
return NS_OK;
|
|
|
|
if (mNativeEventPending.exchange(true))
|
|
return NS_OK;
|
|
|
|
// Returns on the main thread in NativeEventCallback above
|
|
ScheduleNativeEventCallback();
|
|
return NS_OK;
|
|
}
|
|
|
|
// Called from the main thread
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal *thr, bool mayWait)
|
|
{
|
|
if (mBlockNativeEvent) {
|
|
if (!mayWait)
|
|
return NS_OK;
|
|
// Hmm, we're in a nested native event loop and would like to get
|
|
// back to it ASAP, but it seems a gecko event has caused us to
|
|
// spin up a nested XPCOM event loop (eg. modal window), so we
|
|
// really must start processing native events here again.
|
|
mBlockNativeEvent = false;
|
|
if (NS_HasPendingEvents(thr))
|
|
OnDispatchedEvent(thr); // in case we blocked it earlier
|
|
}
|
|
|
|
PRIntervalTime start = PR_IntervalNow();
|
|
PRIntervalTime limit = THREAD_EVENT_STARVATION_LIMIT;
|
|
|
|
// Unblock outer nested wait loop (below).
|
|
if (mBlockedWait)
|
|
*mBlockedWait = false;
|
|
|
|
bool *oldBlockedWait = mBlockedWait;
|
|
mBlockedWait = &mayWait;
|
|
|
|
// When mayWait is true, we need to make sure that there is an event in the
|
|
// thread's event queue before we return. Otherwise, the thread will block
|
|
// on its event queue waiting for an event.
|
|
bool needEvent = mayWait;
|
|
// Reset prior to invoking DoProcessNextNativeEvent which might cause
|
|
// NativeEventCallback to process gecko events.
|
|
mProcessedGeckoEvents = false;
|
|
|
|
if (mFavorPerf <= 0 && start > mSwitchTime + mStarvationDelay) {
|
|
// Favor pending native events
|
|
PRIntervalTime now = start;
|
|
bool keepGoing;
|
|
do {
|
|
mLastNativeEventTime = now;
|
|
keepGoing = DoProcessNextNativeEvent(false);
|
|
} while (keepGoing && ((now = PR_IntervalNow()) - start) < limit);
|
|
} else {
|
|
// Avoid starving native events completely when in performance mode
|
|
if (start - mLastNativeEventTime > limit) {
|
|
mLastNativeEventTime = start;
|
|
DoProcessNextNativeEvent(false);
|
|
}
|
|
}
|
|
|
|
while (!NS_HasPendingEvents(thr) && !mProcessedGeckoEvents) {
|
|
// If we have been asked to exit from Run, then we should not wait for
|
|
// events to process. Note that an inner nested event loop causes
|
|
// 'mayWait' to become false too, through 'mBlockedWait'.
|
|
if (mExiting)
|
|
mayWait = false;
|
|
|
|
mLastNativeEventTime = PR_IntervalNow();
|
|
if (!DoProcessNextNativeEvent(mayWait) || !mayWait)
|
|
break;
|
|
}
|
|
|
|
mBlockedWait = oldBlockedWait;
|
|
|
|
// Make sure that the thread event queue does not block on its monitor, as
|
|
// it normally would do if it did not have any pending events. To avoid
|
|
// that, we simply insert a dummy event into its queue during shutdown.
|
|
if (needEvent && !mExiting && !NS_HasPendingEvents(thr)) {
|
|
DispatchDummyEvent(thr);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
bool
|
|
nsBaseAppShell::DispatchDummyEvent(nsIThread* aTarget)
|
|
{
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
if (!mDummyEvent)
|
|
mDummyEvent = new nsRunnable();
|
|
|
|
return NS_SUCCEEDED(aTarget->Dispatch(mDummyEvent, NS_DISPATCH_NORMAL));
|
|
}
|
|
|
|
void
|
|
nsBaseAppShell::IncrementEventloopNestingLevel()
|
|
{
|
|
++mEventloopNestingLevel;
|
|
#if defined(MOZ_CRASHREPORTER)
|
|
CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel);
|
|
#endif
|
|
}
|
|
|
|
void
|
|
nsBaseAppShell::DecrementEventloopNestingLevel()
|
|
{
|
|
--mEventloopNestingLevel;
|
|
#if defined(MOZ_CRASHREPORTER)
|
|
CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel);
|
|
#endif
|
|
}
|
|
|
|
// Called from the main thread
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::AfterProcessNextEvent(nsIThreadInternal *thr,
|
|
bool eventWasProcessed)
|
|
{
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsBaseAppShell::Observe(nsISupports *subject, const char *topic,
|
|
const char16_t *data)
|
|
{
|
|
NS_ASSERTION(!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID), "oops");
|
|
Exit();
|
|
return NS_OK;
|
|
}
|