Backing out 414463b32e36 to dcae4884a07d
authorDoug Turner <dougt@dougt.org>
Tue, 17 Aug 2010 00:20:44 -0700
changeset 51332 56dd12038d93e9dffdede0f4e714564cf670769e
parent 51331 414463b32e3631eab167410fa52c5429477a8549
child 51333 0f96e7356ba364b923733b65594aafe6dccde7fc
push id15277
push userdwitte@mozilla.com
push dateTue, 24 Aug 2010 04:18:33 +0000
treeherdermozilla-central@49dc8d6901a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone2.0b4pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backing out 414463b32e36 to dcae4884a07d
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
content/base/src/nsFrameLoader.cpp
content/events/src/nsEventStateManager.cpp
content/events/src/nsEventStateManager.h
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
js/src/jstracer.cpp
toolkit/components/satchel/jar.mn
toolkit/components/satchel/src/formSubmitListener.js
toolkit/components/satchel/src/nsFormHistory.js
toolkit/components/satchel/test/satchel_common.js
toolkit/components/satchel/test/subtst_form_submission_1.html
toolkit/components/satchel/test/test_form_submission.html
toolkit/components/satchel/test/test_form_submission_cap.html
toolkit/components/satchel/test/test_form_submission_cap2.html
widget/public/Makefile.in
widget/public/nsGUIEvent.h
widget/public/nsGUIEventIPC.h
widget/src/android/AndroidBridge.cpp
widget/src/android/nsWindow.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -1671,33 +1671,16 @@ public:
   /**
    * Determine whether a content node is focused or not,
    *
    * @param aContent the content node to check
    * @return true if the content node is focused, false otherwise.
    */
   static PRBool IsFocusedContent(nsIContent *aContent);
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-  static void SetActiveFrameLoader(nsFrameLoader *aFrameLoader)
-  {
-    sActiveFrameLoader = aFrameLoader;
-  }
-
-  static void ClearActiveFrameLoader(const nsFrameLoader *aFrameLoader)
-  {
-    if (sActiveFrameLoader == aFrameLoader)
-      sActiveFrameLoader = nsnull;
-  }
-
-  static already_AddRefed<nsFrameLoader> GetActiveFrameLoader();
-#endif
-#endif
-
 private:
 
   static PRBool InitializeEventTable();
 
   static nsresult EnsureStringBundle(PropertiesFile aFile);
 
   static nsIDOMScriptObjectFactory *GetDOMScriptObjectFactory();
 
@@ -1777,22 +1760,16 @@ private:
   static PRUint32 sRemovableScriptBlockerCount;
   static nsCOMArray<nsIRunnable>* sBlockedScriptRunners;
   static PRUint32 sRunnersCountAtFirstBlocker;
   static PRUint32 sScriptBlockerCountWhereRunnersPrevented;
 
   static nsIInterfaceRequestor* sSameOriginChecker;
 
   static PRBool sIsHandlingKeyBoardEvent;
-
-#ifdef MOZ_IPC
-#ifdef ANDROID
-  static nsFrameLoader *sActiveFrameLoader;
-#endif
-#endif
 };
 
 #define NS_HOLD_JS_OBJECTS(obj, clazz)                                         \
   nsContentUtils::HoldJSObjects(NS_CYCLE_COLLECTION_UPCAST(obj, clazz),        \
                                 &NS_CYCLE_COLLECTION_NAME(clazz))
 
 #define NS_DROP_JS_OBJECTS(obj, clazz)                                         \
   nsContentUtils::DropJSObjects(NS_CYCLE_COLLECTION_UPCAST(obj, clazz))
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -261,22 +261,16 @@ JSRuntime *nsAutoGCRoot::sJSScriptRuntim
 
 PRBool nsContentUtils::sIsHandlingKeyBoardEvent = PR_FALSE;
 
 PRBool nsContentUtils::sInitialized = PR_FALSE;
 
 nsRefPtrHashtable<nsPrefObserverHashKey, nsPrefOldCallback>
   *nsContentUtils::sPrefCallbackTable = nsnull;
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-nsFrameLoader *nsContentUtils::sActiveFrameLoader = nsnull;
-#endif
-#endif
-
 static PLDHashTable sEventListenerManagersHash;
 
 class EventListenerManagerMapEntry : public PLDHashEntryHdr
 {
 public:
   EventListenerManagerMapEntry(const void *aKey)
     : mKey(aKey)
   {
@@ -6210,27 +6204,16 @@ mozAutoRemovableBlockerRemover::~mozAuto
 PRBool
 nsContentUtils::IsFocusedContent(nsIContent* aContent)
 {
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
 
   return fm && fm->GetFocusedContent() == aContent;
 }
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-// static
-already_AddRefed<nsFrameLoader>
-nsContentUtils::GetActiveFrameLoader()
-{
-  return nsCOMPtr<nsFrameLoader>(sActiveFrameLoader).forget();
-}
-#endif
-#endif
-
 void nsContentUtils::RemoveNewlines(nsString &aString)
 {
   // strip CR/LF and null
   static const char badChars[] = {'\r', '\n', 0};
   aString.StripChars(badChars);
 }
 
 void
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -1165,19 +1165,16 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
   return NS_OK;
 }
 
 void
 nsFrameLoader::DestroyChild()
 {
 #ifdef MOZ_IPC
   if (mRemoteBrowser) {
-#ifdef ANDROID
-    nsContentUtils::ClearActiveFrameLoader(this);
-#endif
     mRemoteBrowser->SetOwnerElement(nsnull);
     // If this fails, it's most likely due to a content-process crash,
     // and auto-cleanup will kick in.  Otherwise, the child side will
     // destroy itself and send back __delete__().
     unused << mRemoteBrowser->SendDestroy();
     mRemoteBrowser = nsnull;
   }
 #endif
@@ -1703,19 +1700,16 @@ nsFrameLoader::GetRemoteBrowser()
 }
 #endif
 
 NS_IMETHODIMP
 nsFrameLoader::ActivateRemoteFrame() {
 #ifdef MOZ_IPC
   if (mRemoteBrowser) {
     mRemoteBrowser->Activate();
-#ifdef ANDROID
-    nsContentUtils::SetActiveFrameLoader(this);
-#endif
     return NS_OK;
   }
 #endif
   return NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
 nsFrameLoader::SendCrossProcessMouseEvent(const nsAString& aType,
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -39,22 +39,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-#include "mozilla/dom/PBrowserParent.h"
-#endif
-#endif
-
 #include "nsCOMPtr.h"
 #include "nsEventStateManager.h"
 #include "nsEventListenerManager.h"
 #include "nsIMEStateManager.h"
 #include "nsContentEventHandler.h"
 #include "nsIContent.h"
 #include "nsINodeInfo.h"
 #include "nsIDocument.h"
@@ -160,22 +154,16 @@
 #include "nsIController.h"
 #include "nsICommandParams.h"
 #include "mozilla/Services.h"
 
 #ifdef XP_MACOSX
 #import <ApplicationServices/ApplicationServices.h>
 #endif
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-#include "nsFrameLoader.h"
-#endif
-#endif
-
 //#define DEBUG_DOCSHELL_FOCUS
 
 #define NS_USER_INTERACTION_INTERVAL 5000 // ms
 
 static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
 
 static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
 
@@ -1376,50 +1364,16 @@ nsEventStateManager::PreHandleEvent(nsPr
       DoContentCommandEvent(static_cast<nsContentCommandEvent*>(aEvent));
     }
     break;
   case NS_CONTENT_COMMAND_SCROLL:
     {
       DoContentCommandScrollEvent(static_cast<nsContentCommandEvent*>(aEvent));
     }
     break;
-#ifdef MOZ_IPC
-#ifdef ANDROID
-  case NS_TEXT_TEXT:
-    {
-      nsTextEvent *textEvent = static_cast<nsTextEvent*>(aEvent);
-      if (IsTargetCrossProcess(textEvent)) {
-        // Will not be handled locally, remote the event
-        mozilla::dom::PBrowserParent *remoteBrowser = GetCrossProcessTarget();
-        if (remoteBrowser &&
-            remoteBrowser->SendTextEvent(*textEvent)) {
-          // Cancel local dispatching
-          *aStatus = nsEventStatus_eConsumeNoDefault;
-        }
-      }
-    }
-    break;
-  case NS_COMPOSITION_START:
-  case NS_COMPOSITION_END:
-    {
-      nsCompositionEvent *compositionEvent =
-          static_cast<nsCompositionEvent*>(aEvent);
-      if (IsTargetCrossProcess(compositionEvent)) {
-        // Will not be handled locally, remote the event
-        mozilla::dom::PBrowserParent *remoteBrowser = GetCrossProcessTarget();
-        if (remoteBrowser &&
-            remoteBrowser->SendCompositionEvent(*compositionEvent)) {
-          // Cancel local dispatching
-          *aStatus = nsEventStatus_eConsumeNoDefault;
-        }
-      }
-    }
-    break;
-#endif
-#endif
   }
   return NS_OK;
 }
 
 static PRInt32
 GetAccessModifierMask(nsISupports* aDocShell)
 {
   nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(aDocShell));
@@ -3240,88 +3194,24 @@ nsEventStateManager::PostHandleEvent(nsP
       mCurrentTarget->GetContentForEvent(presContext, aEvent,
                                          getter_AddRefs(targetContent));
       if (!NodeAllowsClickThrough(targetContent)) {
         *aStatus = nsEventStatus_eConsumeNoDefault;
       }
     }
     break;
 #endif
-
-#ifdef MOZ_IPC
-#ifdef ANDROID
-  case NS_QUERY_SELECTED_TEXT:
-  case NS_QUERY_TEXT_CONTENT:
-  case NS_QUERY_CARET_RECT:
-  case NS_QUERY_TEXT_RECT:
-  case NS_QUERY_EDITOR_RECT:
-  case NS_QUERY_CONTENT_STATE:
-  // We don't remote nsITransferable yet
-  //case NS_QUERY_SELECTION_AS_TRANSFERABLE:
-  case NS_QUERY_CHARACTER_AT_POINT:
-    {
-      nsQueryContentEvent *queryEvent =
-          static_cast<nsQueryContentEvent*>(aEvent);
-      // If local query failed, try remote query
-      if (queryEvent->mSucceeded)
-        break;
-
-      mozilla::dom::PBrowserParent *remoteBrowser = GetCrossProcessTarget();
-      if (remoteBrowser &&
-          remoteBrowser->SendQueryContentEvent(*queryEvent)) {
-        queryEvent->mWasAsync = PR_TRUE;
-        queryEvent->mSucceeded = PR_TRUE;
-      }
-    }
-    break;
-  case NS_SELECTION_SET:
-    {
-      nsSelectionEvent *selectionEvent =
-          static_cast<nsSelectionEvent*>(aEvent);
-      // If local handler failed, try remoting the event
-      if (selectionEvent->mSucceeded)
-        break;
-
-      mozilla::dom::PBrowserParent *remoteBrowser = GetCrossProcessTarget();
-      if (remoteBrowser &&
-          remoteBrowser->SendSelectionEvent(*selectionEvent))
-        selectionEvent->mSucceeded = PR_TRUE;
-    }
-    break;
-#endif // ANDROID
-#endif // MOZ_IPC
   }
 
   //Reset target frame to null to avoid mistargeting after reentrant event
   mCurrentTarget = nsnull;
 
   return ret;
 }
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-mozilla::dom::PBrowserParent*
-nsEventStateManager::GetCrossProcessTarget()
-{
-  nsCOMPtr<nsFrameLoader> fl = nsContentUtils::GetActiveFrameLoader();
-  NS_ENSURE_TRUE(fl, nsnull);
-  return fl->GetRemoteBrowser();
-}
-
-PRBool
-nsEventStateManager::IsTargetCrossProcess(nsGUIEvent *aEvent)
-{
-  nsQueryContentEvent stateEvent(PR_TRUE, NS_QUERY_CONTENT_STATE, aEvent->widget);
-  nsContentEventHandler handler(mPresContext);
-  handler.OnQueryContentState(&stateEvent);
-  return !stateEvent.mSucceeded;
-}
-#endif
-#endif
-
 NS_IMETHODIMP
 nsEventStateManager::NotifyDestroyPresContext(nsPresContext* aPresContext)
 {
   nsIMEStateManager::OnDestroyPresContext(aPresContext);
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -326,23 +326,16 @@ protected:
    * BeginTrackingDragGesture). aEvent->widget must be
    * mCurrentTarget->GetNearestWidget().
    */
   void FillInEventFromGestureDown(nsMouseEvent* aEvent);
 
   nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
   nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
 
-#ifdef MOZ_IPC
-#ifdef ANDROID
-  mozilla::dom::PBrowserParent *GetCrossProcessTarget();
-  PRBool IsTargetCrossProcess(nsGUIEvent *aEvent);
-#endif
-#endif
-
   PRInt32     mLockCursor;
 
   nsWeakFrame mCurrentTarget;
   nsCOMPtr<nsIContent> mCurrentTargetContent;
   nsWeakFrame mLastMouseOverFrame;
   nsCOMPtr<nsIContent> mLastMouseOverElement;
   nsWeakFrame mLastDragOverFrame;
 
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -43,26 +43,21 @@ include protocol PDocumentRenderer;
 include protocol PDocumentRendererShmem;
 include protocol PDocumentRendererNativeID;
 include protocol PGeolocationRequest;
 
 include "mozilla/TabTypes.h";
 include "TabMessageUtils.h";
 include "gfxMatrix.h";
 include "mozilla/net/NeckoMessageUtils.h";
-include "mozilla/widget/nsGUIEventIPC.h";
 
 using IPC::URI;
 using MagicWindowHandle;
 using RemoteDOMEvent;
 using gfxMatrix;
-using nsCompositionEvent;
-using nsTextEvent;
-using nsQueryContentEvent;
-using nsSelectionEvent;
 
 namespace mozilla {
 namespace dom {
 
 rpc protocol PBrowser
 {
     manager PContent;
 
@@ -105,18 +100,16 @@ parent:
                           bool sameURI) returns (bool retval);
 
 
     rpc CreateWindow() returns (PBrowser window);
 
     sync SyncMessage(nsString aMessage, nsString aJSON)
       returns (nsString[] retval);
 
-    QueryContentResult(nsQueryContentEvent event);
-
     PGeolocationRequest(URI uri);
 
     PContentDialog(PRUint32 aType, nsCString aName, nsCString aFeatures,
                    PRInt32[] aIntParams, nsString[] aStringParams);
 
     __delete__();
 
 child:
@@ -149,24 +142,16 @@ child:
      * @see nsIDOMWindowUtils sendKeyEvent.
      */
     KeyEvent(nsString aType,
              PRInt32 aKeyCode,
              PRInt32 aCharCode,
              PRInt32 aModifiers,
              bool aPreventDefault);
 
-    CompositionEvent(nsCompositionEvent event);
-
-    TextEvent(nsTextEvent event);
-
-    QueryContentEvent(nsQueryContentEvent event);
-
-    SelectionEvent(nsSelectionEvent event);
-
     /**
      * Activate event forwarding from client to parent.
      */
     ActivateFrameEvent(nsString aType, bool capture);
 
     LoadRemoteScript(nsString aURL);
 
     PDocumentRenderer(PRInt32 x, PRInt32 y, PRInt32 w, PRInt32 h, nsString bgcolor, PRUint32 flags, bool flush);
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -49,17 +49,16 @@
 #include "nsIWebProgress.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsThreadUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "mozilla/ipc/DocumentRendererChild.h"
 #include "mozilla/ipc/DocumentRendererShmemChild.h"
 #include "mozilla/ipc/DocumentRendererNativeIDChild.h"
-#include "mozilla/widget/nsGUIEventIPC.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsISupportsImpl.h"
 #include "nsIURI.h"
 #include "nsIWebBrowserFocus.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
@@ -76,18 +75,16 @@
 #include "nsPIWindowRoot.h"
 #include "nsIScriptContext.h"
 #include "nsInterfaceHashtable.h"
 #include "nsPresContext.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsWeakReference.h"
-#include "nsIFrame.h"
-#include "nsIView.h"
 #include "nsISecureBrowserUI.h"
 #include "nsISSLStatusProvider.h"
 #include "nsSerializationHelper.h"
 
 #ifdef MOZ_WIDGET_QT
 #include <QX11EmbedWidget>
 #include <QGraphicsView>
 #include <QGraphicsWidget>
@@ -718,87 +715,25 @@ TabChild::RecvKeyEvent(const nsString& a
   nsCOMPtr<nsIDOMWindowUtils> utils = do_GetInterface(window);
   NS_ENSURE_TRUE(utils, true);
   PRBool ignored = PR_FALSE;
   utils->SendKeyEvent(aType, aKeyCode, aCharCode,
                       aModifiers, aPreventDefault, &ignored);
   return true;
 }
 
-bool
-TabChild::RecvCompositionEvent(const nsCompositionEvent& event)
-{
-  nsCompositionEvent localEvent(event);
-  DispatchWidgetEvent(localEvent);
-  return true;
-}
-
-bool
-TabChild::RecvTextEvent(const nsTextEvent& event)
-{
-  nsTextEvent localEvent(event);
-  DispatchWidgetEvent(localEvent);
-  IPC::ParamTraits<nsTextEvent>::Free(event);
-  return true;
-}
-
-bool
-TabChild::RecvQueryContentEvent(const nsQueryContentEvent& event)
-{
-  nsQueryContentEvent localEvent(event);
-  DispatchWidgetEvent(localEvent);
-  // Send result back even if query failed
-  SendQueryContentResult(localEvent);
-  return true;
-}
-
-bool
-TabChild::RecvSelectionEvent(const nsSelectionEvent& event)
-{
-  nsSelectionEvent localEvent(event);
-  DispatchWidgetEvent(localEvent);
-  return true;
-}
-
-bool
-TabChild::DispatchWidgetEvent(nsGUIEvent& event)
-{
-  nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(mWebNav);
-  NS_ENSURE_TRUE(window, false);
-
-  nsIDocShell *docShell = window->GetDocShell();
-  NS_ENSURE_TRUE(docShell, false);
-
-  nsCOMPtr<nsIPresShell> presShell;
-  docShell->GetPresShell(getter_AddRefs(presShell));
-  NS_ENSURE_TRUE(presShell, false);
-
-  nsIFrame *frame = presShell->GetRootFrame();
-  NS_ENSURE_TRUE(frame, false);
-
-  nsIView *view = frame->GetView();
-  NS_ENSURE_TRUE(view, false);
-
-  nsCOMPtr<nsIWidget> widget = view->GetNearestWidget(nsnull);
-  NS_ENSURE_TRUE(widget, false);
-
-  nsEventStatus status;
-  event.widget = widget;
-  NS_ENSURE_SUCCESS(widget->DispatchEvent(&event, status), false);
-  return true;
-}
-
 mozilla::ipc::PDocumentRendererChild*
-TabChild::AllocPDocumentRenderer(const PRInt32& x,
-                                 const PRInt32& y,
-                                 const PRInt32& w,
-                                 const PRInt32& h,
-                                 const nsString& bgcolor,
-                                 const PRUint32& flags,
-                                 const bool& flush)
+TabChild::AllocPDocumentRenderer(
+        const PRInt32& x,
+        const PRInt32& y,
+        const PRInt32& w,
+        const PRInt32& h,
+        const nsString& bgcolor,
+        const PRUint32& flags,
+        const bool& flush)
 {
     return new mozilla::ipc::DocumentRendererChild();
 }
 
 bool
 TabChild::DeallocPDocumentRenderer(PDocumentRendererChild* actor)
 {
     delete actor;
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -186,20 +186,16 @@ public:
                                 const PRInt32&  aClickCount,
                                 const PRInt32&  aModifiers,
                                 const bool&     aIgnoreRootScrollFrame);
     virtual bool RecvKeyEvent(const nsString& aType,
                               const PRInt32&  aKeyCode,
                               const PRInt32&  aCharCode,
                               const PRInt32&  aModifiers,
                               const bool&     aPreventDefault);
-    virtual bool RecvCompositionEvent(const nsCompositionEvent& event);
-    virtual bool RecvTextEvent(const nsTextEvent& event);
-    virtual bool RecvQueryContentEvent(const nsQueryContentEvent& event);
-    virtual bool RecvSelectionEvent(const nsSelectionEvent& event);
     virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture);
     virtual bool RecvLoadRemoteScript(const nsString& aURL);
     virtual bool RecvAsyncMessage(const nsString& aMessage,
                                   const nsString& aJSON);
     virtual mozilla::ipc::PDocumentRendererChild* AllocPDocumentRenderer(
             const PRInt32& x,
             const PRInt32& y,
             const PRInt32& w,
@@ -284,18 +280,16 @@ public:
     JSContext* GetJSContext() { return mCx; }
 
     nsIPrincipal* GetPrincipal() { return mPrincipal; }
 
 protected:
     NS_OVERRIDE
     virtual bool RecvDestroy();
 
-    bool DispatchWidgetEvent(nsGUIEvent& event);
-
 private:
     void ActorDestroy(ActorDestroyReason why);
 
     bool InitTabChildGlobal();
 
     nsCOMPtr<nsIWebNavigation> mWebNav;
     nsCOMPtr<nsIXPConnectJSObjectHolder> mRootGlobal;
     JSContext* mCx;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -66,21 +66,16 @@
 #include "nsIDOMNSHTMLFrameElement.h"
 #include "nsIDialogCreator.h"
 #include "nsThreadUtils.h"
 #include "nsSerializationHelper.h"
 #include "nsIPromptFactory.h"
 #include "nsIContent.h"
 #include "mozilla/unused.h"
 
-#ifdef ANDROID
-#include "AndroidBridge.h"
-using namespace mozilla;
-#endif
-
 using mozilla::ipc::DocumentRendererParent;
 using mozilla::ipc::DocumentRendererShmemParent;
 using mozilla::ipc::DocumentRendererNativeIDParent;
 using mozilla::dom::ContentParent;
 
 // The flags passed by the webProgress notifications are 16 bits shifted
 // from the ones registered by webProgressListeners.
 #define NOTIFY_FLAG_SHIFT 16
@@ -568,42 +563,16 @@ TabParent::RecvSyncMessage(const nsStrin
 bool
 TabParent::RecvAsyncMessage(const nsString& aMessage,
                             const nsString& aJSON)
 {
   return ReceiveMessage(aMessage, PR_FALSE, aJSON, nsnull);
 }
 
 bool
-TabParent::RecvQueryContentResult(const nsQueryContentEvent& event)
-{
-#ifdef ANDROID
-  if (!event.mSucceeded) {
-    AndroidBridge::Bridge()->ReturnIMEQueryResult(nsnull, 0, 0, 0);
-    return true;
-  }
-
-  switch (event.message) {
-  case NS_QUERY_TEXT_CONTENT:
-    AndroidBridge::Bridge()->ReturnIMEQueryResult(
-        event.mReply.mString.get(), event.mReply.mString.Length(), 0, 0);
-    break;
-  case NS_QUERY_SELECTED_TEXT:
-    AndroidBridge::Bridge()->ReturnIMEQueryResult(
-        event.mReply.mString.get(),
-        event.mReply.mString.Length(),
-        event.GetSelectionStart(),
-        event.GetSelectionEnd() - event.GetSelectionStart());
-    break;
-  }
-#endif
-  return true;
-}
-
-bool
 TabParent::ReceiveMessage(const nsString& aMessage,
                           PRBool aSync,
                           const nsString& aJSON,
                           nsTArray<nsString>* aJSONRetVal)
 {
   nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
   if (frameLoader && frameLoader->GetFrameMessageManager()) {
     nsFrameMessageManager* manager = frameLoader->GetFrameMessageManager();
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -127,17 +127,16 @@ public:
                                       bool* aAllowRefresh);
 
     virtual bool AnswerCreateWindow(PBrowserParent** retval);
     virtual bool RecvSyncMessage(const nsString& aMessage,
                                  const nsString& aJSON,
                                  nsTArray<nsString>* aJSONRetVal);
     virtual bool RecvAsyncMessage(const nsString& aMessage,
                                   const nsString& aJSON);
-    virtual bool RecvQueryContentResult(const nsQueryContentEvent& event);
     virtual PContentDialogParent* AllocPContentDialog(const PRUint32& aType,
                                                       const nsCString& aName,
                                                       const nsCString& aFeatures,
                                                       const nsTArray<int>& aIntParams,
                                                       const nsTArray<nsString>& aStringParams);
     virtual bool DeallocPContentDialog(PContentDialogParent* aDialog)
     {
       delete aDialog;
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -10343,17 +10343,17 @@ IsTraceableRecursion(JSContext *cx)
     if (fp->imacpc || down->imacpc)
         return false;
     if ((fp->flags & JSFRAME_CONSTRUCTING) || (down->flags & JSFRAME_CONSTRUCTING))
         return false;
     if (fp->blockChain || down->blockChain)
         return false;
     if (*fp->script->code != JSOP_TRACE)
         return false;
-    return !fp->fun->isHeavyweight();
+    return true;
 }
 
 JS_REQUIRES_STACK AbortableRecordingStatus
 TraceRecorder::record_EnterFrame(uintN& inlineCallCount)
 {
     JSStackFrame* const fp = cx->fp;
 
     if (++callDepth >= MAX_CALLDEPTH)
deleted file mode 100644
--- a/toolkit/components/satchel/jar.mn
+++ /dev/null
@@ -1,3 +0,0 @@
-toolkit.jar:
-%   content satchel %content/satchel/
-*   content/satchel/formSubmitListener.js            (src/formSubmitListener.js)
deleted file mode 100644
--- a/toolkit/components/satchel/src/formSubmitListener.js
+++ /dev/null
@@ -1,211 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Justin Dolske <dolske@mozilla.com>
- *  Paul O’Shannessy <paul@oshannessy.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-var satchelFormListener = {
-    QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver,
-                                            Ci.nsIDOMEventListener,
-                                            Ci.nsObserver,
-                                            Ci.nsISupportsWeakReference]),
-
-    debug          : true,
-    enabled        : true,
-    saveHttpsForms : true,
-
-    init : function() {
-        Services.obs.addObserver(this, "earlyformsubmit", false);
-        Services.prefs.addObserver("browser.formfill.", this, false);
-        this.updatePrefs();
-        addEventListener("unload", this, false);
-    },
-
-    updatePrefs : function () {
-        this.debug          = Services.prefs.getBoolPref("browser.formfill.debug");
-        this.enabled        = Services.prefs.getBoolPref("browser.formfill.enable");
-        this.saveHttpsForms = Services.prefs.getBoolPref("browser.formfill.saveHttpsForms");
-    },
-
-    // Implements the Luhn checksum algorithm as described at
-    // http://wikipedia.org/wiki/Luhn_algorithm
-    isValidCCNumber : function (ccNumber) {
-        // Remove dashes and whitespace
-        ccNumber = ccNumber.replace(/[\-\s]/g, '');
-
-        let len = ccNumber.length;
-        if (len != 9 && len != 15 && len != 16)
-            return false;
-
-        if (!/^\d+$/.test(ccNumber))
-            return false;
-
-        let total = 0;
-        for (let i = 0; i < len; i++) {
-            let ch = parseInt(ccNumber[len - i - 1]);
-            if (i % 2 == 1) {
-                // Double it, add digits together if > 10
-                ch *= 2;
-                if (ch > 9)
-                    ch -= 9;
-            }
-            total += ch;
-        }
-        return total % 10 == 0;
-    },
-
-    log : function (message) {
-        if (!this.debug)
-            return;
-        dump("satchelFormListener: " + message + "\n");
-        Services.console.logStringMessage("satchelFormListener: " + message);
-    },
-
-    /* ---- dom event handler ---- */
-
-    handleEvent: function(e) {
-        switch (e.type) {
-            case "unload":
-                Services.obs.removeObserver(this, "earlyformsubmit");
-                Services.prefs.removeObserver("browser.formfill.", this);
-                break;
-
-            default:
-                this.log("Oops! Unexpected event: " + e.type);
-                break;
-        }
-    },
-
-    /* ---- nsIObserver interface ---- */
-
-    observe : function (subject, topic, data) {
-        if (topic == "nsPref:changed")
-            this.updatePrefs();
-        else
-            this.log("Oops! Unexpected notification: " + topic);
-    },
-
-    /* ---- nsIFormSubmitObserver interfaces ---- */
-
-    notify : function(form, domWin, actionURI, cancelSubmit) {
-        try {
-            // Even though the global context is for a specific browser, we
-            // can receive observer events from other tabs! Ensure this event
-            // is about our content. 
-            if (domWin.top != content)
-                return;
-            if (!this.enabled)
-                return;
-
-
-            this.log("Form submit observer notified.");
-
-            if (!this.saveHttpsForms) {
-                if (actionURI.schemeIs("https"))
-                    return;
-                if (form.ownerDocument.documentURIObject.schemeIs("https"))
-                    return;
-            }
-
-            if (form.hasAttribute("autocomplete") &&
-                form.getAttribute("autocomplete").toLowerCase() == "off")
-                return;
-
-            let entries = [];
-            for (let i = 0; i < form.elements.length; i++) {
-                let input = form.elements[i];
-                if (!(input instanceof Ci.nsIDOMHTMLInputElement))
-                    continue;
-
-                // Only use inputs that hold text values (not including type="password")
-                if (!input.mozIsTextField(true))
-                    continue;
-
-                // Bug 394612: If Login Manager marked this input, don't save it.
-                // The login manager will deal with remembering it.
-
-                // Don't save values when autocomplete=off is present.
-                if (input.hasAttribute("autocomplete") &&
-                    input.getAttribute("autocomplete").toLowerCase() == "off")
-                    continue;
-
-                let value = input.value.trim();
-
-                // Don't save empty or unchanged values.
-                if (!value || value == input.defaultValue.trim())
-                    continue;
-
-                // Don't save credit card numbers.
-                if (this.isValidCCNumber(value)) {
-                    this.log("skipping saving a credit card number");
-                    continue;
-                }
-
-                let name = input.name || input.id;
-                if (!name)
-                    continue;
-
-                // Limit stored data to 200 characters.
-                if (name.length > 200 || value.length > 200) {
-                    this.log("skipping input that has a name/value too large");
-                    continue;
-                }
-
-                // Limit number of fields stored per form.
-                if (entries.length >= 100) {
-                    this.log("not saving any more entries for this form.");
-                    break;
-                }
-
-                entries.push({ name: name, value: value });
-            }
-
-            if (entries.length) {
-                this.log("sending entries to parent process for form " + form.id);
-                sendAsyncMessage("FormHistory:FormSubmitEntries", entries);
-            }
-        }
-        catch (e) {
-            this.log("notify failed: " + e);
-        }
-    }
-};
-
-satchelFormListener.init();
--- a/toolkit/components/satchel/src/nsFormHistory.js
+++ b/toolkit/components/satchel/src/nsFormHistory.js
@@ -47,24 +47,22 @@ const DB_VERSION = 3;
 const DAY_IN_MS  = 86400000; // 1 day in milliseconds
 
 function FormHistory() {
     this.init();
 }
 
 FormHistory.prototype = {
     classID          : Components.ID("{0c1bb408-71a2-403f-854a-3a0659829ded}"),
-    QueryInterface   : XPCOMUtils.generateQI([Ci.nsIFormHistory2,
-                                              Ci.nsIObserver,
-                                              Ci.nsIFrameMessageListener,
-                                              ]),
+    QueryInterface   : XPCOMUtils.generateQI([Ci.nsIFormHistory2, Ci.nsIObserver, Ci.nsIFormSubmitObserver, Ci.nsISupportsWeakReference]),
 
     debug          : true,
     enabled        : true,
     saveHttpsForms : true,
+    prefBranch     : null,
 
     // The current database schema.
     dbSchema : {
         tables : {
             moz_formhistory: {
                 "id"        : "INTEGER PRIMARY KEY",
                 "fieldname" : "TEXT NOT NULL",
                 "value"     : "TEXT NOT NULL",
@@ -121,29 +119,25 @@ FormHistory.prototype = {
             return;
         dump("FormHistory: " + message + "\n");
         Services.console.logStringMessage("FormHistory: " + message);
     },
 
 
     init : function() {
         let self = this;
-
-        Services.prefs.addObserver("browser.formfill.", this, false);
-
+        this.prefBranch = Services.prefs.getBranch("browser.formfill.");
+        this.prefBranch.QueryInterface(Ci.nsIPrefBranch2);
+        this.prefBranch.addObserver("", this, true);
         this.updatePrefs();
 
         this.dbStmts = {};
 
-        this.messageManager = Cc["@mozilla.org/globalmessagemanager;1"].
-                              getService(Ci.nsIChromeFrameMessageManager);
-        this.messageManager.loadFrameScript("chrome://satchel/content/formSubmitListener.js", true);
-        this.messageManager.addMessageListener("FormHistory:FormSubmitEntries", this);
-
         // Add observers
+        Services.obs.addObserver(this, "earlyformsubmit", false);
         Services.obs.addObserver(function() { self.expireOldEntries() }, "idle-daily", false);
         Services.obs.addObserver(function() { self.expireOldEntries() }, "formhistory-expire-now", false);
 
         try {
             this.dbFile = Services.dirsvc.get("ProfD", Ci.nsIFile).clone();
             this.dbFile.append("formhistory.sqlite");
             this.log("Opening database at " + this.dbFile.path);
 
@@ -156,36 +150,16 @@ FormHistory.prototype = {
                 this.dbInit();
             } else {
                 throw "Initialization failed";
             }
         }
     },
 
 
-    /* ---- message listener ---- */
-
-
-    receiveMessage: function receiveMessage(message) {
-        // Open a transaction so multiple adds happen in one commit
-        this.dbConnection.beginTransaction();
-
-        try {
-            let entries = message.json;
-            for (let i = 0; i < entries.length; i++) {
-                this.addEntry(entries[i].name, entries[i].value);
-            }
-        } finally {
-            // Don't need it to be atomic if there was an error.  Commit what
-            // we managed to put in the table.
-            this.dbConnection.commitTransaction();
-        }
-    },
-
-
     /* ---- nsIFormHistory2 interfaces ---- */
 
 
     get hasEntries() {
         return (this.countAllEntries() > 0);
     },
 
 
@@ -194,20 +168,20 @@ FormHistory.prototype = {
             this.privBrowsingSvc && this.privBrowsingSvc.privateBrowsingEnabled)
             return;
 
         this.log("addEntry for " + name + "=" + value);
 
         let now = Date.now() * 1000; // microseconds
 
         let [id, guid] = this.getExistingEntryID(name, value);
-        let stmt;
 
         if (id != -1) {
             // Update existing entry
+            let stmt;
             let query = "UPDATE moz_formhistory SET timesUsed = timesUsed + 1, lastUsed = :lastUsed WHERE id = :id";
             let params = {
                             lastUsed : now,
                             id       : id
                          };
 
             try {
                 stmt = this.dbCreateStatement(query, params);
@@ -381,16 +355,97 @@ FormHistory.prototype = {
     observe : function (subject, topic, data) {
         if (topic == "nsPref:changed")
             this.updatePrefs();
         else
             this.log("Oops! Unexpected notification: " + topic);
     },
 
 
+    /* ---- nsIFormSubmitObserver interfaces ---- */
+
+
+    notify : function(form, domWin, actionURI, cancelSubmit) {
+        if (!this.enabled)
+            return;
+
+        this.log("Form submit observer notified.");
+
+        if (!this.saveHttpsForms) {
+            if (actionURI.schemeIs("https"))
+                return;
+            if (form.ownerDocument.documentURIObject.schemeIs("https"))
+                return;
+        }
+
+        if (form.hasAttribute("autocomplete") &&
+            form.getAttribute("autocomplete").toLowerCase() == "off")
+            return;
+
+        // Open a transaction so that multiple additions are efficient.
+        this.dbConnection.beginTransaction();
+
+        try {
+            let savedCount = 0;
+            for (let i = 0; i < form.elements.length; i++) {
+                let input = form.elements[i];
+                if (!(input instanceof Ci.nsIDOMHTMLInputElement))
+                    continue;
+
+                // Only use inputs that hold text values (not including type="password")
+                if (!input.mozIsTextField(true))
+                    continue;
+
+                // Bug 394612: If Login Manager marked this input, don't save it.
+                // The login manager will deal with remembering it.
+
+                // Don't save values when autocomplete=off is present.
+                if (input.hasAttribute("autocomplete") &&
+                    input.getAttribute("autocomplete").toLowerCase() == "off")
+                    continue;
+
+                let value = input.value.trim();
+
+                // Don't save empty or unchanged values.
+                if (!value || value == input.defaultValue.trim())
+                    continue;
+
+                // Don't save credit card numbers.
+                if (this.isValidCCNumber(value)) {
+                    this.log("skipping saving a credit card number");
+                    continue;
+                }
+
+                let name = input.name || input.id;
+                if (!name)
+                    continue;
+
+                // Limit stored data to 200 characters.
+                if (name.length > 200 || value.length > 200) {
+                    this.log("skipping input that has a name/value too large");
+                    continue;
+                }
+
+                // Limit number of fields stored per form.
+                if (savedCount++ >= 100) {
+                    this.log("not saving any more entries for this form.");
+                    break;
+                }
+
+                this.addEntry(name, value);
+            }
+        } catch (e) {
+            // Empty
+        } finally {
+            // Save whatever we've added so far.
+            this.dbConnection.commitTransaction();
+        }
+    },
+
+
     /* ---- helpers ---- */
 
 
     generateGUID : function() {
         // string like: "{f60d9eac-9421-4abc-8491-8e8322b063d4}"
         let uuid = this.uuidService.generateUUID().toString();
         let raw = ""; // A string with the low bytes set to random values
         let bytes = 0;
@@ -504,17 +559,17 @@ FormHistory.prototype = {
 
 
     expireOldEntries : function () {
         this.log("expireOldEntries");
 
         // Determine how many days of history we're supposed to keep.
         let expireDays = 180;
         try {
-            expireDays = Services.prefs.getIntPref("browser.formfill.expire_days");
+            expireDays = this.prefBranch.getIntPref("expire_days");
         } catch (e) { /* ignore */ }
 
         let expireTime = Date.now() - expireDays * DAY_IN_MS;
         expireTime *= 1000; // switch to microseconds
 
         this.sendIntNotification("before-expireOldEntries", expireTime);
 
         let beginningCount = this.countAllEntries();
@@ -543,21 +598,51 @@ FormHistory.prototype = {
         if (beginningCount - endingCount > 500)
             this.dbConnection.executeSimpleSQL("VACUUM");
 
         this.sendIntNotification("expireOldEntries", expireTime);
     },
 
 
     updatePrefs : function () {
-        this.debug          = Services.prefs.getBoolPref("browser.formfill.debug");
-        this.enabled        = Services.prefs.getBoolPref("browser.formfill.enable");
-        this.saveHttpsForms = Services.prefs.getBoolPref("browser.formfill.saveHttpsForms");
+        this.debug          = this.prefBranch.getBoolPref("debug");
+        this.enabled        = this.prefBranch.getBoolPref("enable");
+        this.saveHttpsForms = this.prefBranch.getBoolPref("saveHttpsForms");
     },
 
+
+    // Implements the Luhn checksum algorithm as described at
+    // http://wikipedia.org/wiki/Luhn_algorithm
+    isValidCCNumber : function (ccNumber) {
+        // Remove dashes and whitespace
+        ccNumber = ccNumber.replace(/[\-\s]/g, '');
+
+        let len = ccNumber.length;
+        if (len != 9 && len != 15 && len != 16)
+            return false;
+
+        if (!/^\d+$/.test(ccNumber))
+            return false;
+
+        let total = 0;
+        for (let i = 0; i < len; i++) {
+            let ch = parseInt(ccNumber[len - i - 1]);
+            if (i % 2 == 1) {
+                // Double it, add digits together if > 10
+                ch *= 2;
+                if (ch > 9)
+                    ch -= 9;
+            }
+            total += ch;
+        }
+        return total % 10 == 0;
+    },
+
+
+
 //**************************************************************************//
     // Database Creation & Access
 
     /*
      * dbCreateStatement
      *
      * Creates a statement, wraps it, and then does parameter replacement
      * Will use memoization so that statements can be reused.
--- a/toolkit/components/satchel/test/satchel_common.js
+++ b/toolkit/components/satchel/test/satchel_common.js
@@ -30,21 +30,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
  
-netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
 /*
  * $_
  *
  * Returns the element with the specified |name| attribute.
  */
 function $_(formNum, name) {
   var form = document.getElementById("form" + formNum);
   if (!form) {
@@ -112,65 +107,8 @@ function getAutocompletePopup() {
 
 function cleanUpFormHist() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   var formhist = Components.classes["@mozilla.org/satchel/form-history;1"].
                  getService(Components.interfaces.nsIFormHistory2);
   formhist.removeAllEntries();
 }
 cleanUpFormHist();
-
-
-var checkObserver = {
-  verifyStack: [],
-  callback: null,
-
-  waitForChecks: function(callback) {
-    if (this.verifyStack.length == 0)
-      callback();
-    else
-      this.callback = callback;
-  },
-
-  observe: function(subject, topic, data) {
-    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
-    if (data != "addEntry" && data != "modifyEntry")
-      return;
-    ok(this.verifyStack.length > 0, "checking if saved form data was expected");
-
-    // Make sure that every piece of data we expect to be saved is saved, and no
-    // more. Here it is assumed that for every entry satchel saves or modifies, a
-    // message is sent.
-    //
-    // We don't actually check the content of the message, but just that the right
-    // quantity of messages is received.
-    // - if there are too few messages, test will time out
-    // - if there are too many messages, test will error out here
-    //
-    var expected = this.verifyStack.shift();
-    ok(fh.entryExists(expected.name, expected.value), expected.message);
-
-    if (this.verifyStack.length == 0) {
-      var callback = this.callback;
-      this.callback = null;
-      callback();
-    }
-  }
-};
-
-function checkForSave(name, value, message) {
-  checkObserver.verifyStack.push({ name : name, value: value, message: message });
-}
-
-
-function getFormSubmitButton(formNum) {
-  var form = $("form" + formNum); // by id, not name
-  ok(form != null, "getting form " + formNum);
-
-  // we can't just call form.submit(), because that doesn't seem to
-  // invoke the form onsubmit handler.
-  var button = form.firstChild;
-  while (button && button.type != "submit") { button = button.nextSibling; }
-  ok(button != null, "getting form submit button");
-
-  return button;
-}
--- a/toolkit/components/satchel/test/subtst_form_submission_1.html
+++ b/toolkit/components/satchel/test/subtst_form_submission_1.html
@@ -1,38 +1,9 @@
-<!DOCTYPE HTML>
-<html>
-
-<head>
-</head>
-
-<body>
-
-<form id="subform1" onsubmit="return checkSubmit(21)">
+<form id="subform">
   <input id="subtest1" type="text" name="subtest1">
   <button type="submit">Submit</button>
 </form>
 
-<form id="subform2" onsubmit="return checkSubmit(100)">
-  <input id="subtest2" type="text" name="subtest2">
-  <button type="submit">Submit</button>
-</form>
-
 <script>
-  function checkSubmit(num) {
-    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-    return parent.checkSubmit(num);
-  }
-
-  function clickButton(num) {
-    if (num == 21)
-      document.querySelectorAll("button")[0].click();
-    else if (num == 100)
-      document.querySelectorAll("button")[1].click();
-  }
-
   // set the input's value (can't use a default value, as satchel will ignore it)
   document.getElementById("subtest1").value = "subtestValue";
-  document.getElementById("subtest2").value = "subtestValue";
 </script>
-
-</body>
-</html>
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -4,17 +4,16 @@
   <title>Satchel Test for Form Submisstion</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>  
   <script type="text/javascript" src="satchel_common.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <p id="display"></p>
-<iframe id="iframe" src="https://example.com/tests/toolkit/components/satchel/test/subtst_form_submission_1.html"></iframe>
 <div id="content" style="display: none">
   
   <!-- ===== Things that should not be saved. ===== -->
 
   <!-- autocomplete=off for input -->
   <form id="form1" onsubmit="return checkSubmit(1)">
     <input type="text" name="test1" autocomplete="off">
     <button type="submit">Submit</button>
@@ -218,16 +217,19 @@
         input.type = 'text';
         input.name = 'test8_' + (i + 1);
         form.appendChild(input);
       }
     </script>
     <button type="submit">Submit</button>
   </form>
 
+  <iframe id="iframe1" src="https://example.com/tests/toolkit/components/satchel/test/subtst_form_submission_1.html"></iframe>
+  <iframe id="iframe2" src="https://example.com/tests/toolkit/components/satchel/test/subtst_form_submission_1.html"></iframe>
+
   <!-- form data submitted through HTTPS, when browser.formfill.saveHttpsForms is true -->
   <form id="form109" action="https://www.example.com/" onsubmit="return checkSubmit(109)">
     <input type="text" name="test9">
     <button type="submit">Submit</button>
   </form>
 
   <!-- regular form data, when browser.formfill.saveHttpsForms is false -->
   <form id="form110" onsubmit="return checkSubmit(110)">
@@ -340,17 +342,17 @@ function startTest() {
 
 // Called by each form's onsubmit handler.
 function checkSubmit(formNum) {
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
   ok(true, "form " + formNum + " submitted");
   numSubmittedForms++;
 
-
+  
   // Check for expected storage state.
   switch (formNum) {
     // Test 1-20 should not save anything.
     case 1:
     case 2:
     case 3:
     case 4:
     case 5:
@@ -364,133 +366,133 @@ function checkSubmit(formNum) {
     case 13:
     case 14:
     case 15:
     case 16:
     case 17:
     case 18:
     case 19:
     case 20:
-    case 21:
         ok(!fh.hasEntries, "checking for empty storage");
         break;
-    case 100:
-        checkForSave("subtest2", "subtestValue", "checking saved subtest value");
-        break;
+    // The other tests do save data...
     case 101:
-        checkForSave("test1", "savedValue", "checking saved value");
+        ok(fh.entryExists("test1", "savedValue"), "checking saved value");
         break;
     case 102:
-        checkForSave("test2", "savedValue", "checking saved value");
+        ok(fh.entryExists("test2", "savedValue"), "checking saved value");
         break;
     case 103:
-        checkForSave("test3", "savedValue", "checking saved value");
+        ok(fh.entryExists("test3", "savedValue"), "checking saved value");
         break;
     case 104:
-        checkForSave("test4", "trimTrailingAndLeadingSpace", "checking saved value is trimmed on both sides");
+        ok(fh.entryExists("test4", "trimTrailingAndLeadingSpace"), "checking saved value is trimmed on both sides");
         break;
     case 105:
-        checkForSave("test5", "trimTrailingAndLeadingWhitespace", "checking saved value is trimmed on both sides");
+        ok(fh.entryExists("test5", "trimTrailingAndLeadingWhitespace"), "checking saved value is trimmed on both sides");
         break;
     case 106:
-        checkForSave("test6", "00000000109181", "checking saved value");
+        ok(fh.entryExists("test6", "00000000109181"), "checking saved value");
         break;
     case 107:
         for (var i = 0; i != ccNumbers.invalid16.length; i++) {
-          checkForSave("test7_" + (i + 1), ccNumbers.invalid16[i], "checking saved value");
+          ok(fh.entryExists("test7_" + (i + 1), ccNumbers.invalid16[i]), "checking saved value");
         }
         break;
     case 108:
         for (var i = 0; i != ccNumbers.invalid15.length; i++) {
-          checkForSave("test8_" + (i + 1), ccNumbers.invalid15[i], "checking saved value");
+          ok(fh.entryExists("test8_" + (i + 1), ccNumbers.invalid15[i]), "checking saved value");
         }
         break;
     case 109:
-        checkForSave("test9", "savedValue", "checking saved value");
+        ok(fh.entryExists("test9", "savedValue"), "checking saved value");
         break;
     case 110:
-        checkForSave("test10", "savedValue", "checking saved value");
+        ok(fh.entryExists("test10", "savedValue"), "checking saved value");
         break;
     default:
         ok(false, "Unexpected form submission");
         break;
   }
 
-  // Forms 13 and 14 would trigger a save-password notification. Temporarily
+  // Forms 13 and 14 would trigger a save-password notification. Tempoarily
   // disable pwmgr, then reenable it.
   if (formNum == 12)
       prefBranch.setBoolPref("signon.rememberSignons", false);
   if (formNum == 14)
       prefBranch.clearUserPref("signon.rememberSignons");
 
-  // Forms 20 and 21 requires browser.formfill.saveHttpsForms to be false
-  if (formNum == 19)
+  // Form 20 requires browser.formfill.saveHttpsForms to be false
+  // Run a couple subtests here, which submit forms from an HTTPS origin,
+  // these are loaded in iframes since the test suite isn't HTTPS. The subtest
+  // before the pref change should save a value, the (same) subtest run after
+  // the pref change should not.
+  if (formNum == 19) {
+    ok(true, "submitting subtest1");
+    var iframe = document.getElementById("iframe1");
+    iframe.contentDocument.forms[0].submit();
+    ok(fh.entryExists("subtest1", "subtestValue"), "checking saved subtest value");
+    fh.removeEntriesForName("subtest1");
+
     prefBranch.setBoolPref("browser.formfill.saveHttpsForms", false);
-  // Reset preference now that 20 and 21 are over
-  if (formNum == 21)
+
+    ok(true, "submitting subtest1");
+    iframe = document.getElementById("iframe2");
+    iframe.contentDocument.forms[0].submit();
+    ok(!fh.entryExists("subtest1", "subtestValue"), "checking unsaved subtest value");
+  }
+  if (formNum == 20)
     prefBranch.clearUserPref("browser.formfill.saveHttpsForms");
 
   // Form 109 requires browser.formfill.save_https_forms to be true;
   // Form 110 requires it to be false.
   if (formNum == 108)
     prefBranch.setBoolPref("browser.formfill.saveHttpsForms", true);
   if (formNum == 109)
     prefBranch.setBoolPref("browser.formfill.saveHttpsForms", false);
   if (formNum == 110)
     prefBranch.clearUserPref("browser.formfill.saveHttpsForms");
 
   // End the test at the last form.
   if (formNum == 110) {
-    is(numSubmittedForms, 32, "Ensuring all forms were submitted.");
-    Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
+    is(numSubmittedForms, 30, "Ensuring all forms were submitted.");
     SimpleTest.finish();
     return false; // return false to cancel current form submission
   }
 
-  // This timeout is here so that button.click() is never called before this
-  // function returns. If button.click() is called before returning, a long
-  // chain of submits will happen recursively since the submit is dispatched
-  // immediately.
-  //
-  // This in itself is fine, but if there are errors in the code, mochitests
-  // will in some cases give you "server too busy", which is hard to debug!
-  //
-  setTimeout(function() {
-    checkObserver.waitForChecks(function() {
-      netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-
-      var nextFormNum = formNum == 21 ? 100 : (formNum + 1);
-
-      // Submit the next form. Special cases are Forms 21 and 100, which happen
-      // from an HTTPS domain in an iframe.
-      if (nextFormNum == 21 || nextFormNum == 100) {
-        ok(true, "submitting iframe test " + nextFormNum);
-        document.getElementById("iframe").contentWindow.clickButton(nextFormNum);
-      }
-      else {
-        var button = getFormSubmitButton(nextFormNum);
-        button.click();
-      }
-    });
-  }, 0);
+  // submit the next form.
+  var button = getFormSubmitButton(formNum == 20 ? 101 : (formNum + 1));
+  button.click();
 
   return false; // cancel current form submission
 }
 
+
+function getFormSubmitButton(formNum) {
+  var form = $("form" + formNum); // by id, not name
+  ok(form != null, "getting form " + formNum);
+
+  // we can't just call form.submit(), because that doesn't seem to
+  // invoke the form onsubmit handler.
+  var button = form.firstChild;
+  while (button && button.type != "submit") { button = button.nextSibling; }
+  ok(button != null, "getting form submit button");
+
+  return button;
+}
+
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
 var fh = Components.classes["@mozilla.org/satchel/form-history;1"].
          getService(Components.interfaces.nsIFormHistory2);
 ok(fh != null, "Got formHistory service");
 
 var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].
                  getService(Components.interfaces.nsIPrefBranch);
 
-Services.obs.addObserver(checkObserver, "satchel-storage-changed", false);
-
 window.onload = startTest;
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/components/satchel/test/test_form_submission_cap.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap.html
@@ -58,45 +58,57 @@ function startTest() {
 function checkSubmit(formNum) {
   netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
   ok(true, "form " + formNum + " submitted");
   numSubmittedForms++;
 
   // check that the first (numInputFields - 1) CHANGED fields are saved
   for (i = 1; i < numInputFields; i++) { // check all but last
-    checkForSave("test" + i, i, "checking saved value " + i);
+    ok(fh.entryExists("test" + i, i), "checking saved value " + i);
   }
 
+  // make sure that the remaining changed fields are not saved
+  ok(!fh.entryExists("test" + numInputFields, numInputFields), "checking unsaved value " + numInputFields);
+
+
   // End the test at the last form.
   if (formNum == 1) {
     is(numSubmittedForms, 1, "Ensuring all forms were submitted.");
-    Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
     SimpleTest.finish();
     return false; // return false to cancel current form submission
   }
 
-  checkObserver.waitForChecks(function() {
-    // submit the next form.
-    var button = getFormSubmitButton(formNum + 1);
-    button.click();
-  });
+  // submit the next form.
+  var button = getFormSubmitButton(formNum + 1);
+  button.click();
 
   return false; // cancel current form submission
 }
 
 
+function getFormSubmitButton(formNum) {
+  var form = $("form" + formNum); // by id, not name
+  ok(form != null, "getting form " + formNum);
+
+  // we can't just call form.submit(), because that doesn't seem to
+  // invoke the form onsubmit handler.
+  var button = form.firstChild;
+  while (button && button.type != "submit") { button = button.nextSibling; }
+  ok(button != null, "getting form submit button");
+
+  return button;
+}
+
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
 var fh = Components.classes["@mozilla.org/satchel/form-history;1"].
          getService(Components.interfaces.nsIFormHistory2);
 ok(fh != null, "Got formHistory service");
 
 window.onload = startTest;
 
-Services.obs.addObserver(checkObserver, "satchel-storage-changed", false);
-
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
--- a/toolkit/components/satchel/test/test_form_submission_cap2.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap2.html
@@ -150,45 +150,53 @@ function checkSubmit(formNum) {
   numSubmittedForms++;
 
   // make sure that the first (numInputFields - 1) were not saved (as they were not changed)
   for (i = 1; i < numInputFields; i++) {
     ok(!fh.entryExists("test" + i, i), "checking unsaved value " + i);
   }
 
   // make sure that the field # numInputFields was saved
-  checkForSave("test" + numInputFields, numInputFields + " changed", "checking saved value " + numInputFields);
+  ok(fh.entryExists("test" + numInputFields, numInputFields + " changed"), "checking saved value " + numInputFields);
 
 
   // End the test at the last form.
   if (formNum == 1) {
     is(numSubmittedForms, 1, "Ensuring all forms were submitted.");
-    Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
     SimpleTest.finish();
     return false; // return false to cancel current form submission
   }
 
-  checkObserver.waitForChecks(function() {
-    // submit the next form.
-    var button = getFormSubmitButton(formNum + 1);
-    button.click();
-  });
+  // submit the next form.
+  var button = getFormSubmitButton(formNum + 1);
+  button.click();
 
   return false; // cancel current form submission
 }
 
 
+function getFormSubmitButton(formNum) {
+  var form = $("form" + formNum); // by id, not name
+  ok(form != null, "getting form " + formNum);
+
+  // we can't just call form.submit(), because that doesn't seem to
+  // invoke the form onsubmit handler.
+  var button = form.firstChild;
+  while (button && button.type != "submit") { button = button.nextSibling; }
+  ok(button != null, "getting form submit button");
+
+  return button;
+}
+
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
 var fh = Components.classes["@mozilla.org/satchel/form-history;1"].
          getService(Components.interfaces.nsIFormHistory2);
 ok(fh != null, "Got formHistory service");
 
 window.onload = startTest;
 
-Services.obs.addObserver(checkObserver, "satchel-storage-changed", false);
-
 SimpleTest.waitForExplicitFinish();
 
 </script>
 </pre>
 </body>
 </html>
--- a/widget/public/Makefile.in
+++ b/widget/public/Makefile.in
@@ -41,22 +41,16 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= widget
 XPIDL_MODULE	= widget
 GRE_MODULE	= 1
 
-EXPORTS_NAMESPACES = mozilla/widget
-
-EXPORTS_mozilla/widget = \
-		nsGUIEventIPC.h \
-		$(NULL)
-
 EXPORTS		= \
 		nsIWidget.h \
 		nsGUIEvent.h \
 		nsEvent.h \
 		nsNativeWidget.h \
 		nsWidgetInitData.h \
 		nsWidgetsCID.h \
 		nsILookAndFeel.h \
--- a/widget/public/nsGUIEvent.h
+++ b/widget/public/nsGUIEvent.h
@@ -55,25 +55,16 @@
 #include "nsPIDOMEventTarget.h"
 #include "nsWeakPtr.h"
 #include "nsIWidget.h"
 #include "nsTArray.h"
 #include "nsTraceRefcnt.h"
 #include "nsITransferable.h"
 #include "nsIVariant.h"
 
-#ifdef MOZ_IPC
-namespace mozilla {
-namespace dom {
-  class PBrowserParent;
-  class PBrowserChild;
-}
-}
-#endif // MOZ_IPC
-
 #ifdef ACCESSIBILITY
 class nsAccessible;
 #endif
 class nsIRenderingContext;
 class nsIMenuItem;
 class nsIContent;
 class nsIURI;
 class nsHashKey;
@@ -513,22 +504,16 @@ protected:
       refPoint(0, 0),
       time(0),
       flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
       userType(0)
   {
     MOZ_COUNT_CTOR(nsEvent);
   }
 
-#ifdef MOZ_IPC
-  nsEvent()
-  {
-  }
-#endif // MOZ_IPC
-
 public:
   nsEvent(PRBool isTrusted, PRUint32 msg)
     : eventStructType(NS_EVENT),
       message(msg),
       refPoint(0, 0),
       time(0),
       flags(isTrusted ? NS_EVENT_FLAG_TRUSTED : NS_EVENT_FLAG_NONE),
       userType(0)
@@ -570,23 +555,16 @@ class nsGUIEvent : public nsEvent
 {
 protected:
   nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w, PRUint8 structType)
     : nsEvent(isTrusted, msg, structType),
       widget(w), pluginEvent(nsnull)
   {
   }
 
-#ifdef MOZ_IPC
-  nsGUIEvent()
-    : pluginEvent(nsnull)
-  {
-  }
-#endif // MOZ_IPC
-
 public:
   nsGUIEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsEvent(isTrusted, msg, NS_GUI_EVENT),
       widget(w), pluginEvent(nsnull)
   {
   }
 
   /// Originator of the event
@@ -741,22 +719,16 @@ class nsInputEvent : public nsGUIEvent
 protected:
   nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w,
                PRUint8 structType)
     : nsGUIEvent(isTrusted, msg, w, structType),
       isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
   {
   }
 
-#ifdef MOZ_IPC
-  nsInputEvent()
-  {
-  }
-#endif // MOZ_IPC
-
 public:
   nsInputEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsGUIEvent(isTrusted, msg, w, NS_INPUT_EVENT),
       isShift(PR_FALSE), isControl(PR_FALSE), isAlt(PR_FALSE), isMeta(PR_FALSE)
   {
   }
 
   /// PR_TRUE indicates the shift key is down
@@ -1043,26 +1015,16 @@ struct nsTextRange
 
   nsTextRangeStyle mRangeStyle;
 };
 
 typedef nsTextRange* nsTextRangeArray;
 
 class nsTextEvent : public nsInputEvent
 {
-#ifdef MOZ_IPC
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-  nsTextEvent()
-  {
-  }
-#endif // MOZ_IPC
-
 public:
   nsTextEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsInputEvent(isTrusted, msg, w, NS_TEXT_EVENT),
       rangeCount(0), rangeArray(nsnull), isChar(PR_FALSE)
   {
   }
 
   nsString          theText;
@@ -1071,26 +1033,16 @@ public:
   // case there will be no range of type NS_TEXTRANGE_CARETPOSITION in the
   // array.
   nsTextRangeArray  rangeArray;
   PRBool            isChar;
 };
 
 class nsCompositionEvent : public nsInputEvent
 {
-#ifdef MOZ_IPC
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-  nsCompositionEvent()
-  {
-  }
-#endif // MOZ_IPC
-
 public:
   nsCompositionEvent(PRBool isTrusted, PRUint32 msg, nsIWidget *w)
     : nsInputEvent(isTrusted, msg, w, NS_COMPOSITION_EVENT)
   {
   }
 };
 
 /* Mouse Scroll Events: Line Scrolling, Pixel Scrolling and Common Event Flows
@@ -1195,32 +1147,20 @@ public:
     panDirection(ePanNone),
     displayPanFeedback(PR_FALSE)
   {
   }
 };
 
 class nsQueryContentEvent : public nsGUIEvent
 {
-#ifdef MOZ_IPC
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-  nsQueryContentEvent()
-  {
-    mReply.mContentsRoot = nsnull;
-    mReply.mFocusedWidget = nsnull;
-  }
-#endif // MOZ_IPC
-
 public:
   nsQueryContentEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
     nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_QUERY_CONTENT_EVENT),
-    mSucceeded(PR_FALSE), mWasAsync(PR_FALSE)
+    mSucceeded(PR_FALSE)
   {
   }
 
   void InitForQueryTextContent(PRUint32 aOffset, PRUint32 aLength)
   {
     NS_ASSERTION(message == NS_QUERY_TEXT_CONTENT,
                  "wrong initializer is called");
     mInput.mOffset = aOffset;
@@ -1237,32 +1177,17 @@ public:
   void InitForQueryTextRect(PRUint32 aOffset, PRUint32 aLength)
   {
     NS_ASSERTION(message == NS_QUERY_TEXT_RECT,
                  "wrong initializer is called");
     mInput.mOffset = aOffset;
     mInput.mLength = aLength;
   }
 
-  PRUint32 GetSelectionStart(void) const
-  {
-    NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
-                 "not querying selection");
-    return mReply.mOffset + (mReply.mReversed ? mReply.mString.Length() : 0);
-  }
-
-  PRUint32 GetSelectionEnd(void) const
-  {
-    NS_ASSERTION(message == NS_QUERY_SELECTED_TEXT,
-                 "not querying selection");
-    return mReply.mOffset + (mReply.mReversed ? 0 : mReply.mString.Length());
-  }
-
   PRBool mSucceeded;
-  PRPackedBool mWasAsync;
   struct {
     PRUint32 mOffset;
     PRUint32 mLength;
   } mInput;
   struct {
     void* mContentsRoot;
     PRUint32 mOffset;
     nsString mString;
@@ -1289,26 +1214,16 @@ public:
   {
   }
 
   PRPackedBool fromRaise;
 };
 
 class nsSelectionEvent : public nsGUIEvent
 {
-#ifdef MOZ_IPC
-private:
-  friend class mozilla::dom::PBrowserParent;
-  friend class mozilla::dom::PBrowserChild;
-
-  nsSelectionEvent()
-  {
-  }
-#endif // MOZ_IPC
-
 public:
   nsSelectionEvent(PRBool aIsTrusted, PRUint32 aMsg, nsIWidget *aWidget) :
     nsGUIEvent(aIsTrusted, aMsg, aWidget, NS_SELECTION_EVENT),
     mExpandToClusterBoundary(PR_TRUE), mSucceeded(PR_FALSE)
   {
   }
 
   PRUint32 mOffset; // start offset of selection
deleted file mode 100644
--- a/widget/public/nsGUIEventIPC.h
+++ /dev/null
@@ -1,284 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * The Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsGUIEventIPC_h__
-#define nsGUIEventIPC_h__
-
-#include "IPC/IPCMessageUtils.h"
-#include "nsGUIEvent.h"
-
-namespace IPC
-{
-
-template<>
-struct ParamTraits<nsEvent>
-{
-  typedef nsEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, aParam.eventStructType);
-    WriteParam(aMsg, aParam.message);
-    WriteParam(aMsg, aParam.refPoint);
-    WriteParam(aMsg, aParam.time);
-    WriteParam(aMsg, aParam.flags);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->eventStructType) &&
-           ReadParam(aMsg, aIter, &aResult->message) &&
-           ReadParam(aMsg, aIter, &aResult->refPoint) &&
-           ReadParam(aMsg, aIter, &aResult->time) &&
-           ReadParam(aMsg, aIter, &aResult->flags);
-  }
-};
-
-template<>
-struct ParamTraits<nsGUIEvent>
-{
-  typedef nsGUIEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsEvent>(aParam));
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, static_cast<nsEvent*>(aResult));
-  }
-};
-
-template<>
-struct ParamTraits<nsInputEvent>
-{
-  typedef nsInputEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsGUIEvent>(aParam));
-    WriteParam(aMsg, aParam.isShift);
-    WriteParam(aMsg, aParam.isControl);
-    WriteParam(aMsg, aParam.isAlt);
-    WriteParam(aMsg, aParam.isMeta);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, static_cast<nsGUIEvent*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->isShift) &&
-           ReadParam(aMsg, aIter, &aResult->isControl) &&
-           ReadParam(aMsg, aIter, &aResult->isAlt) &&
-           ReadParam(aMsg, aIter, &aResult->isMeta);
-  }
-};
-
-template<>
-struct ParamTraits<nsTextRangeStyle>
-{
-  typedef nsTextRangeStyle paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, aParam.mDefinedStyles);
-    WriteParam(aMsg, aParam.mLineStyle);
-    WriteParam(aMsg, aParam.mIsBoldLine);
-    WriteParam(aMsg, aParam.mForegroundColor);
-    WriteParam(aMsg, aParam.mBackgroundColor);
-    WriteParam(aMsg, aParam.mUnderlineColor);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mDefinedStyles) &&
-           ReadParam(aMsg, aIter, &aResult->mLineStyle) &&
-           ReadParam(aMsg, aIter, &aResult->mIsBoldLine) &&
-           ReadParam(aMsg, aIter, &aResult->mForegroundColor) &&
-           ReadParam(aMsg, aIter, &aResult->mBackgroundColor) &&
-           ReadParam(aMsg, aIter, &aResult->mUnderlineColor);
-  }
-};
-
-template<>
-struct ParamTraits<nsTextRange>
-{
-  typedef nsTextRange paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, aParam.mStartOffset);
-    WriteParam(aMsg, aParam.mEndOffset);
-    WriteParam(aMsg, aParam.mRangeType);
-    WriteParam(aMsg, aParam.mRangeStyle);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, &aResult->mStartOffset) &&
-           ReadParam(aMsg, aIter, &aResult->mEndOffset) &&
-           ReadParam(aMsg, aIter, &aResult->mRangeType) &&
-           ReadParam(aMsg, aIter, &aResult->mRangeStyle);
-  }
-};
-
-template<>
-struct ParamTraits<nsTextEvent>
-{
-  typedef nsTextEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsInputEvent>(aParam));
-    WriteParam(aMsg, aParam.theText);
-    WriteParam(aMsg, aParam.isChar);
-    WriteParam(aMsg, aParam.rangeCount);
-    for (PRUint32 index = 0; index < aParam.rangeCount; index++)
-      WriteParam(aMsg, aParam.rangeArray[index]);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    if (!ReadParam(aMsg, aIter, static_cast<nsInputEvent*>(aResult)) ||
-        !ReadParam(aMsg, aIter, &aResult->theText) ||
-        !ReadParam(aMsg, aIter, &aResult->isChar) ||
-        !ReadParam(aMsg, aIter, &aResult->rangeCount))
-      return false;
-
-    if (!aResult->rangeCount) {
-      aResult->rangeArray = nsnull;
-      return true;
-    }
-
-    aResult->rangeArray = new nsTextRange[aResult->rangeCount];
-    if (!aResult->rangeArray)
-      return false;
-
-    for (PRUint32 index = 0; index < aResult->rangeCount; index++)
-      if (!ReadParam(aMsg, aIter, &aResult->rangeArray[index])) {
-        Free(*aResult);
-        return false;
-      }
-    return true;
-  }
-
-  static void Free(const paramType& aResult)
-  {
-    if (aResult.rangeArray)
-      delete [] aResult.rangeArray;
-  }
-};
-
-template<>
-struct ParamTraits<nsCompositionEvent>
-{
-  typedef nsCompositionEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsInputEvent>(aParam));
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, static_cast<nsInputEvent*>(aResult));
-  }
-};
-
-template<>
-struct ParamTraits<nsQueryContentEvent>
-{
-  typedef nsQueryContentEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsGUIEvent>(aParam));
-    WriteParam(aMsg, aParam.mSucceeded);
-    WriteParam(aMsg, aParam.mInput.mOffset);
-    WriteParam(aMsg, aParam.mInput.mLength);
-    WriteParam(aMsg, aParam.mReply.mOffset);
-    WriteParam(aMsg, aParam.mReply.mString);
-    WriteParam(aMsg, aParam.mReply.mRect);
-    WriteParam(aMsg, aParam.mReply.mReversed);
-    WriteParam(aMsg, aParam.mReply.mHasSelection);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    aResult->mWasAsync = PR_TRUE;
-    return ReadParam(aMsg, aIter, static_cast<nsGUIEvent*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->mSucceeded) &&
-           ReadParam(aMsg, aIter, &aResult->mInput.mOffset) &&
-           ReadParam(aMsg, aIter, &aResult->mInput.mLength) &&
-           ReadParam(aMsg, aIter, &aResult->mReply.mOffset) &&
-           ReadParam(aMsg, aIter, &aResult->mReply.mString) &&
-           ReadParam(aMsg, aIter, &aResult->mReply.mRect) &&
-           ReadParam(aMsg, aIter, &aResult->mReply.mReversed) &&
-           ReadParam(aMsg, aIter, &aResult->mReply.mHasSelection);
-  }
-};
-
-template<>
-struct ParamTraits<nsSelectionEvent>
-{
-  typedef nsSelectionEvent paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    WriteParam(aMsg, static_cast<nsGUIEvent>(aParam));
-    WriteParam(aMsg, aParam.mOffset);
-    WriteParam(aMsg, aParam.mLength);
-    WriteParam(aMsg, aParam.mReversed);
-    WriteParam(aMsg, aParam.mExpandToClusterBoundary);
-    WriteParam(aMsg, aParam.mSucceeded);
-  }
-
-  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
-  {
-    return ReadParam(aMsg, aIter, static_cast<nsGUIEvent*>(aResult)) &&
-           ReadParam(aMsg, aIter, &aResult->mOffset) &&
-           ReadParam(aMsg, aIter, &aResult->mLength) &&
-           ReadParam(aMsg, aIter, &aResult->mReversed) &&
-           ReadParam(aMsg, aIter, &aResult->mExpandToClusterBoundary) &&
-           ReadParam(aMsg, aIter, &aResult->mSucceeded);
-  }
-};
-
-} // namespace IPC
-
-#endif // nsGUIEventIPC_h__
-
--- a/widget/src/android/AndroidBridge.cpp
+++ b/widget/src/android/AndroidBridge.cpp
@@ -32,20 +32,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <android/log.h>
 
-#ifdef MOZ_IPC
 #include "mozilla/dom/ContentChild.h"
-#include "nsXULAppAPI.h"
-#endif
 #include <pthread.h>
 #include <prthread.h>
 #include "nsXPCOMStrings.h"
 
 #include "AndroidBridge.h"
 
 using namespace mozilla;
 
@@ -190,34 +187,28 @@ AndroidBridge::EnsureJNIThread()
 }
 
 void
 AndroidBridge::NotifyIME(int aType, int aState)
 {
     if (sBridge)
         JNI()->CallStaticVoidMethod(sBridge->mGeckoAppShellClass, 
                                     sBridge->jNotifyIME,  aType, aState);
-#ifdef MOZ_IPC
-    // It's possible that we are in chrome process
-    //  but sBridge is not initialized yet
-    else if (XRE_GetProcessType() == GeckoProcessType_Content)
+    else
         mozilla::dom::ContentChild::GetSingleton()->SendNotifyIME(aType, aState);
-#endif
 }
 
 void
 AndroidBridge::NotifyIMEChange(const PRUnichar *aText, PRUint32 aTextLen,
                                int aStart, int aEnd, int aNewEnd)
 {
     if (!sBridge) {
-#ifdef MOZ_IPC
         mozilla::dom::ContentChild::GetSingleton()->
             SendNotifyIMEChange(nsAutoString(aText), aTextLen,
                                 aStart, aEnd, aNewEnd);
-#endif
         return;
     }
 
     jvalue args[4];
     AutoLocalJNIFrame jniFrame(1);
     args[0].l = JNI()->NewString(aText, aTextLen);
     args[1].i = aStart;
     args[2].i = aEnd;
--- a/widget/src/android/nsWindow.cpp
+++ b/widget/src/android/nsWindow.cpp
@@ -1360,21 +1360,21 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
             
             DispatchEvent(&event);
 
             if (!event.mSucceeded) {
                 ALOGIME("IME:     -> failed");
                 AndroidBridge::Bridge()->ReturnIMEQueryResult(
                     nsnull, 0, 0, 0);
                 return;
-            } else if (!event.mWasAsync) {
-                AndroidBridge::Bridge()->ReturnIMEQueryResult(
-                    event.mReply.mString.get(), 
-                    event.mReply.mString.Length(), 0, 0);
             }
+
+            AndroidBridge::Bridge()->ReturnIMEQueryResult(
+                event.mReply.mString.get(), 
+                event.mReply.mString.Length(), 0, 0);
             //ALOGIME("IME:     -> l=%u", event.mReply.mString.Length());
         }
         return;
     case AndroidGeckoEvent::IME_DELETE_TEXT:
         {   
             ALOGIME("IME: IME_DELETE_TEXT");
             nsContentCommandEvent event(PR_TRUE,
                                         NS_CONTENT_COMMAND_DELETE, this);
@@ -1406,23 +1406,31 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
             InitEvent(event, nsnull);
             DispatchEvent(&event);
 
             if (!event.mSucceeded) {
                 ALOGIME("IME:     -> failed");
                 AndroidBridge::Bridge()->ReturnIMEQueryResult(
                     nsnull, 0, 0, 0);
                 return;
-            } else if (!event.mWasAsync) {
-                AndroidBridge::Bridge()->ReturnIMEQueryResult(
-                    event.mReply.mString.get(),
-                    event.mReply.mString.Length(), 
-                    event.GetSelectionStart(),
-                    event.GetSelectionEnd() - event.GetSelectionStart());
             }
+
+            int selStart = int(event.mReply.mOffset + 
+                            (event.mReply.mReversed ? 
+                                event.mReply.mString.Length() : 0));
+
+            int selLength = event.mReply.mReversed ?
+                                int(event.mReply.mString.Length()) : 
+                                -int(event.mReply.mString.Length());
+
+            AndroidBridge::Bridge()->ReturnIMEQueryResult(
+                event.mReply.mString.get(),
+                event.mReply.mString.Length(), 
+                selStart, selLength);
+
             //ALOGIME("IME:     -> o=%u, l=%u", event.mReply.mOffset, event.mReply.mString.Length());
         }
         return;
     }
 }
 
 nsWindow *
 nsWindow::FindWindowForPoint(const nsIntPoint& pt)
@@ -1507,19 +1515,20 @@ nsWindow::CancelIMEComposition()
     AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_CANCELCOMPOSITION, 0);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::OnIMEFocusChange(PRBool aFocus)
 {
     ALOGIME("IME: OnIMEFocusChange: f=%d", aFocus);
-
-    AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE, 
-                             int(aFocus));
+    
+    if (AndroidBridge::Bridge())
+        AndroidBridge::NotifyIME(AndroidBridge::NOTIFY_IME_FOCUSCHANGE, 
+                                 int(aFocus));
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWindow::OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd)
 {
     ALOGIME("IME: OnIMETextChange: s=%d, oe=%d, ne=%d",
             aStart, aOldEnd, aNewEnd);