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

Issue 2558643003: [InputEvent] Move 'beforeinput' logic into |CompositeEditCommand::willApplyEditing()| (3/3) (Closed)

Created:
4 years ago by chongz
Modified:
3 years, 10 months ago
Reviewers:
yosin_UTC9, Xiaocheng
CC:
blink-reviews, chaopeng, chromium-reviews, dcheng, dtapuska, groby+blinkspell_chromium.org, timvolodine
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[InputEvent] Move 'beforeinput' logic into |CompositeEditCommand::willApplyEditing()| (3/3) This CL is based on http://crrev.com/2583993002 and http://crrev.com/2581073003. Before CL we fire 'beforeinput' in multiple locations, after CL we fire 'beforeinput' in 1. 'CompositeEditCommand.cpp', and 2. 'InputMethodController.cpp::insertTextDuringCompositionWithEvents()' Note: 2) Should be removed after https://crbug.com/675820 This CL: 1. Moved/added InputEvent related attributes to |CompositeEditCommand| * e.g. |textDataForInputEvent()|, |targetRangesForInputEvent()| 2. Moved most 'beforeinput' logic into 'CompositeEditCommand.cpp' 3. Retains original event order WRT 'compositionupdate'. 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 This CL also fixed https://crbug.com/652436 BUG=670035

Patch Set 1 #

Total comments: 4

Patch Set 2 : yosin's review, fix nits #

Total comments: 2

Patch Set 3 : Rebase on EditCommandSource and willApply() CLs #

Total comments: 9

Patch Set 4 : Retain the order of firing 'beforeinput' before 'compositionupdate' #

Total comments: 9

Patch Set 5 : xiaocheng's review: Isolate |UndoStep| code; Move attribuates to private #

Total comments: 75

Patch Set 6 : xiaocheng's review 2: Remove unrelated changes and added more checks #

Total comments: 4

Patch Set 7 : xiaocheng's review 3: Rebase and remove updateStyleAndLayoutIgnorePendingStylesheets() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+336 lines, -486 lines) Patch
M third_party/WebKit/LayoutTests/fast/events/inputevents/before-input-order-typing-command.html View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html View 1 chunk +1 line, -1 line 0 comments Download
A third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-compositionupdate.html View 1 2 3 1 chunk +36 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-drag-drop.html View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-keyboard.html View 2 chunks +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/clipboard/DataObject.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/clipboard/DataObject.cpp View 1 2 1 chunk +8 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/clipboard/DataTransfer.h View 1 2 1 chunk +3 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/clipboard/DataTransfer.cpp View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/EditingUtilities.h View 1 2 3 4 2 chunks +24 lines, -17 lines 0 comments Download
M third_party/WebKit/Source/core/editing/EditingUtilities.cpp View 1 2 3 4 5 6 4 chunks +63 lines, -80 lines 0 comments Download
M third_party/WebKit/Source/core/editing/Editor.h View 1 2 3 chunks +0 lines, -18 lines 0 comments Download
M third_party/WebKit/Source/core/editing/Editor.cpp View 1 2 3 4 5 7 chunks +4 lines, -95 lines 0 comments Download
M third_party/WebKit/Source/core/editing/EditorKeyBindings.cpp View 1 chunk +0 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/editing/InputMethodController.cpp View 1 2 3 4 5 4 chunks +23 lines, -35 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.h View 1 2 3 4 3 chunks +8 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp View 1 2 3 4 5 5 chunks +52 lines, -12 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/EditCommand.h View 1 2 3 chunks +0 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/EditCommand.cpp View 1 2 1 chunk +0 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/EditorCommand.cpp View 1 2 3 chunks +0 lines, -149 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.h View 1 2 3 4 2 chunks +4 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp View 1 2 3 4 5 6 1 chunk +16 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/TypingCommand.h View 1 2 3 4 3 chunks +5 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp View 1 2 3 4 5 6 3 chunks +54 lines, -6 lines 0 comments Download
M third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp View 1 2 1 chunk +0 lines, -23 lines 0 comments Download
M third_party/WebKit/Source/core/page/DragController.cpp View 1 2 3 4 5 3 chunks +19 lines, -17 lines 0 comments Download

Messages

Total messages: 78 (64 generated)
chongz
yosin@ Here is the improvement patch we have discussed, PTAL, thanks!
4 years ago (2016-12-07 07:10:11 UTC) #16
yosin_UTC9
It is strange that we need to ask command to ask editor about canceling. EditCommand::willApply() ...
4 years ago (2016-12-07 07:51:27 UTC) #17
chongz
> It is strange that we need to ask command to ask editor about canceling. ...
4 years ago (2016-12-07 15:22:21 UTC) #22
yosin_UTC9
On 2016/12/07 at 15:22:21, chongz wrote: > > It is strange that we need to ...
4 years ago (2016-12-08 07:45:01 UTC) #26
Xiaocheng
https://codereview.chromium.org/2558643003/diff/60001/third_party/WebKit/Source/core/editing/InputMethodController.cpp File third_party/WebKit/Source/core/editing/InputMethodController.cpp (right): https://codereview.chromium.org/2558643003/diff/60001/third_party/WebKit/Source/core/editing/InputMethodController.cpp#newcode74 third_party/WebKit/Source/core/editing/InputMethodController.cpp:74: // 1. Fire 'compositionupdate' event This patch switches the ...
4 years ago (2016-12-19 03:25:44 UTC) #28
chongz
https://codereview.chromium.org/2558643003/diff/60001/third_party/WebKit/Source/core/editing/InputMethodController.cpp File third_party/WebKit/Source/core/editing/InputMethodController.cpp (right): https://codereview.chromium.org/2558643003/diff/60001/third_party/WebKit/Source/core/editing/InputMethodController.cpp#newcode74 third_party/WebKit/Source/core/editing/InputMethodController.cpp:74: // 1. Fire 'compositionupdate' event On 2016/12/19 03:25:44, Xiaocheng ...
4 years ago (2016-12-19 20:53:44 UTC) #29
Xiaocheng
On 2016/12/19 at 20:53:44, chongz wrote: > https://codereview.chromium.org/2558643003/diff/60001/third_party/WebKit/Source/core/editing/InputMethodController.cpp > File third_party/WebKit/Source/core/editing/InputMethodController.cpp (right): > > https://codereview.chromium.org/2558643003/diff/60001/third_party/WebKit/Source/core/editing/InputMethodController.cpp#newcode74 ...
4 years ago (2016-12-20 01:01:58 UTC) #38
chongz
> Thanks. Let's wait for a positive response before moving the firing of beforeinput into ...
4 years ago (2016-12-20 04:48:59 UTC) #50
Xiaocheng
Thanks for the hard work! Since the patch is big and there seems to be ...
4 years ago (2016-12-20 05:49:57 UTC) #54
chongz
xiaochengh@ Thanks for reviewing my code and sorry for the big patch... 1. I've added ...
4 years ago (2016-12-20 23:27:53 UTC) #65
Xiaocheng
Thanks for the doc and the inline comments, which help a lot (and offer me ...
4 years ago (2016-12-21 02:56:39 UTC) #66
chongz
xiaochengh@ Thanks for reviewing! I've removed unrelated changes, added some checks and added comments for ...
4 years ago (2016-12-21 23:59:24 UTC) #70
Xiaocheng
Sorry I'm preempted by something else today and don't have enough time to go through ...
4 years ago (2016-12-22 06:26:20 UTC) #73
chongz
3 years, 12 months ago (2016-12-22 19:32:26 UTC) #78
> Sorry I'm preempted by something else today and don't have enough time to go
> through the full patch. It seems that we can't land this patch in this year as
> holidays are coming...

No problem at all!  Thank you for reviewing my code for the whole week, have a
wonderful holiday! :)

> 
> The patch is still pretty big, and it's still pretty hard to compare the
> behavior in every affected code path before and after the patch. To make the
> iteration more efficient, could you consider a further split? More
specifically:
> 
> 1. Make all code paths (those listed in your doc) pass an axtra parameter
> |hasFiredBeforeInput| to willApplyEditing and willUn/Reapply to indicate
whether
> 'beforeinput' has been fired before reaching willXXX. The parameter value
should
> be |true| for all code paths since they are all firing the event now.
> 
> 2. Implement the willXXX functions and their helpers. willXXX functions should
> immediately return true if it's passed with |hasFiredBeforeInput| as true.
> 
> 3. For each affected code path listed in your doc, stop firing 'beforeinput'
and
> pass false to willXXX. This should also be split into several patches, each
> covering one or several related code paths.
> 
> 4. Finish by cleaning up |hasFiredBeforeInput|.
> 
> This pattern may also help resolving the ordering issue with
> 'compositionupdate', since we can just leave a true |hasFiredBeforeInput| in
> that code path.

Thanks for the detailed plan! Will continue working on it after the holiday.

https://codereview.chromium.org/2558643003/diff/180001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/clipboard/DataTransfer.cpp (right):

https://codereview.chromium.org/2558643003/diff/180001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/clipboard/DataTransfer.cpp:121: InputEvent,
DataTransferReadable,
On 2016/12/22 06:26:20, Xiaocheng wrote:
> Hmm... This is a behavior change.
> 
> We were creating DataTransfers with DragAndDrop and InsertReplacementText for
> beforeinput, but now they both become InputEvent.
> 
> The working draft doesn't say anything about InputEvent's DataTransfer,
> though...
> 
> Anyway, could you clarify?

Sorry for the confusion, there is actually no behavior change.

Originally |DataTransfer| was used by 2 events:
1. ClipboardEvent
(https://w3c.github.io/clipboard-apis/#clipboard-event-interfaces)
  * e.g. 'copy', 'paste'
2. DragEvent (https://html.spec.whatwg.org/multipage/interaction.html#dragevent)
  * 'e.g. 'dragstart', 'drop', etc.

Now we are adding |InputEvent| which would also use |DataTransfer|.
There is no conflicts because |InputEvent::'deleteByDrag'| etc. are new events
and they are not going to replace drag&drop events.

To help reducing future confusion I think we should change |DataTransferType|
to:
```
enum DataTransferType {
    ClipboardEvent,
    DragEvent,
    InputEvent,
  };
```
Or even just change it to `bool m_isDragEvent;` as we only using it internally
for activating drop effect, etc.

https://codereview.chromium.org/2558643003/diff/180001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp (right):

https://codereview.chromium.org/2558643003/diff/180001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp:595:
document().updateStyleAndLayoutIgnorePendingStylesheets();
On 2016/12/22 06:26:20, Xiaocheng wrote:
> This layout update is not very good, as we can't easily find the consumers of
> the clean layout. It may also update layout unnecessarily (when |result ==
> false|).
> 
> I uploaded another patch to put it at the correct places:
> https://codereview.chromium.org/2594313002. Please rebase after it lands.

Rebased, thanks for the patch!

Powered by Google App Engine
This is Rietveld 408576698