From 252da28272a7cf8b1436f8c03f40b8624189672b Mon Sep 17 00:00:00 2001
From: "akkana%netscape.com" <akkana%netscape.com>
Date: Thu, 14 Sep 2006 05:44:05 +0000
Subject: [PATCH] temp workaround for 23669: don't go to url on middle mouse
 clicks if we're over a text field or area, because the event was probably
 already handled by the editor and we shouldn't have gotten it at all. Code
 from joki, r=me.

---
 suite/browser/navigator.js  | 19 ++++++++++++-------
 suite/browser/navigator.xul |  2 +-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/suite/browser/navigator.js b/suite/browser/navigator.js
index 49f3dc0e824..e26e2cf7e87 100644
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -1263,15 +1263,20 @@ function BrowserEditBookmarks()
 	return url;
   }
 
-  function browserLoadClipboardURL()
+  function browserLoadClipboardURL(target)
   {
-    var url = readFromClipboard();
-    dump ("URL on clipboard: '" + url + "'; length = " + url.length + "\n");
-    if (url.length > 0)
+    if (!((target.tagName.toUpperCase() == "INPUT"
+           && (target.type == "" || target.type.toUpperCase() == "TEXT"))
+          || target.tagName.toUpperCase() == "TEXTAREA"))
     {
-      var urlBar = document.getElementById("urlbar");
-      urlBar.value = url;
-      BrowserLoadURL();
+      var url = readFromClipboard();
+      dump ("URL on clipboard: '" + url + "'; length = " + url.length + "\n");
+      if (url.length > 0)
+      {
+        var urlBar = document.getElementById("urlbar");
+        urlBar.value = url;
+        BrowserLoadURL();
+      }
     }
   }
 
diff --git a/suite/browser/navigator.xul b/suite/browser/navigator.xul
index 6f2656c8855..46c5a662b97 100644
--- a/suite/browser/navigator.xul
+++ b/suite/browser/navigator.xul
@@ -412,7 +412,7 @@ Contributor(s): ______________________________________. -->
   <splitter id="sidebar-splitter" chromeclass="extrachrome" />
   
   <box id="appcontent" align="vertical" flex="100%"
-    onclick="if (event.button==2) browserLoadClipboardURL();"
+    onclick="if (event.button==2) browserLoadClipboardURL(event.target);"
     ondragover="return DragOverContentArea(event);"
     ondragdrop="return DropOnContentArea(event);">