diff --git a/editor/libeditor/base/nsEditorCommands.cpp b/editor/libeditor/base/nsEditorCommands.cpp index e3f2039818f..79e99ec88fa 100644 --- a/editor/libeditor/base/nsEditorCommands.cpp +++ b/editor/libeditor/base/nsEditorCommands.cpp @@ -47,6 +47,7 @@ #include "nsIClipboard.h" #include "nsEditorCommands.h" +#include "nsIDocument.h" #define STATE_ENABLED "state_enabled" @@ -669,7 +670,6 @@ nsSelectionMoveCommands::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsSelectionMoveCommands::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) @@ -677,6 +677,15 @@ nsSelectionMoveCommands::DoCommand(const char *aCommandName, nsCOMPtr editor = do_QueryInterface(aCommandRefCon); NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE); + nsCOMPtr domDoc; + editor->GetDocument(getter_AddRefs(domDoc)); + nsCOMPtr doc = do_QueryInterface(domDoc); + if (doc) { + // Most of the commands below (possibly all of them) need layout to + // be up to date. + doc->FlushPendingNotifications(Flush_Layout); + } + nsCOMPtr selCont; nsresult rv = editor->GetSelectionController(getter_AddRefs(selCont)); NS_ENSURE_SUCCESS(rv, rv);