Commit 6b60a145 authored by eric@webkit.org's avatar eric@webkit.org

2009-08-12 Xiaomei Ji <xji@chromium.org>

        Reviewed by Eric Seidel.

        Fix [Chromium] drop down menu letter selection, skip selections
        https://bugs.webkit.org/show_bug.cgi?id=28205

        Not auto-testable since it is chromim platform specific code, and it involves sending a keyboard
        event to the popup, which is not possible (eventSender sends the key
        events through webview, we want to go through the webwidget).

        * manual-tests/keyboard_select_elements_with_same_beginning.html: Added.
        * platform/chromium/PopupMenuChromium.cpp:
        (WebCore::isCharacterTypeEvent): style change.
        (WebCore::PopupListBox::handleKeyEvent): typeAheadFind should be called only when the event is
        a character type event to avoid calling twice for English.
        (WebCore::PopupListBox::typeAheadFind): remove unnecessary checking of isCharacterTypeEvent() since the whole function is only called under that condition.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 97df5422
2009-08-12 Xiaomei Ji <xji@chromium.org>
Reviewed by Eric Seidel.
Fix [Chromium] drop down menu letter selection, skip selections
https://bugs.webkit.org/show_bug.cgi?id=28205
Not auto-testable since it is chromim platform specific code, and it involves sending a keyboard
event to the popup, which is not possible (eventSender sends the key
events through webview, we want to go through the webwidget).
* manual-tests/keyboard_select_elements_with_same_beginning.html: Added.
* platform/chromium/PopupMenuChromium.cpp:
(WebCore::isCharacterTypeEvent): style change.
(WebCore::PopupListBox::handleKeyEvent): typeAheadFind should be called only when the event is
a character type event to avoid calling twice for English.
(WebCore::PopupListBox::typeAheadFind): remove unnecessary checking of isCharacterTypeEvent() since the whole function is only called under that condition.
2009-08-12 Maxime Simon <simon.maxime@gmail.com>
Reviewed by Eric Seidel.
<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">
<title>
Test select on elements with same beginning letter
</title>
</head>
<body>
See bug:<a href="https://bugs.webkit.org/show_bug.cgi?id=28205">28205</a>.
<p>
Click the drop-down to show selections (not navigate to the selection box).
Type the first letter 'A' to go to the elements start with 'A'.
It should select the first item starts with 'A'.
In windows, Continue typing 'A', it should continue to select the next item starts with 'A'.
<p>
<select name="selOrigin">
<option value="">Select Station</option>
<option value="37169_NJCL">Aberdeen Matawan</option>
<option value="2_ATLC">Absecon</option>
<option value="3_MNBN">Allendale</option>
<option value="4_NJCL">Allenhurst</option>
<option value="12_MNE">Basking Ridge</option>
<option value="13_NJCL">Bay Head</option>
<option value="14_BNTN">Bay Street</option>
<option value="15_NJCL">Belmar</option>
</select>
</body>
</html>
......@@ -601,6 +601,22 @@ bool PopupListBox::isInterestedInEventForKey(int keyCode)
}
}
static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event)
{
// Check whether the event is a character-typed event or not.
// In Windows, PlatformKeyboardEvent::Char (not RawKeyDown) type event
// is considered as character type event. In Mac OS, KeyDown (not
// KeyUp) is considered as character type event.
#if PLATFORM(WIN_OS)
if (event.type() == PlatformKeyboardEvent::Char)
return true;
#else
if (event.type() == PlatformKeyboardEvent::KeyDown)
return true;
#endif
return false;
}
bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event)
{
if (event.type() == PlatformKeyboardEvent::KeyUp)
......@@ -641,7 +657,8 @@ bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event)
break;
default:
if (!event.ctrlKey() && !event.altKey() && !event.metaKey()
&& isPrintableChar(event.windowsVirtualKeyCode()))
&& isPrintableChar(event.windowsVirtualKeyCode())
&& isCharacterTypeEvent(event))
typeAheadFind(event);
break;
}
......@@ -690,21 +707,6 @@ static String stripLeadingWhiteSpace(const String& string)
return string.substring(i, length - i);
}
static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event) {
// Check whether the event is a character-typed event or not.
// In Windows, PlatformKeyboardEvent::Char (not RawKeyDown) type event
// is considered as character type event. In Mac OS, KeyDown (not
// KeyUp) is considered as character type event.
#if PLATFORM(WIN_OS)
if (event.type() == PlatformKeyboardEvent::Char)
return true;
#else
if (event.type() == PlatformKeyboardEvent::KeyDown)
return true;
#endif
return false;
}
// From HTMLSelectElement.cpp, with modifications
void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event)
{
......@@ -714,8 +716,7 @@ void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event)
// Reset the time when user types in a character. The time gap between
// last character and the current character is used to indicate whether
// user typed in a string or just a character as the search prefix.
if (isCharacterTypeEvent(event))
m_lastCharTime = now;
m_lastCharTime = now;
UChar c = event.windowsVirtualKeyCode();
......
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