Bug 556458 Cannot select an item of google suggest by mouse click during composition of MS-IME r=roc

This commit is contained in:
Masayuki Nakano 2010-04-02 11:11:59 +09:00
parent 2b60b98a59
commit 6aba9a22d0
2 changed files with 32 additions and 8 deletions

View file

@ -788,7 +788,10 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent)
nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame); nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame);
nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot); nsIFrame* targetFrame = nsLayoutUtils::GetFrameForPoint(rootFrame, ptInRoot);
if (!targetFrame || targetFrame->GetType() != nsGkAtoms::textFrame) { if (!targetFrame || targetFrame->GetType() != nsGkAtoms::textFrame ||
!targetFrame->GetContent() ||
!nsContentUtils::ContentIsDescendantOf(targetFrame->GetContent(),
mRootContent)) {
// there is no character at the point. // there is no character at the point.
aEvent->mReply.mOffset = nsQueryContentEvent::NOT_FOUND; aEvent->mReply.mOffset = nsQueryContentEvent::NOT_FOUND;
aEvent->mSucceeded = PR_TRUE; aEvent->mSucceeded = PR_TRUE;

View file

@ -26,7 +26,8 @@
<body xmlns="http://www.w3.org/1999/xhtml"> <body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"> <p id="display">
<textarea id="textarea" cols="20" rows="4"></textarea> <div style="margin: 0; padding: 0; font-size: 24px;">Here is a text frame.</div>
<textarea style="margin: 0;" id="textarea" cols="20" rows="4"></textarea><br/>
<iframe id="iframe" width="300" height="150" <iframe id="iframe" width="300" height="150"
src="data:text/html,&lt;textarea id='textarea' cols='20' rows='4'&gt;&lt;/textarea&gt;"></iframe> src="data:text/html,&lt;textarea id='textarea' cols='20' rows='4'&gt;&lt;/textarea&gt;"></iframe>
</p> </p>
@ -78,7 +79,7 @@ const nsIDOMWindowUtils = Components.interfaces.nsIDOMWindowUtils;
const kIsWin = (navigator.platform.indexOf("Win") == 0); const kIsWin = (navigator.platform.indexOf("Win") == 0);
const kIsMac = (navigator.platform.indexOf("Mac") == 0); const kIsMac = (navigator.platform.indexOf("Mac") == 0);
function checkQueryContentResult(aResult, aMessage, aID) function checkQueryContentResult(aResult, aMessage)
{ {
ok(aResult, aMessage + ": the result is null"); ok(aResult, aMessage + ": the result is null");
if (!aResult) { if (!aResult) {
@ -741,7 +742,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName)
for (var i = 0; i < kTestingOffset.length; i++) { for (var i = 0; i < kTestingOffset.length; i++) {
var textRect = synthesizeQueryTextRect(kTestingOffset[i], 1); var textRect = synthesizeQueryTextRect(kTestingOffset[i], 1);
if (!checkQueryContentResult(textRect, if (!checkQueryContentResult(textRect,
"runCharAtPointTest (" + aTargetName + "): textRect", "i=" + i)) { "runCharAtPointTest (" + aTargetName + "): textRect: i=" + i)) {
continue; continue;
} }
@ -753,7 +754,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName)
var charAtPt1 = synthesizeCharAtPoint(textRect.left + 1, var charAtPt1 = synthesizeCharAtPoint(textRect.left + 1,
textRect.top + 1); textRect.top + 1);
if (checkQueryContentResult(charAtPt1, if (checkQueryContentResult(charAtPt1,
"runCharAtPointTest (" + aTargetName + "): charAtPt1", "i=" + i)) { "runCharAtPointTest (" + aTargetName + "): charAtPt1: i=" + i)) {
ok(!charAtPt1.notFound, ok(!charAtPt1.notFound,
"runCharAtPointTest (" + aTargetName + "): charAtPt1 isn't found: i=" + i); "runCharAtPointTest (" + aTargetName + "): charAtPt1 isn't found: i=" + i);
if (!charAtPt1.notFound) { if (!charAtPt1.notFound) {
@ -768,7 +769,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName)
var charAtPt2 = synthesizeCharAtPoint(textRect.left + textRect.width - 2, var charAtPt2 = synthesizeCharAtPoint(textRect.left + textRect.width - 2,
textRect.top + textRect.height - 2); textRect.top + textRect.height - 2);
if (checkQueryContentResult(charAtPt2, if (checkQueryContentResult(charAtPt2,
"runCharAtPointTest (" + aTargetName + "): charAtPt2", "i=" + i)) { "runCharAtPointTest (" + aTargetName + "): charAtPt2: i=" + i)) {
ok(!charAtPt2.notFound, ok(!charAtPt2.notFound,
"runCharAtPointTest (" + aTargetName + "): charAtPt2 isn't found: i=" + i); "runCharAtPointTest (" + aTargetName + "): charAtPt2 isn't found: i=" + i);
if (!charAtPt2.notFound) { if (!charAtPt2.notFound) {
@ -783,7 +784,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName)
var charAtPt3 = synthesizeCharAtPoint(textRect.left - 2, var charAtPt3 = synthesizeCharAtPoint(textRect.left - 2,
textRect.top + 1); textRect.top + 1);
if (checkQueryContentResult(charAtPt3, if (checkQueryContentResult(charAtPt3,
"runCharAtPointTest (" + aTargetName + "): charAtPt3", "i=" + i)) { "runCharAtPointTest (" + aTargetName + "): charAtPt3: i=" + i)) {
is(charAtPt3.notFound, kLeftSideOffset[i] == kNone, is(charAtPt3.notFound, kLeftSideOffset[i] == kNone,
kLeftSideOffset[i] == kNone ? kLeftSideOffset[i] == kNone ?
"runCharAtPointTest (" + aTargetName + "): charAtPt3 is found: i=" + i : "runCharAtPointTest (" + aTargetName + "): charAtPt3 is found: i=" + i :
@ -798,7 +799,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName)
var charAtPt4 = synthesizeCharAtPoint(textRect.left + textRect.width + 1, var charAtPt4 = synthesizeCharAtPoint(textRect.left + textRect.width + 1,
textRect.top + textRect.height - 2); textRect.top + textRect.height - 2);
if (checkQueryContentResult(charAtPt4, if (checkQueryContentResult(charAtPt4,
"runCharAtPointTest (" + aTargetName + "): charAtPt4", "i=" + i)) { "runCharAtPointTest (" + aTargetName + "): charAtPt4: i=" + i)) {
is(charAtPt4.notFound, kRightSideOffset[i] == kNone, is(charAtPt4.notFound, kRightSideOffset[i] == kNone,
kRightSideOffset[i] == kNone ? kRightSideOffset[i] == kNone ?
"runCharAtPointTest (" + aTargetName + "): charAtPt4 is found: i=" + i : "runCharAtPointTest (" + aTargetName + "): charAtPt4 is found: i=" + i :
@ -811,6 +812,25 @@ function runCharAtPointTest(aFocusedEditor, aTargetName)
} }
} }
function runCharAtPointAtOutsideTest()
{
textarea.focus();
textarea.value = "some text";
var editorRect = synthesizeQueryEditorRect();
if (!checkQueryContentResult(editorRect,
"runCharAtPointAtOutsideTest: editorRect")) {
return;
}
// Check on a text node which is at the outside of editor.
var charAtPt = synthesizeCharAtPoint(editorRect.left + 20,
editorRect.top - 10);
if (checkQueryContentResult(charAtPt,
"runCharAtPointAtOutsideTest: charAtPt")) {
ok(charAtPt.notFound,
"runCharAtPointAtOutsideTest: charAtPt is found on outside of editor");
}
}
function runTestOnAnotherContext(aPanelOrFrame, aFocusedEditor, aTestName) function runTestOnAnotherContext(aPanelOrFrame, aFocusedEditor, aTestName)
{ {
aFocusedEditor.value = ""; aFocusedEditor.value = "";
@ -976,6 +996,7 @@ function runTest()
{ {
runCompositionTest(); runCompositionTest();
runCharAtPointTest(textarea, "textarea in the document"); runCharAtPointTest(textarea, "textarea in the document");
runCharAtPointAtOutsideTest();
runFrameTest(); runFrameTest();
runPanelTest(); runPanelTest();
} }