Bug 563962 - NS_ERROR_MALFORMED_URI nsIFilePicker.file in contentAreaUtils.js::getTargetFile in this case [r=mbrubeck]
authorMark Finkle <mfinkle@mozilla.com>
Wed, 05 May 2010 16:54:47 -0400
changeset 66208 15de80205affc22547d7a6590e46ab58b6ed8007
parent 66207 0535069b4e5286d9b579f7c1945f7b1b21d31883
child 66209 6768d5faaebc77470e2d699434a351cb867ce5f4
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs563962
Bug 563962 - NS_ERROR_MALFORMED_URI nsIFilePicker.file in contentAreaUtils.js::getTargetFile in this case [r=mbrubeck]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.xul
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -2153,26 +2153,30 @@ var SelectHelper = {
 };
 
 const kXLinkNamespace = "http://www.w3.org/1999/xlink";
 
 var ContextHelper = {
   popupNode: null,
   onLink: false,
   onSaveableLink: false,
+  onVoiceLink: false,
   onImage: false,
+  onLoadedImage: false,
   linkURL: "",
   linkProtocol: null,
   mediaURL: "",
 
   _clearState: function ch_clearState() {
     this.popupNode = null;
     this.onLink = false;
     this.onSaveableLink = false;
+    this.onVoiceLink = false;
     this.onImage = false;
+    this.onLoadedImage = false;
     this.linkURL = "";
     this.linkProtocol = null;
     this.mediaURL = "";
   },
 
   _getLinkURL: function ch_getLinkURL(aLink) {
     let href = aLink.href;  
     if (href)
@@ -2202,28 +2206,37 @@ var ContextHelper = {
     return null;
   },
   
   _isSaveable: function ch_isSaveable(aProtocol) {
     // We don't do the Right Thing for news/snews yet, so turn them off until we do
     return aProtocol && !(aProtocol == "mailto" || aProtocol == "javascript" || aProtocol == "news" || aProtocol == "snews");
   },
 
+  _isVoice: function ch_isVoice(aProtocol) {
+    // Collection of protocols related to voice or data links
+    return aProtocol && (aProtocol == "tel" || aProtocol == "callto" || aProtocol == "sip" || aProtocol == "voipto");
+  },
+
   handleEvent: function ch_handleEvent(aEvent) {
     this._clearState();
 
     let [elementX, elementY] = Browser.transformClientToBrowser(aEvent.clientX, aEvent.clientY);
     this.popupNode = Browser.elementFromPoint(elementX, elementY);
 
     // Do checks for nodes that never have children.
     if (this.popupNode.nodeType == Node.ELEMENT_NODE) {
       // See if the user clicked on an image.
       if (this.popupNode instanceof Ci.nsIImageLoadingContent && this.popupNode.currentURI) {
         this.onImage = true;
         this.mediaURL = this.popupNode.currentURI.spec;
+
+        let request = this.popupNode.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
+        if (request && (request.imageStatus & request.STATUS_SIZE_AVAILABLE))
+          this.onLoadedImage = true;
       }
     }
 
     let elem = this.popupNode;
     while (elem) {
       if (elem.nodeType == Node.ELEMENT_NODE) {
         // Link?
         if (!this.onLink &&
@@ -2232,39 +2245,50 @@ var ContextHelper = {
               elem instanceof HTMLLinkElement ||
               elem.getAttributeNS(kXLinkNamespace, "type") == "simple")) {
 
           // Target is a link or a descendant of a link.
           this.linkURL = this._getLinkURL(elem);
           this.linkProtocol = this._getProtocol(this._getURI(this.linkURL));
           this.onLink = true;
           this.onSaveableLink = this._isSaveable(this.linkProtocol);
+          this.onVoiceLink = this._isVoice(this.linkProtocol);
         }
       }
 
       elem = elem.parentNode;
     }
 
     let first = last = null;
     let commands = document.getElementById("context-commands");
     for (let i=0; i<commands.childElementCount; i++) {
       let command = commands.children[i];
-      let type = command.getAttribute("type");
+      let types = command.getAttribute("type").split(/\s+/);
       command.removeAttribute("selector");
-      if (type.indexOf("image") != -1 && this.onImage) {
+      if (types.indexOf("image") != -1 && this.onImage) {
+        first = (first ? first : command);
+        last = command;
+        command.hidden = false;
+        continue;
+      } else if (types.indexOf("image-loaded") != -1 && this.onLoadedImage) {
         first = (first ? first : command);
         last = command;
         command.hidden = false;
         continue;
-      } else if (type.indexOf("link") != -1 && this.onLink  && this.onSaveableLink) {
+      } else if (types.indexOf("link") != -1 && this.onSaveableLink) {
         first = (first ? first : command);
         last = command;
         command.hidden = false;
         continue;
-      } else if (type.indexOf("mailto") != -1 && this.onLink  && this.linkProtocol == "mailto") {
+      } else if (types.indexOf("callto") != -1 && this.onVoiceLink) {
+        first = (first ? first : command);
+        last = command;
+        command.hidden = false;
+        continue;
+      } else if (types.indexOf("mailto") != -1 && this.onLink && this.linkProtocol == "mailto") {
         first = (first ? first : command);
         last = command;
         command.hidden = false;
         continue;
       }
       command.hidden = true;
     }
 
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -511,17 +511,17 @@
     <vbox id="context-popup" hidden="true" class="dialog-dark" top="0" left="0">
       <hbox id="context-header">
         <label id="context-hint" crop="center" flex="1"/>
       </hbox>
       <richlistbox id="context-commands" onclick="ContextHelper.hide();">
         <richlistitem id="context-openinnewtab" type="link" onclick="ContextCommands.openInNewTab(event);">
           <label value="&contextOpenInNewTab.label;"/>
         </richlistitem>
-        <richlistitem id="context-saveimage" type="image" onclick="ContextCommands.saveImage(event);">
+        <richlistitem id="context-saveimage" type="image-loaded" onclick="ContextCommands.saveImage(event);">
           <label value="&contextSaveImage.label;"/>
         </richlistitem>
       </richlistbox>
     </vbox>
 
     <!-- alerts for content -->
     <hbox id="alerts-container" hidden="true" align="start" class="dialog-dark" top="0" left="0"
           onclick="AlertsHelper.click(event);">