WebCore:

2009-04-13  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Adele Peterson.

        https://bugs.webkit.org/show_bug.cgi?id=25153
        Can't place the caret into text field that scrolls the window on focus
        
        We refetch the target node in the shadow node case, and when we do so the window coordinate for the mouse event may
        be invalid because of scrolling that the focus handler did.  Cache the document point (that we derived from the window
        coordinate) and use that any time we refetch.

        * page/EventHandler.cpp:
        (WebCore::documentPointForWindowPoint):
        (WebCore::EventHandler::handleMousePressEvent):
        (WebCore::EventHandler::prepareMouseEvent):

LayoutTests:

2009-04-13  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Adele Peterson.
        
        <rdar://problem/6748324> REGRESSION (Kirkwood): Can't type in Netflix search field

        * fast/forms/25153-expected.txt: Added.
        * fast/forms/25153.html: Added.



git-svn-id: svn://svn.chromium.org/blink/trunk@42456 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 40603d7d
2009-04-13 Justin Garcia <justin.garcia@apple.com>
Reviewed by Adele Peterson.
<rdar://problem/6748324> REGRESSION (Kirkwood): Can't type in Netflix search field
* fast/forms/25153-expected.txt: Added.
* fast/forms/25153.html: Added.
2009-04-13 Sam Weinig <sam@webkit.org> 2009-04-13 Sam Weinig <sam@webkit.org>
Fix bad expected result. Fix bad expected result.
......
This tests to make sure that clicking inside a text field places the caret in it, even if the fields focus handler scrolls the document. Click inside the text field and verify that the caret is placed where you click.<br>
<input id="textfield" onFocus="window.scrollBy(0, 40)" value="click in me"><br>
<div style="height: 1500px;">
<script>
if (!window.layoutTestController)
return;
window.layoutTestController.dumpAsText();
textfield = document.getElementById("textfield");
// Click near the end of the field so that the caret after all of the text inside it.
x = textfield.offsetParent.offsetLeft + textfield.offsetLeft + textfield.offsetWidth - 5;
y = textfield.offsetParent.offsetTop + textfield.offsetTop + textfield.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
if (textfield.selectionStart == textfield.value.length && textfield.selectionEnd == textfield.value.length)
document.body.innerText = "Success"
else
document.body.innerText = "Failure. Expected selection to be after all of the text in the text field."
</script>
2009-04-13 Justin Garcia <justin.garcia@apple.com>
Reviewed by Adele Peterson.
https://bugs.webkit.org/show_bug.cgi?id=25153
Can't place the caret into text field that scrolls the window on focus
We refetch the target node in the shadow node case, and when we do so the window coordinate for the mouse event may
be invalid because of scrolling that the focus handler did. Cache the document point (that we derived from the window
coordinate) and use that any time we refetch.
* page/EventHandler.cpp:
(WebCore::documentPointForWindowPoint):
(WebCore::EventHandler::handleMousePressEvent):
(WebCore::EventHandler::prepareMouseEvent):
2009-04-13 Sam Weinig <sam@webkit.org> 2009-04-13 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen. Reviewed by Geoffrey Garen.
...@@ -1039,6 +1039,14 @@ Cursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scr ...@@ -1039,6 +1039,14 @@ Cursor EventHandler::selectCursor(const MouseEventWithHitTestResults& event, Scr
} }
return pointerCursor(); return pointerCursor();
} }
IntPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint)
{
FrameView* view = frame->view();
// FIXME: Is it really OK to use the wrong coordinates here when view is 0?
// Historically the code would just crash; this is clearly no worse than that.
return view ? view->windowToContents(windowPoint) : windowPoint;
}
bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
{ {
...@@ -1060,7 +1068,8 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) ...@@ -1060,7 +1068,8 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_mouseDownWasInSubframe = false; m_mouseDownWasInSubframe = false;
HitTestRequest request(HitTestRequest::Active); HitTestRequest request(HitTestRequest::Active);
MouseEventWithHitTestResults mev = prepareMouseEvent(request, mouseEvent); IntPoint documentPoint = documentPointForWindowPoint(m_frame, mouseEvent.pos());
MouseEventWithHitTestResults mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
if (!mev.targetNode()) { if (!mev.targetNode()) {
invalidateClick(); invalidateClick();
...@@ -1139,7 +1148,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) ...@@ -1139,7 +1148,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
if (mev.scrollbar()) { if (mev.scrollbar()) {
const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMouse.get(); const bool wasLastScrollBar = mev.scrollbar() == m_lastScrollbarUnderMouse.get();
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
mev = prepareMouseEvent(request, mouseEvent); mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get()) if (wasLastScrollBar && mev.scrollbar() != m_lastScrollbarUnderMouse.get())
m_lastScrollbarUnderMouse = 0; m_lastScrollbarUnderMouse = 0;
} }
...@@ -1155,7 +1164,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent) ...@@ -1155,7 +1164,7 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
// event target node can't still be the shadow node. // event target node can't still be the shadow node.
if (mev.targetNode()->isShadowNode() && mev.targetNode()->shadowParentNode()->hasTagName(inputTag)) { if (mev.targetNode()->isShadowNode() && mev.targetNode()->shadowParentNode()->hasTagName(inputTag)) {
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
mev = prepareMouseEvent(request, mouseEvent); mev = m_frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
} }
FrameView* view = m_frame->view(); FrameView* view = m_frame->view();
...@@ -1499,12 +1508,8 @@ MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques ...@@ -1499,12 +1508,8 @@ MouseEventWithHitTestResults EventHandler::prepareMouseEvent(const HitTestReques
{ {
ASSERT(m_frame); ASSERT(m_frame);
ASSERT(m_frame->document()); ASSERT(m_frame->document());
FrameView* view = m_frame->view(); return m_frame->document()->prepareMouseEvent(request, documentPointForWindowPoint(m_frame, mev.pos()), mev);
// FIXME: Is it really OK to use the wrong coordinates here when view is 0?
// Historically the code would just crash; this is clearly no worse than that.
IntPoint documentPoint = view ? view->windowToContents(mev.pos()) : mev.pos();
return m_frame->document()->prepareMouseEvent(request, documentPoint, mev);
} }
#if ENABLE(SVG) #if ENABLE(SVG)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment