mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-02-21 11:29:05 +00:00
#388: M1354564
This commit is contained in:
parent
b9509fba4d
commit
d375d57d33
@ -1008,6 +1008,8 @@
|
||||
var newBrowser = this.getBrowserAtIndex(this.tabContainer.selectedIndex);
|
||||
if (this.mCurrentBrowser == newBrowser && !aForceUpdate)
|
||||
return;
|
||||
if (!aForceUpdate)
|
||||
document.commandDispatcher.lock();
|
||||
|
||||
/*
|
||||
if (!aForceUpdate) {
|
||||
@ -1204,6 +1206,8 @@
|
||||
this.tabContainer._setPositionalAttributes();
|
||||
|
||||
//if (!gMultiProcessBrowser) {
|
||||
document.commandDispatcher.unlock();
|
||||
|
||||
let event = new CustomEvent("TabSwitchDone", {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
@ -3203,6 +3207,8 @@ let remote = false;
|
||||
fromBrowser.setAttribute("type", "content-targetable");
|
||||
}
|
||||
|
||||
document.commandDispatcher.unlock();
|
||||
|
||||
let event = new CustomEvent("TabSwitchDone", {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
|
@ -31,4 +31,9 @@ interface nsIDOMXULCommandDispatcher : nsISupports
|
||||
void rewindFocus();
|
||||
void advanceFocusIntoSubtree(in nsIDOMElement elt);
|
||||
attribute boolean suppressFocusScroll;
|
||||
|
||||
// When locked, command updating is batched until unlocked. Always ensure that
|
||||
// lock and unlock is called in a pair.
|
||||
void lock();
|
||||
void unlock();
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ static LazyLogModule gCommandLog("nsXULCommandDispatcher");
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsXULCommandDispatcher::nsXULCommandDispatcher(nsIDocument* aDocument)
|
||||
: mDocument(aDocument), mUpdaters(nullptr)
|
||||
: mDocument(aDocument), mUpdaters(nullptr), mLocked(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -351,6 +351,14 @@ nsXULCommandDispatcher::RemoveCommandUpdater(nsIDOMElement* aElement)
|
||||
NS_IMETHODIMP
|
||||
nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||
{
|
||||
if (mLocked) {
|
||||
if (!mPendingUpdates.Contains(aEventName)) {
|
||||
mPendingUpdates.AppendElement(aEventName);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString id;
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
GetFocusedElement(getter_AddRefs(element));
|
||||
@ -458,3 +466,30 @@ nsXULCommandDispatcher::SetSuppressFocusScroll(bool aSuppressFocusScroll)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULCommandDispatcher::Lock()
|
||||
{
|
||||
// Since locking is used only as a performance optimization, we don't worry
|
||||
// about nested lock calls. If that does happen, it just means we will unlock
|
||||
// and process updates earlier.
|
||||
mLocked = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULCommandDispatcher::Unlock()
|
||||
{
|
||||
if (mLocked) {
|
||||
mLocked = false;
|
||||
|
||||
// Handle any pending updates one at a time. In the unlikely case where a
|
||||
// lock is added during the update, break out.
|
||||
while (!mLocked && mPendingUpdates.Length() > 0) {
|
||||
nsString name = mPendingUpdates.ElementAt(0);
|
||||
mPendingUpdates.RemoveElementAt(0);
|
||||
UpdateCommands(name);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -68,6 +68,9 @@ protected:
|
||||
|
||||
bool Matches(const nsString& aList,
|
||||
const nsAString& aElement);
|
||||
|
||||
bool mLocked;
|
||||
nsTArray<nsString> mPendingUpdates;
|
||||
};
|
||||
|
||||
#endif // nsXULCommandDispatcher_h__
|
||||
|
Loading…
x
Reference in New Issue
Block a user