mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
initial canvas panning
--HG-- branch : mobile extra : convert_revision : svn%3A4eb1ac78-321c-0410-a911-ec516a8615a5/projects/fennec/mobile%4012843
This commit is contained in:
parent
47abbbdc65
commit
d9a441f1b1
@ -59,7 +59,7 @@ var Browser = {
|
|||||||
|
|
||||||
_tabOpen : function(aEvent) {
|
_tabOpen : function(aEvent) {
|
||||||
aEvent.originalTarget.zoomController = new ZoomController(aEvent.originalTarget);
|
aEvent.originalTarget.zoomController = new ZoomController(aEvent.originalTarget);
|
||||||
aEvent.originalTarget.mouseController = new MouseController(aEvent.originalTarget);
|
aEvent.originalTarget.mouseController = new MouseController(this._content);
|
||||||
aEvent.originalTarget.progressController = new ProgressController(aEvent.originalTarget);
|
aEvent.originalTarget.progressController = new ProgressController(aEvent.originalTarget);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -456,6 +456,7 @@ MouseController.prototype = {
|
|||||||
|
|
||||||
this.lastEvent = this.firstEvent = aEvent;
|
this.lastEvent = this.firstEvent = aEvent;
|
||||||
this.fingerDistance = 100;
|
this.fingerDistance = 100;
|
||||||
|
this._browser.startPan(aEvent);
|
||||||
this.mousemove = aEvent.button != 2 ? this.mousePan : this.mouseZoom;
|
this.mousemove = aEvent.button != 2 ? this.mousePan : this.mouseZoom;
|
||||||
this._browser.addEventListener("mousemove", this, true);
|
this._browser.addEventListener("mousemove", this, true);
|
||||||
|
|
||||||
@ -482,6 +483,8 @@ MouseController.prototype = {
|
|||||||
if (totalDistance > 10)
|
if (totalDistance > 10)
|
||||||
aEvent.preventDefault();
|
aEvent.preventDefault();
|
||||||
|
|
||||||
|
this._browser.endPan(aEvent);
|
||||||
|
|
||||||
// Keep scrolling if there is enough momentum
|
// Keep scrolling if there is enough momentum
|
||||||
/*
|
/*
|
||||||
if (this.lastEvent && "momentum" in this.lastEvent && this.mousemove == this.mousePan)
|
if (this.lastEvent && "momentum" in this.lastEvent && this.mousemove == this.mousePan)
|
||||||
@ -551,7 +554,8 @@ MouseController.prototype = {
|
|||||||
y: y
|
y: y
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this._browser.contentWindow.scrollBy(-x, -y);
|
//this._browser.contentWindow.scrollBy(-x, -y);
|
||||||
|
this._browser.doPan(aEvent, -x, -y);
|
||||||
this.lastEvent = aEvent;
|
this.lastEvent = aEvent;
|
||||||
|
|
||||||
//FIX Adjust scrollbars now
|
//FIX Adjust scrollbars now
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
<content>
|
<content>
|
||||||
<xul:deck anonid="container" class="deckbrowser-container" flex="1">
|
<xul:deck anonid="container" class="deckbrowser-container" flex="1">
|
||||||
</xul:deck>
|
</xul:deck>
|
||||||
<xul:vbox anonid="renderspace" class="deckbrowser-renderspace" collapsed="true" flex="1">
|
<xul:scrollbox anonid="renderspace" class="deckbrowser-renderspace" collapsed="true" flex="1">
|
||||||
<html:canvas id="render"/>
|
<html:canvas anonid="canvas"/>
|
||||||
</xul:vbox>
|
</xul:scrollbox>
|
||||||
<xul:vbox anonid="tabspace" class="deckbrowser-tabspace" collapsed="true" align="center" flex="1">
|
<xul:vbox anonid="tabspace" class="deckbrowser-tabspace" collapsed="true" align="center" flex="1">
|
||||||
<xul:description anonid="title" class="deckbrowser-title" crop="end"/>
|
<xul:description anonid="title" class="deckbrowser-title" crop="end"/>
|
||||||
<xul:description anonid="uri" class="deckbrowser-uri" crop="center"/>
|
<xul:description anonid="uri" class="deckbrowser-uri" crop="center"/>
|
||||||
@ -186,9 +186,9 @@
|
|||||||
|
|
||||||
var browsers = this.browsers;
|
var browsers = this.browsers;
|
||||||
for (var i=0; i<browsers.length; i++) {
|
for (var i=0; i<browsers.length; i++) {
|
||||||
var webContent = browsers[i].contentWindow;
|
var domWin = browsers[i].contentWindow;
|
||||||
var viewW = webContent.innerWidth;
|
var viewW = domWin.innerWidth;
|
||||||
var viewH = webContent.innerHeight;
|
var viewH = domWin.innerHeight;
|
||||||
var canvasW = this.boxObject.width / 1.5;
|
var canvasW = this.boxObject.width / 1.5;
|
||||||
var canvasH = (viewH / viewW) * canvasW;
|
var canvasH = (viewH / viewW) * canvasW;
|
||||||
|
|
||||||
@ -232,7 +232,7 @@
|
|||||||
ctx.clearRect(0, 0, canvasW, canvasH);
|
ctx.clearRect(0, 0, canvasW, canvasH);
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.scale(canvasW/viewW, canvasH/viewH);
|
ctx.scale(canvasW/viewW, canvasH/viewH);
|
||||||
ctx.drawWindow(webContent, 0, 0, viewW, viewH, "rgba(0,0,0,0)");
|
ctx.drawWindow(domWin, 0, 0, viewW, viewH, "rgba(0,0,0,0)");
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,6 +242,87 @@
|
|||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<field name="_panX">
|
||||||
|
0
|
||||||
|
</field>
|
||||||
|
|
||||||
|
<field name="_panY">
|
||||||
|
0
|
||||||
|
</field>
|
||||||
|
|
||||||
|
<method name="_updateCanvas">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var renderspace = document.getAnonymousElementByAttribute(this, "anonid", "renderspace");
|
||||||
|
var canvas = document.getAnonymousElementByAttribute(this, "anonid", "canvas");
|
||||||
|
var domWin = this.browser.contentWindow;
|
||||||
|
var canvasW = domWin.innerWidth + domWin.scrollMaxX;
|
||||||
|
var canvasH = domWin.innerHeight + domWin.scrollMaxY;
|
||||||
|
if (canvasW > domWin.innerWidth * 2)
|
||||||
|
canvasW = domWin.innerWidth * 2;
|
||||||
|
if (canvasH > domWin.innerHeight * 2)
|
||||||
|
canvasH = domWin.innerHeight * 2;
|
||||||
|
canvas.width = canvasW;
|
||||||
|
canvas.height = canvasH;
|
||||||
|
|
||||||
|
var ctx = canvas.getContext("2d");
|
||||||
|
ctx.clearRect(0, 0, canvasW, canvasH);
|
||||||
|
var stime = Date.now();
|
||||||
|
ctx.drawWindow(domWin, domWin.scrollX, domWin.scrollY, canvasW, canvasH, "rgba(0,0,0,0)");
|
||||||
|
var etime = Date.now();
|
||||||
|
dump("drawWindow: " + (etime - stime) + " ms\n");
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="startPan">
|
||||||
|
<parameter name="aEvent"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
this._panX = aEvent.screenX;
|
||||||
|
this._panY = aEvent.screenY;
|
||||||
|
|
||||||
|
this._container.collapsed = true;
|
||||||
|
renderspace.collapsed = false;
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="doPan">
|
||||||
|
<parameter name="aEvent"/>
|
||||||
|
<parameter name="aDeltaX"/>
|
||||||
|
<parameter name="aDeltaY"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var renderspace = document.getAnonymousElementByAttribute(this, "anonid", "renderspace");
|
||||||
|
var scroller = renderspace.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
|
||||||
|
scroller.scrollBy(aDeltaX, aDeltaY);
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="endPan">
|
||||||
|
<parameter name="aEvent"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var renderspace = document.getAnonymousElementByAttribute(this, "anonid", "renderspace");
|
||||||
|
var scroller = renderspace.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
|
||||||
|
var sx = {}; var sy = {};
|
||||||
|
scroller.getPosition(sx, sy);
|
||||||
|
var domWin = this.browser.contentWindow;
|
||||||
|
dump("scrollpos: " + sx.value + ", " + sy.value + "\n");
|
||||||
|
dump("domoffset: " + domWin.scrollX + ", " + domWin.scrollY + "\n");
|
||||||
|
domWin.scrollTo(sx.value, sy.value);
|
||||||
|
|
||||||
|
renderspace.collapsed = true;
|
||||||
|
this._container.collapsed = false;
|
||||||
|
|
||||||
|
scroller.scrollTo(0, 0);
|
||||||
|
this._updateCanvas();
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
</implementation>
|
</implementation>
|
||||||
|
|
||||||
<handlers>
|
<handlers>
|
||||||
|
@ -210,7 +210,13 @@ var HUDBar = {
|
|||||||
goToURI : function(aURI) {
|
goToURI : function(aURI) {
|
||||||
if (!aURI)
|
if (!aURI)
|
||||||
aURI = this._edit.value;
|
aURI = this._edit.value;
|
||||||
|
|
||||||
|
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||||
|
if (ios.newURI(aURI, null, null) == null)
|
||||||
|
this.search();
|
||||||
|
else
|
||||||
getBrowser().loadURI(aURI, null, null, false);
|
getBrowser().loadURI(aURI, null, null, false);
|
||||||
|
|
||||||
if (this._panel.state == "open")
|
if (this._panel.state == "open")
|
||||||
this._showMode(PANELMODE_VIEW);
|
this._showMode(PANELMODE_VIEW);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user