Bug 15117

Summary: REGRESSION: Message text isn't focused when reply or forward is clicked
Product: WebKit Reporter: Ruben Bakker <ruben>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Major CC: ddkilzer
Priority: P1 Keywords: GoogleBug, InRadar, Regression
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.4   
URL: http://mail.google.com
Attachments:
Description Flags
Screenshot: Message text after reply was clicked none

Description Ruben Bakker 2007-08-30 12:47:08 PDT
Click either "Reply" or "Forward" and the appearing message text isn't focused. This happens about 20% to 50% of the time. When the focus isn't set, there is no cursor shown in the message text. See attached screenshot.

This problem results in user confusion, or sometimes even to data loss: Users click the link and then start typing. If they have enabled Gmail's keyboard shortcuts, then their entries are interpreted as actions. (y will archive, x will delete etc) 

Important: The problem doesn't occur when using the keyboard, e.g. pressing 'r' for reply. Nor does it happen when you click the link and then immediately move the mouse while the message text is opened.

I have tried to debug it and found this code to be the problem (WebHtmlView.mm):

- (BOOL)acceptsFirstResponder
{
    // Don't accept first responder when we first click on this view.
    // We have to pass the event down through WebCore first to be sure we don't hit a subview.
    // Do accept first responder at any other time, for example from keyboard events,
    // or from calls back from WebCore once we begin mouse-down event handling.
    NSEvent *event = [NSApp currentEvent];
    if ([event type] == NSLeftMouseDown
            && !_private->handlingMouseDownEvent
            && NSPointInRect([event locationInWindow], [self convertRect:[self visibleRect] toView:nil])) {
        return NO; // My Workaround is to return YES here.
    }
    return YES;
}

When it doesn't work, it is because this method returns NO. If I always return YES, the error can't be duplicated.

If you enter 'r' to reply then it will return YES (keyboard event)
If you move your mouse right after the click then a NSMouseMouse Event will be generated and a YES is the result (not a mouse down event).

My findings maybe very superficial - there may be a deeper problem that I don't understand.

I marked this bug 
- REGRESSION, as it started to appear with html message text (old Safari has no problem)
- CRITICAL as people are confused by the problem (Lot's of bug reports on my side)
Comment 1 Ruben Bakker 2007-08-30 12:54:03 PDT
Created attachment 16165 [details]
Screenshot: Message text after reply was clicked
Comment 2 Ruben Bakker 2007-08-30 12:56:39 PDT
I experienced this bug with many different WebKit nightlies since about begin July.
Checked out the source code today for the debugging session (2007-08-30)
Comment 3 Mark Rowe (bdash) 2007-08-30 14:08:55 PDT
<rdar://problem/5451335>
Comment 4 Luis Roel 2008-01-22 17:32:18 PST
Confirmed using build r29711
Comment 5 Alexey Proskuryakov 2008-01-24 00:27:52 PST
Marking confirmed per the above comments.
Comment 6 David Kilzer (:ddkilzer) 2008-02-20 06:27:22 PST
Ruben do you still see this issue?

I could not reproduce it with WebKit Nightly build r30377 on Mac OS X 10.4.11 (8S165) and the new GMail v2 interface.
Comment 7 Ruben Bakker 2008-02-22 22:41:30 PST
(In reply to comment #6)
> Ruben do you still see this issue?
> 
> I could not reproduce it with WebKit Nightly build r30377 on Mac OS X 10.4.11
> (8S165) and the new GMail v2 interface.
> 
Hi David,
I have tested both the Gmail 1 and Gmail 2 interfaces and wasn't able to duplicate the problem. The seems problem seems to be resolved.
Comment 8 David Kilzer (:ddkilzer) 2008-02-23 03:31:41 PST
Marking RESOLVED/FIXED per Comment #7.