From 9f5fba5e1e7fc0ef29b78ea0c08ee22bd02e68cd Mon Sep 17 00:00:00 2001 From: "cst%andrew.cmu.edu" Date: Sun, 4 Sep 2005 15:44:59 +0000 Subject: [PATCH] Bug 304563 Add autoscroll support to SeaMonkey (browser only, for now) r=db48x sr=neil git-svn-id: svn://10.0.0.236/trunk@179623 18797224-902f-48f8-a5cc-f745e15eee43 --- .../classic/communicator/communicator.css | 10 +++ .../classic/communicator/icons/autoscroll.gif | Bin 0 -> 162 bytes mozilla/themes/classic/jar.mn | 1 + .../modern/communicator/communicator.css | 10 +++ .../modern/communicator/icons/autoscroll.gif | Bin 0 -> 162 bytes mozilla/themes/modern/jar.mn | 1 + .../browser/resources/content/navigator.xul | 3 + .../resources/content/contentAreaClick.js | 73 ++++++++++++++++++ 8 files changed, 98 insertions(+) create mode 100644 mozilla/themes/classic/communicator/icons/autoscroll.gif create mode 100644 mozilla/themes/modern/communicator/icons/autoscroll.gif diff --git a/mozilla/themes/classic/communicator/communicator.css b/mozilla/themes/classic/communicator/communicator.css index a32ef2efa74..faa74235b87 100644 --- a/mozilla/themes/classic/communicator/communicator.css +++ b/mozilla/themes/classic/communicator/communicator.css @@ -92,3 +92,13 @@ margin-right: 2px; } +/* :::::: autoscroll popup ::::: */ + +#autoscroller { + height: 28px; + width: 28px; + border: 0px; + margin: -14px; + padding: 0px; + background-image: url("chrome://communicator/skin/icons/autoscroll.gif"); +} diff --git a/mozilla/themes/classic/communicator/icons/autoscroll.gif b/mozilla/themes/classic/communicator/icons/autoscroll.gif new file mode 100644 index 0000000000000000000000000000000000000000..7108e6cd2d6730d3a42a18f334374307567bf2d8 GIT binary patch literal 162 zcmZ?wbhEHblwpuzn8*ME4Gj(d|NjRv6o0a?axpM7=zv5)@(fJHJ^d@CAMr2lNxPI5 ze^!a1A$9iCS_N~jrInKuk8aYRQdDMs|IwVu;=C6)qxu3l-AZblW{Y0<(j+Fm`hjv< zsF!vq$F + + @@ -346,6 +348,7 @@ contentcontextmenu="contentAreaContextMenu" onnewtab="BrowserOpenTab();" onbookmarkgroup="addGroupmarkAs();" + onmousedown="return contentAreaMouseDown(event);" onclick="return contentAreaClick(event);"/> diff --git a/mozilla/xpfe/communicator/resources/content/contentAreaClick.js b/mozilla/xpfe/communicator/resources/content/contentAreaClick.js index 8eb0453d6ba..5063a09b6b9 100644 --- a/mozilla/xpfe/communicator/resources/content/contentAreaClick.js +++ b/mozilla/xpfe/communicator/resources/content/contentAreaClick.js @@ -49,6 +49,14 @@ pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); + var startX; + var startY; + var currX; + var currY; + var scrollingView; + var autoScrollTimer; + var ignoreMouseEvents; + // Prefill a single text field function prefillTextBox(target) { // obtain values to be used for prefilling @@ -201,6 +209,71 @@ return true; } + function contentAreaMouseDown(event) + { + if (event.button == 1 && (event.target != event.currentTarget) + && !hrefAndLinkNodeForClickEvent(event) + && (!pref || !pref.getBoolPref("middlemouse.contentLoadURL"))) { + startScrolling(event); + ignoreMouseEvents = true; + return false; + } + return true; + } + + function startScrolling(event) + { + var scroller = document.getElementById("autoscroller"); + if (scrollingView || !scroller) + return; + document.popupNode = null; + scroller.showPopup(scroller.parentNode, event.screenX, event.screenY, + "popup", null, null); + startX = event.screenX; + startY = event.screenY; + currX = event.screenX; + currY = event.screenY; + addEventListener('mousemove', handleMouseMove, true); + addEventListener('mouseup', handleMouseUpDown, true); + addEventListener('mousedown', handleMouseUpDown, true); + autoScrollTimer = setInterval(autoScrollLoop, 10); + scrollingView = event.originalTarget.ownerDocument.defaultView; + } + + function handleMouseMove(event) + { + currX = event.screenX; + currY = event.screenY; + } + + function autoScrollLoop() + { + var x = currX - startX; + var y = currY - startY; + const speed = 4; + if (Math.abs(x) >= speed || Math.abs(y) >= speed) + ignoreMouseEvents = false; + scrollingView.scrollBy(x / speed, y / speed); + } + + function handleMouseUpDown(event) + { + if (!ignoreMouseEvents) + document.getElementById("autoscroller").hidePopup(); + ignoreMouseEvents = false; + } + + function stopScrolling() + { + if (scrollingView) { + scrollingView = null; + removeEventListener('mousemove', handleMouseMove, true); + removeEventListener('mousedown', handleMouseUpDown, true); + removeEventListener('mouseup', handleMouseUpDown, true); + clearInterval(autoScrollTimer); + } + } + function openNewTabOrWindow(event, href, sendReferrer) { // should we open it in a new tab?