Bug 545059: Remove unneeded/non-working bidi.controlstextmode pref. r=smontagu
authorJonas Sicking <jonas@sicking.cc>
Wed, 24 Feb 2010 21:58:17 -0800
changeset 38676 3250b548e80df921aae22a35e97bb50aca6b8655
parent 38675 a3805f7d1cca7bd485a8a35798ecb56deeb784e1
child 38677 ffe5fb50ba377249f1c6f95e8cc213bb0b78d2fe
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs545059
milestone1.9.3a2pre
Bug 545059: Remove unneeded/non-working bidi.controlstextmode pref. r=smontagu
content/html/content/public/nsIFormSubmission.h
content/html/content/src/nsFormSubmission.cpp
docshell/base/nsIMarkupDocumentViewer.idl
intl/unicharutil/util/nsBidiUtils.cpp
intl/unicharutil/util/nsBidiUtils.h
layout/base/nsDocumentViewer.cpp
layout/base/nsPresContext.cpp
layout/generic/nsBlockFrame.cpp
modules/libpref/src/init/all.js
--- a/content/html/content/public/nsIFormSubmission.h
+++ b/content/html/content/public/nsIFormSubmission.h
@@ -97,45 +97,32 @@ public:
     aCharset = mCharset;
   }
 
 protected:
   /**
    * Can only be constructed by subclasses.
    *
    * @param aCharset the charset of the form as a string
-   * @param aBidiOptions the BIDI options flags for the current pres context
    */
-  nsFormSubmission(const nsACString& aCharset,
-                   PRInt32 aBidiOptions);
+  nsFormSubmission(const nsACString& aCharset);
 
   /**
    * Encode a Unicode string to bytes using the encoder (or just copy the input
    * if there is no encoder).
    * @param aStr the string to encode
    * @param aResult the encoded string [OUT]
    * @throws an error if UnicodeToNewBytes fails
    */
   nsresult EncodeVal(const nsAString& aStr, nsACString& aResult);
 
-  /**
-   * Encode a Unicode string to bytes using an encoder.  (Used by EncodeVal)
-   * @param aStr the string to encode
-   * @param aEncoder the encoder to encode the bytes with (cannot be null)
-   * @param aOut the encoded string [OUT] 
-   * @throws an error if the encoder fails
-   */
-  nsresult UnicodeToNewBytes(const nsAString& aStr, nsACString& aOut);
-
   // The name of the encoder charset
   nsCString mCharset;
   // The encoder that will encode Unicode names and values
   nsCOMPtr<nsISaveAsCharset> mEncoder;
-  // The BIDI options flags for the current pres context
-  PRInt32 mBidiOptions;
 };
 
 
 /**
  * Get a submission object based on attributes in the form (ENCTYPE and METHOD)
  *
  * @param aForm the form to get a submission object based on
  * @param aFormSubmission the form submission object (out param)
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -66,17 +66,16 @@
 #include "nsIMultiplexInputStream.h"
 #include "nsIMIMEInputStream.h"
 #include "nsIMIMEService.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIFileStreams.h"
-#include "nsBidiUtils.h"
 
 static void
 SendJSWarning(nsIDocument* aDocument,
               const char* aWarningName,
               const PRUnichar** aWarningArgs, PRUint32 aWarningArgsLen)
 {
   nsContentUtils::ReportToConsole(nsContentUtils::eFORMS_PROPERTIES,
                                   aWarningName,
@@ -90,25 +89,23 @@ SendJSWarning(nsIDocument* aDocument,
 
 // --------------------------------------------------------------------------
 
 class nsFSURLEncoded : public nsFormSubmission
 {
 public:
   /**
    * @param aCharset the charset of the form as a string
-   * @param aBidiOptions the BIDI options flags for the current pres context
    * @param aMethod the method of the submit (either NS_FORM_METHOD_GET or
    *        NS_FORM_METHOD_POST).
    */
   nsFSURLEncoded(const nsACString& aCharset,
-                 PRInt32 aBidiOptions,
                  PRInt32 aMethod,
                  nsIDocument* aDocument)
-    : nsFormSubmission(aCharset, aBidiOptions),
+    : nsFormSubmission(aCharset),
       mMethod(aMethod),
       mDocument(aDocument),
       mWarnedFileControl(PR_FALSE)
   {
   }
 
   virtual nsresult AddNameValuePair(const nsAString& aName,
                                     const nsAString& aValue);
@@ -386,20 +383,18 @@ nsFSURLEncoded::URLEncode(const nsAStrin
  * Handle multipart/form-data encoding, which does files as well as normal
  * inputs.  This always does POST.
  */
 class nsFSMultipartFormData : public nsFormSubmission
 {
 public:
   /**
    * @param aCharset the charset of the form as a string
-   * @param aBidiOptions the BIDI options flags for the current pres context
    */
-  nsFSMultipartFormData(const nsACString& aCharset,
-                        PRInt32 aBidiOptions);
+  nsFSMultipartFormData(const nsACString& aCharset);
  
   virtual nsresult AddNameValuePair(const nsAString& aName,
                                     const nsAString& aValue);
   virtual nsresult AddNameFilePair(const nsAString& aName,
                                    nsIFile* aFile);
   virtual nsresult GetEncodedSubmission(nsIURI* aURI,
                                         nsIInputStream** aPostDataStream);
 
@@ -430,19 +425,18 @@ private:
   /**
    * The boundary string to use after each "part" (the boundary that marks the
    * end of a value).  This is computed randomly and is different for each
    * submission.
    */
   nsCString mBoundary;
 };
 
-nsFSMultipartFormData::nsFSMultipartFormData(const nsACString& aCharset,
-                                             PRInt32 aBidiOptions)
-    : nsFormSubmission(aCharset, aBidiOptions)
+nsFSMultipartFormData::nsFSMultipartFormData(const nsACString& aCharset)
+    : nsFormSubmission(aCharset)
 {
   mPostDataStream =
     do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1");
 
   mBoundary.AssignLiteral("---------------------------");
   mBoundary.AppendInt(rand());
   mBoundary.AppendInt(rand());
   mBoundary.AppendInt(rand());
@@ -615,19 +609,18 @@ nsFSMultipartFormData::AddPostDataStream
   return rv;
 }
 
 // --------------------------------------------------------------------------
 
 class nsFSTextPlain : public nsFormSubmission
 {
 public:
-  nsFSTextPlain(const nsACString& aCharset,
-                PRInt32 aBidiOptions)
-    : nsFormSubmission(aCharset, aBidiOptions)
+  nsFSTextPlain(const nsACString& aCharset)
+    : nsFormSubmission(aCharset)
   {
   }
 
   virtual nsresult AddNameValuePair(const nsAString& aName,
                                     const nsAString& aValue);
   virtual nsresult AddNameFilePair(const nsAString& aName,
                                    nsIFile* aFile);
   virtual nsresult GetEncodedSubmission(nsIURI* aURI,
@@ -712,20 +705,18 @@ nsFSTextPlain::GetEncodedSubmission(nsIU
     CallQueryInterface(mimeStream, aPostDataStream);
   }
 
   return rv;
 }
 
 // --------------------------------------------------------------------------
 
-nsFormSubmission::nsFormSubmission(const nsACString& aCharset,
-                                   PRInt32 aBidiOptions)
-  : mCharset(aCharset),
-    mBidiOptions(aBidiOptions)
+nsFormSubmission::nsFormSubmission(const nsACString& aCharset)
+  : mCharset(aCharset)
 {
   MOZ_COUNT_CTOR(nsFormSubmission);
 
   nsCAutoString charset(aCharset);
   // canonical name is passed so that we just have to check against
   // *our* canonical names listed in charsetaliases.properties
   if (charset.EqualsLiteral("ISO-8859-1")) {
     charset.AssignLiteral("windows-1252");
@@ -753,94 +744,34 @@ nsFormSubmission::nsFormSubmission(const
 
 nsFormSubmission::~nsFormSubmission()
 {
   MOZ_COUNT_DTOR(nsFormSubmission);
 }
 
 // i18n helper routines
 nsresult
-nsFormSubmission::UnicodeToNewBytes(const nsAString& aStr,
-                                    nsACString& aOut)
-{
-  PRUint8 ctrlsModAtSubmit = GET_BIDI_OPTION_CONTROLSTEXTMODE(mBidiOptions);
-  PRUint8 textDirAtSubmit = GET_BIDI_OPTION_DIRECTION(mBidiOptions);
-  //ahmed 15-1
-  nsAutoString newBuffer;
-  //This condition handle the RTL,LTR for a logical file
-  if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_VISUAL
-     && mCharset.Equals(NS_LITERAL_CSTRING("windows-1256"),
-                        nsCaseInsensitiveCStringComparator())) {
-    Conv_06_FE_WithReverse(nsString(aStr),
-                           newBuffer,
-                           textDirAtSubmit);
-  }
-  else if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_LOGICAL
-          && mCharset.Equals(NS_LITERAL_CSTRING("IBM864"),
-                             nsCaseInsensitiveCStringComparator())) {
-    //For 864 file, When it is logical, if LTR then only convert
-    //If RTL will mak a reverse for the buffer
-    Conv_FE_06(nsString(aStr), newBuffer);
-    if (textDirAtSubmit == 2) { //RTL
-    //Now we need to reverse the Buffer, it is by searching the buffer
-      PRInt32 len = newBuffer.Length();
-      PRUint32 z = 0;
-      nsAutoString temp;
-      temp.SetLength(len);
-      while (--len >= 0)
-        temp.SetCharAt(newBuffer.CharAt(len), z++);
-      newBuffer = temp;
-    }
-  }
-  else if (ctrlsModAtSubmit == IBMBIDI_CONTROLSTEXTMODE_VISUAL
-          && mCharset.Equals(NS_LITERAL_CSTRING("IBM864"),
-                             nsCaseInsensitiveCStringComparator())
-                  && textDirAtSubmit == IBMBIDI_TEXTDIRECTION_RTL) {
-
-    Conv_FE_06(nsString(aStr), newBuffer);
-    //Now we need to reverse the Buffer, it is by searching the buffer
-    PRInt32 len = newBuffer.Length();
-    PRUint32 z = 0;
-    nsAutoString temp;
-    temp.SetLength(len);
-    while (--len >= 0)
-      temp.SetCharAt(newBuffer.CharAt(len), z++);
-    newBuffer = temp;
-  }
-  else {
-    newBuffer = aStr;
-  }
-
-  nsXPIDLCString res;
-  if (!newBuffer.IsEmpty()) {
-    aOut.Truncate();
-    nsresult rv = mEncoder->Convert(newBuffer.get(), getter_Copies(res));
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  aOut = res;
-  return NS_OK;
-}
-
-nsresult
 nsFormSubmission::EncodeVal(const nsAString& aStr, nsACString& aOut)
 {
-  if (mEncoder)
-    return UnicodeToNewBytes(aStr, aOut);
+  if (mEncoder) {
+    aOut.Truncate();
+    return aStr.IsEmpty() ? NS_OK :
+           mEncoder->Convert(PromiseFlatString(aStr).get(),
+                             getter_Copies(aOut));
+  }
 
   // fall back to UTF-8
   CopyUTF16toUTF8(aStr, aOut);
   return NS_OK;
 }
 
 // --------------------------------------------------------------------------
 
 static void
 GetSubmitCharset(nsGenericHTMLElement* aForm,
-                 PRUint8 aCtrlsModAtSubmit,
                  nsACString& oCharset)
 {
   oCharset.AssignLiteral("UTF-8"); // default to utf-8
 
   nsresult rv = NS_OK;
   nsAutoString acceptCharsetValue;
   aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset,
                  acceptCharsetValue);
@@ -872,37 +803,16 @@ GetSubmitCharset(nsGenericHTMLElement* a
     }
   }
   // if there are no accept-charset or all the charset are not supported
   // Get the charset from document
   nsIDocument* doc = aForm->GetDocument();
   if (doc) {
     oCharset = doc->GetDocumentCharacterSet();
   }
-
-  if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL
-     && oCharset.Equals(NS_LITERAL_CSTRING("windows-1256"),
-                        nsCaseInsensitiveCStringComparator())) {
-    oCharset.AssignLiteral("IBM864");
-  }
-  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_LOGICAL
-          && oCharset.Equals(NS_LITERAL_CSTRING("IBM864"),
-                             nsCaseInsensitiveCStringComparator())) {
-    oCharset.AssignLiteral("IBM864i");
-  }
-  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL
-          && oCharset.Equals(NS_LITERAL_CSTRING("ISO-8859-6"),
-                             nsCaseInsensitiveCStringComparator())) {
-    oCharset.AssignLiteral("IBM864");
-  }
-  else if (aCtrlsModAtSubmit==IBMBIDI_CONTROLSTEXTMODE_VISUAL
-          && oCharset.Equals(NS_LITERAL_CSTRING("UTF-8"),
-                             nsCaseInsensitiveCStringComparator())) {
-    oCharset.AssignLiteral("IBM864");
-  }
 }
 
 static void
 GetEnumAttr(nsGenericHTMLElement* aContent,
             nsIAtom* atom, PRInt32* aValue)
 {
   const nsAttrValue* value = aContent->GetParsedAttr(atom);
   if (value && value->Type() == nsAttrValue::eEnum) {
@@ -913,48 +823,43 @@ GetEnumAttr(nsGenericHTMLElement* aConte
 nsresult
 GetSubmissionFromForm(nsGenericHTMLElement* aForm,
                       nsFormSubmission** aFormSubmission)
 {
   // Get all the information necessary to encode the form data
   nsIDocument* doc = aForm->GetCurrentDoc();
   NS_ASSERTION(doc, "Should have doc if we're building submission!");
 
-  // Get BIDI options
-  PRUint8 ctrlsModAtSubmit = 0;
-  PRUint32 bidiOptions = doc->GetBidiOptions();
-  ctrlsModAtSubmit = GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions);
-
   // Get encoding type (default: urlencoded)
   PRInt32 enctype = NS_FORM_ENCTYPE_URLENCODED;
   GetEnumAttr(aForm, nsGkAtoms::enctype, &enctype);
 
   // Get method (default: GET)
   PRInt32 method = NS_FORM_METHOD_GET;
   GetEnumAttr(aForm, nsGkAtoms::method, &method);
 
   // Get charset
   nsCAutoString charset;
-  GetSubmitCharset(aForm, ctrlsModAtSubmit, charset);
+  GetSubmitCharset(aForm, charset);
 
   // Choose encoder
   if (method == NS_FORM_METHOD_POST &&
       enctype == NS_FORM_ENCTYPE_MULTIPART) {
-    *aFormSubmission = new nsFSMultipartFormData(charset, bidiOptions);
+    *aFormSubmission = new nsFSMultipartFormData(charset);
   } else if (method == NS_FORM_METHOD_POST &&
              enctype == NS_FORM_ENCTYPE_TEXTPLAIN) {
-    *aFormSubmission = new nsFSTextPlain(charset, bidiOptions);
+    *aFormSubmission = new nsFSTextPlain(charset);
   } else {
     if (enctype == NS_FORM_ENCTYPE_MULTIPART ||
         enctype == NS_FORM_ENCTYPE_TEXTPLAIN) {
       nsAutoString enctypeStr;
       aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::enctype, enctypeStr);
       const PRUnichar* enctypeStrPtr = enctypeStr.get();
       SendJSWarning(aForm->GetOwnerDoc(), "ForgotPostWarning",
                     &enctypeStrPtr, 1);
     }
-    *aFormSubmission = new nsFSURLEncoded(charset, bidiOptions,
-                                          method, aForm->GetOwnerDoc());
+    *aFormSubmission = new nsFSURLEncoded(charset, method,
+                                          aForm->GetOwnerDoc());
   }
   NS_ENSURE_TRUE(*aFormSubmission, NS_ERROR_OUT_OF_MEMORY);
 
   return NS_OK;
 }
--- a/docshell/base/nsIMarkupDocumentViewer.idl
+++ b/docshell/base/nsIMarkupDocumentViewer.idl
@@ -47,17 +47,17 @@
  * for a markup document - HTML or XML
  */
 
 #include "nsISupports.idl"
 
 interface nsIDOMNode;
 
 
-[scriptable, uuid(40b2282a-a882-4483-a634-dec468d88377)]
+[scriptable, uuid(19187542-1f4d-46e1-9b2d-d5de02dace85)]
 interface nsIMarkupDocumentViewer : nsISupports
 {
 
 	/*
 	Scrolls to a given DOM content node. 
 	*/
 	void scrollToNode(in nsIDOMNode node);
 
@@ -121,24 +121,16 @@ interface nsIMarkupDocumentViewer : nsIS
    * Bidi Algorithm. Visual text will be displayed without reordering. 
    *               1 - the default order for the charset
    *               2 - logical order
    *               3 - visual order
    */
   attribute octet bidiTextType;
 
   /**
-   * bidiControlsTextMode: the order of bidirectional text in form controls.
-   *                       1 - logical
-   *                       2 - visual
-   *                       3 - like the containing document
-   */
-  attribute octet bidiControlsTextMode;
-
-  /**
    * bidiNumeral: the type of numerals to display. 
    *              1 - depending on context, default is Arabic numerals
    *              2 - depending on context, default is Hindi numerals
    *              3 - Arabic numerals
    *              4 - Hindi numerals
    */
   attribute octet bidiNumeral;
 
--- a/intl/unicharutil/util/nsBidiUtils.cpp
+++ b/intl/unicharutil/util/nsBidiUtils.cpp
@@ -40,224 +40,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #include "nsBidiUtils.h"
 #include "symmtable.h"
 #include "bidicattable.h"
 #include "nsCharTraits.h"
 
-#define FE_TO_06_OFFSET 0xfe70
-
-static const PRUnichar FE_TO_06 [][2] = {
-    {0x064b,0x0000},{0x064b,0x0640},{0x064c,0x0000},
-    {0x0000,0x0000},{0x064d,0x0000},{0x0000,0x0000},
-    {0x064e,0x0000},{0x064e,0x0640},{0x064f,0x0000},
-    {0x064f,0x0640},{0x0650,0x0000},{0x0650,0x0640},
-    {0x0651,0x0000},{0x0651,0x0640},{0x0652,0x0000},
-    {0x0652,0x0640},{0x0621,0x0000},{0x0622,0x0000},
-    {0x0622,0x0000},{0x0623,0x0000},{0x0623,0x0000},
-    {0x0624,0x0000},{0x0624,0x0000},{0x0625,0x0000},
-    {0x0625,0x0000},{0x0626,0x0000},{0x0626,0x0000},
-    {0x0626,0x0000},{0x0626,0x0000},{0x0627,0x0000},
-    {0x0627,0x0000},{0x0628,0x0000},{0x0628,0x0000},
-    {0x0628,0x0000},{0x0628,0x0000},{0x0629,0x0000},
-    {0x0629,0x0000},{0x062a,0x0000},{0x062a,0x0000},
-    {0x062a,0x0000},{0x062a,0x0000},{0x062b,0x0000},
-    {0x062b,0x0000},{0x062b,0x0000},{0x062b,0x0000},
-    {0x062c,0x0000},{0x062c,0x0000},{0x062c,0x0000},
-    {0x062c,0x0000},{0x062d,0x0000},{0x062d,0x0000},
-    {0x062d,0x0000},{0x062d,0x0000},{0x062e,0x0000},
-    {0x062e,0x0000},{0x062e,0x0000},{0x062e,0x0000},
-    {0x062f,0x0000},{0x062f,0x0000},{0x0630,0x0000},
-    {0x0630,0x0000},{0x0631,0x0000},{0x0631,0x0000},
-    {0x0632,0x0000},{0x0632,0x0000},{0x0633,0x0000},
-    {0x0633,0x0000},{0x0633,0x0000},{0x0633,0x0000},
-    {0x0634,0x0000},{0x0634,0x0000},{0x0634,0x0000},
-    {0x0634,0x0000},{0x0635,0x0000},{0x0635,0x0000},
-    {0x0635,0x0000},{0x0635,0x0000},{0x0636,0x0000},
-    {0x0636,0x0000},{0x0636,0x0000},{0x0636,0x0000},
-    {0x0637,0x0000},{0x0637,0x0000},{0x0637,0x0000},
-    {0x0637,0x0000},{0x0638,0x0000},{0x0638,0x0000},
-    {0x0638,0x0000},{0x0638,0x0000},{0x0639,0x0000},
-    {0x0639,0x0000},{0x0639,0x0000},{0x0639,0x0000},
-    {0x063a,0x0000},{0x063a,0x0000},{0x063a,0x0000},
-    {0x063a,0x0000},{0x0641,0x0000},{0x0641,0x0000},
-    {0x0641,0x0000},{0x0641,0x0000},{0x0642,0x0000},
-    {0x0642,0x0000},{0x0642,0x0000},{0x0642,0x0000},
-    {0x0643,0x0000},{0x0643,0x0000},{0x0643,0x0000},
-    {0x0643,0x0000},{0x0644,0x0000},{0x0644,0x0000},
-    {0x0644,0x0000},{0x0644,0x0000},{0x0645,0x0000},
-    {0x0645,0x0000},{0x0645,0x0000},{0x0645,0x0000},
-    {0x0646,0x0000},{0x0646,0x0000},{0x0646,0x0000},
-    {0x0646,0x0000},{0x0647,0x0000},{0x0647,0x0000},
-    {0x0647,0x0000},{0x0647,0x0000},{0x0648,0x0000},
-    {0x0648,0x0000},{0x0649,0x0000},{0x0649,0x0000},
-    {0x064a,0x0000},{0x064a,0x0000},{0x064a,0x0000},
-    {0x064a,0x0000},{0x0644,0x0622},{0x0644,0x0622},
-    {0x0644,0x0623},{0x0644,0x0623},{0x0644,0x0625},
-    {0x0644,0x0625},{0x0644,0x0627},{0x0644,0x0627}
-};
-
-static const PRUnichar FB_TO_06 [] = {
-    0x0671,0x0671,0x067B,0x067B,0x067B,0x067B,0x067E,0x067E, //FB50-FB57
-    0x067E,0x067E,0x0680,0x0680,0x0680,0x0680,0x067A,0x067A, //FB58-FB5F
-    0x067A,0x067A,0x067F,0x067F,0x067F,0x067F,0x0679,0x0679, //FB60-FB67
-    0x0679,0x0679,0x06A4,0x06A4,0x06A4,0x06A4,0x06A6,0x06A6, //FB68-FB6F
-    0x06A6,0x06A6,0x0684,0x0684,0x0684,0x0684,0x0683,0x0683, //FB70-FB77
-    0x0683,0x0683,0x0686,0x0686,0x0686,0x0686,0x0687,0x0687, //FB78-FB7F
-    0x0687,0x0687,0x068D,0x068D,0x068C,0x068C,0x068E,0x068E, //FB80-FB87
-    0x0688,0x0688,0x0698,0x0698,0x0691,0x0691,0x06A9,0x06A9, //FB88-FB8F
-    0x06A9,0x06A9,0x06AF,0x06AF,0x06AF,0x06AF,0x06B3,0x06B3, //FB90-FB97
-    0x06B3,0x06B3,0x06B1,0x06B1,0x06B1,0x06B1,0x06BA,0x06BA, //FB98-FB9F
-    0x06BB,0x06BB,0x06BB,0x06BB,0x06C0,0x06C0,0x06C1,0x06C1, //FBA0-FBA7
-    0x06C1,0x06C1,0x06BE,0x06BE,0x06BE,0x06BE,0x06D2,0x06D2, //FBA8-FBAF
-    0x06D3,0x06D3,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBB0-FBB7
-    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBB8-FBBF
-    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBC0-FBC7
-    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBC8-FBCF
-    0x0000,0x0000,0x0000,0x06AD,0x06AD,0x06AD,0x06AD,0x06C7, //FBD0-FBD7
-    0x06C7,0x06C6,0x06C6,0x06C8,0x06C8,0x0677,0x06CB,0x06CB, //FBD8-FBDF
-    0x06C5,0x06C5,0x06C9,0x06C9,0x06D0,0x06D0,0x06D0,0x06D0, //FBE0-FBE7
-    0x0649,0x0649,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBE8-FBEF
-    0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, //FBF0-FBF7
-    0x0000,0x0000,0x0000,0x0000,0x06CC,0x06CC,0x06CC,0x06CC  //FBF8-FBFF
-};
-
-#define PresentationToOriginal(c, order)                  \
-    (((0xFE70 <= (c) && (c) <= 0xFEFC)) ?                 \
-         FE_TO_06[(c)- FE_TO_06_OFFSET][order] :                    \
-     (((0xFB50 <= (c) && (c) <= 0xFBFF) && (order) == 0) ? \
-         FB_TO_06[(c)-0xFB50] : (PRUnichar) 0x0000))
-
-//============ Begin Arabic Basic to Presentation Form B Code ============
-// Note: the following code are moved from gfx/src/windows/nsRenderingContextWin.cpp
-static const PRUint8 gArabicMap1[] = {
-            0x81, 0x83, 0x85, 0x87, 0x89, 0x8D, // 0622-0627
-0x8F, 0x93, 0x95, 0x99, 0x9D, 0xA1, 0xA5, 0xA9, // 0628-062F
-0xAB, 0xAD, 0xAF, 0xB1, 0xB5, 0xB9, 0xBD, 0xC1, // 0630-0637
-0xC5, 0xC9, 0xCD                                // 0638-063A
-};
-
-static const PRUint8 gArabicMap2[] = {
-      0xD1, 0xD5, 0xD9, 0xDD, 0xE1, 0xE5, 0xE9, // 0641-0647
-0xED, 0xEF, 0xF1                                // 0648-064A
-};
-
-static const PRUint8 gArabicMapEx[] = {
-      0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0671-0677
-0x00, 0x66, 0x5E, 0x52, 0x00, 0x00, 0x56, 0x62, // 0678-067F
-0x5A, 0x00, 0x00, 0x76, 0x72, 0x00, 0x7A, 0x7E, // 0680-0687
-0x88, 0x00, 0x00, 0x00, 0x84, 0x82, 0x86, 0x00, // 0688-068F
-0x00, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0690-0697
-0x8A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0698-069F
-0x00, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x6E, 0x00, // 06A0-06A7
-0x00, 0x8E, 0x00, 0x00, 0x00, 0xD3, 0x00, 0x92, // 06A8-06AF
-0x00, 0x9A, 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, // 06B0-06B7
-0x00, 0x00, 0x9E, 0xA0, 0x00, 0x00, 0xAA, 0x00, // 06B8-06BF
-0xA4, 0xA6, 0x00, 0x00, 0x00, 0xE0, 0xD9, 0xD7, // 06C0-06C7
-0xDB, 0xE2, 0x00, 0xDE, 0xFC, 0x00, 0x00, 0x00, // 06C8-06CF
-0xE4, 0x00, 0xAE, 0xB0                          // 06D0-06D3
-};
-
-#define PresentationFormB(c, form)                                       \
-    (((0x0622<=(c)) && ((c)<=0x063A)) ?                                  \
-      (0xFE00|(gArabicMap1[(c)-0x0622] + (form))) :                      \
-       (((0x0641<=(c)) && ((c)<=0x064A)) ?                               \
-        (0xFE00|(gArabicMap2[(c)-0x0641] + (form))) :                    \
-         (((0x0671<=(c)) && ((c))<=0x06D3) && gArabicMapEx[(c)-0x0671]) ? \
-          (0xFB00|(gArabicMapEx[(c)-0x0671] + (form))) : (c)))
-
-typedef enum {
-   eIsolated,  // or Char N
-   eFinal,     // or Char R
-   eInitial,   // or Char L
-   eMedial     // or Char M
-} eArabicForm;
-
-typedef enum {
-   eTr = 0, // Transparent
-   eRJ = 1, // Right-Joining
-   eLJ = 2, // Left-Joining
-   eDJ = 3, // Dual-Joining
-   eNJ = 4, // Non-Joining
-   eJC = 7, // Joining Causing
-   eRightJCMask = 2, // bit of Right-Join Causing 
-   eLeftJCMask = 1   // bit of Left-Join Causing 
-} eArabicJoiningClass;
-
-#define RightJCClass(j) (eRightJCMask&(j))
-#define LeftJCClass(j)  (eLeftJCMask&(j))
-
-#define DecideForm(jl,j,jr)                                 \
-  (((eRJ == (j)) && RightJCClass(jr)) ? eFinal              \
-                                      :                     \
-   ((eDJ == (j)) ?                                          \
-    ((RightJCClass(jr)) ?                                   \
-     (((LeftJCClass(jl)) ? eMedial                          \
-                         : eFinal))                         \
-                        :                                   \
-     (((LeftJCClass(jl)) ? eInitial                         \
-                         : eIsolated))                      \
-    )                     : eIsolated))                     \
-
-// All letters without an equivalen in the FB50 block are 'eNJ' here. This
-// should be fixed after finding some better mechanism for handling Arabic.
-static const PRInt8 gJoiningClass[] = {
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0600-0607
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0608-060F
-eTr, eTr, eTr, eTr, eTr, eTr, eNJ, eNJ, // 0610-0617
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0618-061F
-eNJ, eNJ, eRJ, eRJ, eRJ, eRJ, eDJ, eRJ, // 0620-0627
-eDJ, eRJ, eDJ, eDJ, eDJ, eDJ, eDJ, eRJ, // 0628-062F
-eRJ, eRJ, eRJ, eDJ, eDJ, eDJ, eDJ, eDJ, // 0630-0637
-eDJ, eDJ, eDJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0638-063F
-eJC, eDJ, eDJ, eDJ, eDJ, eDJ, eDJ, eDJ, // 0640-0647
-eRJ, eDJ, eDJ, eTr, eTr, eTr, eTr, eTr, // 0648-064F
-eTr, eTr, eTr, eTr, eTr, eTr, eTr, eTr, // 0650-0657
-eTr, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0658-065F
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0660-0667
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0668-066F
-eTr, eRJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0670-0677
-eNJ, eDJ, eDJ, eDJ, eNJ, eNJ, eDJ, eDJ, // 0678-067F
-eDJ, eNJ, eNJ, eDJ, eDJ, eNJ, eDJ, eDJ, // 0680-0687
-eRJ, eNJ, eNJ, eNJ, eRJ, eRJ, eRJ, eNJ, // 0688-068F
-eNJ, eRJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0690-0697
-eRJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 0698-069F
-eNJ, eNJ, eNJ, eNJ, eDJ, eNJ, eDJ, eNJ, // 06A0-06A7
-eNJ, eDJ, eNJ, eNJ, eNJ, eDJ, eNJ, eDJ, // 06A8-06AF
-eNJ, eDJ, eNJ, eDJ, eNJ, eNJ, eNJ, eNJ, // 06B0-06B7
-eNJ, eNJ, eDJ, eDJ, eNJ, eNJ, eDJ, eNJ, // 06B8-06BF
-eRJ, eDJ, eNJ, eNJ, eNJ, eRJ, eRJ, eRJ, // 06C0-06C7
-eRJ, eRJ, eNJ, eRJ, eDJ, eNJ, eNJ, eNJ, // 06C8-06CF
-eDJ, eNJ, eRJ, eRJ, eNJ, eNJ, eTr, eTr, // 06D0-06D7
-eTr, eTr, eTr, eTr, eTr, eNJ, eNJ, eTr, // 06D8-06DF
-eTr, eTr, eTr, eTr, eTr, eNJ, eNJ, eTr, // 06E0-06E7
-eTr, eNJ, eTr, eTr, eTr, eTr, eNJ, eNJ, // 06E8-06EF
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, // 06F0-06F7
-eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ, eNJ  // 06F8-06FF
-};
-
-#define GetJoiningClass(c)                   \
-  ((IS_ARABIC_CHAR(c)) ?                     \
-      (gJoiningClass[(c) - 0x0600]) :        \
-      ((0x200D == (c)) ? eJC : eTr))
-
-static const PRUint16 gArabicLigatureMap[] = 
-{
-0x82DF, // 0xFE82 0xFEDF -> 0xFEF5
-0x82E0, // 0xFE82 0xFEE0 -> 0xFEF6
-0x84DF, // 0xFE84 0xFEDF -> 0xFEF7
-0x84E0, // 0xFE84 0xFEE0 -> 0xFEF8
-0x88DF, // 0xFE88 0xFEDF -> 0xFEF9
-0x88E0, // 0xFE88 0xFEE0 -> 0xFEFA
-0x8EDF, // 0xFE8E 0xFEDF -> 0xFEFB
-0x8EE0  // 0xFE8E 0xFEE0 -> 0xFEFC
-};
-
 static nsCharType ebc2ucd[15] = {
   eCharType_OtherNeutral, /* Placeholder -- there will never be a 0 index value */
   eCharType_LeftToRight,
   eCharType_RightToLeft,
   eCharType_RightToLeftArabic,
   eCharType_ArabicNumber,
   eCharType_EuropeanNumber,
   eCharType_EuropeanNumberSeparator,
@@ -296,274 +88,16 @@ static nsCharType cc2ucd[5] = {
      (c)))
 #define NUM_TO_PERSIAN(c) \
   ((((c)>=START_HINDI_DIGITS) && ((c)<=END_HINDI_DIGITS)) ? \
    ((c) - (PRUint16)PERSIAN_TO_HINDI_DIGIT_INCREMENT) : \
    ((((c)>=START_ARABIC_DIGITS) && ((c)<=END_ARABIC_DIGITS)) ? \
     ((c) + (PRUint16)ARABIC_TO_PERSIAN_DIGIT_INCREMENT) : \
      (c)))
 
-// helper function to reverse a PRUnichar buffer
-static void ReverseString(PRUnichar* aBuffer, PRUint32 aLen)
-{
-  PRUnichar *start, *end;
-  PRUnichar swapChar;
-
-  for (start = aBuffer, end = aBuffer + aLen - 1; start < end; ++start, --end) {
-    swapChar = *start;
-    *start = *end;
-    *end = swapChar;
-  }
-}
-
-nsresult ArabicShaping(const PRUnichar* aString, PRUint32 aLen,
-                       PRUnichar* aBuf, PRUint32 *aBufLen, 
-                       PRBool aInputLogical, PRBool aOutputLogical)
-{
-  nsAutoString tempString(aString, aLen);
-  if (tempString.Length() != aLen)
-    return NS_ERROR_OUT_OF_MEMORY;
-  PRUnichar *tempBuf = tempString.BeginWriting();
-  if (aInputLogical) {
-    ReverseString(tempBuf, aLen);
-  }
-  const PRUnichar* src = tempBuf;
-  const PRUnichar* p;
-  PRUnichar* dest = aBuf;
-  PRUnichar formB;
-  PRInt8 leftJ, thisJ, rightJ;
-  PRInt8 leftNoTrJ, rightNoTrJ;
-  thisJ = leftNoTrJ = eNJ;
-  rightJ = GetJoiningClass(*(src));
-  while(src<tempBuf+aLen-1) {
-    leftJ = thisJ;
-
-    if ((eTr != leftJ) || ((leftJ == eTr) && 
-        ( ( (src-1) >= tempBuf) && !IS_ARABIC_CHAR(*(src-1)))))
-      leftNoTrJ = thisJ;
-
-    if(src-2 >= (tempBuf)){
-      for(p=src-2; (p >= (tempBuf))&& (eTr == leftNoTrJ) && (IS_ARABIC_CHAR(*(p+1))) ; p--)  
-        leftNoTrJ = GetJoiningClass(*(p)) ;
-    }
-
-    thisJ = rightJ;
-    rightJ = rightNoTrJ = GetJoiningClass(*(src+1)) ;
-
-    if(src+2 <= (tempBuf+aLen-1)){
-      for(p=src+2; (p <= (tempBuf+aLen-1))&&(eTr == rightNoTrJ) && (IS_ARABIC_CHAR(*(src+1))); p++)
-        rightNoTrJ = GetJoiningClass(*(p)) ;
-    }
-
-    formB = PresentationFormB(*src, DecideForm(leftNoTrJ, thisJ, rightNoTrJ));
-    *dest++ = formB;
-    src++;
-
-  }
-  if((eTr != thisJ) || 
-     ((thisJ == eTr) && (((src-1)>=tempBuf) && (!IS_ARABIC_CHAR(*(src-1))))))
-    leftNoTrJ = thisJ;
-
-  if(src-2 >= (tempBuf)){
-    for(p=src-2; (src-2 >= (tempBuf)) && (eTr == leftNoTrJ) && (IS_ARABIC_CHAR(*(p+1))); p--)
-      leftNoTrJ = GetJoiningClass(*(p)) ;
-  }
-
-  formB = PresentationFormB(*src, DecideForm(leftNoTrJ, rightJ, eNJ));
-  *dest++ = formB;
-  src++;
-
-  PRUnichar *lSrc = aBuf;
-  PRUnichar *lDest = aBuf;
-  while(lSrc < (dest-1)) {
-    PRUnichar next = *(lSrc+1);
-    if(((0xFEDF == next) || (0xFEE0 == next)) && 
-       (0xFE80 == (0xFFF1 & *lSrc))) {
-      PRBool done = PR_FALSE;
-      PRUint16 key = ((*lSrc) << 8) | ( 0x00FF & next);
-      PRUint16 i;
-      for(i=0;i<8;i++) {
-        if(key == gArabicLigatureMap[i]) {
-          done = PR_TRUE;
-          // lam and alef in the source are mapped to a lam-alef ligature in the
-          // destination, so lSrc is incremented by 2 here
-          *lDest++ = 0xFEF5 + i;
-          lSrc+=2;
-          break;
-        }
-      }
-      if(! done)
-        *lDest++ = *lSrc++; 
-    } else if (0x200C == *lSrc || 0x200D == *lSrc)
-      // Strip zero-width joining controls ZWJ and ZWNJ from the shaped text
-      lSrc++;
-    else 
-      *lDest++ = *lSrc++; 
-
-  }
-  if(lSrc < dest)
-    *lDest++ = *lSrc++; 
-
-  *aBufLen = lDest - aBuf;
-  NS_ASSERTION(*aBufLen <= aLen, "ArabicShaping() likely did a buffer overflow!");
-
-  if (aOutputLogical) {
-    ReverseString(aBuf, *aBufLen);
-  }
-  return NS_OK;
-}
-
-nsresult Conv_FE_06(const nsString& aSrc, nsString& aDst)
-{
-  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
-  PRUint32 i, size = aSrc.Length();
-  aDst.Truncate();
-  for (i=0;i<size;i++) { // i : Source
-    if (aSrcUnichars[i] == 0x0000) 
-      break; // no need to convert char after the NULL
-    if (IS_FE_CHAR(aSrcUnichars[i])) {
-      //ahmed for lamalf
-      PRUnichar ch = (PresentationToOriginal(aSrcUnichars[i], 1));
-      if(ch)
-        aDst += ch;
-      ch=(PresentationToOriginal(aSrcUnichars[i], 0));
-      if(ch)
-        aDst += ch;
-      else //if it is 00, just output what we have in FExx
-        aDst += aSrcUnichars[i];
-    } else {
-      aDst += aSrcUnichars[i]; // copy it even if it is not in FE range
-    }
-  }// for : loop the buffer
-  return NS_OK;
-}
-
-nsresult Conv_FE_06_WithReverse(const nsString& aSrc, nsString& aDst)
-{
-  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
-  PRBool foundArabic = PR_FALSE;
-  PRUint32 i, endArabic, beginArabic, size;
-  beginArabic = 0;
-  size = aSrc.Length();
-  aDst.Truncate();
-  for (endArabic=0;endArabic<size;endArabic++) {
-    if (aSrcUnichars[endArabic] == 0x0000) 
-      break; // no need to convert char after the NULL
-
-    while( (IS_FE_CHAR(aSrcUnichars[endArabic]))||
-           (IS_ARABIC_CHAR(aSrcUnichars[endArabic]))||
-           (IS_ARABIC_DIGIT(aSrcUnichars[endArabic]))||
-           (aSrcUnichars[endArabic]==0x0020)) 
-    {
-      if(! foundArabic ) {
-        beginArabic=endArabic;
-        foundArabic= PR_TRUE;
-      }
-      endArabic++;
-    }
-    if(foundArabic) {
-      endArabic--;
-      for (i=endArabic; i>=beginArabic; i--) {
-        if(IS_FE_CHAR(aSrcUnichars[i])) {
-          //ahmed for the bug of lamalf
-          aDst += PresentationToOriginal(aSrcUnichars[i], 0);
-          if (PresentationToOriginal(aSrcUnichars[i], 1)) {
-            // Two characters, we have to resize the buffer :(
-             aDst += PresentationToOriginal(aSrcUnichars[i], 1);
-          } // if expands to 2 char
-        } else {
-          // do we need to check the following if ?
-          if((IS_ARABIC_CHAR(aSrcUnichars[i]))||
-             (IS_ARABIC_DIGIT(aSrcUnichars[i]))||
-             (aSrcUnichars[i]==0x0020))
-            aDst += aSrcUnichars[i];
-        }     
-      }
-    } else {
-      aDst += aSrcUnichars[endArabic]; 
-    }
-    foundArabic=PR_FALSE;
-  }// for : loop the buffer
-  return NS_OK;
-}
-
-nsresult Conv_06_FE_WithReverse(const nsString& aSrc,
-                                nsString& aDst,
-                                PRUint32 aDir)
-{
-  PRUnichar *aSrcUnichars = (PRUnichar *)aSrc.get();
-  PRUint32 i, beginArabic, endArabic, size;
-  beginArabic = 0;
-  size = aSrc.Length();
-  aDst.Truncate();
-  PRBool foundArabic = PR_FALSE;
-  for (endArabic=0;endArabic<size;endArabic++) {
-    if (aSrcUnichars[endArabic] == 0x0000) 
-      break; // no need to convert char after the NULL
-
-    while( (IS_06_CHAR(aSrcUnichars[endArabic])) || 
-           (IS_ARABIC_CHAR(aSrcUnichars[endArabic])) || 
-           (aSrcUnichars[endArabic]==0x0020) || 
-           (IS_ARABIC_DIGIT(aSrcUnichars[endArabic]))  ) 
-    {
-      if(! foundArabic) {
-        beginArabic=endArabic;
-        foundArabic=PR_TRUE;
-      }
-      endArabic++;
-    }
-    if(foundArabic) {
-      endArabic--;
-      PRUnichar buf[8192];
-      PRUint32 len=8192;
-
-      ArabicShaping(&aSrcUnichars[beginArabic], endArabic-beginArabic+1,
-                    buf, &len, 
-                    PR_TRUE, PR_FALSE);
-      // to reverse the numerals
-      PRUint32 endNumeral, beginNumeral = 0;
-      for (endNumeral=0;endNumeral<=len-1;endNumeral++){
-        PRBool foundNumeral = PR_FALSE;
-        while((endNumeral < len) && (IS_ARABIC_DIGIT(buf[endNumeral]))  ) {
-          if(!foundNumeral)
-          {
-            foundNumeral=PR_TRUE;
-            beginNumeral=endNumeral;
-          }
-          endNumeral++;
-        }
-        if(foundNumeral){
-          endNumeral--;
-          PRUnichar numbuf[20];
-          for(i=beginNumeral; i<=endNumeral; i++){
-            numbuf[i-beginNumeral]=buf[endNumeral-i+beginNumeral];
-          }
-          for(i=0;i<=endNumeral-beginNumeral;i++){
-            buf[i+beginNumeral]=numbuf[i];
-          }
-        }
-      }
-      if(aDir==1){//ltr
-        for (i=0;i<=len-1;i++){
-          aDst+= buf[i];
-        } 
-      }
-      else if(aDir==2){//rtl
-        for (i=0;i<=len-1;i++){
-          aDst+= buf[len-1-i];
-        } 
-      }
-    } else {
-      aDst += aSrcUnichars[endArabic];
-    }
-    foundArabic=PR_FALSE;
-  }// for : loop the buffer
-  return NS_OK;
-}
-
 PRUnichar HandleNumberInChar(PRUnichar aChar, PRBool aPrevCharArabic, PRUint32 aNumFlag)
 {
   // IBMBIDI_NUMERAL_NOMINAL *
   // IBMBIDI_NUMERAL_REGULAR
   // IBMBIDI_NUMERAL_HINDICONTEXT
   // IBMBIDI_NUMERAL_ARABIC
   // IBMBIDI_NUMERAL_HINDI
 
--- a/intl/unicharutil/util/nsBidiUtils.h
+++ b/intl/unicharutil/util/nsBidiUtils.h
@@ -112,56 +112,16 @@ typedef enum nsCharType nsCharType;
 
 #define CHARTYPE_IS_RTL(val) ( ( (val) == eCharType_RightToLeft) || ( (val) == eCharType_RightToLeftArabic) )
 
 #define CHARTYPE_IS_WEAK(val) ( ( (val) == eCharType_EuropeanNumberSeparator)    \
                            || ( (val) == eCharType_EuropeanNumberTerminator) \
                            || ( ( (val) > eCharType_ArabicNumber) && ( (val) != eCharType_RightToLeftArabic) ) )
 
   /**
-   * Perform Arabic shaping on a Unichar string
-   * @param aString is the input string
-   * @param aLen is the length of aStrong
-   * @param aBuf receives the shaped output
-   * @param aBuflen receives the length of aBuf
-   * @param aInputLogical indicates that the input is in logical order
-   * @param aOutputLogical indicates that the output should be in logical order
-   */
-  nsresult ArabicShaping(const PRUnichar* aString, PRUint32 aLen,
-                         PRUnichar* aBuf, PRUint32* aBufLen,
-                         PRBool aInputLogical, PRBool aOutputLogical);
-
-  /**
-   * Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx
-   * range
-   * @param aSrc is the input string
-   * @param aDst is the output string
-   */
-  nsresult Conv_FE_06(const nsString& aSrc, nsString& aDst);
-
-  /**
-   * Scan an nsString, converting characters in the FExx range (Arabic presentation forms) to the equivalent characters in the 06xx
-   * range, and also reverse the string
-   * @param aSrc is the input string
-   * @param aDst is the output string
-   */
-  nsresult Conv_FE_06_WithReverse(const nsString& aSrc, nsString& aDst);
-
-  /**
-   * Scan an nsString, converting characters in the 06xx range to the equivalent characters in the 0Fxx range (Arabic presentation
-   * forms), with the option to reverse the string
-   * @param aSrc is the input string
-   * @param aDst is the output string
-   * @param aDir indicates whether the string should be reversed
-   *        IBMBIDI_TEXTDIRECTION_LTR: do not reverse the string
-   *        IBMBIDI_TEXTDIRECTION_RTL: reverse the string
-   */
-  nsresult Conv_06_FE_WithReverse(const nsString& aSrc, nsString& aDst, PRUint32 aDir);
-
-  /**
    * Inspects a Unichar, converting numbers to Arabic or Hindi forms and returning them
    * @param aChar is the character
    * @param aPrevCharArabic is true if the previous character in the string is an Arabic char
    * @param aNumFlag specifies the conversion to perform:
    *        IBMBIDI_NUMERAL_NOMINAL:      don't do any conversion
    *        IBMBIDI_NUMERAL_HINDI:        convert to Hindi forms (Unicode 0660-0669)
    *        IBMBIDI_NUMERAL_ARABIC:       convert to Arabic forms (Unicode 0030-0039)
    *        IBMBIDI_NUMERAL_HINDICONTEXT: convert numbers in Arabic text to Hindi, otherwise to Arabic
@@ -224,24 +184,22 @@ typedef enum nsCharType nsCharType;
 //  ------------------
 //  If Pref values are to be changed
 //  in the XUL file of Prefs. the values
 //  Must be changed here too..
 //  ------------------
 //
 #define IBMBIDI_TEXTDIRECTION_STR       "bidi.direction"
 #define IBMBIDI_TEXTTYPE_STR            "bidi.texttype"
-#define IBMBIDI_CONTROLSTEXTMODE_STR    "bidi.controlstextmode"
 #define IBMBIDI_NUMERAL_STR             "bidi.numeral"
 #define IBMBIDI_SUPPORTMODE_STR         "bidi.support"
 #define IBMBIDI_CHARSET_STR             "bidi.characterset"
 
 #define IBMBIDI_TEXTDIRECTION       1
 #define IBMBIDI_TEXTTYPE            2
-#define IBMBIDI_CONTROLSTEXTMODE    3
 #define IBMBIDI_NUMERAL             4
 #define IBMBIDI_SUPPORTMODE         5
 #define IBMBIDI_CHARSET             6
 
 //  ------------------
 //  Text Direction
 //  ------------------
 //  bidi.direction
@@ -250,23 +208,16 @@ typedef enum nsCharType nsCharType;
 //  ------------------
 //  Text Type
 //  ------------------
 //  bidi.texttype
 #define IBMBIDI_TEXTTYPE_CHARSET      1 //  1 = charsettexttypeBidi *
 #define IBMBIDI_TEXTTYPE_LOGICAL      2 //  2 = logicaltexttypeBidi
 #define IBMBIDI_TEXTTYPE_VISUAL       3 //  3 = visualtexttypeBidi
 //  ------------------
-//  Controls Text Mode
-//  ------------------
-//  bidi.controlstextmode
-#define IBMBIDI_CONTROLSTEXTMODE_LOGICAL   1 //  1 = logicalcontrolstextmodeBidiCmd *
-#define IBMBIDI_CONTROLSTEXTMODE_VISUAL    2 //  2 = visualcontrolstextmodeBidi
-#define IBMBIDI_CONTROLSTEXTMODE_CONTAINER 3 //  3 = containercontrolstextmodeBidi
-//  ------------------
 //  Numeral Style
 //  ------------------
 //  bidi.numeral
 #define IBMBIDI_NUMERAL_NOMINAL       0 //  0 = nominalnumeralBidi *
 #define IBMBIDI_NUMERAL_REGULAR       1 //  1 = regularcontextnumeralBidi
 #define IBMBIDI_NUMERAL_HINDICONTEXT  2 //  2 = hindicontextnumeralBidi
 #define IBMBIDI_NUMERAL_ARABIC        3 //  3 = arabicnumeralBidi
 #define IBMBIDI_NUMERAL_HINDI         4 //  4 = hindinumeralBidi
@@ -284,35 +235,32 @@ typedef enum nsCharType nsCharType;
 //  ------------------
 //  bidi.characterset
 #define IBMBIDI_CHARSET_BIDI        1 //  1 = doccharactersetBidi *
 #define IBMBIDI_CHARSET_DEFAULT     2 //  2 = defaultcharactersetBidi
 
 #define IBMBIDI_DEFAULT_BIDI_OPTIONS              \
         ((IBMBIDI_TEXTDIRECTION_LTR<<0)         | \
          (IBMBIDI_TEXTTYPE_CHARSET<<4)          | \
-         (IBMBIDI_CONTROLSTEXTMODE_LOGICAL<<8)  | \
-         (IBMBIDI_NUMERAL_NOMINAL<<12)          | \
-         (IBMBIDI_SUPPORTMODE_MOZILLA<<16)      | \
-         (IBMBIDI_CHARSET_BIDI<<20))
+         (IBMBIDI_NUMERAL_NOMINAL<<8)          | \
+         (IBMBIDI_SUPPORTMODE_MOZILLA<<12)      | \
+         (IBMBIDI_CHARSET_BIDI<<16))
 
 
 #define GET_BIDI_OPTION_DIRECTION(bo) (((bo)>>0) & 0x0000000F) /* 4 bits for DIRECTION */
 #define GET_BIDI_OPTION_TEXTTYPE(bo) (((bo)>>4) & 0x0000000F) /* 4 bits for TEXTTYPE */
-#define GET_BIDI_OPTION_CONTROLSTEXTMODE(bo) (((bo)>>8) & 0x0000000F) /* 4 bits for CONTROLTEXTMODE */
-#define GET_BIDI_OPTION_NUMERAL(bo) (((bo)>>12) & 0x0000000F) /* 4 bits for NUMERAL */
-#define GET_BIDI_OPTION_SUPPORT(bo) (((bo)>>16) & 0x0000000F) /* 4 bits for SUPPORT */
-#define GET_BIDI_OPTION_CHARACTERSET(bo) (((bo)>>20) & 0x0000000F) /* 4 bits for CHARACTERSET */
+#define GET_BIDI_OPTION_NUMERAL(bo) (((bo)>>8) & 0x0000000F) /* 4 bits for NUMERAL */
+#define GET_BIDI_OPTION_SUPPORT(bo) (((bo)>>12) & 0x0000000F) /* 4 bits for SUPPORT */
+#define GET_BIDI_OPTION_CHARACTERSET(bo) (((bo)>>16) & 0x0000000F) /* 4 bits for CHARACTERSET */
 
 #define SET_BIDI_OPTION_DIRECTION(bo, dir) {(bo)=((bo) & 0xFFFFFFF0)|(((dir)& 0x0000000F)<<0);}
 #define SET_BIDI_OPTION_TEXTTYPE(bo, tt) {(bo)=((bo) & 0xFFFFFF0F)|(((tt)& 0x0000000F)<<4);}
-#define SET_BIDI_OPTION_CONTROLSTEXTMODE(bo, cotm) {(bo)=((bo) & 0xFFFFF0FF)|(((cotm)& 0x0000000F)<<8);}
-#define SET_BIDI_OPTION_NUMERAL(bo, num) {(bo)=((bo) & 0xFFFF0FFF)|(((num)& 0x0000000F)<<12);}
-#define SET_BIDI_OPTION_SUPPORT(bo, sup) {(bo)=((bo) & 0xFFF0FFFF)|(((sup)& 0x0000000F)<<16);}
-#define SET_BIDI_OPTION_CHARACTERSET(bo, cs) {(bo)=((bo) & 0xFF0FFFFF)|(((cs)& 0x0000000F)<<20);}
+#define SET_BIDI_OPTION_NUMERAL(bo, num) {(bo)=((bo) & 0xFFFFF0FF)|(((num)& 0x0000000F)<<8);}
+#define SET_BIDI_OPTION_SUPPORT(bo, sup) {(bo)=((bo) & 0xFFFF0FFF)|(((sup)& 0x0000000F)<<12);}
+#define SET_BIDI_OPTION_CHARACTERSET(bo, cs) {(bo)=((bo) & 0xFFF0FFFF)|(((cs)& 0x0000000F)<<16);}
 
 /* Constants related to the position of numerics in the codepage */
 #define START_HINDI_DIGITS              0x0660
 #define END_HINDI_DIGITS                0x0669
 #define START_ARABIC_DIGITS             0x0030
 #define END_ARABIC_DIGITS               0x0039
 #define START_FARSI_DIGITS              0x06f0
 #define END_FARSI_DIGITS                0x06f9
@@ -336,19 +284,16 @@ typedef enum nsCharType nsCharType;
   ( (u) >= 0x0591 && (u) <= 0x05A1) || ( (u) >= 0x05A3 && (u) <= 0x05B9) \
     || ( (u) >= 0x05BB && (u) <= 0x05BD) || ( (u) == 0x05BF) || ( (u) == 0x05C1) \
     || ( (u) == 0x05C2) || ( (u) == 0x05C4) \
     || ( (u) >= 0x064B && (u) <= 0x0652) || ( (u) == 0x0670) \
     || ( (u) >= 0x06D7 && (u) <= 0x06E4) || ( (u) == 0x06E7) || ( (u) == 0x06E8) \
     || ( (u) >= 0x06EA && (u) <= 0x06ED) )
 
 #define IS_HEBREW_CHAR(c) (((0x0590 <= (c)) && ((c)<= 0x05FF)) || (((c) >= 0xfb1d) && ((c) <= 0xfb4f)))
-#define IS_06_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
-#define IS_FE_CHAR(c) (((0xfb50 <= (c)) && ((c)<= 0xfbFF)) \
-                       || ((0xfe70 <= (c)) && ((c)<= 0xfeFC)))
 #define IS_ARABIC_CHAR(c) ((0x0600 <= (c)) && ((c)<= 0x06FF))
 #define IS_ARABIC_ALPHABETIC(c) (IS_ARABIC_CHAR(c) && \
                                 !(IS_HINDI_DIGIT(c) || IS_FARSI_DIGIT(c) || IS_ARABIC_SEPARATOR(c)))
 #define IS_BIDI_CONTROL_CHAR(c) (((0x202a <= (c)) && ((c)<= 0x202e)) \
                                 || ((c) == 0x200e) || ((c) == 0x200f))
 
 /**
  * The codepoint ranges in the following macros are based on the blocks
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3134,37 +3134,16 @@ NS_IMETHODIMP DocumentViewerImpl::GetBid
 
   if (aTextType) {
     GetBidiOptions(&bidiOptions);
     *aTextType = GET_BIDI_OPTION_TEXTTYPE(bidiOptions);
   }
   return NS_OK;
 }
 
-NS_IMETHODIMP DocumentViewerImpl::SetBidiControlsTextMode(PRUint8 aControlsTextMode)
-{
-  PRUint32 bidiOptions;
-
-  GetBidiOptions(&bidiOptions);
-  SET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions, aControlsTextMode);
-  SetBidiOptions(bidiOptions);
-  return NS_OK;
-}
-
-NS_IMETHODIMP DocumentViewerImpl::GetBidiControlsTextMode(PRUint8* aControlsTextMode)
-{
-  PRUint32 bidiOptions;
-
-  if (aControlsTextMode) {
-    GetBidiOptions(&bidiOptions);
-    *aControlsTextMode = GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions);
-  }
-  return NS_OK;
-}
-
 NS_IMETHODIMP DocumentViewerImpl::SetBidiNumeral(PRUint8 aNumeral)
 {
   PRUint32 bidiOptions;
 
   GetBidiOptions(&bidiOptions);
   SET_BIDI_OPTION_NUMERAL(bidiOptions, aNumeral);
   SetBidiOptions(bidiOptions);
   return NS_OK;
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -729,21 +729,16 @@ nsPresContext::GetUserPreferences()
   mPrefBidiDirection = prefInt;
 
   prefInt =
     nsContentUtils::GetIntPref(IBMBIDI_TEXTTYPE_STR,
                                GET_BIDI_OPTION_TEXTTYPE(bidiOptions));
   SET_BIDI_OPTION_TEXTTYPE(bidiOptions, prefInt);
 
   prefInt =
-    nsContentUtils::GetIntPref(IBMBIDI_CONTROLSTEXTMODE_STR,
-                               GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions));
-  SET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions, prefInt);
-
-  prefInt =
     nsContentUtils::GetIntPref(IBMBIDI_NUMERAL_STR,
                                GET_BIDI_OPTION_NUMERAL(bidiOptions));
   SET_BIDI_OPTION_NUMERAL(bidiOptions, prefInt);
 
   prefInt =
     nsContentUtils::GetIntPref(IBMBIDI_SUPPORTMODE_STR,
                                GET_BIDI_OPTION_SUPPORT(bidiOptions));
   SET_BIDI_OPTION_SUPPORT(bidiOptions, prefInt);
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -6914,30 +6914,26 @@ nsBlockFrame::ResolveBidi()
     return NS_ERROR_NULL_POINTER;
 
   return bidiUtils->Resolve(this, IsVisualFormControl(presContext));
 }
 
 PRBool
 nsBlockFrame::IsVisualFormControl(nsPresContext* aPresContext)
 {
-  // This check is only necessary on visual bidi pages, because most
-  // visual pages use logical order for form controls so that they will
-  // display correctly on native widgets in OSs with Bidi support.
-  // So bail out if the page is not visual, or if the pref is
-  // set to use visual order on forms in visual pages
+  // We always use logical order on form controls, so that they will display
+  // correctly in native widgets in OSs with Bidi support.
+  // If the page uses logical ordering we can bail out immediately, but on
+  // visual pages we need to drill up in content to detect whether this block
+  // is a descendant of a form control.
+
   if (!aPresContext->IsVisualMode()) {
     return PR_FALSE;
   }
 
-  PRUint32 options = aPresContext->GetBidi();
-  if (IBMBIDI_CONTROLSTEXTMODE_LOGICAL != GET_BIDI_OPTION_CONTROLSTEXTMODE(options)) {
-    return PR_FALSE;
-  }
-
   nsIContent* content = GetContent();
   for ( ; content; content = content->GetParent()) {
     if (content->IsNodeOfType(nsINode::eHTML_FORM_CONTROL)) {
       return PR_TRUE;
     }
   }
   
   return PR_FALSE;
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -1062,23 +1062,16 @@ pref("bidi.direction", 1);
 // ------------------
 //  Text Type
 // ------------------
 // 1 = charsettexttypeBidi *
 // 2 = logicaltexttypeBidi
 // 3 = visualtexttypeBidi
 pref("bidi.texttype", 1);
 // ------------------
-//  Controls Text Mode
-// ------------------
-// 1 = logicalcontrolstextmodeBidiCmd
-// 2 = visualcontrolstextmodeBidi <-- NO LONGER SUPPORTED
-// 3 = containercontrolstextmodeBidi *
-pref("bidi.controlstextmode", 1);
-// ------------------
 //  Numeral Style
 // ------------------
 // 0 = nominalnumeralBidi *
 // 1 = regularcontextnumeralBidi
 // 2 = hindicontextnumeralBidi
 // 3 = arabicnumeralBidi
 // 4 = hindinumeralBidi
 // 5 = persiancontextnumeralBidi