Bug 605365 - Change Content's formAssistant to be a public property (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Mon, 19 Sep 2011 09:45:52 -0700
changeset 77138 a9adf1767b4668df8ad0fa036db2bf19a07616d0
parent 77137 4e1b3e291b1bc0ee611abb67d1e027345602662e
child 77139 f17d190c8c6cee9ebb9aff8bd797ec22d4956eef
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmfinkle
bugs605365
milestone9.0a1
Bug 605365 - Change Content's formAssistant to be a public property (r=mfinkle) So that we can share the same FormAssistant instance with other components defined in content.js. Updated chrome tests accordingly.
mobile/chrome/content/content.js
mobile/chrome/tests/remote_autocomplete.js
mobile/chrome/tests/remote_contentpopup.js
mobile/chrome/tests/remote_forms.js
mobile/chrome/tests/remote_formsZoom.js
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -249,19 +249,19 @@ function getContentClientRects(aElement)
                   height: r.height
                 });
   }
   return result;
 };
 
 
 let Content = {
-  get _formAssistant() {
-    delete this._formAssistant;
-    return this._formAssistant = new FormAssistant();
+  get formAssistant() {
+    delete this.formAssistant;
+    return this.formAssistant = new FormAssistant();
   },
 
   init: function init() {
     this._isZoomedToElement = false;
 
     addMessageListener("Browser:Blur", this);
     addMessageListener("Browser:MouseOver", this);
     addMessageListener("Browser:MouseLong", this);
@@ -485,37 +485,37 @@ let Content = {
                              0, null);
         event.x = x;
         event.y = y;
         element.dispatchEvent(event);
         break;
       }
 
       case "Browser:MouseClick": {
-        this._formAssistant.focusSync = true;
+        this.formAssistant.focusSync = true;
         let element = elementFromPoint(x, y);
         if (modifiers == Ci.nsIDOMNSEvent.CONTROL_MASK) {
           let uri = Util.getHrefForElement(element);
           if (uri)
             sendAsyncMessage("Browser:OpenURI", { uri: uri,
                                                   referrer: element.ownerDocument.documentURIObject.spec });
           break;
         }
 
-        if (!this._formAssistant.open(element))
+        if (!this.formAssistant.open(element))
           sendAsyncMessage("FindAssist:Hide", { });
 
         if (this._highlightElement) {
           this._sendMouseEvent("mousemove", this._highlightElement, x, y);
           this._sendMouseEvent("mousedown", this._highlightElement, x, y);
           this._sendMouseEvent("mouseup", this._highlightElement, x, y);
         }
         this._cancelTapHighlight();
         ContextHandler.reset();
-        this._formAssistant.focusSync = false;
+        this.formAssistant.focusSync = false;
         break;
       }
 
       case "Browser:SaveAs":
         if (json.type != Ci.nsIPrintSettings.kOutputFormatPDF)
           return;
 
         let printSettings = Cc["@mozilla.org/gfx/printsettings-service;1"]
--- a/mobile/chrome/tests/remote_autocomplete.js
+++ b/mobile/chrome/tests/remote_autocomplete.js
@@ -1,11 +1,11 @@
 dump("====================== Content Script Loaded =======================\n");
 
-let assistant = Content._formAssistant;
+let assistant = Content.formAssistant;
 
 AsyncTests.add("TestRemoteAutocomplete:Click", function(aMessage, aJson) {
   let element = content.document.getElementById(aJson.id);
   assistant.open(element);
   return true;
 });
 
 AsyncTests.add("TestRemoteAutocomplete:Check", function(aMessage, aJson) {
--- a/mobile/chrome/tests/remote_contentpopup.js
+++ b/mobile/chrome/tests/remote_contentpopup.js
@@ -1,11 +1,11 @@
 dump("====================== Content Script Loaded =======================\n");
 
-let assistant = Content._formAssistant;
+let assistant = Content.formAssistant;
 
 AsyncTests.add("TestRemoteAutocomplete:Click", function(aMessage, aJson) {
   let element = content.document.getElementById(aJson.id);
   assistant.open(element);
   assistant._executeDelayed(function(assistant) {
     sendAsyncMessage("FormAssist:AutoComplete", assistant._getJSON());
   });
   return true;
--- a/mobile/chrome/tests/remote_forms.js
+++ b/mobile/chrome/tests/remote_forms.js
@@ -1,11 +1,11 @@
 dump("====================== Content Script Loaded =======================\n");
 
-let assistant = Content._formAssistant;
+let assistant = Content.formAssistant;
 
 // Copied from http://mxr.mozilla.org/mozilla-central/source/testing/mochitest/tests/SimpleTest/EventUtils.js
 // except the netscape.security.PrivilegeManager.enablePrivilege call
 function sendMouseEvent(aEvent, aTarget, aWindow) {
   if (['click', 'mousedown', 'mouseup', 'mouseover', 'mouseout'].indexOf(aEvent.type) == -1) {
     throw new Error("sendMouseEvent doesn't know about event type '" + aEvent.type + "'");
   }
 
--- a/mobile/chrome/tests/remote_formsZoom.js
+++ b/mobile/chrome/tests/remote_formsZoom.js
@@ -1,9 +1,9 @@
 dump("====================== Content Script Loaded =======================\n");
 
-let assistant = Content._formAssistant;
+let assistant = Content.formAssistant;
 
 AsyncTests.add("FormAssist:Show", function(aMessage, aJson) {
   let element = content.document.getElementById(aJson.id);
   assistant.open(element);
 });