RESOLVED FIXED 25639
Spellcheck disabling does not disable context menu
https://bugs.webkit.org/show_bug.cgi?id=25639
Summary Spellcheck disabling does not disable context menu
Julie Parent
Reported 2009-05-07 21:30:33 PDT
Setting spellcheck=false seems to disable the red squiggly, but if you right click on a misspelled word, the context menu still has spelling suggestions and other spellcheck related items.
Attachments
Patch (1.46 KB, patch)
2010-05-12 02:29 PDT, Tony Chang
no flags
Patch (10.35 KB, patch)
2010-05-12 21:33 PDT, Tony Chang
no flags
Patch (10.81 KB, patch)
2010-05-13 19:32 PDT, Tony Chang
darin: review+
commit-queue: commit-queue-
Tony Chang
Comment 1 2010-05-12 02:29:27 PDT
Tony Chang
Comment 2 2010-05-12 02:31:56 PDT
(In reply to comment #1) > Created an attachment (id=55819) [details] > Patch This is not for review because it has no tests. But I wanted some suggestions on how to test. We can't use a pixel test because context menus aren't shown. I considered adding a method to eventSender, but there's no method in the WebKit api for getting the menu items. It's probably possible for me to crawl the NSMenu of a showing context menu, but is that too much of a hack? The other option is to just write a manual layout test. Suggestions welcome, otherwise I'll probably try to crawl the NSMenu tomorrow.
Evan Martin
Comment 3 2010-05-12 03:32:26 PDT
I wonder how other context menu items (cut/copy/paste/copy link address) are tested?
Darin Adler
Comment 4 2010-05-12 11:27:29 PDT
I don't think this is the right level to do this check; the check itself is OK but a bit too low level. If you look at the call site in ContextMenu::populate, it has some logic about menu items related to spelling that runs even if the function returns false. I think a better fix would be creating a function that combines the isInPasswordField check with the spellCheckingEnabledInFocusedNode check and calling that in ContextMenu::populate. That function could be local to the ContextMenu file and class or in the Editor or wherever seems most natural and clear.
Tony Chang
Comment 5 2010-05-12 21:33:37 PDT
Tony Chang
Comment 6 2010-05-12 21:38:22 PDT
(In reply to comment #3) > I wonder how other context menu items (cut/copy/paste/copy link address) are tested? As far as I can tell, people test the behavior (e.g., the result of a paste), not the menu itself. (In reply to comment #4) > I don't think this is the right level to do this check; the check itself is OK but a bit too low level. If you look at the call site in ContextMenu::populate, it has some logic about menu items related to spelling that runs even if the function returns false. I moved the check to ContextMenu. I wasn't sure what to do about the "Spelling and Grammar" menu. The current patch keeps it, but I think either behavior would be ok. I didn't merge with the isInPasswordField because it's used for other things like disabling transformations. This includes a layout test with an extension to eventSender. Since it gets the context menu items, I'll have to grab results for Tiger and Snow Leopard from the bots.
Darin Adler
Comment 7 2010-05-13 14:15:07 PDT
Comment on attachment 55937 [details] Patch Comments in Skipped files start with "#" rather than "//". You have a TODO to add a bug number. Please do that. > + if (subView) { > + NSMenu* menu = [subView menuForEvent:event]; > + if (shouldPrintMenuItems) { > + printf("ContextMenuItems: "); > + for (int i = 0; i < [menu numberOfItems]; ++i) { It doesn't make sense to set up the menu local variable before checking the shouldPrintMenuItems. > + if (i > 0) > + printf(", "); > + NSMenuItem* menuItem = [menu itemAtIndex:i]; > + printf("%s", [menuItem isSeparatorItem] ? "----" : [[menuItem title] UTF8String]); Since menu item titles are localized, it might be better to log something else, perhaps the selector, reformatted in to the style of a WebCore editor command name. SEL selector = [menuItem action]; char commandName[256]; strcpy(commandName, sel_getName(selector)); size_t commandName Length = strlen(commandName); if (commandNameLength >= 2 && commandName[commandNameLength - 1] == ':') { commandName[0] = toupper(commandName[0]); commandName[commandNameLength - 1] = '\0'; } Using printf with a constant string or a string of just "%s" is an anti-pattern. fputs(stdio, <string>) is better.
Darin Adler
Comment 8 2010-05-13 14:15:42 PDT
Comment on attachment 55937 [details] Patch review- so you can rework the tests a bit. The code change seems fine.
Tony Chang
Comment 9 2010-05-13 19:32:50 PDT
Tony Chang
Comment 10 2010-05-13 19:36:28 PDT
(In reply to comment #7) > (From update of attachment 55937 [details]) > Comments in Skipped files start with "#" rather than "//". Fixed. > You have a TODO to add a bug number. Please do that. Fixed. > > + if (subView) { > > + NSMenu* menu = [subView menuForEvent:event]; > > + if (shouldPrintMenuItems) { > > + printf("ContextMenuItems: "); > > + for (int i = 0; i < [menu numberOfItems]; ++i) { > > It doesn't make sense to set up the menu local variable before checking the shouldPrintMenuItems. We always want to run [subView menuForEvent:event], so I put it outside the shouldPrintMenuItems check. > > + if (i > 0) > > + printf(", "); > > + NSMenuItem* menuItem = [menu itemAtIndex:i]; > > + printf("%s", [menuItem isSeparatorItem] ? "----" : [[menuItem title] UTF8String]); > > Since menu item titles are localized, it might be better to log something else, perhaps the selector, reformatted in to the style of a WebCore editor command name. I see. I tried this using the code you provided, but I got a bunch of ForwardContextMenuAction and SubmenuAction. It looks like it keeps the value in tag and there's a big switch statement for determining the action. We could just write out the tag (int) or maybe have a switch to map enum values to strings (seems like it might be a pain to keep in sync). The current patch has tag number + title, but it's mostly just to demonstrate the output. Thoughts?
Darin Adler
Comment 11 2010-05-14 09:25:53 PDT
Comment on attachment 56044 [details] Patch I guess dumping the title is best. Probably not all that helpful to dump the tag. Sorry for sending you off on a wild goose chase before.
Adam Barth
Comment 12 2010-05-14 23:31:01 PDT
Attachment 56044 [details] was posted by a committer and has review+, assigning to Tony Chang for commit.
Adam Barth
Comment 13 2010-05-15 18:54:15 PDT
Comment on attachment 56044 [details] Patch This looks straightforward enough. Tossing it on the commit-queue for Tony.
WebKit Commit Bot
Comment 14 2010-05-16 14:33:32 PDT
Comment on attachment 56044 [details] Patch Rejecting patch 56044 from commit-queue. Failed to run "[u'/Users/eseidel/Projects/CommitQueue/WebKitTools/Scripts/svn-apply', u'--reviewer', u'Darin Adler', u'--force']" exit_code: 1 Last 500 characters of output: opard/editing/spelling/context-menu-suggestions-expected.txt patching file LayoutTests/platform/qt/Skipped Hunk #1 succeeded at 5090 (offset -6 lines). patching file LayoutTests/platform/win/Skipped Hunk #1 succeeded at 876 (offset 4 lines). patching file WebCore/ChangeLog Hunk #1 succeeded at 1 with fuzz 3. patching file WebCore/platform/ContextMenu.cpp patching file WebKitTools/ChangeLog Hunk #1 succeeded at 1 with fuzz 3. patching file WebKitTools/DumpRenderTree/mac/EventSendingController.mm Full output: http://webkit-commit-queue.appspot.com/results/2273195
Tony Chang
Comment 15 2010-05-16 17:26:50 PDT
Note You need to log in before you can comment on or make changes to this bug.