Bug 125392 - REGRESSION(r136280): input[type=image] should assume coords of 0,0 when activated without physically clicking
Summary: REGRESSION(r136280): input[type=image] should assume coords of 0,0 when activ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: BlinkMergeCandidate, Regression
Depends on:
Blocks: 102624
  Show dependency treegraph
 
Reported: 2013-12-07 11:52 PST by Ryosuke Niwa
Modified: 2013-12-09 15:41 PST (History)
5 users (show)

See Also:


Attachments
Merges the patch (5.99 KB, patch)
2013-12-07 12:10 PST, Ryosuke Niwa
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2013-12-07 11:52:34 PST
Activating an image button with the keyboard or element.click() should result in selected coords of (0,0). This is consistent with the spec and IE and Firefox.

The relevant spec is:
"If the user activates the control without explicitly selecting a coordinate, then the coordinate (0,0) must be assumed."
http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#image-button-state-(type=image)

https://code.google.com/p/chromium/issues/detail?id=306392
Comment 1 Ryosuke Niwa 2013-12-07 12:10:05 PST
Created attachment 218660 [details]
Merges the patch
Comment 2 Darin Adler 2013-12-09 08:28:25 PST
Comment on attachment 218660 [details]
Merges the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=218660&action=review

> Source/WebCore/html/ImageInputType.cpp:96
> +static IntPoint clickLocationForEvent(Event& event)
> +{
> +    if (!event.underlyingEvent())
> +        return IntPoint();
> +
> +    Event& underlyingEvent = *event.underlyingEvent();
> +    if (!underlyingEvent.isMouseEvent())
> +        return IntPoint();
> +
> +    MouseEvent& mouseEvent = toMouseEvent(underlyingEvent);
> +    if (mouseEvent.isSimulated())
> +        return IntPoint();
> +
> +    return IntPoint(mouseEvent.offsetX(), mouseEvent.offsetY());
> +}

This is not a very good standalone function. The function relies on the fact that the event passed to it is not itself a mouse event, and instead goes right at the underlying event. A general purpose function would want to handle the case where the event itself was a mouse event, and also arguably needs a loop that keeps following underlyingEvent pointers until it finds a mouse event.

I understand the desire to make ImageInputType::handleDOMActivateEvent more elegant by factoring out the code, but the code was specific to DOM activate in a subtle way.
Comment 3 Ryosuke Niwa 2013-12-09 15:41:15 PST
Committed r160337: <http://trac.webkit.org/changeset/160337>