From b6d22cbb3174acdd7d0d44c1773cc98e65486f01 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Thu, 22 Dec 2011 19:21:06 +0100 Subject: [PATCH] declare compat with Gecko 12 versions --- Makefile.in | 2 +- content/mandelbrot.js | 42 ++++++++++++++++++++++++++++++------------ install.rdf | 8 ++++---- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index a44d02e..2e0331e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,7 +49,7 @@ endif MODULE = mandelbrot -EXTENSION_VERSION = 4.0 +EXTENSION_VERSION = 4.0.1 XPI_NAME = mandelbrot USE_EXTENSION_MANIFEST = 1 diff --git a/content/mandelbrot.js b/content/mandelbrot.js index 7d77b12..279d3ae 100644 --- a/content/mandelbrot.js +++ b/content/mandelbrot.js @@ -467,27 +467,45 @@ function drawPoint(context, img_x, img_y, C, iterMax, algorithm) { var zoomstart; var imgBackup; +var zoomTouchID; let imgEvHandler = { handleEvent: function(aEvent) { let canvas = document.getElementById("mbrotImage"); let context = canvas.getContext("2d"); + let touchEvent = aEvent.type.indexOf('touch') != -1; + + // Bail out if this is neither a touch nor left-click. + if (!touchEvent && aEvent.button != 0) + return; + + // Bail out if the started touch can't be found. + if (touchEvent && zoomstart && + !aEvent.changedTouches.identifiedTouch(zoomTouchID)) + return; + + let coordObj = touchEvent ? + aEvent.changedTouches.identifiedTouch(zoomTouchID) : + aEvent; + switch (aEvent.type) { case 'mousedown': case 'touchstart': - if (aEvent.button == 0) { - // left button - start dragzoom - zoomstart = {x: aEvent.clientX - canvas.offsetLeft, - y: aEvent.clientY - canvas.offsetTop}; - imgBackup = context.getImageData(0, 0, canvas.width, canvas.height); + if (touchEvent) { + zoomTouchID = aEvent.changedTouches.item(0).identifier; + coordObj = aEvent.changedTouches.identifiedTouch(zoomTouchID); } + // left button - start dragzoom + zoomstart = {x: coordObj.clientX - canvas.offsetLeft, + y: coordObj.clientY - canvas.offsetTop}; + imgBackup = context.getImageData(0, 0, canvas.width, canvas.height); break; case 'mouseup': case 'touchend': - if (aEvent.button == 0 && zoomstart) { + if (zoomstart) { context.putImageData(imgBackup, 0, 0); - let zoomend = {x: aEvent.clientX - canvas.offsetLeft, - y: aEvent.clientY - canvas.offsetTop}; + let zoomend = {x: coordObj.clientX - canvas.offsetLeft, + y: coordObj.clientY - canvas.offsetTop}; // make sure zoomend is bigger than zoomstart if ((zoomend.x == zoomstart.x) || (zoomend.y == zoomstart.y)) { @@ -516,12 +534,12 @@ let imgEvHandler = { break; case 'mousemove': case 'touchmove': - if (aEvent.button == 0 && zoomstart) { + if (zoomstart) { context.putImageData(imgBackup, 0, 0); context.strokeStyle = "rgb(255,255,31)"; context.strokeRect(zoomstart.x, zoomstart.y, - aEvent.clientX - canvas.offsetLeft - zoomstart.x, - aEvent.clientY - canvas.offsetTop - zoomstart.y); + coordObj.clientX - canvas.offsetLeft - zoomstart.x, + coordObj.clientY - canvas.offsetTop - zoomstart.y); } break; } @@ -588,7 +606,7 @@ function updateBookmarkMenu(aParent) { na.setAttribute("disabled", "true"); } -function goBack () { +function goBack() { if (gLastImageData) { Services.prefs.setIntPref("mandelbrot.iteration_max", gLastImageData.iterMax); diff --git a/install.rdf b/install.rdf index fe5345c..5928584 100644 --- a/install.rdf +++ b/install.rdf @@ -14,7 +14,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 4.0 - 11.0a1 + 12.0a1 @@ -22,7 +22,7 @@ {92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a} 2.1 - 2.8a1 + 2.9a1 @@ -30,7 +30,7 @@ {a23983c0-fd0e-11dc-95ff-0800200c9a66} 4.0 - 11.0a1 + 12.0a1 @@ -38,7 +38,7 @@ toolkit@mozilla.org 2.0 - 11.0 + 12.0 -- 2.43.0