Граф коммитов

27 Коммитов

Автор SHA1 Сообщение Дата
Masayuki Nakano 84cbc7e792 Bug 1529884 - part 6: Through subject principal at Document::ExecCommand() to constructor of EditorBase::AutoEditActionDataSetter r=smaug
`Document::ExecCommand()` knows subject principal.  This patch makes it tell
`EditorCommand::DoCommand()` and `EditorCommand::DoCommandParam()`.  Then,
makes they tell each editor public methods which may cause dispatching
`beforeinput` event once we implement it.  Finally, each editor public
method sets it to the constructor of `EditorBase::AutoEditActionDataSetter`.
This means that when editor tries to dispatch `beforeinput` event, editor
can check whether it's called by JS or not from everywhere.

Differential Revision: https://phabricator.services.mozilla.com/D29635

--HG--
extra : moz-landing-system : lando
2019-06-10 10:27:07 +00:00
Masayuki Nakano 94e3b7524c Bug 1529884 - part 1: Make Document use hashtable to map HTML command and internal command data r=smaug
Currently, `Document` converts HTML command (e.g., used by `execCommand()`) to
internal XUL command with array in the global space.  However, it requires scan
of the array for every command access.

This patch makes `Document` use hashtable to make the conversion faster.

New mapping info comes from:

- `mXULCommandName` is same as `internalCommandString`
- `mCommand` is mapped in CommandList.h from `mXULCommandName`
- `mGetEditorCommandFunc` is mapped from `mXULCommandName` in:
  - https://searchfox.org/mozilla-central/rev/d143f8ce30d1bcfee7a1227c27bf876a85f8cede/editor/libeditor/EditorController.cpp#31-32,34-38,40-41,43,45-51,54-57,67-112
  - https://searchfox.org/mozilla-central/rev/75294521381b331f821aad3d6b60636844080ee2/editor/libeditor/HTMLEditorController.cpp#26-28,31-39,48,51-52,55-58,60-63,65-73,76-80,83-88,90-91,93-94,97-100,102-104
- `mExecCommandParam` is converted from `useNewParam` and `convertToBoolean`:
  - If corresponding editor command class's `DoCommandParam()` just calls
    `DoCommand()`, `ExecCommandParam::Ignore`.
  - If `useNewParam` is `true` and `convertToBoolean` is `false`, given value
    should be ignored and may set constant instead.  In this case,
    `ExecCommandParam::Ignore`.
  - If `useNewParam` is `false` and `convertToBoolean` is `false`, given value
    should be treated as string.  In this case, `ExecCommandParam::String`.
  - If `useNewParam` is `false` and `convertToBoolean` is `true`, given value
    should be treated as bool.  In this case, if given command is not a legacy
    one, `ExecCommandParam::Boolean`.  Otherwise, i.e., if given command
    is a legacy one, `ExecCommandParam::InvertedBoolean`.
  - Otherwise, `ExecCommandParam::String`.

Differential Revision: https://phabricator.services.mozilla.com/D29628

--HG--
extra : moz-landing-system : lando
2019-06-10 10:23:59 +00:00
Masayuki Nakano 5ac5e497b5 Bug 1555227 - Make GetInternalCommand() return new commands when the command is "cmd_align" without params r=m_kato
`cmd_align` is always with `nsCommandParams` when it's executed.  However,
when somebody checks whether the command is enabled or not, or retrieves the
state, `GetInternalCommand()` is called without `nsCommandParams`.  Therefore,
even when `nsCommandParmas` is nullptr for `cmd_align`, `GetInternalCommand()`
shouldn't warn it.

Additionally, internal command supports to set `align` to empty string.
Therefore, `GetInternalCommand()` also needs to support it.

This patch adds `Command::FormatJustify` for the former case and
`Command::FormatJustifyNone` for the latter case.

Note that this does not affect to actual behavior since `AlignCommand`
does not refer the result of `GetInternalCommand()`.

Differential Revision: https://phabricator.services.mozilla.com/D33604

--HG--
extra : moz-landing-system : lando
2019-06-04 10:01:31 +00:00
Masayuki Nakano 29dd5c8e74 Bug 1549661 - part 6: Create `EditorCommand::DoCommandParam(Command aCommand, nsITransferable* aTransferableParam, TextEditor& aTextEditor)` r=m_kato
If `nsIControllerCommand::DoCommandParams()` is called without aParams or
`nsITransferable` pointer, this patch sets nullptr to `aTransferableParam` for
`DoCommandParam()`.  This allows each implementation to choose ignore or
return error.

Differential Revision: https://phabricator.services.mozilla.com/D30500

--HG--
extra : moz-landing-system : lando
2019-05-21 07:47:49 +00:00
Masayuki Nakano 276f23b02c Bug 1549661 - part 5: Make commands for `MultiStateCommandBase` take both `CString` and `String` r=m_kato
Only `MultiStateCommandBase::DoCommandParams()` allows `CString` param and
`String` param (the former is preferred).  This patch makes
`EditorCommand::DoCommandParams()` aware of this case.

Differential Revision: https://phabricator.services.mozilla.com/D30499

--HG--
extra : moz-landing-system : lando
2019-05-21 07:47:47 +00:00
Masayuki Nakano 3e190307e7 Bug 1549661 - part 4: Create `EditorCommand::DoCommandParam(Command aCommand, const nsAString& aStringParam, TextEditor& aTextEditor)` r=m_kato
If `nsIControllerCommand::DoCommandParams()` is called with `nullptr` for its
`aParams`, this patch sets `VoidString()` to `DoCommandParam()` for making
each implementation be able to consider whether the case is an error or
treat it as specific default value.

Differential Revision: https://phabricator.services.mozilla.com/D30498

--HG--
extra : moz-landing-system : lando
2019-05-21 07:45:55 +00:00
Masayuki Nakano 723ebc93fe Bug 1549661 - part 3: Create `EditorCommand::DoCommandParam(Command aCommand, const nsACString& aCStringParam, TextEditor& aTextEditor)` r=m_kato
If `nsIControllerCommand::DoCommandParams()` is called with `nullptr` for its
`aParams`, this patch sets `VoidCString()` to `DoCommandParam()` for making
each implementation be able to consider whether the case is an error or
treat it as specific default value.

Differential Revision: https://phabricator.services.mozilla.com/D30497

--HG--
extra : moz-landing-system : lando
2019-05-21 07:45:22 +00:00
Masayuki Nakano 2b5a319f77 Bug 1549661 - part 2: Create `EditorCommand::DoCommandParam(Command aCommand, const Maybe<bool>& aBoolParam, TextEditor& aTextEditor)` r=m_kato
We should use `Maybe` for `bool` because some command may treat the default
value when the parameter is omitted as `true` or `false.  Although, current
implementation does not do that.

Differential Revision: https://phabricator.services.mozilla.com/D30496

--HG--
extra : moz-landing-system : lando
2019-05-21 07:44:39 +00:00
Masayuki Nakano ef7e3647d8 Bug 1549661 - part 1: Create `EditorCommand::DoCommandParam(Command aCommand, TextEditor& aTextEditor)` and make it just call `DoCommand()` r=m_kato
Most `EditorCommand` classes don't require additional params for executing
a command.  All of them just calls their `DoCommand()` or returns same result.
So, we can create new virtual method,
`EditorCommand::DoCommandParam(Command aCommand, TextEditor& aTextEditor)`,
which just delegates to `DoCommand()`.

This patch adds some undeclared commands but which are handled by
`EditorCommand` subclasses, and changes `CommandInt` type from `int8_t` to
`uint8_t` since the count of `Command` items becomes over 128.

Differential Revision: https://phabricator.services.mozilla.com/D30495

--HG--
extra : moz-landing-system : lando
2019-05-21 07:44:11 +00:00
Masayuki Nakano 6da5cf38da Bug 1546839 - part 4: Make all editor command classes use Command instead of command name r=smaug
`strcmp` may be slow due to checking null character.  Therefore, internal
methods of them should use command as far as possible.  This patch makes
them take/use `Command` instead of `const char*`.

Differential Revision: https://phabricator.services.mozilla.com/D29174

--HG--
extra : moz-landing-system : lando
2019-04-30 04:24:49 +00:00
Masayuki Nakano 28714c6be2 Bug 1546578 - part 10: Mark methods of editor command classes as far as possible r=m_kato
Differential Revision: https://phabricator.services.mozilla.com/D28698

--HG--
extra : moz-landing-system : lando
2019-04-27 07:37:19 +00:00
Masayuki Nakano 143cfe7fde Bug 1546578 - part 9: Make GetCurrentState() of editor command classes take nsCommandParams& instead of nsICommandParams* r=m_kato
Now, all callers of `GetCurrentState()` have reference or pointer to
`nsCommandParam`.  So, taking the concrete class makes sense.

Differential Revision: https://phabricator.services.mozilla.com/D28697

--HG--
extra : moz-landing-system : lando
2019-04-27 07:36:30 +00:00
Masayuki Nakano 0592829433 Bug 1546578 - part 8: Make EditorCommand implement nsIControllerCommand::GetCommandStateParams() and call internal GetCommandStateParams() method which take TextEditor directly r=m_kato
This patch makes `EditorCommand` implement
`nsIControllerCommand::GetCommandStateParams()` and then, makes it call internal
`GetCommandStateParams()` method which takes `TextEditor` or `nsIEditingSession`
instead.

This makes each implementation really simpler.

Differential Revision: https://phabricator.services.mozilla.com/D28696

--HG--
extra : moz-landing-system : lando
2019-04-27 07:35:56 +00:00
Masayuki Nakano cae2231fcc Bug 1546578 - part 7: Make EditorCommand implement nsIControllerCommand::DoCommandParams() and call internal DoCommandParams() method which take TextEditor directly r=m_kato
This patch makes `EditorCommand` implement
`nsIControllerCommand::DoCommandParams()` and then, makes it call internal
`DoCommandParams()` method which takes `TextEditor` instead.

This makes each implementation really simpler.

Differential Revision: https://phabricator.services.mozilla.com/D28694

--HG--
extra : moz-landing-system : lando
2019-04-26 15:32:06 +00:00
Masayuki Nakano c4b1e41c47 Bug 1546578 - part 6: Make EditorCommand implement nsIControllerCommand::DoCommand() and call internal DoCommand() method which take TextEditor directly r=m_kato
This patch makes `EditorCommand` implement `nsIControllerCommand::DoCommand()`
and then, makes it call internal `DoCommand()` method which takes `TextEditor`
instead.

Note that `DoCommand()` of some command classes have not returned error when
given context is not editor.  However, it does not make sense to do that only
for some commands.  Therefore, this patch makes `EditorCommand::DoCommand()`
return error when given context is not an editor.

This makes each implementation really simpler.

Differential Revision: https://phabricator.services.mozilla.com/D28691

--HG--
extra : moz-landing-system : lando
2019-04-26 14:00:47 +00:00
Masayuki Nakano 2c962c8575 Bug 1546578 - part 5: Make EditorCommand implement nsIControllerCommand::IsCommandEnabled() and call internal IsCommandEnabled() method which return bool directly r=m_kato
This patch makes `EditorCommand` implement
`nsIControllerCommand::IsCommandEnabled()` and then, makes it call internal
`IsCommandEnabled()` method which returns `bool` directly and takes `TextEditor`
instead.

This makes each implementation really simpler.

Differential Revision: https://phabricator.services.mozilla.com/D28687

--HG--
extra : moz-landing-system : lando
2019-04-26 13:11:24 +00:00
Masayuki Nakano dc5aeff4d8 Bug 1546578 - part 4: Merge AbsolutePositioningCommand::IsCommandEnabled() with StateUpdatingCommandBase::IsCommandEnabled() r=m_kato
[`AbsolutePositioningCommand::IsCommandEnabled()`](https://searchfox.org/mozilla-central/rev/f46e2bf881d522a440b30cbf5cf8d76fc212eaf4/editor/libeditor/HTMLEditorCommands.cpp#1038-1056) overrides
[`StateUpdatingCommandBase::IsCommandEnabled()`](https://searchfox.org/mozilla-central/rev/f46e2bf881d522a440b30cbf5cf8d76fc212eaf4/editor/libeditor/HTMLEditorCommands.cpp#65-77).

There are only 2 differences between them:
1. `AbsolutePositioningCommand::IsCommandEnabled()` never returns true if given
   context is not an HTMLEditor instance.
2. `AbsolutePositioningCommand::IsCommandEnabled()` checks
   `HTMLEditor::IsAbsolutePositionEditorEnabled()` additionally.

So, we can get rid of it if we make
`StateUpdatingCommandBase::IsCommandEnabled()` check given command name is
"cmd_absPos" or not.  The mapping is here:
https://searchfox.org/mozilla-central/rev/ec489aa170b6486891cf3625717d6fa12bcd11c1/editor/libeditor/HTMLEditorController.cpp#102

Differential Revision: https://phabricator.services.mozilla.com/D28685

--HG--
extra : moz-landing-system : lando
2019-04-26 11:06:45 +00:00
Masayuki Nakano b8709cc5da Bug 1546578 - part 3: Get rid of HighlightColorStateCommand::IsCommandEnabled() because of it's exactly same as its superclass's definition r=m_kato
[`HighlightColorStateCommand::IsCommandEnabled()`](https://searchfox.org/mozilla-central/rev/f46e2bf881d522a440b30cbf5cf8d76fc212eaf4/editor/libeditor/HTMLEditorCommands.cpp#930-942) is exactly same as
[its superclass's implementation](https://searchfox.org/mozilla-central/rev/f46e2bf881d522a440b30cbf5cf8d76fc212eaf4/editor/libeditor/HTMLEditorCommands.cpp#586-599).

So, we can get rid of it.

Differential Revision: https://phabricator.services.mozilla.com/D28684

--HG--
extra : moz-landing-system : lando
2019-04-26 03:20:45 +00:00
Masayuki Nakano 39220c722f Bug 1546578 - part 2: Make all editor command classes derived from `EditorCommand` class r=m_kato
This patch makes all editor command classes derived from `EditorCommand` class.
So, this allows `nsHTMLEditor::ExecCommand()` to access them directly in the
future.

Differential Revision: https://phabricator.services.mozilla.com/D28683

--HG--
extra : moz-landing-system : lando
2019-04-26 03:20:02 +00:00
Masayuki Nakano 129a809380 Bug 1546578 - part 1: Get rid of HTMLEditorCommands.h r=m_kato
When declaring a common base class of all editor command classes in
EditorCommands.h, we need to declare some useful macro to declare its
subclasses.  However, such macro should be `#undef`ed in the header file.

Therefore, this patch moves all contents in HTMLEditorCommands.h to
EditorCommands.h and removes it from the tree.

Differential Revision: https://phabricator.services.mozilla.com/D28682

--HG--
extra : moz-landing-system : lando
2019-04-26 02:20:22 +00:00
Masayuki Nakano 6d9c401af5 Bug 1543966 - part 1: Make "editing commands" and "editor commands" singleton classes r=m_kato
Different from the comment in `EditorCommands.h`, editing commands and
editor commands are instantiated for each editable document or each
`HTMLInputElement` or `HTMLTextareaElement`.  Therefore, even though they
are stateless, we allocate too many instances of them.  We should make
them singleton classes to reduce the footprint and save runtime allocation
cost.

Differential Revision: https://phabricator.services.mozilla.com/D27406

--HG--
extra : moz-landing-system : lando
2019-04-15 07:49:46 +00:00
Boris Zbarsky 9a4ba73134 Bug 1534370 part 3. Mark InsertFromTransferable as MOZ_CAN_RUN_SCRIPT. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D23042

--HG--
extra : moz-landing-system : lando
2019-03-12 01:55:03 +00:00
Masayuki Nakano 6e11a1ab32 Bug 1505668 - part 3: Stop supporting "cmd_copyAndCollapseToEnd" since only CopyPasteAssistent refers it but nobody uses it r=m_kato,TYLin
"cmd_copyAndCollapseToEnd" is referred only by CopyPasteAssistent (even
including comm-central and BlueGriffon), but CopyPasteAssistent won't receive
"copy" command to send it.

So, it seems that we can get rid of a lot around CopyPasteAssistent but this
patch just changes the mapping in it ("copy" is mapped to "cmd_copy") and
removes command handlers of "cmd_copyAndCollapseToEnd" completely.

Differential Revision: https://phabricator.services.mozilla.com/D20612

--HG--
extra : moz-landing-system : lando
2019-02-22 01:39:14 +00:00
Masayuki Nakano 4c828577c0 Bug 1505668 - part 1: Stop supporting "cmd_clearUndo" since nobody uses it r=m_kato
"cmd_clearUndo" is never used now (even including comm-central and BlueGriffon).
So, we can stop supporting this command and we can get rid of the command
handler, ClearUndoCommand.

Differential Revision: https://phabricator.services.mozilla.com/D20610

--HG--
extra : moz-landing-system : lando
2019-02-21 11:14:11 +00:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Aryeh Gregor f6c34fc75b Bug 748308 - Support insertParagraph and insertLineBreak per spec/Blink/WebKit; r=masayuki
Previously we supported insertParagraph as a synonym for formatBlock
"p", which is both useless and incompatible with all other browsers.
Edge's behavior doesn't look useful and looks redundant with insertHTML
(although it matches the name nicely, probably because they invented
the command).  Blink/WebKit treat it the same as hitting Enter, which is
useful for cross-browser testing until we get synthesizeKey() in wpt.

At the same time, I added insertLineBreak, which Blink/WebKit support
with the same functionality as pressing Shift-Enter.

The new event.html failures are spurious -- we used to pass by mistake
because we didn't support insertlinebreak at all.  insertlinebreak.html
has only new passes, no new failures, although it's not clear on the
diff.

MozReview-Commit-ID: 16oPcxXwGcj
2016-08-23 14:13:17 +03:00
Masayuki Nakano 26f08a9046 Bug 1260651 part.34 Rename editor command classes and their file names r=mccr8
This patch renames editor command classes listed below:

* nsBaseEditorCommand -> mozilla::EditorCommandBase
* nsUndoCommand -> mozilla::UndoCommand
* nsRedoCommand -> mozilla::RedoCommand
* nsClearUndoCommand -> mozilla::ClearUndoCommand
* nsCutCommand -> mozilla::CutCommand
* nsCutOrDeleteCommand -> mozilla::CutOrDeleteCommand
* nsCopyCommand -> mozilla::CopyCommand
* nsCopyOrDeleteCommand -> mozilla::CopyOrDeleteCommand
* nsCopyAndCollapseToEndCommand -> mozilla::CopyAndCollapseToEndCommand
* nsPasteCommand -> mozilla::PasteCommand
* nsPasteTransferableCommand -> mozilla::PasteTransferableCommand
* nsSwitchTextDirectionCommand -> mozilla::SwitchTextDirectionCommand
* nsDeleteCommand -> mozilla::DeleteCommand
* nsSelectAllCommand -> mozilla::SelectAllCommand
* nsSelectionMoveCommands -> mozilla::SelectionMoveCommands
* nsInsertPlaintextCommand -> mozilla::InsertPlaintextCommand
* nsPasteQuotationCommand -> mozilla::PasteQuotationCommand

MozReview-Commit-ID: Lf6Lc39FpqM

--HG--
rename : editor/libeditor/nsEditorCommands.cpp => editor/libeditor/EditorCommands.cpp
rename : editor/libeditor/nsEditorCommands.h => editor/libeditor/EditorCommands.h
2016-06-24 11:45:22 +09:00