New issue
Advanced search Search tips

Issue 670035 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Task

Blocked on: View detail
issue 673789
issue 678795

Blocking:
issue 701863



Sign in to add a comment

InputEvent Improvement: Support |Editor::willApplyEditing()| and fire 'beforeinput' in a single place

Project Member Reported by chongz@chromium.org, Nov 30 2016

Issue description

Currently 'beforeinput' are fired everywhere before executing an edit command, which causes duplicated code and it's difficult to maintain.

One possible solution is to support:
1. |CompositeEditCommand::willApply()|, called by |CompositeEditCommand::apply()|
2. |Editor::willApplyEditing()|, called by |CompositeEditCommand::willApply()|

So the pattern for InputEvent would become:
1. |Editor::willApplyEditing()| fires 'beforeinput'
2. |Editor::appliedEditing()| fires 'input'

Technique Difficulties:
Since we don't want |execCommand()| to fire 'beforeinput', we will have to pass |m_source| from |Editor::Command::execute()| down to every |CompositeEditCommand|, which would affect a wide range of code.

Do we want this or is there any other suggestions?
 

Comment 1 by yosin@chromium.org, Dec 1 2016

Can we consolidate all command execution into |Editor::Command::execute()| with making |EditorInternalCommand| to have |InputType| rather than |InputTypeFromCommandType()| function?

In this way, knowledge of inputType is one place and be table driven.
Note: We need to find out way to handling of InertNewline => InsertPargraph/InsertLineBreak which depend or rich/plain, though.

Sure that should be doable (we might have to make |InputType| a function to handle |InertNewline|), thanks for the suggestion!

But actually I was thinking about another plan, where we should push all |InputEvent| related stuff into |CompositeEditCommand|. Sorry for the confusion.
e.g.
Current Status:
1. Some |InputType|s and |Range| are bound to |EditorInternalCommand| (Typing, keyboard hotkeys, context menu)
2. Some |InputType|s and |data| are bound to |CompositeEditCommand| (IME, drag&drop, spellcheck)
3. Each time we execute a |CompositeEditCommand| or an |EditorInternalCommand| we will have to write the following pattern[1]:
  i. Call |dispatchBeforeInputEditorCommand/DataTransfer/..()|
  ii. Check if canceled
  iii. Check if |m_frame| still exists
  iv. Execute the command

Proposed Plan:
1. Bind all |InputType|, |data|, |Range|, etc. to each |CompositeEditCommand|
2. Make |CompositeEditCommand::apply()| calls |CompositeEditCommand::willApply()|, which in turn calls |Editor::willApplyEditing(cmd)| and fires 'beforeinput'
  * This works for |EditorInternalCommand| as it will eventually execute a |CompositeEditCommand|
3. So we only need to have the pattern [1] in one place (Inside |Editor::willApplyEditing(cmd)|)


Taking |InertNewline| as an example, the call path is:
1. |Editor::Command::execute()|
2. |executeInsertNewline()|
3. |EventHandler::handleTextInputEvent()|
4. |EventHandler::defaultTextInputEventHandler()|
5. |Editor::handleTextEvent()|
6.1. |Editor::insertLineBreak()| -> |TypingCommand::insertLineBreak()|
6.2. |Editor::insertParagraphSeparator()| -> |TypingCommand::insertParagraphSeparator()|
7. |TypingCommand::apply()|

So I think we should fire 'beforeinput' in 7. instead of in 1.

Comment 3 by yosin@chromium.org, Dec 2 2016

Let's create patch about your plan to see what your proposal makes our code simpler.

Regarding example in #c2, should we dispatch "beforeinput" before TextEvent? Since
TextEvent is subject to deprecate, we make it to second citizen rather than first citizen which drives DOM mutation.

Comment 4 by chongz@chromium.org, Dec 13 2016

Blockedon: 673789
Project Member

Comment 5 by bugdroid1@chromium.org, Dec 20 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4d0f52c1162dae46a7902527775f2a95fc972423

commit 4d0f52c1162dae46a7902527775f2a95fc972423
Author: chongz <chongz@chromium.org>
Date: Tue Dec 20 00:26:43 2016

[Editing] Introduce |CompositeEditCommand::willApplyEditing()| in prepare for 'beforeinput' (1/3)

This is the first sub-patch (1/3) of unifying 'beforeinput' logic. (Original CL
https://crrev.com/2558643003)

This CL:
1. Added attribute |m_inputType| to |TypingCommand|
2. Added calling path |CompositeEditCommand::apply()| =>
    *|CompositeEditCommand::willApply()| =>
    *|CompositeEditCommand::willApplyEditing()|
3. Added calling path |static TypingCommand::deleteSelection()/insertText()/...| =>
    *|TypingCommand::willAddTypingToOpenCommand()| =>
    *|CompositeEditCommand::willApplyEditing()|

* Marks new methods.

The next step is to move 'beforeinput' logic to
|CompositeEditCommand::willApplyEditing()|.

This CL shouldn't have any behavior change.

To help reviewing, here is a simple doc describing the following plans:
https://docs.google.com/a/chromium.org/document/d/1M9bQaLKdRpR1qJ9i7zZKN-hKwd4ZkgJs5GPde2ZsDy0/edit?usp=sharing

BUG=670035

Review-Url: https://codereview.chromium.org/2583993002
Cr-Commit-Position: refs/heads/master@{#439633}

[modify] https://crrev.com/4d0f52c1162dae46a7902527775f2a95fc972423/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
[modify] https://crrev.com/4d0f52c1162dae46a7902527775f2a95fc972423/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h
[modify] https://crrev.com/4d0f52c1162dae46a7902527775f2a95fc972423/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
[modify] https://crrev.com/4d0f52c1162dae46a7902527775f2a95fc972423/third_party/WebKit/Source/core/editing/commands/TypingCommand.h

Project Member

Comment 6 by bugdroid1@chromium.org, Dec 20 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c6596482a643b73b8cfe7b615639e6fea449e08b

commit c6596482a643b73b8cfe7b615639e6fea449e08b
Author: chongz <chongz@chromium.org>
Date: Tue Dec 20 00:45:22 2016

[Editing] Introduce |EditCommandComposition::willUn/Reapply()| in prepare for 'beforeinput' (2/3)

This is the second sub-patch (2/3) of unifying 'beforeinput' logic. (Original CL
https://crrev.com/2558643003)

This CL:
1. Updated calling path |Editor::undo()| =>
    |UndoStack::undo()| =>
    |EditCommandComposition::unapply()| =>
    *|EditCommandComposition::willUnapply()|.
2. Similar for redo.

* Marks new methods.

The next step is to fire 'beforeinput' in |EditCommandComposition::willUn/Reapply()|.

This CL shouldn't have any behavior change.

To help reviewing, here is a simple doc describing the following plans:
https://docs.google.com/a/chromium.org/document/d/1M9bQaLKdRpR1qJ9i7zZKN-hKwd4ZkgJs5GPde2ZsDy0/edit?usp=sharing

BUG=670035

Review-Url: https://codereview.chromium.org/2581073003
Cr-Commit-Position: refs/heads/master@{#439640}

[modify] https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b/third_party/WebKit/Source/core/editing/Editor.cpp
[modify] https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
[modify] https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h
[modify] https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b/third_party/WebKit/Source/core/editing/commands/UndoStack.cpp
[modify] https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b/third_party/WebKit/Source/core/editing/commands/UndoStack.h
[modify] https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b/third_party/WebKit/Source/core/editing/commands/UndoStep.h

Project Member

Comment 7 by bugdroid1@chromium.org, Dec 22 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/52e388599d4d76546635b462a534e08dca4ff104

commit 52e388599d4d76546635b462a534e08dca4ff104
Author: xiaochengh <xiaochengh@chromium.org>
Date: Thu Dec 22 11:50:30 2016

Update layout after TypingCommand::willAddTypingToOpenCommand

This patch is a preparation for https://crrev.com/2558643003, where
TypingCommand::willAddTypingToOpenCommand is modified to fire 'beforeinput'
event. Since the event handler may make layout dirty and all follow-up
operations require clean layout, this patch adds layout update after
TypingCommand::willAddTypingToOpenCommand finishes.

BUG=670035

Review-Url: https://codereview.chromium.org/2594313002
Cr-Commit-Position: refs/heads/master@{#440387}

[modify] https://crrev.com/52e388599d4d76546635b462a534e08dca4ff104/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp

Blockedon: 678795
Project Member

Comment 9 by bugdroid1@chromium.org, Jan 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bca99cd5304a9e2a6fb249d7d3c352854752cd69

commit bca99cd5304a9e2a6fb249d7d3c352854752cd69
Author: chongz <chongz@chromium.org>
Date: Fri Jan 13 20:55:34 2017

Revert of [Editing] Introduce |EditCommandComposition::willUn/Reapply()| in prepare for 'beforeinput' (2/3) (patchset #2 id:20001 of https://codereview.chromium.org/2581073003/ )

Reason for revert:
We want to revert all CLs and start over the refactor process, see:
https://crbug.com/673789.

Original issue's description:
> [Editing] Introduce |EditCommandComposition::willUn/Reapply()| in prepare for 'beforeinput' (2/3)
>
> This is the second sub-patch (2/3) of unifying 'beforeinput' logic. (Original CL
> https://crrev.com/2558643003)
>
> This CL:
> 1. Updated calling path |Editor::undo()| =>
>     |UndoStack::undo()| =>
>     |EditCommandComposition::unapply()| =>
>     *|EditCommandComposition::willUnapply()|.
> 2. Similar for redo.
>
> * Marks new methods.
>
> The next step is to fire 'beforeinput' in |EditCommandComposition::willUn/Reapply()|.
>
> This CL shouldn't have any behavior change.
>
> To help reviewing, here is a simple doc describing the following plans:
> https://docs.google.com/a/chromium.org/document/d/1M9bQaLKdRpR1qJ9i7zZKN-hKwd4ZkgJs5GPde2ZsDy0/edit?usp=sharing
>
> BUG=670035
>
> Committed: https://crrev.com/c6596482a643b73b8cfe7b615639e6fea449e08b
> Cr-Commit-Position: refs/heads/master@{#439640}

TBR=tkent@chromium.org,xiaochengh@chromium.org,yosin@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=670035

Review-Url: https://codereview.chromium.org/2631743002
Cr-Commit-Position: refs/heads/master@{#443664}

[modify] https://crrev.com/bca99cd5304a9e2a6fb249d7d3c352854752cd69/third_party/WebKit/Source/core/editing/Editor.cpp
[modify] https://crrev.com/bca99cd5304a9e2a6fb249d7d3c352854752cd69/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
[modify] https://crrev.com/bca99cd5304a9e2a6fb249d7d3c352854752cd69/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h
[modify] https://crrev.com/bca99cd5304a9e2a6fb249d7d3c352854752cd69/third_party/WebKit/Source/core/editing/commands/UndoStack.cpp
[modify] https://crrev.com/bca99cd5304a9e2a6fb249d7d3c352854752cd69/third_party/WebKit/Source/core/editing/commands/UndoStack.h
[modify] https://crrev.com/bca99cd5304a9e2a6fb249d7d3c352854752cd69/third_party/WebKit/Source/core/editing/commands/UndoStep.h

Project Member

Comment 10 by bugdroid1@chromium.org, Jan 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/945ff69e7e98f750bdbd1d5e33ebc98bd4402ca4

commit 945ff69e7e98f750bdbd1d5e33ebc98bd4402ca4
Author: chongz <chongz@chromium.org>
Date: Mon Jan 16 19:22:17 2017

Revert of Update layout after TypingCommand::willAddTypingToOpenCommand (patchset #1 id:1 of https://codereview.chromium.org/2594313002/ )

Reason for revert:
Reason for revert:
We want to revert all CLs and start over the refactor process, see:
https://crbug.com/673789.

Original issue's description:
> Update layout after TypingCommand::willAddTypingToOpenCommand
>
> This patch is a preparation for https://crrev.com/2558643003, where
> TypingCommand::willAddTypingToOpenCommand is modified to fire 'beforeinput'
> event. Since the event handler may make layout dirty and all follow-up
> operations require clean layout, this patch adds layout update after
> TypingCommand::willAddTypingToOpenCommand finishes.
>
> BUG=670035
>
> Committed: https://crrev.com/52e388599d4d76546635b462a534e08dca4ff104
> Cr-Commit-Position: refs/heads/master@{#440387}

TBR=dominicc@chromium.org,xiaochengh@chromium.org,yosin@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=670035

Review-Url: https://codereview.chromium.org/2634133002
Cr-Commit-Position: refs/heads/master@{#443931}

[modify] https://crrev.com/945ff69e7e98f750bdbd1d5e33ebc98bd4402ca4/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp

Project Member

Comment 11 by bugdroid1@chromium.org, Jan 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8fa239362956ce98ce4bd9f3b540050231a33179

commit 8fa239362956ce98ce4bd9f3b540050231a33179
Author: chongz <chongz@chromium.org>
Date: Mon Jan 16 21:06:50 2017

Revert of [Editing] Introduce |CompositeEditCommand::willApplyEditing()| in prepare for 'beforeinput' (1/3) (patchset #2 id:40001 of https://codereview.chromium.org/2583993002/ )

Reason for revert:
We want to revert all CLs and start over the refactor process, see:
https://crbug.com/673789.

Original issue's description:
> [Editing] Introduce |CompositeEditCommand::willApplyEditing()| in prepare for 'beforeinput' (1/3)
>
> This is the first sub-patch (1/3) of unifying 'beforeinput' logic. (Original CL
> https://crrev.com/2558643003)
>
> This CL:
> 1. Added attribute |m_inputType| to |TypingCommand|
> 2. Added calling path |CompositeEditCommand::apply()| =>
>     *|CompositeEditCommand::willApply()| =>
>     *|CompositeEditCommand::willApplyEditing()|
> 3. Added calling path |static TypingCommand::deleteSelection()/insertText()/...| =>
>     *|TypingCommand::willAddTypingToOpenCommand()| =>
>     *|CompositeEditCommand::willApplyEditing()|
>
> * Marks new methods.
>
> The next step is to move 'beforeinput' logic to
> |CompositeEditCommand::willApplyEditing()|.
>
> This CL shouldn't have any behavior change.
>
> To help reviewing, here is a simple doc describing the following plans:
> https://docs.google.com/a/chromium.org/document/d/1M9bQaLKdRpR1qJ9i7zZKN-hKwd4ZkgJs5GPde2ZsDy0/edit?usp=sharing
>
> BUG=670035
>
> Committed: https://crrev.com/4d0f52c1162dae46a7902527775f2a95fc972423
> Cr-Commit-Position: refs/heads/master@{#439633}

TBR=tkent@chromium.org,xiaochengh@chromium.org,yosin@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=670035

Review-Url: https://codereview.chromium.org/2634633002
Cr-Commit-Position: refs/heads/master@{#443942}

[modify] https://crrev.com/8fa239362956ce98ce4bd9f3b540050231a33179/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
[modify] https://crrev.com/8fa239362956ce98ce4bd9f3b540050231a33179/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h
[modify] https://crrev.com/8fa239362956ce98ce4bd9f3b540050231a33179/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
[modify] https://crrev.com/8fa239362956ce98ce4bd9f3b540050231a33179/third_party/WebKit/Source/core/editing/commands/TypingCommand.h

Blocking: 701863
Blocking: -585875
Components: Blink>Editing
Labels: Type-Task
Owner: ----
Status: Available (was: Assigned)
Project Member

Comment 15 by sheriffbot@chromium.org, Nov 14

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Available (was: Untriaged)
Still an issue in 2018 Q4 check-in.

Sign in to add a comment