Bug 533367 - don't translate phone numbers [r=stuart]
authorBrad Lassey <blassey@mozilla.com>
Mon, 07 Dec 2009 22:19:54 -0500
changeset 65892 cac0a1837012714dcc1f444f571d0a5efb1307e3
parent 65891 5955045bf224b8709665bc9875ab2d9c4df6713c
child 65893 a16cb0d98835d40b799c66001ace44bc2c31b653
push idunknown
push userunknown
push dateunknown
reviewersstuart
bugs533367
Bug 533367 - don't translate phone numbers [r=stuart]
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -814,43 +814,16 @@ var Browser = {
 
       if (notification.persistence)
         notification.persistence--;
       else if (Date.now() > notification.timeout)
         notificationBox.removeNotification(notification);
     }
   },
 
-  translatePhoneNumbers: function translatePhoneNumbers() {
-    let doc = getBrowser().contentDocument;
-    // jonas black magic (only match text nodes that contain a sequence of 4 numbers)
-    let textnodes = doc.evaluate('//text()[contains(translate(., "0123456789", "^^^^^^^^^^"), "^^^^")]',
-                                 doc,
-                                 null,
-                                 XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
-                                 null);
-    let s, node, lastLastIndex;
-    let re = /(\+?1? ?-?\(?\d{3}\)?[ +-\.]\d{3}[ +-\.]\d{4})/;
-    for (var i = 0; i < textnodes.snapshotLength; i++) {
-      node = textnodes.snapshotItem(i);
-      s = node.data;
-      if (s.match(re)) {
-        s = s.replace(re, "<a href='tel:$1'> $1 </a>");
-        try {
-          let replacement = doc.createElement("span");
-          replacement.innerHTML = s;
-          node.parentNode.insertBefore(replacement, node);
-          node.parentNode.removeChild(node);
-        } catch(e) {
-          //do nothing, but continue
-        }
-      }
-    }
-  },
-
   /** Returns true iff a tab's browser has been destroyed to free up memory. */
   sacrificeTab: function sacrificeTab() {
     let tabToClear = this._tabs.reduce(function(prevTab, currentTab) {
       if (currentTab == Browser.selectedTab || !currentTab.browser) {
         return prevTab;
       } else {
         return (prevTab && prevTab.lastSelected <= currentTab.lastSelected) ? prevTab : currentTab;
       }
@@ -2514,18 +2487,16 @@ ProgressController.prototype = {
     if (Browser._browserView._idleServiceObserver.isIdle())
       Browser._browserView._tileManager.restartPrefetchCrawl();
     
     if (this.browser.currentURI.spec != "about:blank")
       this._tab.updateThumbnail();
   },
 
   _documentStop: function() {
-    // translate any phone numbers
-    Browser.translatePhoneNumbers();
   }
 };
 
 var OfflineApps = {
   get _pm() {
     delete this._pm;
     return this._pm = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
   },