From 6aba9a22d0057afca0aaece02a39c77b77b3cc72 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 2 Apr 2010 11:11:59 +0900 Subject: [PATCH] Bug 556458 Cannot select an item of google suggest by mouse click during composition of MS-IME r=roc --- content/events/src/nsContentEventHandler.cpp | 5 ++- .../window_composition_text_querycontent.xul | 35 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/content/events/src/nsContentEventHandler.cpp b/content/events/src/nsContentEventHandler.cpp index 0f545985d9af..bfb031e32935 100644 --- a/content/events/src/nsContentEventHandler.cpp +++ b/content/events/src/nsContentEventHandler.cpp @@ -788,7 +788,10 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent) nsLayoutUtils::GetEventCoordinatesRelativeTo(&eventOnRoot, rootFrame); 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. aEvent->mReply.mOffset = nsQueryContentEvent::NOT_FOUND; aEvent->mSucceeded = PR_TRUE; diff --git a/widget/tests/window_composition_text_querycontent.xul b/widget/tests/window_composition_text_querycontent.xul index 20378fcb042c..f909ffa142db 100644 --- a/widget/tests/window_composition_text_querycontent.xul +++ b/widget/tests/window_composition_text_querycontent.xul @@ -26,7 +26,8 @@

- +

Here is a text frame.
+

@@ -78,7 +79,7 @@ const nsIDOMWindowUtils = Components.interfaces.nsIDOMWindowUtils; const kIsWin = (navigator.platform.indexOf("Win") == 0); const kIsMac = (navigator.platform.indexOf("Mac") == 0); -function checkQueryContentResult(aResult, aMessage, aID) +function checkQueryContentResult(aResult, aMessage) { ok(aResult, aMessage + ": the result is null"); if (!aResult) { @@ -741,7 +742,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName) for (var i = 0; i < kTestingOffset.length; i++) { var textRect = synthesizeQueryTextRect(kTestingOffset[i], 1); if (!checkQueryContentResult(textRect, - "runCharAtPointTest (" + aTargetName + "): textRect", "i=" + i)) { + "runCharAtPointTest (" + aTargetName + "): textRect: i=" + i)) { continue; } @@ -753,7 +754,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName) var charAtPt1 = synthesizeCharAtPoint(textRect.left + 1, textRect.top + 1); if (checkQueryContentResult(charAtPt1, - "runCharAtPointTest (" + aTargetName + "): charAtPt1", "i=" + i)) { + "runCharAtPointTest (" + aTargetName + "): charAtPt1: i=" + i)) { ok(!charAtPt1.notFound, "runCharAtPointTest (" + aTargetName + "): charAtPt1 isn't found: i=" + i); if (!charAtPt1.notFound) { @@ -768,7 +769,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName) var charAtPt2 = synthesizeCharAtPoint(textRect.left + textRect.width - 2, textRect.top + textRect.height - 2); if (checkQueryContentResult(charAtPt2, - "runCharAtPointTest (" + aTargetName + "): charAtPt2", "i=" + i)) { + "runCharAtPointTest (" + aTargetName + "): charAtPt2: i=" + i)) { ok(!charAtPt2.notFound, "runCharAtPointTest (" + aTargetName + "): charAtPt2 isn't found: i=" + i); if (!charAtPt2.notFound) { @@ -783,7 +784,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName) var charAtPt3 = synthesizeCharAtPoint(textRect.left - 2, textRect.top + 1); if (checkQueryContentResult(charAtPt3, - "runCharAtPointTest (" + aTargetName + "): charAtPt3", "i=" + i)) { + "runCharAtPointTest (" + aTargetName + "): charAtPt3: i=" + i)) { is(charAtPt3.notFound, kLeftSideOffset[i] == kNone, kLeftSideOffset[i] == kNone ? "runCharAtPointTest (" + aTargetName + "): charAtPt3 is found: i=" + i : @@ -798,7 +799,7 @@ function runCharAtPointTest(aFocusedEditor, aTargetName) var charAtPt4 = synthesizeCharAtPoint(textRect.left + textRect.width + 1, textRect.top + textRect.height - 2); if (checkQueryContentResult(charAtPt4, - "runCharAtPointTest (" + aTargetName + "): charAtPt4", "i=" + i)) { + "runCharAtPointTest (" + aTargetName + "): charAtPt4: i=" + i)) { is(charAtPt4.notFound, kRightSideOffset[i] == kNone, kRightSideOffset[i] == kNone ? "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) { aFocusedEditor.value = ""; @@ -976,6 +996,7 @@ function runTest() { runCompositionTest(); runCharAtPointTest(textarea, "textarea in the document"); + runCharAtPointAtOutsideTest(); runFrameTest(); runPanelTest(); }