Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Issue 2574793002: [Editing] Store |CommandSource| in |CompositeEditCommand| (Closed)

Created:
4 years ago by chongz
Modified:
4 years ago
Reviewers:
Xiaocheng
CC:
blink-reviews, blink-reviews-dom_chromium.org, blink-reviews-style_chromium.org, chaopeng, chromium-reviews, dcheng, dglazkov+blink, dtapuska, eae+blinkwatch, groby+blinkspell_chromium.org, kinuko+watch, rwlbuis, sof, timvolodine, yosin_UTC9, Yuta Kitamura
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Editing] Store |CommandSource| in |CompositeEditCommand| This CL was split into 3 sub-patches: 1. https://crrev.com/2578753002 2. https://crrev.com/2576903002 3. https://crrev.com/2579253002 This CL added a new attribute |CommandSource m_source| to |CompositeEditCommand| and it should be set for all of it's sub-classes. |m_source| could wither be * |CommandSource::MenuOrKeyBinding|, e.g. User actions, or * |CommandSource::Dom|, e.g. 'document.execCommand()'. This CL shouldn't cause any behavior change, and is a pre-patch for https://crrev.com/2558643003/. BUG=673789

Patch Set 1 #

Total comments: 12
Unified diffs Side-by-side diffs Delta from patch set Stats (+657 lines, -486 lines) Patch
M third_party/WebKit/Source/core/dom/Document.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/Editor.h View 9 chunks +37 lines, -24 lines 0 comments Download
M third_party/WebKit/Source/core/editing/Editor.cpp View 33 chunks +77 lines, -54 lines 6 comments Download
M third_party/WebKit/Source/core/editing/InputMethodController.cpp View 6 chunks +10 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.h View 1 chunk +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommand.cpp View 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommandTest.cpp View 2 chunks +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.h View 2 chunks +14 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ApplyStyleCommand.cpp View 4 chunks +10 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.h View 1 chunk +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/BreakBlockquoteCommand.cpp View 1 chunk +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h View 3 chunks +6 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp View 10 chunks +46 lines, -32 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CreateLinkCommand.h View 1 chunk +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CreateLinkCommand.cpp View 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.h View 3 chunks +10 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommand.cpp View 2 chunks +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/DeleteSelectionCommandTest.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/DragAndDropCommand.h View 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/DragAndDropCommand.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp View 120 chunks +239 lines, -231 lines 4 comments Download
M third_party/WebKit/Source/core/editing/commands/FormatBlockCommand.h View 2 chunks +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/FormatBlockCommand.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.h View 1 chunk +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/IndentOutdentCommand.cpp View 2 chunks +6 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.h View 1 chunk +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertLineBreakCommand.cpp View 1 chunk +3 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertListCommand.h View 2 chunks +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp View 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertListCommandTest.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.h View 1 chunk +5 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertParagraphSeparatorCommand.cpp View 2 chunks +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertTextCommand.h View 2 chunks +3 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/RemoveFormatCommand.h View 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/RemoveFormatCommand.cpp View 2 chunks +4 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/RemoveNodePreservingChildrenCommand.h View 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/RemoveNodePreservingChildrenCommand.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.h View 2 chunks +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp View 3 chunks +10 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommandTest.cpp View 3 chunks +6 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.h View 1 chunk +7 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/SimplifyMarkupCommand.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/SplitTextNodeContainingElementCommand.h View 1 chunk +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/SplitTextNodeContainingElementCommand.cpp View 1 chunk +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/TypingCommand.h View 2 chunks +14 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp View 16 chunks +38 lines, -21 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/TypingCommandTest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/UnlinkCommand.h View 1 chunk +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/UnlinkCommand.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/page/DragController.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/web/WebLocalFrameImpl.cpp View 2 chunks +3 lines, -2 lines 2 comments Download
M third_party/WebKit/Source/web/tests/WebFrameTest.cpp View 2 chunks +3 lines, -1 line 0 comments Download

Messages

Total messages: 15 (11 generated)
chongz
xiaochengh@ PTAL, thanks! (Seems that yosin@ and yutak@ are both OOO) https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp File third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp (right): ...
4 years ago (2016-12-13 20:08:12 UTC) #11
Xiaocheng
I tried to understand the patch but didn't succeed due to my limited experience with ...
4 years ago (2016-12-14 04:19:50 UTC) #12
Xiaocheng
https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp File third_party/WebKit/Source/web/WebLocalFrameImpl.cpp (right): https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp#newcode115 third_party/WebKit/Source/web/WebLocalFrameImpl.cpp:115: #include "core/editing/commands/CompositeEditCommand.h" Besides, ideally we would like not to ...
4 years ago (2016-12-14 05:13:15 UTC) #13
chongz
4 years ago (2016-12-15 00:53:33 UTC) #14
> I tried to understand the patch but didn't succeed due to my limited
experience
> with event lifecycle...
> 
> Anyway, could you make the patch easier for me by splitting it into simpler
> patches?

Sorry for the confusion. I will split it into 3 patches:
1. Rename |CommandSource|
2. Pass source from |Editor::Command| to |Editor::apply*()/insert*()/...|
3. Pass source from |Editor::apply*()/insert*()/...| to |CompositeEditCommand|
   and |TypingCommand|

And the first 2 patches are here:
1. https://crrev.com/2578753002
2. https://crrev.com/2576903002

> 
> I notice that a lot of changes in editing/command are kind of
> mechanical/straightforward. It would be easier to review if mechanical parts
can
> be separated out.
> 
> Besides, in the current code base, there are only two initialization sites of
> EditorCommandSource (in Document and EditorCommand resp.), which is easy to
> track and reason about. This patch makes some functions taking an extra
> CommandSource parameter, and hence, introduces a lot more initialization
sites.
> It is hard figure out whether the value is correct, and whether the relevant
> functions really need the extra parameter. Is it possible to somehow limit and
> unify the init sites of CommandSource?

The original plan was to make |CommandSource| an attribute of
|CompositeEditCommand|,
which means we'd have to modify lots of constructors.
To make our life easier, do you think it would be better to pass |CommandSource|
to |CompositeEditCommand::apply(CommandSource =
CommandSource::MenuOrKeyBinding)| instead?
The benefit is we don't have to touch constructors.

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/c...
File third_party/WebKit/Source/core/editing/Editor.cpp (right):

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/c...
third_party/WebKit/Source/core/editing/Editor.cpp:992: if
(!focusedOrMainFrame->selection().isAvailable())
On 2016/12/14 04:19:50, Xiaocheng wrote:
> Seems irrelevant to this patch.

Will remove.

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/c...
third_party/WebKit/Source/core/editing/Editor.cpp:1291: if
(m_preventRevealSelection || !m_frame->selection().isAvailable())
On 2016/12/14 04:19:50, Xiaocheng wrote:
> Seems irrelevant to this patch.

Will remove.

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/c...
third_party/WebKit/Source/core/editing/Editor.cpp:1445: if
(frame().selection().isAvailable())
On 2016/12/14 04:19:50, Xiaocheng wrote:
> Seems irrelevant to this patch.

Will remove.

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/c...
File third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp (right):

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/c...
third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp:693: if
(frame.selection().isAvailable())
On 2016/12/14 04:19:50, Xiaocheng wrote:
> Seems irrelevant to this patch.

Will remove.

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/w...
File third_party/WebKit/Source/web/WebLocalFrameImpl.cpp (right):

https://codereview.chromium.org/2574793002/diff/1/third_party/WebKit/Source/w...
third_party/WebKit/Source/web/WebLocalFrameImpl.cpp:115: #include
"core/editing/commands/CompositeEditCommand.h"
On 2016/12/14 05:13:15, Xiaocheng wrote:
> Besides, ideally we would like not to make anything outside editing depend on
> editing/commands.

Changed |CommandSource| to be a default parameter in the second sub-patch:
"https://codereview.chromium.org/2576903002/diff/1/third_party/WebKit/Source/core/editing/Editor.h#newcode277"

Powered by Google App Engine
This is Rietveld 408576698