Bug 694913 Assume that user clicked on right most of a character if clicked character in composition string is zero-width r=roc+emk

This commit is contained in:
Masayuki Nakano 2011-10-26 11:10:43 +09:00
Родитель 331c9e69f1
Коммит 1e701c5bdd
1 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -2066,7 +2066,8 @@ nsIMM32Handler::ResolveIMECaretPos(nsIWidget* aReferenceWidget,
bool bool
nsIMM32Handler::OnMouseEvent(nsWindow* aWindow, LPARAM lParam, int aAction) nsIMM32Handler::OnMouseEvent(nsWindow* aWindow, LPARAM lParam, int aAction)
{ {
if (!sWM_MSIME_MOUSE || !mIsComposing) { if (!sWM_MSIME_MOUSE || !mIsComposing ||
!ShouldDrawCompositionStringOurselves()) {
return false; return false;
} }
@ -2090,8 +2091,18 @@ nsIMM32Handler::OnMouseEvent(nsWindow* aWindow, LPARAM lParam, int aAction)
ResolveIMECaretPos(aWindow, cursorRect, ResolveIMECaretPos(aWindow, cursorRect,
aWindow->GetTopLevelWindow(false), cursorInTopLevel); aWindow->GetTopLevelWindow(false), cursorInTopLevel);
PRInt32 cursorXInChar = cursorInTopLevel.x - charAtPt.mReply.mRect.x; PRInt32 cursorXInChar = cursorInTopLevel.x - charAtPt.mReply.mRect.x;
int positioning = cursorXInChar * 4 / charAtPt.mReply.mRect.width; // The event might hit to zero-width character, see bug 694913.
// The reason might be:
// * There are some zero-width characters are actually.
// * font-size is specified zero.
// But nobody reproduced this bug actually...
// We should assume that user clicked on right most of the zero-width
// character in such case.
int positioning = 1;
if (charAtPt.mReply.mRect.width > 0) {
positioning = cursorXInChar * 4 / charAtPt.mReply.mRect.width;
positioning = (positioning + 2) % 4; positioning = (positioning + 2) % 4;
}
int offset = charAtPt.mReply.mOffset - mCompositionStart; int offset = charAtPt.mReply.mOffset - mCompositionStart;
if (positioning < 2) { if (positioning < 2) {