[webkit-dev] selecting text ignores mouse down position

Evan Martin evan at chromium.org
Fri Mar 11 11:34:53 PST 2011

The simple layout test below demonstrates that when you select text by
clicking and dragging, we ignore the position of the initial mouse
down and instead rely on mouse move events to judge what text is
selected.  I verified the behavior on Linux (Chrome) and Mac

Is it expected that the platform sends a mouse move event at the
position of the initial mouse down when dragging?
Or is this a bug in WebKit?  I'm trying to figure out which layer I
should fix this at.

I manually verified on Chrome Linux via some logging statements that
if I move the mouse rapidly and drag, the mouse down position is
sometimes a pixel away from the first mouse move event position.

<div id='text'>The first part of this text should be selected.</div>
if (window.eventSender) {
    var div = document.getElementById('text');
    var x = div.offsetLeft + 1;
    var y = div.offsetTop + 5;
    eventSender.mouseMoveTo(x, y);

    // With this mouse move event, we select the initial range of text.
    // Without it, we don't -- we just get the caret positioned within the text.
    eventSender.mouseMoveTo(x, y);

    eventSender.mouseMoveTo(x + 50, y);

More information about the webkit-dev mailing list