Bug 304563 Add autoscroll support to SeaMonkey (browser only, for now)

r=db48x sr=neil
This commit is contained in:
cst%andrew.cmu.edu 2005-09-04 15:44:59 +00:00
Родитель 7047a74f0d
Коммит 57b0482067
8 изменённых файлов: 98 добавлений и 0 удалений

Просмотреть файл

@ -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");
}

Просмотреть файл

Просмотреть файл

@ -55,6 +55,7 @@ classic.jar:
skin/classic/communicator/brand/throbber-anim.gif (communicator/brand/throbber-anim.gif)
skin/classic/communicator/brand/throbber16-single.gif (communicator/brand/throbber16-single.gif)
skin/classic/communicator/brand/throbber16-anim.gif (communicator/brand/throbber16-anim.gif)
skin/classic/communicator/icons/autoscroll.gif (communicator/icons/autoscroll.gif)
skin/classic/communicator/icons/offline.gif (communicator/icons/offline.gif)
skin/classic/communicator/icons/online.gif (communicator/icons/online.gif)
skin/classic/communicator/icons/search-act.gif (communicator/icons/search-act.gif)

Просмотреть файл

@ -89,3 +89,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");
}

Просмотреть файл

Просмотреть файл

@ -28,6 +28,7 @@ modern.jar:
skin/modern/communicator/directory/file-folder-open.gif (communicator/directory/file-folder-open.gif)
skin/modern/communicator/directory/file-icon.gif (communicator/directory/file-icon.gif)
skin/modern/communicator/directory/directory.css (communicator/directory/directory.css)
skin/modern/communicator/icons/autoscroll.gif (communicator/icons/autoscroll.gif)
skin/modern/communicator/icons/loading.gif (communicator/icons/loading.gif)
skin/modern/communicator/icons/lock-broken.gif (communicator/icons/lock-broken.gif)
skin/modern/communicator/icons/lock-insecure.gif (communicator/icons/lock-insecure.gif)

Просмотреть файл

@ -139,6 +139,8 @@
<!-- context menu -->
<popupset id="contentAreaContextSet"/>
<popup id="autoscroller" onpopuphidden="stopScrolling()"/>
<toolbox id="navigator-toolbox" class="toolbox-top" deferattached="true">
<!-- Menu -->
<menubar id="main-menubar" persist="collapsed" grippytooltiptext="&menuBar.tooltip;"/>
@ -346,6 +348,7 @@
contentcontextmenu="contentAreaContextMenu"
onnewtab="BrowserOpenTab();"
onbookmarkgroup="addGroupmarkAs();"
onmousedown="return contentAreaMouseDown(event);"
onclick="return contentAreaClick(event);"/>
</hbox>
</vbox>

Просмотреть файл

@ -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?