WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
51306
[Qt] Refactor EditorClientQt::handleKeyboardEvent
https://bugs.webkit.org/show_bug.cgi?id=51306
Summary
[Qt] Refactor EditorClientQt::handleKeyboardEvent
Antonio Gomes
Reported
2010-12-19 13:19:44 PST
The method now is a complete mess, although it could be much simpler. I plan to refactor it in 2 or maybe 3 steps, so it will be a much patch bug. First one coming ....
Attachments
patch 1 - v1
(14.55 KB, patch)
2010-12-19 13:47 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 1 - v1.1
(14.70 KB, patch)
2010-12-19 13:54 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 2 - v1
(6.46 KB, patch)
2010-12-19 18:02 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 3 - comprises patch 1 and 2
(15.39 KB, patch)
2010-12-21 07:50 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 3 - v2
(15.38 KB, patch)
2010-12-21 14:10 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 3 - v3
(15.53 KB, patch)
2010-12-22 09:28 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 3 - v4 - right file.
(15.79 KB, patch)
2010-12-22 09:31 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 3 - v5 (committed r74891- r=kenneth)
(14.66 KB, patch)
2011-01-02 17:53 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
patch 4 - v1
(1.65 KB, patch)
2011-01-03 11:29 PST
,
Antonio Gomes
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Antonio Gomes
Comment 1
2010-12-19 13:47:45 PST
Created
attachment 76959
[details]
patch 1 - v1
WebKit Review Bot
Comment 2
2010-12-19 13:50:17 PST
Attachment 76959
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'WebKit/qt/ChangeLog', u'WebKit/qt/WebCoreSupport/EditorClientQt.cpp']" exit_code: 1 WebKit/qt/WebCoreSupport/EditorClientQt.cpp:498: Non-label code inside switch statements should be indented. [whitespace/indent] [4] Total errors found: 1 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Antonio Gomes
Comment 3
2010-12-19 13:54:55 PST
Created
attachment 76960
[details]
patch 1 - v1.1 Fixed the style issue.
Antonio Gomes
Comment 4
2010-12-19 18:02:53 PST
Created
attachment 76966
[details]
patch 2 - v1 Second part of the refactory. Methods is *much* cleaner now. Not up to review yet, because it depends on the first one to be in.
Kenneth Rohde Christiansen
Comment 5
2010-12-20 06:30:16 PST
Comment on
attachment 76960
[details]
patch 1 - v1.1 View in context:
https://bugs.webkit.org/attachment.cgi?id=76960&action=review
Did you think about this in a WebKit2 sense?
> WebKit/qt/ChangeLog:11 > + in qwebpage.cpp). However, there are some keyCodes associated to any no QAction,
any no? I dont understand you.
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 > + // Ctrl+DELETE and Ctrl+BACKSPACE are covered by QWebPagePrivate::editorCommandForWebActions().
why write DELETE with upper case letters?
Antonio Gomes
Comment 6
2010-12-20 06:38:22 PST
(In reply to
comment #5
)
> (From update of
attachment 76960
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=76960&action=review
> > Did you think about this in a WebKit2 sense?
No actually. As I said, it is just a refactor for the current code. All functionality should behavior exactly the same, kenne. Do you have specifc webkit2 issue in your mind?
> > WebKit/qt/ChangeLog:11 > > + in qwebpage.cpp). However, there are some keyCodes associated to any no QAction, > > any no? I dont understand you.
"However, there are some keyCodes associated to any QAction," ... consider it fixed locally.
> > WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 > > + // Ctrl+DELETE and Ctrl+BACKSPACE are covered by QWebPagePrivate::editorCommandForWebActions(). > > why write DELETE with upper case letters?
I can remove the uppercase, but as I said, this comment was already existent, and I kept it as it. Prefer to change it?
Antonio Gomes
Comment 7
2010-12-21 07:50:36 PST
Created
attachment 77112
[details]
patch 3 - comprises patch 1 and 2 I thought doing it in smaller chunks were make reviewing easier, however it failed. I am upload a new patch with both patch 1 and 2 together.
WebKit Review Bot
Comment 8
2010-12-21 07:54:38 PST
Attachment 77112
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'WebKit/qt/ChangeLog', u'WebKit/qt/WebCoreSupport/EditorClientQt.cpp']" exit_code: 1 WebKit/qt/WebCoreSupport/EditorClientQt.cpp:512: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 1 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Antonio Gomes
Comment 9
2010-12-21 14:10:50 PST
Created
attachment 77151
[details]
patch 3 - v2 Fixed the style issue.
Kenneth Rohde Christiansen
Comment 10
2010-12-22 06:39:43 PST
Comment on
attachment 77151
[details]
patch 3 - v2 View in context:
https://bugs.webkit.org/attachment.cgi?id=77151&action=review
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:359 > +// We are not mapping all editor commands here since most of them are being handled in QWebPage.cpp.
There is no file called QWebPage.cpp it is called qwebpage.cpp
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:388 > +const char* interpretKeyEvent(const KeyboardEvent* event)
from the method name it is not obvious what it returns
Antonio Gomes
Comment 11
2010-12-22 09:28:15 PST
Created
attachment 77224
[details]
patch 3 - v3 - Fixed QWebPage.cpp -> qwebpage.cpp - renamed interpretKeyEvent to editorCommandForKeyCodeAndModifiers
Antonio Gomes
Comment 12
2010-12-22 09:31:31 PST
Created
attachment 77225
[details]
patch 3 - v4 - right file. see changes in
comment #11
.
Kenneth Rohde Christiansen
Comment 13
2010-12-23 02:02:01 PST
Comment on
attachment 77225
[details]
patch 3 - v4 - right file. View in context:
https://bugs.webkit.org/attachment.cgi?id=77225&action=review
How is this tested? Maybe the ChangeLog could make that clear
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:353 > +struct KeyDownEntry {
What about KeyUp?
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:361 > +// We are not mapping all editor commands here since most of them are being handled in qwebpage.cpp. > +// The ones we are mapping here are either not being handled in QWebPage, or need special > +// handling for Spatial Navigation or Caret Browsing features.
This could be simplified. // Handle key presses here that are needed for spatial navigation and caret browsing. All other key presses are handled directly in QWebPage.
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:386 > +#define ARRAYSIZE(array) (sizeof(array) / sizeof((array)[0]))
I dont really see the point in this one :-) you use it in one place only. just do something like int numEntries = sizeof(keyDownEntries) / sizeof ... That would make the code cleaner
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:392 > + static HashMap<int, const char*>* keyDownCommandsMap = 0;
Why is this a pointer?
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:399 > + if (!keyDownCommandsMap) { > + keyDownCommandsMap = new HashMap<int, const char*>; > + > + for (unsigned i = 0; i < ARRAYSIZE(keyDownEntries); i++) > + keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, keyDownEntries[i].editorCommand); > + }
So you create a static array outside the method, and then here you create a hashmap for it. Can't that be simplified?
> WebKit/qt/WebCoreSupport/EditorClientQt.cpp:459 > + if (!commandName.isEmpty()) {
Shouldn't we assert if something is not handled instead? as that means that we need to add it to EditorClient or QWebPage, right?
Antonio Gomes
Comment 14
2011-01-02 17:53:14 PST
(In reply to
comment #13
)
> (From update of
attachment 77225
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=77225&action=review
> > How is this tested? Maybe the ChangeLog could make that clear
I am testing it by running the layout tests in LayoutTests/editing and seeing no regressions. As it is a refactor only patch, it should just work as it is now. I can working on improving test coverage (via Qt autotests) for editing, but it can come later maybe (?)
> > WebKit/qt/WebCoreSupport/EditorClientQt.cpp:353 > > +struct KeyDownEntry { > > What about KeyUp?
what matters for editing is keydown and keypress. We bail out earlier in the case of keyup: 402 void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) 403 { ... 407 408 const PlatformKeyboardEvent* kevent = event->keyEvent(); 409 if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp) 410 return;
> > WebKit/qt/WebCoreSupport/EditorClientQt.cpp:392 > > + static HashMap<int, const char*>* keyDownCommandsMap = 0; > > Why is this a pointer?
Fixed. Not a pointer anymore.
> > WebKit/qt/WebCoreSupport/EditorClientQt.cpp:459 > > + if (!commandName.isEmpty()) { > > Shouldn't we assert if something is not handled instead? as that means that we need to add it to EditorClient or QWebPage, right?
I can add asserts yes, but I would like to do this in follow ups if you agree too. Again, it is mean to just be a refactor.
Antonio Gomes
Comment 15
2011-01-02 17:53:56 PST
Created
attachment 77787
[details]
patch 3 - v5 (committed
r74891
- r=kenneth) Addressed Kenneth's requests.
WebKit Review Bot
Comment 16
2011-01-02 17:55:48 PST
Attachment 77787
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'WebKit/qt/ChangeLog', u'WebKit/qt/WebCoreSupport/EditorClientQt.cpp']" exit_code: 1 WebKit/qt/WebCoreSupport/EditorClientQt.cpp:504: One space before end of line comments [whitespace/comments] [5] Total errors found: 1 in 2 files If any of these errors are false positives, please file a bug against check-webkit-style.
Antonio Gomes
Comment 17
2011-01-03 08:04:36 PST
Comment on
attachment 77787
[details]
patch 3 - v5 (committed
r74891
- r=kenneth) Clearing flags on attachment: 77787 Committed
r74891
: <
http://trac.webkit.org/changeset/74891
>
Yi Shen
Comment 18
2011-01-03 10:48:05 PST
Antonio, I saw some crash on my linux. Do you have any idea about it? Thx Program received signal SIGSEGV, Segmentation fault. 0x01e66fb7 in WebCore::editorCommandForKeyDownEvent (event=0x83f9f18) at ../../../WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 380 ASSERT(event->type() == eventNames().keydownEvent); (gdb) i s #0 0x01e66fb7 in WebCore::editorCommandForKeyDownEvent (event=0x83f9f18) at ../../../WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 #1 0x01e6745c in WebCore::EditorClientQt::handleKeyboardEvent ( this=0x823e780, event=0x83f9f18) (gdb) p event->type() $1 = "keypress"
Antonio Gomes
Comment 19
2011-01-03 10:51:19 PST
(In reply to
comment #18
)
> Antonio, I saw some crash on my linux. Do you have any idea about it? Thx > > Program received signal SIGSEGV, Segmentation fault. > 0x01e66fb7 in WebCore::editorCommandForKeyDownEvent (event=0x83f9f18) > at ../../../WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 > 380 ASSERT(event->type() == eventNames().keydownEvent); > (gdb) i s > #0 0x01e66fb7 in WebCore::editorCommandForKeyDownEvent (event=0x83f9f18) > at ../../../WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 > #1 0x01e6745c in WebCore::EditorClientQt::handleKeyboardEvent ( > this=0x823e780, event=0x83f9f18) > > (gdb) p event->type() > $1 = "keypress"
I can have a look, yi. Steps to reproduce?
Yi Shen
Comment 20
2011-01-03 10:54:54 PST
(In reply to
comment #19
)
> (In reply to
comment #18
) > > Antonio, I saw some crash on my linux. Do you have any idea about it? Thx > > > > Program received signal SIGSEGV, Segmentation fault. > > 0x01e66fb7 in WebCore::editorCommandForKeyDownEvent (event=0x83f9f18) > > at ../../../WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 > > 380 ASSERT(event->type() == eventNames().keydownEvent); > > (gdb) i s > > #0 0x01e66fb7 in WebCore::editorCommandForKeyDownEvent (event=0x83f9f18) > > at ../../../WebKit/qt/WebCoreSupport/EditorClientQt.cpp:380 > > #1 0x01e6745c in WebCore::EditorClientQt::handleKeyboardEvent ( > > this=0x823e780, event=0x83f9f18) > > > > (gdb) p event->type() > > $1 = "keypress" > > I can have a look, yi. Steps to reproduce?
I can reproduce it by 1) launched QtTestBrowser, 2) then went to google.com, 3) typed a character in the search field on the page through the keyboard.
Antonio Gomes
Comment 21
2011-01-03 10:59:40 PST
> > I can reproduce it by > 1) launched QtTestBrowser, > 2) then went to google.com, > 3) typed a character in the search field on the page through the keyboard.
Could you tell me if this: - ASSERT(event->type() == eventNames().keydownEvent); + if (event->type() == eventNames().keydownEvent) + return ""; fixes it? If so, I will commit it and reopen to proper fix. I know that is the right thing ... thanks!
Antonio Gomes
Comment 22
2011-01-03 11:00:56 PST
> Could you tell me if this: > > - ASSERT(event->type() == eventNames().keydownEvent); > + if (event->type() == eventNames().keydownEvent)
err, it should be !=
Yi Shen
Comment 23
2011-01-03 11:11:24 PST
(In reply to
comment #22
)
> > Could you tell me if this: > > > > - ASSERT(event->type() == eventNames().keydownEvent); > > + if (event->type() == eventNames().keydownEvent) > > err, it should be !=
I will try it and let you know. (Give me 30 minutes to rebuild it :))
Antonio Gomes
Comment 24
2011-01-03 11:29:24 PST
Created
attachment 77829
[details]
patch 4 - v1
Antonio Gomes
Comment 25
2011-01-03 11:29:56 PST
Comment on
attachment 77829
[details]
patch 4 - v1 Follow up asserting hit fix.
Yi Shen
Comment 26
2011-01-03 11:56:25 PST
(In reply to
comment #25
)
> (From update of
attachment 77829
[details]
) > Follow up asserting hit fix.
Hi Antonio, I tested your changes on linux, no crash can be reproduced :)
Antonio Gomes
Comment 27
2011-01-03 12:11:01 PST
(In reply to
comment #26
)
> (In reply to
comment #25
) > > (From update of
attachment 77829
[details]
[details]) > > Follow up asserting hit fix. > > Hi Antonio, I tested your changes on linux, no crash can be reproduced :)
Thanks Yi. Reopen the bug for CQ to work.
WebKit Commit Bot
Comment 28
2011-01-03 13:16:21 PST
Comment on
attachment 77829
[details]
patch 4 - v1 Clearing flags on attachment: 77829 Committed
r74932
: <
http://trac.webkit.org/changeset/74932
>
WebKit Commit Bot
Comment 29
2011-01-03 13:16:30 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug