Bug 1194121 - Skip UpdateCommands() from initializing collapse to avoid sync IPC during app startup. r=jst

This commit is contained in:
Ting-Yu Chou
2015-08-28 15:18:56 +08:00
parent 19c5dc9db7
commit 405693f91a

View File

@@ -166,8 +166,7 @@ public:
nsDocViewerSelectionListener() nsDocViewerSelectionListener()
: mDocViewer(nullptr) : mDocViewer(nullptr)
, mGotSelectionState(false) , mSelectionWasCollapsed(true)
, mSelectionWasCollapsed(false)
{ {
} }
@@ -177,8 +176,7 @@ protected:
virtual ~nsDocViewerSelectionListener() {} virtual ~nsDocViewerSelectionListener() {}
nsDocumentViewer* mDocViewer; nsDocumentViewer* mDocViewer;
bool mGotSelectionState;
bool mSelectionWasCollapsed; bool mSelectionWasCollapsed;
}; };
@@ -3572,13 +3570,13 @@ NS_IMETHODIMP nsDocViewerSelectionListener::NotifySelectionChanged(nsIDOMDocumen
bool selectionCollapsed; bool selectionCollapsed;
selection->GetIsCollapsed(&selectionCollapsed); selection->GetIsCollapsed(&selectionCollapsed);
// we only call UpdateCommands when the selection changes from collapsed // We only call UpdateCommands when the selection changes from collapsed to
// to non-collapsed or vice versa. We might need another update string // non-collapsed or vice versa, however we skip the initializing collapse. We
// for simple selection changes, but that would be expenseive. // might need another update string for simple selection changes, but that
if (!mGotSelectionState || mSelectionWasCollapsed != selectionCollapsed) // would be expenseive.
if (mSelectionWasCollapsed != selectionCollapsed)
{ {
domWindow->UpdateCommands(NS_LITERAL_STRING("select"), selection, aReason); domWindow->UpdateCommands(NS_LITERAL_STRING("select"), selection, aReason);
mGotSelectionState = true;
mSelectionWasCollapsed = selectionCollapsed; mSelectionWasCollapsed = selectionCollapsed;
} }