Browse Source

b=487185, r=mfinkle, External links open multiple times

matthew.gertner@gmail.com 15 years ago
parent
commit
49b4c9d732

+ 1 - 9
Makefile.in

@@ -43,21 +43,13 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DIRS		= chrome components newapp client extension
+DIRS		= chrome components common newapp client extension
 
 APP_UA_NAME = $(shell echo $(MOZ_APP_DISPLAYNAME) | sed -e's/[^A-Za-z]//g')
 DEFINES += -DAPP_NAME=$(MOZ_APP_DISPLAYNAME) -DAPP_VERSION=$(MOZ_APP_VERSION) -DAPP_UA_NAME=$(APP_UA_NAME)
 
 PREF_JS_EXPORTS = $(srcdir)/defaults/preferences/preferences.js
 
-EXTRA_JS_MODULES += \
-  $(srcdir)/modules/HostUI.jsm \
-  $(NULL)
-
-EXTRA_PP_JS_MODULES += \
-  $(srcdir)/common/modules/WebAppProperties.jsm \
-  $(NULL)
-
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DAPP_VERSION=$(MOZ_APP_VERSION)

+ 3 - 1
chrome/content/about.js

@@ -44,7 +44,9 @@ function onload(aEvent)
   userAgent.value = navigator.userAgent;
 
   var credits = document.getElementById("credits");
-  credits.value = window.arguments[0].credits.replace("\\n", "\n", "g");
+  if (window.arguments && window.arguments[0]) {
+    credits.value = window.arguments[0].credits.replace("\\n", "\n", "g");
+  }
 
   if (credits.value.length == 0) {
     document.getElementById("box_credits").hidden = true;

+ 10 - 6
chrome/content/webrunner.js

@@ -562,7 +562,7 @@ var WebRunner = {
   {
     var link = aEvent.target;
 
-    if (link instanceof HTMLAnchorElement && this._isLinkExternal(link)) {
+    if (link instanceof HTMLAnchorElement && WebRunner._isLinkExternal(link)) {
       aEvent.stopPropagation();
     }
   },
@@ -571,12 +571,12 @@ var WebRunner = {
   {
     var link = aEvent.target;
 
-    if (link instanceof HTMLAnchorElement && this._isLinkExternal(link)) {
+    if (link instanceof HTMLAnchorElement && WebRunner._isLinkExternal(link)) {
       // We don't want to open external links in this process: do so in the
       // default browser.
-      var resolvedURI = this._ios.newURI(link.href, null, null);
+      var resolvedURI = WebRunner._ios.newURI(link.href, null, null);
 
-      this._loadExternalURI(resolvedURI);
+      WebRunner._loadExternalURI(resolvedURI);
 
       aEvent.preventDefault();
       aEvent.stopPropagation();
@@ -927,8 +927,12 @@ var WebRunner = {
 
   attachDocument : function(aDocument) {
     var self = this;
-    aDocument.addEventListener("click", function(aEvent) { self._domClick(aEvent); }, true);
-    aDocument.addEventListener("DOMActivate", function(aEvent) { self._domActivate(aEvent); }, true);
+    // Remove handlers in case we already added them to this document
+    aDocument.removeEventListener("click", self._domClick, true);
+    aDocument.removeEventListener("DOMActivate", self._domActivate, true);
+    
+    aDocument.addEventListener("click", self._domClick, true);
+    aDocument.addEventListener("DOMActivate", self._domActivate, true);
   },
 
   // nsIXULBrowserWindow implementation to display link destinations in the statusbar

+ 17 - 0
components/public/nsIPlatformGlue.idl

@@ -163,6 +163,23 @@ interface nsIPlatformGlue : nsISupports
    */
   boolean isRegisteredProtocolHandler(in AString uriScheme);
   
+  /**
+   * Use the appropriate platform-specific mechanism to indicate that the window requires attention.
+   */
+  void getAttention();
+  
+  /**
+   * Display the preferences dialog.
+   *
+   * @param paneToShow The name of the pane to display when the dialog is opened.
+   */
+  void showPreferences(in AString paneToShow);
+  
+  /**
+   * Display the About dialog.
+   */
+  void showAbout();
+  
   /**
    * Clear private data (cache, history, etc.).
    */

+ 16 - 0
components/src/nsPlatformGlue.js

@@ -234,6 +234,7 @@ PlatformGlue.prototype = {
 
   _prefs : Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch),
   _window : null,
+  _chromeWindow : null,
   _icon : null,
   _protocolCallbacks : {},
 
@@ -293,6 +294,7 @@ PlatformGlue.prototype = {
     
       if (aWebProgress.DOMWindow == browser.contentWindow) {
         this._window = aWebProgress.DOMWindow;
+        this._chromeWindow = win;
       }
     }
   },
@@ -461,6 +463,20 @@ PlatformGlue.prototype = {
     Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader).
       loadSubScript("chrome://webrunner/content/browser/sanitize.js", null);
     Sanitizer.sanitize();
+  },
+  
+  getAttention : function getAttention() {
+    this._chromeWindow.getAttention();
+  },
+  
+  showPreferences : function showPreferences(paneToShow)
+  {
+    this._chromeWindow.openDialog("chrome://webrunner/content/preferences/preferences.xul", "preferences", "chrome,titlebar,toolbar,centerscreen,dialog", paneToShow);
+  },
+  
+  showAbout : function showAbout()
+  {
+    this._chromeWindow.openDialog("chrome://webrunner/content/about.xul", "about", "centerscreen,modal");
   }
 }
 

+ 1 - 1
confvars.sh

@@ -38,7 +38,7 @@
 
 MOZ_APP_NAME=prism
 MOZ_APP_DISPLAYNAME=Prism
-MOZ_APP_VERSION=0.9.1
+MOZ_APP_VERSION=0.9.9
 
 MOZ_XUL_APP=1
 MOZ_UPDATER=1

+ 2 - 2
extension/install.rdf

@@ -5,7 +5,7 @@
 		<em:type>2</em:type>
 		<em:name>Prism for Firefox</em:name>
 		<em:description>Create Prism applications directly in Firefox</em:description>
-		<em:version>0.2.1</em:version>
+		<em:version>0.9.9</em:version>
 		<em:creator>Prism Project</em:creator>
 		<em:iconURL>chrome://refractor/skin/install-shortcut48.png</em:iconURL>
 		<em:homepageURL>http://wiki.mozilla.org/Prism</em:homepageURL>
@@ -14,7 +14,7 @@
 			<Description>
 				<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- Firefox -->
 				<em:minVersion>3.0</em:minVersion>
-				<em:maxVersion>3.0.*</em:maxVersion>
+				<em:maxVersion>3.5b4</em:maxVersion>
 			</Description>
 		</em:targetApplication>
 	</Description>

+ 0 - 99
modules/HostUI.jsm

@@ -1,99 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.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 WebRunner.
- *
- * The Initial Developer of the Original Code is Mozilla Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2007
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Mark Finkle, <mark.finkle@gmail.com>, <mfinkle@mozilla.com>
- *   Matthew Gertner <matthew.gertner@gmail.com>
- *
- * ***** END LICENSE BLOCK ***** */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-EXPORTED_SYMBOLS = ["HostUI"];
-
-/**
- * Simple host API exposed to the web application script files.
- */
-var HostUI = {
-  _document : null,
-  _window :   null,
-
-  log : function(aMsg) {
-    var console = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
-    console.logStringMessage(aMsg);
-  },
-
-  getBrowser : function() {
-    return this._document.getElementById("browser_content");
-  },
-  
-  showAbout : function() {
-    this._window.openDialog("chrome://webrunner/content/about.xul", "about", "centerscreen,modal");
-  },
-  
-  showPreferences : function(paneToShow) {
-    this._window.openDialog("chrome://webrunner/content/preferences/preferences.xul", "preferences", "chrome,titlebar,toolbar,centerscreen,dialog", paneToShow);
-  },
-  
-  showAlert : function(aImage, aTitle, aMsg) {
-    var alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
-    alerts.showAlertNotification(aImage, aTitle, aMsg, false, "", null);
-  },
-
-  getResource : function(aResource) {
-    var resourceSpec = "chrome://webrunner/skin/resources/" + aResource;
-    return resourceSpec;
-  },
-
-  playSound : function(aSound) {
-    var sound = Cc["@mozilla.org/sound;1"].createInstance(Ci.nsISound);
-    if (aSound == "beep") {
-      sound.beep();
-    }
-    else if (aSound.indexOf("://") == -1) {
-      sound.playSystemSound(aSound);
-    }
-    else
-    {
-      var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
-      sound.play(ioService.newURI(aSound, null, null));
-    }
-  },
-
-  getAttention : function() {
-    window.getAttention();
-  },
-
-  sidebar : {
-    get visible() {
-      return this._document.getElementById("splitter_sidebar").getAttribute("state") == "open";
-    },
-
-    set visible(show) {
-      this._document.getElementById("splitter_sidebar").setAttribute("state", show ? "open" : "collapsed");
-    },
-
-    add : function(title, uri) {
-      this._document.getElementById("box_sidebar").href = uri;
-      this._document.getElementById("label_sidebar").value = title;
-      this._document.getElementById("browser_sidebar").setAttribute("src", uri);
-    }
-  }
-};