mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 849438 - Searches in ListControlFrames should ignore . r=bz
This commit is contained in:
parent
8135a7145c
commit
d15e867cca
@ -334,6 +334,12 @@ public:
|
||||
*/
|
||||
static bool IsHTMLWhitespace(PRUnichar aChar);
|
||||
|
||||
/*
|
||||
* Returns whether the character is an HTML whitespace (see IsHTMLWhitespace)
|
||||
* or a nbsp character (U+00A0).
|
||||
*/
|
||||
static bool IsHTMLWhitespaceOrNBSP(PRUnichar aChar);
|
||||
|
||||
/**
|
||||
* Is the HTML local name a block element?
|
||||
*/
|
||||
|
@ -1199,6 +1199,13 @@ nsContentUtils::IsHTMLWhitespace(PRUnichar aChar)
|
||||
aChar == PRUnichar(0x0020);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
nsContentUtils::IsHTMLWhitespaceOrNBSP(PRUnichar aChar)
|
||||
{
|
||||
return IsHTMLWhitespace(aChar) || aChar == PRUnichar(0xA0);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
nsContentUtils::IsHTMLBlock(nsIAtom* aLocalName)
|
||||
@ -2158,6 +2165,9 @@ nsContentUtils::TrimWhitespace<nsCRT::IsAsciiSpace>(const nsAString&, bool);
|
||||
template
|
||||
const nsDependentSubstring
|
||||
nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(const nsAString&, bool);
|
||||
template
|
||||
const nsDependentSubstring
|
||||
nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespaceOrNBSP>(const nsAString&, bool);
|
||||
|
||||
static inline void KeyAppendSep(nsACString& aKey)
|
||||
{
|
||||
|
@ -2465,28 +2465,32 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||
startIndex++;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < numOptions; i++) {
|
||||
for (uint32_t i = 0; i < numOptions; ++i) {
|
||||
uint32_t index = (i + startIndex) % numOptions;
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement =
|
||||
GetOption(options, index);
|
||||
if (optionElement) {
|
||||
nsAutoString text;
|
||||
if (NS_OK == optionElement->GetText(text)) {
|
||||
if (StringBeginsWith(text, incrementalString,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
bool wasChanged = PerformSelection(index, isShift, isControl);
|
||||
if (wasChanged) {
|
||||
// dispatch event, update combobox, etc.
|
||||
if (!UpdateSelection()) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLOptionElement> optionElement = GetOption(options, index);
|
||||
if (!optionElement) {
|
||||
continue;
|
||||
}
|
||||
} // for
|
||||
|
||||
nsAutoString text;
|
||||
if (NS_FAILED(optionElement->GetText(text)) ||
|
||||
!StringBeginsWith(nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespaceOrNBSP>(text, false),
|
||||
incrementalString,
|
||||
nsCaseInsensitiveStringComparator())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!PerformSelection(index, isShift, isControl)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// If UpdateSelection() returns false, that means the frame is no longer
|
||||
// alive. We should stop doing anything.
|
||||
if (!UpdateSelection()) {
|
||||
return NS_OK;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} break;//case
|
||||
} // switch
|
||||
|
@ -44,6 +44,7 @@ MOCHITEST_FILES = test_bug231389.html \
|
||||
test_bug644542.html \
|
||||
test_bug672810.html \
|
||||
test_bug704049.html \
|
||||
test_listcontrol_search.html \
|
||||
$(NULL)
|
||||
|
||||
MOCHITEST_CHROME_FILES = \
|
||||
|
46
layout/forms/test/test_listcontrol_search.html
Normal file
46
layout/forms/test/test_listcontrol_search.html
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=849438
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for <select> list control search</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** This test will focus a select element and press a key that matches the
|
||||
first non-space character of an entry. **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(function() {
|
||||
var select = document.getElementsByTagName('select')[0];
|
||||
select.focus();
|
||||
synthesizeKey('a', {});
|
||||
|
||||
is(select.options[0].selected, false, "the first option isn't selected");
|
||||
is(select.options[1].selected, true, "the second option is selected");
|
||||
|
||||
select.blur();
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=849438">Mozilla Bug 849438</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<select>
|
||||
<option>Please select an entry</option>
|
||||
<option> a</option>
|
||||
<option> b</option>
|
||||
</select>
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -268,6 +268,7 @@
|
||||
"layout/forms/test/test_bug644542.html": "TIMED_OUT",
|
||||
"layout/forms/test/test_bug672810.html": "",
|
||||
"layout/forms/test/test_textarea_resize.html": "",
|
||||
"layout/forms/test/test_listcontrol_search.html": "select elements don't use an in-page popup on Android",
|
||||
"layout/generic/test/test_bug496275.html": "CRASH_DUMP",
|
||||
"layout/generic/test/test_bug503813.html": "CRASH_DUMP",
|
||||
"layout/generic/test/test_bug514732.html": "CRASH_DUMP",
|
||||
|
@ -468,6 +468,7 @@
|
||||
"layout/forms/test/test_bug644542.html" : "",
|
||||
"layout/forms/test/test_bug672810.html" : "",
|
||||
"layout/forms/test/test_bug704049.html" : "",
|
||||
"layout/forms/test/test_listcontrol_search.html" : "select elements don't use an in-page popup in B2G",
|
||||
"layout/generic/test/test_bug240933.html" : "",
|
||||
"layout/generic/test/test_bug263683.html" : "",
|
||||
"layout/generic/test/test_bug290397.html" : "",
|
||||
|
Loading…
Reference in New Issue
Block a user