diff --git a/b2g/config/dolphin/sources.xml b/b2g/config/dolphin/sources.xml index 2f41131b69e..3149c3038f1 100644 --- a/b2g/config/dolphin/sources.xml +++ b/b2g/config/dolphin/sources.xml @@ -15,7 +15,7 @@ - + @@ -116,8 +116,10 @@ + + diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index d5c10342a5f..ad8196404bb 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 2cb835eddff..12d14140982 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + @@ -118,8 +118,10 @@ + + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 208c86e57e9..966506b445e 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + @@ -116,8 +116,10 @@ + + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index d5c10342a5f..ad8196404bb 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame-kk/sources.xml b/b2g/config/flame-kk/sources.xml index 6a26bfc7ddc..794a4ac6f70 100644 --- a/b2g/config/flame-kk/sources.xml +++ b/b2g/config/flame-kk/sources.xml @@ -15,7 +15,7 @@ - + @@ -116,8 +116,10 @@ + + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index b4d13b136b4..af9ca23883e 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 3ad52a6bc84..802938f5e75 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "415520315b048f40979e9bac344bec99e18df901", + "revision": "eb65c4355e0a16dc5cd203c5c007fd7e3bf0e4b2", "repo_path": "integration/gaia-central" } diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 9867c1f46ee..14d96f08af3 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 0afeb9b5513..0d8c274fec0 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 89177860d17..28dbbedf4eb 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + @@ -118,8 +118,10 @@ + + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 7b20ab3841a..de4c0a9bb51 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/dom/base/nsGlobalWindowCommands.cpp b/dom/base/nsGlobalWindowCommands.cpp index e8a5c7749ce..89ac9358677 100644 --- a/dom/base/nsGlobalWindowCommands.cpp +++ b/dom/base/nsGlobalWindowCommands.cpp @@ -29,6 +29,7 @@ #include "nsIClipboard.h" #include "mozilla/Attributes.h" #include "mozilla/BasicEvents.h" +#include "mozilla/dom/Selection.h" #include "nsIClipboardDragDropHooks.h" #include "nsIClipboardDragDropHookList.h" @@ -482,7 +483,8 @@ nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aCon NS_ENSURE_ARG_POINTER(outCmdEnabled); *outCmdEnabled = false; - if (strcmp(aCommandName, "cmd_copy")) + if (strcmp(aCommandName, "cmd_copy") && + strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) return NS_OK; nsCOMPtr window = do_QueryInterface(aContext); @@ -496,7 +498,8 @@ nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aCon nsresult nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext) { - if (strcmp(aCommandName, "cmd_copy")) + if (strcmp(aCommandName, "cmd_copy") && + strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) return NS_OK; nsCOMPtr window = do_QueryInterface(aContext); @@ -509,6 +512,14 @@ nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext) NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, presShell, nullptr); + + if (!strcmp(aCommandName, "cmd_copyAndCollapseToEnd")) { + dom::Selection *sel = + presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL); + NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE); + sel->CollapseToEnd(); + } + return NS_OK; } @@ -1045,6 +1056,7 @@ nsWindowCommandRegistration::RegisterWindowCommands( NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_cut"); NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_copy"); + NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_copyAndCollapseToEnd"); NS_REGISTER_ONE_COMMAND(nsClipboardCommand, "cmd_paste"); NS_REGISTER_ONE_COMMAND(nsClipboardCopyLinkCommand, "cmd_copyLink"); NS_REGISTER_FIRST_COMMAND(nsClipboardImageCommands, sCopyImageLocationString); diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index e6bbf89733e..ed20ccd695a 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -59,7 +59,7 @@ const OBSERVED_EVENTS = [ const COMMAND_MAP = { 'cut': 'cmd_cut', - 'copy': 'cmd_copy', + 'copy': 'cmd_copyAndCollapseToEnd', 'paste': 'cmd_paste', 'selectall': 'cmd_selectAll' }; diff --git a/dom/browser-element/mochitest/browserElement_CopyPaste.js b/dom/browser-element/mochitest/browserElement_CopyPaste.js index 890a696d1d2..607b775d182 100644 --- a/dom/browser-element/mochitest/browserElement_CopyPaste.js +++ b/dom/browser-element/mochitest/browserElement_CopyPaste.js @@ -190,6 +190,7 @@ function testPaste1(e) { // Then paste it to child side. copyToClipboard(pasteData); + doCommand('selectall'); doCommand("paste"); SimpleTest.executeSoon(function() { testPaste2(e); }); } diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index 738e88e8c30..41ae4e8600b 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -1936,7 +1936,9 @@ RadioInterface.prototype = { case "networkinfochanged": gMobileConnectionService.notifyNetworkInfoChanged(this.clientId, message); - connHandler.updateRILNetworkInterface(); + if (message[RIL.NETWORK_INFO_DATA_REGISTRATION_STATE]) { + connHandler.updateRILNetworkInterface(); + } break; case "networkselectionmodechange": gMobileConnectionService.notifyNetworkSelectModeChanged(this.clientId, diff --git a/editor/libeditor/nsEditorCommands.cpp b/editor/libeditor/nsEditorCommands.cpp index e03065a268b..5cff3ada31c 100644 --- a/editor/libeditor/nsEditorCommands.cpp +++ b/editor/libeditor/nsEditorCommands.cpp @@ -3,7 +3,6 @@ * 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 "mozFlushType.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" @@ -28,27 +27,21 @@ class nsISupports; - -#define STATE_ENABLED "state_enabled" +#define STATE_ENABLED "state_enabled" #define STATE_DATA "state_data" - -nsBaseEditorCommand::nsBaseEditorCommand() -{ -} +nsBaseEditorCommand::nsBaseEditorCommand() {} NS_IMPL_ISUPPORTS(nsBaseEditorCommand, nsIControllerCommand) - NS_IMETHODIMP -nsUndoCommand::IsCommandEnabled(const char * aCommandName, - nsISupports *aCommandRefCon, +nsUndoCommand::IsCommandEnabled(const char *aCommandName, + nsISupports *aCommandRefCon, bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { bool isEnabled, isEditable = false; nsresult rv = editor->GetIsSelectionEditable(&isEditable); NS_ENSURE_SUCCESS(rv, rv); @@ -60,18 +53,17 @@ nsUndoCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsUndoCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) return editor->Undo(1); - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsUndoCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -79,25 +71,24 @@ nsUndoCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsUndoCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP -nsRedoCommand::IsCommandEnabled(const char * aCommandName, +nsRedoCommand::IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { bool isEnabled, isEditable = false; nsresult rv = editor->GetIsSelectionEditable(&isEditable); NS_ENSURE_SUCCESS(rv, rv); @@ -109,18 +100,17 @@ nsRedoCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsRedoCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) return editor->Redo(1); - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsRedoCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -128,20 +118,20 @@ nsRedoCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsRedoCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP -nsClearUndoCommand::IsCommandEnabled(const char * aCommandName, +nsClearUndoCommand::IsCommandEnabled(const char *aCommandName, nsISupports *refCon, bool *outCmdEnabled) -{ +{ NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(refCon); if (editor) @@ -150,51 +140,48 @@ nsClearUndoCommand::IsCommandEnabled(const char * aCommandName, *outCmdEnabled = false; return NS_OK; } - NS_IMETHODIMP nsClearUndoCommand::DoCommand(const char *aCommandName, nsISupports *refCon) -{ +{ nsCOMPtr editor = do_QueryInterface(refCon); NS_ENSURE_TRUE(editor, NS_ERROR_NOT_IMPLEMENTED); - - editor->EnableUndo(false); // Turning off undo clears undo/redo stacks. - editor->EnableUndo(true); // This re-enables undo/redo. - + + editor->EnableUndo(false); // Turning off undo clears undo/redo stacks. + editor->EnableUndo(true); // This re-enables undo/redo. + return NS_OK; } - -NS_IMETHODIMP + +NS_IMETHODIMP nsClearUndoCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *refCon) { return DoCommand(aCommandName, refCon); } - -NS_IMETHODIMP + +NS_IMETHODIMP nsClearUndoCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *refCon) -{ +{ NS_ENSURE_ARG_POINTER(aParams); - + bool enabled; nsresult rv = IsCommandEnabled(aCommandName, refCon, &enabled); NS_ENSURE_SUCCESS(rv, rv); - + return aParams->SetBooleanValue(STATE_ENABLED, enabled); } NS_IMETHODIMP -nsCutCommand::IsCommandEnabled(const char * aCommandName, - nsISupports *aCommandRefCon, - bool *outCmdEnabled) +nsCutCommand::IsCommandEnabled(const char *aCommandName, + nsISupports *aCommandRefCon, bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { bool isEditable = false; nsresult rv = editor->GetIsSelectionEditable(&isEditable); NS_ENSURE_SUCCESS(rv, rv); @@ -206,18 +193,17 @@ nsCutCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsCutCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) return editor->Cut(); - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsCutCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -225,19 +211,18 @@ nsCutCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsCutCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } - NS_IMETHODIMP -nsCutOrDeleteCommand::IsCommandEnabled(const char * aCommandName, +nsCutOrDeleteCommand::IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *outCmdEnabled) { @@ -250,14 +235,12 @@ nsCutOrDeleteCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsCutOrDeleteCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { nsCOMPtr selection; nsresult rv = editor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection && selection->Collapsed()) { @@ -265,11 +248,11 @@ nsCutOrDeleteCommand::DoCommand(const char *aCommandName, } return editor->Cut(); } - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsCutOrDeleteCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -277,18 +260,18 @@ nsCutOrDeleteCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsCutOrDeleteCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP -nsCopyCommand::IsCommandEnabled(const char * aCommandName, +nsCopyCommand::IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *outCmdEnabled) { @@ -301,18 +284,17 @@ nsCopyCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsCopyCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) return editor->Copy(); - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsCopyCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -320,18 +302,18 @@ nsCopyCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsCopyCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP -nsCopyOrDeleteCommand::IsCommandEnabled(const char * aCommandName, +nsCopyOrDeleteCommand::IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *outCmdEnabled) { @@ -344,14 +326,12 @@ nsCopyOrDeleteCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsCopyOrDeleteCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { nsCOMPtr selection; nsresult rv = editor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection && selection->Collapsed()) { @@ -359,11 +339,11 @@ nsCopyOrDeleteCommand::DoCommand(const char *aCommandName, } return editor->Copy(); } - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsCopyOrDeleteCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -371,14 +351,68 @@ nsCopyOrDeleteCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsCopyOrDeleteCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); +} + +NS_IMETHODIMP +nsCopyAndCollapseToEndCommand::IsCommandEnabled(const char *aCommandName, + nsISupports *aCommandRefCon, + bool *outCmdEnabled) +{ + NS_ENSURE_ARG_POINTER(outCmdEnabled); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); + if (editor) + return editor->CanCopy(outCmdEnabled); + + *outCmdEnabled = false; + return NS_OK; +} + +NS_IMETHODIMP +nsCopyAndCollapseToEndCommand::DoCommand(const char *aCommandName, + nsISupports *aCommandRefCon) +{ + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); + if (editor) { + nsresult rv = editor->Copy(); + if (NS_FAILED(rv)) { + return rv; + } + + nsCOMPtr selection; + rv = editor->GetSelection(getter_AddRefs(selection)); + if (NS_SUCCEEDED(rv) && selection) { + selection->CollapseToEnd(); + } + return rv; + } + + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +nsCopyAndCollapseToEndCommand::DoCommandParams(const char *aCommandName, + nsICommandParams *aParams, + nsISupports *aCommandRefCon) +{ + return DoCommand(aCommandName, aCommandRefCon); +} + +NS_IMETHODIMP +nsCopyAndCollapseToEndCommand::GetCommandStateParams( + const char *aCommandName, nsICommandParams *aParams, + nsISupports *aCommandRefCon) +{ + bool canUndo; + IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP @@ -388,8 +422,7 @@ nsPasteCommand::IsCommandEnabled(const char *aCommandName, { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { bool isEditable = false; nsresult rv = editor->GetIsSelectionEditable(&isEditable); NS_ENSURE_SUCCESS(rv, rv); @@ -401,17 +434,16 @@ nsPasteCommand::IsCommandEnabled(const char *aCommandName, return NS_OK; } - NS_IMETHODIMP nsPasteCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE); - + return editor->Paste(nsIClipboard::kGlobalClipboard); } -NS_IMETHODIMP +NS_IMETHODIMP nsPasteCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -419,14 +451,14 @@ nsPasteCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsPasteCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP @@ -436,8 +468,7 @@ nsPasteTransferableCommand::IsCommandEnabled(const char *aCommandName, { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); - if (editor) - { + if (editor) { bool isEditable = false; nsresult rv = editor->GetIsSelectionEditable(&isEditable); NS_ENSURE_SUCCESS(rv, rv); @@ -450,19 +481,20 @@ nsPasteTransferableCommand::IsCommandEnabled(const char *aCommandName, } NS_IMETHODIMP -nsPasteTransferableCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) +nsPasteTransferableCommand::DoCommand(const char *aCommandName, + nsISupports *aCommandRefCon) { return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsPasteTransferableCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE); - + nsCOMPtr supports; aParams->GetISupportsValue("transferable", getter_AddRefs(supports)); NS_ENSURE_TRUE(supports, NS_ERROR_FAILURE); @@ -473,7 +505,7 @@ nsPasteTransferableCommand::DoCommandParams(const char *aCommandName, return editor->PasteTransferable(trans); } -NS_IMETHODIMP +NS_IMETHODIMP nsPasteTransferableCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -499,8 +531,8 @@ nsPasteTransferableCommand::GetCommandStateParams(const char *aCommandName, NS_IMETHODIMP nsSwitchTextDirectionCommand::IsCommandEnabled(const char *aCommandName, - nsISupports *aCommandRefCon, - bool *outCmdEnabled) + nsISupports *aCommandRefCon, + bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); @@ -512,7 +544,8 @@ nsSwitchTextDirectionCommand::IsCommandEnabled(const char *aCommandName, } NS_IMETHODIMP -nsSwitchTextDirectionCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) +nsSwitchTextDirectionCommand::DoCommand(const char *aCommandName, + nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE); @@ -520,18 +553,18 @@ nsSwitchTextDirectionCommand::DoCommand(const char *aCommandName, nsISupports *a return editor->SwitchTextDirection(); } -NS_IMETHODIMP +NS_IMETHODIMP nsSwitchTextDirectionCommand::DoCommandParams(const char *aCommandName, - nsICommandParams *aParams, - nsISupports *aCommandRefCon) + nsICommandParams *aParams, + nsISupports *aCommandRefCon) { return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsSwitchTextDirectionCommand::GetCommandStateParams(const char *aCommandName, - nsICommandParams *aParams, - nsISupports *aCommandRefCon) + nsICommandParams *aParams, + nsISupports *aCommandRefCon) { bool canSwitchTextDirection = true; IsCommandEnabled(aCommandName, aCommandRefCon, &canSwitchTextDirection); @@ -539,9 +572,9 @@ nsSwitchTextDirectionCommand::GetCommandStateParams(const char *aCommandName, } NS_IMETHODIMP -nsDeleteCommand::IsCommandEnabled(const char* aCommandName, - nsISupports* aCommandRefCon, - bool* outCmdEnabled) +nsDeleteCommand::IsCommandEnabled(const char *aCommandName, + nsISupports *aCommandRefCon, + bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(aCommandRefCon); @@ -563,10 +596,9 @@ nsDeleteCommand::IsCommandEnabled(const char* aCommandName, return NS_OK; } - NS_IMETHODIMP -nsDeleteCommand::DoCommand(const char* aCommandName, - nsISupports* aCommandRefCon) +nsDeleteCommand::DoCommand(const char *aCommandName, + nsISupports *aCommandRefCon) { nsCOMPtr editor = do_QueryInterface(aCommandRefCon); NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE); @@ -597,7 +629,7 @@ nsDeleteCommand::DoCommand(const char* aCommandName, return editor->DeleteSelection(deleteDir, nsIEditor::eStrip); } -NS_IMETHODIMP +NS_IMETHODIMP nsDeleteCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -605,18 +637,18 @@ nsDeleteCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsDeleteCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } NS_IMETHODIMP -nsSelectAllCommand::IsCommandEnabled(const char * aCommandName, +nsSelectAllCommand::IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *outCmdEnabled) { @@ -639,7 +671,6 @@ nsSelectAllCommand::IsCommandEnabled(const char * aCommandName, return rv; } - NS_IMETHODIMP nsSelectAllCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon) @@ -647,11 +678,11 @@ nsSelectAllCommand::DoCommand(const char *aCommandName, nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) return editor->SelectAll(); - + return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsSelectAllCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -659,19 +690,18 @@ nsSelectAllCommand::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsSelectAllCommand::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } - NS_IMETHODIMP -nsSelectionMoveCommands::IsCommandEnabled(const char * aCommandName, +nsSelectionMoveCommands::IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, bool *outCmdEnabled) { @@ -765,13 +795,13 @@ nsSelectionMoveCommands::DoCommand(const char *aCommandName, } nsCOMPtr selCont; - nsresult rv = editor->GetSelectionController(getter_AddRefs(selCont)); + nsresult rv = editor->GetSelectionController(getter_AddRefs(selCont)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(selCont, NS_ERROR_FAILURE); // scroll commands for (size_t i = 0; i < mozilla::ArrayLength(scrollCommands); i++) { - const ScrollCommand& cmd = scrollCommands[i]; + const ScrollCommand &cmd = scrollCommands[i]; if (!nsCRT::strcmp(aCommandName, cmd.reverseScroll)) { return (selCont->*(cmd.scroll))(false); } else if (!nsCRT::strcmp(aCommandName, cmd.forwardScroll)) { @@ -781,7 +811,7 @@ nsSelectionMoveCommands::DoCommand(const char *aCommandName, // caret movement/selection commands for (size_t i = 0; i < mozilla::ArrayLength(moveCommands); i++) { - const MoveCommand& cmd = moveCommands[i]; + const MoveCommand &cmd = moveCommands[i]; if (!nsCRT::strcmp(aCommandName, cmd.reverseMove)) { return (selCont->*(cmd.move))(false, false); } else if (!nsCRT::strcmp(aCommandName, cmd.forwardMove)) { @@ -795,7 +825,7 @@ nsSelectionMoveCommands::DoCommand(const char *aCommandName, // physical-direction movement/selection for (size_t i = 0; i < mozilla::ArrayLength(physicalCommands); i++) { - const PhysicalCommand& cmd = physicalCommands[i]; + const PhysicalCommand &cmd = physicalCommands[i]; if (!nsCRT::strcmp(aCommandName, cmd.move)) { return selCont->PhysicalMove(cmd.direction, cmd.amount, false); } else if (!nsCRT::strcmp(aCommandName, cmd.select)) { @@ -806,7 +836,7 @@ nsSelectionMoveCommands::DoCommand(const char *aCommandName, return NS_ERROR_FAILURE; } -NS_IMETHODIMP +NS_IMETHODIMP nsSelectionMoveCommands::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) @@ -814,20 +844,19 @@ nsSelectionMoveCommands::DoCommandParams(const char *aCommandName, return DoCommand(aCommandName, aCommandRefCon); } -NS_IMETHODIMP +NS_IMETHODIMP nsSelectionMoveCommands::GetCommandStateParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *aCommandRefCon) { bool canUndo; IsCommandEnabled(aCommandName, aCommandRefCon, &canUndo); - return aParams->SetBooleanValue(STATE_ENABLED,canUndo); + return aParams->SetBooleanValue(STATE_ENABLED, canUndo); } - NS_IMETHODIMP -nsInsertPlaintextCommand::IsCommandEnabled(const char * aCommandName, - nsISupports *refCon, +nsInsertPlaintextCommand::IsCommandEnabled(const char *aCommandName, + nsISupports *refCon, bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); @@ -839,7 +868,6 @@ nsInsertPlaintextCommand::IsCommandEnabled(const char * aCommandName, return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHODIMP nsInsertPlaintextCommand::DoCommand(const char *aCommandName, nsISupports *refCon) @@ -880,16 +908,15 @@ nsInsertPlaintextCommand::GetCommandStateParams(const char *aCommandName, return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled); } - NS_IMETHODIMP -nsPasteQuotationCommand::IsCommandEnabled(const char * aCommandName, +nsPasteQuotationCommand::IsCommandEnabled(const char *aCommandName, nsISupports *refCon, bool *outCmdEnabled) { NS_ENSURE_ARG_POINTER(outCmdEnabled); nsCOMPtr editor = do_QueryInterface(refCon); - nsCOMPtr mailEditor = do_QueryInterface(refCon); + nsCOMPtr mailEditor = do_QueryInterface(refCon); if (editor && mailEditor) { uint32_t flags; editor->GetFlags(&flags); @@ -901,12 +928,11 @@ nsPasteQuotationCommand::IsCommandEnabled(const char * aCommandName, return NS_OK; } - NS_IMETHODIMP nsPasteQuotationCommand::DoCommand(const char *aCommandName, nsISupports *refCon) { - nsCOMPtr mailEditor = do_QueryInterface(refCon); + nsCOMPtr mailEditor = do_QueryInterface(refCon); if (mailEditor) return mailEditor->PasteAsQuotation(nsIClipboard::kGlobalClipboard); @@ -918,7 +944,7 @@ nsPasteQuotationCommand::DoCommandParams(const char *aCommandName, nsICommandParams *aParams, nsISupports *refCon) { - nsCOMPtr mailEditor = do_QueryInterface(refCon); + nsCOMPtr mailEditor = do_QueryInterface(refCon); if (mailEditor) return mailEditor->PasteAsQuotation(nsIClipboard::kGlobalClipboard); @@ -931,13 +957,11 @@ nsPasteQuotationCommand::GetCommandStateParams(const char *aCommandName, nsISupports *refCon) { nsCOMPtr editor = do_QueryInterface(refCon); - if (editor) - { + if (editor) { bool enabled = false; editor->CanPaste(nsIClipboard::kGlobalClipboard, &enabled); aParams->SetBooleanValue(STATE_ENABLED, enabled); } - + return NS_OK; } - diff --git a/editor/libeditor/nsEditorCommands.h b/editor/libeditor/nsEditorCommands.h index fdb6f47c5e0..e4da6a69ae4 100644 --- a/editor/libeditor/nsEditorCommands.h +++ b/editor/libeditor/nsEditorCommands.h @@ -52,6 +52,7 @@ NS_DECL_EDITOR_COMMAND(nsCutCommand) NS_DECL_EDITOR_COMMAND(nsCutOrDeleteCommand) NS_DECL_EDITOR_COMMAND(nsCopyCommand) NS_DECL_EDITOR_COMMAND(nsCopyOrDeleteCommand) +NS_DECL_EDITOR_COMMAND(nsCopyAndCollapseToEndCommand) NS_DECL_EDITOR_COMMAND(nsPasteCommand) NS_DECL_EDITOR_COMMAND(nsPasteTransferableCommand) NS_DECL_EDITOR_COMMAND(nsSwitchTextDirectionCommand) diff --git a/editor/libeditor/nsEditorController.cpp b/editor/libeditor/nsEditorController.cpp index 35bed781c67..f90c928470c 100644 --- a/editor/libeditor/nsEditorController.cpp +++ b/editor/libeditor/nsEditorController.cpp @@ -53,6 +53,8 @@ nsresult nsEditorController::RegisterEditingCommands(nsIControllerCommandTable * NS_REGISTER_ONE_COMMAND(nsCutOrDeleteCommand, "cmd_cutOrDelete"); NS_REGISTER_ONE_COMMAND(nsCopyCommand, "cmd_copy"); NS_REGISTER_ONE_COMMAND(nsCopyOrDeleteCommand, "cmd_copyOrDelete"); + NS_REGISTER_ONE_COMMAND(nsCopyAndCollapseToEndCommand, + "cmd_copyAndCollapseToEnd"); NS_REGISTER_ONE_COMMAND(nsSelectAllCommand, "cmd_selectAll"); NS_REGISTER_ONE_COMMAND(nsPasteCommand, "cmd_paste"); diff --git a/editor/libeditor/tests/chrome.ini b/editor/libeditor/tests/chrome.ini index 9d10b23f2f1..7c5c2fc3ce0 100644 --- a/editor/libeditor/tests/chrome.ini +++ b/editor/libeditor/tests/chrome.ini @@ -20,6 +20,7 @@ skip-if = buildapp == 'mulet' [test_bug830600.html] [test_bug1053048.html] [test_bug1102906.html] +[test_bug1101392.html] [test_composition_event_created_in_chrome.html] [test_contenteditable_text_input_handling.html] [test_dragdrop.html] diff --git a/editor/libeditor/tests/test_bug1101392.html b/editor/libeditor/tests/test_bug1101392.html new file mode 100644 index 00000000000..c38b1558c94 --- /dev/null +++ b/editor/libeditor/tests/test_bug1101392.html @@ -0,0 +1,77 @@ + + + + + + Test for Bug 1101392 + + + + + +Mozilla Bug 1101392 +
abc
+ + + +
+
+ + diff --git a/layout/base/TouchCaret.cpp b/layout/base/TouchCaret.cpp index 51aceb4bd94..ce18f1e3746 100644 --- a/layout/base/TouchCaret.cpp +++ b/layout/base/TouchCaret.cpp @@ -354,7 +354,10 @@ TouchCaret::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* aSel, // Update touch caret position and visibility. // Hide touch caret while key event causes selection change. - if (aReason & nsISelectionListener::KEYPRESS_REASON) { + // Also hide touch caret when gecko or javascript collapse the selection. + if (aReason & nsISelectionListener::KEYPRESS_REASON || + aReason & nsISelectionListener::COLLAPSETOSTART_REASON || + aReason & nsISelectionListener::COLLAPSETOEND_REASON) { TOUCHCARET_LOG("KEYPRESS_REASON"); SetVisibility(false); } else {