RESOLVED FIXED 52241
REGRESSION(r69831): focus() in onkeypress discards input (affects chaseonline.chase.com)
https://bugs.webkit.org/show_bug.cgi?id=52241
Summary REGRESSION(r69831): focus() in onkeypress discards input (affects chaseonline...
Tony Gentilcore
Reported 2011-01-11 12:40:57 PST
Created attachment 78581 [details] Testcase Changing focus during the onkeypress handler causes the pressed key to be dropped (see attached testcase). This makes it impossible to enter a social security number on the Chase bank website. In debug builds, I'm getting: ASSERTION FAILED: !ec (/Volumes/work/WebKit/Source/WebCore/dom/Range.cpp:86 WebCore::Range::Range(WTF::PassRefPtr<WebCore::Document>, WTF::PassRefPtr<WebCore::Node>, int, WTF::PassRefPtr<WebCore::Node>, int)) Copying a few people who have modified Range.cpp recently just in case they have a better idea about this. Filed in chromium as http://crbug.com/69126
Attachments
Testcase (454 bytes, text/html)
2011-01-11 12:40 PST, Tony Gentilcore
no flags
fixes the bug (6.64 KB, patch)
2011-01-12 16:55 PST, Ryosuke Niwa
no flags
fixed per Eric's comment (6.84 KB, patch)
2011-01-12 17:30 PST, Ryosuke Niwa
eric: review+
Alexey Proskuryakov
Comment 1 2011-01-11 20:07:56 PST
This is a regression from Safari 5. WebKit2 also fails, but with a different assertion.
Ryosuke Niwa
Comment 2 2011-01-12 12:56:27 PST
Ryosuke Niwa
Comment 3 2011-01-12 13:00:39 PST
Between these two revisions, WebCore/editing had the following changesets: http://trac.webkit.org/changeset/69831 http://trac.webkit.org/changeset/69836
Ryosuke Niwa
Comment 4 2011-01-12 13:51:35 PST
I confirmed that the bug reproduces on r69831 and doesn't reproduce on r69830.
Tony Gentilcore
Comment 5 2011-01-12 13:56:12 PST
(In reply to comment #4) > I confirmed that the bug reproduces on r69831 and doesn't reproduce on r69830. +Justin It is also worth noting that patch is merged onto 517 and 552.
Ryosuke Niwa
Comment 6 2011-01-12 13:58:17 PST
(In reply to comment #5) > (In reply to comment #4) > > I confirmed that the bug reproduces on r69831 and doesn't reproduce on r69830. > > +Justin > > It is also worth noting that patch is merged onto 517 and 552. Actually, the original patch was written by me. Justin just committed it. I should be able to post a patch tonight or within the next couple of days.
Ryosuke Niwa
Comment 7 2011-01-12 16:55:20 PST
Created attachment 78758 [details] fixes the bug
Ryosuke Niwa
Comment 8 2011-01-12 16:57:45 PST
(In reply to comment #7) > Created an attachment (id=78758) [details] > fixes the bug It turned out that the root cause of this bug was present before r69831 but VisiblePosition was more "forgiving" for historical reasons (e.g. legacy editing position).
Eric Seidel (no email)
Comment 9 2011-01-12 17:02:47 PST
Comment on attachment 78758 [details] fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=78758&action=review > Source/WebCore/rendering/RenderTextControl.cpp:311 > + if (offset <= start && start <= offset + length) { > + if (node->isTextNode()) { > + } else { > + } > + if (offset <= end && end <= offset + length) { > + end -= offset; > + endNode = node->parentNode(); > + } > + break; > + } These two blocks are basically identical. Seems we should use an inline function here instead.
Ryosuke Niwa
Comment 10 2011-01-12 17:30:19 PST
Created attachment 78764 [details] fixed per Eric's comment
Eric Seidel (no email)
Comment 11 2011-01-12 17:40:02 PST
Comment on attachment 78764 [details] fixed per Eric's comment View in context: https://bugs.webkit.org/attachment.cgi?id=78764&action=review Seems sane. > LayoutTests/fast/forms/focus-change-on-keypress.html:36 > + if (shouldChangeSelection) > + expected = name == 'textarea' ? 'ac\n' : 'acb'; > + else > + expected = name == 'textarea' ? 'a\nc' : 'abc'; This seems slightly odd way to write this if, but oK. :)
Ryosuke Niwa
Comment 12 2011-01-12 17:41:42 PST
(In reply to comment #11) > (From update of attachment 78764 [details]) > > LayoutTests/fast/forms/focus-change-on-keypress.html:36 > > + if (shouldChangeSelection) > > + expected = name == 'textarea' ? 'ac\n' : 'acb'; > > + else > > + expected = name == 'textarea' ? 'a\nc' : 'abc'; > > This seems slightly odd way to write this if, but oK. :) Maybe I should do: if (name == 'textarea') expected = shouldChangeSelection ? 'ac\n' : 'a\nc' else expected = shouldChangeSelection ? 'acb' : 'abc' instead?
Eric Seidel (no email)
Comment 13 2011-01-12 18:13:32 PST
(In reply to comment #12) > (In reply to comment #11) > > (From update of attachment 78764 [details] [details]) > > > LayoutTests/fast/forms/focus-change-on-keypress.html:36 > > > + if (shouldChangeSelection) > > > + expected = name == 'textarea' ? 'ac\n' : 'acb'; > > > + else > > > + expected = name == 'textarea' ? 'a\nc' : 'abc'; > > > > This seems slightly odd way to write this if, but oK. :) > > Maybe I should do: > > if (name == 'textarea') > expected = shouldChangeSelection ? 'ac\n' : 'a\nc' > else > expected = shouldChangeSelection ? 'acb' : 'abc' > > instead? Sorry I read those both as 'abc', now I understand why the complexity is needed.
Ryosuke Niwa
Comment 14 2011-01-12 18:20:30 PST
(In reply to comment #13) > (In reply to comment #12) > > Maybe I should do: > > > > if (name == 'textarea') > > expected = shouldChangeSelection ? 'ac\n' : 'a\nc' > > else > > expected = shouldChangeSelection ? 'acb' : 'abc' > > > > instead? > > Sorry I read those both as 'abc', now I understand why the complexity is needed. No problem. I'll use new one nonetheless because it reads better.
David Kilzer (:ddkilzer)
Comment 15 2011-01-12 21:10:33 PST
Ryosuke Niwa
Comment 16 2011-01-12 21:17:14 PST
Note You need to log in before you can comment on or make changes to this bug.