1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 06:57:59 +01:00
This commit is contained in:
Kris Maglione
2008-12-17 23:16:20 -05:00
parent 5fffe79206
commit cdcfb68e3b
2 changed files with 25 additions and 11 deletions

View File

@@ -115,6 +115,7 @@ function Buffer() //{{{
else else
v = win.scrollMaxY / 100 * vertical; v = win.scrollMaxY / 100 * vertical;
marks.add("'", true);
win.scrollTo(h, v); win.scrollTo(h, v);
} }
@@ -1156,6 +1157,17 @@ function Buffer() //{{{
scrollToPercentiles(-1, percentage); scrollToPercentiles(-1, percentage);
}, },
scrollToRatio: function (x, y)
{
scrollToPercentiles(x * 100, y * 100);
},
scrollTo: function (x, y)
{
marks.add("'", true);
content.scrollTo(x, y);
},
scrollStart: function () scrollStart: function ()
{ {
scrollToPercentiles(0, -1); scrollToPercentiles(0, -1);
@@ -1340,12 +1352,11 @@ function Marks() //{{{
function onPageLoad(event) function onPageLoad(event)
{ {
let win = event.originalTarget.defaultView; let win = event.originalTarget.defaultView;
for (let i = 0, length = pendingJumps.length; i < length; i++) for (let [i, mark] in Iterator(pendingJumps))
{ {
let mark = pendingJumps[i];
if (win && win.location.href == mark.location) if (win && win.location.href == mark.location)
{ {
win.scrollTo(mark.position.x * win.scrollMaxX, mark.position.y * win.scrollMaxY); buffer.scrollToRatio(mark.position.x, mark.position.y);
pendingJumps.splice(i, 1); pendingJumps.splice(i, 1);
return; return;
} }
@@ -1390,7 +1401,7 @@ function Marks() //{{{
} }
} }
function isLocalMark(mark) /^[a-z]$/.test(mark); function isLocalMark(mark) /^['"a-z]$/.test(mark);
function isURLMark(mark) /^[A-Z0-9]$/.test(mark); function isURLMark(mark) /^[A-Z0-9]$/.test(mark);
function localMarkIter() function localMarkIter()
@@ -1537,12 +1548,13 @@ function Marks() //{{{
return { return {
// TODO: add support for frameset pages // TODO: add support for frameset pages
add: function (mark) add: function (mark, silent)
{ {
let win = window.content; let win = window.content;
if (win.document.body.localName.toLowerCase() == "frameset") if (win.document.body.localName.toLowerCase() == "frameset")
{ {
if (!silent)
liberator.echoerr("Marks support for frameset pages not implemented yet"); liberator.echoerr("Marks support for frameset pages not implemented yet");
return; return;
} }
@@ -1554,6 +1566,7 @@ function Marks() //{{{
if (isURLMark(mark)) if (isURLMark(mark))
{ {
urlMarks.set(mark, { location: win.location.href, position: position, tab: tabs.getTab() }); urlMarks.set(mark, { location: win.location.href, position: position, tab: tabs.getTab() });
if (!silent)
liberator.log("Adding URL mark: " + markToString(mark, urlMarks.get(mark)), 5); liberator.log("Adding URL mark: " + markToString(mark, urlMarks.get(mark)), 5);
} }
else if (isLocalMark(mark)) else if (isLocalMark(mark))
@@ -1564,6 +1577,7 @@ function Marks() //{{{
localMarks.set(mark, []); localMarks.set(mark, []);
let vals = { location: win.location.href, position: position }; let vals = { location: win.location.href, position: position };
localMarks.get(mark).push(vals); localMarks.get(mark).push(vals);
if (!silent)
liberator.log("Adding local mark: " + markToString(mark, vals), 5); liberator.log("Adding local mark: " + markToString(mark, vals), 5);
} }
}, },
@@ -1621,7 +1635,7 @@ function Marks() //{{{
return; return;
} }
liberator.log("Jumping to URL mark: " + markToString(mark, slice), 5); liberator.log("Jumping to URL mark: " + markToString(mark, slice), 5);
win.scrollTo(slice.position.x * win.scrollMaxX, slice.position.y * win.scrollMaxY); buffer.scrollToRatio(slice.position.x, slice.position.y);
ok = true; ok = true;
} }
} }
@@ -1636,7 +1650,7 @@ function Marks() //{{{
if (win.location.href == lmark.location) if (win.location.href == lmark.location)
{ {
liberator.log("Jumping to local mark: " + markToString(mark, lmark), 5); liberator.log("Jumping to local mark: " + markToString(mark, lmark), 5);
win.scrollTo(lmark.position.x * win.scrollMaxX, lmark.position.y * win.scrollMaxY); buffer.scrollToRatio(lmark.position.x, lmark.position.y);
ok = true; ok = true;
break; break;
} }

View File

@@ -952,7 +952,7 @@ const liberator = (function () //{{{
setTimeout(function () { setTimeout(function () {
let elem = buffer.evaluateXPath('//*[@class="tag" and text()="' + tag + '"]').snapshotItem(0); let elem = buffer.evaluateXPath('//*[@class="tag" and text()="' + tag + '"]').snapshotItem(0);
if (elem) if (elem)
window.content.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context buffer.scrollTo(0, elem.getBoundingClientRect().top - 10); // 10px context
else else
liberator.dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' ); liberator.dump('no element: ' + '@class="tag" and text()="' + tag + '"\n' );
}, 500); }, 500);