Bug 852197 - Cleanup and fix various console warnings in Metro front end. r=mbrubeck
authorBrian R. Bondy <netzen@gmail.com>
Tue, 19 Mar 2013 10:52:24 -0400
changeset 131847 121c90c4ebe429a3941983c589ea11581040fb64
parent 131846 85eca178a678385f98a385935dfcffa8bb775fdc
child 131848 9e6e38d4ae0bb948df7c8d837e10bbaab15f6d2a
push idunknown
push userunknown
push dateunknown
reviewersmbrubeck
bugs852197
milestone22.0a1
Bug 852197 - Cleanup and fix various console warnings in Metro front end. r=mbrubeck
browser/metro/base/content/bindings/grid.xml
browser/metro/base/content/bookmarks.js
browser/metro/base/content/browser-scripts.js
browser/metro/base/content/browser-ui.js
browser/metro/base/content/input.js
--- a/browser/metro/base/content/bindings/grid.xml
+++ b/browser/metro/base/content/bindings/grid.xml
@@ -509,21 +509,16 @@
       <property name="backgroundimage"
                 onset="this._backgroundimage = val; this.setBackgroundImage();"
                 onget="return this._backgroundimage;" />
       <property name="selected"
                 onget="return this.getAttribute('selected') == 'true';" />
 
       <constructor>
         <![CDATA[
-          // Bindings don't get bound until the item is displayed,
-          // so we have to reset the background color/image when we get
-          // created.
-          this.setColor();
-          this.setBackgroundImage();
         ]]>
       </constructor>
 
       <property name="control">
         <getter><![CDATA[
           var parent = this.parentNode;
           while (parent) {
             if (parent instanceof Components.interfaces.nsIDOMXULSelectControlElement)
@@ -532,30 +527,30 @@
           }
           return null;
         ]]></getter>
       </property>
 
       <method name="setColor">
         <body>
           <![CDATA[
-            if (this.color != undefined) {
+            if (this._color != undefined) {
               this._box.parentNode.setAttribute("customColorPresent", "true");
               this._box.style.backgroundColor = this.color;
             } else {
               this._box.parentNode.removeAttribute("customColorPresent");
             }
           ]]>
         </body>
       </method>
 
       <method name="setBackgroundImage">
         <body>
           <![CDATA[
-            if (this.backgroundImage != undefined) {
+            if (this._backgroundImage != undefined) {
               this._box.parentNode.setAttribute("customImagePresent", "true");
               this._box.style.backgroundImage = this.backgroundImage;
             } else {
               this._box.parentNode.removeAttribute("customImagePresent");
               this._box.style.removeProperty("background-image");
             }
           ]]>
         </body>
--- a/browser/metro/base/content/bookmarks.js
+++ b/browser/metro/base/content/bookmarks.js
@@ -220,16 +220,19 @@ BookmarksView.prototype = {
   _gotIcon: function _gotIcon(aBookmarkId, aItem, aIconUri) {
     aItem.setAttribute("iconURI", aIconUri ? aIconUri.spec : "");
 
     let color = Bookmarks.getFaveIconPrimaryColor(aBookmarkId);
     if (color) {
       aItem.color = color;
       return;
     }
+    if (!aIconUri) {
+      return;
+    }
     let url = Services.io.newURI(aIconUri.spec.replace("moz-anno:favicon:",""), "", null)
     let ca = Components.classes["@mozilla.org/places/colorAnalyzer;1"]
                        .getService(Components.interfaces.mozIColorAnalyzer);
     ca.findRepresentativeColor(url, function (success, color) {
       let colorStr = Bookmarks.fixupColorFormat(color);
       Bookmarks.setFaveIconPrimaryColor(aBookmarkId, colorStr);
       aItem.color = colorStr;
     }, this);
--- a/browser/metro/base/content/browser-scripts.js
+++ b/browser/metro/base/content/browser-scripts.js
@@ -113,17 +113,16 @@ let ScriptContexts = {};
   ["PreferencesPanelView", "chrome://browser/content/preferences.js"],
   ["BookmarksStartView", "chrome://browser/content/bookmarks.js"],
   ["HistoryView", "chrome://browser/content/history.js"],
   ["HistoryStartView", "chrome://browser/content/history.js"],
   ["HistoryPanelView", "chrome://browser/content/history.js"],
   ["TopSitesView", "chrome://browser/content/TopSites.js"],
   ["TopSitesSnappedView", "chrome://browser/content/TopSites.js"],
   ["TopSitesStartView", "chrome://browser/content/TopSites.js"],
-  ["InputSourceHelper", "chrome://browser/content/input.js"],
   ["Sanitizer", "chrome://browser/content/sanitize.js"],
   ["SSLExceptions", "chrome://browser/content/exceptions.js"],
 #ifdef MOZ_SERVICES_SYNC
   ["WeaveGlue", "chrome://browser/content/sync.js"],
   ["SyncPairDevice", "chrome://browser/content/sync.js"],
   ["RemoteTabsView", "chrome://browser/content/RemoteTabs.js"],
   ["RemoteTabsPanelView", "chrome://browser/content/RemoteTabs.js"],
   ["RemoteTabsStartView", "chrome://browser/content/RemoteTabs.js"],
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -1604,17 +1604,17 @@ var DialogUI = {
     xhr.open("GET", aSrc, false);
     xhr.overrideMimeType("text/xml");
     xhr.send(null);
     if (!xhr.responseXML)
       return null;
 
     let currentNode;
     let nodeIterator = xhr.responseXML.createNodeIterator(xhr.responseXML, NodeFilter.SHOW_TEXT, null, false);
-    while (currentNode = nodeIterator.nextNode()) {
+    while (!!(currentNode = nodeIterator.nextNode())) {
       let trimmed = currentNode.nodeValue.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
       if (!trimmed.length)
         currentNode.parentNode.removeChild(currentNode);
     }
 
     let doc = xhr.responseXML.documentElement;
 
     let dialog  = null;
--- a/browser/metro/base/content/input.js
+++ b/browser/metro/base/content/input.js
@@ -1149,30 +1149,18 @@ var GestureModule = {
   }
 };
 
 /**
  * Helper to track when the user is using a precise pointing device (pen/mouse)
  * versus an imprecise one (touch).
  */
 var InputSourceHelper = {
-  _isPrecise: false,
-  _treatMouseAsTouch: false,
-  
-  get isPrecise() {
-    return this._isPrecise;
-  },
-  
-  get treatMouseAsTouch() {
-    return this._treatMouseAsTouch;
-  },
-
-  set treatMouseAsTouch(aVal) {
-    this._treatMouseAsTouch = aVal;
-  },
+  isPrecise: false,
+  treatMouseAsTouch: false,
 
   init: function ish_init() {
     // debug feature, make all input imprecise
     try {
       this.treatMouseAsTouch = Services.prefs.getBoolPref(kDebugMouseInputPref);
     } catch (e) {}
     if (!this.treatMouseAsTouch) {
       window.addEventListener("mousemove", this, true);
@@ -1181,36 +1169,36 @@ var InputSourceHelper = {
   },
   
   handleEvent: function ish_handleEvent(aEvent) {
     switch (aEvent.mozInputSource) {
       case Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE:
       case Ci.nsIDOMMouseEvent.MOZ_SOURCE_PEN:
       case Ci.nsIDOMMouseEvent.MOZ_SOURCE_ERASER:
       case Ci.nsIDOMMouseEvent.MOZ_SOURCE_CURSOR:
-        if (!this._isPrecise && !this.treatMouseAsTouch) {
-          this._isPrecise = true;
+        if (!this.isPrecise && !this.treatMouseAsTouch) {
+          this.isPrecise = true;
           this._fire("MozPrecisePointer");
         }
         break;
 
       case Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH:
-        if (this._isPrecise) {
-          this._isPrecise = false;
+        if (this.isPrecise) {
+          this.isPrecise = false;
           this._fire("MozImprecisePointer");
         }
         break;
     }
   },
   
   fireUpdate: function fireUpdate() {
     if (this.treatMouseAsTouch) {
       this._fire("MozImprecisePointer");
     } else {
-      if (this._isPrecise) {
+      if (this.isPrecise) {
         this._fire("MozPrecisePointer");
       } else {
         this._fire("MozImprecisePointer");
       }
     }
   },
 
   _fire: function (name) {