Commit 444dff87 authored by tonikitoo@webkit.org's avatar tonikitoo@webkit.org

2010-04-25 Antonio Gomes <tonikitoo@webkit.org>

        Reviewed by Darin Adler.

        Clicking a scrollbar blurs the currently focused element
        https://bugs.webkit.org/show_bug.cgi?id=16809

        WebKit ports that do not use native (platform) widgets for rendering the scrollbars
        are currently mismatching a common behaviour of other browser vendors (including
        Firefox and Opera): clicking on a frame scrollbar *should not* steal focus from content.
        WebKit browsers based ports that do use WebCore for handling scrollbars, like QtWebKit for
        instance, can observe the opposite behaviour.

        Patch fixes this behaviour by checking if current MouseDown event targets a frame scrollbar.
        If that is the case, it bails out and do not change focus behavior at all.

        It is important to note that the given way this is implemented by this patch, non-frame
        scrollbars (e.g. a vertical scrollbar of an overflowed textareas or divs) will keep working
        in the same way as it works currently.

        Tests: scrollbars/scrollbar-click-does-not-blur-content.html
               scrollbars/scrollbar-iframe-click-does-not-blur-content.html

        * page/EventHandler.cpp:
        (WebCore::EventHandler::dispatchMouseEve

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58476 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 55af7ae8
2010-04-25 Antonio Gomes <tonikitoo@webkit.org>
Reviewed by Darin Adler.
Clicking a scrollbar blurs the currently focused element
https://bugs.webkit.org/show_bug.cgi?id=16809
* scrollbars/resources/scrollable-iframe-with-input-field.html: Added.
* scrollbars/scrollbar-click-does-not-blur-content-expected.txt:
* scrollbars/scrollbar-click-does-not-blur-content.html: Added.
* scrollbars/scrollbar-iframe-click-does-not-blur-content-expected.txt:
* scrollbars/scrollbar-iframe-click-does-not-blur-content.html: Added.
2010-04-28 Martin Robinson <mrobinson@webkit.org>
Reviewed by Gustavo Noronha.
......
......@@ -5998,3 +5998,6 @@ editing/pasteboard/copy-backslash-with-euc.html
# https://bugs.webkit.org/show_bug.cgi?id=37914
fast/frames/frame-crash-with-page-cache.html
# document.body.clientWidth includes vertical scrollbar size.
scrollbars/scrollbar-click-does-not-blur-content.html
......@@ -174,3 +174,6 @@ fast/dom/icon-url-property.html
# It seems this depends on the size of physical screen?
printing/media-queries-print.html
# EventSendingController does not send events on areas outside the WebView.
scrollbars/scrollbar-click-does-not-blur-content.html
<body>
<input id='textField' type='text'><br><br>
<div style='position:absolute; width:200%; height:200%;'></div>
</body>
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function runTest()
{
document.getElementById("textField").focus();
if (window.eventSender) {
eventSender.mouseMoveTo(document.body.clientWidth + 8, 40);
eventSender.mouseDown();
eventSender.mouseUp();
finished();
}
}
function finished()
{
if (document.activeElement.getAttribute("id") == "textField")
document.getElementById('console').innerHTML = "PASS";
else
document.getElementById('console').innerHTML = "FAIL";
if (window.layoutTestController)
window.layoutTestController.notifyDone();
}
window.onload = runTest;
</script>
</head>
<body>
<div id="console" style="width:200%;height:200%;">
<input id="textField" type="text"><br><br>
<div style="border:2px solid black;width:25%;" onclick="finished();"> This test checks that right clicking the scroll bars doesn't trigger a blur event in content (See <a href="https://bugs.webkit.org/show_bug.cgi?id=16809">Bug 16809</a>). If the test passes, the output will be a single line that says PASS. To run the tests manually, click each of the scroll bars, and focus shoulds remain in the input field above</div>
</div>
</body>
</html>
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function runTest()
{
window.frames[0].document.getElementById("textField").focus();
if (window.eventSender) {
var frame = document.getElementById("anIFrame");
// center the mouse cursor (NOTE: 2px inset for scrollbars).
var x = frame.offsetParent.offsetLeft + frame.contentDocument.body.clientWidth + 8;
var y = frame.offsetParent.offsetTop + frame.offsetHeight / 2;
// send mouse event to click iframe's scrollbar.
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
finished();
}
}
function finished()
{
var doc = window.frames[0].document;
if (doc.hasFocus() && doc.activeElement.getAttribute("id") == "textField")
document.getElementById('console').innerHTML = "PASS";
else
document.getElementById('console').innerHTML = "FAIL";
if (window.layoutTestController)
window.layoutTestController.notifyDone();
}
</script>
</head>
<body>
<div id="console" style="left:50px;top:50px;width:200px;height:200px;position:absolute;">
<iframe onload="runTest();" id="anIFrame" style="width:200px;height:200px;position:absolute;" src="resources/scrollable-iframe-with-input-field.html">
</div>
</body>
</html>
2010-04-25 Antonio Gomes <tonikitoo@webkit.org>
Reviewed by Darin Adler.
Clicking a scrollbar blurs the currently focused element
https://bugs.webkit.org/show_bug.cgi?id=16809
WebKit ports that do not use native (platform) widgets for rendering the scrollbars
are currently mismatching a common behaviour of other browser vendors (including
Firefox and Opera): clicking on a frame scrollbar *should not* steal focus from content.
WebKit browsers based ports that do use WebCore for handling scrollbars, like QtWebKit for
instance, can observe the opposite behaviour.
Patch fixes this behaviour by checking if current MouseDown event targets a frame scrollbar.
If that is the case, it bails out and do not change focus behavior at all.
It is important to note that the given way this is implemented by this patch, non-frame
scrollbars (e.g. a vertical scrollbar of an overflowed textareas or divs) will keep working
in the same way as it works currently.
Tests: scrollbars/scrollbar-click-does-not-blur-content.html
scrollbars/scrollbar-iframe-click-does-not-blur-content.html
* page/EventHandler.cpp:
(WebCore::EventHandler::dispatchMouseEvent):
2010-04-28 Dan Bernstein <mitz@apple.com>
Rubber-stamped by Maciej Stachowiak.
......@@ -1803,8 +1803,15 @@ bool EventHandler::dispatchMouseEvent(const AtomicString& eventType, Node* targe
if (m_nodeUnderMouse)
swallowEvent = m_nodeUnderMouse->dispatchMouseEvent(mouseEvent, eventType, clickCount);
if (!swallowEvent && eventType == eventNames().mousedownEvent) {
// If clicking on a frame scrollbar, do not mess up with content focus.
if (FrameView* view = m_frame->view()) {
if (view->scrollbarAtPoint(mouseEvent.pos()))
return false;
}
// The layout needs to be up to date to determine if an element is focusable.
m_frame->document()->updateLayoutIgnorePendingStylesheets();
......
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