From 0a6fd85ac1b3c1e22a5c216e5fcbf7d192a5fc20 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 19 Apr 2018 11:39:02 -0500 Subject: Force use of level 1 Liftetime DSE optimization on modern GCC Instead of completely disabling it. --- build/autoconf/compiler-opts.m4 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 index 57a974435..d4016b609 100644 --- a/build/autoconf/compiler-opts.m4 +++ b/build/autoconf/compiler-opts.m4 @@ -183,16 +183,15 @@ if test "$GNU_CC"; then case "$CC_VERSION" in 4.*) ;; + 5.*) + ;; *) # Lifetime Dead Store Elimination level 2 (default in GCC6+) breaks Gecko. - # Ideally, we'd use -flifetime-dse=1, but that means we'd forcefully - # enable it on optimization levels where it would otherwise not be enabled. - # So we disable it entirely. But since that would mean inconsistency with - # GCC5, which has level 1 depending on optimization level, disable it on - # GCC5 as well, because better safe than sorry. + # Instead of completely disabling this optimization on newer GCC's, + # we'll force them to use level 1 optimization with -flifetime-dse=1. # Add it first so that a mozconfig can override by setting CFLAGS/CXXFLAGS. - CFLAGS="-fno-lifetime-dse $CFLAGS" - CXXFLAGS="-fno-lifetime-dse $CXXFLAGS" + CFLAGS="-flifetime-dse=1 $CFLAGS" + CXXFLAGS="-flifetime-dse=1 $CXXFLAGS" ;; esac fi -- cgit v1.2.3 From c5a52404bd6206a481aedc61ea21f9dccf93377a Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 20 Apr 2018 08:27:35 -0500 Subject: Style fix --- build/autoconf/compiler-opts.m4 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 index d4016b609..c47d792f4 100644 --- a/build/autoconf/compiler-opts.m4 +++ b/build/autoconf/compiler-opts.m4 @@ -181,9 +181,7 @@ if test "$GNU_CC"; then if test -z "$CLANG_CC"; then case "$CC_VERSION" in - 4.*) - ;; - 5.*) + 4.* | 5.*) ;; *) # Lifetime Dead Store Elimination level 2 (default in GCC6+) breaks Gecko. -- cgit v1.2.3 From 0b2e4f1afad41e638bce2c631c7bc895ba6c0c69 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 20 Apr 2018 17:39:09 +0200 Subject: moebius#217: WebExtensions - Implemented "runtime.onMessageExternal"/"onConnectExternal" https://github.com/MoonchildProductions/moebius/pull/217 --- .../components/webextensions/ExtensionChild.jsm | 28 +++- .../components/webextensions/ExtensionCommon.jsm | 3 +- .../components/webextensions/ExtensionContent.jsm | 2 +- .../webextensions/LegacyExtensionsUtils.jsm | 2 +- toolkit/components/webextensions/ext-c-runtime.js | 5 +- .../components/webextensions/schemas/runtime.json | 2 - .../webextensions/test/mochitest/mochitest.ini | 1 + .../test/mochitest/test_ext_all_apis.js | 2 + .../mochitest/test_ext_external_messaging.html | 111 ++++++++++++++++ .../mochitest/test_ext_sendmessage_reply2.html | 144 +++++++++++++++++---- .../xpcshell/test_ext_legacy_extension_context.js | 4 +- 11 files changed, 262 insertions(+), 42 deletions(-) create mode 100644 toolkit/components/webextensions/test/mochitest/test_ext_external_messaging.html diff --git a/toolkit/components/webextensions/ExtensionChild.jsm b/toolkit/components/webextensions/ExtensionChild.jsm index c953dd685..5dc4e2277 100644 --- a/toolkit/components/webextensions/ExtensionChild.jsm +++ b/toolkit/components/webextensions/ExtensionChild.jsm @@ -325,7 +325,7 @@ class Messenger { return this.sendMessage(messageManager, msg, recipient, responseCallback); } - onMessage(name) { + _onMessage(name, filter) { return new SingletonEventManager(this.context, name, callback => { let listener = { messageFilterPermissive: this.optionalFilter, @@ -333,7 +333,8 @@ class Messenger { filterMessage: (sender, recipient) => { // Ignore the message if it was sent by this Messenger. - return sender.contextId !== this.context.contextId; + return (sender.contextId !== this.context.contextId && + filter(sender, recipient)); }, receiveMessage: ({target, data: message, sender, recipient}) => { @@ -373,6 +374,14 @@ class Messenger { }).api(); } + onMessage(name) { + return this._onMessage(name, sender => sender.id === this.sender.id); + } + + onMessageExternal(name) { + return this._onMessage(name, sender => sender.id !== this.sender.id); + } + _connect(messageManager, port, recipient) { let msg = { name: port.name, @@ -407,7 +416,7 @@ class Messenger { return this._connect(messageManager, port, recipient); } - onConnect(name) { + _onConnect(name, filter) { return new SingletonEventManager(this.context, name, callback => { let listener = { messageFilterPermissive: this.optionalFilter, @@ -415,7 +424,8 @@ class Messenger { filterMessage: (sender, recipient) => { // Ignore the port if it was created by this Messenger. - return sender.contextId !== this.context.contextId; + return (sender.contextId !== this.context.contextId && + filter(sender, recipient)); }, receiveMessage: ({target, data: message, sender}) => { @@ -438,6 +448,14 @@ class Messenger { }; }).api(); } + + onConnect(name) { + return this._onConnect(name, sender => sender.id === this.sender.id); + } + + onConnectExternal(name) { + return this._onConnect(name, sender => sender.id !== this.sender.id); + } } var apiManager = new class extends SchemaAPIManager { @@ -745,7 +763,7 @@ class ExtensionPageContextChild extends BaseContext { // This is the MessageSender property passed to extension. // It can be augmented by the "page-open" hook. - let sender = {id: extension.uuid}; + let sender = {id: extension.id}; if (viewType == "tab") { sender.tabId = tabId; this.tabId = tabId; diff --git a/toolkit/components/webextensions/ExtensionCommon.jsm b/toolkit/components/webextensions/ExtensionCommon.jsm index a339fb27e..9ec84b5c7 100644 --- a/toolkit/components/webextensions/ExtensionCommon.jsm +++ b/toolkit/components/webextensions/ExtensionCommon.jsm @@ -197,10 +197,9 @@ class BaseContext { * @returns {Promise} */ sendMessage(target, messageName, data, options = {}) { - options.recipient = options.recipient || {}; + options.recipient = Object.assign({extensionId: this.extension.id}, options.recipient); options.sender = options.sender || {}; - options.recipient.extensionId = this.extension.id; options.sender.extensionId = this.extension.id; options.sender.contextId = this.contextId; diff --git a/toolkit/components/webextensions/ExtensionContent.jsm b/toolkit/components/webextensions/ExtensionContent.jsm index 9b9a02091..5bdcde6f5 100644 --- a/toolkit/components/webextensions/ExtensionContent.jsm +++ b/toolkit/components/webextensions/ExtensionContent.jsm @@ -456,7 +456,7 @@ class ContentScriptContextChild extends BaseContext { defineLazyGetter(ContentScriptContextChild.prototype, "messenger", function() { // The |sender| parameter is passed directly to the extension. - let sender = {id: this.extension.uuid, frameId: this.frameId, url: this.url}; + let sender = {id: this.extension.id, frameId: this.frameId, url: this.url}; let filter = {extensionId: this.extension.id}; let optionalFilter = {frameId: this.frameId}; diff --git a/toolkit/components/webextensions/LegacyExtensionsUtils.jsm b/toolkit/components/webextensions/LegacyExtensionsUtils.jsm index 7632548e3..e8d276fe9 100644 --- a/toolkit/components/webextensions/LegacyExtensionsUtils.jsm +++ b/toolkit/components/webextensions/LegacyExtensionsUtils.jsm @@ -64,7 +64,7 @@ var LegacyExtensionContext = class extends BaseContext { {value: cloneScope, enumerable: true, configurable: true, writable: true} ); - let sender = {id: targetExtension.uuid}; + let sender = {id: targetExtension.id}; let filter = {extensionId: targetExtension.id}; // Legacy addons live in the main process. Messages from other addons are // Messages from WebExtensions are sent to the main process and forwarded via diff --git a/toolkit/components/webextensions/ext-c-runtime.js b/toolkit/components/webextensions/ext-c-runtime.js index 8adca60ca..1dcac35da 100644 --- a/toolkit/components/webextensions/ext-c-runtime.js +++ b/toolkit/components/webextensions/ext-c-runtime.js @@ -9,6 +9,10 @@ function runtimeApiFactory(context) { onMessage: context.messenger.onMessage("runtime.onMessage"), + onConnectExternal: context.messenger.onConnectExternal("runtime.onConnectExternal"), + + onMessageExternal: context.messenger.onMessageExternal("runtime.onMessageExternal"), + connect: function(extensionId, connectInfo) { let name = connectInfo !== null && connectInfo.name || ""; extensionId = extensionId || extension.id; @@ -47,7 +51,6 @@ function runtimeApiFactory(context) { if (options != null && typeof options != "object") { return Promise.reject({message: "runtime.sendMessage's options argument is invalid"}); } - // TODO(robwu): Validate option keys and values when we support it. extensionId = extensionId || extension.id; let recipient = {extensionId}; diff --git a/toolkit/components/webextensions/schemas/runtime.json b/toolkit/components/webextensions/schemas/runtime.json index b3f12a768..575df7d27 100644 --- a/toolkit/components/webextensions/schemas/runtime.json +++ b/toolkit/components/webextensions/schemas/runtime.json @@ -535,7 +535,6 @@ }, { "name": "onConnectExternal", - "unsupported": true, "type": "function", "description": "Fired when a connection is made from another extension.", "parameters": [ @@ -560,7 +559,6 @@ }, { "name": "onMessageExternal", - "unsupported": true, "type": "function", "description": "Fired when a message is sent from another extension/app. Cannot be used in a content script.", "parameters": [ diff --git a/toolkit/components/webextensions/test/mochitest/mochitest.ini b/toolkit/components/webextensions/test/mochitest/mochitest.ini index 45586237e..1f61060ad 100644 --- a/toolkit/components/webextensions/test/mochitest/mochitest.ini +++ b/toolkit/components/webextensions/test/mochitest/mochitest.ini @@ -59,6 +59,7 @@ skip-if = os == 'android' # Android does not support tabs API. Bug 1260250 [test_ext_contentscript_teardown.html] skip-if = (os == 'android') # Android does not support tabs API. Bug 1260250 [test_ext_exclude_include_globs.html] +[test_ext_external_messaging.html] [test_ext_i18n_css.html] [test_ext_generate.html] [test_ext_notifications.html] diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js b/toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js index 0f617c37e..25d04b36b 100644 --- a/toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js +++ b/toolkit/components/webextensions/test/mochitest/test_ext_all_apis.js @@ -75,7 +75,9 @@ let expectedBackgroundApis = [ "runtime.getBackgroundPage", "runtime.getBrowserInfo", "runtime.getPlatformInfo", + "runtime.onConnectExternal", "runtime.onInstalled", + "runtime.onMessageExternal", "runtime.onStartup", "runtime.onUpdateAvailable", "runtime.openOptionsPage", diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_external_messaging.html b/toolkit/components/webextensions/test/mochitest/test_ext_external_messaging.html new file mode 100644 index 000000000..dfc1f9427 --- /dev/null +++ b/toolkit/components/webextensions/test/mochitest/test_ext_external_messaging.html @@ -0,0 +1,111 @@ + + + + WebExtension external messaging + + + + + + + + + + + + diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html index 1ebc1b40f..5c350be2f 100644 --- a/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html +++ b/toolkit/components/webextensions/test/mochitest/test_ext_sendmessage_reply2.html @@ -13,48 +13,119 @@ diff --git a/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js b/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js index 63d5361a1..770851472 100644 --- a/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js +++ b/toolkit/components/webextensions/test/xpcshell/test_ext_legacy_extension_context.js @@ -108,7 +108,7 @@ add_task(function* test_legacy_extension_context() { "Got the expected message"); ok(msgSender, "Got a message sender object"); - equal(msgSender.id, extensionInfo.uuid, "The sender has the expected id property"); + equal(msgSender.id, extension.id, "The sender has the expected id property"); equal(msgSender.url, extensionInfo.bgURL, "The sender has the expected url property"); // Wait confirmation that the reply has been received. @@ -136,7 +136,7 @@ add_task(function* test_legacy_extension_context() { ok(port, "Got the Port API object"); ok(port.sender, "The port has a sender property"); - equal(port.sender.id, extensionInfo.uuid, + equal(port.sender.id, extension.id, "The port sender has the expected id property"); equal(port.sender.url, extensionInfo.bgURL, "The port sender has the expected url property"); -- cgit v1.2.3 From 11c9f20ea8e15cb5ef51c5cab0863d311ac00025 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 20 Apr 2018 18:08:43 +0200 Subject: moebius#219: WebExtensions - add-on throws error on load when suggested_key is null / missing https://github.com/MoonchildProductions/moebius/pull/219 --- browser/components/webextensions/ext-commands.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/browser/components/webextensions/ext-commands.js b/browser/components/webextensions/ext-commands.js index 416544e86..3f0bf8d1a 100644 --- a/browser/components/webextensions/ext-commands.js +++ b/browser/components/webextensions/ext-commands.js @@ -74,15 +74,14 @@ CommandList.prototype = { // For Windows, chrome.runtime expects 'win' while chrome.commands // expects 'windows'. We can special case this for now. let os = PlatformInfo.os == "win" ? "windows" : PlatformInfo.os; - for (let name of Object.keys(manifest.commands)) { - let command = manifest.commands[name]; - let shortcut = command.suggested_key[os] || command.suggested_key.default; - if (shortcut) { - commands.set(name, { - description: command.description, - shortcut: shortcut.replace(/\s+/g, ""), - }); - } + for (let [name, command] of Object.entries(manifest.commands)) { + let suggested_key = command.suggested_key || {}; + let shortcut = suggested_key[os] || suggested_key.default; + shortcut = shortcut ? shortcut.replace(/\s+/g, "") : null; + commands.set(name, { + description: command.description, + shortcut, + }); } return commands; }, @@ -96,8 +95,10 @@ CommandList.prototype = { let keyset = doc.createElementNS(XUL_NS, "keyset"); keyset.id = `ext-keyset-id-${this.id}`; this.commands.forEach((command, name) => { - let keyElement = this.buildKey(doc, name, command.shortcut); - keyset.appendChild(keyElement); + if (command.shortcut) { + let keyElement = this.buildKey(doc, name, command.shortcut); + keyset.appendChild(keyElement); + } }); doc.documentElement.appendChild(keyset); this.keysetsMap.set(window, keyset); -- cgit v1.2.3 From 04c7949bc3da9e02e563436d7d772424c5492a69 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 20 Apr 2018 19:16:00 +0200 Subject: Bug 1317030 - Removing/reattaching an element from the DOM triggers spurious mouseenter events native in moebius --- dom/events/EventStateManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index c23cdb575..f66cf3f90 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -4034,7 +4034,7 @@ public: } } - ~EnterLeaveDispatcher() + void Dispatch() { if (mEventMessage == eMouseEnter || mEventMessage == ePointerEnter) { for (int32_t i = mTargets.Count() - 1; i >= 0; --i) { @@ -4119,6 +4119,7 @@ EventStateManager::NotifyMouseOut(WidgetMouseEvent* aMouseEvent, // Fire mouseout DispatchMouseOrPointerEvent(aMouseEvent, isPointer ? ePointerOut : eMouseOut, wrapper->mLastOverElement, aMovingInto); + leaveDispatcher.Dispatch(); wrapper->mLastOverFrame = nullptr; wrapper->mLastOverElement = nullptr; @@ -4193,6 +4194,7 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, DispatchMouseOrPointerEvent(aMouseEvent, isPointer ? ePointerOver : eMouseOver, aContent, lastOverElement); + enterDispatcher->Dispatch(); wrapper->mLastOverElement = aContent; } else { wrapper->mLastOverFrame = nullptr; -- cgit v1.2.3 From d4feeb474eeedbd9e90356d36bb2ae70dc7808a1 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 20 Apr 2018 19:44:42 +0200 Subject: Bug 1322994 - Update pointerevent web-platform-tests (partially - depends on) https://github.com/MoonchildProductions/moebius/pull/71 --- ...ercapture_events_to_original_target-manual.html | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html b/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html index f4d5573ed..31fe919af 100644 --- a/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html +++ b/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html @@ -1,4 +1,4 @@ - + Pointer Event: releasePointerCapture() - subsequent events follow normal hitting testing mechanisms @@ -14,17 +14,21 @@ +

Pointer Event: releasePointerCapture() - subsequent events follow normal hitting testing mechanisms

- Use mouse, touch or pen to contact here and move around.

Test complete: Scroll to Summary to view Pass/Fail Results.

diff --git a/dom/events/test/pointerevents/test_bug1285128.html b/dom/events/test/pointerevents/test_bug1285128.html index f7f1eb698..9577940c1 100644 --- a/dom/events/test/pointerevents/test_bug1285128.html +++ b/dom/events/test/pointerevents/test_bug1285128.html @@ -13,7 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1285128 Mozilla Bug 1285128

-
+
+
+ + + + +

+ + + diff --git a/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html b/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html index 5eb631f6a..2b08e2bb8 100644 --- a/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html +++ b/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html @@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870 function executeTest(int_win) { sendMouseEvent(int_win, "target0", "mousemove"); sendMouseEvent(int_win, "target1", "mousemove"); + sendMouseEvent(int_win, "btnCapture", "mousemove"); sendMouseEvent(int_win, "btnCapture", "mousedown"); sendMouseEvent(int_win, "target1", "mousemove"); sendMouseEvent(int_win, "target0", "mousemove"); diff --git a/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html b/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html index cbf91df74..35350e016 100644 --- a/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html +++ b/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html @@ -17,9 +17,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870 runTestInNewWindow("pointerevent_releasepointercapture_events_to_original_target-manual.html"); } function executeTest(int_win) { - sendTouchEvent(int_win, "target0", "touchstart"); - sendTouchEvent(int_win, "target0", "touchmove"); - sendTouchEvent(int_win, "target0", "touchend"); + // Synthesize mouse events to run this test. + sendMouseEvent(int_win, "target0", "mousemove"); + sendMouseEvent(int_win, "target0", "mousedown"); + sendMouseEvent(int_win, "target0", "mousemove", {buttons: 1}); + sendMouseEvent(int_win, "target0", "mousemove", {buttons: 1}); + sendMouseEvent(int_win, "target0", "mouseup"); + + window.addEventListener("message", function(aEvent) { + if (aEvent.data == "Test Touch") { + // Synthesize touch events to run this test. + sendTouchEvent(int_win, "target0", "touchstart"); + sendTouchEvent(int_win, "target0", "touchmove"); + sendTouchEvent(int_win, "target0", "touchend"); + window.postMessage("Test Pen", "*"); + } else if (aEvent.data == "Test Pen") { + // Synthesize pen events to run this test. + sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN}); + sendMouseEvent(int_win, "target0", "mousedown", {inputSource:MouseEvent.MOZ_SOURCE_PEN}); + sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN, buttons: 1}); + sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN, buttons: 1}); + sendMouseEvent(int_win, "target0", "mouseup", {inputSource:MouseEvent.MOZ_SOURCE_PEN}); + } + }); + window.postMessage("Test Touch", "*"); } diff --git a/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html b/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html index 0883d616b..09e97ec97 100644 --- a/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html +++ b/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html @@ -19,8 +19,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870 function executeTest(int_win) { sendMouseEvent(int_win, "target1", "mousemove"); sendMouseEvent(int_win, "btnCapture", "mousedown"); - sendMouseEvent(int_win, "target1", "mousemove"); - sendMouseEvent(int_win, "target1", "mouseup"); + sendMouseEvent(int_win, "btnCapture", "mousemove"); + sendMouseEvent(int_win, "btnCapture", "mouseup"); } diff --git a/dom/webidl/PointerEvent.webidl b/dom/webidl/PointerEvent.webidl index 2e83922c8..4e8a0eb90 100644 --- a/dom/webidl/PointerEvent.webidl +++ b/dom/webidl/PointerEvent.webidl @@ -17,8 +17,10 @@ interface PointerEvent : MouseEvent readonly attribute long width; readonly attribute long height; readonly attribute float pressure; + readonly attribute float tangentialPressure; readonly attribute long tiltX; readonly attribute long tiltY; + readonly attribute long twist; readonly attribute DOMString pointerType; readonly attribute boolean isPrimary; }; @@ -29,8 +31,10 @@ dictionary PointerEventInit : MouseEventInit long width = 1; long height = 1; float pressure = 0; + float tangentialPressure = 0; long tiltX = 0; long tiltY = 0; + long twist = 0; DOMString pointerType = ""; boolean isPrimary = false; }; diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index cbbae0e8f..5990402ed 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -1298,11 +1298,11 @@ public: } }; - static void DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture, - uint32_t aPointerId, - uint16_t aPointerType, - bool aIsPrimary, - nsIContent* aCaptureTarget); + static void DispatchGotOrLostPointerCaptureEvent( + bool aIsGotCapture, + const mozilla::WidgetPointerEvent* aPointerEvent, + nsIContent* aCaptureTarget); + static PointerCaptureInfo* GetPointerCaptureInfo(uint32_t aPointerId); static void SetPointerCapturingContent(uint32_t aPointerId, nsIContent* aContent); @@ -1311,8 +1311,8 @@ public: // CheckPointerCaptureState checks cases, when got/lostpointercapture events // should be fired. - static void CheckPointerCaptureState(uint32_t aPointerId, - uint16_t aPointerType, bool aIsPrimary); + static void CheckPointerCaptureState( + const mozilla::WidgetPointerEvent* aPointerEvent); // GetPointerInfo returns true if pointer with aPointerId is situated in // device, false otherwise. diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 56ac370b9..63dfbd8a3 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -6514,10 +6514,11 @@ nsIPresShell::GetPointerCapturingContent(uint32_t aPointerId) } /* static */ void -nsIPresShell::CheckPointerCaptureState(uint32_t aPointerId, - uint16_t aPointerType, bool aIsPrimary) +nsIPresShell::CheckPointerCaptureState(const WidgetPointerEvent* aPointerEvent) { - PointerCaptureInfo* captureInfo = GetPointerCaptureInfo(aPointerId); + PointerCaptureInfo* captureInfo = + GetPointerCaptureInfo(aPointerEvent->pointerId); + if (captureInfo && captureInfo->mPendingContent != captureInfo->mOverrideContent) { // cache captureInfo->mPendingContent since it may be changed in the pointer @@ -6525,17 +6526,16 @@ nsIPresShell::CheckPointerCaptureState(uint32_t aPointerId, nsIContent* pendingContent = captureInfo->mPendingContent.get(); if (captureInfo->mOverrideContent) { DispatchGotOrLostPointerCaptureEvent(/* aIsGotCapture */ false, - aPointerId, aPointerType, aIsPrimary, + aPointerEvent, captureInfo->mOverrideContent); } if (pendingContent) { - DispatchGotOrLostPointerCaptureEvent(/* aIsGotCapture */ true, aPointerId, - aPointerType, aIsPrimary, - pendingContent); + DispatchGotOrLostPointerCaptureEvent(/* aIsGotCapture */ true, + aPointerEvent, pendingContent); } captureInfo->mOverrideContent = pendingContent; if (captureInfo->Empty()) { - sPointerCaptureList->Remove(aPointerId); + sPointerCaptureList->Remove(aPointerEvent->pointerId); } } } @@ -6976,37 +6976,30 @@ DispatchPointerFromMouseOrTouch(PresShell* aShell, return NS_OK; } -class ReleasePointerCaptureCaller +class ReleasePointerCaptureCaller final { public: - ReleasePointerCaptureCaller() : - mPointerId(0), - mPointerType(nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN), - mIsPrimary(false), - mIsSet(false) + ReleasePointerCaptureCaller() + : mPointerEvent(nullptr) { } ~ReleasePointerCaptureCaller() { - if (mIsSet) { - nsIPresShell::ReleasePointerCapturingContent(mPointerId); - nsIPresShell::CheckPointerCaptureState(mPointerId, mPointerType, - mIsPrimary); + if (mPointerEvent) { + nsIPresShell::ReleasePointerCapturingContent(mPointerEvent->pointerId); + nsIPresShell::CheckPointerCaptureState(mPointerEvent); } } - void SetTarget(uint32_t aPointerId, uint16_t aPointerType, bool aIsPrimary) + + void SetTarget(const WidgetPointerEvent* aPointerEvent) { - mPointerId = aPointerId; - mPointerType = aPointerType; - mIsPrimary = aIsPrimary; - mIsSet = true; + MOZ_ASSERT(aPointerEvent); + mPointerEvent = aPointerEvent; } private: - int32_t mPointerId; - uint16_t mPointerType; - bool mIsPrimary; - bool mIsSet; + // This is synchronously used inside PresShell::HandleEvent. + const WidgetPointerEvent* mPointerEvent; }; static bool @@ -7719,9 +7712,7 @@ PresShell::HandleEvent(nsIFrame* aFrame, nsWeakFrame frameKeeper(frame); // Handle pending pointer capture before any pointer events except // gotpointercapture / lostpointercapture. - CheckPointerCaptureState(pointerEvent->pointerId, - pointerEvent->inputSource, - pointerEvent->mIsPrimary); + CheckPointerCaptureState(pointerEvent); // Prevent application crashes, in case damaged frame. if (!frameKeeper.IsAlive()) { frame = nullptr; @@ -7742,33 +7733,29 @@ PresShell::HandleEvent(nsIFrame* aFrame, } } - if (aEvent->mClass == ePointerEventClass && - aEvent->mMessage != ePointerDown) { - if (WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent()) { - uint32_t pointerId = pointerEvent->pointerId; + // Mouse events should be fired to the same target as their mapped pointer + // events + if ((aEvent->mClass == ePointerEventClass || + aEvent->mClass == eMouseEventClass) && + aEvent->mMessage != ePointerDown && aEvent->mMessage != eMouseDown) { + if (WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent()) { + uint32_t pointerId = mouseEvent->pointerId; nsIContent* pointerCapturingContent = GetPointerCapturingContent(pointerId); if (pointerCapturingContent) { if (nsIFrame* capturingFrame = pointerCapturingContent->GetPrimaryFrame()) { - // If pointer capture is set, we should suppress - // pointerover/pointerenter events for all elements except element - // which have pointer capture. (Code in EventStateManager) - pointerEvent->retargetedByPointerCapture = - frame && frame->GetContent() && - !nsContentUtils::ContentIsDescendantOf(frame->GetContent(), - pointerCapturingContent); frame = capturingFrame; } - if (pointerEvent->mMessage == ePointerUp || - pointerEvent->mMessage == ePointerCancel) { + if (aEvent->mMessage == ePointerUp || + aEvent->mMessage == ePointerCancel) { // Implicitly releasing capture for given pointer. // ePointerLostCapture should be send after ePointerUp or // ePointerCancel. - releasePointerCaptureCaller.SetTarget(pointerId, - pointerEvent->inputSource, - pointerEvent->mIsPrimary); + WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent(); + MOZ_ASSERT(pointerEvent); + releasePointerCaptureCaller.SetTarget(pointerEvent); } } } @@ -8340,35 +8327,44 @@ PresShell::HandleEventInternal(WidgetEvent* aEvent, return rv; } -void -nsIPresShell::DispatchGotOrLostPointerCaptureEvent(bool aIsGotCapture, - uint32_t aPointerId, - uint16_t aPointerType, - bool aIsPrimary, - nsIContent* aCaptureTarget) -{ - PointerEventInit init; - init.mPointerId = aPointerId; - init.mBubbles = true; - ConvertPointerTypeToString(aPointerType, init.mPointerType); - init.mIsPrimary = aIsPrimary; - RefPtr event; - event = PointerEvent::Constructor(aCaptureTarget, - aIsGotCapture - ? NS_LITERAL_STRING("gotpointercapture") - : NS_LITERAL_STRING("lostpointercapture"), - init); - if (event) { +/* static */ void +nsIPresShell::DispatchGotOrLostPointerCaptureEvent( + bool aIsGotCapture, + const WidgetPointerEvent* aPointerEvent, + nsIContent* aCaptureTarget) +{ + nsIDocument* targetDoc = aCaptureTarget->OwnerDoc(); + nsCOMPtr shell = targetDoc->GetShell(); + NS_ENSURE_TRUE_VOID(shell); + + if (!aIsGotCapture && !aCaptureTarget->IsInUncomposedDoc()) { + // If the capturing element was removed from the DOM tree, fire + // ePointerLostCapture at the document. + PointerEventInit init; + init.mPointerId = aPointerEvent->pointerId; + init.mBubbles = true; + init.mComposed = true; + ConvertPointerTypeToString(aPointerEvent->inputSource, init.mPointerType); + init.mIsPrimary = aPointerEvent->mIsPrimary; + RefPtr event; + event = PointerEvent::Constructor(aCaptureTarget, + NS_LITERAL_STRING("lostpointercapture"), + init); bool dummy; - // If the capturing element was removed from the DOM tree, - // lostpointercapture event should be fired at the document. - if (!aIsGotCapture && !aCaptureTarget->IsInUncomposedDoc()) { - aCaptureTarget->OwnerDoc()->DispatchEvent(event->InternalDOMEvent(), - &dummy); - } else { - aCaptureTarget->DispatchEvent(event->InternalDOMEvent(), &dummy); - } + targetDoc->DispatchEvent(event->InternalDOMEvent(), &dummy); + return; } + nsEventStatus status = nsEventStatus_eIgnore; + WidgetPointerEvent localEvent(aPointerEvent->IsTrusted(), + aIsGotCapture ? ePointerGotCapture : + ePointerLostCapture, + aPointerEvent->mWidget); + localEvent.AssignPointerEventData(*aPointerEvent, true); + nsresult rv = shell->HandleEventWithTarget( + &localEvent, + aCaptureTarget->GetPrimaryFrame(), + aCaptureTarget, &status); + NS_ENSURE_SUCCESS_VOID(rv); } nsresult diff --git a/layout/base/tests/bug1078327_inner.html b/layout/base/tests/bug1078327_inner.html index 9e32fc996..0cfb9da7f 100644 --- a/layout/base/tests/bug1078327_inner.html +++ b/layout/base/tests/bug1078327_inner.html @@ -24,16 +24,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327 var test_mediator_move = false; var test_mediator_out = false; var test_listener = false; + var test_lost_capture = false; function TargetHandler(event) { logger("Target receive event: " + event.type + ". Mediator.setPointerCapture()"); mediator.setPointerCapture(event.pointerId); test_target = true; + test_capture = true; } function MediatorHandler(event) { logger("Mediator receive event: " + event.type); - if(event.type == "gotpointercapture") - test_capture = true; if(!test_capture) return; if(event.type == "pointermove") @@ -43,7 +43,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327 if(event.type == "pointerout") test_mediator_out++; if(event.type == "lostpointercapture") - test_capture = false; + test_lost_capture = true; } function ListenerHandler(event) { logger("Listener receive event: " + event.type); @@ -86,7 +86,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327 } function finishTest() { parent.is(test_target, true, "pointerdown event should be received by target"); - parent.is(test_capture, false, "test_capture should be false at the end of the test"); + parent.is(test_lost_capture, true, "mediator should receive lostpointercapture"); parent.is(test_mediator_over, 1, "mediator should receive pointerover event only once"); parent.is(test_mediator_move, 5, "mediator should receive pointermove event five times"); parent.is(test_mediator_out, 1, "mediator should receive pointerout event only once"); diff --git a/layout/base/tests/bug1162990_inner_1.html b/layout/base/tests/bug1162990_inner_1.html index 4ea5edb5c..0f950df8d 100644 --- a/layout/base/tests/bug1162990_inner_1.html +++ b/layout/base/tests/bug1162990_inner_1.html @@ -111,10 +111,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162990 } function finishTest() { - parent.is(test_basketLeave, 0, "Part1: basket should not receive pointerleave event after pointer capturing"); + parent.is(test_basketLeave, 1, "Part1: basket should receive pointerleave event after pointer capturing"); parent.is(test_targetGotCapture, 1, "Part1: target should receive gotpointercapture event"); parent.is(test_targetLostCapture, 1, "Part1: target should receive lostpointercapture event"); - parent.is(test_targetLeave, 2, "Part1: target should receive pointerleave event two times"); + parent.is(test_targetLeave, 1, "Part1: target should receive pointerleave event only one time"); parent.is(test_childLeave, 0, "Part1: child should not receive pointerleave event after pointer capturing"); parent.is(test_listenerDown, 1, "Part1: listener should receive pointerdown event"); parent.is(test_listenerLeave, 1, "Part1: listener should receive pointerleave event only one time"); diff --git a/layout/base/tests/bug1162990_inner_2.html b/layout/base/tests/bug1162990_inner_2.html index 54aa74ca3..e418927bd 100644 --- a/layout/base/tests/bug1162990_inner_2.html +++ b/layout/base/tests/bug1162990_inner_2.html @@ -116,7 +116,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162990 parent.is(test_targetDown, 1, "Part2: target should receive pointerdown event"); parent.is(test_targetGotCapture, 1, "Part2: target should receive gotpointercapture event"); parent.is(test_targetLostCapture, 1, "Part2: target should receive lostpointercapture event"); - parent.is(test_targetLeave, 1, "Part2: target should receive pointerleave event"); + parent.is(test_targetLeave, 0, "Part2: target should not receive pointerleave event"); parent.is(test_childLeave, 0, "Part2: child should not receive pointerleave event after pointer capturing"); parent.is(test_listenerLeave, 0, "Part2: listener should not receive pointerleave event after pointer capturing"); logger("finishTest"); diff --git a/layout/base/tests/bug976963_inner.html b/layout/base/tests/bug976963_inner.html deleted file mode 100644 index 2c55fbccd..000000000 --- a/layout/base/tests/bug976963_inner.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - Test for Bug 976963 - - - - - - - - Mozilla Bug 976963 -

- -
div id=listener
-
div id=middler
-
div id=target
-
-  
- - diff --git a/layout/base/tests/bug977003_inner_5.html b/layout/base/tests/bug977003_inner_5.html index 70fc5ba40..81094043c 100644 --- a/layout/base/tests/bug977003_inner_5.html +++ b/layout/base/tests/bug977003_inner_5.html @@ -26,6 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139 var test_lost_listener = false; var test_lost_type = ""; var test_move_listener = false; + var test_over_listener = false; var test_listener = false; var test_lost_primary = false; @@ -53,6 +54,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139 logger("Receive event on Listener: " + event.type); test_move_listener = true; } + function ListenerOverHandler(event) { + logger("Receive event on Listener: " + event.type); + test_over_listener = true; + } function ListenerHandler(event) { logger("Receive event on Listener: " + event.type); test_listener = true; @@ -74,7 +79,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139 target.addEventListener("pointerdown", TargetDownHandler, false); listener.addEventListener("gotpointercapture", ListenerGotPCHandler, false); listener.addEventListener("lostpointercapture", ListenerLostPCHandler, false); - listener.addEventListener("pointerover", ListenerHandler, false); + listener.addEventListener("pointerover", ListenerOverHandler, false); listener.addEventListener("pointermove", ListenerMoveHandler, false); listener.addEventListener("pointerup", ListenerHandler, false); listener.addEventListener("pointerout", ListenerHandler, false); @@ -93,6 +98,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139 parent.is(test_lost_type, "touch", "Part 5: lostpointercapture event should have pointerType touch"); parent.is(test_lost_primary, true, "Part 5: lostpointercapture event should have isPrimary as true"); parent.is(test_move_listener, true, "Part 5: gotpointercapture should be triggered by pointermove"); + parent.is(test_over_listener, true, "Part 5: listener should receive pointerover when capturing pointer"); parent.is(test_listener, false, "Part 5: listener should not receive any other events"); logger("finishTest"); parent.finishTest(); diff --git a/layout/base/tests/bug977003_inner_6.html b/layout/base/tests/bug977003_inner_6.html index 12424b1f2..b60ca5c31 100644 --- a/layout/base/tests/bug977003_inner_6.html +++ b/layout/base/tests/bug977003_inner_6.html @@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563 var listener = undefined; var test_target = false; var test_move = false; + var test_over = false; var test_listener = false; var receive_lostpointercapture = false; @@ -44,6 +45,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563 } } else if(event.type == "pointermove") { test_move = true; + } else if(event.type == "pointerover") { + test_over = true; } else { test_listener = true; } @@ -81,7 +84,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563 // PE level 2 defines that the pending pointer capture is processed when firing next pointer events. // In this test case, pointer capture release is processed when firing pointermove parent.is(test_move, true, "Part 6: gotpointercapture should be triggered by pointermove"); - parent.is(test_listener, false, "Part 6: no other pointerevents should be fired before gotpointercapture"); + parent.is(test_over, true, "Part 6: pointerover should be received when capturing pointer"); + parent.is(test_listener, false, "Part 6: no other pointerevents should be fired before gotpointercapture except pointerover"); logger("finishTest"); parent.finishTest(); } diff --git a/layout/base/tests/mochitest.ini b/layout/base/tests/mochitest.ini index 279b0af8a..405697977 100644 --- a/layout/base/tests/mochitest.ini +++ b/layout/base/tests/mochitest.ini @@ -256,8 +256,6 @@ skip-if = toolkit == 'android' support-files = bug851445_helper.html [test_bug970964.html] support-files = bug970964_inner.html -[test_bug976963.html] -support-files = bug976963_inner.html [test_bug977003.html] support-files = bug977003_inner_1.html diff --git a/layout/base/tests/test_bug976963.html b/layout/base/tests/test_bug976963.html deleted file mode 100644 index 4b8da3a6e..000000000 --- a/layout/base/tests/test_bug976963.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - Test for Bug 976963 - - - - - - - - diff --git a/widget/MouseEvents.h b/widget/MouseEvents.h index f214ec22b..442ac41e8 100644 --- a/widget/MouseEvents.h +++ b/widget/MouseEvents.h @@ -46,15 +46,17 @@ public: uint32_t pointerId; uint32_t tiltX; uint32_t tiltY; + uint32_t twist; + float tangentialPressure; bool convertToPointer; - bool retargetedByPointerCapture; WidgetPointerHelper() : pointerId(0) , tiltX(0) , tiltY(0) + , twist(0) + , tangentialPressure(0) , convertToPointer(true) - , retargetedByPointerCapture(false) { } @@ -63,8 +65,9 @@ public: pointerId = aEvent.pointerId; tiltX = aEvent.tiltX; tiltY = aEvent.tiltY; + twist = aEvent.twist; + tangentialPressure = aEvent.tangentialPressure; convertToPointer = aEvent.convertToPointer; - retargetedByPointerCapture = aEvent.retargetedByPointerCapture; } }; diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index e06e3784a..e45189bb1 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -228,8 +228,10 @@ struct ParamTraits WriteParam(aMsg, aParam.pointerId); WriteParam(aMsg, aParam.tiltX); WriteParam(aMsg, aParam.tiltY); - // We don't serialize convertToPointer and retargetedByPointerCapture since - // they are temporarily variable and should be reset to default. + WriteParam(aMsg, aParam.twist); + WriteParam(aMsg, aParam.tangentialPressure); + // We don't serialize convertToPointer since it's temporarily variable and + // should be reset to default. } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) @@ -237,7 +239,9 @@ struct ParamTraits bool rv; rv = ReadParam(aMsg, aIter, &aResult->pointerId) && ReadParam(aMsg, aIter, &aResult->tiltX) && - ReadParam(aMsg, aIter, &aResult->tiltY); + ReadParam(aMsg, aIter, &aResult->tiltY) && + ReadParam(aMsg, aIter, &aResult->twist) && + ReadParam(aMsg, aIter, &aResult->tangentialPressure); return rv; } }; -- cgit v1.2.3 From 2828e5db828d13ef662817f37f55709ab302db51 Mon Sep 17 00:00:00 2001 From: trav90 Date: Fri, 20 Apr 2018 17:44:53 -0500 Subject: Use -1 instead of 0 to indicate absent glxtest_pipe fd --- widget/GfxInfoX11.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/widget/GfxInfoX11.cpp b/widget/GfxInfoX11.cpp index 4297aaa93..48fc3dbb5 100644 --- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -23,7 +23,7 @@ NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) #endif // these global variables will be set when firing the glxtest process -int glxtest_pipe = 0; +int glxtest_pipe = -1; pid_t glxtest_pid = 0; nsresult @@ -50,8 +50,8 @@ GfxInfo::GetData() // to understand this function, see bug 639842. We retrieve the OpenGL driver information in a // separate process to protect against bad drivers. - // if glxtest_pipe == 0, that means that we already read the information - if (!glxtest_pipe) + // if glxtest_pipe == -1, that means that we already read the information + if (glxtest_pipe == -1) return; enum { buf_size = 1024 }; @@ -60,7 +60,7 @@ GfxInfo::GetData() &buf, buf_size-1); // -1 because we'll append a zero close(glxtest_pipe); - glxtest_pipe = 0; + glxtest_pipe = -1; // bytesread < 0 would mean that the above read() call failed. // This should never happen. If it did, the outcome would be to blacklist anyway. -- cgit v1.2.3 From 754ad610489603f80ea38bbd2cf18b28f0d8bf1d Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 20 Apr 2018 20:11:26 -0400 Subject: Import XULRunner and make it produce the generic stub --- application/xulrunner/README.xulrunner | 13 + application/xulrunner/app.mozbuild | 13 + application/xulrunner/app/Makefile.in | 75 ++++ application/xulrunner/app/default16.png | Bin 0 -> 744 bytes application/xulrunner/app/default32.png | Bin 0 -> 2084 bytes application/xulrunner/app/default48.png | Bin 0 -> 3846 bytes application/xulrunner/app/document.ico | Bin 0 -> 22486 bytes application/xulrunner/app/install_app.py | 221 ++++++++++ application/xulrunner/app/macbuild/Info.plist.in | 31 ++ .../xulrunner/app/macbuild/InfoPlist.strings | Bin 0 -> 280 bytes application/xulrunner/app/moz.build | 70 ++++ application/xulrunner/app/nsXULRunnerApp.cpp | 294 ++++++++++++++ application/xulrunner/app/splash.rc | 22 + application/xulrunner/app/xulrunner.exe.manifest | 38 ++ application/xulrunner/app/xulrunner.ico | Bin 0 -> 22486 bytes application/xulrunner/app/xulrunner.js | 26 ++ application/xulrunner/config/mozconfig | 9 + application/xulrunner/config/mozconfigs/common | 7 + .../xulrunner/config/mozconfigs/common.override | 8 + .../xulrunner/config/mozconfigs/linux32/xulrunner | 9 + .../config/mozconfigs/linux32/xulrunner-qt | 15 + .../xulrunner/config/mozconfigs/linux64/xulrunner | 9 + .../config/mozconfigs/macosx-universal/xulrunner | 9 + .../xulrunner/config/mozconfigs/win32/xulrunner | 16 + .../xulrunner/config/mozconfigs/win64/xulrunner | 15 + application/xulrunner/configure.in | 11 + application/xulrunner/confvars.sh | 28 ++ application/xulrunner/examples/moz.build | 7 + .../xulrunner/examples/simple/application.ini | 43 ++ .../xulrunner/examples/simple/components/moz.build | 7 + .../examples/simple/components/public/moz.build | 13 + .../simple/components/public/nsISimpleTest.idl | 15 + .../examples/simple/components/src/SimpleTest.cpp | 54 +++ .../examples/simple/components/src/SimpleTest.js | 27 ++ .../simple/components/src/SimpleTest.manifest | 2 + .../examples/simple/components/src/moz.build | 21 + .../xulrunner/examples/simple/content/contents.rdf | 0 .../xulrunner/examples/simple/content/simple.js | 17 + .../xulrunner/examples/simple/content/simple.xul | 20 + .../xulrunner/examples/simple/icons/simple.ico | Bin 0 -> 29310 bytes application/xulrunner/examples/simple/jar.mn | 12 + .../xulrunner/examples/simple/locale/simple.dtd | 7 + application/xulrunner/examples/simple/moz.build | 22 + .../xulrunner/examples/simple/simple-prefs.js | 6 + application/xulrunner/installer/Makefile.in | 148 +++++++ .../xulrunner/installer/debian/changelog.in | 7 + application/xulrunner/installer/debian/compat | 1 + application/xulrunner/installer/debian/control | 48 +++ application/xulrunner/installer/debian/icon_base64 | 36 ++ application/xulrunner/installer/debian/menu | 2 + application/xulrunner/installer/debian/postinst.in | 42 ++ application/xulrunner/installer/debian/prerm.in | 29 ++ .../xulrunner/installer/debian/xulrunner.links.in | 2 + .../installer/debian/xulrunner.service.in | 4 + .../xulrunner/installer/libxul-embedding.pc.in | 10 + application/xulrunner/installer/libxul.pc.in | 11 + application/xulrunner/installer/moz.build | 6 + application/xulrunner/installer/mozilla-js.pc.in | 10 + application/xulrunner/installer/mozilla-nspr.pc.in | 11 + application/xulrunner/installer/mozilla-nss.pc.in | 10 + .../xulrunner/installer/mozilla-plugin.pc.in | 8 + application/xulrunner/locales/all-locales | 39 ++ application/xulrunner/moz.build | 11 + application/xulrunner/moz.configure | 7 + application/xulrunner/stub/Makefile.in | 11 + application/xulrunner/stub/moz.build | 51 +++ application/xulrunner/stub/nsXULStub.cpp | 445 +++++++++++++++++++++ .../xulrunner/stub/xulrunner-stub.exe.manifest | 38 ++ application/xulrunner/stub/xulrunner-stub.rc | 6 + application/xulrunner/tools/redit/Makefile.in | 11 + application/xulrunner/tools/redit/moz.build | 15 + application/xulrunner/tools/redit/redit.cpp | 187 +++++++++ old-configure.in | 10 - 73 files changed, 2418 insertions(+), 10 deletions(-) create mode 100644 application/xulrunner/README.xulrunner create mode 100644 application/xulrunner/app.mozbuild create mode 100644 application/xulrunner/app/Makefile.in create mode 100644 application/xulrunner/app/default16.png create mode 100644 application/xulrunner/app/default32.png create mode 100644 application/xulrunner/app/default48.png create mode 100644 application/xulrunner/app/document.ico create mode 100644 application/xulrunner/app/install_app.py create mode 100644 application/xulrunner/app/macbuild/Info.plist.in create mode 100644 application/xulrunner/app/macbuild/InfoPlist.strings create mode 100644 application/xulrunner/app/moz.build create mode 100644 application/xulrunner/app/nsXULRunnerApp.cpp create mode 100644 application/xulrunner/app/splash.rc create mode 100644 application/xulrunner/app/xulrunner.exe.manifest create mode 100644 application/xulrunner/app/xulrunner.ico create mode 100644 application/xulrunner/app/xulrunner.js create mode 100644 application/xulrunner/config/mozconfig create mode 100644 application/xulrunner/config/mozconfigs/common create mode 100644 application/xulrunner/config/mozconfigs/common.override create mode 100644 application/xulrunner/config/mozconfigs/linux32/xulrunner create mode 100644 application/xulrunner/config/mozconfigs/linux32/xulrunner-qt create mode 100644 application/xulrunner/config/mozconfigs/linux64/xulrunner create mode 100644 application/xulrunner/config/mozconfigs/macosx-universal/xulrunner create mode 100644 application/xulrunner/config/mozconfigs/win32/xulrunner create mode 100644 application/xulrunner/config/mozconfigs/win64/xulrunner create mode 100644 application/xulrunner/configure.in create mode 100644 application/xulrunner/confvars.sh create mode 100644 application/xulrunner/examples/moz.build create mode 100644 application/xulrunner/examples/simple/application.ini create mode 100644 application/xulrunner/examples/simple/components/moz.build create mode 100644 application/xulrunner/examples/simple/components/public/moz.build create mode 100644 application/xulrunner/examples/simple/components/public/nsISimpleTest.idl create mode 100644 application/xulrunner/examples/simple/components/src/SimpleTest.cpp create mode 100644 application/xulrunner/examples/simple/components/src/SimpleTest.js create mode 100644 application/xulrunner/examples/simple/components/src/SimpleTest.manifest create mode 100644 application/xulrunner/examples/simple/components/src/moz.build create mode 100644 application/xulrunner/examples/simple/content/contents.rdf create mode 100644 application/xulrunner/examples/simple/content/simple.js create mode 100644 application/xulrunner/examples/simple/content/simple.xul create mode 100644 application/xulrunner/examples/simple/icons/simple.ico create mode 100644 application/xulrunner/examples/simple/jar.mn create mode 100644 application/xulrunner/examples/simple/locale/simple.dtd create mode 100644 application/xulrunner/examples/simple/moz.build create mode 100644 application/xulrunner/examples/simple/simple-prefs.js create mode 100644 application/xulrunner/installer/Makefile.in create mode 100644 application/xulrunner/installer/debian/changelog.in create mode 100644 application/xulrunner/installer/debian/compat create mode 100644 application/xulrunner/installer/debian/control create mode 100644 application/xulrunner/installer/debian/icon_base64 create mode 100644 application/xulrunner/installer/debian/menu create mode 100644 application/xulrunner/installer/debian/postinst.in create mode 100644 application/xulrunner/installer/debian/prerm.in create mode 100644 application/xulrunner/installer/debian/xulrunner.links.in create mode 100644 application/xulrunner/installer/debian/xulrunner.service.in create mode 100644 application/xulrunner/installer/libxul-embedding.pc.in create mode 100644 application/xulrunner/installer/libxul.pc.in create mode 100644 application/xulrunner/installer/moz.build create mode 100644 application/xulrunner/installer/mozilla-js.pc.in create mode 100644 application/xulrunner/installer/mozilla-nspr.pc.in create mode 100644 application/xulrunner/installer/mozilla-nss.pc.in create mode 100644 application/xulrunner/installer/mozilla-plugin.pc.in create mode 100644 application/xulrunner/locales/all-locales create mode 100644 application/xulrunner/moz.build create mode 100644 application/xulrunner/moz.configure create mode 100644 application/xulrunner/stub/Makefile.in create mode 100644 application/xulrunner/stub/moz.build create mode 100644 application/xulrunner/stub/nsXULStub.cpp create mode 100644 application/xulrunner/stub/xulrunner-stub.exe.manifest create mode 100644 application/xulrunner/stub/xulrunner-stub.rc create mode 100644 application/xulrunner/tools/redit/Makefile.in create mode 100644 application/xulrunner/tools/redit/moz.build create mode 100644 application/xulrunner/tools/redit/redit.cpp diff --git a/application/xulrunner/README.xulrunner b/application/xulrunner/README.xulrunner new file mode 100644 index 000000000..424b7a615 --- /dev/null +++ b/application/xulrunner/README.xulrunner @@ -0,0 +1,13 @@ +XULRunner is a package which can be used to run applications written in HTML +or XUL. It can also be used to embed the gecko rendering engine into +binary applications. + +XULRunner is not a product; it is a tool which can be used to create products. +It is a byproduct of Firefox development and the Mozilla community does not +have a strong commitment to support XULRunner development apart from Firefox +development. + +For more information about using XULRunner or how to use this binary package, +see the Mozilla Developer Center article: + +https://developer.mozilla.org/en/XULRunner diff --git a/application/xulrunner/app.mozbuild b/application/xulrunner/app.mozbuild new file mode 100644 index 000000000..7b8316016 --- /dev/null +++ b/application/xulrunner/app.mozbuild @@ -0,0 +1,13 @@ +# 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/. + +include('/toolkit/toolkit.mozbuild') + +if CONFIG['MOZ_EXTENSIONS']: + DIRS += ['/extensions'] + +DIRS += [ + '/application/xulrunner', +] diff --git a/application/xulrunner/app/Makefile.in b/application/xulrunner/app/Makefile.in new file mode 100644 index 000000000..98e377d69 --- /dev/null +++ b/application/xulrunner/app/Makefile.in @@ -0,0 +1,75 @@ +# vim:set ts=8 sw=8 sts=8 et: +# 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/. + +GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/,xulrunner.js) + +ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) +TK_LIBS := -framework Cocoa $(TK_LIBS) +endif + +ifndef MOZ_WINCONSOLE +ifdef MOZ_DEBUG +MOZ_WINCONSOLE = 1 +else +MOZ_WINCONSOLE = 0 +endif +endif + +# This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that +# shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall. +NSDISTMODE = copy + +include $(topsrcdir)/config/config.mk + +include $(topsrcdir)/config/rules.mk + +DEFINES += -DXULRUNNER_ICO='"$(DIST)/branding/xulrunner.ico"' -DDOCUMENT_ICO='"$(DIST)/branding/document.ico"' + +ifdef MOZ_WIDGET_GTK +libs:: + $(INSTALL) $(IFLAGS1) $(DIST)/branding/default16.png $(DIST)/bin/chrome/icons/default + $(INSTALL) $(IFLAGS1) $(DIST)/branding/default32.png $(DIST)/bin/chrome/icons/default + $(INSTALL) $(IFLAGS1) $(DIST)/branding/default48.png $(DIST)/bin/chrome/icons/default +endif + +# XXX applications would need to supply this file +#export:: brand.dtd.in +# $(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) $^ -o brand.dtd) + +ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) + +FRAMEWORK_NAME = XUL +FRAMEWORK_VERSION = $(MOZILLA_VERSION) + +FRAMEWORK_DIR = \ + $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION) + +$(FRAMEWORK_DIR)/Resources: + $(NSINSTALL) -D $@ + +tools:: $(PROGRAM) $(FRAMEWORK_DIR)/Resources + $(NSINSTALL) $(srcdir)/macbuild/InfoPlist.strings $(FRAMEWORK_DIR)/Resources + sed -e 's/APP_VERSION/$(APP_VERSION)/' $(srcdir)/macbuild/Info.plist.in > $(FRAMEWORK_DIR)/Info.plist + rsync -av $(DIST)/bin/ $(FRAMEWORK_DIR) --exclude mangle --exclude shlibsign + rm -f $(DIST)/$(FRAMEWORK_NAME).framework/Versions/Current \ + $(DIST)/$(FRAMEWORK_NAME).framework/libxpcom.dylib \ + $(DIST)/$(FRAMEWORK_NAME).framework/XUL \ + $(DIST)/$(FRAMEWORK_NAME).framework/xulrunner + ln -s $(FRAMEWORK_VERSION) $(DIST)/$(FRAMEWORK_NAME).framework/Versions/Current + ln -s Versions/Current/libxpcom.dylib $(DIST)/$(FRAMEWORK_NAME).framework/libxpcom.dylib + ln -s Versions/Current/XUL $(DIST)/$(FRAMEWORK_NAME).framework/XUL + ln -s Versions/Current/xulrunner $(DIST)/$(FRAMEWORK_NAME).framework/xulrunner + +clean clobber:: + rm -rf $(DIST)/$(FRAMEWORK_NAME).framework +endif + +README_FILE = $(srcdir)/../README.xulrunner + +libs:: + $(INSTALL) $(IFLAGS1) $(README_FILE) $(DIST)/bin + $(INSTALL) $(IFLAGS1) $(topsrcdir)/LICENSE $(DIST)/bin + $(INSTALL) $(IFLAGS1) $(srcdir)/install_app.py $(DIST)/bin + diff --git a/application/xulrunner/app/default16.png b/application/xulrunner/app/default16.png new file mode 100644 index 000000000..e74f5cf2e Binary files /dev/null and b/application/xulrunner/app/default16.png differ diff --git a/application/xulrunner/app/default32.png b/application/xulrunner/app/default32.png new file mode 100644 index 000000000..914509054 Binary files /dev/null and b/application/xulrunner/app/default32.png differ diff --git a/application/xulrunner/app/default48.png b/application/xulrunner/app/default48.png new file mode 100644 index 000000000..5fd71e110 Binary files /dev/null and b/application/xulrunner/app/default48.png differ diff --git a/application/xulrunner/app/document.ico b/application/xulrunner/app/document.ico new file mode 100644 index 000000000..311116324 Binary files /dev/null and b/application/xulrunner/app/document.ico differ diff --git a/application/xulrunner/app/install_app.py b/application/xulrunner/app/install_app.py new file mode 100644 index 000000000..6be8c5ecb --- /dev/null +++ b/application/xulrunner/app/install_app.py @@ -0,0 +1,221 @@ +#!/usr/bin/env 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/. + +# Min version of python is 2.7 +import sys +if ((sys.version_info.major != 2) or (sys.version_info.minor < 7)): + raise Exception("You need to use Python version 2.7 or higher") + +import os, shutil, re, zipfile +from ConfigParser import SafeConfigParser + +# Platform-specific support +# see https://developer.mozilla.org/en/XULRunner/Deploying_XULRunner_1.8 +if sys.platform.startswith('linux') or sys.platform == "win32": + def installApp(appLocation, installDir, appName, greDir): + zipApp, iniParser, appName = validateArguments(appLocation, installDir, appName, greDir) + if (zipApp): + zipApp.extractAll(installDir) + else: + shutil.copytree(appLocation, installDir) + shutil.copy2(os.path.join(greDir, xulrunnerStubName), + os.path.join(installDir, appName)) + copyGRE(greDir, os.path.join(installDir, "xulrunner")) + +if sys.platform.startswith('linux'): + xulrunnerStubName = "xulrunner-stub" + + def makeAppName(leafName): + return leafName.lower() + +elif sys.platform == "win32": + xulrunnerStubName = "xulrunner-stub.exe" + + def makeAppName(leafName): + return leafName + ".exe" + +elif sys.platform == "darwin": + xulrunnerStubName = "xulrunner-stub" + + def installApp(appLocation, installDir, appName, greDir): + zipApp, iniparser, appName = validateArguments(appLocation, installDir, appName, greDir) + installDir += "/" + appName + ".app" + resourcesDir = os.path.join(installDir, "Contents/Resources") + if (zipApp): + zipApp.extractAll(resourcesDir) + else: + shutil.copytree(appLocation, resourcesDir) + MacOSDir = os.path.join(installDir, "Contents/MacOS") + os.makedirs(MacOSDir) + shutil.copy2(os.path.join(greDir, xulrunnerStubName), MacOSDir) + copyGRE(greDir, + os.path.join(installDir, "Contents/Frameworks/XUL.framework")) + + # Contents/Info.plist + contents = """ + + + +CFBundleInfoDictionaryVersion +6.0 +CFBundlePackageType +APPL +CFBundleSignature +???? +CFBundleExecutable +xulrunner +NSAppleScriptEnabled + +CFBundleGetInfoString +$infoString +CFBundleName +$appName +CFBundleShortVersionString +$version +CFBundleVersion +$version.$buildID +CFBundleIdentifier +$reverseVendor + + +""" + version = iniparser.get("App", "Version") + buildID = iniparser.get("App", "BuildID") + infoString = appName + " " + version + reverseVendor = "com.vendor.unknown" + appID = iniparser.get("App", "ID") + colonIndex = appID.find("@") + 1 + if (colonIndex != 0): + vendor = appID[colonIndex:] + reverseVendor = ".".join(vendor.split(".")[::-1]) + contents = contents.replace("$infoString", infoString) + contents = contents.replace("$appName", appName) + contents = contents.replace("$version", version) + contents = contents.replace("$buildID", buildID) + contents = contents.replace("$reverseVendor", reverseVendor) + infoPList = open(os.path.join(installDir, "Contents/Info.plist"), "w+b") + infoPList.write(contents) + infoPList.close() + + def makeAppName(leafName): + return leafName + +else: + # Implement xulrunnerStubName, installApp and makeAppName as above. + raise Exception("This operating system isn't supported for install_app.py yet!") +# End platform-specific support + +def resolvePath(path): + return os.path.realpath(path) + +def requireINIOption(iniparser, section, option): + if not (iniparser.has_option(section, option)): + raise Exception("application.ini must have a " + option + " option under the " + section + " section") + +def checkAppINI(appLocation): + if (os.path.isdir(appLocation)): + zipApp = None + appINIPath = os.path.join(appLocation, "application.ini") + if not (os.path.isfile(appINIPath)): + raise Exception(appINIPath + " does not exist") + appINI = open(appINIPath) + elif (zipfile.is_zipfile(appLocation)): + zipApp = zipfile.ZipFile(appLocation) + if not ("application.ini" in zipApp.namelist()): + raise Exception("jar:" + appLocation + "!/application.ini does not exist") + appINI = zipApp.open("application.ini") + else: + raise Exception("appLocation must be a directory containing application.ini or a zip file with application.ini at its root") + + # application.ini verification + iniparser = SafeConfigParser() + iniparser.readfp(appINI) + if not (iniparser.has_section("App")): + raise Exception("application.ini must have an App section") + if not (iniparser.has_section("Gecko")): + raise Exception("application.ini must have a Gecko section") + requireINIOption(iniparser, "App", "Name") + requireINIOption(iniparser, "App", "Version") + requireINIOption(iniparser, "App", "BuildID") + requireINIOption(iniparser, "App", "ID") + requireINIOption(iniparser, "Gecko", "MinVersion") + + return zipApp, iniparser + pass + +def copyGRE(greDir, targetDir): + shutil.copytree(greDir, targetDir, symlinks=True) + +def validateArguments(appLocation, installDir, appName, greDir): + # application directory / zip verification + appLocation = resolvePath(appLocation) + + # target directory + installDir = resolvePath(installDir) + + if (os.path.exists(installDir)): + raise Exception("installDir must not exist: " + cmds.installDir) + + greDir = resolvePath(greDir) + xulrunnerStubPath = os.path.isfile(os.path.join(greDir, xulrunnerStubName)) + if not xulrunnerStubPath: + raise Exception("XULRunner stub executable not found: " + os.path.join(greDir, xulrunnerStubName)) + + # appName + zipApp, iniparser = checkAppINI(appLocation) + if not appName: + appName = iniparser.get("App", "Name") + appName = makeAppName(appName) + pattern = re.compile("[\\\/\:*?\"<>|\x00]") + if pattern.search(appName): + raise Exception("App name has illegal characters for at least one operating system") + return zipApp, iniparser, appName + +def handleCommandLine(): + import argparse + + # Argument parsing. + parser = argparse.ArgumentParser( + description="XULRunner application installer", + usage="""install_app.py appLocation installDir greDir [--appName APPNAME] + install_app.py -h + install_app.py --version + """ + ) + parser.add_argument( + "appLocation", + action="store", + help="The directory or ZIP file containing application.ini as a top-level child file" + ) + parser.add_argument( + "installDir", + action="store", + help="The directory to install the application to" + ) + parser.add_argument( + "--greDir", + action="store", + help="The directory containing the Gecko SDK (usually where this Python script lives)", + default=os.path.dirname(sys.argv[0]) + ) + parser.add_argument( + "--appName", + action="store", + help="The name of the application to install" + ) + parser.add_argument("--version", action="version", version="%(prog)s 1.0") + + # The command code. + cmds = parser.parse_args() + try: + installApp(cmds.appLocation, cmds.installDir, cmds.appName, cmds.greDir) + except exn: + shutil.rmtree(cmds.installDir) + raise exn + print cmds.appName + " application installed to " + cmds.installDir + +if __name__ == '__main__': + handleCommandLine() diff --git a/application/xulrunner/app/macbuild/Info.plist.in b/application/xulrunner/app/macbuild/Info.plist.in new file mode 100644 index 000000000..69676b80c --- /dev/null +++ b/application/xulrunner/app/macbuild/Info.plist.in @@ -0,0 +1,31 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + xulrunner-bin + CFBundleIdentifier + org.mozilla.xulrunner + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + XULRunner + CFBundlePackageType + FMWK + CFBundleSignature + MOZB + CFBundleVersion + APP_VERSION + LSMinimumSystemVersion + 10.5 + LSMinimumSystemVersionByArchitecture + + i386 + 10.5.0 + x86_64 + 10.6.0 + + + diff --git a/application/xulrunner/app/macbuild/InfoPlist.strings b/application/xulrunner/app/macbuild/InfoPlist.strings new file mode 100644 index 000000000..5d9eefd51 Binary files /dev/null and b/application/xulrunner/app/macbuild/InfoPlist.strings differ diff --git a/application/xulrunner/app/moz.build b/application/xulrunner/app/moz.build new file mode 100644 index 000000000..1c9cb117c --- /dev/null +++ b/application/xulrunner/app/moz.build @@ -0,0 +1,70 @@ +# -*- 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/. + +GeckoProgram('xulrunner') + +SOURCES += [ + 'nsXULRunnerApp.cpp', +] + +DEFINES['XULRUNNER_PROGNAME'] = '"xulrunner"' +if CONFIG['MOZ_DEBUG']: + DEFINES['DEBUG'] = True + +LOCAL_INCLUDES += [ + '/toolkit/profile', + '/toolkit/xre', + '/xpcom/base', + '/xpcom/build', +] + +if CONFIG['_MSC_VER']: + # Always enter a Windows program through wmain, whether or not we're + # a console application. + WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup'] + +# Control the default heap size. +# This is the heap returned by GetProcessHeap(). +# As we use the CRT heap, the default size is too large and wastes VM. +# +# The default heap size is 1MB on Win32. +# The heap will grow if need be. +# +# Set it to 256k. See bug 127069. +if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']: + LDFLAGS += ['/HEAP:0x40000'] + +if CONFIG['OS_ARCH'] == 'WINNT': + RCINCLUDE = 'splash.rc' + OS_LIBS += [ + 'comctl32', + 'comdlg32', + 'uuid', + 'shell32', + 'ole32', + 'oleaut32', + 'version', + 'winspool', + ] + +DISABLE_STL_WRAPPING = True + +JS_PREFERENCE_PP_FILES += [ + 'xulrunner.js', +] + +if CONFIG['OS_ARCH'] == 'WINNT': + BRANDING_FILES += [ + 'document.ico', + 'xulrunner.ico', + ] + +if CONFIG['MOZ_WIDGET_GTK']: + BRANDING_FILES += [ + 'default16.png', + 'default32.png', + 'default48.png', + ] diff --git a/application/xulrunner/app/nsXULRunnerApp.cpp b/application/xulrunner/app/nsXULRunnerApp.cpp new file mode 100644 index 000000000..d86317a85 --- /dev/null +++ b/application/xulrunner/app/nsXULRunnerApp.cpp @@ -0,0 +1,294 @@ +/* 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 "nsXULAppAPI.h" +#include "nsXPCOMGlue.h" +#include +#include +#ifdef XP_WIN +#include +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#endif +#define strcasecmp _stricmp +#endif + +#include "nsAppRunner.h" +#include "nsIFile.h" +#include "nsCOMPtr.h" +#include "nsMemory.h" +#include "nsCRTGlue.h" +#include "nsStringAPI.h" +#include "nsServiceManagerUtils.h" +#include "plstr.h" +#include "prprf.h" +#include "prenv.h" +#include "nsINIParser.h" + +#ifdef XP_WIN +#define XRE_DONT_SUPPORT_XPSP2 // See https://bugzil.la/1023941#c32 +#include "nsWindowsWMain.cpp" +#endif + +#include "BinaryPath.h" + +#include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL + +using namespace mozilla; + +/** + * Output a string to the user. This method is really only meant to be used to + * output last-ditch error messages designed for developers NOT END USERS. + * + * @param isError + * Pass true to indicate severe errors. + * @param fmt + * printf-style format string followed by arguments. + */ +static void Output(bool isError, const char *fmt, ... ) +{ + va_list ap; + va_start(ap, fmt); + +#if (defined(XP_WIN) && !MOZ_WINCONSOLE) + wchar_t msg[2048]; + _vsnwprintf(msg, sizeof(msg)/sizeof(msg[0]), NS_ConvertUTF8toUTF16(fmt).get(), ap); + + UINT flags = MB_OK; + if (isError) + flags |= MB_ICONERROR; + else + flags |= MB_ICONINFORMATION; + + MessageBoxW(nullptr, msg, L"XULRunner", flags); +#else + vfprintf(stderr, fmt, ap); +#endif + + va_end(ap); +} + +/** + * Return true if |arg| matches the given argument name. + */ +static bool IsArg(const char* arg, const char* s) +{ + if (*arg == '-') + { + if (*++arg == '-') + ++arg; + return !strcasecmp(arg, s); + } + +#if defined(XP_WIN) + if (*arg == '/') + return !strcasecmp(++arg, s); +#endif + + return false; +} + +static nsresult +GetGREVersion(const char *argv0, + nsACString *aMilestone, + nsACString *aVersion) +{ + if (aMilestone) + aMilestone->AssignLiteral(""); + if (aVersion) + aVersion->AssignLiteral(""); + + nsCOMPtr iniFile; + nsresult rv = BinaryPath::GetFile(argv0, getter_AddRefs(iniFile)); + if (NS_FAILED(rv)) + return rv; + + iniFile->SetNativeLeafName(NS_LITERAL_CSTRING("platform.ini")); + + nsINIParser parser; + rv = parser.Init(iniFile); + if (NS_FAILED(rv)) + return rv; + + if (aMilestone) { + rv = parser.GetString("Build", "Milestone", *aMilestone); + if (NS_FAILED(rv)) + return rv; + } + if (aVersion) { + rv = parser.GetString("Build", "BuildID", *aVersion); + if (NS_FAILED(rv)) + return rv; + } + return NS_OK; +} + +static void Usage(const char *argv0) +{ + nsAutoCString milestone; + GetGREVersion(argv0, &milestone, nullptr); + + // display additional information (XXX make localizable?) + Output(false, + "Mozilla XULRunner %s\n\n" + "Usage: " XULRUNNER_PROGNAME " [OPTIONS]\n" + " " XULRUNNER_PROGNAME " APP-FILE [APP-OPTIONS...]\n" + "\n" + "OPTIONS\n" + " --app specify APP-FILE (optional)\n" + " -h, --help show this message\n" + " -v, --version show version\n" + " --gre-version print the GRE version string on stdout\n" + "\n" + "APP-FILE\n" + " Application initialization file.\n" + "\n" + "APP-OPTIONS\n" + " Application specific options.\n", + milestone.get()); +} + +XRE_GetFileFromPathType XRE_GetFileFromPath; +XRE_CreateAppDataType XRE_CreateAppData; +XRE_FreeAppDataType XRE_FreeAppData; +XRE_mainType XRE_main; + +static const nsDynamicFunctionLoad kXULFuncs[] = { + { "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath }, + { "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData }, + { "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData }, + { "XRE_main", (NSFuncPtr*) &XRE_main }, + { nullptr, nullptr } +}; + +class AutoAppData +{ +public: + AutoAppData(nsIFile* aINIFile) : mAppData(nullptr) { + nsresult rv = XRE_CreateAppData(aINIFile, &mAppData); + if (NS_FAILED(rv)) + mAppData = nullptr; + } + ~AutoAppData() { + if (mAppData) + XRE_FreeAppData(mAppData); + } + + operator nsXREAppData*() const { return mAppData; } + nsXREAppData* operator -> () const { return mAppData; } + +private: + nsXREAppData* mAppData; +}; + +int main(int argc, char* argv[]) +{ + char exePath[MAXPATHLEN]; + nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath); + if (NS_FAILED(rv)) { + Output(true, "Couldn't calculate the application directory.\n"); + return 255; + } + + char *lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]); + if (!lastSlash || (size_t(lastSlash - exePath) > MAXPATHLEN - sizeof(XPCOM_DLL) - 1)) + return 255; + + strcpy(++lastSlash, XPCOM_DLL); + + rv = XPCOMGlueStartup(exePath); + if (NS_FAILED(rv)) { + Output(true, "Couldn't load XPCOM.\n"); + return 255; + } + + if (argc > 1 && (IsArg(argv[1], "h") || + IsArg(argv[1], "help") || + IsArg(argv[1], "?"))) + { + Usage(argv[0]); + return 0; + } + + if (argc == 2 && (IsArg(argv[1], "v") || IsArg(argv[1], "version"))) + { + nsAutoCString milestone; + nsAutoCString version; + GetGREVersion(argv[0], &milestone, &version); + Output(false, "Mozilla XULRunner %s - %s\n", + milestone.get(), version.get()); + return 0; + } + + rv = XPCOMGlueLoadXULFunctions(kXULFuncs); + if (NS_FAILED(rv)) { + Output(true, "Couldn't load XRE functions.\n"); + return 255; + } + + if (argc > 1) { + nsAutoCString milestone; + rv = GetGREVersion(argv[0], &milestone, nullptr); + if (NS_FAILED(rv)) + return 2; + + if (IsArg(argv[1], "gre-version")) { + if (argc != 2) { + Usage(argv[0]); + return 1; + } + + printf("%s\n", milestone.get()); + return 0; + } + + if (IsArg(argv[1], "install-app")) { + Output(true, "--install-app support has been removed. Use 'python install-app.py' instead.\n"); + return 1; + } + } + + const char *appDataFile = getenv("XUL_APP_FILE"); + + if (!(appDataFile && *appDataFile)) { + if (argc < 2) { + Usage(argv[0]); + return 1; + } + + if (IsArg(argv[1], "app")) { + if (argc == 2) { + Usage(argv[0]); + return 1; + } + argv[1] = argv[0]; + ++argv; + --argc; + } + + appDataFile = argv[1]; + argv[1] = argv[0]; + ++argv; + --argc; + + static char kAppEnv[MAXPATHLEN]; + snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile); + putenv(kAppEnv); + } + + nsCOMPtr appDataLF; + rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appDataLF)); + if (NS_FAILED(rv)) { + Output(true, "Error: unrecognized application.ini path.\n"); + return 2; + } + + AutoAppData appData(appDataLF); + if (!appData) { + Output(true, "Error: couldn't parse application.ini.\n"); + return 2; + } + + return XRE_main(argc, argv, appData, 0); +} diff --git a/application/xulrunner/app/splash.rc b/application/xulrunner/app/splash.rc new file mode 100644 index 000000000..4374383ba --- /dev/null +++ b/application/xulrunner/app/splash.rc @@ -0,0 +1,22 @@ +/* -*- Mode: C++; 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/. */ + +#include +#include "nsNativeAppSupportWin.h" + +1 24 "xulrunner.exe.manifest" + +IDI_APPICON ICON XULRUNNER_ICO +IDI_DOCUMENT ICON DOCUMENT_ICO +IDI_APPLICATION ICON XULRUNNER_ICO + +STRINGTABLE DISCARDABLE +BEGIN +#ifdef DEBUG + IDS_STARTMENU_APPNAME, "Firefox Debug" +#else + IDS_STARTMENU_APPNAME, "Firefox" +#endif +END diff --git a/application/xulrunner/app/xulrunner.exe.manifest b/application/xulrunner/app/xulrunner.exe.manifest new file mode 100644 index 000000000..b08eea074 --- /dev/null +++ b/application/xulrunner/app/xulrunner.exe.manifest @@ -0,0 +1,38 @@ + + + +Mozilla XULRunner + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/xulrunner/app/xulrunner.ico b/application/xulrunner/app/xulrunner.ico new file mode 100644 index 000000000..0518438a0 Binary files /dev/null and b/application/xulrunner/app/xulrunner.ico differ diff --git a/application/xulrunner/app/xulrunner.js b/application/xulrunner/app/xulrunner.js new file mode 100644 index 000000000..509bb48a5 --- /dev/null +++ b/application/xulrunner/app/xulrunner.js @@ -0,0 +1,26 @@ +/* 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/. */ + +#filter substitution + +// We need to override the default values of these preferences since all.js +// assumes these are in the navigator package, which for us is nonexistent. +// XXX(darin): perhaps all.js should not be seamonkey specific +pref("general.useragent.locale", "@AB_CD@"); +pref("xpinstall.dialog.confirm", "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul"); +pref("xpinstall.dialog.progress.chrome", "chrome://mozapps/content/extensions/extensions.xul"); +pref("xpinstall.dialog.progress.skin", "chrome://mozapps/content/extensions/extensions.xul"); +pref("xpinstall.dialog.progress.type.chrome", "Extension:Manager"); +pref("xpinstall.dialog.progress.type.skin", "Extension:Manager"); +pref("xpinstall.enabled", true); +#ifdef XP_WIN +pref("browser.preferences.instantApply", false); +#else +pref("browser.preferences.instantApply", true); +#endif +#ifdef XP_MACOSX +pref("browser.preferences.animateFadeIn", true); +#else +pref("browser.preferences.animateFadeIn", false); +#endif diff --git a/application/xulrunner/config/mozconfig b/application/xulrunner/config/mozconfig new file mode 100644 index 000000000..9fa972cac --- /dev/null +++ b/application/xulrunner/config/mozconfig @@ -0,0 +1,9 @@ +# 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/. + +# This file specifies the build flags for XULRunner. You can use it by adding: +# . $topsrcdir/xulrunner/config/mozconfig +# to the top of your mozconfig file. + +ac_add_options --enable-application=xulrunner diff --git a/application/xulrunner/config/mozconfigs/common b/application/xulrunner/config/mozconfigs/common new file mode 100644 index 000000000..a6811c575 --- /dev/null +++ b/application/xulrunner/config/mozconfigs/common @@ -0,0 +1,7 @@ +# 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/. + +# This file is included at the top of all xulrunner mozconfigs + +. "$topsrcdir/build/mozconfig.common" diff --git a/application/xulrunner/config/mozconfigs/common.override b/application/xulrunner/config/mozconfigs/common.override new file mode 100644 index 000000000..8d719a5b5 --- /dev/null +++ b/application/xulrunner/config/mozconfigs/common.override @@ -0,0 +1,8 @@ +# 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/. + +# This file is included at the bottom of all xulrunner mozconfigs + +. "$topsrcdir/build/mozconfig.common.override" +. "$topsrcdir/build/mozconfig.cache" diff --git a/application/xulrunner/config/mozconfigs/linux32/xulrunner b/application/xulrunner/config/mozconfigs/linux32/xulrunner new file mode 100644 index 000000000..171674f8c --- /dev/null +++ b/application/xulrunner/config/mozconfigs/linux32/xulrunner @@ -0,0 +1,9 @@ +export MOZILLA_OFFICIAL=1 +export JAVA_HOME=/tools/jdk + +ac_add_options --enable-application=xulrunner +ac_add_options --disable-tests + +. $topsrcdir/build/unix/mozconfig.linux32 + +. "$topsrcdir/xulrunner/config/mozconfigs/common.override" diff --git a/application/xulrunner/config/mozconfigs/linux32/xulrunner-qt b/application/xulrunner/config/mozconfigs/linux32/xulrunner-qt new file mode 100644 index 000000000..54e4ecb8f --- /dev/null +++ b/application/xulrunner/config/mozconfigs/linux32/xulrunner-qt @@ -0,0 +1,15 @@ +export MOZILLA_OFFICIAL=1 +export JAVA_HOME=/tools/jdk + +ac_add_options --enable-application=xulrunner +ac_add_options --disable-tests + +. $topsrcdir/build/unix/mozconfig.linux32 + +# QT Options +export PKG_CONFIG_PATH=/tools/qt-4.6.3/qt/lib/pkgconfig +ac_add_options --with-qtdir=/tools/qt-4.6.3/qt +ac_add_options --enable-default-toolkit=cairo-qt +ac_add_options --disable-crashreporter + +. "$topsrcdir/xulrunner/config/mozconfigs/common.override" diff --git a/application/xulrunner/config/mozconfigs/linux64/xulrunner b/application/xulrunner/config/mozconfigs/linux64/xulrunner new file mode 100644 index 000000000..c18a12f67 --- /dev/null +++ b/application/xulrunner/config/mozconfigs/linux64/xulrunner @@ -0,0 +1,9 @@ +export MOZILLA_OFFICIAL=1 +export JAVA_HOME=/tools/jdk + +ac_add_options --enable-application=xulrunner +ac_add_options --disable-tests + +. $topsrcdir/build/unix/mozconfig.linux + +. "$topsrcdir/xulrunner/config/mozconfigs/common.override" diff --git a/application/xulrunner/config/mozconfigs/macosx-universal/xulrunner b/application/xulrunner/config/mozconfigs/macosx-universal/xulrunner new file mode 100644 index 000000000..ac7e24fe2 --- /dev/null +++ b/application/xulrunner/config/mozconfigs/macosx-universal/xulrunner @@ -0,0 +1,9 @@ +. $topsrcdir/build/macosx/universal/mozconfig + +export MOZILLA_OFFICIAL=1 + +ac_add_options --enable-application=xulrunner +ac_add_options --disable-tests +ac_add_options --with-xulrunner-stub-name=xulrunner-stub + +. "$topsrcdir/xulrunner/config/mozconfigs/common.override" diff --git a/application/xulrunner/config/mozconfigs/win32/xulrunner b/application/xulrunner/config/mozconfigs/win32/xulrunner new file mode 100644 index 000000000..4c8b596a5 --- /dev/null +++ b/application/xulrunner/config/mozconfigs/win32/xulrunner @@ -0,0 +1,16 @@ +. "$topsrcdir/xulrunner/config/mozconfigs/common" + +export MOZILLA_OFFICIAL=1 +export JAVA_HOME=/d/jdk1.6.0_14 + +ac_add_options --enable-application=xulrunner +ac_add_options --enable-jemalloc +ac_add_options --disable-tests + +if test "$PROCESSOR_ARCHITECTURE" = "AMD64" -o "$PROCESSOR_ARCHITEW6432" = "AMD64"; then + . $topsrcdir/build/win32/mozconfig.vs2013-win64 +else + . $topsrcdir/build/win32/mozconfig.vs2010 +fi + +. "$topsrcdir/xulrunner/config/mozconfigs/common.override" diff --git a/application/xulrunner/config/mozconfigs/win64/xulrunner b/application/xulrunner/config/mozconfigs/win64/xulrunner new file mode 100644 index 000000000..7dbade2bb --- /dev/null +++ b/application/xulrunner/config/mozconfigs/win64/xulrunner @@ -0,0 +1,15 @@ +. "$topsrcdir/xulrunner/config/mozconfigs/common" + +ac_add_options --target=x86_64-pc-mingw32 +ac_add_options --host=x86_64-pc-mingw32 + +export MOZILLA_OFFICIAL=1 +export JAVA_HOME=/d/jdk1.6.0_14 + +ac_add_options --enable-application=xulrunner +ac_add_options --enable-jemalloc +ac_add_options --disable-tests + +. $topsrcdir/build/win64/mozconfig.vs2013 + +. "$topsrcdir/xulrunner/config/mozconfigs/common.override" diff --git a/application/xulrunner/configure.in b/application/xulrunner/configure.in new file mode 100644 index 000000000..825faaddd --- /dev/null +++ b/application/xulrunner/configure.in @@ -0,0 +1,11 @@ +dnl -*- Mode: Autoconf; tab-width: 2; indent-tabs-mode: nil; -*- +dnl vi: set tabstop=2 shiftwidth=2 expandtab: +dnl This Source Code Form is subject to the terms of the Mozilla Public +dnl License, v. 2.0. If a copy of the MPL was not distributed with this +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. + +dnl Things we need to carry from confvars.sh +AC_SUBST(MOZ_XULRUNNER) +AC_DEFINE(MOZ_XULRUNNER) + +dnl Optional parts of the build. diff --git a/application/xulrunner/confvars.sh b/application/xulrunner/confvars.sh new file mode 100644 index 000000000..a317df2a6 --- /dev/null +++ b/application/xulrunner/confvars.sh @@ -0,0 +1,28 @@ +#! /bin/sh +# 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/. + +MOZ_XULRUNNER=1 +MC_OFFICIAL=1 + +MOZ_APP_NAME=xulrunner +MOZ_APP_DISPLAYNAME=XULRunner +MOZ_APP_VERSION=$MOZILLA_VERSION +MOZ_CHROME_FILE_FORMAT=omni + +MOZ_UPDATER=1 + +if test "$OS_ARCH" = "WINNT"; then + MOZ_MAINTENANCE_SERVICE= +fi + +MOZ_PLACES=1 +MOZ_WEBRTC=1 +MOZ_WEBGL_CONFORMANT=1 + +MOZ_EXTENSIONS_DEFAULT=" gio" + +MOZ_SERVICES_COMMON=1 +MOZ_SERVICES_SYNC=1 +MOZ_SERVICES_HEALTHREPORT= diff --git a/application/xulrunner/examples/moz.build b/application/xulrunner/examples/moz.build new file mode 100644 index 000000000..a1782b42f --- /dev/null +++ b/application/xulrunner/examples/moz.build @@ -0,0 +1,7 @@ +# -*- 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/. + +DIRS += ['simple'] diff --git a/application/xulrunner/examples/simple/application.ini b/application/xulrunner/examples/simple/application.ini new file mode 100644 index 000000000..39c051422 --- /dev/null +++ b/application/xulrunner/examples/simple/application.ini @@ -0,0 +1,43 @@ +#filter substitution +[App] +; +; This field specifies your organization's name. This field is recommended, +; but optional. +Vendor=MozillaTest +; +; This field specifies your application's name. This field is required. +Name=Simple +; +; This field specifies your application's version. This field is required. +Version=0.1 +; +; This field specifies your application's build ID (timestamp). This field is +; required. +BuildID=20070625 +; +; This field specifies a compact copyright notice for your application. This +; field is optional. +Copyright=Copyright (c) 2004 Mozilla.org +; +; This ID is just an example. Every XUL app ought to have it's own unique ID. +; You can use the microsoft "guidgen" or "uuidgen" tools, or go on +; irc.mozilla.org and /msg botbot uuid. This field is optional. +ID={3aea3f07-ffe3-4060-bb03-bff3a5365e90} + +[Gecko] +; +; This field is required. It specifies the minimum Gecko version that this +; application requires. +MinVersion=@MOZILLA_VERSION_U@ +; +; This field is optional. It specifies the maximum Gecko version that this +; application requires. It should be specified if your application uses +; unfrozen interfaces. +MaxVersion=@MOZILLA_VERSION_U@ + +[Shell] +; +; This field specifies the location of your application's main icon with file +; extension excluded. NOTE: Unix style file separators are required. This +; field is optional. +Icon=chrome/icons/default/simple diff --git a/application/xulrunner/examples/simple/components/moz.build b/application/xulrunner/examples/simple/components/moz.build new file mode 100644 index 000000000..8ff468534 --- /dev/null +++ b/application/xulrunner/examples/simple/components/moz.build @@ -0,0 +1,7 @@ +# -*- 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/. + +DIRS += ['public', 'src'] diff --git a/application/xulrunner/examples/simple/components/public/moz.build b/application/xulrunner/examples/simple/components/public/moz.build new file mode 100644 index 000000000..3a611f85a --- /dev/null +++ b/application/xulrunner/examples/simple/components/public/moz.build @@ -0,0 +1,13 @@ +# -*- 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 += [ + 'nsISimpleTest.idl', +] + +XPIDL_MODULE = 'simple' + +XPI_NAME = 'simple' diff --git a/application/xulrunner/examples/simple/components/public/nsISimpleTest.idl b/application/xulrunner/examples/simple/components/public/nsISimpleTest.idl new file mode 100644 index 000000000..99b9b86af --- /dev/null +++ b/application/xulrunner/examples/simple/components/public/nsISimpleTest.idl @@ -0,0 +1,15 @@ +/* vim:set ts=2 sw=2 sts=2 et cin: */ +/* 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 "nsISupports.idl" + +[scriptable, uuid(f2f71d91-0451-47ec-aaa0-166663a7711a)] +interface nsISimpleTest : nsISupports +{ + /** + * This interface adds two numbers together and returns the result. + */ + long add(in long a, in long b); +}; diff --git a/application/xulrunner/examples/simple/components/src/SimpleTest.cpp b/application/xulrunner/examples/simple/components/src/SimpleTest.cpp new file mode 100644 index 000000000..06249abdd --- /dev/null +++ b/application/xulrunner/examples/simple/components/src/SimpleTest.cpp @@ -0,0 +1,54 @@ +/* vim:set ts=2 sw=2 sts=2 et cin: */ +/* 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 +#include "nsISimpleTest.h" +#include "mozilla/ModuleUtils.h" + +class SimpleTest : public nsISimpleTest +{ + ~SimpleTest() {} +public: + NS_DECL_ISUPPORTS + NS_DECL_NSISIMPLETEST +}; + +NS_IMPL_ISUPPORTS(SimpleTest, nsISimpleTest) + +NS_IMETHODIMP +SimpleTest::Add(int32_t a, int32_t b, int32_t *r) +{ + printf("add(%d,%d) from C++\n", a, b); + + *r = a + b; + return NS_OK; +} + +NS_GENERIC_FACTORY_CONSTRUCTOR(SimpleTest) + +// 5e14b432-37b6-4377-923b-c987418d8429 +#define SIMPLETEST_CID \ + { 0x5e14b432, 0x37b6, 0x4377, \ + { 0x92, 0x3b, 0xc9, 0x87, 0x41, 0x8d, 0x84, 0x29 } } + +NS_DEFINE_NAMED_CID(SIMPLETEST_CID); + +static const mozilla::Module::CIDEntry kSimpleCIDs[] = { + { &kSIMPLETEST_CID, false, nullptr, SimpleTestConstructor }, + { nullptr } +}; + +static const mozilla::Module::ContractIDEntry kSimpleContracts[] = { + { "@test.mozilla.org/simple-test;1?impl=c++", &kSIMPLETEST_CID }, + { nullptr } +}; + +static const mozilla::Module kSimpleModule = { + mozilla::Module::kVersion, + kSimpleCIDs, + kSimpleContracts +}; + +NSMODULE_DEFN(SimpleTestModule) = &kSimpleModule; diff --git a/application/xulrunner/examples/simple/components/src/SimpleTest.js b/application/xulrunner/examples/simple/components/src/SimpleTest.js new file mode 100644 index 000000000..e6cf90660 --- /dev/null +++ b/application/xulrunner/examples/simple/components/src/SimpleTest.js @@ -0,0 +1,27 @@ +/* vim:set ts=2 sw=2 sts=2 et cin: */ +/* 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/. */ + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +function SimpleTest() { +} + +SimpleTest.prototype = { + classID: Components.ID("{4177e257-a0dc-49b9-a774-522a000a49fa}"), + + QueryInterface: function(iid) { + if (iid.equals(Components.interfaces.nsISimpleTest) || + iid.equals(Components.interfaces.nsISupports)) + return this; + throw Components.results.NS_ERROR_NO_INTERFACE; + }, + + add: function(a, b) { + dump("add(" + a + "," + b + ") from JS\n"); + return a + b; + } +}; + +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SimpleTest]); diff --git a/application/xulrunner/examples/simple/components/src/SimpleTest.manifest b/application/xulrunner/examples/simple/components/src/SimpleTest.manifest new file mode 100644 index 000000000..c7388b9d7 --- /dev/null +++ b/application/xulrunner/examples/simple/components/src/SimpleTest.manifest @@ -0,0 +1,2 @@ +component {4177e257-a0dc-49b9-a774-522a000a49fa} SimpleTest.js +contract @test.mozilla.org/simple-test;1?impl=js {4177e257-a0dc-49b9-a774-522a000a49fa} diff --git a/application/xulrunner/examples/simple/components/src/moz.build b/application/xulrunner/examples/simple/components/src/moz.build new file mode 100644 index 000000000..153bfdd0c --- /dev/null +++ b/application/xulrunner/examples/simple/components/src/moz.build @@ -0,0 +1,21 @@ +# -*- 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/. + +SOURCES += [ + 'SimpleTest.cpp', +] + +XPCOMBinaryComponent('simpletest') + +EXTRA_COMPONENTS += [ + 'SimpleTest.js', + 'SimpleTest.manifest', +] + +XPI_NAME = 'simple' + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wshadow'] diff --git a/application/xulrunner/examples/simple/content/contents.rdf b/application/xulrunner/examples/simple/content/contents.rdf new file mode 100644 index 000000000..e69de29bb diff --git a/application/xulrunner/examples/simple/content/simple.js b/application/xulrunner/examples/simple/content/simple.js new file mode 100644 index 000000000..acf6f1029 --- /dev/null +++ b/application/xulrunner/examples/simple/content/simple.js @@ -0,0 +1,17 @@ +/* vim:set ts=2 sw=2 sts=2 et cin: */ +/* 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/. */ + +function onButtonClick() { + var textbox = document.getElementById("textbox"); + + var contractid = (textbox.value % 2 == 0) ? + "@test.mozilla.org/simple-test;1?impl=js" : + "@test.mozilla.org/simple-test;1?impl=c++"; + + var test = Components.classes[contractid]. + createInstance(Components.interfaces.nsISimpleTest); + + textbox.value = test.add(textbox.value, 1); +} diff --git a/application/xulrunner/examples/simple/content/simple.xul b/application/xulrunner/examples/simple/content/simple.xul new file mode 100644 index 000000000..6ff915d0c --- /dev/null +++ b/application/xulrunner/examples/simple/content/simple.xul @@ -0,0 +1,20 @@ + +# vim:set ts=8 sw=8 sts=8 noet: +# 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/. + + + + + + +