This commit is contained in:
Ryan VanderMeulen 2013-10-18 15:08:39 -04:00
Родитель 81d7d7f5b1 8674df19f6
Коммит 956845a7af
166 изменённых файлов: 2991 добавлений и 2419 удалений

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

@ -24,7 +24,7 @@ LIBS += \
$(DEPTH)/widget/gonk/libdisplay/$(LIB_PREFIX)display.$(LIB_SUFFIX) \
$(MOZ_ZLIB_LIBS) \
$(NULL)
ifeq (18,$(ANDROID_VERSION))
ifeq ($(ANDROID_VERSION),$(findstring $(ANDROID_VERSION),17 18))
LIBS += \
-lgui \
-lsuspend \

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

@ -711,6 +711,15 @@ var gPluginHandler = {
centerActions.push(pluginInfo);
}
if (centerActions.length == 0) {
// TODO: this is a temporary band-aid to avoid broken doorhangers
// until bug 926605 is landed.
notification.options.centerActions = [];
setTimeout(() => PopupNotifications.remove(notification), 0);
return;
}
centerActions.sort(function(a, b) {
return a.pluginName.localeCompare(b.pluginName);
});

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

@ -59,6 +59,7 @@ support-files =
plugin_clickToPlayDeny.html
plugin_data_url.html
plugin_hidden_to_visible.html
plugin_iframe.html
plugin_small.html
plugin_test.html
plugin_test2.html
@ -79,6 +80,7 @@ support-files =
[browser_CTP_data_urls.js]
[browser_CTP_drag_drop.js]
[browser_CTP_iframe.js]
[browser_CTP_nonplugins.js]
[browser_CTP_resize.js]
[browser_URLBarSetURI.js]

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

@ -0,0 +1,135 @@
var rootDir = getRootDirectory(gTestPath);
const gTestRoot = rootDir;
const gHttpTestRoot = rootDir.replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gTestBrowser = null;
var gNextTest = null;
var gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
var gPageLoads = 0;
Components.utils.import("resource://gre/modules/Services.jsm");
// This listens for the next opened tab and checks it is of the right url.
// opencallback is called when the new tab is fully loaded
// closecallback is called when the tab is closed
function TabOpenListener(url, opencallback, closecallback) {
this.url = url;
this.opencallback = opencallback;
this.closecallback = closecallback;
gBrowser.tabContainer.addEventListener("TabOpen", this, false);
}
TabOpenListener.prototype = {
url: null,
opencallback: null,
closecallback: null,
tab: null,
browser: null,
handleEvent: function(event) {
if (event.type == "TabOpen") {
gBrowser.tabContainer.removeEventListener("TabOpen", this, false);
this.tab = event.originalTarget;
this.browser = this.tab.linkedBrowser;
gBrowser.addEventListener("pageshow", this, false);
} else if (event.type == "pageshow") {
if (event.target.location.href != this.url)
return;
gBrowser.removeEventListener("pageshow", this, false);
this.tab.addEventListener("TabClose", this, false);
var url = this.browser.contentDocument.location.href;
is(url, this.url, "Should have opened the correct tab");
this.opencallback(this.tab, this.browser.contentWindow);
} else if (event.type == "TabClose") {
if (event.originalTarget != this.tab)
return;
this.tab.removeEventListener("TabClose", this, false);
this.opencallback = null;
this.tab = null;
this.browser = null;
// Let the window close complete
executeSoon(this.closecallback);
this.closecallback = null;
}
}
};
function test() {
waitForExplicitFinish();
registerCleanupFunction(function() {
clearAllPluginPermissions();
Services.prefs.clearUserPref("extensions.blocklist.suppressUI");
});
Services.prefs.setBoolPref("extensions.blocklist.suppressUI", true);
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
Services.prefs.setBoolPref("plugins.click_to_play", true);
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
prepareTest(runAfterPluginBindingAttached(test1), gHttpTestRoot + "plugin_iframe.html");
}
function finishTest() {
clearAllPluginPermissions();
gTestBrowser.removeEventListener("load", pageLoad, true);
gBrowser.removeCurrentTab();
window.focus();
finish();
}
function pageLoad() {
// Wait for the iframe to be loaded as well.
if (gPageLoads++ < 1)
return;
// The plugin events are async dispatched and can come after the load event
// This just allows the events to fire before we then go on to test the states.
executeSoon(gNextTest);
}
function prepareTest(nextTest, url) {
gNextTest = nextTest;
gTestBrowser.contentWindow.location = url;
}
// Due to layout being async, "PluginBindAttached" may trigger later.
// This wraps a function to force a layout flush, thus triggering it,
// and schedules the function execution so they're definitely executed
// afterwards.
function runAfterPluginBindingAttached(func) {
return function() {
let doc = gTestBrowser.contentDocument.getElementById('frame').contentDocument;
let elems = doc.getElementsByTagName('embed');
if (elems.length < 1) {
elems = doc.getElementsByTagName('object');
}
elems[0].clientTop;
executeSoon(func);
};
}
// Test that we don't show a doorhanger after removing the last plugin
// when the plugin was in an iframe.
function test1() {
let popupNotification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
ok(popupNotification, "Test 1, Should have a click-to-play notification");
let frame = gTestBrowser.contentDocument.getElementById("frame");
frame.parentElement.removeChild(frame);
let condition = () => {
let notification = PopupNotifications.getNotification("click-to-play-plugins", gTestBrowser);
if (notification) {
notification.reshow();
}
return !notification;
}
waitForCondition(condition, finishTest, "Test1, Waited too long for notification too be removed");
}

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

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<iframe src="plugin_test.html" id="frame" width="300" height="300">
This should load plugin_test.html
</iframe>
</body>
</html>

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

@ -1,4 +1,4 @@
This is the pdf.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 0.8.558
Current extension version is: 0.8.629

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

@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '0.8.558';
PDFJS.build = 'ea50c07';
PDFJS.version = '0.8.629';
PDFJS.build = 'b16b3be';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -1231,6 +1231,11 @@ var ColorSpace = (function ColorSpaceClosure() {
return this.singletons.rgb;
case 'DeviceCmykCS':
return this.singletons.cmyk;
case 'CalGrayCS':
var whitePoint = IR[1].WhitePoint;
var blackPoint = IR[1].BlackPoint;
var gamma = IR[1].Gamma;
return new CalGrayCS(whitePoint, blackPoint, gamma);
case 'PatternCS':
var basePatternCS = IR[1];
if (basePatternCS)
@ -1306,7 +1311,8 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'CMYK':
return 'DeviceCmykCS';
case 'CalGray':
return 'DeviceGrayCS';
var params = cs[1].getAll();
return ['CalGrayCS', params];
case 'CalRGB':
return 'DeviceRgbCS';
case 'ICCBased':
@ -1726,6 +1732,113 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() {
return DeviceCmykCS;
})();
//
// CalGrayCS: Based on "PDF Reference, Sixth Ed", p.245
//
var CalGrayCS = (function CalGrayCSClosure() {
function CalGrayCS(whitePoint, blackPoint, gamma) {
this.name = 'CalGray';
this.numComps = 3;
this.defaultColor = new Float32Array([0, 0, 0]);
if (!whitePoint) {
error('WhitePoint missing - required for color space CalGray');
}
blackPoint = blackPoint || [0, 0, 0];
gamma = gamma || 1;
// Translate arguments to spec variables.
this.XW = whitePoint[0];
this.YW = whitePoint[1];
this.ZW = whitePoint[2];
this.XB = blackPoint[0];
this.YB = blackPoint[1];
this.ZB = blackPoint[2];
this.G = gamma;
// Validate variables as per spec.
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
error('Invalid WhitePoint components for ' + this.name +
', no fallback available');
}
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
info('Invalid BlackPoint for ' + this.name + ', falling back to default');
this.XB = this.YB = this.ZB = 0;
}
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
TODO(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
', ZB: ' + this.ZB + ', only default values are supported.');
}
if (this.G < 1) {
info('Invalid Gamma: ' + this.G + ' for ' + this.name +
', falling back to default');
this.G = 1;
}
}
CalGrayCS.prototype = {
getRgb: function CalGrayCS_getRgb(src, srcOffset) {
var rgb = new Uint8Array(3);
this.getRgbItem(src, srcOffset, rgb, 0);
return rgb;
},
getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset,
dest, destOffset) {
// A represents a gray component of a calibrated gray space.
// A <---> AG in the spec
var A = src[srcOffset];
var AG = Math.pow(A, this.G);
// Computes intermediate variables M, L, N as per spec.
// Except if other than default BlackPoint values are used.
var M = this.XW * AG;
var L = this.YW * AG;
var N = this.ZW * AG;
// Decode XYZ, as per spec.
var X = M;
var Y = L;
var Z = N;
// http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
// This yields values in range [0, 100].
var Lstar = Math.max(116 * Math.pow(Y, 1 / 3) - 16, 0);
// Convert values to rgb range [0, 255].
dest[destOffset] = Lstar * 255 / 100;
dest[destOffset + 1] = Lstar * 255 / 100;
dest[destOffset + 2] = Lstar * 255 / 100;
},
getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count,
dest, destOffset, bits) {
// TODO: This part is copied from DeviceGray. Make this utility function.
var scale = 255 / ((1 << bits) - 1);
var j = srcOffset, q = destOffset;
for (var i = 0; i < count; ++i) {
var c = (scale * src[j++]) | 0;
dest[q++] = c;
dest[q++] = c;
dest[q++] = c;
}
},
getOutputLength: function CalGrayCS_getOutputLength(inputLength) {
return inputLength * 3;
},
isPassthrough: ColorSpace.prototype.isPassthrough,
createRgbBuffer: ColorSpace.prototype.createRgbBuffer,
isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
},
usesZeroToOneRange: true
};
return CalGrayCS;
})();
//
// LabCS: Based on "PDF Reference, Sixth Ed", p.250
//
@ -1868,6 +1981,7 @@ var LabCS = (function LabCSClosure() {
})();
var PatternType = {
AXIAL: 2,
RADIAL: 3
@ -3831,8 +3945,54 @@ PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
* @var {Boolean}
*/
PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ?
false :
PDFJS.disableFontFace;
false : PDFJS.disableFontFace;
/**
* Path for image resources, mainly for annotation icons. Include trailing
* slash.
* @var {String}
*/
PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
'' : PDFJS.imageResourcesPath;
/**
* Disable the web worker and run all code on the main thread. This will happen
* automatically if the browser doesn't support workers or sending typed arrays
* to workers.
* @var {Boolean}
*/
PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
false : PDFJS.disableWorker;
/**
* Path and filename of the worker file. Required when the worker is enabled.
* @var {String}
*/
PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
/**
* Disable range request loading of PDF files. When enabled and if the server
* supports partial content requests then the PDF will be fetched in chunks.
* Enabled (false) by default.
* @var {Boolean}
*/
PDFJS.disableRange = PDFJS.disableRange === undefined ?
false : PDFJS.disableRange;
/**
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
* will automatically keep fetching more data even if it isn't needed to display
* the current page. This default behavior can be disabled.
* @var {Boolean}
*/
PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ?
false : PDFJS.disableAutoFetch;
/**
* Enables special hooks for debugging PDF.js.
* @var {Boolean}
*/
PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
/**
* This is the main entry point for loading a PDF and interacting with it.
@ -4274,7 +4434,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
// as it arrives on the worker. Chrome added this with version 15.
if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') {
var workerSrc = PDFJS.workerSrc;
if (typeof workerSrc === 'undefined') {
if (!workerSrc) {
error('No PDFJS.workerSrc specified');
}
@ -6618,7 +6778,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
var imgToPaint;
if (imgData instanceof HTMLElement) {
// instanceof HTMLElement does not work in jsdom node.js module
if (imgData instanceof HTMLElement || !imgData.data) {
imgToPaint = imgData;
} else {
var tmpCanvas = CachedCanvases.getCanvas('inlineImage', width, height);

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

@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
PDFJS.version = '0.8.558';
PDFJS.build = 'ea50c07';
PDFJS.version = '0.8.629';
PDFJS.build = 'b16b3be';
(function pdfjsWrapper() {
// Use strict in our context only - users might not want it
@ -4170,22 +4170,16 @@ var PDFDocument = (function PDFDocumentClosure() {
return shadow(this, 'documentInfo', docInfo);
},
get fingerprint() {
var xref = this.xref, fileID;
var xref = this.xref, hash, fileID = '';
if (xref.trailer.has('ID')) {
fileID = '';
var id = xref.trailer.get('ID')[0];
id.split('').forEach(function(el) {
fileID += Number(el.charCodeAt(0)).toString(16);
});
hash = stringToBytes(xref.trailer.get('ID')[0]);
} else {
// If we got no fileID, then we generate one,
// from the first 100 bytes of PDF
var data = this.stream.bytes.subarray(0, 100);
var hash = calculateMD5(data, 0, data.length);
fileID = '';
for (var i = 0, length = hash.length; i < length; i++) {
fileID += Number(hash[i]).toString(16);
}
hash = calculateMD5(this.stream.bytes.subarray(0, 100), 0, 100);
}
for (var i = 0, n = hash.length; i < n; i++) {
fileID += hash[i].toString(16);
}
return shadow(this, 'fingerprint', fileID);
@ -12573,6 +12567,11 @@ var ColorSpace = (function ColorSpaceClosure() {
return this.singletons.rgb;
case 'DeviceCmykCS':
return this.singletons.cmyk;
case 'CalGrayCS':
var whitePoint = IR[1].WhitePoint;
var blackPoint = IR[1].BlackPoint;
var gamma = IR[1].Gamma;
return new CalGrayCS(whitePoint, blackPoint, gamma);
case 'PatternCS':
var basePatternCS = IR[1];
if (basePatternCS)
@ -12648,7 +12647,8 @@ var ColorSpace = (function ColorSpaceClosure() {
case 'CMYK':
return 'DeviceCmykCS';
case 'CalGray':
return 'DeviceGrayCS';
var params = cs[1].getAll();
return ['CalGrayCS', params];
case 'CalRGB':
return 'DeviceRgbCS';
case 'ICCBased':
@ -13068,6 +13068,113 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() {
return DeviceCmykCS;
})();
//
// CalGrayCS: Based on "PDF Reference, Sixth Ed", p.245
//
var CalGrayCS = (function CalGrayCSClosure() {
function CalGrayCS(whitePoint, blackPoint, gamma) {
this.name = 'CalGray';
this.numComps = 3;
this.defaultColor = new Float32Array([0, 0, 0]);
if (!whitePoint) {
error('WhitePoint missing - required for color space CalGray');
}
blackPoint = blackPoint || [0, 0, 0];
gamma = gamma || 1;
// Translate arguments to spec variables.
this.XW = whitePoint[0];
this.YW = whitePoint[1];
this.ZW = whitePoint[2];
this.XB = blackPoint[0];
this.YB = blackPoint[1];
this.ZB = blackPoint[2];
this.G = gamma;
// Validate variables as per spec.
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
error('Invalid WhitePoint components for ' + this.name +
', no fallback available');
}
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
info('Invalid BlackPoint for ' + this.name + ', falling back to default');
this.XB = this.YB = this.ZB = 0;
}
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
TODO(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
', ZB: ' + this.ZB + ', only default values are supported.');
}
if (this.G < 1) {
info('Invalid Gamma: ' + this.G + ' for ' + this.name +
', falling back to default');
this.G = 1;
}
}
CalGrayCS.prototype = {
getRgb: function CalGrayCS_getRgb(src, srcOffset) {
var rgb = new Uint8Array(3);
this.getRgbItem(src, srcOffset, rgb, 0);
return rgb;
},
getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset,
dest, destOffset) {
// A represents a gray component of a calibrated gray space.
// A <---> AG in the spec
var A = src[srcOffset];
var AG = Math.pow(A, this.G);
// Computes intermediate variables M, L, N as per spec.
// Except if other than default BlackPoint values are used.
var M = this.XW * AG;
var L = this.YW * AG;
var N = this.ZW * AG;
// Decode XYZ, as per spec.
var X = M;
var Y = L;
var Z = N;
// http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
// This yields values in range [0, 100].
var Lstar = Math.max(116 * Math.pow(Y, 1 / 3) - 16, 0);
// Convert values to rgb range [0, 255].
dest[destOffset] = Lstar * 255 / 100;
dest[destOffset + 1] = Lstar * 255 / 100;
dest[destOffset + 2] = Lstar * 255 / 100;
},
getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count,
dest, destOffset, bits) {
// TODO: This part is copied from DeviceGray. Make this utility function.
var scale = 255 / ((1 << bits) - 1);
var j = srcOffset, q = destOffset;
for (var i = 0; i < count; ++i) {
var c = (scale * src[j++]) | 0;
dest[q++] = c;
dest[q++] = c;
dest[q++] = c;
}
},
getOutputLength: function CalGrayCS_getOutputLength(inputLength) {
return inputLength * 3;
},
isPassthrough: ColorSpace.prototype.isPassthrough,
createRgbBuffer: ColorSpace.prototype.createRgbBuffer,
isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
},
usesZeroToOneRange: true
};
return CalGrayCS;
})();
//
// LabCS: Based on "PDF Reference, Sixth Ed", p.250
//
@ -13210,6 +13317,7 @@ var LabCS = (function LabCSClosure() {
})();
var ARCFourCipher = (function ARCFourCipherClosure() {
function ARCFourCipher(key) {
this.a = 0;
@ -20951,18 +21059,22 @@ var CFFFont = (function CFFFontClosure() {
var unassignedUnicodeItems = [];
var inverseEncoding = [];
var gidStart = 0;
// Even though the CFF font may not actually be a CID font is could have
// CID information in the font descriptor.
if (this.properties.cidSystemInfo) {
// According to section 9.7.4.2 if the font is actually a CID font then
// we should use the charset to map CIDs to GIDs. If it is not actually
// a CID font then CIDs can be mapped directly to GIDs.
// According to section 9.7.4.2 CIDFontType0C glyph selection should be
// handled differently.
if (this.properties.subtype === 'CIDFontType0C') {
if (this.cff.isCIDFont) {
// If the font is actually a CID font then we should use the charset
// to map CIDs to GIDs.
inverseEncoding = charsets;
} else {
for (var i = 0, ii = charsets.length; i < charsets.length; i++) {
// If it is NOT actually a CID font then CIDs should be mapped
// directly to GIDs.
inverseEncoding = [];
for (var i = 0, ii = cff.charStrings.count; i < ii; i++) {
inverseEncoding.push(i);
}
// Use the identity map for charsets as well.
charsets = inverseEncoding;
}
} else {
for (var charcode in encoding) {
@ -35872,6 +35984,19 @@ var JpxImage = (function JpxImageClosure() {
}
return ll;
};
Transform.prototype.expand = function expand(buffer, bufferPadding, step) {
// Section F.3.7 extending... using max extension of 4
var i1 = bufferPadding - 1, j1 = bufferPadding + 1;
var i2 = bufferPadding + step - 2, j2 = bufferPadding + step;
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
};
Transform.prototype.iterate = function Transform_iterate(ll, hl, lh, hh,
u0, v0) {
var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
@ -35925,18 +36050,7 @@ var JpxImage = (function JpxImageClosure() {
for (var u = 0; u < width; u++, k++, l++)
buffer[l] = items[k];
// Section F.3.7 extending... using max extension of 4
var i1 = bufferPadding - 1, j1 = bufferPadding + 1;
var i2 = bufferPadding + width - 2, j2 = bufferPadding + width;
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
this.expand(buffer, bufferPadding, width);
this.filter(buffer, bufferPadding, width, u0, bufferOut);
k = v * width;
@ -35960,18 +36074,7 @@ var JpxImage = (function JpxImageClosure() {
for (var v = 0; v < height; v++, k += width, l++)
buffer[l] = items[k];
// Section F.3.7 extending... using max extension of 4
var i1 = bufferPadding - 1, j1 = bufferPadding + 1;
var i2 = bufferPadding + height - 2, j2 = bufferPadding + height;
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
buffer[i1--] = buffer[j1++];
buffer[j2++] = buffer[i2--];
this.expand(buffer, bufferPadding, height);
this.filter(buffer, bufferPadding, height, v0, bufferOut);
k = u;
@ -36624,10 +36727,6 @@ var Jbig2Image = (function Jbig2ImageClosure() {
var decoder = decodingContext.decoder;
var contextCache = decodingContext.contextCache;
if (transposed)
error('JBIG2 error: transposed is not supported');
var stripT = -decodeInteger(contextCache, 'IADT', decoder); // 6.4.6
var firstS = 0;
var i = 0;
@ -36662,28 +36761,60 @@ var Jbig2Image = (function Jbig2ImageClosure() {
}
var offsetT = t - ((referenceCorner & 1) ? 0 : symbolHeight);
var offsetS = currentS - ((referenceCorner & 2) ? symbolWidth : 0);
for (var t2 = 0; t2 < symbolHeight; t2++) {
var row = bitmap[offsetT + t2];
if (!row) continue;
var symbolRow = symbolBitmap[t2];
switch (combinationOperator) {
case 0: // OR
for (var s2 = 0; s2 < symbolWidth; s2++)
row[offsetS + s2] |= symbolRow[s2];
break;
case 2: // XOR
for (var s2 = 0; s2 < symbolWidth; s2++)
row[offsetS + s2] ^= symbolRow[s2];
break;
default:
error('JBIG2 error: operator ' + combinationOperator +
' is not supported');
if (transposed) {
// Place Symbol Bitmap from T1,S1
for (var s2 = 0; s2 < symbolHeight; s2++) {
var row = bitmap[offsetS + s2];
if (!row) {
continue;
}
var symbolRow = symbolBitmap[s2];
// To ignore Parts of Symbol bitmap which goes
// outside bitmap region
var maxWidth = Math.min(width - offsetT, symbolWidth);
switch (combinationOperator) {
case 0: // OR
for (var t2 = 0; t2 < maxWidth; t2++) {
row[offsetT + t2] |= symbolRow[t2];
}
break;
case 2: // XOR
for (var t2 = 0; t2 < maxWidth; t2++) {
row[offsetT + t2] ^= symbolRow[t2];
}
break;
default:
error('JBIG2 error: operator ' + combinationOperator +
' is not supported');
}
}
currentS += symbolHeight - 1;
} else {
for (var t2 = 0; t2 < symbolHeight; t2++) {
var row = bitmap[offsetT + t2];
if (!row) {
continue;
}
var symbolRow = symbolBitmap[t2];
switch (combinationOperator) {
case 0: // OR
for (var s2 = 0; s2 < symbolWidth; s2++) {
row[offsetS + s2] |= symbolRow[s2];
}
break;
case 2: // XOR
for (var s2 = 0; s2 < symbolWidth; s2++) {
row[offsetS + s2] ^= symbolRow[s2];
}
break;
default:
error('JBIG2 error: operator ' + combinationOperator +
' is not supported');
}
}
currentS += symbolWidth - 1;
}
currentS += symbolWidth - 1;
i++;
var deltaS = decodeInteger(contextCache, 'IADS', decoder); // 6.4.8
if (deltaS === null)
break; // OOB

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

@ -20,6 +20,8 @@
html {
height: 100%;
/* Font size is needed to make the activity bar the corect size. */
font-size: 10px;
}
body {
@ -80,7 +82,16 @@ select {
display: none;
}
#viewerContainer.presentationControls {
:-moz-full-screen .textLayer > div {
cursor: none;
}
:fullscreen .textLayer > div {
cursor: none;
}
#viewerContainer.presentationControls,
#viewerContainer.presentationControls .textLayer > div {
cursor: default;
}
@ -113,6 +124,7 @@ html[dir='rtl'] .innerCenter {
#outerContainer {
width: 100%;
height: 100%;
position: relative;
}
#sidebarContainer {
@ -328,6 +340,7 @@ html[dir='rtl'] .secondaryToolbar {
max-width: 200px;
max-height: 400px;
overflow-y: auto;
margin-bottom: -4px;
}
.doorHanger,
@ -803,19 +816,24 @@ html[dir="rtl"] .secondaryToolbarButton.print::before {
content: url(images/toolbarButton-download.png);
}
.toolbarButton.bookmark {
.toolbarButton.bookmark,
.secondaryToolbarButton.bookmark {
-moz-box-sizing: border-box;
box-sizing: border-box;
margin-top: 3px;
padding-top: 4px;
text-decoration: none;
}
.secondaryToolbarButton.bookmark {
padding-top: 5px;
}
#viewBookmark[href='#'] {
.bookmark[href='#'] {
opacity: .5;
pointer-events: none;
}
.toolbarButton.bookmark::before {
.toolbarButton.bookmark::before,
.secondaryToolbarButton.bookmark::before {
content: url(images/toolbarButton-bookmark.png);
}
@ -852,9 +870,11 @@ html[dir="rtl"] .secondaryToolbarButton {
padding-right: 24px;
text-align: right;
}
#secondaryToolbarButtonContainer :last-child {
margin-bottom: 0;
html[dir="ltr"] .secondaryToolbarButton.bookmark {
padding-left: 27px;
}
html[dir="rtl"] .secondaryToolbarButton.bookmark {
padding-right: 27px;
}
html[dir="ltr"] .secondaryToolbarButton > span {
@ -971,6 +991,11 @@ html[dir='rtl'] .verticalToolbarSeparator {
.thumbnail {
float: left;
margin-bottom: 5px;
}
#thumbnailView > a:last-of-type > .thumbnail {
margin-bottom: 10px;
}
.thumbnail:not([data-loaded]) {

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

@ -98,21 +98,25 @@ limitations under the License.
<span data-l10n-id="download_label">Download</span>
</button>
<a href="#" id="secondaryViewBookmark" class="secondaryToolbarButton bookmark visibleSmallView" title="Current view (copy or open in new window)" tabindex="22" data-l10n-id="bookmark">
<span data-l10n-id="bookmark_label">Current View</span>
</a>
<div class="horizontalToolbarSeparator visibleLargeView"></div>
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="22" data-l10n-id="first_page">
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="23" data-l10n-id="first_page">
<span data-l10n-id="first_page_label">Go to First Page</span>
</button>
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="23" data-l10n-id="last_page">
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="24" data-l10n-id="last_page">
<span data-l10n-id="last_page_label">Go to Last Page</span>
</button>
<div class="horizontalToolbarSeparator"></div>
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="24" data-l10n-id="page_rotate_cw">
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="25" data-l10n-id="page_rotate_cw">
<span data-l10n-id="page_rotate_cw_label">Rotate Clockwise</span>
</button>
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="25" data-l10n-id="page_rotate_ccw">
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="26" data-l10n-id="page_rotate_ccw">
<span data-l10n-id="page_rotate_ccw_label">Rotate Counterclockwise</span>
</button>
</div>
@ -160,7 +164,9 @@ limitations under the License.
<span data-l10n-id="download_label">Download</span>
</button>
<!-- <div class="toolbarButtonSpacer"></div> -->
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="16" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="16" data-l10n-id="bookmark">
<span data-l10n-id="bookmark_label">Current View</span>
</a>
<div class="verticalToolbarSeparator hiddenSmallView"></div>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -187,7 +187,6 @@
#endif
@BINPATH@/components/dom_camera.xpt
@BINPATH@/components/dom_canvas.xpt
@BINPATH@/components/dom_contacts.xpt
@BINPATH@/components/dom_alarm.xpt
@BINPATH@/components/dom_core.xpt
@BINPATH@/components/dom_css.xpt

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

@ -228,7 +228,7 @@ if test -n "$gonkdir" ; then
AC_SUBST(MOZ_OMX_DECODER)
MOZ_RTSP=1
;;
18)
17|18)
GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include"
if test -d "$gonkdir/external/bluetooth/bluez"; then
GONK_INCLUDES="$GONK_INCLUDES -I$gonkdir/external/dbus -I$gonkdir/external/bluetooth/bluez/lib"

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

@ -1368,13 +1368,6 @@ public:
*/
static const nsDependentString GetLocalizedEllipsis();
/**
* The routine GetNativeEvent returns the result of
* aDOMEvent->GetInternalNSEvent().
* XXX Is this necessary?
*/
static mozilla::WidgetEvent* GetNativeEvent(nsIDOMEvent* aDOMEvent);
/**
* Get the candidates for accelkeys for aDOMKeyEvent.
*

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

@ -2168,9 +2168,9 @@ Element::PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor)
case NS_MOUSE_ENTER_SYNTH:
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
// FALL THROUGH
case NS_FOCUS_CONTENT:
if (aVisitor.mEvent->eventStructType != NS_FOCUS_EVENT ||
!static_cast<InternalFocusEvent*>(aVisitor.mEvent)->isRefocus) {
case NS_FOCUS_CONTENT: {
InternalFocusEvent* focusEvent = aVisitor.mEvent->AsFocusEvent();
if (!focusEvent || !focusEvent->isRefocus) {
nsAutoString target;
GetLinkTarget(target);
nsContentUtils::TriggerLink(this, aVisitor.mPresContext, absURI, target,
@ -2179,7 +2179,7 @@ Element::PreHandleEventForLinks(nsEventChainPreVisitor& aVisitor)
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
}
break;
}
case NS_MOUSE_EXIT_SYNTH:
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
// FALL THROUGH
@ -2249,8 +2249,7 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
case NS_MOUSE_CLICK:
if (aVisitor.mEvent->IsLeftClickEvent()) {
WidgetInputEvent* inputEvent =
static_cast<WidgetInputEvent*>(aVisitor.mEvent);
WidgetInputEvent* inputEvent = aVisitor.mEvent->AsInputEvent();
if (inputEvent->IsControl() || inputEvent->IsMeta() ||
inputEvent->IsAlt() ||inputEvent->IsShift()) {
break;
@ -2287,16 +2286,13 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor)
case NS_KEY_PRESS:
{
if (aVisitor.mEvent->eventStructType == NS_KEY_EVENT) {
WidgetKeyboardEvent* keyEvent =
static_cast<WidgetKeyboardEvent*>(aVisitor.mEvent);
if (keyEvent->keyCode == NS_VK_RETURN) {
nsEventStatus status = nsEventStatus_eIgnore;
rv = DispatchClickEvent(aVisitor.mPresContext, keyEvent, this,
false, nullptr, &status);
if (NS_SUCCEEDED(rv)) {
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
if (keyEvent && keyEvent->keyCode == NS_VK_RETURN) {
nsEventStatus status = nsEventStatus_eIgnore;
rv = DispatchClickEvent(aVisitor.mPresContext, keyEvent, this,
false, nullptr, &status);
if (NS_SUCCEEDED(rv)) {
aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
}
}
}

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

@ -4557,13 +4557,6 @@ nsContentUtils::GetLocalizedEllipsis()
return nsDependentString(sBuf);
}
//static
WidgetEvent*
nsContentUtils::GetNativeEvent(nsIDOMEvent* aDOMEvent)
{
return aDOMEvent ? aDOMEvent->GetInternalNSEvent() : nullptr;
}
static bool
HasASCIIDigit(const nsTArray<nsShortcutCandidate>& aCandidates)
{
@ -4604,7 +4597,7 @@ nsContentUtils::GetAccelKeyCandidates(nsIDOMKeyEvent* aDOMKeyEvent,
return;
WidgetKeyboardEvent* nativeKeyEvent =
static_cast<WidgetKeyboardEvent*>(GetNativeEvent(aDOMKeyEvent));
aDOMKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
if (nativeKeyEvent) {
NS_ASSERTION(nativeKeyEvent->eventStructType == NS_KEY_EVENT,
"wrong type of native event");

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

@ -16,6 +16,8 @@ namespace mozilla {
class InternalMutationEvent : public WidgetEvent
{
public:
virtual InternalMutationEvent* AsMutationEvent() MOZ_OVERRIDE { return this; }
InternalMutationEvent(bool aIsTrusted, uint32_t aMessage) :
WidgetEvent(aIsTrusted, aMessage, NS_MUTATION_EVENT),
mAttrChange(0)

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

@ -29,16 +29,6 @@ DOMWheelEvent::DOMWheelEvent(EventTarget* aOwner,
}
}
DOMWheelEvent::~DOMWheelEvent()
{
if (mEventIsInternal && mEvent) {
MOZ_ASSERT(mEvent->eventStructType == NS_WHEEL_EVENT,
"The mEvent must be WidgetWheelEvent");
delete static_cast<WidgetWheelEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(DOMWheelEvent, nsDOMMouseEvent)
NS_IMPL_RELEASE_INHERITED(DOMWheelEvent, nsDOMMouseEvent)

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

@ -22,7 +22,6 @@ public:
DOMWheelEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetWheelEvent* aWheelEvent);
virtual ~DOMWheelEvent();
NS_DECL_ISUPPORTS_INHERITED

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

@ -51,7 +51,7 @@ TextComposition::DispatchEvent(WidgetGUIEvent* aEvent,
nsDispatchingCallback* aCallBack)
{
if (aEvent->message == NS_COMPOSITION_UPDATE) {
mLastData = static_cast<WidgetCompositionEvent*>(aEvent)->data;
mLastData = aEvent->AsCompositionEvent()->data;
}
nsEventDispatcher::Dispatch(mNode, mPresContext,

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

@ -26,14 +26,6 @@ nsDOMAnimationEvent::nsDOMAnimationEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMAnimationEvent::~nsDOMAnimationEvent()
{
if (mEventIsInternal) {
delete AnimationEvent();
mEvent = nullptr;
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMAnimationEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMAnimationEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -54,9 +46,10 @@ nsDOMAnimationEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
e->AnimationEvent()->animationName = aParam.mAnimationName;
e->AnimationEvent()->elapsedTime = aParam.mElapsedTime;
e->AnimationEvent()->pseudoElement = aParam.mPseudoElement;
InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
internalEvent->animationName = aParam.mAnimationName;
internalEvent->elapsedTime = aParam.mElapsedTime;
internalEvent->pseudoElement = aParam.mPseudoElement;
e->SetTrusted(trusted);
return e.forget();
@ -65,7 +58,7 @@ nsDOMAnimationEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
NS_IMETHODIMP
nsDOMAnimationEvent::GetAnimationName(nsAString & aAnimationName)
{
aAnimationName = AnimationEvent()->animationName;
aAnimationName = mEvent->AsAnimationEvent()->animationName;
return NS_OK;
}
@ -76,10 +69,16 @@ nsDOMAnimationEvent::GetElapsedTime(float *aElapsedTime)
return NS_OK;
}
float
nsDOMAnimationEvent::ElapsedTime()
{
return mEvent->AsAnimationEvent()->elapsedTime;
}
NS_IMETHODIMP
nsDOMAnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
{
aPseudoElement = AnimationEvent()->pseudoElement;
aPseudoElement = mEvent->AsAnimationEvent()->pseudoElement;
return NS_OK;
}

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

@ -7,7 +7,7 @@
#include "nsDOMEvent.h"
#include "nsIDOMAnimationEvent.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/AnimationEventBinding.h"
class nsAString;
@ -19,7 +19,6 @@ public:
nsDOMAnimationEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
mozilla::InternalAnimationEvent* aEvent);
~nsDOMAnimationEvent();
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_TO_NSDOMEVENT
@ -41,17 +40,7 @@ public:
// GetAnimationName(nsAString& aAnimationName);
// GetPseudoElement(nsAString& aPseudoElement);
float ElapsedTime()
{
return AnimationEvent()->elapsedTime;
}
private:
mozilla::InternalAnimationEvent* AnimationEvent() {
NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_ANIMATION_EVENT,
"unexpected struct type");
return static_cast<mozilla::InternalAnimationEvent*>(mEvent);
}
float ElapsedTime();
};
#endif /* !defined(nsDOMAnimationEvent_h_) */

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

@ -24,14 +24,6 @@ nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMClipboardEvent::~nsDOMClipboardEvent()
{
if (mEventIsInternal && mEvent->eventStructType == NS_CLIPBOARD_EVENT) {
delete static_cast<InternalClipboardEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMClipboardEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMClipboardEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -40,14 +32,15 @@ NS_IMPL_ADDREF_INHERITED(nsDOMClipboardEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMClipboardEvent, nsDOMEvent)
nsresult
nsDOMClipboardEvent::InitClipboardEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
nsIDOMDataTransfer* clipboardData)
nsDOMClipboardEvent::InitClipboardEvent(const nsAString& aType,
bool aCanBubble,
bool aCancelable,
nsIDOMDataTransfer* aClipboardData)
{
nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
NS_ENSURE_SUCCESS(rv, rv);
InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
event->clipboardData = clipboardData;
mEvent->AsClipboardEvent()->clipboardData = aClipboardData;
return NS_OK;
}
@ -65,8 +58,7 @@ nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
nsRefPtr<nsDOMDataTransfer> clipboardData;
if (e->mEventIsInternal) {
InternalClipboardEvent* event =
static_cast<InternalClipboardEvent*>(e->mEvent);
InternalClipboardEvent* event = e->mEvent->AsClipboardEvent();
if (event) {
// Always create a clipboardData for the copy event. If this is changed to
// support other types of events, make sure that read/write privileges are
@ -92,7 +84,7 @@ nsDOMClipboardEvent::GetClipboardData(nsIDOMDataTransfer** aClipboardData)
nsIDOMDataTransfer*
nsDOMClipboardEvent::GetClipboardData()
{
InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
InternalClipboardEvent* event = mEvent->AsClipboardEvent();
if (!event->clipboardData) {
if (mEventIsInternal) {

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

@ -18,7 +18,6 @@ public:
nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::InternalClipboardEvent* aEvent);
virtual ~nsDOMClipboardEvent();
NS_DECL_ISUPPORTS_INHERITED

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

@ -23,14 +23,6 @@ nsDOMCommandEvent::nsDOMCommandEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMCommandEvent::~nsDOMCommandEvent()
{
if (mEventIsInternal && mEvent->eventStructType == NS_COMMAND_EVENT) {
delete static_cast<WidgetCommandEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMCommandEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMCommandEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -41,7 +33,7 @@ NS_IMPL_RELEASE_INHERITED(nsDOMCommandEvent, nsDOMEvent)
NS_IMETHODIMP
nsDOMCommandEvent::GetCommand(nsAString& aCommand)
{
nsIAtom* command = static_cast<WidgetCommandEvent*>(mEvent)->command;
nsIAtom* command = mEvent->AsCommandEvent()->command;
if (command) {
command->ToString(aCommand);
} else {
@ -59,7 +51,7 @@ nsDOMCommandEvent::InitCommandEvent(const nsAString& aTypeArg,
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
static_cast<WidgetCommandEvent*>(mEvent)->command = do_GetAtom(aCommand);
mEvent->AsCommandEvent()->command = do_GetAtom(aCommand);
return NS_OK;
}

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

@ -18,7 +18,6 @@ public:
nsDOMCommandEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetCommandEvent* aEvent);
virtual ~nsDOMCommandEvent();
NS_DECL_ISUPPORTS_INHERITED

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

@ -31,18 +31,10 @@ nsDOMCompositionEvent::nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner,
mEvent->mFlags.mCancelable = false;
}
mData = static_cast<WidgetCompositionEvent*>(mEvent)->data;
mData = mEvent->AsCompositionEvent()->data;
// TODO: Native event should have locale information.
}
nsDOMCompositionEvent::~nsDOMCompositionEvent()
{
if (mEventIsInternal) {
delete static_cast<WidgetCompositionEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMCompositionEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMCompositionEvent, nsDOMUIEvent)

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

@ -10,7 +10,7 @@
#include "nsDOMUIEvent.h"
#include "nsIDOMCompositionEvent.h"
#include "mozilla/dom/CompositionEventBinding.h"
#include "mozilla/TextEvents.h"
#include "mozilla/EventForwards.h"
class nsDOMCompositionEvent : public nsDOMUIEvent,
public nsIDOMCompositionEvent
@ -19,7 +19,6 @@ public:
nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetCompositionEvent* aEvent);
virtual ~nsDOMCompositionEvent();
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_TO_NSDOMUIEVENT

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

@ -13,7 +13,7 @@ using namespace mozilla;
nsDOMDragEvent::nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
WidgetDragEvent* aEvent)
: nsDOMMouseEvent(aOwner, aPresContext, aEvent ? aEvent :
new WidgetDragEvent(false, 0, nullptr))
{
@ -29,15 +29,6 @@ nsDOMDragEvent::nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMDragEvent::~nsDOMDragEvent()
{
if (mEventIsInternal) {
if (mEvent->eventStructType == NS_DRAG_EVENT)
delete static_cast<WidgetDragEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMDragEvent, nsDOMMouseEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMDragEvent, nsDOMMouseEvent)
@ -63,8 +54,7 @@ nsDOMDragEvent::InitDragEvent(const nsAString & aType,
NS_ENSURE_SUCCESS(rv, rv);
if (mEventIsInternal && mEvent) {
WidgetDragEvent* dragEvent = static_cast<WidgetDragEvent*>(mEvent);
dragEvent->dataTransfer = aDataTransfer;
mEvent->AsDragEvent()->dataTransfer = aDataTransfer;
}
return NS_OK;
@ -89,7 +79,7 @@ nsDOMDragEvent::GetDataTransfer()
return nullptr;
}
WidgetDragEvent* dragEvent = static_cast<WidgetDragEvent*>(mEvent);
WidgetDragEvent* dragEvent = mEvent->AsDragEvent();
// for synthetic events, just use the supplied data transfer object even if null
if (!mEventIsInternal) {
nsresult rv = nsContentUtils::SetDataTransferInEvent(dragEvent);

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

@ -17,8 +17,7 @@ class nsDOMDragEvent : public nsDOMMouseEvent,
public:
nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetInputEvent* aEvent);
virtual ~nsDOMDragEvent();
mozilla::WidgetDragEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED

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

@ -143,24 +143,22 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent)
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget =
nullptr;
tmp->mEvent->AsMouseEventBase()->relatedTarget = nullptr;
break;
case NS_DRAG_EVENT:
static_cast<WidgetDragEvent*>(tmp->mEvent)->dataTransfer = nullptr;
static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget =
nullptr;
case NS_DRAG_EVENT: {
WidgetDragEvent* dragEvent = tmp->mEvent->AsDragEvent();
dragEvent->dataTransfer = nullptr;
dragEvent->relatedTarget = nullptr;
break;
}
case NS_CLIPBOARD_EVENT:
static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData =
nullptr;
tmp->mEvent->AsClipboardEvent()->clipboardData = nullptr;
break;
case NS_MUTATION_EVENT:
static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode =
nullptr;
tmp->mEvent->AsMutationEvent()->mRelatedNode = nullptr;
break;
case NS_FOCUS_EVENT:
static_cast<InternalFocusEvent*>(tmp->mEvent)->relatedTarget = nullptr;
tmp->mEvent->AsFocusEvent()->relatedTarget = nullptr;
break;
default:
break;
@ -183,31 +181,27 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent)
case NS_WHEEL_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
cb.NoteXPCOMChild(
static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget);
cb.NoteXPCOMChild(tmp->mEvent->AsMouseEventBase()->relatedTarget);
break;
case NS_DRAG_EVENT:
case NS_DRAG_EVENT: {
WidgetDragEvent* dragEvent = tmp->mEvent->AsDragEvent();
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->dataTransfer");
cb.NoteXPCOMChild(
static_cast<WidgetDragEvent*>(tmp->mEvent)->dataTransfer);
cb.NoteXPCOMChild(dragEvent->dataTransfer);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
cb.NoteXPCOMChild(
static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget);
cb.NoteXPCOMChild(dragEvent->relatedTarget);
break;
}
case NS_CLIPBOARD_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->clipboardData");
cb.NoteXPCOMChild(
static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData);
cb.NoteXPCOMChild(tmp->mEvent->AsClipboardEvent()->clipboardData);
break;
case NS_MUTATION_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->mRelatedNode");
cb.NoteXPCOMChild(
static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode);
cb.NoteXPCOMChild(tmp->mEvent->AsMutationEvent()->mRelatedNode);
break;
case NS_FOCUS_EVENT:
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
cb.NoteXPCOMChild(
static_cast<InternalFocusEvent*>(tmp->mEvent)->relatedTarget);
cb.NoteXPCOMChild(tmp->mEvent->AsFocusEvent()->relatedTarget);
break;
default:
break;
@ -532,7 +526,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_INPUT_EVENT:
{
WidgetInputEvent* oldInputEvent = static_cast<WidgetInputEvent*>(mEvent);
WidgetInputEvent* oldInputEvent = mEvent->AsInputEvent();
WidgetInputEvent* inputEvent = new WidgetInputEvent(false, msg, nullptr);
inputEvent->AssignInputEventData(*oldInputEvent, true);
newEvent = inputEvent;
@ -540,8 +534,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_KEY_EVENT:
{
WidgetKeyboardEvent* oldKeyEvent =
static_cast<WidgetKeyboardEvent*>(mEvent);
WidgetKeyboardEvent* oldKeyEvent = mEvent->AsKeyboardEvent();
WidgetKeyboardEvent* keyEvent =
new WidgetKeyboardEvent(false, msg, nullptr);
keyEvent->AssignKeyEventData(*oldKeyEvent, true);
@ -559,7 +552,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_DRAG_EVENT:
{
WidgetDragEvent* oldDragEvent = static_cast<WidgetDragEvent*>(mEvent);
WidgetDragEvent* oldDragEvent = mEvent->AsDragEvent();
WidgetDragEvent* dragEvent = new WidgetDragEvent(false, msg, nullptr);
dragEvent->AssignDragEventData(*oldDragEvent, true);
newEvent = dragEvent;
@ -567,8 +560,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_CLIPBOARD_EVENT:
{
InternalClipboardEvent* oldClipboardEvent =
static_cast<InternalClipboardEvent*>(mEvent);
InternalClipboardEvent* oldClipboardEvent = mEvent->AsClipboardEvent();
InternalClipboardEvent* clipboardEvent =
new InternalClipboardEvent(false, msg);
clipboardEvent->AssignClipboardEventData(*oldClipboardEvent, true);
@ -578,7 +570,7 @@ nsDOMEvent::DuplicatePrivateData()
case NS_SCRIPT_ERROR_EVENT:
{
InternalScriptErrorEvent* oldScriptErrorEvent =
static_cast<InternalScriptErrorEvent*>(mEvent);
mEvent->AsScriptErrorEvent();
InternalScriptErrorEvent* scriptErrorEvent =
new InternalScriptErrorEvent(false, msg);
scriptErrorEvent->AssignScriptErrorEventData(*oldScriptErrorEvent, true);
@ -587,7 +579,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_TEXT_EVENT:
{
WidgetTextEvent* oldTextEvent = static_cast<WidgetTextEvent*>(mEvent);
WidgetTextEvent* oldTextEvent = mEvent->AsTextEvent();
WidgetTextEvent* textEvent = new WidgetTextEvent(false, msg, nullptr);
textEvent->AssignTextEventData(*oldTextEvent, true);
newEvent = textEvent;
@ -598,7 +590,7 @@ nsDOMEvent::DuplicatePrivateData()
WidgetCompositionEvent* compositionEvent =
new WidgetCompositionEvent(false, msg, nullptr);
WidgetCompositionEvent* oldCompositionEvent =
static_cast<WidgetCompositionEvent*>(mEvent);
mEvent->AsCompositionEvent();
compositionEvent->AssignCompositionEventData(*oldCompositionEvent, true);
newEvent = compositionEvent;
break;
@ -606,7 +598,7 @@ nsDOMEvent::DuplicatePrivateData()
case NS_MOUSE_SCROLL_EVENT:
{
WidgetMouseScrollEvent* oldMouseScrollEvent =
static_cast<WidgetMouseScrollEvent*>(mEvent);
mEvent->AsMouseScrollEvent();
WidgetMouseScrollEvent* mouseScrollEvent =
new WidgetMouseScrollEvent(false, msg, nullptr);
mouseScrollEvent->AssignMouseScrollEventData(*oldMouseScrollEvent, true);
@ -623,8 +615,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_SCROLLPORT_EVENT:
{
InternalScrollPortEvent* oldScrollPortEvent =
static_cast<InternalScrollPortEvent*>(mEvent);
InternalScrollPortEvent* oldScrollPortEvent = mEvent->AsScrollPortEvent();
InternalScrollPortEvent* scrollPortEvent =
new InternalScrollPortEvent(false, msg, nullptr);
scrollPortEvent->AssignScrollPortEventData(*oldScrollPortEvent, true);
@ -633,8 +624,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_SCROLLAREA_EVENT:
{
InternalScrollAreaEvent* oldScrollAreaEvent =
static_cast<InternalScrollAreaEvent*>(mEvent);
InternalScrollAreaEvent* oldScrollAreaEvent = mEvent->AsScrollAreaEvent();
InternalScrollAreaEvent* scrollAreaEvent =
new InternalScrollAreaEvent(false, msg, nullptr);
scrollAreaEvent->AssignScrollAreaEventData(*oldScrollAreaEvent, true);
@ -645,15 +635,14 @@ nsDOMEvent::DuplicatePrivateData()
{
InternalMutationEvent* mutationEvent =
new InternalMutationEvent(false, msg);
InternalMutationEvent* oldMutationEvent =
static_cast<InternalMutationEvent*>(mEvent);
InternalMutationEvent* oldMutationEvent = mEvent->AsMutationEvent();
mutationEvent->AssignMutationEventData(*oldMutationEvent, true);
newEvent = mutationEvent;
break;
}
case NS_FORM_EVENT:
{
InternalFormEvent* oldFormEvent = static_cast<InternalFormEvent*>(mEvent);
InternalFormEvent* oldFormEvent = mEvent->AsFormEvent();
InternalFormEvent* formEvent = new InternalFormEvent(false, msg);
formEvent->AssignFormEventData(*oldFormEvent, true);
newEvent = formEvent;
@ -662,16 +651,14 @@ nsDOMEvent::DuplicatePrivateData()
case NS_FOCUS_EVENT:
{
InternalFocusEvent* newFocusEvent = new InternalFocusEvent(false, msg);
InternalFocusEvent* oldFocusEvent =
static_cast<InternalFocusEvent*>(mEvent);
InternalFocusEvent* oldFocusEvent = mEvent->AsFocusEvent();
newFocusEvent->AssignFocusEventData(*oldFocusEvent, true);
newEvent = newFocusEvent;
break;
}
case NS_COMMAND_EVENT:
{
WidgetCommandEvent* oldCommandEvent =
static_cast<WidgetCommandEvent*>(mEvent);
WidgetCommandEvent* oldCommandEvent = mEvent->AsCommandEvent();
WidgetCommandEvent* commandEvent =
new WidgetCommandEvent(false, mEvent->userType,
oldCommandEvent->command, nullptr);
@ -681,7 +668,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_UI_EVENT:
{
InternalUIEvent* oldUIEvent = static_cast<InternalUIEvent*>(mEvent);
InternalUIEvent* oldUIEvent = mEvent->AsUIEvent();
InternalUIEvent* uiEvent =
new InternalUIEvent(false, msg, oldUIEvent->detail);
uiEvent->AssignUIEventData(*oldUIEvent, true);
@ -699,7 +686,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_SMIL_TIME_EVENT:
{
InternalUIEvent* oldUIEvent = static_cast<InternalUIEvent*>(mEvent);
InternalUIEvent* oldUIEvent = mEvent->AsUIEvent();
InternalUIEvent* uiEvent = new InternalUIEvent(false, msg, 0);
uiEvent->eventStructType = NS_SMIL_TIME_EVENT;
uiEvent->AssignUIEventData(*oldUIEvent, true);
@ -709,7 +696,7 @@ nsDOMEvent::DuplicatePrivateData()
case NS_SIMPLE_GESTURE_EVENT:
{
WidgetSimpleGestureEvent* oldSimpleGestureEvent =
static_cast<WidgetSimpleGestureEvent*>(mEvent);
mEvent->AsSimpleGestureEvent();
WidgetSimpleGestureEvent* simpleGestureEvent =
new WidgetSimpleGestureEvent(false, msg, nullptr, 0, 0.0);
simpleGestureEvent->
@ -719,8 +706,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_TRANSITION_EVENT:
{
InternalTransitionEvent* oldTransitionEvent =
static_cast<InternalTransitionEvent*>(mEvent);
InternalTransitionEvent* oldTransitionEvent = mEvent->AsTransitionEvent();
InternalTransitionEvent* transitionEvent =
new InternalTransitionEvent(false, msg,
oldTransitionEvent->propertyName,
@ -732,8 +718,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_ANIMATION_EVENT:
{
InternalAnimationEvent* oldAnimationEvent =
static_cast<InternalAnimationEvent*>(mEvent);
InternalAnimationEvent* oldAnimationEvent = mEvent->AsAnimationEvent();
InternalAnimationEvent* animationEvent =
new InternalAnimationEvent(false, msg,
oldAnimationEvent->animationName,
@ -745,7 +730,7 @@ nsDOMEvent::DuplicatePrivateData()
}
case NS_TOUCH_EVENT:
{
WidgetTouchEvent* oldTouchEvent = static_cast<WidgetTouchEvent*>(mEvent);
WidgetTouchEvent* oldTouchEvent = mEvent->AsTouchEvent();
WidgetTouchEvent* touchEvent = new WidgetTouchEvent(false, oldTouchEvent);
touchEvent->AssignTouchEventData(*oldTouchEvent, true);
newEvent = touchEvent;
@ -899,7 +884,7 @@ nsDOMEvent::GetEventPopupControlState(WidgetEvent* aEvent)
break;
case NS_KEY_EVENT :
if (aEvent->mFlags.mIsTrusted) {
uint32_t key = static_cast<WidgetKeyboardEvent*>(aEvent)->keyCode;
uint32_t key = aEvent->AsKeyboardEvent()->keyCode;
switch(aEvent->message) {
case NS_KEY_PRESS :
// return key on focused button. see note at NS_MOUSE_CLICK.

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

@ -27,14 +27,6 @@ nsDOMFocusEvent::nsDOMFocusEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMFocusEvent::~nsDOMFocusEvent()
{
if (mEventIsInternal && mEvent) {
delete static_cast<InternalFocusEvent*>(mEvent);
mEvent = nullptr;
}
}
/* readonly attribute nsIDOMEventTarget relatedTarget; */
NS_IMETHODIMP
nsDOMFocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
@ -47,7 +39,7 @@ nsDOMFocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
mozilla::dom::EventTarget*
nsDOMFocusEvent::GetRelatedTarget()
{
return static_cast<InternalFocusEvent*>(mEvent)->relatedTarget;
return mEvent->AsFocusEvent()->relatedTarget;
}
nsresult
@ -60,7 +52,7 @@ nsDOMFocusEvent::InitFocusEvent(const nsAString& aType,
{
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
static_cast<InternalFocusEvent*>(mEvent)->relatedTarget = aRelatedTarget;
mEvent->AsFocusEvent()->relatedTarget = aRelatedTarget;
return NS_OK;
}

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

@ -43,7 +43,6 @@ protected:
nsIDOMWindow* aView,
int32_t aDetail,
mozilla::dom::EventTarget* aRelatedTarget);
~nsDOMFocusEvent();
};
#endif /* !defined(nsDOMFocusEvent_h_) */

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

@ -26,14 +26,6 @@ nsDOMKeyboardEvent::nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMKeyboardEvent::~nsDOMKeyboardEvent()
{
if (mEventIsInternal) {
delete static_cast<WidgetKeyboardEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
@ -41,6 +33,12 @@ NS_INTERFACE_MAP_BEGIN(nsDOMKeyboardEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
bool
nsDOMKeyboardEvent::AltKey()
{
return mEvent->AsKeyboardEvent()->IsAlt();
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetAltKey(bool* aIsDown)
{
@ -49,6 +47,12 @@ nsDOMKeyboardEvent::GetAltKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMKeyboardEvent::CtrlKey()
{
return mEvent->AsKeyboardEvent()->IsControl();
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetCtrlKey(bool* aIsDown)
{
@ -57,6 +61,12 @@ nsDOMKeyboardEvent::GetCtrlKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMKeyboardEvent::ShiftKey()
{
return mEvent->AsKeyboardEvent()->IsShift();
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetShiftKey(bool* aIsDown)
{
@ -65,6 +75,12 @@ nsDOMKeyboardEvent::GetShiftKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMKeyboardEvent::MetaKey()
{
return mEvent->AsKeyboardEvent()->IsMeta();
}
NS_IMETHODIMP
nsDOMKeyboardEvent::GetMetaKey(bool* aIsDown)
{
@ -87,7 +103,7 @@ NS_IMETHODIMP
nsDOMKeyboardEvent::GetKey(nsAString& aKeyName)
{
if (!mEventIsInternal) {
static_cast<WidgetKeyboardEvent*>(mEvent)->GetDOMKeyName(aKeyName);
mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
}
return NS_OK;
}
@ -108,7 +124,7 @@ nsDOMKeyboardEvent::CharCode()
case NS_KEY_DOWN:
return 0;
case NS_KEY_PRESS:
return static_cast<WidgetKeyboardEvent*>(mEvent)->charCode;
return mEvent->AsKeyboardEvent()->charCode;
}
return 0;
}
@ -128,7 +144,7 @@ nsDOMKeyboardEvent::KeyCode()
case NS_KEY_UP:
case NS_KEY_PRESS:
case NS_KEY_DOWN:
return static_cast<WidgetKeyboardEvent*>(mEvent)->keyCode;
return mEvent->AsKeyboardEvent()->keyCode;
}
return 0;
}
@ -144,7 +160,7 @@ nsDOMKeyboardEvent::Which()
//Special case for 4xp bug 62878. Try to make value of which
//more closely mirror the values that 4.x gave for RETURN and BACKSPACE
{
uint32_t keyCode = static_cast<WidgetKeyboardEvent*>(mEvent)->keyCode;
uint32_t keyCode = mEvent->AsKeyboardEvent()->keyCode;
if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) {
return keyCode;
}
@ -164,6 +180,12 @@ nsDOMKeyboardEvent::GetLocation(uint32_t* aLocation)
return NS_OK;
}
uint32_t
nsDOMKeyboardEvent::Location()
{
return mEvent->AsKeyboardEvent()->location;
}
NS_IMETHODIMP
nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
@ -173,7 +195,7 @@ nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool a
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
NS_ENSURE_SUCCESS(rv, rv);
WidgetKeyboardEvent* keyEvent = static_cast<WidgetKeyboardEvent*>(mEvent);
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
keyEvent->keyCode = aKeyCode;
keyEvent->charCode = aCharCode;

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

@ -10,7 +10,6 @@
#include "nsDOMUIEvent.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/KeyboardEventBinding.h"
#include "mozilla/TextEvents.h"
class nsDOMKeyboardEvent : public nsDOMUIEvent,
public nsIDOMKeyEvent
@ -19,7 +18,6 @@ public:
nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetKeyboardEvent* aEvent);
virtual ~nsDOMKeyboardEvent();
NS_DECL_ISUPPORTS_INHERITED
@ -35,25 +33,10 @@ public:
return mozilla::dom::KeyboardEventBinding::Wrap(aCx, aScope, this);
}
bool AltKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsAlt();
}
bool CtrlKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsControl();
}
bool ShiftKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsShift();
}
bool MetaKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsMeta();
}
bool AltKey();
bool CtrlKey();
bool ShiftKey();
bool MetaKey();
bool GetModifierState(const nsAString& aKey)
{
@ -63,11 +46,7 @@ public:
uint32_t CharCode();
uint32_t KeyCode();
virtual uint32_t Which() MOZ_OVERRIDE;
uint32_t Location()
{
return static_cast<mozilla::WidgetKeyboardEvent*>(mEvent)->location;
}
uint32_t Location();
void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,

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

@ -13,7 +13,7 @@ using namespace mozilla;
nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
WidgetMouseEventBase* aEvent)
: nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
new WidgetMouseEvent(false, 0, nullptr,
WidgetMouseEvent::eReal))
@ -46,22 +46,6 @@ nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMMouseEvent::~nsDOMMouseEvent()
{
if (mEventIsInternal && mEvent) {
switch (mEvent->eventStructType)
{
case NS_MOUSE_EVENT:
delete static_cast<WidgetMouseEvent*>(mEvent);
break;
default:
delete mEvent;
break;
}
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
@ -79,29 +63,26 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool a
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
switch(mEvent->eventStructType)
{
switch(mEvent->eventStructType) {
case NS_MOUSE_EVENT:
case NS_MOUSE_SCROLL_EVENT:
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
{
static_cast<WidgetMouseEventBase*>(mEvent)->relatedTarget =
aRelatedTarget;
static_cast<WidgetMouseEventBase*>(mEvent)->button = aButton;
WidgetInputEvent* inputEvent = static_cast<WidgetInputEvent*>(mEvent);
inputEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
mClientPoint.x = aClientX;
mClientPoint.y = aClientY;
inputEvent->refPoint.x = aScreenX;
inputEvent->refPoint.y = aScreenY;
case NS_SIMPLE_GESTURE_EVENT: {
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
mouseEventBase->relatedTarget = aRelatedTarget;
mouseEventBase->button = aButton;
mouseEventBase->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
mClientPoint.x = aClientX;
mClientPoint.y = aClientY;
mouseEventBase->refPoint.x = aScreenX;
mouseEventBase->refPoint.y = aScreenY;
if (mEvent->eventStructType == NS_MOUSE_EVENT) {
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(mEvent);
mouseEvent->clickCount = aDetail;
}
break;
if (mEvent->eventStructType == NS_MOUSE_EVENT) {
WidgetMouseEvent* mouseEvent = static_cast<WidgetMouseEvent*>(mEvent);
mouseEvent->clickCount = aDetail;
}
break;
}
default:
break;
@ -141,7 +122,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString& aType,
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
static_cast<WidgetInputEvent*>(mEvent)->modifiers = modifiers;
mEvent->AsInputEvent()->modifiers = modifiers;
return NS_OK;
default:
MOZ_CRASH("There is no space to store the modifiers");
@ -171,7 +152,7 @@ nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
static_cast<WidgetMouseEventBase*>(e->mEvent)->buttons = aParam.mButtons;
e->mEvent->AsMouseEventBase()->buttons = aParam.mButtons;
break;
default:
break;
@ -194,8 +175,9 @@ nsDOMMouseEvent::InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool
aMetaKey, aButton, aRelatedTarget);
NS_ENSURE_SUCCESS(rv, rv);
static_cast<WidgetMouseEventBase*>(mEvent)->pressure = aPressure;
static_cast<WidgetMouseEventBase*>(mEvent)->inputSource = aInputSource;
WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
mouseEventBase->pressure = aPressure;
mouseEventBase->inputSource = aInputSource;
return NS_OK;
}
@ -217,7 +199,7 @@ nsDOMMouseEvent::Button()
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
return static_cast<WidgetMouseEventBase*>(mEvent)->button;
return mEvent->AsMouseEventBase()->button;
default:
NS_WARNING("Tried to get mouse button for non-mouse event!");
return WidgetMouseEvent::eLeftButton;
@ -242,7 +224,7 @@ nsDOMMouseEvent::Buttons()
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
return static_cast<WidgetMouseEventBase*>(mEvent)->buttons;
return mEvent->AsMouseEventBase()->buttons;
default:
MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
}
@ -267,8 +249,8 @@ nsDOMMouseEvent::GetRelatedTarget()
case NS_WHEEL_EVENT:
case NS_DRAG_EVENT:
case NS_SIMPLE_GESTURE_EVENT:
relatedTarget = do_QueryInterface(
static_cast<WidgetMouseEventBase*>(mEvent)->relatedTarget);
relatedTarget =
do_QueryInterface(mEvent->AsMouseEventBase()->relatedTarget);
break;
default:
break;
@ -372,6 +354,12 @@ nsDOMMouseEvent::ClientY()
mClientPoint).y;
}
bool
nsDOMMouseEvent::AltKey()
{
return mEvent->AsInputEvent()->IsAlt();
}
NS_IMETHODIMP
nsDOMMouseEvent::GetAltKey(bool* aIsDown)
{
@ -380,6 +368,12 @@ nsDOMMouseEvent::GetAltKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMMouseEvent::CtrlKey()
{
return mEvent->AsInputEvent()->IsControl();
}
NS_IMETHODIMP
nsDOMMouseEvent::GetCtrlKey(bool* aIsDown)
{
@ -388,6 +382,12 @@ nsDOMMouseEvent::GetCtrlKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMMouseEvent::ShiftKey()
{
return mEvent->AsInputEvent()->IsShift();
}
NS_IMETHODIMP
nsDOMMouseEvent::GetShiftKey(bool* aIsDown)
{
@ -396,6 +396,12 @@ nsDOMMouseEvent::GetShiftKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMMouseEvent::MetaKey()
{
return mEvent->AsInputEvent()->IsMeta();
}
NS_IMETHODIMP
nsDOMMouseEvent::GetMetaKey(bool* aIsDown)
{
@ -414,6 +420,12 @@ nsDOMMouseEvent::GetModifierState(const nsAString& aKey,
return NS_OK;
}
float
nsDOMMouseEvent::MozPressure() const
{
return mEvent->AsMouseEventBase()->pressure;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetMozPressure(float* aPressure)
{
@ -422,6 +434,12 @@ nsDOMMouseEvent::GetMozPressure(float* aPressure)
return NS_OK;
}
uint16_t
nsDOMMouseEvent::MozInputSource() const
{
return mEvent->AsMouseEventBase()->inputSource;
}
NS_IMETHODIMP
nsDOMMouseEvent::GetMozInputSource(uint16_t* aInputSource)
{
@ -433,7 +451,7 @@ nsDOMMouseEvent::GetMozInputSource(uint16_t* aInputSource)
nsresult NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
WidgetMouseEvent* aEvent)
{
nsDOMMouseEvent* it = new nsDOMMouseEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);

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

@ -9,7 +9,7 @@
#include "nsIDOMMouseEvent.h"
#include "nsDOMUIEvent.h"
#include "mozilla/dom/MouseEventBinding.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/EventForwards.h"
class nsDOMMouseEvent : public nsDOMUIEvent,
public nsIDOMMouseEvent
@ -17,8 +17,7 @@ class nsDOMMouseEvent : public nsDOMUIEvent,
public:
nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetInputEvent* aEvent);
virtual ~nsDOMMouseEvent();
mozilla::WidgetMouseEventBase* aEvent);
NS_DECL_ISUPPORTS_INHERITED
@ -44,22 +43,10 @@ public:
int32_t ScreenY();
int32_t ClientX();
int32_t ClientY();
bool CtrlKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsControl();
}
bool ShiftKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsShift();
}
bool AltKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsAlt();
}
bool MetaKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsMeta();
}
bool CtrlKey();
bool ShiftKey();
bool AltKey();
bool MetaKey();
uint16_t Button();
uint16_t Buttons();
already_AddRefed<mozilla::dom::EventTarget> GetRelatedTarget();
@ -93,14 +80,8 @@ public:
{
return GetMovementPoint().y;
}
float MozPressure() const
{
return static_cast<mozilla::WidgetMouseEventBase*>(mEvent)->pressure;
}
uint16_t MozInputSource() const
{
return static_cast<mozilla::WidgetMouseEventBase*>(mEvent)->inputSource;
}
float MozPressure() const;
uint16_t MozInputSource() const;
void InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX,
int32_t aScreenY, int32_t aClientX, int32_t aClientY,

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

@ -11,7 +11,7 @@ using namespace mozilla;
nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
WidgetMouseScrollEvent* aEvent)
: nsDOMMouseEvent(aOwner, aPresContext,
aEvent ? aEvent :
new WidgetMouseScrollEvent(false, 0, nullptr))
@ -26,25 +26,7 @@ nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
}
if(mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
mDetail = static_cast<WidgetMouseScrollEvent*>(mEvent)->delta;
}
}
nsDOMMouseScrollEvent::~nsDOMMouseScrollEvent()
{
if (mEventIsInternal && mEvent) {
switch (mEvent->eventStructType)
{
case NS_MOUSE_SCROLL_EVENT:
delete static_cast<WidgetMouseScrollEvent*>(mEvent);
break;
default:
delete mEvent;
break;
}
mEvent = nullptr;
}
mDetail = mEvent->AsMouseScrollEvent()->delta;
}
NS_IMPL_ADDREF_INHERITED(nsDOMMouseScrollEvent, nsDOMMouseEvent)
@ -66,12 +48,7 @@ nsDOMMouseScrollEvent::InitMouseScrollEvent(const nsAString & aType, bool aCanBu
aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
aAltKey, aShiftKey, aMetaKey, aButton, aRelatedTarget);
NS_ENSURE_SUCCESS(rv, rv);
if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
static_cast<WidgetMouseScrollEvent*>(mEvent)->isHorizontal =
(aAxis == HORIZONTAL_AXIS);
}
mEvent->AsMouseScrollEvent()->isHorizontal = (aAxis == HORIZONTAL_AXIS);
return NS_OK;
}
@ -87,18 +64,15 @@ nsDOMMouseScrollEvent::GetAxis(int32_t* aResult)
int32_t
nsDOMMouseScrollEvent::Axis()
{
if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) {
return static_cast<WidgetMouseScrollEvent*>(mEvent)->isHorizontal ?
static_cast<int32_t>(HORIZONTAL_AXIS) :
static_cast<int32_t>(VERTICAL_AXIS);
}
return 0;
return mEvent->AsMouseScrollEvent()->isHorizontal ?
static_cast<int32_t>(HORIZONTAL_AXIS) :
static_cast<int32_t>(VERTICAL_AXIS);
}
nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
WidgetInputEvent* aEvent)
WidgetMouseScrollEvent* aEvent)
{
nsDOMMouseScrollEvent* it =
new nsDOMMouseScrollEvent(aOwner, aPresContext, aEvent);

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

@ -16,8 +16,7 @@ class nsDOMMouseScrollEvent : public nsDOMMouseEvent,
public:
nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetInputEvent* aEvent);
virtual ~nsDOMMouseScrollEvent();
mozilla::WidgetMouseScrollEvent* aEvent);
NS_DECL_ISUPPORTS_INHERITED

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

@ -20,16 +20,6 @@ nsDOMMutationEvent::nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
mEventIsInternal = (aEvent == nullptr);
}
nsDOMMutationEvent::~nsDOMMutationEvent()
{
if (mEventIsInternal) {
InternalMutationEvent* mutation =
static_cast<InternalMutationEvent*>(mEvent);
delete mutation;
mEvent = nullptr;
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMMutationEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMMutationEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -40,8 +30,8 @@ NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
already_AddRefed<nsINode>
nsDOMMutationEvent::GetRelatedNode()
{
nsCOMPtr<nsINode> n = do_QueryInterface(
static_cast<InternalMutationEvent*>(mEvent)->mRelatedNode);
nsCOMPtr<nsINode> n =
do_QueryInterface(mEvent->AsMutationEvent()->mRelatedNode);
return n.forget();
}
@ -57,7 +47,7 @@ nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
NS_IMETHODIMP
nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
{
InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
if (mutation->mPrevAttrValue)
mutation->mPrevAttrValue->ToString(aPrevValue);
return NS_OK;
@ -66,7 +56,7 @@ nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
NS_IMETHODIMP
nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
{
InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
if (mutation->mNewAttrValue)
mutation->mNewAttrValue->ToString(aNewValue);
return NS_OK;
@ -75,7 +65,7 @@ nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
NS_IMETHODIMP
nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
{
InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
if (mutation->mAttrName)
mutation->mAttrName->ToString(aAttrName);
return NS_OK;
@ -84,7 +74,7 @@ nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
uint16_t
nsDOMMutationEvent::AttrChange()
{
return static_cast<InternalMutationEvent*>(mEvent)->mAttrChange;
return mEvent->AsMutationEvent()->mAttrChange;
}
NS_IMETHODIMP
@ -99,8 +89,8 @@ nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, bool aCanBubble
{
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
InternalMutationEvent* mutation = mEvent->AsMutationEvent();
mutation->mRelatedNode = aRelatedNodeArg;
if (!aPrevValueArg.IsEmpty())
mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);

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

@ -20,8 +20,6 @@ public:
nsPresContext* aPresContext,
mozilla::InternalMutationEvent* aEvent);
virtual ~nsDOMMutationEvent();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMMUTATIONEVENT

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

@ -21,16 +21,6 @@ nsDOMScrollAreaEvent::nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
mClientArea.SetLayoutRect(aEvent ? aEvent->mArea : nsRect());
}
nsDOMScrollAreaEvent::~nsDOMScrollAreaEvent()
{
if (mEventIsInternal && mEvent) {
if (mEvent->eventStructType == NS_SCROLLAREA_EVENT) {
delete static_cast<InternalScrollAreaEvent*>(mEvent);
mEvent = nullptr;
}
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMScrollAreaEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMScrollAreaEvent, nsDOMUIEvent)

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

@ -23,7 +23,6 @@ public:
nsDOMScrollAreaEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
mozilla::InternalScrollAreaEvent* aEvent);
virtual ~nsDOMScrollAreaEvent();
NS_DECL_ISUPPORTS_INHERITED

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

@ -30,14 +30,6 @@ nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwn
}
}
nsDOMSimpleGestureEvent::~nsDOMSimpleGestureEvent()
{
if (mEventIsInternal) {
delete static_cast<WidgetSimpleGestureEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
@ -46,24 +38,34 @@ NS_INTERFACE_MAP_BEGIN(nsDOMSimpleGestureEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
/* attribute unsigned long allowedDirections; */
uint32_t
nsDOMSimpleGestureEvent::AllowedDirections()
{
return mEvent->AsSimpleGestureEvent()->allowedDirections;
}
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetAllowedDirections(uint32_t *aAllowedDirections)
{
NS_ENSURE_ARG_POINTER(aAllowedDirections);
*aAllowedDirections =
static_cast<WidgetSimpleGestureEvent*>(mEvent)->allowedDirections;
*aAllowedDirections = AllowedDirections();
return NS_OK;
}
NS_IMETHODIMP
nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
{
static_cast<WidgetSimpleGestureEvent*>(mEvent)->allowedDirections =
aAllowedDirections;
mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
return NS_OK;
}
/* readonly attribute unsigned long direction; */
uint32_t
nsDOMSimpleGestureEvent::Direction()
{
return mEvent->AsSimpleGestureEvent()->direction;
}
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection)
{
@ -73,6 +75,12 @@ nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection)
}
/* readonly attribute float delta; */
double
nsDOMSimpleGestureEvent::Delta()
{
return mEvent->AsSimpleGestureEvent()->delta;
}
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
{
@ -82,6 +90,12 @@ nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
}
/* readonly attribute unsigned long clickCount; */
uint32_t
nsDOMSimpleGestureEvent::ClickCount()
{
return mEvent->AsSimpleGestureEvent()->clickCount;
}
NS_IMETHODIMP
nsDOMSimpleGestureEvent::GetClickCount(uint32_t *aClickCount)
{
@ -128,8 +142,7 @@ nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
aRelatedTarget);
NS_ENSURE_SUCCESS(rv, rv);
WidgetSimpleGestureEvent* simpleGestureEvent =
static_cast<WidgetSimpleGestureEvent*>(mEvent);
WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
simpleGestureEvent->direction = aDirectionArg;
simpleGestureEvent->delta = aDeltaArg;

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

@ -7,7 +7,7 @@
#include "nsIDOMSimpleGestureEvent.h"
#include "nsDOMMouseEvent.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/SimpleGestureEventBinding.h"
class nsPresContext;
@ -18,7 +18,6 @@ class nsDOMSimpleGestureEvent : public nsDOMMouseEvent,
public:
nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext*, mozilla::WidgetSimpleGestureEvent*);
virtual ~nsDOMSimpleGestureEvent();
NS_DECL_ISUPPORTS_INHERITED
@ -33,26 +32,10 @@ public:
return mozilla::dom::SimpleGestureEventBinding::Wrap(aCx, aScope, this);
}
uint32_t AllowedDirections()
{
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->
allowedDirections;
}
uint32_t Direction()
{
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->direction;
}
double Delta()
{
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->delta;
}
uint32_t ClickCount()
{
return static_cast<mozilla::WidgetSimpleGestureEvent*>(mEvent)->clickCount;
}
uint32_t AllowedDirections();
uint32_t Direction();
double Delta();
uint32_t ClickCount();
void InitSimpleGestureEvent(const nsAString& aType,
bool aCanBubble,

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

@ -30,7 +30,7 @@ nsDOMTextEvent::nsDOMTextEvent(mozilla::dom::EventTarget* aOwner,
//
// extract the IME composition string
//
WidgetTextEvent *te = static_cast<WidgetTextEvent*>(mEvent);
WidgetTextEvent* te = mEvent->AsTextEvent();
mText = te->theText;
//

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

@ -71,14 +71,6 @@ nsDOMTouchEvent::nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMTouchEvent::~nsDOMTouchEvent()
{
if (mEventIsInternal && mEvent) {
delete static_cast<WidgetTouchEvent*>(mEvent);
mEvent = nullptr;
}
}
NS_IMPL_CYCLE_COLLECTION_INHERITED_3(nsDOMTouchEvent, nsDOMUIEvent,
mTouches,
mTargetTouches,
@ -115,8 +107,8 @@ nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
return;
}
static_cast<WidgetInputEvent*>(mEvent)->
InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mTouches = aTouches;
mTargetTouches = aTargetTouches;
mChangedTouches = aChangedTouches;
@ -126,7 +118,7 @@ nsDOMTouchList*
nsDOMTouchEvent::Touches()
{
if (!mTouches) {
WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(mEvent);
WidgetTouchEvent* touchEvent = mEvent->AsTouchEvent();
if (mEvent->message == NS_TOUCH_END || mEvent->message == NS_TOUCH_CANCEL) {
// for touchend events, remove any changed touches from the touches array
nsTArray< nsRefPtr<Touch> > unchangedTouches;
@ -149,7 +141,7 @@ nsDOMTouchEvent::TargetTouches()
{
if (!mTargetTouches) {
nsTArray< nsRefPtr<Touch> > targetTouches;
WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(mEvent);
WidgetTouchEvent* touchEvent = mEvent->AsTouchEvent();
const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
// for touchend/cancel events, don't append to the target list if this is a
@ -171,7 +163,7 @@ nsDOMTouchEvent::ChangedTouches()
{
if (!mChangedTouches) {
nsTArray< nsRefPtr<Touch> > changedTouches;
WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(mEvent);
WidgetTouchEvent* touchEvent = mEvent->AsTouchEvent();
const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
if (touches[i]->mChanged) {
@ -221,6 +213,30 @@ nsDOMTouchEvent::PrefEnabled()
return prefValue;
}
bool
nsDOMTouchEvent::AltKey()
{
return mEvent->AsTouchEvent()->IsAlt();
}
bool
nsDOMTouchEvent::MetaKey()
{
return mEvent->AsTouchEvent()->IsMeta();
}
bool
nsDOMTouchEvent::CtrlKey()
{
return mEvent->AsTouchEvent()->IsControl();
}
bool
nsDOMTouchEvent::ShiftKey()
{
return mEvent->AsTouchEvent()->IsShift();
}
nsresult
NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,

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

@ -8,8 +8,9 @@
#include "nsDOMUIEvent.h"
#include "nsTArray.h"
#include "mozilla/Attributes.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/EventForwards.h"
#include "nsJSEnvironment.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/TouchEventBinding.h"
#include "nsWrapperCache.h"
@ -84,7 +85,6 @@ public:
nsDOMTouchEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetTouchEvent* aEvent);
virtual ~nsDOMTouchEvent();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
@ -99,25 +99,10 @@ public:
nsDOMTouchList* TargetTouches();
nsDOMTouchList* ChangedTouches();
bool AltKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsAlt();
}
bool MetaKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsMeta();
}
bool CtrlKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsControl();
}
bool ShiftKey()
{
return static_cast<mozilla::WidgetInputEvent*>(mEvent)->IsShift();
}
bool AltKey();
bool MetaKey();
bool CtrlKey();
bool ShiftKey();
void InitTouchEvent(const nsAString& aType,
bool aCanBubble,

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

@ -26,14 +26,6 @@ nsDOMTransitionEvent::nsDOMTransitionEvent(mozilla::dom::EventTarget* aOwner,
}
}
nsDOMTransitionEvent::~nsDOMTransitionEvent()
{
if (mEventIsInternal) {
delete TransitionEvent();
mEvent = nullptr;
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMTransitionEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMTransitionEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
@ -54,9 +46,10 @@ nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
e->TransitionEvent()->propertyName = aParam.mPropertyName;
e->TransitionEvent()->elapsedTime = aParam.mElapsedTime;
e->TransitionEvent()->pseudoElement = aParam.mPseudoElement;
InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent();
internalEvent->propertyName = aParam.mPropertyName;
internalEvent->elapsedTime = aParam.mElapsedTime;
internalEvent->pseudoElement = aParam.mPseudoElement;
e->SetTrusted(trusted);
return e.forget();
@ -65,7 +58,7 @@ nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
NS_IMETHODIMP
nsDOMTransitionEvent::GetPropertyName(nsAString & aPropertyName)
{
aPropertyName = TransitionEvent()->propertyName;
aPropertyName = mEvent->AsTransitionEvent()->propertyName;
return NS_OK;
}
@ -76,10 +69,16 @@ nsDOMTransitionEvent::GetElapsedTime(float *aElapsedTime)
return NS_OK;
}
float
nsDOMTransitionEvent::ElapsedTime()
{
return mEvent->AsTransitionEvent()->elapsedTime;
}
NS_IMETHODIMP
nsDOMTransitionEvent::GetPseudoElement(nsAString& aPseudoElement)
{
aPseudoElement = TransitionEvent()->pseudoElement;
aPseudoElement = mEvent->AsTransitionEvent()->pseudoElement;
return NS_OK;
}

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

@ -7,7 +7,7 @@
#include "nsDOMEvent.h"
#include "nsIDOMTransitionEvent.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/EventForwards.h"
#include "mozilla/dom/TransitionEventBinding.h"
class nsAString;
@ -19,7 +19,6 @@ public:
nsDOMTransitionEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
mozilla::InternalTransitionEvent* aEvent);
~nsDOMTransitionEvent();
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_TO_NSDOMEVENT
@ -41,17 +40,7 @@ public:
// GetPropertyName(nsAString& aPropertyName)
// GetPseudoElement(nsAString& aPreudoElement)
float ElapsedTime()
{
return TransitionEvent()->elapsedTime;
}
private:
mozilla::InternalTransitionEvent* TransitionEvent() {
NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_TRANSITION_EVENT,
"unexpected struct type");
return static_cast<mozilla::InternalTransitionEvent*>(mEvent);
}
float ElapsedTime();
};
#endif /* !defined(nsDOMTransitionEvent_h_) */

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

@ -44,15 +44,13 @@ nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner,
{
case NS_UI_EVENT:
{
InternalUIEvent *event = static_cast<InternalUIEvent*>(mEvent);
mDetail = event->detail;
mDetail = mEvent->AsUIEvent()->detail;
break;
}
case NS_SCROLLPORT_EVENT:
{
InternalScrollPortEvent* scrollEvent =
static_cast<InternalScrollPortEvent*>(mEvent);
InternalScrollPortEvent* scrollEvent = mEvent->AsScrollPortEvent();
mDetail = (int32_t)scrollEvent->orient;
break;
}
@ -345,16 +343,12 @@ nsDOMUIEvent::GetIsChar(bool* aIsChar)
bool
nsDOMUIEvent::IsChar() const
{
switch (mEvent->eventStructType)
{
case NS_KEY_EVENT:
return static_cast<WidgetKeyboardEvent*>(mEvent)->isChar;
case NS_TEXT_EVENT:
return static_cast<WidgetTextEvent*>(mEvent)->isChar;
default:
return false;
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
if (keyEvent) {
return keyEvent->isChar;
}
MOZ_CRASH("Switch handles all cases.");
WidgetTextEvent* textEvent = mEvent->AsTextEvent();
return textEvent ? textEvent->isChar : false;
}
NS_IMETHODIMP
@ -462,10 +456,8 @@ nsDOMUIEvent::ComputeModifierState(const nsAString& aModifiersList)
bool
nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey)
{
if (!mEvent->IsInputDerivedEvent()) {
MOZ_CRASH("mEvent must be WidgetInputEvent or derived class");
}
WidgetInputEvent* inputEvent = static_cast<WidgetInputEvent*>(mEvent);
WidgetInputEvent* inputEvent = mEvent->AsInputEvent();
MOZ_ASSERT(inputEvent, "mEvent must be WidgetInputEvent or derived class");
if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) {
return inputEvent->IsShift();
}

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

@ -34,6 +34,12 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMXULCommandEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
bool
nsDOMXULCommandEvent::AltKey()
{
return mEvent->AsInputEvent()->IsAlt();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetAltKey(bool* aIsDown)
{
@ -42,6 +48,12 @@ nsDOMXULCommandEvent::GetAltKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMXULCommandEvent::CtrlKey()
{
return mEvent->AsInputEvent()->IsControl();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetCtrlKey(bool* aIsDown)
{
@ -50,6 +62,12 @@ nsDOMXULCommandEvent::GetCtrlKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMXULCommandEvent::ShiftKey()
{
return mEvent->AsInputEvent()->IsShift();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetShiftKey(bool* aIsDown)
{
@ -58,6 +76,12 @@ nsDOMXULCommandEvent::GetShiftKey(bool* aIsDown)
return NS_OK;
}
bool
nsDOMXULCommandEvent::MetaKey()
{
return mEvent->AsInputEvent()->IsMeta();
}
NS_IMETHODIMP
nsDOMXULCommandEvent::GetMetaKey(bool* aIsDown)
{
@ -87,7 +111,8 @@ nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
aView, aDetail);
NS_ENSURE_SUCCESS(rv, rv);
Event()->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
aShiftKey, aMetaKey);
mSourceEvent = aSourceEvent;
return NS_OK;

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

@ -34,25 +34,10 @@ public:
return mozilla::dom::XULCommandEventBinding::Wrap(aCx, aScope, this);
}
bool AltKey()
{
return Event()->IsAlt();
}
bool CtrlKey()
{
return Event()->IsControl();
}
bool ShiftKey()
{
return Event()->IsShift();
}
bool MetaKey()
{
return Event()->IsMeta();
}
bool AltKey();
bool CtrlKey();
bool ShiftKey();
bool MetaKey();
already_AddRefed<nsDOMEvent> GetSourceEvent()
{
@ -76,11 +61,6 @@ public:
}
protected:
// Convenience accessor for the event
mozilla::WidgetInputEvent* Event() {
return static_cast<mozilla::WidgetInputEvent*>(mEvent);
}
nsCOMPtr<nsIDOMEvent> mSourceEvent;
};

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

@ -692,7 +692,7 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
switch(aEvent->eventStructType) {
case NS_MUTATION_EVENT:
return NS_NewDOMMutationEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalMutationEvent*>(aEvent));
aEvent->AsMutationEvent());
case NS_GUI_EVENT:
case NS_SCROLLPORT_EVENT:
case NS_UI_EVENT:
@ -700,35 +700,34 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
static_cast<WidgetGUIEvent*>(aEvent));
case NS_SCROLLAREA_EVENT:
return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalScrollAreaEvent*>(aEvent));
aEvent->AsScrollAreaEvent());
case NS_KEY_EVENT:
return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetKeyboardEvent*>(aEvent));
aEvent->AsKeyboardEvent());
case NS_COMPOSITION_EVENT:
return NS_NewDOMCompositionEvent(
aDOMEvent, aOwner,
aPresContext, static_cast<WidgetCompositionEvent*>(aEvent));
return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext,
aEvent->AsCompositionEvent());
case NS_MOUSE_EVENT:
return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetInputEvent*>(aEvent));
aEvent->AsMouseEvent());
case NS_FOCUS_EVENT:
return NS_NewDOMFocusEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalFocusEvent*>(aEvent));
aEvent->AsFocusEvent());
case NS_MOUSE_SCROLL_EVENT:
return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetInputEvent*>(aEvent));
aEvent->AsMouseScrollEvent());
case NS_WHEEL_EVENT:
return NS_NewDOMWheelEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetWheelEvent*>(aEvent));
case NS_DRAG_EVENT:
return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetDragEvent*>(aEvent));
aEvent->AsDragEvent());
case NS_TEXT_EVENT:
return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetTextEvent*>(aEvent));
aEvent->AsTextEvent());
case NS_CLIPBOARD_EVENT:
return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalClipboardEvent*>(aEvent));
aEvent->AsClipboardEvent());
case NS_SVGZOOM_EVENT:
return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetGUIEvent*>(aEvent));
@ -737,19 +736,19 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner,
case NS_COMMAND_EVENT:
return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetCommandEvent*>(aEvent));
aEvent->AsCommandEvent());
case NS_SIMPLE_GESTURE_EVENT:
return NS_NewDOMSimpleGestureEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetSimpleGestureEvent*>(aEvent));
aEvent->AsSimpleGestureEvent());
case NS_TOUCH_EVENT:
return NS_NewDOMTouchEvent(aDOMEvent, aOwner, aPresContext,
static_cast<WidgetTouchEvent*>(aEvent));
aEvent->AsTouchEvent());
case NS_TRANSITION_EVENT:
return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalTransitionEvent*>(aEvent));
aEvent->AsTransitionEvent());
case NS_ANIMATION_EVENT:
return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext,
static_cast<InternalAnimationEvent*>(aEvent));
aEvent->AsAnimationEvent());
default:
// For all other types of events, create a vanilla event object.
return NS_NewDOMEvent(aDOMEvent, aOwner, aPresContext, aEvent);

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

@ -1145,8 +1145,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case NS_KEY_PRESS:
{
WidgetKeyboardEvent* keyEvent = static_cast<WidgetKeyboardEvent*>(aEvent);
WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
int32_t modifierMask = 0;
if (keyEvent->IsShift())
@ -1210,72 +1209,68 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
}
break;
case NS_QUERY_SELECTED_TEXT:
DoQuerySelectedText(static_cast<WidgetQueryContentEvent*>(aEvent));
DoQuerySelectedText(aEvent->AsQueryContentEvent());
break;
case NS_QUERY_TEXT_CONTENT:
{
if (RemoteQueryContentEvent(aEvent))
break;
nsContentEventHandler handler(mPresContext);
handler.OnQueryTextContent(static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryTextContent(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_CARET_RECT:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQueryCaretRect(static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryCaretRect(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_TEXT_RECT:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQueryTextRect(static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryTextRect(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_EDITOR_RECT:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQueryEditorRect(static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryEditorRect(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_CONTENT_STATE:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQueryContentState(static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryContentState(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_SELECTION_AS_TRANSFERABLE:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQuerySelectionAsTransferable(
static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQuerySelectionAsTransferable(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_CHARACTER_AT_POINT:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQueryCharacterAtPoint(
static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryCharacterAtPoint(aEvent->AsQueryContentEvent());
}
break;
case NS_QUERY_DOM_WIDGET_HITTEST:
{
// XXX remote event
nsContentEventHandler handler(mPresContext);
handler.OnQueryDOMWidgetHittest(
static_cast<WidgetQueryContentEvent*>(aEvent));
handler.OnQueryDOMWidgetHittest(aEvent->AsQueryContentEvent());
}
break;
case NS_SELECTION_SET:
{
WidgetSelectionEvent *selectionEvent =
static_cast<WidgetSelectionEvent*>(aEvent);
WidgetSelectionEvent* selectionEvent = aEvent->AsSelectionEvent();
if (IsTargetCrossProcess(selectionEvent)) {
// Will not be handled locally, remote the event
if (GetCrossProcessTarget()->SendSelectionEvent(*selectionEvent))
@ -1283,7 +1278,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
break;
}
nsContentEventHandler handler(mPresContext);
handler.OnSelectionEvent(static_cast<WidgetSelectionEvent*>(aEvent));
handler.OnSelectionEvent(selectionEvent);
}
break;
case NS_CONTENT_COMMAND_CUT:
@ -1294,18 +1289,17 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case NS_CONTENT_COMMAND_REDO:
case NS_CONTENT_COMMAND_PASTE_TRANSFERABLE:
{
DoContentCommandEvent(static_cast<WidgetContentCommandEvent*>(aEvent));
DoContentCommandEvent(aEvent->AsContentCommandEvent());
}
break;
case NS_CONTENT_COMMAND_SCROLL:
{
DoContentCommandScrollEvent(
static_cast<WidgetContentCommandEvent*>(aEvent));
DoContentCommandScrollEvent(aEvent->AsContentCommandEvent());
}
break;
case NS_TEXT_TEXT:
{
WidgetTextEvent *textEvent = static_cast<WidgetTextEvent*>(aEvent);
WidgetTextEvent *textEvent = aEvent->AsTextEvent();
if (IsTargetCrossProcess(textEvent)) {
// Will not be handled locally, remote the event
if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) {
@ -1319,8 +1313,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
if (aEvent->mFlags.mIsTrusted) {
// If the event is trusted event, set the selected text to data of
// composition event.
WidgetCompositionEvent *compositionEvent =
static_cast<WidgetCompositionEvent*>(aEvent);
WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT,
compositionEvent->widget);
DoQuerySelectedText(&selectedText);
@ -1331,8 +1324,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
case NS_COMPOSITION_UPDATE:
case NS_COMPOSITION_END:
{
WidgetCompositionEvent *compositionEvent =
static_cast<WidgetCompositionEvent*>(aEvent);
WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
if (IsTargetCrossProcess(compositionEvent)) {
// Will not be handled locally, remote the event
if (GetCrossProcessTarget()->SendCompositionEvent(*compositionEvent)) {
@ -1609,8 +1601,7 @@ nsEventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
return remote->SendRealMouseEvent(*mouseEvent);
}
case NS_KEY_EVENT: {
WidgetKeyboardEvent* keyEvent = static_cast<WidgetKeyboardEvent*>(aEvent);
return remote->SendRealKeyEvent(*keyEvent);
return remote->SendRealKeyEvent(*aEvent->AsKeyboardEvent());
}
case NS_WHEEL_EVENT: {
WidgetWheelEvent* wheelEvent = static_cast<WidgetWheelEvent*>(aEvent);
@ -1620,8 +1611,7 @@ nsEventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
// Let the child process synthesize a mouse event if needed, and
// ensure we don't synthesize one in this process.
*aStatus = nsEventStatus_eConsumeNoDefault;
WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
return remote->SendRealTouchEvent(*touchEvent);
return remote->SendRealTouchEvent(*aEvent->AsTouchEvent());
}
default: {
MOZ_CRASH("Attempt to send non-whitelisted event?");
@ -1737,8 +1727,8 @@ nsEventStateManager::HandleCrossProcessEvent(WidgetEvent* aEvent,
//
// This loop is similar to the one used in
// PresShell::DispatchTouchEvent().
WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
const nsTArray< nsRefPtr<Touch> >& touches =
aEvent->AsTouchEvent()->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
Touch* touch = touches[i];
// NB: the |mChanged| check is an optimization, subprocesses can
@ -3483,9 +3473,9 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
case NS_GESTURENOTIFY_EVENT_START:
{
if (nsEventStatus_eConsumeNoDefault != *aStatus)
DecideGestureEvent(static_cast<WidgetGestureNotifyEvent*>(aEvent),
mCurrentTarget);
if (nsEventStatus_eConsumeNoDefault != *aStatus) {
DecideGestureEvent(aEvent->AsGestureNotifyEvent(), mCurrentTarget);
}
}
break;
@ -3511,7 +3501,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
WidgetDragEvent *dragEvent = static_cast<WidgetDragEvent*>(aEvent);
WidgetDragEvent *dragEvent = aEvent->AsDragEvent();
// collect any changes to moz cursor settings stored in the event's
// data transfer.
@ -3642,7 +3632,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
case NS_KEY_PRESS:
if (nsEventStatus_eConsumeNoDefault != *aStatus) {
WidgetKeyboardEvent* keyEvent = static_cast<WidgetKeyboardEvent*>(aEvent);
WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
//This is to prevent keyboard scrolling while alt modifier in use.
if (!keyEvent->IsAlt()) {
switch(keyEvent->keyCode) {
@ -3709,8 +3699,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
bool
nsEventStateManager::RemoteQueryContentEvent(WidgetEvent* aEvent)
{
WidgetQueryContentEvent *queryEvent =
static_cast<WidgetQueryContentEvent*>(aEvent);
WidgetQueryContentEvent* queryEvent = aEvent->AsQueryContentEvent();
if (!IsTargetCrossProcess(queryEvent)) {
return false;
}

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

@ -260,8 +260,7 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
{
// For backwards compat, trigger buttons with space or enter
// (bug 25300)
WidgetKeyboardEvent* keyEvent =
static_cast<WidgetKeyboardEvent*>(aVisitor.mEvent);
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
if ((keyEvent->keyCode == NS_VK_RETURN &&
NS_KEY_PRESS == aVisitor.mEvent->message) ||
(keyEvent->keyCode == NS_VK_SPACE &&

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

@ -686,16 +686,14 @@ HTMLFormElement::BuildSubmission(nsFormSubmission** aFormSubmission,
// Get the originating frame (failure is non-fatal)
nsGenericHTMLElement* originatingElement = nullptr;
if (aEvent) {
if (NS_FORM_EVENT == aEvent->eventStructType) {
nsIContent* originator =
static_cast<InternalFormEvent*>(aEvent)->originator;
InternalFormEvent* formEvent = aEvent->AsFormEvent();
if (formEvent) {
nsIContent* originator = formEvent->originator;
if (originator) {
if (!originator->IsHTML()) {
return NS_ERROR_UNEXPECTED;
}
originatingElement =
static_cast<nsGenericHTMLElement*>(
static_cast<InternalFormEvent*>(aEvent)->originator);
originatingElement = static_cast<nsGenericHTMLElement*>(originator);
}
}
}

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

@ -3487,7 +3487,7 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
// just because we raised a window.
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (fm && IsSingleLineTextControl(false) &&
!(static_cast<InternalFocusEvent*>(aVisitor.mEvent))->fromRaise &&
!aVisitor.mEvent->AsFocusEvent()->fromRaise &&
SelectTextFieldOnFocus()) {
nsIDocument* document = GetCurrentDoc();
if (document) {
@ -3510,9 +3510,7 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
{
// For backwards compat, trigger checks/radios/buttons with
// space or enter (bug 25300)
WidgetKeyboardEvent* keyEvent =
static_cast<WidgetKeyboardEvent*>(aVisitor.mEvent);
WidgetKeyboardEvent* keyEvent = aVisitor.mEvent->AsKeyboardEvent();
if ((aVisitor.mEvent->message == NS_KEY_PRESS &&
keyEvent->keyCode == NS_VK_RETURN) ||
(aVisitor.mEvent->message == NS_KEY_UP &&
@ -3791,8 +3789,7 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor
if (nsIPresShell::GetCapturingContent()) {
break; // don't start drag if someone else is already capturing
}
WidgetInputEvent* inputEvent =
static_cast<WidgetInputEvent*>(aVisitor.mEvent);
WidgetInputEvent* inputEvent = aVisitor.mEvent->AsInputEvent();
if (inputEvent->IsShift() || inputEvent->IsControl() ||
inputEvent->IsAlt() || inputEvent->IsMeta() ||
inputEvent->IsAltGraph() || inputEvent->IsFn() ||
@ -3808,9 +3805,7 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor
CancelRangeThumbDrag();
}
} else {
WidgetTouchEvent* touchEvent =
static_cast<WidgetTouchEvent*>(aVisitor.mEvent);
if (touchEvent->touches.Length() == 1) {
if (aVisitor.mEvent->AsTouchEvent()->touches.Length() == 1) {
StartRangeThumbDrag(inputEvent);
} else if (mIsDraggingRange) {
CancelRangeThumbDrag();
@ -3830,8 +3825,7 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor
break;
}
SetValueOfRangeForUserEvent(
rangeFrame->GetValueAtEventPoint(
static_cast<WidgetInputEvent*>(aVisitor.mEvent)));
rangeFrame->GetValueAtEventPoint(aVisitor.mEvent->AsInputEvent()));
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
break;
@ -3844,14 +3838,13 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor
// call CancelRangeThumbDrag() if that is the case. We just finish off
// the drag and set our final value (unless someone has called
// preventDefault() and prevents us getting here).
FinishRangeThumbDrag(static_cast<WidgetInputEvent*>(aVisitor.mEvent));
FinishRangeThumbDrag(aVisitor.mEvent->AsInputEvent());
aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true;
break;
case NS_KEY_PRESS:
if (mIsDraggingRange &&
static_cast<WidgetKeyboardEvent*>(aVisitor.mEvent)->keyCode ==
NS_VK_ESCAPE) {
aVisitor.mEvent->AsKeyboardEvent()->keyCode == NS_VK_ESCAPE) {
CancelRangeThumbDrag();
}
break;

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

@ -197,7 +197,7 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
EventFlags eventFlags;
eventFlags.mMultipleActionsPrevented = true;
DispatchClickEvent(aVisitor.mPresContext,
static_cast<WidgetInputEvent*>(aVisitor.mEvent),
aVisitor.mEvent->AsInputEvent(),
content, false, &eventFlags, &status);
// Do we care about the status this returned? I don't think we do...
// Don't run another <label> off of this click

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

@ -853,8 +853,8 @@ nsTextInputListener::HandleEvent(nsIDOMEvent* aEvent)
}
WidgetKeyboardEvent* keyEvent =
static_cast<WidgetKeyboardEvent*>(aEvent->GetInternalNSEvent());
if (keyEvent->eventStructType != NS_KEY_EVENT) {
aEvent->GetInternalNSEvent()->AsKeyboardEvent();
if (!keyEvent) {
return NS_ERROR_UNEXPECTED;
}

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

@ -57,13 +57,22 @@ load_gstreamer()
if (major == GST_VERSION_MAJOR && minor == GST_VERSION_MINOR) {
gstreamerLib = RTLD_DEFAULT;
} else {
#ifdef __OpenBSD__
gstreamerLib = dlopen("libgstreamer-0.10.so", RTLD_NOW | RTLD_LOCAL);
#else
gstreamerLib = dlopen("libgstreamer-0.10.so.0", RTLD_NOW | RTLD_LOCAL);
#endif
}
void *handles[] = {
gstreamerLib,
#ifdef __OpenBSD__
dlopen("libgstapp-0.10.so", RTLD_NOW | RTLD_LOCAL),
dlopen("libgstvideo-0.10.so", RTLD_NOW | RTLD_LOCAL)
#else
dlopen("libgstapp-0.10.so.0", RTLD_NOW | RTLD_LOCAL),
dlopen("libgstvideo-0.10.so.0", RTLD_NOW | RTLD_LOCAL)
#endif
};
for (size_t i = 0; i < sizeof(handles) / sizeof(handles[0]); i++) {

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

@ -467,7 +467,7 @@ bool OmxDecoder::AllocateMediaResources()
if ((mVideoTrack != nullptr) && (mVideoSource == nullptr)) {
mNativeWindow = new GonkNativeWindow();
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
mNativeWindowClient = new GonkNativeWindowClient(mNativeWindow->getBufferQueue());
#else
mNativeWindowClient = new GonkNativeWindowClient(mNativeWindow);

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

@ -26,8 +26,7 @@ nsDOMTimeEvent::nsDOMTimeEvent(mozilla::dom::EventTarget* aOwner,
}
if (mEvent->eventStructType == NS_SMIL_TIME_EVENT) {
InternalUIEvent* event = static_cast<InternalUIEvent*>(mEvent);
mDetail = event->detail;
mDetail = mEvent->AsUIEvent()->detail;
}
mEvent->mFlags.mBubbles = false;

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

@ -910,9 +910,8 @@ bool
nsXBLPrototypeHandler::ModifiersMatchMask(nsIDOMUIEvent* aEvent,
bool aIgnoreShiftKey)
{
WidgetEvent* event = aEvent->GetInternalNSEvent();
NS_ENSURE_TRUE(event && event->IsInputDerivedEvent(), false);
WidgetInputEvent* inputEvent = static_cast<WidgetInputEvent*>(event);
WidgetInputEvent* inputEvent = aEvent->GetInternalNSEvent()->AsInputEvent();
NS_ENSURE_TRUE(inputEvent, false);
if (mKeyMask & cMetaMask) {
if (inputEvent->IsMeta() != ((mKeyMask & cMeta) != 0)) {

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

@ -361,10 +361,9 @@ nsXBLWindowKeyHandler::WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventTy
}
WidgetKeyboardEvent* keyEvent =
static_cast<WidgetKeyboardEvent*>(aKeyEvent->GetInternalNSEvent());
MOZ_ASSERT(keyEvent->eventStructType == NS_KEY_EVENT,
aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
MOZ_ASSERT(keyEvent,
"DOM key event's internal event must be WidgetKeyboardEvent");
bool handled = false;
switch (keyEvent->message) {
case NS_KEY_PRESS:

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

@ -1190,8 +1190,7 @@ nsXULElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
}
}
WidgetInputEvent* orig =
static_cast<WidgetInputEvent*>(aVisitor.mEvent);
WidgetInputEvent* orig = aVisitor.mEvent->AsInputEvent();
nsContentUtils::DispatchXULCommand(
commandContent,
aVisitor.mEvent->mFlags.mIsTrusted,

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

@ -52,7 +52,8 @@ DOMRequestIpcHelper.prototype = {
* queryInterface method and adds at least one weak listener to the Message
* Manager MUST implement Ci.nsISupportsWeakReference.
*/
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference]),
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
Ci.nsIObserver]),
/**
* 'aMessages' is expected to be an array of either:
@ -154,10 +155,18 @@ DOMRequestIpcHelper.prototype = {
this.innerWindowID = util.currentInnerWindowID;
}
this._destroyed = false;
Services.obs.addObserver(this, "inner-window-destroyed", false);
},
destroyDOMRequestHelper: function() {
if (this._destroyed) {
return;
}
this._destroyed = true;
Services.obs.removeObserver(this, "inner-window-destroyed");
if (this._listeners) {
@ -171,6 +180,11 @@ DOMRequestIpcHelper.prototype = {
this._listeners = null;
this._requests = null;
this._window = null;
// Objects inheriting from DOMRequestIPCHelper may have an uninit function.
if (this.uninit) {
this.uninit();
}
},
observe: function(aSubject, aTopic, aData) {

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

@ -46,7 +46,8 @@ URL::Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
rv = ioService->NewURI(NS_ConvertUTF16toUTF8(aUrl), nullptr, aBase.GetURI(),
getter_AddRefs(uri));
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
nsAutoString label(aUrl);
aRv.ThrowTypeError(MSG_INVALID_URL, &label);
return nullptr;
}
@ -69,7 +70,8 @@ URL::Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
rv = ioService->NewURI(NS_ConvertUTF16toUTF8(aBase), nullptr, nullptr,
getter_AddRefs(baseUri));
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
nsAutoString label(aBase);
aRv.ThrowTypeError(MSG_INVALID_URL, &label);
return nullptr;
}
@ -77,7 +79,8 @@ URL::Constructor(const GlobalObject& aGlobal, const nsAString& aUrl,
rv = ioService->NewURI(NS_ConvertUTF16toUTF8(aUrl), nullptr, baseUri,
getter_AddRefs(uri));
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
nsAutoString label(aUrl);
aRv.ThrowTypeError(MSG_INVALID_URL, &label);
return nullptr;
}
@ -203,7 +206,8 @@ URL::SetHref(const nsAString& aHref, ErrorResult& aRv)
nsCOMPtr<nsIURI> uri;
rv = ioService->NewURI(href, nullptr, nullptr, getter_AddRefs(uri));
if (NS_FAILED(rv)) {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
nsAutoString label(aHref);
aRv.ThrowTypeError(MSG_INVALID_URL, &label);
return;
}

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

@ -24,32 +24,32 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=926890
var url = new URL('http://www.example.com');
ok(url, "URL created");
var status = false;
try {
url.href = '42';
ok(false, "url.href = 42 should throw");
} catch(e) {
status = true;
ok(true, "url.href = 42 should throw");
ok(e instanceof TypeError, "error type typeError");
}
ok(status, "url.href = 42 should throw");
url.href = 'http://www.example.org';
ok(true, "url.href should not throw");
status = false
try {
new URL('42');
ok(false, "new URL(42) should throw");
} catch(e) {
status = true;
ok(true, "new URL(42) should throw");
ok(e instanceof TypeError, "error type typeError");
}
ok(status, "new URL(42) should throw");
status = false
try {
new URL('http://www.example.com', '42');
ok(false, "new URL(something, 42) should throw");
} catch(e) {
status = true;
ok(true, "new URL(something, 42) should throw");
ok(e instanceof TypeError, "error type typeError");
}
ok(status, "new URL(something, 42) should throw");
</script>
</body>

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

@ -47,3 +47,4 @@ MSG_DEF(MSG_INVALID_BYTESTRING, 2, "Cannot convert string to ByteString because
MSG_DEF(MSG_NOT_DATE, 1, "{0} is not a date.")
MSG_DEF(MSG_INVALID_ADVANCE_COUNT, 0, "0 (Zero) is not a valid advance count.")
MSG_DEF(MSG_DEFINEPROPERTY_ON_GSP, 0, "Not allowed to define a property on the named properties object.")
MSG_DEF(MSG_INVALID_URL, 1, "{0} is not a valid URL.")

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

@ -4780,7 +4780,8 @@ class Parser(Tokenizer):
def p_error(self, p):
if not p:
raise WebIDLError("Syntax Error at end of file. Possibly due to missing semicolon(;), braces(}) or both", [])
raise WebIDLError("Syntax Error at end of file. Possibly due to missing semicolon(;), braces(}) or both",
[self._filename])
else:
raise WebIDLError("invalid syntax", [Location(self.lexer, p.lineno, p.lexpos, self._filename)])

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

@ -183,7 +183,7 @@ GonkCameraHardware::Init()
mNativeWindow = new GonkNativeWindow();
mNativeWindow->setNewFrameCallback(this);
mCamera->setListener(this);
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
mCamera->setPreviewTexture(mNativeWindow->getBufferQueue());
#else
mCamera->setPreviewTexture(mNativeWindow);

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

@ -130,7 +130,7 @@ static int32_t getColorFormat(const char* colorFormat) {
if (!strcmp(colorFormat, "OMX_TI_COLOR_FormatYUV420PackedSemiPlanar")) {
return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
}
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE)) {
return OMX_COLOR_FormatAndroidOpaque;
}
@ -542,7 +542,7 @@ status_t GonkCameraSource::start(MetaData *meta) {
if (meta->findInt64(kKeyTime, &startTimeUs)) {
mStartTimeUs = startTimeUs;
}
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
int32_t nBuffers;
if (meta->findInt32(kKeyNumBuffers, &nBuffers)) {
CHECK_GT(nBuffers, 0);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,6 +1,3 @@
component {35ad8a4e-9486-44b6-883d-550f14635e49} ContactManager.js
contract @mozilla.org/contactProperties;1 {35ad8a4e-9486-44b6-883d-550f14635e49}
component {9cbfa81c-bcab-4ca9-b0d2-f4318f295e33} ContactManager.js
contract @mozilla.org/contactAddress;1 {9cbfa81c-bcab-4ca9-b0d2-f4318f295e33}
@ -10,16 +7,8 @@ contract @mozilla.org/contactField;1 {ad19a543-69e4-44f0-adfa-37c011556bc1}
component {4d42c5a9-ea5d-4102-80c3-40cc986367ca} ContactManager.js
contract @mozilla.org/contactTelField;1 {4d42c5a9-ea5d-4102-80c3-40cc986367ca}
component {0a5b1fab-70da-46dd-b902-619904d920c2} ContactManager.js
contract @mozilla.org/contactFindSortOptions;1 {0a5b1fab-70da-46dd-b902-619904d920c2}
component {28ce07d0-45d9-4b7a-8843-521df4edd8bc} ContactManager.js
contract @mozilla.org/contactFindOptions;1 {28ce07d0-45d9-4b7a-8843-521df4edd8bc}
component {72a5ee28-81d8-4af8-90b3-ae935396cc66} ContactManager.js
contract @mozilla.org/contact;1 {72a5ee28-81d8-4af8-90b3-ae935396cc66}
category JavaScript-global-constructor mozContact @mozilla.org/contact;1
component {8beb3a66-d70a-4111-b216-b8e995ad3aff} ContactManager.js
contract @mozilla.org/contactManager;1 {8beb3a66-d70a-4111-b216-b8e995ad3aff}
category JavaScript-navigator-property mozContacts @mozilla.org/contactManager;1

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

@ -20,24 +20,28 @@ Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
const DB_NAME = "contacts";
const DB_VERSION = 14;
const DB_VERSION = 16;
const STORE_NAME = "contacts";
const SAVED_GETALL_STORE_NAME = "getallcache";
const CHUNK_SIZE = 20;
const REVISION_STORE = "revision";
const REVISION_KEY = "revision";
function optionalDate(aValue) {
if (aValue) {
if (!(aValue instanceof Date)) {
return new Date(aValue);
}
return aValue;
}
return undefined;
}
function exportContact(aRecord) {
let contact = {};
contact.properties = aRecord.properties;
for (let field in aRecord.properties)
contact.properties[field] = aRecord.properties[field];
contact.updated = aRecord.updated;
contact.published = aRecord.published;
contact.id = aRecord.id;
return contact;
if (aRecord) {
delete aRecord.search;
}
return aRecord;
}
function ContactDispatcher(aContacts, aFullContacts, aCallback, aNewTxn, aClearDispatcher, aFailureCb) {
@ -150,9 +154,7 @@ ContactDB.prototype = {
for (let i = 0; i < contacts.length; i++) {
let contact = {};
contact.properties = contacts[i];
contact.id = idService.generateUUID().toString().replace('-', '', 'g')
.replace('{', '')
.replace('}', '');
contact.id = idService.generateUUID().toString().replace(/[{}-]/g, "");
contact = this.makeImport(contact);
this.updateRecordMetadata(contact);
if (DEBUG) debug("import: " + JSON.stringify(contact));
@ -544,11 +546,80 @@ ContactDB.prototype = {
if (modified || modified2) {
cursor.update(cursor.value);
}
cursor.continue();
} else {
next();
}
};
},
function upgrade14to15() {
if (DEBUG) debug("Fix array properties saved as scalars");
if (!objectStore) {
objectStore = aTransaction.objectStore(STORE_NAME);
}
const ARRAY_PROPERTIES = ["photo", "adr", "email", "url", "impp", "tel",
"name", "honorificPrefix", "givenName",
"additionalName", "familyName", "honorificSuffix",
"nickname", "category", "org", "jobTitle",
"note", "key"];
const PROPERTIES_WITH_TYPE = ["adr", "email", "url", "impp", "tel"];
objectStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
let changed = false;
if (cursor) {
let props = cursor.value.properties;
for (let prop of ARRAY_PROPERTIES) {
if (props[prop]) {
if (!Array.isArray(props[prop])) {
cursor.value.properties[prop] = [props[prop]];
changed = true;
}
if (PROPERTIES_WITH_TYPE.indexOf(prop) !== -1) {
let subprop = cursor.value.properties[prop];
for (let i = 0; i < subprop.length; ++i) {
if (!Array.isArray(subprop[i].type)) {
cursor.value.properties[prop][i].type = [subprop[i].type];
changed = true;
}
}
}
}
}
if (changed) {
cursor.update(cursor.value);
}
cursor.continue();
} else {
next();
}
};
},
function upgrade15to16() {
if (DEBUG) debug("Fix Date properties");
if (!objectStore) {
objectStore = aTransaction.objectStore(STORE_NAME);
}
const DATE_PROPERTIES = ["bday", "anniversary"];
objectStore.openCursor().onsuccess = function(event) {
let cursor = event.target.result;
let changed = false;
if (cursor) {
let props = cursor.value.properties;
for (let prop of DATE_PROPERTIES) {
if (props[prop] && !(props[prop] instanceof Date)) {
cursor.value.properties[prop] = new Date(props[prop]);
changed = true;
}
}
if (changed) {
cursor.update(cursor.value);
}
cursor.continue();
} else {
next();
}
};
},
];
let index = aOldVersion;
@ -576,31 +647,7 @@ ContactDB.prototype = {
},
makeImport: function makeImport(aContact) {
let contact = {};
contact.properties = {
name: [],
honorificPrefix: [],
givenName: [],
additionalName: [],
familyName: [],
honorificSuffix: [],
nickname: [],
email: [],
photo: [],
url: [],
category: [],
adr: [],
tel: [],
org: [],
jobTitle: [],
bday: null,
note: [],
impp: [],
anniversary: null,
sex: null,
genderIdentity: null,
key: [],
};
let contact = {properties: {}};
contact.search = {
givenName: [],
@ -687,7 +734,6 @@ ContactDB.prototype = {
}
}
}
if (DEBUG) debug("contact:" + JSON.stringify(contact));
contact.updated = aContact.updated;
contact.published = aContact.published;

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

@ -4,8 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Android only supports the Contacts API on the Nightly channel.
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android' or CONFIG['NIGHTLY_BUILD']:
# Disable the tests on Android for now (bug 927869)
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
TEST_DIRS += ['tests']
EXTRA_COMPONENTS += [

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

@ -61,29 +61,30 @@ var c4 = {
};
var c5 = {
nickname: "empty"
familyName: [],
givenName: [],
};
var c6 = {
name: "e",
name: ["e"],
familyName: ["e","e","e"],
givenName: ["e","e","e"],
};
var c7 = {
name: "e",
name: ["e"],
familyName: ["e","e","e"],
givenName: ["e","e","e"],
};
var c8 = {
name: "e",
name: ["e"],
familyName: ["e","e","e"],
givenName: ["e","e","e"],
};
var adr1 = {
type: "work",
type: ["work"],
streetAddress: "street 1",
locality: "locality 1",
region: "region 1",
@ -92,7 +93,7 @@ var adr1 = {
};
var adr2 = {
type: "home, fax",
type: ["home, fax"],
streetAddress: "street2",
locality: "locality2",
region: "region2",
@ -104,34 +105,34 @@ var properties1 = {
name: ["Test1 TestFamilyName", "Test2 Wagner"],
familyName: ["TestFamilyName","Wagner"],
givenName: ["Test1","Test2"],
nickname: "nicktest",
nickname: ["nicktest"],
tel: [{type: ["work"], value: "123456", carrier: "testCarrier"} , {type: ["home", "fax"], value: "+55 (31) 9876-3456"}, {type: ["home"], value: "+49 451 491934"}],
adr: adr1,
adr: [adr1],
email: [{type: ["work"], value: "x@y.com"}],
};
var properties2 = {
name: ["dummyHonorificPrefix dummyGivenName dummyFamilyName dummyHonorificSuffix", "dummyHonorificPrefix2"],
familyName: "dummyFamilyName",
givenName: "dummyGivenName",
familyName: ["dummyFamilyName"],
givenName: ["dummyGivenName"],
honorificPrefix: ["dummyHonorificPrefix","dummyHonorificPrefix2"],
honorificSuffix: "dummyHonorificSuffix",
additionalName: "dummyadditionalName",
nickname: "dummyNickname",
honorificSuffix: ["dummyHonorificSuffix"],
additionalName: ["dummyadditionalName"],
nickname: ["dummyNickname"],
tel: [{type: ["test"], value: "7932012345", carrier: "myCarrier", pref: 1},{type: ["home", "custom"], value: "7932012346", pref: 0}],
email: [{type: ["test"], value: "a@b.c"}, {value: "b@c.d", pref: 1}],
adr: [adr1, adr2],
impp: [{type: ["aim"], value:"im1", pref: 1}, {value: "im2"}],
org: ["org1", "org2"],
jobTitle: ["boss", "superboss"],
note: "test note",
note: ["test note"],
category: ["cat1", "cat2"],
url: [{type: ["work", "work2"], value: "www.1.com", pref: 1}, {value:"www2.com"}],
bday: new Date("1980, 12, 01"),
anniversary: new Date("2000, 12, 01"),
sex: "male",
genderIdentity: "test",
key: "ERPJ394GJJWEVJ0349GJ09W3H4FG0WFW80VHW3408GH30WGH348G3H"
key: ["ERPJ394GJJWEVJ0349GJ09W3H4FG0WFW80VHW3408GH30WGH348G3H"]
};
var sample_id1;
@ -166,20 +167,39 @@ function checkStr(str1, str2, msg) {
ok(false, "Expected both strings to be either present or absent");
return;
}
if (!str1 || str1 == "null") {
str1 = null;
}
if (!str2 || str2 == "null") {
str2 = null;
}
is(str1, str2, msg);
}
function checkStrArray(str1, str2, msg) {
// comparing /[null(,null)+]/ and undefined should pass
function nonNull(e) {
return e != null;
function normalize_falsy(v) {
if (!v || v == "null" || v == "undefined") {
return "";
}
return v;
}
if ((Array.isArray(str1) && str1.filter(nonNull).length == 0 && str2 == undefined)
||(Array.isArray(str2) && str2.filter(nonNull).length == 0 && str1 == undefined)) {
ok(true, msg);
} else if (str1) {
is(JSON.stringify(typeof str1 == "string" ? [str1] : str1), JSON.stringify(typeof str2 == "string" ? [str2] : str2), msg);
function optArray(val) {
return Array.isArray(val) ? val : [val];
}
str1 = optArray(str1).map(normalize_falsy).filter(v => v != "");
str2 = optArray(str2).map(normalize_falsy).filter(v => v != "");
ise(JSON.stringify(str1), JSON.stringify(str2), msg);
}
function checkPref(pref1, pref2) {
// If on Android treat one preference as 0 and the other as undefined as matching
if (isAndroid) {
if ((!pref1 && pref2 == undefined) || (pref1 == undefined && !pref2)) {
pref1 = false;
pref2 = false;
}
}
ise(!!pref1, !!pref2, "Same pref");
}
function checkAddress(adr1, adr2) {
@ -188,44 +208,31 @@ function checkAddress(adr1, adr2) {
return;
}
checkStrArray(adr1.type, adr2.type, "Same type");
checkStrArray(adr1.streetAddress, adr2.streetAddress, "Same streetAddress");
checkStrArray(adr1.locality, adr2.locality, "Same locality");
checkStrArray(adr1.region, adr2.region, "Same region");
checkStrArray(adr1.postalCode, adr2.postalCode, "Same postalCode");
checkStrArray(adr1.countryName, adr2.countryName, "Same countryName");
checkStr(adr1.streetAddress, adr2.streetAddress, "Same streetAddress");
checkStr(adr1.locality, adr2.locality, "Same locality");
checkStr(adr1.region, adr2.region, "Same region");
checkStr(adr1.postalCode, adr2.postalCode, "Same postalCode");
checkStr(adr1.countryName, adr2.countryName, "Same countryName");
checkPref(adr1.pref, adr2.pref);
}
function checkTel(tel1, tel2) {
if (tel1 ^ tel2) {
ok(false, "Expected both tels to be either present or absent");
return;
}
checkStrArray(tel1.type, tel2.type, "Same type");
checkStrArray(tel1.value, tel2.value, "Same value");
checkStrArray(tel1.carrier, tel2.carrier, "Same carrier");
checkPref(tel1.pref, tel2.pref);
}
function checkField(field1, field2) {
if (field1 ^ field2) {
ok(false, "Expected both fields to be either present or absent");
return;
}
checkStrArray(field1.type, field2.type, "Same type");
checkStrArray(field1.value, field2.value, "Same value");
checkStr(field1.value, field2.value, "Same value");
checkPref(field1.pref, field2.pref);
}
function checkPref(pref1, pref2) {
// If on Android treat one preference as 0 and the other as undefined as matching
if (isAndroid) {
if ((pref1 == 0 && pref2 == undefined) || (pref1 == undefined && pref2 == 0)) {
pref1 = 0;
pref2 = 0;
}
function checkTel(tel1, tel2) {
if (tel1 ^ tel2) {
ok(false, "Expected both tels to be either present or absent");
return;
}
is(pref1, pref2, "Same pref");
checkField(tel1, tel2);
checkStr(tel1.carrier, tel2.carrier, "Same carrier");
}
function checkCategory(category1, category2) {
@ -239,21 +246,42 @@ function checkCategory(category1, category2) {
}
function removeAndroidDefaultCategory(category) {
if (category == undefined) {
return;
if (!category) {
return category;
}
for (var i = 0; i < category.length; i++) {
var result = [];
for (var i of category) {
// Some devices may return the full group name (prefixed with "System Group: ")
if (category[i] == "My Contacts" || category[i] == "System Group: My Contacts") {
category.splice(i, 1);
if (i != "My Contacts" && i != "System Group: My Contacts") {
result.push(i);
}
}
return category;
return result;
}
function checkArrayField(array1, array2, func, msg) {
if (!!array1 ^ !!array2) {
ok(false, "Expected both arrays to be either present or absent");
return;
}
if (!array1 && !array2) {
ok(true, msg);
return;
}
ise(array1.length, array2.length, "Same length");
for (var i = 0; i < array1.length; ++i) {
func(array1[i], array2[i], msg);
}
}
function checkContacts(contact1, contact2) {
if (!!contact1 ^ !!contact2) {
ok(false, "Expected both contacts to be either present or absent");
return;
}
checkStrArray(contact1.name, contact2.name, "Same name");
checkStrArray(contact1.honorificPrefix, contact2.honorificPrefix, "Same honorificPrefix");
checkStrArray(contact1.givenName, contact2.givenName, "Same givenName");
@ -271,21 +299,11 @@ function checkContacts(contact1, contact2) {
checkStr(contact1.genderIdentity, contact2.genderIdentity, "Same genderIdentity");
checkStrArray(contact1.key, contact2.key, "Same key");
for (var i in contact1.email) {
checkField(contact1.email[i], contact2.email[i]);
}
for (var i in contact1.adr) {
checkAddress(contact1.adr[i], contact2.adr[i]);
}
for (var i in contact1.tel) {
checkTel(contact1.tel[i], contact2.tel[i]);
}
for (var i in contact1.url) {
checkField(contact1.url[i], contact2.url[i]);
}
for (var i in contact1.impp) {
checkField(contact1.impp[i], contact2.impp[i]);
}
checkArrayField(contact1.adr, contact2.adr, checkAddress, "Same adr");
checkArrayField(contact1.tel, contact2.tel, checkTel, "Same tel");
checkArrayField(contact1.email, contact2.email, checkField, "Same email");
checkArrayField(contact1.url, contact2.url, checkField, "Same url");
checkArrayField(contact1.impp, contact2.impp, checkField, "Same impp");
}
var req;
@ -293,6 +311,10 @@ var index = 0;
var initialRev;
var defaultOptions = {
sortBy: "givenName",
};
function checkRevision(revision, msg, then) {
var revReq = mozContacts.getRevision();
revReq.onsuccess = function(e) {
@ -319,8 +341,6 @@ function checkCount(count, msg, then) {
}
var mozContacts = window.navigator.mozContacts;
ok(mozContacts, "mozContacts exists");
ok("mozContact" in window, "mozContact exists");
var steps = [
function() {
req = mozContacts.getRevision();
@ -354,7 +374,7 @@ var steps = [
},
function () {
ok(true, "Retrieving all contacts");
req = mozContacts.find({});
req = mozContacts.find(defaultOptions);
req.onsuccess = function () {
is(req.result.length, 0, "Empty database.");
checkRevision(1, "Revision was not incremented on find", next);
@ -363,8 +383,7 @@ var steps = [
},
function () {
ok(true, "Adding empty contact");
createResult1 = new mozContact();
createResult1.init({});
createResult1 = new mozContact({});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -377,7 +396,7 @@ var steps = [
},
function () {
ok(true, "Retrieving all contacts");
req = mozContacts.find({});
req = mozContacts.find(defaultOptions);
req.onsuccess = function () {
is(req.result.length, 1, "One contact.");
findResult1 = req.result[0];
@ -389,7 +408,7 @@ var steps = [
ok(true, "Deleting empty contact");
req = navigator.mozContacts.remove(findResult1);
req.onsuccess = function () {
var req2 = mozContacts.find({});
var req2 = mozContacts.find(defaultOptions);
req2.onsuccess = function () {
is(req2.result.length, 0, "Empty Database.");
clearTemps();
@ -401,8 +420,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact1");
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
mozContacts.oncontactchange = function(event) {
is(event.contactID, createResult1.id, "Same contactID");
@ -487,8 +505,7 @@ var steps = [
is(event.contactID, createResult2.id, "Same contactID");
is(event.reason, "create", "Same reason");
}
createResult2 = new mozContact();
createResult2.init({name: "newName"});
createResult2 = new mozContact({name: ["newName"]});
req = navigator.mozContacts.save(createResult2);
req.onsuccess = function () {
ok(createResult2.id, "The contact now has an ID.");
@ -573,8 +590,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact with properties1");
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
mozContacts.oncontactchange = null;
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
@ -788,14 +804,16 @@ var steps = [
},
function () {
ok(true, "Retrieving all contacts");
req = mozContacts.find({});
req = mozContacts.find(defaultOptions);
req.onsuccess = function() {
is(req.result.length, 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
checkContacts(createResult1, findResult1);
ok(findResult1.updated, "Has updated field");
ok(findResult1.published, "Has published field");
if (!isAndroid) {
ok(findResult1.updated, "Has updated field");
ok(findResult1.published, "Has published field");
}
next();
}
req.onerror = onFailure;
@ -808,7 +826,7 @@ var steps = [
findResult1.impp = properties1.impp = [{value:"phil impp"}];
req = navigator.mozContacts.save(findResult1);
req.onsuccess = function () {
var req2 = mozContacts.find({});
var req2 = mozContacts.find(defaultOptions);
req2.onsuccess = function() {
is(req2.result.length, 1, "Found exactly 1 contact.");
findResult2 = req2.result[0];
@ -872,7 +890,7 @@ var steps = [
findResult1.impp = properties1.impp = [{value: "phil impp"}];
req = mozContacts.save(findResult1);
req.onsuccess = function () {
var req2 = mozContacts.find({});
var req2 = mozContacts.find(defaultOptions);
req2.onsuccess = function () {
is(req2.result.length, 1, "Found exactly 1 contact.");
findResult1 = req2.result[0];
@ -937,9 +955,8 @@ var steps = [
SpecialPowers.executeSoon(next);
} else {
findResult1.email = [{value: properties1.nickname}];
findResult1.nickname = "TEST";
var newContact = new mozContact();
newContact.init(findResult1);
findResult1.nickname = ["TEST"];
var newContact = new mozContact(findResult1);
req = mozContacts.save(newContact);
req.onsuccess = function () {
var options = {filterBy: ["email", "givenName"],
@ -961,7 +978,7 @@ var steps = [
ok(true, "Deleting contact" + findResult1);
req = mozContacts.remove(findResult1);
req.onsuccess = function () {
var req2 = mozContacts.find({});
var req2 = mozContacts.find(defaultOptions);
req2.onsuccess = function () {
is(req2.result.length, 1, "One contact left.");
findResult1 = req2.result[0];
@ -982,8 +999,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact");
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
req = mozContacts.save(createResult1)
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -994,8 +1010,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact2");
createResult2 = new mozContact();
createResult2.init(properties2);
createResult2 = new mozContact(properties2);
req = mozContacts.save(createResult2);
req.onsuccess = function () {
ok(createResult2.id, "The contact now has an ID.");
@ -1006,10 +1021,10 @@ var steps = [
},
function () {
ok(true, "Retrieving all contacts");
req = mozContacts.find({sortBy: 'FamilyName',})
req = mozContacts.find({sortBy: "familyName"});
req.onsuccess = function () {
is(req.result.length, 2, "Found exactly 2 contact.");
checkContacts(properties2, req.result[1]);
checkContacts(req.result[1], properties1);
next();
}
req.onerror = onFailure;
@ -1086,16 +1101,14 @@ var steps = [
function () {
ok(true, "Adding 20 contacts");
for (var i=0; i<19; i++) {
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
req = mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
};
req.onerror = onFailure;
};
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
req = mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1106,7 +1119,7 @@ var steps = [
},
function () {
ok(true, "Retrieving all contacts");
req = mozContacts.find({});
req = mozContacts.find(defaultOptions);
req.onsuccess = function () {
is(req.result.length, 20, "20 Entries.");
next();
@ -1152,11 +1165,10 @@ var steps = [
ok(true, "Retrieving all contacts3");
var options = {filterBy: ["givenName", "tel", "email"],
filterOp: "startsWith",
filterValue: properties1.givenName[0].substring(0, 4),
filterLimit: 15 };
filterValue: properties1.givenName[0].substring(0, 4)};
req = mozContacts.find(options);
req.onsuccess = function () {
is(req.result.length, 15, "15 Entries.");
is(req.result.length, 20, "20 Entries.");
checkContacts(createResult1, req.result[10]);
next();
}
@ -1173,8 +1185,7 @@ var steps = [
},
function () {
ok(true, "Testing clone contact");
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
req = mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1187,14 +1198,14 @@ var steps = [
ok(true, "Testing clone contact2");
var cloned = new mozContact(createResult1);
ok(cloned.id != createResult1.id, "Cloned contact has new ID");
cloned.email = {value: "new email!"};
cloned.givenName = "Tom";
cloned.email = [{value: "new email!"}];
cloned.givenName = ["Tom"];
req = mozContacts.save(cloned);
req.onsuccess = function () {
ok(cloned.id, "The contact now has an ID.");
ok(cloned.email[0].value == "new email!", "Same Email");
ok(createResult1.email != cloned.email, "Clone has different email");
ok(cloned.givenName == "Tom", "New Name");
is(cloned.email[0].value, "new email!", "Same Email");
isnot(createResult1.email[0].value, cloned.email[0].value, "Clone has different email");
is(cloned.givenName, "Tom", "New Name");
next();
}
req.onerror = onFailure;
@ -1204,7 +1215,7 @@ var steps = [
var options = {filterBy: ["givenName"],
filterOp: "startsWith",
filterValue: properties2.givenName[0].substring(0, 4)};
req = mozContacts.find({});
req = mozContacts.find(defaultOptions);
req.onsuccess = function () {
is(req.result.length, 2, "2 Entries.");
next();
@ -1213,11 +1224,14 @@ var steps = [
},
function () {
ok(true, "Search with redundant fields should only return 1 contact");
createResult1 = new mozContact();
createResult1.init({name: "XXX", givenName: "XXX", email: [{value: "XXX"}], tel: {value: "XXX"}});
createResult1 = new mozContact({name: ["XXX"],
givenName: ["XXX"],
email: [{value: "XXX"}],
tel: [{value: "XXX"}]
});
req = mozContacts.save(createResult1);
req.onsuccess = function() {
var options = {filterBy: [],
var options = {filterBy: ["givenName", "familyName"],
filterOp: "equals",
filterValue: "XXX"};
var req2 = mozContacts.find(options);
@ -1240,8 +1254,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c3);
createResult1 = new mozContact(c3);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1252,8 +1265,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c2);
createResult1 = new mozContact(c2);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1264,8 +1276,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c4);
createResult1 = new mozContact(c4);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1276,8 +1287,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c1);
createResult1 = new mozContact(c1);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1318,8 +1328,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c5);
createResult1 = new mozContact(c5);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1346,17 +1355,16 @@ var steps = [
},
function () {
ok(true, "Don't allow to add custom fields");
createResult1 = new mozContact();
createResult1.init({givenName: "customTest", yyy: "XXX"});
createResult1 = new mozContact({givenName: ["customTest"], yyy: "XXX"});
req = mozContacts.save(createResult1);
req.onsuccess = function() {
var options = {filterBy: [],
var options = {filterBy: ["givenName"],
filterOp: "equals",
filterValue: "customTest"};
var req2 = mozContacts.find(options);
req2.onsuccess = function() {
is(req2.result.length, 1, "1 Entry");
checkStrArray(req2.result.givenName, "customTest", "same name");
checkStrArray(req2.result[0].givenName, ["customTest"], "same name");
ok(req2.result.yyy === undefined, "custom property undefined");
next();
}
@ -1375,8 +1383,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c7);
createResult1 = new mozContact(c7);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1387,8 +1394,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c6);
createResult1 = new mozContact(c6);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1399,8 +1405,7 @@ var steps = [
},
function () {
ok(true, "Test sorting");
createResult1 = new mozContact();
createResult1.init(c8);
createResult1 = new mozContact(c8);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1430,7 +1435,7 @@ var steps = [
},
function () {
ok(true, "Deleting database");
req = mozContacts.clear()
req = mozContacts.clear();
req.onsuccess = function () {
ok(true, "Deleted the database");
next();
@ -1439,8 +1444,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact with properties2");
createResult2 = new mozContact();
createResult2.init(properties2);
createResult2 = new mozContact(properties2);
req = mozContacts.save(createResult2);
req.onsuccess = function () {
ok(createResult2.id, "The contact now has an ID.");
@ -1485,9 +1489,8 @@ var steps = [
req.onerror = onFailure;
},
function () {
ok(true, "Adding empty contact");
createResult1 = new mozContact();
createResult1.init({name: "5", givenName: "5"});
ok(true, "Adding contact for category search");
createResult1 = new mozContact({name: ["5"], givenName: ["5"]});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1522,20 +1525,10 @@ var steps = [
ok(true, "Adding contact with invalid data");
var input = document.createElement("input");
var obj = {
name: [1, 2],
familyName: 3,
givenName: 4,
honorificPrefix: [],
honorificSuffix: {foo: "bar"},
additionalName: 7,
nickname: [8, 9],
org: [10, 11],
jobTitle: [12, 13],
note: 14,
category: [15, 16],
honorificSuffix: [{foo: "bar"}],
sex: 17,
genderIdentity: 18,
key: 4,
email: input,
adr: input,
tel: input,
@ -1553,12 +1546,12 @@ var steps = [
}
}
})());
createResult1 = new mozContact();
createResult1.init(obj);
createResult1 = new mozContact(obj);
req = mozContacts.save(createResult1);
req.onsuccess = function () {
checkContacts(createResult1, {
honorificPrefix: "string",
honorificPrefix: ["string"],
honorificSuffix: ["[object Object]"],
sex: "17",
genderIdentity: "18"
});
@ -1567,8 +1560,7 @@ var steps = [
},
function () {
ok(true, "Adding contact with no number but carrier");
createResult1 = new mozContact();
createResult1.init({ tel: [{type: ["home"], carrier: "myCarrier"} ] });
createResult1 = new mozContact({ tel: [{type: ["home"], carrier: "myCarrier"} ] });
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1578,8 +1570,7 @@ var steps = [
},
function () {
ok(true, "Adding contact with email but no value");
createResult1 = new mozContact();
createResult1.init({ email: [{type: ["home"]}] });
createResult1 = new mozContact({ email: [{type: ["home"]}] });
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1589,8 +1580,7 @@ var steps = [
},
function () {
ok(true, "Testing numbersOnly search 1");
createResult1 = new mozContact();
createResult1.init({ name: ["aaaaaaaaa"], givenName: ["aaaaaaaaa"], tel: [{ value: "1234567890"}]});
createResult1 = new mozContact({ name: ["aaaaaaaaa"], givenName: ["aaaaaaaaa"], tel: [{ value: "1234567890"}]});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -1670,17 +1660,10 @@ var steps = [
},
function() {
ok(true, "Test setting array properties to scalar values")
const DOMStrings = ["name","honorificPrefix","givenName","additionalName",
"familyName", "honorificSuffix","nickname","category",
"org","jobTitle","note"];
const FIELDS = ["email","url","adr","tel","impp"];
createResult1 = new mozContact();
for (var prop of DOMStrings) {
createResult1[prop] = "foo";
ok(Array.isArray(createResult1[prop]), prop + " is array");
}
for (var prop of FIELDS) {
createResult1[prop] = {type: "foo"};
createResult1[prop] = {type: ["foo"]};
ok(Array.isArray(createResult1[prop]), prop + " is array");
}
next();

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

@ -90,14 +90,14 @@ var randomBlob = getRandomBlob(1024);
var randomBlob2 = getRandomBlob(1024);
var properties1 = {
name: "xTestname1",
givenName: "xTestname1",
name: ["xTestname1"],
givenName: ["xTestname1"],
photo: [randomBlob]
};
var properties2 = {
name: "yTestname2",
givenName: "yTestname2",
name: ["yTestname2"],
givenName: ["yTestname2"],
photo: [randomBlob, randomBlob2]
};
@ -177,8 +177,7 @@ var steps = [
},
function () {
ok(true, "Adding contact with photo");
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -191,7 +190,7 @@ var steps = [
ok(true, "Retrieving by substring");
var options = {filterBy: ["givenName"],
filterOp: "startsWith",
filterValue: properties1.givenName.substring(0,3)};
filterValue: properties1.givenName[0].substring(0,3)};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
@ -203,8 +202,7 @@ var steps = [
},
function () {
ok(true, "Adding contact with 2 photos");
createResult1 = new mozContact();
createResult1.init(properties2);
createResult1 = new mozContact(properties2);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -217,7 +215,7 @@ var steps = [
ok(true, "Retrieving by substring");
var options = {filterBy: ["givenName"],
filterOp: "startsWith",
filterValue: properties2.givenName.substring(0,3)};
filterValue: properties2.givenName[0].substring(0,3)};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
@ -227,58 +225,6 @@ var steps = [
};
req.onerror = onFailure;
},
function () {
ok(true, "Adding photo as String");
createResult1 = new mozContact();
createResult1.init({givenName: "asdf", photo: ["xyz"]});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
sample_id1 = createResult1.id;
is(createResult1.photo, null, "No photo")
next();
};
req.onerror = onFailure;
},
function () {
ok(true, "Adding photo as String");
createResult1 = new mozContact();
createResult1.init({givenName: "jkl", photo: "xyz"});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
is(createResult1.photo, null, "No photo")
next();
};
req.onerror = onFailure;
},
function () {
ok(true, "Retrieving by substring");
var options = {filterBy: ["givenName"],
filterOp: "startsWith",
filterValue: "asdf"};
req = mozContacts.find(options);
req.onsuccess = function () {
ok(req.result.length == 1, "Found exactly 1 contact.");
findResult1 = req.result[0];
ok(findResult1.id == sample_id1, "Same ID");
is(findResult1.photo, null, "No photo");
next();
};
req.onerror = onFailure;
},
function () {
ok(true, "Adding photo as Object");
createResult1 = new mozContact();
createResult1.init({photo: [{}]});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
is(createResult1.photo, null, "No photo")
next();
};
req.onerror = onFailure;
},
function () {
ok(true, "Deleting database");
req = mozContacts.clear()

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

@ -36,7 +36,7 @@ var androidVersion = SpecialPowers.Cc['@mozilla.org/system-info;1']
.getProperty('version');
let adr1 = {
type: "work",
type: ["work"],
streetAddress: "street 1",
locality: "locality 1",
region: "region 1",
@ -48,9 +48,9 @@ let properties1 = {
name: ["Testname1 TestFamilyName"],
familyName: ["TestFamilyName","Wagner"],
givenName: ["Test1","Test2"],
nickname: "nicktest",
nickname: ["nicktest"],
tel: [{type: ["work"], value: "123456", carrier: "testCarrier"} , {type: ["home", "fax"], value: "+9-876-5432"}],
adr: adr1,
adr: [adr1],
email: [{type: ["work"], value: "x@y.com"}]
};
@ -58,102 +58,137 @@ function onFailure() {
ok(false, "in on Failure!");
next();
}
function checkStr(str1, str2, msg) {
// comparing /[null(,null)+]/ and undefined should pass
function nonNull(e) {
return e != null;
if (str1 ^ str2) {
ok(false, "Expected both strings to be either present or absent");
return;
}
if ((Array.isArray(str1) && str1.filter(nonNull).length == 0 && str2 == undefined)
||(Array.isArray(str2) && str2.filter(nonNull).length == 0 && str1 == undefined)) {
ok(true, msg);
} else if (str1) {
is(JSON.stringify(typeof str1 == "string" ? [str1] : str1), JSON.stringify(typeof str2 == "string" ? [str2] : str2), msg);
is(str1, str2, msg);
}
function checkStrArray(str1, str2, msg) {
function normalize_falsy(k, v) {
if (!v || v == "null" || v == "undefined") {
return "";
}
return v;
}
ise(JSON.stringify(str1, normalize_falsy), JSON.stringify(str2, normalize_falsy), msg);
}
function checkPref(pref1, pref2) {
// If on Android treat one preference as 0 and the other as undefined as matching
if (isAndroid) {
if ((!pref1 && pref2 == undefined) || (pref1 == undefined && !pref2)) {
pref1 = false;
pref2 = false;
}
}
ise(!!pref1, !!pref2, "Same pref");
}
function checkAddress(adr1, adr2) {
checkStr(adr1.type, adr2.type, "Same type");
checkStr(adr1.streetAddress, adr2.streetAddress, "Same streetAddress");
checkStr(adr1.locality, adr2.locality, "Same locality");
checkStr(adr1.region, adr2.region, "Same region");
checkStr(adr1.postalCode, adr2.postalCode, "Same postalCode");
checkStr(adr1.countryName, adr2.countryName, "Same countryName");
}
function checkTel(tel1, tel2) {
checkStr(tel1.type, tel2.type, "Same type");
checkStr(tel1.value, tel2.value, "Same value");
checkStr(tel1.carrier, tel2.carrier, "Same carrier");
if (adr1 ^ adr2) {
ok(false, "Expected both adrs to be either present or absent");
return;
}
checkStrArray(adr1.type, adr2.type, "Same type");
checkStrArray(adr1.streetAddress, adr2.streetAddress, "Same streetAddress");
checkStrArray(adr1.locality, adr2.locality, "Same locality");
checkStrArray(adr1.region, adr2.region, "Same region");
checkStrArray(adr1.postalCode, adr2.postalCode, "Same postalCode");
checkStrArray(adr1.countryName, adr2.countryName, "Same countryName");
checkPref(adr1.pref, adr2.pref);
}
function checkField(field1, field2) {
checkStr(field1.type, field2.type, "Same type");
checkStr(field1.value, field2.value, "Same value");
if (field1 ^ field2) {
ok(false, "Expected both fields to be either present or absent");
return;
}
checkStrArray(field1.type, field2.type, "Same type");
checkStrArray(field1.value, field2.value, "Same value");
checkPref(field1.pref, field2.pref);
}
function checkTel(tel1, tel2) {
if (tel1 ^ tel2) {
ok(false, "Expected both tels to be either present or absent");
return;
}
checkField(tel1, tel2);
checkStrArray(tel1.carrier, tel2.carrier, "Same carrier");
}
function checkCategory(category1, category2) {
// Android adds contacts to the a default category. This should be removed from the
// results before comparing them
if (isAndroid) {
category1 = removeAndroidDefaultCategory(category1);
category2 = removeAndroidDefaultCategory(category2);
}
checkStrArray(category1, category2, "Same Category")
}
function removeAndroidDefaultCategory(category) {
if (!category) {
return category;
}
var result = [];
for (var i of category) {
// Some devices may return the full group name (prefixed with "System Group: ")
if (i != "My Contacts" && i != "System Group: My Contacts") {
result.push(i);
}
}
return result;
}
function checkArrayField(array1, array2, func, msg) {
if (!!array1 ^ !!array2) {
ok(false, "Expected both arrays to be either present or absent");
return;
}
if (!array1 && !array2) {
ok(true, msg);
return;
}
ise(array1.length, array2.length, "Same length");
for (var i = 0; i < array1.length; ++i) {
func(array1[i], array2[i], msg);
}
}
function checkContacts(contact1, contact2) {
checkStr(contact1.name, contact2.name, "Same name");
checkStr(contact1.honorificPrefix, contact2.honorificPrefix, "Same honorificPrefix");
checkStr(contact1.givenName, contact2.givenName, "Same givenName");
checkStr(contact1.additionalName, contact2.additionalName, "Same additionalName");
checkStr(contact1.familyName, contact2.familyName, "Same familyName");
checkStr(contact1.honorificSuffix, contact2.honorificSuffix, "Same honorificSuffix");
checkStr(contact1.nickname, contact2.nickname, "Same nickname");
checkStr(contact1.category, contact2.category, "Same category");
checkStr(contact1.org, contact2.org, "Same org");
checkStr(contact1.jobTitle, contact2.jobTitle, "Same jobTitle");
if (!!contact1 ^ !!contact2) {
ok(false, "Expected both contacts to be either present or absent");
return;
}
checkStrArray(contact1.name, contact2.name, "Same name");
checkStrArray(contact1.honorificPrefix, contact2.honorificPrefix, "Same honorificPrefix");
checkStrArray(contact1.givenName, contact2.givenName, "Same givenName");
checkStrArray(contact1.additionalName, contact2.additionalName, "Same additionalName");
checkStrArray(contact1.familyName, contact2.familyName, "Same familyName");
checkStrArray(contact1.honorificSuffix, contact2.honorificSuffix, "Same honorificSuffix");
checkStrArray(contact1.nickname, contact2.nickname, "Same nickname");
checkCategory(contact1.category, contact2.category);
checkStrArray(contact1.org, contact2.org, "Same org");
checkStrArray(contact1.jobTitle, contact2.jobTitle, "Same jobTitle");
is(contact1.bday ? contact1.bday.valueOf() : null, contact2.bday ? contact2.bday.valueOf() : null, "Same birthday");
checkStr(contact1.note, contact2.note, "Same note");
checkStrArray(contact1.note, contact2.note, "Same note");
is(contact1.anniversary ? contact1.anniversary.valueOf() : null , contact2.anniversary ? contact2.anniversary.valueOf() : null, "Same anniversary");
is(contact1.sex, contact2.sex, "Same sex");
is(contact1.genderIdentity, contact2.genderIdentity, "Same genderIdentity");
checkStr(contact1.sex, contact2.sex, "Same sex");
checkStr(contact1.genderIdentity, contact2.genderIdentity, "Same genderIdentity");
checkStrArray(contact1.key, contact2.key, "Same key");
for (let i in contact1.email) {
if (contact1.email) {
ok(contact2.email != null, "conatct2.email exists");
}
if (contact2.email) {
ok(contact1.email != null, "conatct1.email exists");
}
checkField(contact1.email[i], contact2.email[i]);
}
for (let i in contact1.adr) {
if (contact1.adr) {
ok(contact2.adr != null, "conatct2.adr exists");
}
if (contact2.adr) {
ok(contact1.adr != null, "conatct1.adr exists");
}
checkAddress(contact1.adr[i], contact2.adr[i]);
}
for (let i in contact1.tel) {
if (contact1.tel) {
ok(contact2.tel != null, "conatct2.tel exists");
}
if (contact2.tel) {
ok(contact1.tel != null, "conatct1.tel exists");
}
checkTel(contact1.tel[i], contact2.tel[i]);
}
for (let i in contact1.url) {
if (contact1.url) {
ok(contact2.url != null, "conatct2.url exists");
}
if (contact2.url) {
ok(contact1.url != null, "conatct1.url exists");
}
checkField(contact1.url[i], contact2.url[i]);
}
for (let i in contact1.impp) {
if (contact1.impp) {
ok(contact2.impp != null, "conatct2.impp exists");
}
if (contact2.impp) {
ok(contact1.impp != null, "conatct1.impp exists");
}
checkField(contact1.impp[i], contact2.impp[i]);
}
checkArrayField(contact1.adr, contact2.adr, checkAddress, "Same adr");
checkArrayField(contact1.tel, contact2.tel, checkTel, "Same tel");
checkArrayField(contact1.email, contact2.email, checkField, "Same email");
checkArrayField(contact1.url, contact2.url, checkField, "Same url");
checkArrayField(contact1.impp, contact2.impp, checkField, "Same impp");
}
function clearDatabase() {
@ -169,24 +204,22 @@ function clearDatabase() {
function addContacts() {
ok(true, "Adding 40 contacts");
for (let i = 0; i < 39; ++i) {
createResult1 = new mozContact();
properties1.familyName[0] = "Testname" + (i < 10 ? "0" + i : i);
properties1.name = properties1.givenName[0] + " " + properties1.familyName[0];
createResult1.init(properties1);
properties1.name = [properties1.givenName[0] + " " + properties1.familyName[0]];
createResult1 = new mozContact(properties1);
req = mozContacts.save(createResult1);
req.onsuccess = function() {
ok(createResult1.id, "The contact now has an ID.");
};
req.onerror = onFailure;
};
createResult1 = new mozContact();
properties1.familyName[0] = "Testname39";
properties1.name = properties1.givenName[0] + " Testname39";
createResult1.init(properties1);
properties1.name = [properties1.givenName[0] + " Testname39"];
createResult1 = new mozContact(properties1);
req = mozContacts.save(createResult1);
req.onsuccess = function() {
ok(createResult1.id, "The contact now has an ID.");
ok(createResult1.name == properties1.name, "Same Name");
checkStrArray(createResult1.name, properties1.name, "Same Name");
next();
};
req.onerror = onFailure;
@ -202,6 +235,7 @@ function getOne(msg) {
return function() {
ok(true, msg || "Retrieving one contact with getAll");
req = mozContacts.getAll({});
let count = 0;
req.onsuccess = function(event) {
ok(true, "on success");
@ -246,11 +280,14 @@ function getAll(msg) {
}
let steps = [
function start() {
SpecialPowers.Cc["@mozilla.org/tools/profiler;1"].getService(SpecialPowers.Ci.nsIProfiler).AddMarker("GETALL_START");
next();
},
clearDatabase,
function() {
// add a contact
createResult1 = new mozContact();
createResult1.init({});
createResult1 = new mozContact({});
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function() {
next();
@ -441,6 +478,7 @@ let steps = [
function() {
ok(true, "all done!\n");
SpecialPowers.Cc["@mozilla.org/tools/profiler;1"].getService(SpecialPowers.Ci.nsIProfiler).AddMarker("GETALL_END");
SimpleTest.finish();
}
];

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

@ -51,13 +51,13 @@ var number2 = {
};
var properties1 = {
name: "Testname1",
name: ["Testname1"],
tel: [{type: ["work"], value: number1.local, carrier: "testCarrier"} , {type: ["home", "fax"], value: number2.local}],
};
var shortNumber = "888";
var properties2 = {
name: "Testname2",
name: ["Testname2"],
tel: [{type: ["work"], value: shortNumber, carrier: "testCarrier"}]
};
@ -67,7 +67,7 @@ var number3 = {
};
var properties3 = {
name: "Testname2",
name: ["Testname2"],
tel: [{value: number3.international2}]
};
@ -91,8 +91,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact1");
createResult1 = new mozContact();
createResult1.init(properties1);
createResult1 = new mozContact(properties1);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -103,8 +102,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact2");
var createResult2 = new mozContact();
createResult2.init(properties2);
var createResult2 = new mozContact(properties2);
req = navigator.mozContacts.save(createResult2);
req.onsuccess = function () {
ok(createResult2.id, "The contact now has an ID.");
@ -249,8 +247,7 @@ var steps = [
},
function () {
ok(true, "Adding a new contact with country code");
createResult1 = new mozContact();
createResult1.init(properties3);
createResult1 = new mozContact(properties3);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");

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

@ -82,8 +82,7 @@ var steps = [
},
function () {
ok(true, "Adding contact");
createResult1 = new mozContact();
createResult1.init(prop);
createResult1 = new mozContact(prop);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -166,8 +165,7 @@ var steps = [
},
function () {
ok(true, "Adding contact");
createResult1 = new mozContact();
createResult1.init(prop2);
createResult1 = new mozContact(prop2);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -259,8 +257,7 @@ var steps = [
},
function () {
ok(true, "Adding contact");
createResult1 = new mozContact();
createResult1.init(prop3);
createResult1 = new mozContact(prop3);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -289,8 +286,7 @@ var steps = [
},
function () {
ok(true, "Adding contact");
createResult1 = new mozContact();
createResult1.init(prop4);
createResult1 = new mozContact(prop4);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");

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

@ -73,8 +73,7 @@ var steps = [
},
function () {
ok(true, "Adding contact");
createResult1 = new mozContact();
createResult1.init(prop);
createResult1 = new mozContact(prop);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");
@ -112,8 +111,7 @@ var steps = [
},
function () {
ok(true, "Adding contact");
createResult1 = new mozContact();
createResult1.init(prop2);
createResult1 = new mozContact(prop2);
req = navigator.mozContacts.save(createResult1);
req.onsuccess = function () {
ok(createResult1.id, "The contact now has an ID.");

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

@ -497,7 +497,7 @@ interface nsIDOMMozIccManager : nsIDOMEventTarget
* PIN2 is only required for 'fdn'.
*/
nsIDOMDOMRequest updateContact(in DOMString contactType,
in nsIDOMContact contact,
in nsISupports contact,
[optional] in DOMString pin2);
// End of UICC Phonebook Interfaces.

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

@ -72,7 +72,7 @@ interface nsIIccProvider : nsISupports
nsIDOMDOMRequest updateContact(in nsIDOMWindow window,
in DOMString contactType,
in nsIDOMContact contact,
in nsISupports contact,
in DOMString pin2);
/**

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

@ -234,7 +234,7 @@ IccManager::ReadContacts(const nsAString& aContactType, nsIDOMDOMRequest** aRequ
NS_IMETHODIMP
IccManager::UpdateContact(const nsAString& aContactType,
nsIDOMContact* aContact,
nsISupports* aContact,
const nsAString& aPin2,
nsIDOMDOMRequest** aRequest)
{

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

@ -15,19 +15,19 @@ function testReadContacts(type) {
is(Array.isArray(contacts), true);
is(contacts[0].name, "Mozilla");
is(contacts[0].name[0], "Mozilla");
is(contacts[0].tel[0].value, "15555218201");
is(contacts[0].id, "890141032111185107201");
is(contacts[1].name, "Saßê黃");
is(contacts[1].name[0], "Saßê黃");
is(contacts[1].tel[0].value, "15555218202");
is(contacts[1].id, "890141032111185107202");
is(contacts[2].name, "Fire 火");
is(contacts[2].name[0], "Fire 火");
is(contacts[2].tel[0].value, "15555218203");
is(contacts[2].id, "890141032111185107203");
is(contacts[3].name, "Huang 黃");
is(contacts[3].name[0], "Huang 黃");
is(contacts[3].tel[0].value, "15555218204");
is(contacts[3].id, "890141032111185107204");
@ -41,10 +41,8 @@ function testReadContacts(type) {
};
function testAddContact(type, pin2) {
let contact = new mozContact();
contact.init({
name: "add",
let contact = new mozContact({
name: ["add"],
tel: [{value: "0912345678"}],
email:[]
});
@ -62,7 +60,7 @@ function testAddContact(type, pin2) {
// There are 4 SIM contacts which are harded in emulator
is(contacts.length, 5);
is(contacts[4].name, "add");
is(contacts[4].name[0], "add");
is(contacts[4].tel[0].value, "0912345678");
runNextTest();

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

@ -1,15 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
XPIDL_SOURCES += [
'nsIContactProperties.idl',
'nsIDOMContactManager.idl',
]
XPIDL_MODULE = 'dom_contacts'
MODULE = 'dom'

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

@ -1,74 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
[scriptable, uuid(9cbfa81c-bcab-4ca9-b0d2-f4318f295e33)]
interface nsIContactAddress : nsISupports
{
attribute DOMString type;
attribute boolean pref; // false = no pref, true = preferred (vCard3 TYPE:PREF; vCard4 PREF:1)
attribute DOMString streetAddress;
attribute DOMString locality;
attribute DOMString region;
attribute DOMString postalCode;
attribute DOMString countryName;
};
[scriptable, uuid(ad19a543-69e4-44f0-adfa-37c011556bc1)]
interface nsIContactField : nsISupports
{
attribute jsval type; // DOMString[], "home", "work", etc.
attribute DOMString value;
attribute boolean pref; // false = no pref, true = preferred (vCard3 TYPE:PREF; vCard4 PREF:1)
};
[scriptable, uuid(4d42c5a9-ea5d-4102-80c3-40cc986367ca)]
interface nsIContactTelField : nsIContactField
{
attribute DOMString carrier;
};
[scriptable, uuid(0a5b1fab-70da-46dd-b902-619904d920c2)]
interface nsIContactFindSortOptions : nsISupports
{
attribute DOMString sortBy; // "givenName" or "familyName"
attribute DOMString sortOrder; // e.g. "descending"
};
[scriptable, uuid(28ce07d0-45d9-4b7a-8843-521df4edd8bc)]
interface nsIContactFindOptions : nsIContactFindSortOptions
{
attribute DOMString filterValue; // e.g. "Tom"
attribute DOMString filterOp; // e.g. "startsWith"
attribute jsval filterBy; // DOMString[], e.g. ["givenName", "nickname"]
attribute unsigned long filterLimit;
};
[scriptable, uuid(35ad8a4e-9486-44b6-883d-550f14635e49)]
interface nsIContactProperties : nsISupports
{
attribute jsval name; // DOMString[]
attribute jsval honorificPrefix; // DOMString[]
attribute jsval givenName; // DOMString[]
attribute jsval additionalName; // DOMString[]
attribute jsval familyName; // DOMString[]
attribute jsval honorificSuffix; // DOMString[]
attribute jsval nickname; // DOMString[]
attribute jsval email; // ContactField[]
attribute jsval photo; // nsIDOMBlob[]
attribute jsval url; // ContactField[]
attribute jsval category; // DOMString[]
attribute jsval adr; // ContactAddress[]
attribute jsval tel; // ContactTelField[]
attribute jsval org; // DOMString[]
attribute jsval jobTitle; // DOMString[]
attribute jsval bday; // Date
attribute jsval note; // DOMString[]
attribute jsval impp; // ContactField[]
attribute jsval anniversary; // Date
attribute DOMString sex; // DOMString
attribute DOMString genderIdentity; // DOMString
attribute jsval key; // DOMString[]
};

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

@ -1,41 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
#include "nsIContactProperties.idl"
#include "nsIDOMEventTarget.idl"
interface nsIArray;
interface nsIDOMDOMRequest;
interface nsIDOMDOMCursor;
[scriptable, uuid(72a5ee28-81d8-4af8-90b3-ae935396cc66)]
interface nsIDOMContact : nsIContactProperties
{
attribute DOMString id;
readonly attribute jsval published;
readonly attribute jsval updated;
void init(in nsIContactProperties properties); // Workaround BUG 723206
};
[scriptable, uuid(8beb3a66-d70a-4111-b216-b8e995ad3aff)]
interface nsIDOMContactManager : nsISupports
{
nsIDOMDOMRequest find(in nsIContactFindOptions options);
nsIDOMDOMCursor getAll(in nsIContactFindSortOptions options);
nsIDOMDOMRequest clear();
nsIDOMDOMRequest save(in nsIDOMContact contact);
nsIDOMDOMRequest remove(in nsIDOMContact contact);
attribute nsIDOMEventListener oncontactchange;
nsIDOMDOMRequest getRevision();
nsIDOMDOMRequest getCount();
};

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

@ -242,7 +242,7 @@ nsresult
NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetInputEvent* aEvent);
mozilla::WidgetMouseEvent* aEvent);
nsresult
NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
@ -252,7 +252,7 @@ nsresult
NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
mozilla::WidgetInputEvent* aEvent);
mozilla::WidgetMouseScrollEvent* aEvent);
nsresult
NS_NewDOMWheelEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,

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

@ -626,10 +626,10 @@ TabParent::MapEventCoordinatesForChildProcess(
aEvent->refPoint = aOffset;
} else {
aEvent->refPoint = LayoutDeviceIntPoint();
WidgetTouchEvent* touchEvent = static_cast<WidgetTouchEvent*>(aEvent);
// Then offset all the touch points by that distance, to put them
// in the space where top-left is 0,0.
const nsTArray< nsRefPtr<Touch> >& touches = touchEvent->touches;
const nsTArray< nsRefPtr<Touch> >& touches =
aEvent->AsTouchEvent()->touches;
for (uint32_t i = 0; i < touches.Length(); ++i) {
Touch* touch = touches[i];
if (touch) {
@ -741,7 +741,7 @@ TabParent::TryCapture(const WidgetGUIEvent& aEvent)
return false;
}
WidgetTouchEvent event(static_cast<const WidgetTouchEvent&>(aEvent));
WidgetTouchEvent event(*aEvent.AsTouchEvent());
bool isTouchPointUp = (event.message == NS_TOUCH_END ||
event.message == NS_TOUCH_CANCEL);

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

@ -284,6 +284,9 @@ SystemMessageManager.prototype = {
if (aTopic === kSystemMessageInternalReady) {
this._registerManifest();
}
// Call the DOMRequestIpcHelper.observe method.
this.__proto__.__proto__.observe.call(this, aSubject, aTopic, aData);
},
_registerManifest: function sysMessMgr_registerManifest() {

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

@ -7,7 +7,6 @@
interfaces = [
'base',
'canvas',
'contacts',
'core',
'html',
'events',

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

@ -2335,8 +2335,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
#endif
#ifdef MOZ_WIDGET_QT
const WidgetKeyboardEvent& keyEvent =
static_cast<const WidgetKeyboardEvent&>(anEvent);
const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent();
memset( &event, 0, sizeof(event) );
event.time = anEvent.time;
@ -2497,8 +2496,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
case NS_KEY_EVENT:
{
const WidgetKeyboardEvent& keyEvent =
static_cast<const WidgetKeyboardEvent&>(anEvent);
const WidgetKeyboardEvent& keyEvent = *anEvent.AsKeyboardEvent();
LOG("Firing NS_KEY_EVENT %d %d\n", keyEvent.keyCode, keyEvent.charCode);
// pluginEvent is initialized by nsWindow::InitKeyEvent().
ANPEvent* pluginEvent = reinterpret_cast<ANPEvent*>(keyEvent.pluginEvent);

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

@ -176,11 +176,9 @@ nsJSEventListener::HandleEvent(nsIDOMEvent* aEvent)
Optional<uint32_t> columnNumber;
NS_ENSURE_TRUE(aEvent, NS_ERROR_UNEXPECTED);
WidgetEvent* event = aEvent->GetInternalNSEvent();
if (event->message == NS_LOAD_ERROR &&
event->eventStructType == NS_SCRIPT_ERROR_EVENT) {
InternalScriptErrorEvent *scriptEvent =
static_cast<InternalScriptErrorEvent*>(event);
InternalScriptErrorEvent* scriptEvent =
aEvent->GetInternalNSEvent()->AsScriptErrorEvent();
if (scriptEvent && scriptEvent->message == NS_LOAD_ERROR) {
errorMsg = scriptEvent->errorMsg;
msgOrEvent.SetAsString() = static_cast<nsAString*>(&errorMsg);

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

@ -1772,7 +1772,6 @@ RILContentHelper.prototype = {
delete this._windowsMap[message.requestId];
let contacts = message.contacts;
let result = contacts.map(function(c) {
let contact = Cc["@mozilla.org/contact;1"].createInstance(Ci.nsIDOMContact);
let prop = {name: [c.alphaId], tel: [{value: c.number}]};
if (c.email) {
@ -1785,7 +1784,7 @@ RILContentHelper.prototype = {
prop.tel.push({value: c.anr[i]});
}
contact.init(prop);
let contact = new window.mozContact(prop);
contact.id = message.iccid + c.recordId;
return contact;
});

170
dom/webidl/Contacts.webidl Normal file
Просмотреть файл

@ -0,0 +1,170 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[ChromeOnly, Constructor, JSImplementation="@mozilla.org/contactAddress;1"]
interface ContactAddress {
attribute object? type; // DOMString[]
attribute DOMString? streetAddress;
attribute DOMString? locality;
attribute DOMString? region;
attribute DOMString? postalCode;
attribute DOMString? countryName;
attribute boolean? pref;
[ChromeOnly]
void initialize(optional sequence<DOMString>? type,
optional DOMString streetAddress,
optional DOMString locality,
optional DOMString region,
optional DOMString postalCode,
optional DOMString countryName,
optional boolean pref);
};
dictionary ContactAddressInit {
sequence<DOMString>? type;
DOMString? streetAddress;
DOMString? locality;
DOMString? region;
DOMString? postalCode;
DOMString? countryName;
boolean? pref;
};
[ChromeOnly, Constructor, JSImplementation="@mozilla.org/contactField;1"]
interface ContactField {
attribute object? type; // DOMString[]
attribute DOMString? value;
attribute boolean? pref;
[ChromeOnly]
void initialize(optional sequence<DOMString>? type,
optional DOMString value,
optional boolean pref);
};
dictionary ContactFieldInit {
sequence<DOMString>? type;
DOMString? value;
boolean? pref;
};
[ChromeOnly, Constructor, JSImplementation="@mozilla.org/contactTelField;1"]
interface ContactTelField : ContactField {
attribute DOMString? carrier;
[ChromeOnly]
void initialize(optional sequence<DOMString>? type,
optional DOMString value,
optional DOMString? carrier,
optional boolean pref);
};
dictionary ContactTelFieldInit : ContactFieldInit {
DOMString? carrier;
};
dictionary ContactProperties {
Date? bday;
Date? anniversary;
DOMString? sex;
DOMString? genderIdentity;
sequence<Blob>? photo;
sequence<ContactAddressInit>? adr;
sequence<ContactFieldInit>? email;
sequence<ContactFieldInit>? url;
sequence<ContactFieldInit>? impp;
sequence<ContactTelFieldInit>? tel;
sequence<DOMString>? name;
sequence<DOMString>? honorificPrefix;
sequence<DOMString>? givenName;
sequence<DOMString>? additionalName;
sequence<DOMString>? familyName;
sequence<DOMString>? honorificSuffix;
sequence<DOMString>? nickname;
sequence<DOMString>? category;
sequence<DOMString>? org;
sequence<DOMString>? jobTitle;
sequence<DOMString>? note;
sequence<DOMString>? key;
};
[Constructor(optional ContactProperties properties),
JSImplementation="@mozilla.org/contact;1"]
interface mozContact {
attribute DOMString id;
readonly attribute Date? published;
readonly attribute Date? updated;
attribute Date? bday;
attribute Date? anniversary;
attribute DOMString? sex;
attribute DOMString? genderIdentity;
attribute object? photo;
attribute object? adr;
attribute object? email;
attribute object? url;
attribute object? impp;
attribute object? tel;
attribute object? name;
attribute object? honorificPrefix;
attribute object? givenName;
attribute object? additionalName;
attribute object? familyName;
attribute object? honorificSuffix;
attribute object? nickname;
attribute object? category;
attribute object? org;
attribute object? jobTitle;
attribute object? note;
attribute object? key;
[ChromeOnly]
void setMetadata(DOMString id, Date? published, Date? updated);
jsonifier;
};
dictionary ContactFindSortOptions {
DOMString sortBy; // "givenName" or "familyName"
DOMString sortOrder = "ascending"; // e.g. "descending"
};
dictionary ContactFindOptions : ContactFindSortOptions {
DOMString filterValue; // e.g. "Tom"
DOMString filterOp; // e.g. "startsWith"
any filterBy; // e.g. ["givenName", "nickname"]
unsigned long filterLimit = 0;
};
[NoInterfaceObject, NavigatorProperty="mozContacts",
JSImplementation="@mozilla.org/contactManager;1"]
interface ContactManager : EventTarget {
DOMRequest find(optional ContactFindOptions options);
DOMCursor getAll(optional ContactFindSortOptions options);
DOMRequest clear();
DOMRequest save(mozContact contact);
DOMRequest remove(mozContact contact);
DOMRequest getRevision();
DOMRequest getCount();
attribute EventHandler oncontactchange;
};

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

@ -59,6 +59,7 @@ WEBIDL_FILES = [
'CommandEvent.webidl',
'Comment.webidl',
'CompositionEvent.webidl',
'Contacts.webidl',
'ConvolverNode.webidl',
'Coordinates.webidl',
'DOMCursor.webidl',

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

@ -4809,7 +4809,8 @@ nsEditor::HandleKeyPressEvent(nsIDOMKeyEvent* aKeyEvent)
// And also when you add new key handling, you need to change the subclass's
// HandleKeyPressEvent()'s switch statement.
WidgetKeyboardEvent* nativeKeyEvent = GetNativeKeyEvent(aKeyEvent);
WidgetKeyboardEvent* nativeKeyEvent =
aKeyEvent->GetInternalNSEvent()->AsKeyboardEvent();
NS_ENSURE_TRUE(nativeKeyEvent, NS_ERROR_UNEXPECTED);
NS_ASSERTION(nativeKeyEvent->message == NS_KEY_PRESS,
"HandleKeyPressEvent gets non-keypress event");
@ -5162,16 +5163,6 @@ nsEditor::IsModifiableNode(nsINode *aNode)
return true;
}
WidgetKeyboardEvent*
nsEditor::GetNativeKeyEvent(nsIDOMKeyEvent* aDOMKeyEvent)
{
NS_ENSURE_TRUE(aDOMKeyEvent, nullptr);
WidgetEvent* nativeEvent = aDOMKeyEvent->GetInternalNSEvent();
NS_ENSURE_TRUE(nativeEvent, nullptr);
NS_ENSURE_TRUE(nativeEvent->eventStructType == NS_KEY_EVENT, nullptr);
return static_cast<WidgetKeyboardEvent*>(nativeEvent);
}
already_AddRefed<nsIContent>
nsEditor::GetFocusedContent()
{

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше