Package: firefox
Version: 1.5.dfsg+1.5.0.4-3
Severity: important
Tags: patch l10n

It is bug #271815 of mozilla.org, and is fixed in cvs trunk.
( https://bugzilla.mozilla.org/show_bug.cgi?id=271815 )

The file I attached is mozilla.org's official patch, which works great for
firefox 1.5 and later ones. The patch is clean, and does not slowdown firefox.

The bug #271815 is: Text cursor always points to a wrong place under
OverTheSpot mode. It is very annoying when typing CJKV characters.
(OnTheSpot mode has not this bug.)

Debian's official mozilla suite have applied an old version patch, which only
worked for firefox 1.0 and older. Firefox 1.5 and newer ones need this new
OverTheSpot patch.
(Mozilla.org's nightly builds, aka firefox 3.0a1, has applied this patch, and
 OverTheSpot works great.)

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-1-k7
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages firefox depends on:
ii  debianutils                 2.17         Miscellaneous utilities specific t
ii  fontconfig                  2.3.2-7      generic font configuration library
ii  libatk1.0-0                 1.12.1-1     The ATK accessibility toolkit
ii  libc6                       2.3.6-15     GNU C Library: Shared libraries
ii  libcairo2                   1.2.0-3      The Cairo 2D vector graphics libra
ii  libfontconfig1              2.3.2-7      generic font configuration library
ii  libfreetype6                2.2.1-2      FreeType 2 font engine, shared lib
ii  libgcc1                     1:4.1.1-9    GCC support library
ii  libglib2.0-0                2.10.3-3     The GLib library of C routines
ii  libgtk2.0-0                 2.8.18-1     The GTK+ graphical user interface 
ii  libidl0                     0.8.6-1      library for parsing CORBA IDL file
ii  libjpeg62                   6b-13        The Independent JPEG Group's JPEG 
ii  libpango1.0-0               1.12.3-1+b1  Layout and rendering of internatio
ii  libpng12-0                  1.2.8rel-5.2 PNG library - runtime
ii  libstdc++6                  4.1.1-9      The GNU Standard C++ Library v3
ii  libx11-6                    2:1.0.0-7    X11 client-side library
ii  libxft2                     2.1.8.2-8    FreeType-based font drawing librar
ii  libxinerama1                1:1.0.1-4    X11 Xinerama extension library
ii  libxp6                      1:1.0.0-1    X Printing Extension (Xprint) clie
ii  libxt6                      1:1.0.0-5    X11 toolkit intrinsics library
ii  psmisc                      22.2-1       Utilities that use the proc filesy
ii  zlib1g                      1:1.2.3-13   compression library - runtime

firefox recommends no packages.

-- no debconf information
Index: editor/libeditor/text/nsPlaintextEditor.cpp
===================================================================
RCS file: /cvsroot/mozilla/editor/libeditor/text/nsPlaintextEditor.cpp,v
retrieving revision 1.95
diff -u -8 -p -w -r1.95 nsPlaintextEditor.cpp
--- editor/libeditor/text/nsPlaintextEditor.cpp	1 May 2006 05:25:49 -0000	1.95
+++ editor/libeditor/text/nsPlaintextEditor.cpp	19 Jun 2006 08:32:58 -0000
@@ -1538,35 +1538,52 @@ nsPlaintextEditor::GetEmbeddedObjects(ns
 #pragma mark -
 #pragma mark  nsIEditorIMESupport overrides 
 #pragma mark -
 #endif
 
 NS_IMETHODIMP
 nsPlaintextEditor::SetCompositionString(const nsAString& aCompositionString, nsIPrivateTextRangeList* aTextRangeList,nsTextEventReply* aReply)
 {
-  NS_ASSERTION(aTextRangeList, "null ptr");
-  if (!aTextRangeList)
-    return NS_ERROR_NULL_POINTER;
-
-  // workaround for windows ime bug 23558: we get every ime event twice. 
-  // for escape keypress, this causes an empty string to be passed
-  // twice, which freaks out the editor.  This is to detect and avoid that
-  // situation:
-  if (aCompositionString.IsEmpty() && !mIMETextNode) 
+  if (!aTextRangeList && !aCompositionString.IsEmpty())
   {
-    return NS_OK;
+    NS_ERROR("aTextRangeList is null but the composition string is not null");
+    return NS_ERROR_NULL_POINTER;
   }
   
-  mIMETextRangeList = aTextRangeList;
-
   nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
   if (!ps) 
     return NS_ERROR_NOT_INITIALIZED;
 
+  nsCOMPtr<nsISelection> selection;
+  nsresult result = GetSelection(getter_AddRefs(selection));
+  if (NS_FAILED(result)) return result;
+
+  nsCOMPtr<nsICaret>  caretP;
+  ps->GetCaret(getter_AddRefs(caretP));
+
+  // We should return caret position if it is possible. Because this event
+  // dispatcher always expects to be returned the correct caret position.
+  // But in following cases, we don't need to process the composition string,
+  // so, we only need to return the caret position.
+
+  // aCompositionString.IsEmpty() && !mIMETextNode:
+  //   Workaround for Windows IME bug 23558: We get every IME event twice.
+  //   For escape keypress, this causes an empty string to be passed
+  //   twice, which freaks out the editor.
+
+  // aCompositionString.IsEmpty() && !aTextRangeList:
+  //   Some Chinese IMEs for Linux are always composition string and text range
+  //   list are empty when listing the Chinese characters. In this case,
+  //   we don't need to process composition string too. See bug 271815.
+
+  if (!aCompositionString.IsEmpty() || (mIMETextNode && aTextRangeList))
+  {
+    mIMETextRangeList = aTextRangeList;
+
   // XXX_kin: BEGIN HACK! HACK! HACK!
   // XXX_kin:
   // XXX_kin: This is lame! The IME stuff needs caret coordinates
   // XXX_kin: synchronously, but the editor could be using async
   // XXX_kin: updates (reflows and paints) for performance reasons.
   // XXX_kin: In order to give IME what it needs, we have to temporarily
   // XXX_kin: switch to sync updating during this call so that the
   // XXX_kin: nsAutoPlaceHolderBatch can force sync reflows, paints,
@@ -1574,64 +1591,60 @@ nsPlaintextEditor::SetCompositionString(
   // XXX_kin: caret coordinates.
 
   PRUint32 flags = 0;
   PRBool restoreFlags = PR_FALSE;
 
   if (NS_SUCCEEDED(GetFlags(&flags)) &&
      (flags & nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))
   {
-    if (NS_SUCCEEDED(SetFlags(flags & (~nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))))
+      if (NS_SUCCEEDED(SetFlags(
+          flags & (~nsIPlaintextEditor::eEditorUseAsyncUpdatesMask))))
        restoreFlags = PR_TRUE;
   }
 
   // XXX_kin: END HACK! HACK! HACK!
 
-  nsCOMPtr<nsISelection> selection;
-  nsresult result = GetSelection(getter_AddRefs(selection));
-  if (NS_FAILED(result)) return result;
-
-  nsCOMPtr<nsICaret>  caretP;
-  
   // we need the nsAutoPlaceHolderBatch destructor called before hitting
   // GetCaretCoordinates so the states in Frame system sync with content
   // therefore, we put the nsAutoPlaceHolderBatch into a inner block
   {
     nsAutoPlaceHolderBatch batch(this, gIMETxnName);
 
     SetIsIMEComposing(); // We set mIsIMEComposing properly.
 
     result = InsertText(aCompositionString);
 
     mIMEBufferLength = aCompositionString.Length();
 
-    ps->GetCaret(getter_AddRefs(caretP));
     if (caretP)
       caretP->SetCaretDOMSelection(selection);
 
     // second part of 23558 fix:
     if (aCompositionString.IsEmpty()) 
-    {
       mIMETextNode = nsnull;
     }
-  }
 
   // XXX_kin: BEGIN HACK! HACK! HACK!
   // XXX_kin:
   // XXX_kin: Restore the previous set of flags!
 
   if (restoreFlags)
     SetFlags(flags);
 
   // XXX_kin: END HACK! HACK! HACK!
+  }
 
   if (caretP)
   {
-    result = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates, selection,
-              &(aReply->mCursorPosition), &(aReply->mCursorIsCollapsed), nsnull);
+    result = caretP->GetCaretCoordinates(nsICaret::eIMECoordinates,
+                                         selection,
+                                         &(aReply->mCursorPosition),
+                                         &(aReply->mCursorIsCollapsed),
+                                         nsnull);
     NS_ASSERTION(NS_SUCCEEDED(result), "cannot get caret position");
   }
   
   return result;
 }
 
 NS_IMETHODIMP 
 nsPlaintextEditor::GetReconversionString(nsReconversionEventReply* aReply)

Reply via email to