diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index d1f439e1a00bfd..06a86aafc955b9 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -128,11 +128,21 @@ pref("app.update.cert.maxErrors", 5); // when the |app.update.cert.checkAttributes| preference is set to false. Also, // the |app.update.url.override| preference should ONLY be used for testing. // IMPORTANT! metro.js should also be updated for updates to certs.X.issuerName + +// Nightly builds have switched over to aus4.mozilla.org, but we don't want anything else to yet. +#ifdef NIGHTLY_BUILD pref("app.update.certs.1.issuerName", "CN=DigiCert Secure Server CA,O=DigiCert Inc,C=US"); pref("app.update.certs.1.commonName", "aus4.mozilla.org"); pref("app.update.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US"); pref("app.update.certs.2.commonName", "aus4.mozilla.org"); +#else +pref("app.update.certs.1.issuerName", "OU=Equifax Secure Certificate Authority,O=Equifax,C=US"); +pref("app.update.certs.1.commonName", "aus3.mozilla.org"); + +pref("app.update.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US"); +pref("app.update.certs.2.commonName", "aus3.mozilla.org"); +#endif // Whether or not app updates are enabled pref("app.update.enabled", true); @@ -162,7 +172,11 @@ pref("app.update.silent", false); pref("app.update.staging.enabled", true); // Update service URL: +#ifdef NIGHTLY_BUILD pref("app.update.url", "https://aus4.mozilla.org/update/3/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml"); +#else +pref("app.update.url", "https://aus3.mozilla.org/update/3/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml"); +#endif // app.update.url.manual is in branding section // app.update.url.details is in branding section diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index 9759751f4bb38a..efdba4ac172e60 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -663,62 +663,6 @@ StackFramesView.prototype = Heritage.extend(WidgetMethods, { _prevBlackBoxedUrl: null }); -/** - * Utility functions for handling stackframes. - */ -let StackFrameUtils = { - /** - * Create a textual representation for the specified stack frame - * to display in the stackframes container. - * - * @param object aFrame - * The stack frame to label. - */ - getFrameTitle: function(aFrame) { - if (aFrame.type == "call") { - let c = aFrame.callee; - return (c.userDisplayName || c.displayName || c.name || "(anonymous)"); - } - return "(" + aFrame.type + ")"; - }, - - /** - * Constructs a scope label based on its environment. - * - * @param object aEnv - * The scope's environment. - * @return string - * The scope's label. - */ - getScopeLabel: function(aEnv) { - let name = ""; - - // Name the outermost scope Global. - if (!aEnv.parent) { - name = L10N.getStr("globalScopeLabel"); - } - // Otherwise construct the scope name. - else { - name = aEnv.type.charAt(0).toUpperCase() + aEnv.type.slice(1); - } - - let label = L10N.getFormatStr("scopeLabel", name); - switch (aEnv.type) { - case "with": - case "object": - label += " [" + aEnv.object.class + "]"; - break; - case "function": - let f = aEnv.function; - label += " [" + - (f.userDisplayName || f.displayName || f.name || "(anonymous)") + - "]"; - break; - } - return label; - } -}; - /** * Functions handling the filtering UI. */ diff --git a/browser/devtools/debugger/debugger-view.js b/browser/devtools/debugger/debugger-view.js index 8940863fa451ab..0101a6966d3559 100644 --- a/browser/devtools/debugger/debugger-view.js +++ b/browser/devtools/debugger/debugger-view.js @@ -148,6 +148,7 @@ let DebuggerView = { // Attach a controller that handles interfacing with the debugger protocol. VariablesViewController.attach(this.Variables, { + getEnvironmentClient: aObject => gThreadClient.environment(aObject), getObjectClient: aObject => gThreadClient.pauseGrip(aObject) }); diff --git a/browser/devtools/debugger/test/browser.ini b/browser/devtools/debugger/test/browser.ini index 8c6f35cc8a00f2..710e846288adce 100644 --- a/browser/devtools/debugger/test/browser.ini +++ b/browser/devtools/debugger/test/browser.ini @@ -22,6 +22,7 @@ support-files = code_ugly.js doc_binary_search.html doc_blackboxing.html + doc_closures.html doc_cmd-break.html doc_cmd-dbg.html doc_conditional-breakpoints.html @@ -69,6 +70,7 @@ support-files = [browser_dbg_chrome-debugging.js] [browser_dbg_clean-exit-window.js] [browser_dbg_clean-exit.js] +[browser_dbg_closure-inspection.js] [browser_dbg_cmd-blackbox.js] [browser_dbg_cmd-break.js] [browser_dbg_cmd-dbg.js] diff --git a/browser/devtools/debugger/test/browser_dbg_closure-inspection.js b/browser/devtools/debugger/test/browser_dbg_closure-inspection.js new file mode 100644 index 00000000000000..1acc1d1fc765ac --- /dev/null +++ b/browser/devtools/debugger/test/browser_dbg_closure-inspection.js @@ -0,0 +1,216 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +const TAB_URL = EXAMPLE_URL + "doc_closures.html"; + +// Test that inspecting a closure works as expected. + +function test() { + let gPanel, gTab, gDebuggee, gDebugger; + + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { + gTab = aTab; + gDebuggee = aDebuggee; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + + waitForSourceShown(gPanel, ".html") + .then(testClosure) + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) + .then(null, aError => { + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + }); + }); + + function testClosure() { + // Spin the event loop before causing the debuggee to pause, to allow + // this function to return first. + executeSoon(() => { + EventUtils.sendMouseEvent({ type: "click" }, + gDebuggee.document.querySelector("button"), + gDebuggee); + }); + + gDebuggee.gRecurseLimit = 2; + + return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { + let deferred = promise.defer(); + + let gVars = gDebugger.DebuggerView.Variables, + localScope = gVars.getScopeAtIndex(0), + globalScope = gVars.getScopeAtIndex(1), + localNodes = localScope.target.querySelector(".variables-view-element-details").childNodes, + globalNodes = globalScope.target.querySelector(".variables-view-element-details").childNodes; + + is(localNodes[4].querySelector(".name").getAttribute("value"), "person", + "Should have the right property name for |person|."); + + is(localNodes[4].querySelector(".value").getAttribute("value"), "Object", + "Should have the right property value for |person|."); + + // Expand the 'person' tree node. This causes its properties to be + // retrieved and displayed. + let personNode = gVars.getItemForNode(localNodes[4]); + personNode.expand(); + is(personNode.expanded, true, "person should be expanded at this point."); + + // Poll every few milliseconds until the properties are retrieved. + // It's important to set the timer in the chrome window, because the + // content window timers are disabled while the debuggee is paused. + let count1 = 0; + let intervalID = window.setInterval(function(){ + info("count1: " + count1); + if (++count1 > 50) { + ok(false, "Timed out while polling for the properties."); + window.clearInterval(intervalID); + deferred.reject("Timed out."); + return; + } + if (!personNode._retrieved) { + return; + } + window.clearInterval(intervalID); + + is(personNode.get("getName").target.querySelector(".name") + .getAttribute("value"), "getName", + "Should have the right property name for 'getName' in person."); + is(personNode.get("getName").target.querySelector(".value") + .getAttribute("value"), "Function", + "'getName' in person should have the right value."); + is(personNode.get("getFoo").target.querySelector(".name") + .getAttribute("value"), "getFoo", + "Should have the right property name for 'getFoo' in person."); + is(personNode.get("getFoo").target.querySelector(".value") + .getAttribute("value"), "Function", + "'getFoo' in person should have the right value."); + + // Expand the function nodes. This causes their properties to be + // retrieved and displayed. + let getFooNode = personNode.get("getFoo"); + let getNameNode = personNode.get("getName"); + getFooNode.expand(); + getNameNode.expand(); + is(getFooNode.expanded, true, "person.getFoo should be expanded at this point."); + is(getNameNode.expanded, true, "person.getName should be expanded at this point."); + + // Poll every few milliseconds until the properties are retrieved. + // It's important to set the timer in the chrome window, because the + // content window timers are disabled while the debuggee is paused. + let count2 = 0; + let intervalID1 = window.setInterval(function(){ + info("count2: " + count2); + if (++count2 > 50) { + ok(false, "Timed out while polling for the properties."); + window.clearInterval(intervalID1); + deferred.reject("Timed out."); + return; + } + if (!getFooNode._retrieved || !getNameNode._retrieved) { + return; + } + window.clearInterval(intervalID1); + + is(getFooNode.get("").target.querySelector(".name") + .getAttribute("value"), "", + "Found the closure node for getFoo."); + is(getFooNode.get("").target.querySelector(".value") + .getAttribute("value"), "", + "The closure node has no value for getFoo."); + is(getNameNode.get("").target.querySelector(".name") + .getAttribute("value"), "", + "Found the closure node for getName."); + is(getNameNode.get("").target.querySelector(".value") + .getAttribute("value"), "", + "The closure node has no value for getName."); + + // Expand the Closure nodes. + let getFooClosure = getFooNode.get(""); + let getNameClosure = getNameNode.get(""); + getFooClosure.expand(); + getNameClosure.expand(); + is(getFooClosure.expanded, true, "person.getFoo closure should be expanded at this point."); + is(getNameClosure.expanded, true, "person.getName closure should be expanded at this point."); + + // Poll every few milliseconds until the properties are retrieved. + // It's important to set the timer in the chrome window, because the + // content window timers are disabled while the debuggee is paused. + let count3 = 0; + let intervalID2 = window.setInterval(function(){ + info("count3: " + count3); + if (++count3 > 50) { + ok(false, "Timed out while polling for the properties."); + window.clearInterval(intervalID2); + deferred.reject("Timed out."); + return; + } + if (!getFooClosure._retrieved || !getNameClosure._retrieved) { + return; + } + window.clearInterval(intervalID2); + + is(getFooClosure.get("Function scope [_pfactory]").target.querySelector(".name") + .getAttribute("value"), "Function scope [_pfactory]", + "Found the function scope node for the getFoo closure."); + is(getFooClosure.get("Function scope [_pfactory]").target.querySelector(".value") + .getAttribute("value"), "", + "The function scope node has no value for the getFoo closure."); + is(getNameClosure.get("Function scope [_pfactory]").target.querySelector(".name") + .getAttribute("value"), "Function scope [_pfactory]", + "Found the function scope node for the getName closure."); + is(getNameClosure.get("Function scope [_pfactory]").target.querySelector(".value") + .getAttribute("value"), "", + "The function scope node has no value for the getName closure."); + + // Expand the scope nodes. + let getFooInnerScope = getFooClosure.get("Function scope [_pfactory]"); + let getNameInnerScope = getNameClosure.get("Function scope [_pfactory]"); + getFooInnerScope.expand(); + getNameInnerScope.expand(); + is(getFooInnerScope.expanded, true, "person.getFoo inner scope should be expanded at this point."); + is(getNameInnerScope.expanded, true, "person.getName inner scope should be expanded at this point."); + + // Poll every few milliseconds until the properties are retrieved. + // It's important to set the timer in the chrome window, because the + // content window timers are disabled while the debuggee is paused. + let count4 = 0; + let intervalID3 = window.setInterval(function(){ + info("count4: " + count4); + if (++count4 > 50) { + ok(false, "Timed out while polling for the properties."); + window.clearInterval(intervalID3); + deferred.reject("Timed out."); + return; + } + if (!getFooInnerScope._retrieved || !getNameInnerScope._retrieved) { + return; + } + window.clearInterval(intervalID3); + + // Only test that each function closes over the necessary variable. + // We wouldn't want future SpiderMonkey closure space + // optimizations to break this test. + is(getFooInnerScope.get("foo").target.querySelector(".name") + .getAttribute("value"), "foo", + "Found the foo node for the getFoo inner scope."); + is(getFooInnerScope.get("foo").target.querySelector(".value") + .getAttribute("value"), "10", + "The foo node has the expected value."); + is(getNameInnerScope.get("name").target.querySelector(".name") + .getAttribute("value"), "name", + "Found the name node for the getName inner scope."); + is(getNameInnerScope.get("name").target.querySelector(".value") + .getAttribute("value"), '"Bob"', + "The name node has the expected value."); + + deferred.resolve(); + }, 100); + }, 100); + }, 100); + }, 100); + + return deferred.promise; + }); + } +} diff --git a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js index 498d3b3eefa11e..8110042eeac8af 100644 --- a/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-filter-01.js @@ -81,8 +81,6 @@ function testVariablesAndPropertiesFiltering() { isnot(globalScope.target.querySelectorAll(".variables-view-variable:not([non-match])").length, 0, "There should be some variables displayed in the global scope."); - is(localScope.target.querySelectorAll(".variables-view-property:not([non-match])").length, 3, - "There should be 3 properties displayed in the local scope."); is(withScope.target.querySelectorAll(".variables-view-property:not([non-match])").length, 0, "There should be 0 properties displayed in the with scope."); is(functionScope.target.querySelectorAll(".variables-view-property:not([non-match])").length, 0, diff --git a/browser/devtools/debugger/test/doc_closures.html b/browser/devtools/debugger/test/doc_closures.html new file mode 100644 index 00000000000000..1ba91601a42ec3 --- /dev/null +++ b/browser/devtools/debugger/test/doc_closures.html @@ -0,0 +1,32 @@ + + + + + Debugger Test for Closure Inspection + + + + + + + + diff --git a/browser/devtools/scratchpad/scratchpad.js b/browser/devtools/scratchpad/scratchpad.js index ab835ec699c76f..6e8ad29587f0e8 100644 --- a/browser/devtools/scratchpad/scratchpad.js +++ b/browser/devtools/scratchpad/scratchpad.js @@ -56,6 +56,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "VariablesView", XPCOMUtils.defineLazyModuleGetter(this, "VariablesViewController", "resource:///modules/devtools/VariablesViewController.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "EnvironmentClient", + "resource://gre/modules/devtools/dbg-client.jsm"); + XPCOMUtils.defineLazyModuleGetter(this, "ObjectClient", "resource://gre/modules/devtools/dbg-client.jsm"); @@ -852,6 +855,8 @@ var Scratchpad = { fp.init(window, this.strings.GetStringFromName("openFile.title"), Ci.nsIFilePicker.modeOpen); fp.defaultString = ""; + fp.appendFilter("JavaScript Files", "*.js; *.jsm; *.json"); + fp.appendFilter("All Files", "*.*"); fp.open(aResult => { if (aResult != Ci.nsIFilePicker.returnCancel) { promptCallback(fp.file); @@ -1100,6 +1105,8 @@ var Scratchpad = { fp.init(window, this.strings.GetStringFromName("saveFileAs"), Ci.nsIFilePicker.modeSave); fp.defaultString = "scratchpad.js"; + fp.appendFilter("JavaScript Files", "*.js; *.jsm; *.json"); + fp.appendFilter("All Files", "*.*"); fp.open(fpCallback); }, @@ -1310,6 +1317,7 @@ var Scratchpad = { this._triggerObservers("Ready"); this.populateRecentFilesMenu(); PreferenceObserver.init(); + CloseObserver.init(); }).then(null, (err) => console.log(err.message)); }, @@ -1454,8 +1462,10 @@ var Scratchpad = { */ close: function SP_close(aCallback) { + let shouldClose; + this.promptSave((aShouldClose, aSaved, aStatus) => { - let shouldClose = aShouldClose; + shouldClose = aShouldClose; if (aSaved && !Components.isSuccessCode(aStatus)) { shouldClose = false; } @@ -1466,9 +1476,11 @@ var Scratchpad = { } if (aCallback) { - aCallback(); + aCallback(shouldClose); } }); + + return shouldClose; }, _observers: [], @@ -1744,6 +1756,9 @@ ScratchpadSidebar.prototype = { }); VariablesViewController.attach(this.variablesView, { + getEnvironmentClient: aGrip => { + return new EnvironmentClient(this._scratchpad.debuggerClient, aGrip); + }, getObjectClient: aGrip => { return new ObjectClient(this._scratchpad.debuggerClient, aGrip); }, @@ -1886,6 +1901,35 @@ var PreferenceObserver = { } }; + +/** + * The CloseObserver listens for the last browser window closing and attempts to + * close the Scratchpad. + */ +var CloseObserver = { + init: function CO_init() + { + Services.obs.addObserver(this, "browser-lastwindow-close-requested", false); + }, + + observe: function CO_observe(aSubject) + { + if (Scratchpad.close()) { + this.uninit(); + } + else { + aSubject.QueryInterface(Ci.nsISupportsPRBool); + aSubject.data = true; + } + }, + + uninit: function CO_uninit() + { + Services.obs.removeObserver(this, "browser-lastwindow-close-requested", + false); + }, +}; + XPCOMUtils.defineLazyGetter(Scratchpad, "strings", function () { return Services.strings.createBundle(SCRATCHPAD_L10N); }); diff --git a/browser/devtools/scratchpad/test/browser.ini b/browser/devtools/scratchpad/test/browser.ini index 17707325715294..9237ed814e777a 100644 --- a/browser/devtools/scratchpad/test/browser.ini +++ b/browser/devtools/scratchpad/test/browser.ini @@ -1,6 +1,7 @@ [DEFAULT] support-files = head.js +[browser_scratchpad_browser_last_window_closing.js] [browser_scratchpad_bug684546_reset_undo.js] [browser_scratchpad_bug690552_display_outputs_errors.js] [browser_scratchpad_bug714942_goto_line_ui.js] diff --git a/browser/devtools/scratchpad/test/browser_scratchpad_browser_last_window_closing.js b/browser/devtools/scratchpad/test/browser_scratchpad_browser_last_window_closing.js new file mode 100644 index 00000000000000..43be884cd7b1d4 --- /dev/null +++ b/browser/devtools/scratchpad/test/browser_scratchpad_browser_last_window_closing.js @@ -0,0 +1,79 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const BUTTON_POSITION_CANCEL = 1; +const BUTTON_POSITION_DONT_SAVE = 2; + + +function test() +{ + waitForExplicitFinish(); + + // Observer must be attached *before* Scratchpad is opened. + CloseObserver.init(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() { + gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true); + openScratchpad(runTests); + }, true); + + content.location = "data:text/html;charset=utf8,

test browser last window closing

"; +} + + + +function runTests({ Scratchpad }) +{ + let browser = Services.wm.getEnumerator("navigator:browser").getNext(); + let oldPrompt = Services.prompt; + let button; + + Services.prompt = { + confirmEx: () => button + }; + + + Scratchpad.dirty = true; + + // Test canceling close. + button = BUTTON_POSITION_CANCEL; + CloseObserver.expectedValue = true; + browser.BrowserTryToCloseWindow(); + + // Test accepting close. + button = BUTTON_POSITION_DONT_SAVE; + CloseObserver.expectedValue = false; + browser.BrowserTryToCloseWindow(); + + // Test closing without prompt needed. + Scratchpad.dirty = false; + browser.BrowserTryToCloseWindow(); + + Services.prompt = oldPrompt; + CloseObserver.uninit(); + finish(); +} + + +let CloseObserver = { + expectedValue: null, + init: function() + { + Services.obs.addObserver(this, "browser-lastwindow-close-requested", false); + }, + + observe: function(aSubject) + { + aSubject.QueryInterface(Ci.nsISupportsPRBool); + let message = this.expectedValue ? "close" : "stay open"; + ok(this.expectedValue === aSubject.data, "Expected browser to " + message); + aSubject.data = true; + }, + + uninit: function() + { + Services.obs.removeObserver(this, "browser-lastwindow-close-requested", false); + }, +}; diff --git a/browser/devtools/shared/widgets/VariablesView.jsm b/browser/devtools/shared/widgets/VariablesView.jsm index 72acf3b9ebd1da..dbdf993cd8bd5e 100644 --- a/browser/devtools/shared/widgets/VariablesView.jsm +++ b/browser/devtools/shared/widgets/VariablesView.jsm @@ -1136,7 +1136,8 @@ Scope.prototype = { * @param object aDescriptor * Specifies the value and/or type & class of the child, * or 'get' & 'set' accessor properties. If the type is implicit, - * it will be inferred from the value. + * it will be inferred from the value. If this parameter is omitted, + * a property without a value will be added (useful for branch nodes). * e.g. - { value: 42 } * - { value: true } * - { value: "nasu" } @@ -2304,6 +2305,11 @@ Variable.prototype = Heritage.extend(Scope.prototype, { this.hideArrow(); } + // If no value will be displayed, we don't need the separator. + if (!descriptor.get && !descriptor.set && !descriptor.value) { + separatorLabel.hidden = true; + } + if (descriptor.get || descriptor.set) { separatorLabel.hidden = true; valueLabel.hidden = true; @@ -2441,7 +2447,8 @@ Variable.prototype = Heritage.extend(Scope.prototype, { /** * Sets a variable's configurable, enumerable and writable attributes, - * and specifies if it's a 'this', '' or '__proto__' reference. + * and specifies if it's a 'this', '', '' or '__proto__' + * reference. */ _setAttributes: function() { let ownerView = this.ownerView; @@ -2485,7 +2492,6 @@ Variable.prototype = Heritage.extend(Scope.prototype, { if (name == "this") { target.setAttribute("self", ""); } - else if (name == "") { target.setAttribute("exception", ""); } diff --git a/browser/devtools/shared/widgets/VariablesViewController.jsm b/browser/devtools/shared/widgets/VariablesViewController.jsm index 97c1a5b5c918fa..e5c110abef87da 100644 --- a/browser/devtools/shared/widgets/VariablesViewController.jsm +++ b/browser/devtools/shared/widgets/VariablesViewController.jsm @@ -28,9 +28,13 @@ XPCOMUtils.defineLazyGetter(this, "VARIABLES_SORTING_ENABLED", () => Services.prefs.getBoolPref("devtools.debugger.ui.variables-sorting-enabled") ); +XPCOMUtils.defineLazyModuleGetter(this, "console", + "resource://gre/modules/devtools/Console.jsm"); + const MAX_LONG_STRING_LENGTH = 200000; +const DBG_STRINGS_URI = "chrome://browser/locale/devtools/debugger.properties"; -this.EXPORTED_SYMBOLS = ["VariablesViewController"]; +this.EXPORTED_SYMBOLS = ["VariablesViewController", "StackFrameUtils"]; /** @@ -44,6 +48,7 @@ this.EXPORTED_SYMBOLS = ["VariablesViewController"]; * Options for configuring the controller. Supported options: * - getObjectClient: callback for creating an object grip client * - getLongStringClient: callback for creating a long string grip client + * - getEnvironmentClient: callback for creating an environment client * - releaseActor: callback for releasing an actor when it's no longer needed * - overrideValueEvalMacro: callback for creating an overriding eval macro * - getterOrSetterEvalMacro: callback for creating a getter/setter eval macro @@ -54,6 +59,7 @@ function VariablesViewController(aView, aOptions) { this._getObjectClient = aOptions.getObjectClient; this._getLongStringClient = aOptions.getLongStringClient; + this._getEnvironmentClient = aOptions.getEnvironmentClient; this._releaseActor = aOptions.releaseActor; if (aOptions.overrideValueEvalMacro) { @@ -131,8 +137,15 @@ VariablesViewController.prototype = { */ _populateFromObject: function(aTarget, aGrip) { let deferred = promise.defer(); + // Mark the specified variable as having retrieved all its properties. + let finish = variable => { + variable._retrieved = true; + this.view.commitHierarchy(); + deferred.resolve(); + }; - this._getObjectClient(aGrip).getPrototypeAndProperties(aResponse => { + let objectClient = this._getObjectClient(aGrip); + objectClient.getPrototypeAndProperties(aResponse => { let { ownProperties, prototype } = aResponse; // safeGetterValues is new and isn't necessary defined on old actors let safeGetterValues = aResponse.safeGetterValues || {}; @@ -167,20 +180,108 @@ VariablesViewController.prototype = { this.addExpander(proto, prototype); } - // Mark the variable as having retrieved all its properties. - aTarget._retrieved = true; - this.view.commitHierarchy(); - deferred.resolve(); + // If the object is a function we need to fetch its scope chain. + if (aGrip.class == "Function") { + objectClient.getScope(aResponse => { + if (aResponse.error) { + console.error(aResponse.error + ": " + aResponse.message); + finish(aTarget); + return; + } + this._addVarScope(aTarget, aResponse.scope).then(() => finish(aTarget)); + }); + } else { + finish(aTarget); + } }); return deferred.promise; }, + /** + * Adds the scope chain elements (closures) of a function variable to the + * view. + * + * @param Variable aTarget + * The variable where the properties will be placed into. + * @param Scope aScope + * The lexical environment form as specified in the protocol. + */ + _addVarScope: function(aTarget, aScope) { + let objectScopes = []; + let environment = aScope; + let funcScope = aTarget.addItem(""); + funcScope._target.setAttribute("scope", ""); + funcScope._fetched = true; + funcScope.showArrow(); + do { + // Create a scope to contain all the inspected variables. + let label = StackFrameUtils.getScopeLabel(environment); + // Block scopes have the same label, so make addItem allow duplicates. + let closure = funcScope.addItem(label, undefined, true); + closure._target.setAttribute("scope", ""); + closure._fetched = environment.class == "Function"; + closure.showArrow(); + // Add nodes for every argument and every other variable in scope. + if (environment.bindings) { + this._addBindings(closure, environment.bindings); + funcScope._retrieved = true; + closure._retrieved = true; + } else { + let deferred = Promise.defer(); + objectScopes.push(deferred.promise); + this._getEnvironmentClient(environment).getBindings(response => { + this._addBindings(closure, response.bindings); + funcScope._retrieved = true; + closure._retrieved = true; + deferred.resolve(); + }); + } + } while ((environment = environment.parent)); + aTarget.expand(); + + return Promise.all(objectScopes).then(() => { + // Signal that scopes have been fetched. + this.view.emit("fetched", "scopes", funcScope); + }); + }, + + /** + * Adds nodes for every specified binding to the closure node. + * + * @param Variable closure + * The node where the bindings will be placed into. + * @param object bindings + * The bindings form as specified in the protocol. + */ + _addBindings: function(closure, bindings) { + for (let argument of bindings.arguments) { + let name = Object.getOwnPropertyNames(argument)[0]; + let argRef = closure.addItem(name, argument[name]); + let argVal = argument[name].value; + this.addExpander(argRef, argVal); + } + + let aVariables = bindings.variables; + let variableNames = Object.keys(aVariables); + + // Sort all of the variables before adding them, if preferred. + if (VARIABLES_SORTING_ENABLED) { + variableNames.sort(); + } + // Add the variables to the specified scope. + for (let name of variableNames) { + let varRef = closure.addItem(name, aVariables[name]); + let varVal = aVariables[name].value; + this.addExpander(varRef, varVal); + } + }, + /** * Adds an 'onexpand' callback for a variable, lazily handling * the addition of new properties. * - * @param Variable aVar + * @param Variable aTarget * The variable where the properties will be placed into. * @param any aSource * The source to use to populate the target. @@ -254,7 +355,7 @@ VariablesViewController.prototype = { throw new Error("No actor grip was given for the variable."); } - // If the target a Variable or Property then we're fetching properties + // If the target is a Variable or Property then we're fetching properties. if (VariablesView.isVariable(aTarget)) { this._populateFromObject(aTarget, aSource).then(() => { deferred.resolve(); @@ -360,3 +461,64 @@ VariablesViewController.attach = function(aView, aOptions) { } return new VariablesViewController(aView, aOptions); }; + +/** + * Utility functions for handling stackframes. + */ +let StackFrameUtils = { + /** + * Create a textual representation for the specified stack frame + * to display in the stackframes container. + * + * @param object aFrame + * The stack frame to label. + */ + getFrameTitle: function(aFrame) { + if (aFrame.type == "call") { + let c = aFrame.callee; + return (c.name || c.userDisplayName || c.displayName || "(anonymous)"); + } + return "(" + aFrame.type + ")"; + }, + + /** + * Constructs a scope label based on its environment. + * + * @param object aEnv + * The scope's environment. + * @return string + * The scope's label. + */ + getScopeLabel: function(aEnv) { + let name = ""; + + // Name the outermost scope Global. + if (!aEnv.parent) { + name = L10N.getStr("globalScopeLabel"); + } + // Otherwise construct the scope name. + else { + name = aEnv.type.charAt(0).toUpperCase() + aEnv.type.slice(1); + } + + let label = L10N.getFormatStr("scopeLabel", name); + switch (aEnv.type) { + case "with": + case "object": + label += " [" + aEnv.object.class + "]"; + break; + case "function": + let f = aEnv.function; + label += " [" + + (f.name || f.userDisplayName || f.displayName || "(anonymous)") + + "]"; + break; + } + return label; + } +}; + +/** + * Localization convenience methods. + */ +let L10N = new ViewHelpers.L10N(DBG_STRINGS_URI); diff --git a/browser/devtools/webconsole/test/browser.ini b/browser/devtools/webconsole/test/browser.ini index 99fe47fc1e9c82..1d434c80f0fd38 100644 --- a/browser/devtools/webconsole/test/browser.ini +++ b/browser/devtools/webconsole/test/browser.ini @@ -59,6 +59,7 @@ support-files = test-bug-859170-longstring-hang.html test-bug-869003-iframe.html test-bug-869003-top-window.html + test-closures.html test-console-extras.html test-console-replaced-api.html test-console.html @@ -210,6 +211,7 @@ support-files = [browser_webconsole_cached_autocomplete.js] [browser_webconsole_change_font_size.js] [browser_webconsole_chrome.js] +[browser_webconsole_closure_inspection.js] [browser_webconsole_completion.js] [browser_webconsole_console_extras.js] [browser_webconsole_console_logging_api.js] diff --git a/browser/devtools/webconsole/test/browser_webconsole_closure_inspection.js b/browser/devtools/webconsole/test/browser_webconsole_closure_inspection.js new file mode 100644 index 00000000000000..bbcf0be70fb44d --- /dev/null +++ b/browser/devtools/webconsole/test/browser_webconsole_closure_inspection.js @@ -0,0 +1,91 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Check that inspecting a closure in the variables view sidebar works when +// execution is paused. + +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-closures.html"; + +let gWebConsole, gJSTerm, gVariablesView; + +function test() +{ + registerCleanupFunction(() => { + gWebConsole = gJSTerm = gVariablesView = null; + }); + + addTab(TEST_URI); + browser.addEventListener("load", function onLoad() { + browser.removeEventListener("load", onLoad, true); + openConsole(null, (hud) => { + openDebugger().then(({ toolbox, panelWin }) => { + let deferred = promise.defer(); + panelWin.gThreadClient.addOneTimeListener("resumed", (aEvent, aPacket) => { + ok(true, "Debugger resumed"); + deferred.resolve({ toolbox: toolbox, panelWin: panelWin }); + }); + return deferred.promise; + }).then(({ toolbox, panelWin }) => { + let deferred = promise.defer(); + panelWin.once(panelWin.EVENTS.FETCHED_SCOPES, (aEvent, aPacket) => { + ok(true, "Scopes were fetched"); + toolbox.selectTool("webconsole").then(() => consoleOpened(hud)); + deferred.resolve(); + }); + + let button = content.document.querySelector("button"); + ok(button, "button element found"); + button.click(); + + return deferred.promise; + }); + }); + }, true); +} + +function consoleOpened(hud) +{ + gWebConsole = hud; + gJSTerm = hud.jsterm; + gJSTerm.execute("window.george.getName"); + + waitForMessages({ + webconsole: gWebConsole, + messages: [{ + text: "[object Function]", + category: CATEGORY_OUTPUT, + objects: true, + }], + }).then(onExecuteGetName); +} + +function onExecuteGetName(aResults) +{ + let clickable = aResults[0].clickableElements[0]; + ok(clickable, "clickable object found"); + + gJSTerm.once("variablesview-fetched", onGetNameFetch); + EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow) +} + +function onGetNameFetch(aEvent, aVar) +{ + gVariablesView = aVar._variablesView; + ok(gVariablesView, "variables view object"); + + findVariableViewProperties(aVar, [ + { name: /_pfactory/, value: "" }, + ], { webconsole: gWebConsole }).then(onExpandClosure); +} + +function onExpandClosure(aResults) +{ + let prop = aResults[0].matchedProp; + ok(prop, "matched the name property in the variables view"); + + gVariablesView.window.focus(); + gJSTerm.once("sidebar-closed", finishTest); + EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window); +} diff --git a/browser/devtools/webconsole/test/test-closures.html b/browser/devtools/webconsole/test/test-closures.html new file mode 100644 index 00000000000000..4fadade20791c8 --- /dev/null +++ b/browser/devtools/webconsole/test/test-closures.html @@ -0,0 +1,26 @@ + + + + + Console Test for Closure Inspection + + + + + + + + diff --git a/browser/devtools/webconsole/webconsole.js b/browser/devtools/webconsole/webconsole.js index 549362995863fe..6c2e51b7094d3f 100644 --- a/browser/devtools/webconsole/webconsole.js +++ b/browser/devtools/webconsole/webconsole.js @@ -26,6 +26,7 @@ loader.lazyGetter(this, "ConsoleOutput", () => require("devtools/webconsole/console-output").ConsoleOutput); loader.lazyGetter(this, "Messages", () => require("devtools/webconsole/console-output").Messages); +loader.lazyImporter(this, "EnvironmentClient", "resource://gre/modules/devtools/dbg-client.jsm"); loader.lazyImporter(this, "ObjectClient", "resource://gre/modules/devtools/dbg-client.jsm"); loader.lazyImporter(this, "VariablesView", "resource:///modules/devtools/VariablesView.jsm"); loader.lazyImporter(this, "VariablesViewController", "resource:///modules/devtools/VariablesViewController.jsm"); @@ -3423,6 +3424,9 @@ JSTerm.prototype = { view.lazyAppend = this._lazyVariablesView; VariablesViewController.attach(view, { + getEnvironmentClient: aGrip => { + return new EnvironmentClient(this.hud.proxy.client, aGrip); + }, getObjectClient: aGrip => { return new ObjectClient(this.hud.proxy.client, aGrip); }, diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index b9af55d06498f0..2f70ea96fb46f3 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,4 +1,4 @@ This is the pdf.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 0.8.505 +Current extension version is: 0.8.558 diff --git a/browser/extensions/pdfjs/components/PdfRedirector.js b/browser/extensions/pdfjs/components/PdfRedirector.js index 24d66a2ded58b3..4a08ec2eb90ff7 100644 --- a/browser/extensions/pdfjs/components/PdfRedirector.js +++ b/browser/extensions/pdfjs/components/PdfRedirector.js @@ -43,50 +43,30 @@ function getDOMWindow(aChannel) { } function getObjectUrl(window) { - var url; - var element = window.frameElement; - var isOverlay = false; - var params = {}; - if (element) { - var tagName = element.nodeName; - while (tagName != 'EMBED' && tagName != 'OBJECT') { - // plugin overlay skipping until the target plugin is found - isOverlay = true; - element = element.parentNode; - if (!element) - throw 'Plugin element is not found'; - tagName = element.nodeName; - } - if (tagName == 'EMBED') { - for (var i = 0; i < element.attributes.length; ++i) { - params[element.attributes[i].localName] = element.attributes[i].value; - } - url = params.src; - } else { - for (var i = 0; i < element.childNodes.length; ++i) { - var paramElement = element.childNodes[i]; - if (paramElement.nodeType != Ci.nsIDOMNode.ELEMENT_NODE || - paramElement.nodeName != 'PARAM') { - continue; - } - - params[paramElement.getAttribute('name')] = - paramElement.getAttribute('value'); - } - var dataAttribute = element.getAttribute('data'); - url = dataAttribute || params.movie || params.src; - } + // PlayPreview overlay "belongs" to the embed/object tag and consists of DIV + // and IFRAME. Starting from IFRAME and looking for first object tag. + var element = window.frameElement, containerElement; + if (!element) { + return null; // iframe tag } - if (!url) { - return url; // src is not specified + var tagName = element.nodeName; + while (tagName !== 'EMBED' && tagName !== 'OBJECT') { + containerElement = element; + element = element.parentNode; + if (!element) { + return null; // object tag was not found + } + tagName = element.nodeName; } - var element = window.frameElement; - // XXX base uri? - var baseUri = !element ? null : - Services.io.newURI(element.ownerDocument.location.href, null, null); + // Checking if overlay is a proper PlayPreview overlay. + for (var i = 0; i < element.children.length; i++) { + if (element.children[i] === containerElement) { + return null; // invalid plugin element overlay + } + } - return Services.io.newURI(url, null, baseUri).spec; + return element.srcURI.spec; } function PdfRedirector() { diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 9247164f740648..4a0e921f6b4dcd 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '0.8.505'; -PDFJS.build = 'da1c944'; +PDFJS.version = '0.8.558'; +PDFJS.build = 'ea50c07'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index d116a9d11dc9fc..2ea9bf50bcdccf 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '0.8.505'; -PDFJS.build = 'da1c944'; +PDFJS.version = '0.8.558'; +PDFJS.build = 'ea50c07'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -3564,6 +3564,10 @@ var BasePdfManager = (function BasePdfManagerClosure() { if (this.passwordChangedPromise) { this.passwordChangedPromise.resolve(); } + }, + + terminate: function BasePdfManager_terminate() { + return new NotImplementedException(); } }; @@ -3616,6 +3620,11 @@ var LocalPdfManager = (function LocalPdfManagerClosure() { return this.loadedStream; }; + LocalPdfManager.prototype.terminate = + function LocalPdfManager_terminate() { + return; + }; + return LocalPdfManager; })(); @@ -3693,6 +3702,11 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() { return this.streamManager.onLoadedStream(); }; + NetworkPdfManager.prototype.terminate = + function NetworkPdfManager_terminate() { + this.streamManager.networkManager.abortAllRequests(); + }; + return NetworkPdfManager; })(); @@ -4576,6 +4590,12 @@ var Catalog = (function CatalogClosure() { }, getPage: function Catalog_getPage(pageIndex) { + if (pageIndex < 0 || pageIndex >= this.numPages || + (pageIndex|0) !== pageIndex) { + var pagePromise = new Promise(); + pagePromise.reject(new Error('Invalid page index')); + return pagePromise; + } if (!(pageIndex in this.pagePromises)) { this.pagePromises[pageIndex] = new Promise(); } @@ -14546,14 +14566,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var bidiTexts; var SPACE_FACTOR = 0.35; var MULTI_SPACE_FACTOR = 1.5; + var textState; if (!state) { + textState = new TextState(); bidiTexts = []; state = { + textState: textState, bidiTexts: bidiTexts }; } else { bidiTexts = state.bidiTexts; + textState = state.textState; } var self = this; @@ -14573,6 +14597,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var chunk = ''; var font = null; + var charSpace = 0, wordSpace = 0; while (!isEOF(obj = parser.getObj())) { if (isCmd(obj)) { var cmd = obj.cmd; @@ -14580,6 +14605,49 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // TODO: Add support for SAVE/RESTORE and XFORM here. case 'Tf': font = handleSetFont(args[0].name).translated; + textState.fontSize = args[1]; + break; + case 'Ts': + textState.textRise = args[0]; + break; + case 'Tz': + textState.textHScale = args[0] / 100; + break; + case 'TL': + textState.leading = args[0]; + break; + case 'Td': + textState.translateTextMatrix(args[0], args[1]); + break; + case 'TD': + textState.leading = -args[1]; + textState.translateTextMatrix(args[0], args[1]); + break; + case 'T*': + textState.translateTextMatrix(0, -textState.leading); + break; + case 'Tm': + textState.setTextMatrix(args[0], args[1], + args[2], args[3], args[4], args[5]); + break; + case 'Tc': + charSpace = args[0]; + break; + case 'Tw': + wordSpace = args[0]; + break; + case 'q': + textState.push(); + break; + case 'Q': + textState.pop(); + break; + case 'BT': + textState.initialiseTextObj(); + break; + case 'cm': + textState.transformCTM(args[0], args[1], args[2], + args[3], args[4], args[5]); break; case 'TJ': var items = args[0]; @@ -14665,6 +14733,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { if (chunk !== '') { var bidiText = PDFJS.bidi(chunk, -1, font.vertical); + var renderParams = textState.calcRenderParams(); + bidiText.x = renderParams.renderMatrix[4] - (textState.fontSize * + renderParams.vScale * Math.sin(renderParams.angle)); + bidiText.y = renderParams.renderMatrix[5] + (textState.fontSize * + renderParams.vScale * Math.cos(renderParams.angle)); + if (bidiText.dir == 'ttb') { + bidiText.x += renderParams.vScale / 2; + bidiText.y -= renderParams.vScale; + } bidiTexts.push(bidiText); chunk = ''; @@ -14774,119 +14851,24 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { if (!isIdentityMap) error('ToUnicode file cmap translation not implemented'); } else if (isStream(cmapObj)) { - var tokens = []; - var token = ''; - var beginArrayToken = {}; - - var cmap = cmapObj.getBytes(cmapObj.length); - for (var i = 0, ii = cmap.length; i < ii; i++) { - var octet = cmap[i]; - if (octet == 0x20 || octet == 0x0D || octet == 0x0A || - octet == 0x3C || octet == 0x5B || octet == 0x5D) { - switch (token) { - case 'usecmap': - error('usecmap is not implemented'); - break; - - case 'beginbfchar': - case 'beginbfrange': - case 'begincidchar': - case 'begincidrange': - token = ''; - tokens = []; - break; - - case 'endcidrange': - case 'endbfrange': - for (var j = 0, jj = tokens.length; j < jj; j += 3) { - var startRange = tokens[j]; - var endRange = tokens[j + 1]; - var code = tokens[j + 2]; - if (code == 0xFFFF) { - // CMap is broken, assuming code == startRange - code = startRange; - } - if (isArray(code)) { - var codeindex = 0; - while (startRange <= endRange) { - charToUnicode[startRange] = code[codeindex++]; - ++startRange; - } - } else { - while (startRange <= endRange) { - charToUnicode[startRange] = code++; - ++startRange; - } - } - } - break; - - case 'endcidchar': - case 'endbfchar': - for (var j = 0, jj = tokens.length; j < jj; j += 2) { - var index = tokens[j]; - var code = tokens[j + 1]; - charToUnicode[index] = code; - } - break; - - case '': - break; - - default: - if (token[0] >= '0' && token[0] <= '9') - token = parseInt(token, 10); // a number - tokens.push(token); - token = ''; - } - switch (octet) { - case 0x5B: - // begin list parsing - tokens.push(beginArrayToken); - break; - case 0x5D: - // collect array items - var items = [], item; - while (tokens.length && - (item = tokens.pop()) != beginArrayToken) - items.unshift(item); - tokens.push(items); - break; - } - } else if (octet == 0x3E) { - if (token.length) { - // Heuristic: guessing chars size by checking numbers sizes - // in the CMap entries. - if (token.length == 2 && properties.composite) - properties.wideChars = false; - - if (token.length <= 4) { - // parsing hex number - tokens.push(parseInt(token, 16)); - token = ''; - } else { - // parsing hex UTF-16BE numbers - var str = []; - for (var k = 0, kk = token.length; k < kk; k += 4) { - var b = parseInt(token.substr(k, 4), 16); - if (b <= 0x10) { - k += 4; - b = (b << 16) | parseInt(token.substr(k, 4), 16); - b -= 0x10000; - str.push(0xD800 | (b >> 10)); - str.push(0xDC00 | (b & 0x3FF)); - break; - } - str.push(b); - } - tokens.push(String.fromCharCode.apply(String, str)); - token = ''; - } + var cmap = CMapFactory.create(cmapObj).map; + // Convert UTF-16BE + for (var i in cmap) { + var token = cmap[i]; + var str = []; + for (var k = 0; k < token.length; k += 2) { + var w1 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1); + if ((w1 & 0xF800) !== 0xD800) { // w1 < 0xD800 || w1 > 0xDFFF + str.push(w1); + continue; } - } else { - token += String.fromCharCode(octet); + k += 2; + var w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1); + str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000); } + cmap[i] = String.fromCharCode.apply(String, str); } + return cmap; } return charToUnicode; }, @@ -15173,6 +15155,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { properties.cidEncoding = cidEncoding.name; properties.vertical = /-V$/.test(cidEncoding.name); } + properties.cmap = CMapFactory.create(cidEncoding); } this.extractWidths(dict, xref, descriptor, properties); this.extractDataStructures(dict, baseDict, xref, properties); @@ -15373,6 +15356,78 @@ var OperatorList = (function OperatorListClosure() { return OperatorList; })(); +var TextState = (function TextStateClosure() { + function TextState() { + this.fontSize = 0; + this.ctm = [1, 0, 0, 1, 0, 0]; + this.textMatrix = [1, 0, 0, 1, 0, 0]; + this.stateStack = []; + //textState variables + this.leading = 0; + this.textHScale = 1; + this.textRise = 0; + } + TextState.prototype = { + push: function TextState_push() { + this.stateStack.push(this.ctm.slice()); + }, + pop: function TextStae_pop() { + this.ctm = this.stateStack.pop(); + }, + initialiseTextObj: function TextState_initialiseTextObj() { + var m = this.textMatrix; + m[0] = 1, m[1] = 0, m[2] = 0, m[3] = 1, m[4] = 0, m[5] = 0; + }, + setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) { + var m = this.textMatrix; + m[0] = a, m[1] = b, m[2] = c, m[3] = d, m[4] = e, m[5] = f; + }, + transformCTM: function TextState_transformCTM(a, b, c, d, e, f) { + var m = this.ctm; + var m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3], m4 = m[4], m5 = m[5]; + m[0] = m0 * a + m2 * b; + m[1] = m1 * a + m3 * b; + m[2] = m0 * c + m2 * d; + m[3] = m1 * c + m3 * d; + m[4] = m0 * e + m2 * f + m4; + m[5] = m1 * e + m3 * f + m5; + }, + translateTextMatrix: function TextState_translateTextMatrix(x, y) { + var m = this.textMatrix; + m[4] = m[0] * x + m[2] * y + m[4]; + m[5] = m[1] * x + m[3] * y + m[5]; + }, + calcRenderParams: function TextState_calcRenderingParams() { + var tm = this.textMatrix; + var cm = this.ctm; + var a = this.fontSize; + var b = a * this.textHScale; + var c = this.textRise; + var vScale = Math.sqrt((tm[2] * tm[2]) + (tm[3] * tm[3])); + var angle = Math.atan2(tm[1], tm[0]); + var m0 = tm[0] * cm[0] + tm[1] * cm[2]; + var m1 = tm[0] * cm[1] + tm[1] * cm[3]; + var m2 = tm[2] * cm[0] + tm[3] * cm[2]; + var m3 = tm[2] * cm[1] + tm[3] * cm[3]; + var m4 = tm[4] * cm[0] + tm[5] * cm[2] + cm[4]; + var m5 = tm[4] * cm[1] + tm[5] * cm[3] + cm[5]; + var renderMatrix = [ + b * m0, + b * m1, + a * m2, + a * m3, + c * m2 + m4, + c * m3 + m5 + ]; + return { + renderMatrix: renderMatrix, + vScale: vScale, + angle: angle + }; + }, + }; + return TextState; +})(); var EvalState = (function EvalStateClosure() { function EvalState() { @@ -17549,6 +17604,7 @@ var Font = (function FontClosure() { this.composite = properties.composite; this.wideChars = properties.wideChars; this.hasEncoding = properties.hasEncoding; + this.cmap = properties.cmap; this.fontMatrix = properties.fontMatrix; if (properties.type == 'Type3') { @@ -19068,7 +19124,7 @@ var Font = (function FontClosure() { var dupFirstEntry = false; if (properties.type == 'CIDFontType2' && properties.toUnicode && - properties.toUnicode[0] > 0) { + properties.toUnicode[0] > '\u0000') { // oracle's defect (see 3427), duplicating first entry dupFirstEntry = true; numGlyphs++; @@ -19617,8 +19673,12 @@ var Font = (function FontClosure() { var unicode = toUnicode[i]; var fontCharCode = typeof unicode === 'object' ? unusedUnicode++ : unicode; - if (typeof unicode !== 'undefined') + if (typeof unicode !== 'undefined') { + if (isString(fontCharCode) && fontCharCode.length === 1) { + fontCharCode = fontCharCode.charCodeAt(0); + } result[i] = fontCharCode; + } } return result; }, @@ -19631,7 +19691,7 @@ var Font = (function FontClosure() { var isIdentityMap = toUnicode.length === 0; for (var i = firstChar, ii = lastChar; i <= ii; i++) { // TODO missing map the character according font's CMap - map[i] = isIdentityMap ? i : toUnicode[i]; + map[i] = isIdentityMap ? String.fromCharCode(i) : toUnicode[i]; } } else { for (var i = firstChar, ii = lastChar; i <= ii; i++) { @@ -19639,7 +19699,7 @@ var Font = (function FontClosure() { if (!glyph) glyph = properties.baseEncoding[i]; if (!!glyph && (glyph in GlyphsUnicode)) - map[i] = GlyphsUnicode[glyph]; + map[i] = String.fromCharCode(GlyphsUnicode[glyph]); } } this.toUnicode = map; @@ -19902,15 +19962,15 @@ var Font = (function FontClosure() { warn('Unsupported CMap: ' + cidEncoding); } } - if (!converter && this.wideChars) { + if (!converter && this.cmap) { + var i = 0; // composite fonts have multi-byte strings convert the string from // single-byte to multi-byte - // XXX assuming CIDFonts are two-byte - later need to extract the - // correct byte encoding according to the PDF spec - var length = chars.length - 1; // looping over two bytes at a time so - // loop should never end on the last byte - for (var i = 0; i < length; i++) { - var charcode = int16([chars.charCodeAt(i++), chars.charCodeAt(i)]); + while (i < chars.length) { + var c = this.cmap.readCharCode(chars, i); + var charcode = c[0]; + var length = c[1]; + i += length; var glyph = this.charToGlyph(charcode); glyphs.push(glyph); // placing null after each word break charcode (ASCII SPACE) @@ -34079,7 +34139,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { }); handler.on('Terminate', function wphTerminate(data, promise) { - pdfManager.streamManager.networkManager.abortAllRequests(); + pdfManager.terminate(); promise.resolve(); }); } @@ -37514,6 +37574,447 @@ var bidi = PDFJS.bidi = (function bidiClosure() { return bidi; })(); + + +var CMAP_CODESPACES = { + 'Adobe-CNS1-0': [[], [0, 14335]], + 'Adobe-CNS1-1': [[], [0, 17407]], + 'Adobe-CNS1-2': [[], [0, 17663]], + 'Adobe-CNS1-3': [[], [0, 18943]], + 'Adobe-CNS1-4': [[], [0, 19199]], + 'Adobe-CNS1-5': [[], [0, 19199]], + 'Adobe-CNS1-6': [[], [0, 19199]], + 'Adobe-CNS1-UCS2': [[], [0, 65535]], + 'B5-H': [[0, 128], [41280, 65278]], + 'B5-V': [[0, 128], [41280, 65278]], + 'B5pc-H': [[0, 128, 253, 255], [41280, 64766]], + 'B5pc-V': [[0, 128, 253, 255], [41280, 64766]], + 'CNS-EUC-H': [[0, 128], [41377, 65278], [], + [2392957345, 2392981246, 2393022881, 2393046782, 2393088417, 2393112318]], + 'CNS-EUC-V': [[0, 128], [41377, 65278], [], + [2392957345, 2392981246, 2393022881, 2393046782, 2393088417, 2393112318]], + 'CNS1-H': [[], [8481, 32382]], + 'CNS1-V': [[], [8481, 32382]], + 'CNS2-H': [[], [8481, 32382]], + 'CNS2-V': [[], [8481, 32382]], + 'ETen-B5-H': [[0, 128], [41280, 65278]], + 'ETen-B5-V': [[0, 128], [41280, 65278]], + 'ETenms-B5-H': [[0, 128], [41280, 65278]], + 'ETenms-B5-V': [[0, 128], [41280, 65278]], + 'ETHK-B5-H': [[0, 128], [34624, 65278]], + 'ETHK-B5-V': [[0, 128], [34624, 65278]], + 'HKdla-B5-H': [[0, 128], [41280, 65278]], + 'HKdla-B5-V': [[0, 128], [41280, 65278]], + 'HKdlb-B5-H': [[0, 128], [36416, 65278]], + 'HKdlb-B5-V': [[0, 128], [36416, 65278]], + 'HKgccs-B5-H': [[0, 128], [35392, 65278]], + 'HKgccs-B5-V': [[0, 128], [35392, 65278]], + 'HKm314-B5-H': [[0, 128], [41280, 65278]], + 'HKm314-B5-V': [[0, 128], [41280, 65278]], + 'HKm471-B5-H': [[0, 128], [41280, 65278]], + 'HKm471-B5-V': [[0, 128], [41280, 65278]], + 'HKscs-B5-H': [[0, 128], [34624, 65278]], + 'HKscs-B5-V': [[0, 128], [34624, 65278]], + 'UniCNS-UCS2-H': [[], [0, 55295, 57344, 65535]], + 'UniCNS-UCS2-V': [[], [0, 55295, 57344, 65535]], + 'UniCNS-UTF16-H': [[], [0, 55295, 57344, 65535], [], + [3623934976, 3690979327]], + 'UniCNS-UTF16-V': [[], [0, 55295, 57344, 65535], [], + [3623934976, 3690979327]], + 'Adobe-GB1-0': [[], [0, 7935]], + 'Adobe-GB1-1': [[], [0, 9983]], + 'Adobe-GB1-2': [[], [0, 22271]], + 'Adobe-GB1-3': [[], [0, 22527]], + 'Adobe-GB1-4': [[], [0, 29183]], + 'Adobe-GB1-5': [[], [0, 30463]], + 'Adobe-GB1-UCS2': [[], [0, 65535]], + 'GB-EUC-H': [[0, 128], [41377, 65278]], + 'GB-EUC-V': [[0, 128], [41377, 65278]], + 'GB-H': [[], [8481, 32382]], + 'GB-V': [[], [8481, 32382]], + 'GBK-EUC-H': [[0, 128], [33088, 65278]], + 'GBK-EUC-V': [[0, 128], [33088, 65278]], + 'GBK2K-H': [[0, 127], [33088, 65278], [], [2167439664, 4265213497]], + 'GBK2K-V': [[0, 127], [33088, 65278], [], [2167439664, 4265213497]], + 'GBKp-EUC-H': [[0, 128], [33088, 65278]], + 'GBKp-EUC-V': [[0, 128], [33088, 65278]], + 'GBpc-EUC-H': [[0, 128, 253, 255], [41377, 64766]], + 'GBpc-EUC-V': [[0, 128, 253, 255], [41377, 64766]], + 'GBT-EUC-H': [[0, 128], [41377, 65278]], + 'GBT-EUC-V': [[0, 128], [41377, 65278]], + 'GBT-H': [[], [8481, 32382]], + 'GBT-V': [[], [8481, 32382]], + 'GBTpc-EUC-H': [[0, 128, 253, 255], [41377, 64766]], + 'GBTpc-EUC-V': [[0, 128, 253, 255], [41377, 64766]], + 'UniGB-UCS2-H': [[], [0, 55295, 57344, 65535]], + 'UniGB-UCS2-V': [[], [0, 55295, 57344, 65535]], + 'UniGB-UTF16-H': [[], [0, 55295, 57344, 65535], [], [3623934976, 3690979327]], + 'UniGB-UTF16-V': [[], [0, 55295, 57344, 65535], [], [3623934976, 3690979327]], + '78-EUC-H': [[0, 128], [36512, 36575, 41377, 65278]], + '78-EUC-V': [[0, 128], [36512, 36575, 41377, 65278]], + '78-H': [[], [8481, 32382]], + '78-RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '78-RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '78-V': [[], [8481, 32382]], + '78ms-RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '78ms-RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '83pv-RKSJ-H': [[0, 128, 160, 223, 253, 255], [33088, 40956, 57408, 64764]], + '90ms-RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '90ms-RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '90msp-RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '90msp-RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + '90pv-RKSJ-H': [[0, 128, 160, 223, 253, 255], [33088, 40956, 57408, 64764]], + '90pv-RKSJ-V': [[0, 128, 160, 223, 253, 255], [33088, 40956, 57408, 64764]], + 'Add-H': [[], [8481, 32382]], + 'Add-RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + 'Add-RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + 'Add-V': [[], [8481, 32382]], + 'Adobe-Japan1-0': [[], [0, 8447]], + 'Adobe-Japan1-1': [[], [0, 8447]], + 'Adobe-Japan1-2': [[], [0, 8959]], + 'Adobe-Japan1-3': [[], [0, 9471]], + 'Adobe-Japan1-4': [[], [0, 15615]], + 'Adobe-Japan1-5': [[], [0, 20479]], + 'Adobe-Japan1-6': [[], [0, 23295]], + 'Adobe-Japan1-UCS2': [[], [0, 65535]], + 'Adobe-Japan2-0': [[], [0, 6143]], + 'EUC-H': [[0, 128], [36512, 36575, 41377, 65278]], + 'EUC-V': [[0, 128], [36512, 36575, 41377, 65278]], + 'Ext-H': [[], [8481, 32382]], + 'Ext-RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + 'Ext-RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + 'Ext-V': [[], [8481, 32382]], + 'H': [[], [8481, 32382]], + 'Hankaku': [[0, 255], []], + 'Hiragana': [[0, 255], []], + 'Hojo-EUC-H': [[], [], [9413025, 9436926], []], + 'Hojo-EUC-V': [[], [], [9413025, 9436926], []], + 'Hojo-H': [[], [8481, 32382]], + 'Hojo-V': [[], [8481, 32382]], + 'Katakana': [[0, 255], []], + 'NWP-H': [[], [8481, 32382]], + 'NWP-V': [[], [8481, 32382]], + 'RKSJ-H': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + 'RKSJ-V': [[0, 128, 160, 223], [33088, 40956, 57408, 64764]], + 'Roman': [[0, 255], []], + 'UniHojo-UCS2-H': [[], [0, 55295, 57344, 65535]], + 'UniHojo-UCS2-V': [[], [0, 55295, 57344, 65535]], + 'UniHojo-UTF16-H': [[], [0, 55295, 57344, 65535], [], + [3623934976, 3690979327]], + 'UniHojo-UTF16-V': [[], [0, 55295, 57344, 65535], [], + [3623934976, 3690979327]], + 'UniJIS-UCS2-H': [[], [0, 55295, 57344, 65535]], + 'UniJIS-UCS2-HW-H': [[], [0, 55295, 57344, 65535]], + 'UniJIS-UCS2-HW-V': [[], [0, 55295, 57344, 65535]], + 'UniJIS-UCS2-V': [[], [0, 55295, 57344, 65535]], + 'UniJIS-UTF16-H': [[], [0, 55295, 57344, 65535], [], + [3623934976, 3690979327]], + 'UniJIS-UTF16-V': [[], [0, 55295, 57344, 65535], [], + [3623934976, 3690979327]], + 'UniJISPro-UCS2-HW-V': [[], [0, 55295, 57344, 65535]], + 'UniJISPro-UCS2-V': [[], [0, 55295, 57344, 65535]], + 'V': [[], [8481, 32382]], + 'WP-Symbol': [[0, 255], []], + 'Adobe-Korea1-0': [[], [0, 9471]], + 'Adobe-Korea1-1': [[], [0, 18175]], + 'Adobe-Korea1-2': [[], [0, 18431]], + 'Adobe-Korea1-UCS2': [[], [0, 65535]], + 'KSC-EUC-H': [[0, 128], [41377, 65278]], + 'KSC-EUC-V': [[0, 128], [41377, 65278]], + 'KSC-H': [[], [8481, 32382]], + 'KSC-Johab-H': [[0, 128], [33857, 54270, 55345, 57086, 57393, 63998]], + 'KSC-Johab-V': [[0, 128], [33857, 54270, 55345, 57086, 57393, 63998]], + 'KSC-V': [[], [8481, 32382]], + 'KSCms-UHC-H': [[0, 128], [33089, 65278]], + 'KSCms-UHC-HW-H': [[0, 128], [33089, 65278]], + 'KSCms-UHC-HW-V': [[0, 128], [33089, 65278]], + 'KSCms-UHC-V': [[0, 128], [33089, 65278]], + 'KSCpc-EUC-H': [[0, 132, 254, 255], [41281, 65022]], + 'KSCpc-EUC-V': [[0, 132, 254, 255], [41281, 65022]], + 'UniKS-UCS2-H': [[], [0, 55295, 57344, 65535]], + 'UniKS-UCS2-V': [[], [0, 55295, 57344, 65535]], + 'UniKS-UTF16-H': [[], [0, 55295, 57344, 65535], [], [3623934976, 3690979327]], + 'UniKS-UTF16-V': [[], [0, 55295, 57344, 65535], [], [3623934976, 3690979327]] +}; + +// CMap, not to be confused with TrueType's cmap. +var CMap = (function CMapClosure() { + function CMap() { + // Codespace ranges are stored as follows: + // [[1BytePairs], [2BytePairs], [3BytePairs], [4BytePairs]] + // where nBytePairs are ranges e.g. [low1, high1, low2, high2, ...] + this.codespaceRanges = [[], [], [], []]; + this.map = []; + this.vertical = false; + } + CMap.prototype = { + addCodespaceRange: function(n, low, high) { + this.codespaceRanges[n - 1].push(low, high); + }, + + mapRange: function(low, high, dstLow) { + var lastByte = dstLow.length - 1; + while (low <= high) { + this.map[low] = dstLow; + // Only the last byte has to be incremented. + dstLow = dstLow.substr(0, lastByte) + + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1); + ++low; + } + }, + + mapRangeToArray: function(low, high, array) { + var i = 0; + while (low <= high) { + this.map[low] = array[i++]; + ++low; + } + }, + + mapOne: function(src, dst) { + this.map[src] = dst; + }, + + lookup: function(code) { + return this.map[code]; + }, + + readCharCode: function(str, offset) { + var c = 0; + var codespaceRanges = this.codespaceRanges; + var codespaceRangesLen = this.codespaceRanges.length; + // 9.7.6.2 CMap Mapping + // The code length is at most 4. + for (var n = 0; n < codespaceRangesLen; n++) { + c = ((c << 8) | str.charCodeAt(offset + n)) >>> 0; + // Check each codespace range to see if it falls within. + var codespaceRange = codespaceRanges[n]; + for (var k = 0, kk = codespaceRange.length; k < kk;) { + var low = codespaceRange[k++]; + var high = codespaceRange[k++]; + if (c >= low && c <= high) { + return [c, n + 1]; + } + } + } + + return [0, 1]; + } + + }; + return CMap; +})(); + +var IdentityCMap = (function IdentityCMapClosure() { + function IdentityCMap(vertical, n) { + CMap.call(this); + this.vertical = vertical; + this.addCodespaceRange(n, 0, 0xffff); + this.mapRange(0, 0xffff, '\u0000'); + } + Util.inherit(IdentityCMap, CMap, {}); + + return IdentityCMap; +})(); + +var CMapFactory = (function CMapFactoryClosure() { + function strToInt(str) { + var a = 0; + for (var i = 0; i < str.length; i++) { + a = (a << 8) | str.charCodeAt(i); + } + return a >>> 0; + } + + function expectString(obj) { + if (!isString(obj)) { + error('Malformed CMap: expected string.'); + } + } + + function expectInt(obj) { + if (!isInt(obj)) { + error('Malformed CMap: expected int.'); + } + } + + function parseBfChar(cMap, lexer) { + while (true) { + var obj = lexer.getObj(); + if (isEOF(obj)) { + break; + } + if (isCmd(obj, 'endbfchar')) { + return; + } + expectString(obj); + var src = strToInt(obj); + obj = lexer.getObj(); + // TODO are /dstName used? + expectString(obj); + var dst = obj; + cMap.mapOne(src, dst); + } + } + + function parseBfRange(cMap, lexer) { + while (true) { + var obj = lexer.getObj(); + if (isEOF(obj)) { + break; + } + if (isCmd(obj, 'endbfrange')) { + return; + } + expectString(obj); + var low = strToInt(obj); + obj = lexer.getObj(); + expectString(obj); + var high = strToInt(obj); + obj = lexer.getObj(); + if (isInt(obj) || isString(obj)) { + var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj; + cMap.mapRange(low, high, dstLow); + } else if (isCmd(obj, '[')) { + obj = lexer.getObj(); + var array = []; + while (!isCmd(obj, ']') && !isEOF(obj)) { + array.push(obj); + obj = lexer.getObj(); + } + cMap.mapRangeToArray(low, high, array); + } else { + break; + } + } + error('Invalid bf range.'); + } + + function parseCidChar(cMap, lexer) { + while (true) { + var obj = lexer.getObj(); + if (isEOF(obj)) { + break; + } + if (isCmd(obj, 'endcidchar')) { + return; + } + expectString(obj); + var src = strToInt(obj); + obj = lexer.getObj(); + expectInt(obj); + var dst = String.fromCharCode(obj); + cMap.mapOne(src, dst); + } + } + + function parseCidRange(cMap, lexer) { + while (true) { + var obj = lexer.getObj(); + if (isEOF(obj)) { + break; + } + if (isCmd(obj, 'endcidrange')) { + return; + } + expectString(obj); + var low = strToInt(obj); + obj = lexer.getObj(); + expectString(obj); + var high = strToInt(obj); + obj = lexer.getObj(); + expectInt(obj); + var dstLow = String.fromCharCode(obj); + cMap.mapRange(low, high, dstLow); + } + } + + function parseCodespaceRange(cMap, lexer) { + while (true) { + var obj = lexer.getObj(); + if (isEOF(obj)) { + break; + } + if (isCmd(obj, 'endcodespacerange')) { + return; + } + if (!isString(obj)) { + break; + } + var low = strToInt(obj); + obj = lexer.getObj(); + if (!isString(obj)) { + break; + } + var high = strToInt(obj); + cMap.addCodespaceRange(obj.length, low, high); + } + error('Invalid codespace range.'); + } + + function parseCmap(cMap, lexer) { + objLoop: while (true) { + var obj = lexer.getObj(); + if (isEOF(obj)) { + break; + } else if (isCmd(obj)) { + switch (obj.cmd) { + case 'endcMap': + break objLoop; + case 'usecMap': + // TODO + break; + case 'begincodespacerange': + parseCodespaceRange(cMap, lexer); + break; + case 'beginbfchar': + parseBfChar(cMap, lexer); + break; + case 'begincidchar': + parseCidChar(cMap, lexer); + break; + case 'beginbfrange': + parseBfRange(cMap, lexer); + break; + case 'begincidrange': + parseCidRange(cMap, lexer); + break; + } + } + } + } + return { + create: function (encoding) { + if (isName(encoding)) { + switch (encoding.name) { + case 'Identity-H': + return new IdentityCMap(false, 2); + case 'Identity-V': + return new IdentityCMap(true, 2); + default: + if (encoding.name in CMAP_CODESPACES) { + // XXX: Temporary hack so the correct amount of bytes are read in + // CMap.readCharCode. + var cMap = new CMap(); + cMap.codespaceRanges = CMAP_CODESPACES[encoding.name]; + return cMap; + } + return null; + } + } else if (isStream(encoding)) { + var cMap = new CMap(); + var lexer = new Lexer(encoding); + try { + parseCmap(cMap, lexer); + } catch (e) { + warn('Invalid CMap data. ' + e); + } + return cMap; + } + error('Encoding required.'); + } + }; +})(); /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* diff --git a/browser/extensions/pdfjs/content/web/images/toolbarButton-secondaryToolbarToggle-rtl.png b/browser/extensions/pdfjs/content/web/images/toolbarButton-secondaryToolbarToggle-rtl.png new file mode 100644 index 00000000000000..97930244ced83a Binary files /dev/null and b/browser/extensions/pdfjs/content/web/images/toolbarButton-secondaryToolbarToggle-rtl.png differ diff --git a/browser/extensions/pdfjs/content/web/images/toolbarButton-sidebarToggle-rtl.png b/browser/extensions/pdfjs/content/web/images/toolbarButton-sidebarToggle-rtl.png new file mode 100644 index 00000000000000..d9946fd0ad71ee Binary files /dev/null and b/browser/extensions/pdfjs/content/web/images/toolbarButton-sidebarToggle-rtl.png differ diff --git a/browser/extensions/pdfjs/content/web/images/toolbarButton-viewOutline-rtl.png b/browser/extensions/pdfjs/content/web/images/toolbarButton-viewOutline-rtl.png new file mode 100644 index 00000000000000..d57a12c5d5b6d5 Binary files /dev/null and b/browser/extensions/pdfjs/content/web/images/toolbarButton-viewOutline-rtl.png differ diff --git a/browser/extensions/pdfjs/content/web/viewer.css b/browser/extensions/pdfjs/content/web/viewer.css index 461ad05ba63278..047c23fb1608c1 100644 --- a/browser/extensions/pdfjs/content/web/viewer.css +++ b/browser/extensions/pdfjs/content/web/viewer.css @@ -85,24 +85,28 @@ select { } /* outer/inner center provides horizontal center */ +.outerCenter { + pointer-events: none; + position: relative; +} html[dir='ltr'] .outerCenter { float: right; - position: relative; right: 50%; } html[dir='rtl'] .outerCenter { float: left; - position: relative; left: 50%; } +.innerCenter { + pointer-events: auto; + position: relative; +} html[dir='ltr'] .innerCenter { float: right; - position: relative; right: -50%; } html[dir='rtl'] .innerCenter { float: left; - position: relative; left: -50%; } @@ -390,10 +394,9 @@ html[dir='ltr'] #toolbarViewerLeft { margin-left: -1px; } html[dir='rtl'] #toolbarViewerRight { - margin-left: -1px; + margin-right: -1px; } - html[dir='ltr'] #toolbarViewerLeft, html[dir='rtl'] #toolbarViewerRight { position: absolute; @@ -486,6 +489,7 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton { .splitToolbarButton > .toolbarButton:hover, .splitToolbarButton > .toolbarButton:focus, .dropdownToolbarButton:hover, +.promptButton:hover, .toolbarButton.textButton:hover, .toolbarButton.textButton:focus { background-color: hsla(0,0%,0%,.2); @@ -539,6 +543,7 @@ html[dir='rtl'] .splitToolbarButtonSeparator { .toolbarButton, .dropdownToolbarButton, +.promptButton, .secondaryToolbarButton { min-width: 16px; padding: 2px 6px 0; @@ -556,10 +561,12 @@ html[dir='rtl'] .splitToolbarButtonSeparator { } html[dir='ltr'] .toolbarButton, +html[dir='ltr'] .promptButton, html[dir='ltr'] .dropdownToolbarButton { margin: 3px 2px 4px 0; } html[dir='rtl'] .toolbarButton, +html[dir='rtl'] .promptButton, html[dir='rtl'] .dropdownToolbarButton { margin: 3px 0 4px 2px; } @@ -567,6 +574,7 @@ html[dir='rtl'] .dropdownToolbarButton { .toolbarButton:hover, .toolbarButton:focus, .dropdownToolbarButton, +.promptButton, .secondaryToolbarButton:hover, .secondaryToolbarButton:focus { background-color: hsla(0,0%,0%,.12); @@ -580,6 +588,7 @@ html[dir='rtl'] .dropdownToolbarButton { } .toolbarButton:hover:active, +.promptButton:hover:active, .dropdownToolbarButton:hover:active, .secondaryToolbarButton:hover:active { background-color: hsla(0,0%,0%,.2); @@ -646,6 +655,12 @@ html[dir='rtl'] .dropdownToolbarButton { background: hsl(0,0%,24%); } +.promptButton { + margin: 3px 2px 4px 5px !important; + line-height: 16px; + padding: 2px 6px 3px 6px; +} + #customScaleOption { display: none; } @@ -702,6 +717,7 @@ html[dir='rtl'] #findNext { top: 4px; left: 7px; } + html[dir="ltr"] .secondaryToolbarButton::before { left: 4px; } @@ -709,18 +725,23 @@ html[dir="rtl"] .secondaryToolbarButton::before { right: 4px; } -.toolbarButton#sidebarToggle::before { +html[dir='ltr'] .toolbarButton#sidebarToggle::before { content: url(images/toolbarButton-sidebarToggle.png); } +html[dir='rtl'] .toolbarButton#sidebarToggle::before { + content: url(images/toolbarButton-sidebarToggle-rtl.png); +} -.toolbarButton#secondaryToolbarToggle::before { +html[dir='ltr'] .toolbarButton#secondaryToolbarToggle::before { content: url(images/toolbarButton-secondaryToolbarToggle.png); } +html[dir='rtl'] .toolbarButton#secondaryToolbarToggle::before { + content: url(images/toolbarButton-secondaryToolbarToggle-rtl.png); +} html[dir='ltr'] .toolbarButton.findPrevious::before { content: url(images/findbarButton-previous.png); } - html[dir='rtl'] .toolbarButton.findPrevious::before { content: url(images/findbarButton-previous-rtl.png); } @@ -728,7 +749,6 @@ html[dir='rtl'] .toolbarButton.findPrevious::before { html[dir='ltr'] .toolbarButton.findNext::before { content: url(images/findbarButton-next.png); } - html[dir='rtl'] .toolbarButton.findNext::before { content: url(images/findbarButton-next-rtl.png); } @@ -736,7 +756,6 @@ html[dir='rtl'] .toolbarButton.findNext::before { html[dir='ltr'] .toolbarButton.pageUp::before { content: url(images/toolbarButton-pageUp.png); } - html[dir='rtl'] .toolbarButton.pageUp::before { content: url(images/toolbarButton-pageUp-rtl.png); } @@ -744,7 +763,6 @@ html[dir='rtl'] .toolbarButton.pageUp::before { html[dir='ltr'] .toolbarButton.pageDown::before { content: url(images/toolbarButton-pageDown.png); } - html[dir='rtl'] .toolbarButton.pageDown::before { content: url(images/toolbarButton-pageDown-rtl.png); } @@ -767,6 +785,7 @@ html[dir='rtl'] .toolbarButton.pageDown::before { content: url(images/toolbarButton-print.png); left: 6px; } + html[dir="ltr"] .secondaryToolbarButton.print::before { left: 3px; } @@ -804,9 +823,12 @@ html[dir="rtl"] .secondaryToolbarButton.print::before { content: url(images/toolbarButton-viewThumbnail.png); } -#viewOutline.toolbarButton::before { +html[dir="ltr"] #viewOutline.toolbarButton::before { content: url(images/toolbarButton-viewOutline.png); } +html[dir="rtl"] #viewOutline.toolbarButton::before { + content: url(images/toolbarButton-viewOutline-rtl.png); +} #viewFind.toolbarButton::before { content: url(images/toolbarButton-search.png); @@ -1233,6 +1255,60 @@ canvas { width: 98%; } +#overlayContainer { + display: table; + position: absolute; + width: 100%; + height: 100%; + background-color: hsla(0,0%,0%,.2); + z-index: 10000; +} + +#promptContainer { + display: table-cell; + vertical-align: middle; + text-align: center; +} + +#promptContainer > * { + display: inline-block; +} + +.prompt { + display: table; + padding: 15px; + border-spacing: 4px; + color: hsl(0,0%,85%); + line-height: 14px; + text-align: center; + background-color: #474747; /* fallback */ + background-image: url(images/texture.png), + linear-gradient(hsla(0,0%,32%,.99), hsla(0,0%,27%,.95)); + box-shadow: inset 1px 0 0 hsla(0,0%,100%,.08), + inset 0 1px 1px hsla(0,0%,0%,.15), + inset 0 -1px 0 hsla(0,0%,100%,.05), + 0 1px 0 hsla(0,0%,0%,.15), + 0 1px 1px hsla(0,0%,0%,.1); +} + +.prompt > .row { + display: table-row; +} + +.prompt > .row > * { + display: table-cell; +} + +.prompt .toolbarField { + margin: 5px 0; + width: 200px; +} + +.prompt .toolbarField:hover, +.prompt .toolbarField:focus { + border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42); +} + .clearBoth { clear: both; } @@ -1341,6 +1417,10 @@ canvas { display: block; } + .fileInput { + display: none; + } + /* Rules for browsers that support mozPrintCallback */ body[data-mozPrintCallback] #outerContainer { display: none; @@ -1365,12 +1445,12 @@ canvas { html[dir='ltr'] #outerContainer.sidebarMoving .outerCenter, html[dir='ltr'] #outerContainer.sidebarOpen .outerCenter { float: left; - left: 185px; + left: 205px; } html[dir='rtl'] #outerContainer.sidebarMoving .outerCenter, html[dir='rtl'] #outerContainer.sidebarOpen .outerCenter { float: right; - right: 185px; + right: 205px; } } @@ -1414,11 +1494,11 @@ canvas { html[dir='ltr'] .outerCenter { float: left; - left: 185px; + left: 205px; } html[dir='rtl'] .outerCenter { float: right; - right: 185px; + right: 205px; } #outerContainer .hiddenLargeView, diff --git a/browser/extensions/pdfjs/content/web/viewer.html b/browser/extensions/pdfjs/content/web/viewer.html index 0bdc01e3c101e3..133886aed2790a 100644 --- a/browser/extensions/pdfjs/content/web/viewer.html +++ b/browser/extensions/pdfjs/content/web/viewer.html @@ -241,6 +241,23 @@ + +
diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index 3cdffa34daddaf..b9e8e56f7aa425 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -17,7 +17,8 @@ /* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, PDFFindBar, CustomStyle, PDFFindController, ProgressBar, TextLayerBuilder, DownloadManager, getFileName, getOutputScale, scrollIntoView, getPDFFileNameFromURL, - PDFHistory, ThumbnailView, noContextMenuHandler, SecondaryToolbar */ + PDFHistory, PageView, ThumbnailView, noContextMenuHandler, + SecondaryToolbar, PasswordPrompt */ 'use strict'; @@ -119,8 +120,14 @@ function getFileName(url) { scales. The scaled property is set to false if scaling is not required, true otherwise. */ -function getOutputScale() { - var pixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1; +function getOutputScale(ctx) { + var devicePixelRatio = window.devicePixelRatio || 1; + var backingStoreRatio = ctx.webkitBackingStorePixelRatio || + ctx.mozBackingStorePixelRatio || + ctx.msBackingStorePixelRatio || + ctx.oBackingStorePixelRatio || + ctx.backingStorePixelRatio || 1; + var pixelRatio = devicePixelRatio / backingStoreRatio; return { sx: pixelRatio, sy: pixelRatio, @@ -1114,10 +1121,14 @@ var PDFHistory = { } return; } - if (this.nextHashParam && this.nextHashParam === params.hash) { - this.nextHashParam = null; - this.updatePreviousBookmark = true; - return; + if (this.nextHashParam) { + if (this.nextHashParam === params.hash) { + this.nextHashParam = null; + this.updatePreviousBookmark = true; + return; + } else { + this.nextHashParam = null; + } } if (params.hash) { @@ -1345,6 +1356,9 @@ var SecondaryToolbar = { // Misc. functions for interacting with the toolbar. setMaxHeight: function secondaryToolbarSetMaxHeight(container) { + if (!container) { + return; + } this.newContainerHeight = container.clientHeight; if (this.previousContainerHeight === this.newContainerHeight) { return; @@ -1388,6 +1402,82 @@ var SecondaryToolbar = { }; +var PasswordPrompt = { + visible: false, + updatePassword: null, + reason: null, + overlayContainer: null, + passwordField: null, + passwordText: null, + passwordSubmit: null, + passwordCancel: null, + + initialize: function secondaryToolbarInitialize(options) { + this.overlayContainer = options.overlayContainer; + this.passwordField = options.passwordField; + this.passwordText = options.passwordText; + this.passwordSubmit = options.passwordSubmit; + this.passwordCancel = options.passwordCancel; + + // Attach the event listeners. + this.passwordSubmit.addEventListener('click', + this.verifyPassword.bind(this)); + + this.passwordCancel.addEventListener('click', this.hide.bind(this)); + + this.passwordField.addEventListener('keydown', + function (e) { + if (e.keyCode === 13) { // Enter key + this.verifyPassword(); + } + }.bind(this)); + + this.overlayContainer.addEventListener('keydown', + function (e) { + if (e.keyCode === 27) { // Esc key + this.hide(); + } + }.bind(this)); + }, + + show: function passwordPromptShow() { + if (this.visible) { + return; + } + this.visible = true; + this.overlayContainer.classList.remove('hidden'); + this.passwordField.focus(); + + var promptString = mozL10n.get('password_label', null, + 'Enter the password to open this PDF file.'); + + if (this.reason === PDFJS.PasswordResponses.INCORRECT_PASSWORD) { + promptString = mozL10n.get('password_invalid', null, + 'Invalid password. Please try again.'); + } + + this.passwordText.textContent = promptString; + }, + + hide: function passwordPromptClose() { + if (!this.visible) { + return; + } + this.visible = false; + this.passwordField.value = ''; + this.overlayContainer.classList.add('hidden'); + }, + + verifyPassword: function passwordPromptVerifyPassword() { + var password = this.passwordField.value; + if (password && password.length > 0) { + this.hide(); + return this.updatePassword(password); + } + } +}; + + var PDFView = { pages: [], thumbnails: [], @@ -1437,6 +1527,14 @@ var PDFView = { pageRotateCcw: document.getElementById('pageRotateCcw') }); + PasswordPrompt.initialize({ + overlayContainer: document.getElementById('overlayContainer'), + passwordField: document.getElementById('password'), + passwordText: document.getElementById('passwordText'), + passwordSubmit: document.getElementById('passwordSubmit'), + passwordCancel: document.getElementById('passwordCancel') + }); + PDFFindBar.initialize({ bar: document.getElementById('findbar'), toggleButton: document.getElementById('viewFind'), @@ -1613,11 +1711,16 @@ var PDFView = { get supportsFullscreen() { var doc = document.documentElement; var support = doc.requestFullscreen || doc.mozRequestFullScreen || - doc.webkitRequestFullScreen; + doc.webkitRequestFullScreen || doc.msRequestFullscreen; if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || - document.webkitFullscreenEnabled === false ) { + document.webkitFullscreenEnabled === false || + document.msFullscreenEnabled === false) { + support = false; + } else if (this.isViewerEmbedded) { + // Need to check if the viewer is embedded as well, to prevent issues with + // presentation mode when the viewer is embedded in '' tags. support = false; } @@ -1775,18 +1878,9 @@ var PDFView = { var self = this; self.loading = true; var passwordNeeded = function passwordNeeded(updatePassword, reason) { - var promptString = mozL10n.get('request_password', null, - 'PDF is protected by a password:'); - - if (reason === PDFJS.PasswordResponses.INCORRECT_PASSWORD) { - promptString += '\n' + mozL10n.get('invalid_password', null, - 'Invalid Password.'); - } - - password = prompt(promptString); - if (password && password.length > 0) { - return updatePassword(password); - } + PasswordPrompt.updatePassword = updatePassword; + PasswordPrompt.reason = reason; + PasswordPrompt.show(); }; function getDocumentProgress(progressData) { @@ -2539,9 +2633,13 @@ var PDFView = { }, presentationMode: function pdfViewPresentationMode() { + if (!this.supportsFullscreen) { + return false; + } var isPresentationMode = document.fullscreenElement || document.mozFullScreen || - document.webkitIsFullScreen; + document.webkitIsFullScreen || + document.msFullscreenElement; if (isPresentationMode) { return false; @@ -2554,6 +2652,8 @@ var PDFView = { wrapper.mozRequestFullScreen(); } else if (document.documentElement.webkitRequestFullScreen) { wrapper.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); + } else if (document.documentElement.msRequestFullscreen) { + wrapper.msRequestFullscreen(); } else { return false; } @@ -2712,6 +2812,7 @@ var PDFView = { } }; + var PageView = function pageView(container, id, scale, navigateTo, defaultViewport) { this.id = id; @@ -2778,8 +2879,9 @@ var PageView = function pageView(container, id, scale, div.style.width = Math.floor(this.viewport.width) + 'px'; div.style.height = Math.floor(this.viewport.height) + 'px'; - while (div.hasChildNodes()) + while (div.hasChildNodes()) { div.removeChild(div.lastChild); + } div.removeAttribute('data-loaded'); this.annotationLayer = null; @@ -2812,8 +2914,9 @@ var PageView = function pageView(container, id, scale, function bindLink(link, dest) { link.href = PDFView.getDestinationHash(dest); link.onclick = function pageViewSetupLinksOnclick() { - if (dest) + if (dest) { PDFView.navigateTo(dest); + } return false; }; link.className = 'internalLink'; @@ -2927,83 +3030,83 @@ var PageView = function pageView(container, id, scale, }; this.scrollIntoView = function pageViewScrollIntoView(dest) { - if (PDFView.isPresentationMode) { // Avoid breaking presentation mode. - dest = null; - } - if (!dest) { - scrollIntoView(div); - return; - } + if (PDFView.isPresentationMode) { // Avoid breaking presentation mode. + dest = null; + } + if (!dest) { + scrollIntoView(div); + return; + } - var x = 0, y = 0; - var width = 0, height = 0, widthScale, heightScale; - var scale = 0; - switch (dest[1].name) { - case 'XYZ': - x = dest[2]; - y = dest[3]; - scale = dest[4]; - // If x and/or y coordinates are not supplied, default to - // _top_ left of the page (not the obvious bottom left, - // since aligning the bottom of the intended page with the - // top of the window is rarely helpful). - x = x !== null ? x : 0; - y = y !== null ? y : this.height / this.scale; - break; - case 'Fit': - case 'FitB': - scale = 'page-fit'; - break; - case 'FitH': - case 'FitBH': - y = dest[2]; - scale = 'page-width'; - break; - case 'FitV': - case 'FitBV': - x = dest[2]; - scale = 'page-height'; - break; - case 'FitR': - x = dest[2]; - y = dest[3]; - width = dest[4] - x; - height = dest[5] - y; - widthScale = (PDFView.container.clientWidth - SCROLLBAR_PADDING) / - width / CSS_UNITS; - heightScale = (PDFView.container.clientHeight - SCROLLBAR_PADDING) / - height / CSS_UNITS; - scale = Math.min(widthScale, heightScale); - break; - default: - return; - } + var x = 0, y = 0; + var width = 0, height = 0, widthScale, heightScale; + var scale = 0; + switch (dest[1].name) { + case 'XYZ': + x = dest[2]; + y = dest[3]; + scale = dest[4]; + // If x and/or y coordinates are not supplied, default to + // _top_ left of the page (not the obvious bottom left, + // since aligning the bottom of the intended page with the + // top of the window is rarely helpful). + x = x !== null ? x : 0; + y = y !== null ? y : this.height / this.scale; + break; + case 'Fit': + case 'FitB': + scale = 'page-fit'; + break; + case 'FitH': + case 'FitBH': + y = dest[2]; + scale = 'page-width'; + break; + case 'FitV': + case 'FitBV': + x = dest[2]; + scale = 'page-height'; + break; + case 'FitR': + x = dest[2]; + y = dest[3]; + width = dest[4] - x; + height = dest[5] - y; + widthScale = (PDFView.container.clientWidth - SCROLLBAR_PADDING) / + width / CSS_UNITS; + heightScale = (PDFView.container.clientHeight - SCROLLBAR_PADDING) / + height / CSS_UNITS; + scale = Math.min(widthScale, heightScale); + break; + default: + return; + } - if (scale && scale !== PDFView.currentScale) { - PDFView.parseScale(scale, true, true); - } else if (PDFView.currentScale === UNKNOWN_SCALE) { - PDFView.parseScale(DEFAULT_SCALE, true, true); - } + if (scale && scale !== PDFView.currentScale) { + PDFView.parseScale(scale, true, true); + } else if (PDFView.currentScale === UNKNOWN_SCALE) { + PDFView.parseScale(DEFAULT_SCALE, true, true); + } - if (scale === 'page-fit' && !dest[4]) { - scrollIntoView(div); - return; - } + if (scale === 'page-fit' && !dest[4]) { + scrollIntoView(div); + return; + } - var boundingRect = [ - this.viewport.convertToViewportPoint(x, y), - this.viewport.convertToViewportPoint(x + width, y + height) - ]; - setTimeout(function pageViewScrollIntoViewRelayout() { - // letting page to re-layout before scrolling - var scale = PDFView.currentScale; - var x = Math.min(boundingRect[0][0], boundingRect[1][0]); - var y = Math.min(boundingRect[0][1], boundingRect[1][1]); - var width = Math.abs(boundingRect[0][0] - boundingRect[1][0]); - var height = Math.abs(boundingRect[0][1] - boundingRect[1][1]); - - scrollIntoView(div, {left: x, top: y, width: width, height: height}); - }, 0); + var boundingRect = [ + this.viewport.convertToViewportPoint(x, y), + this.viewport.convertToViewportPoint(x + width, y + height) + ]; + setTimeout(function pageViewScrollIntoViewRelayout() { + // letting page to re-layout before scrolling + var scale = PDFView.currentScale; + var x = Math.min(boundingRect[0][0], boundingRect[1][0]); + var y = Math.min(boundingRect[0][1], boundingRect[1][1]); + var width = Math.abs(boundingRect[0][0] - boundingRect[1][0]); + var height = Math.abs(boundingRect[0][1] - boundingRect[1][1]); + + scrollIntoView(div, {left: x, top: y, width: width, height: height}); + }, 0); }; this.getTextContent = function pageviewGetTextContent() { @@ -3046,9 +3149,13 @@ var PageView = function pageView(container, id, scale, this.canvas = canvas; var scale = this.scale; - var outputScale = getOutputScale(); + var ctx = canvas.getContext('2d'); + var outputScale = getOutputScale(ctx); + canvas.width = Math.floor(viewport.width) * outputScale.sx; canvas.height = Math.floor(viewport.height) * outputScale.sy; + canvas.style.width = Math.floor(viewport.width) + 'px'; + canvas.style.height = Math.floor(viewport.height) + 'px'; var textLayerDiv = null; if (!PDFJS.disableTextLayer) { @@ -3063,27 +3170,22 @@ var PageView = function pageView(container, id, scale, textLayerDiv: textLayerDiv, pageIndex: this.id - 1, lastScrollSource: PDFView, + viewport: this.viewport, isViewerInPresentationMode: PDFView.isPresentationMode }) : null; - - if (outputScale.scaled) { - var cssScale = 'scale(' + (1 / outputScale.sx) + ', ' + - (1 / outputScale.sy) + ')'; - CustomStyle.setProp('transform' , canvas, cssScale); - CustomStyle.setProp('transformOrigin' , canvas, '0% 0%'); - if (textLayerDiv) { - CustomStyle.setProp('transform' , textLayerDiv, cssScale); - CustomStyle.setProp('transformOrigin' , textLayerDiv, '0% 0%'); - } - } - - var ctx = canvas.getContext('2d'); // TODO(mack): use data attributes to store these ctx._scaleX = outputScale.sx; ctx._scaleY = outputScale.sy; if (outputScale.scaled) { ctx.scale(outputScale.sx, outputScale.sy); } + if (outputScale.scaled && textLayerDiv) { + var cssScale = 'scale(' + (1 / outputScale.sx) + ', ' + + (1 / outputScale.sy) + ')'; + CustomStyle.setProp('transform' , textLayerDiv, cssScale); + CustomStyle.setProp('transformOrigin' , textLayerDiv, '0% 0%'); + } + // Checking if document fonts are used only once var checkIfDocumentFontsUsed = !PDFView.pdfDocument.embeddedFontsUsed; @@ -3131,8 +3233,9 @@ var PageView = function pageView(container, id, scale, self.stats = pdfPage.stats; self.updateStats(); - if (self.onAfterDraw) + if (self.onAfterDraw) { self.onAfterDraw(); + } cache.push(self); @@ -3231,10 +3334,11 @@ var PageView = function pageView(container, id, scale, console.error(error); // Tell the printEngine that rendering this canvas/page has failed. // This will make the print proces stop. - if ('abort' in obj) + if ('abort' in obj) { obj.abort(); - else + } else { obj.done(); + } self.pdfPage.destroy(); }); }; @@ -3446,6 +3550,7 @@ var TextLayerBuilder = function textLayerBuilder(options) { this.pageIdx = options.pageIndex; this.matches = []; this.lastScrollSource = options.lastScrollSource; + this.viewport = options.viewport; this.isViewerInPresentationMode = options.isViewerInPresentationMode; if(typeof PDFFindController === 'undefined') { @@ -3568,6 +3673,12 @@ var TextLayerBuilder = function textLayerBuilder(options) { } textDiv.textContent = bidiText.str; + // TODO refactor text layer to use text content position + /** + * var arr = this.viewport.convertToViewportPoint(bidiText.x, bidiText.y); + * textDiv.style.left = arr[0] + 'px'; + * textDiv.style.top = arr[1] + 'px'; + */ // bidiText.dir may be 'ttb' for vertical texts. textDiv.dir = bidiText.dir; } @@ -4261,6 +4372,10 @@ window.addEventListener('click', function click(evt) { }, false); window.addEventListener('keydown', function keydown(evt) { + if (PasswordPrompt.visible) { + return; + } + var handled = false; var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | @@ -4466,7 +4581,8 @@ window.addEventListener('afterprint', function afterPrint(evt) { function presentationModeChange(e) { var isPresentationMode = document.fullscreenElement || document.mozFullScreen || - document.webkitIsFullScreen; + document.webkitIsFullScreen || + document.msFullscreenElement; if (isPresentationMode) { PDFView.enterPresentationMode(); @@ -4479,6 +4595,7 @@ window.addEventListener('afterprint', function afterPrint(evt) { window.addEventListener('mozfullscreenchange', presentationModeChange, false); window.addEventListener('webkitfullscreenchange', presentationModeChange, false); + window.addEventListener('MSFullscreenChange', presentationModeChange, false); })(); (function animationStartedClosure() { diff --git a/browser/extensions/pdfjs/extension-files b/browser/extensions/pdfjs/extension-files index 869d07ecff36da..6a68225cd64777 100644 --- a/browser/extensions/pdfjs/extension-files +++ b/browser/extensions/pdfjs/extension-files @@ -38,8 +38,11 @@ content/web/images/toolbarButton-pageUp.png content/web/images/toolbarButton-presentationMode.png content/web/images/toolbarButton-print.png content/web/images/toolbarButton-search.png +content/web/images/toolbarButton-secondaryToolbarToggle-rtl.png content/web/images/toolbarButton-secondaryToolbarToggle.png +content/web/images/toolbarButton-sidebarToggle-rtl.png content/web/images/toolbarButton-sidebarToggle.png +content/web/images/toolbarButton-viewOutline-rtl.png content/web/images/toolbarButton-viewOutline.png content/web/images/toolbarButton-viewThumbnail.png content/web/images/toolbarButton-zoomIn.png diff --git a/browser/locales/en-US/pdfviewer/viewer.properties b/browser/locales/en-US/pdfviewer/viewer.properties index 5b3f524860b97f..629bfb27cc8f1a 100644 --- a/browser/locales/en-US/pdfviewer/viewer.properties +++ b/browser/locales/en-US/pdfviewer/viewer.properties @@ -33,7 +33,7 @@ zoom.title=Zoom presentation_mode.title=Switch to Presentation Mode presentation_mode_label=Presentation Mode open_file.title=Open File -open_file_label=Open File +open_file_label=Open print.title=Print print_label=Print download.title=Download @@ -125,8 +125,10 @@ missing_file_error=Missing PDF file. # the PDF spec (32000-1:2008 Table 169 – Annotation types). # Some common types are e.g.: "Check", "Text", "Comment", "Note" text_annotation_type.alt=[{{type}} Annotation] -request_password=PDF is protected by a password: -invalid_password=Invalid Password. +password_label=Enter the password to open this PDF file. +password_invalid=Invalid password. Please try again. +password_ok=OK +password_cancel=Cancel printing_not_supported=Warning: Printing is not fully supported by this browser. printing_not_ready=Warning: The PDF is not fully loaded for printing. diff --git a/browser/metro/profile/metro.js b/browser/metro/profile/metro.js index 7b1a7f12ec917f..fc6d11aed04321 100644 --- a/browser/metro/profile/metro.js +++ b/browser/metro/profile/metro.js @@ -40,6 +40,7 @@ pref("gfx.azpc.touch_start_tolerance", "0.1"); // dpi * tolerance = pixel thresh pref("gfx.azpc.pan_repaint_interval", "50"); // prefer 20 fps pref("gfx.azpc.fling_repaint_interval", "50"); // prefer 20 fps pref("gfx.axis.fling_friction", "0.002"); +pref("gfx.axis.fling_stopped_threshold", "0.2"); // Enable Microsoft TSF support by default for imes. pref("intl.enable_tsf_support", true); @@ -442,7 +443,11 @@ pref("app.update.silent", true); pref("app.update.staging.enabled", true); // Update service URL: +#ifdef NIGHTLY_BUILD pref("app.update.url", "https://aus4.mozilla.org/update/3/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml"); +#else +pref("app.update.url", "https://aus3.mozilla.org/update/3/%PRODUCT%/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml"); +#endif // Show the Update Checking/Ready UI when the user was idle for x seconds pref("app.update.idletime", 60); @@ -510,10 +515,19 @@ pref("app.update.cert.maxErrors", 5); // when the |app.update.cert.checkAttributes| preference is set to false. Also, // the |app.update.url.override| preference should ONLY be used for testing. // IMPORTANT! firefox.js should also be updated for updates to certs.X.issuerName + +// Nightly builds have switched over to aus4.mozilla.org, but we don't want anything else to yet. +#ifdef NIGHTLY_BUILD pref("app.update.certs.1.issuerName", "CN=DigiCert Secure Server CA,O=DigiCert Inc,C=US"); pref("app.update.certs.1.commonName", "aus4.mozilla.org"); pref("app.update.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US"); pref("app.update.certs.2.commonName", "aus4.mozilla.org"); +#else +pref("app.update.certs.1.issuerName", "OU=Equifax Secure Certificate Authority,O=Equifax,C=US"); +pref("app.update.certs.1.commonName", "aus3.mozilla.org"); +pref("app.update.certs.2.issuerName", "CN=Thawte SSL CA,O=\"Thawte, Inc.\",C=US"); +pref("app.update.certs.2.commonName", "aus3.mozilla.org"); +#endif // User-settable override to app.update.url for testing purposes. //pref("app.update.url.override", ""); diff --git a/browser/themes/linux/devtools/widgets.css b/browser/themes/linux/devtools/widgets.css index dbc41973b659e8..2428881b36c8c4 100644 --- a/browser/themes/linux/devtools/widgets.css +++ b/browser/themes/linux/devtools/widgets.css @@ -476,7 +476,7 @@ /* Custom configurable/enumerable/writable or frozen/sealed/extensible * variables and properties */ -.variable-or-property[non-enumerable]:not([self]):not([exception]):not([return]) > .title > .name { +.variable-or-property[non-enumerable]:not([self]):not([exception]):not([return]):not([scope]) > .title > .name { opacity: 0.5; } @@ -530,6 +530,11 @@ text-shadow: 0 0 8px #cfc; } +.variable-or-property[scope]:not(:focus) > .title > .name { + color: #00a; + text-shadow: 0 0 8px #ccf; +} + /* Variables and properties tooltips */ .variable-or-property > tooltip > label { diff --git a/browser/themes/osx/devtools/widgets.css b/browser/themes/osx/devtools/widgets.css index 15f02ceb243934..f6897cf042547d 100644 --- a/browser/themes/osx/devtools/widgets.css +++ b/browser/themes/osx/devtools/widgets.css @@ -476,7 +476,7 @@ /* Custom configurable/enumerable/writable or frozen/sealed/extensible * variables and properties */ -.variable-or-property[non-enumerable]:not([self]):not([exception]):not([return]) > .title > .name { +.variable-or-property[non-enumerable]:not([self]):not([exception]):not([return]):not([scope]) > .title > .name { opacity: 0.5; } @@ -530,6 +530,11 @@ text-shadow: 0 0 8px #cfc; } +.variable-or-property[scope]:not(:focus) > .title > .name { + color: #00a; + text-shadow: 0 0 8px #ccf; +} + /* Variables and properties tooltips */ .variable-or-property > tooltip > label { diff --git a/browser/themes/windows/devtools/widgets.css b/browser/themes/windows/devtools/widgets.css index 07ebbf634c1146..3ada2110db1682 100644 --- a/browser/themes/windows/devtools/widgets.css +++ b/browser/themes/windows/devtools/widgets.css @@ -479,7 +479,7 @@ /* Custom configurable/enumerable/writable or frozen/sealed/extensible * variables and properties */ -.variable-or-property[non-enumerable]:not([self]):not([exception]):not([return]) > .title > .name { +.variable-or-property[non-enumerable]:not([self]):not([exception]):not([return]):not([scope]) > .title > .name { opacity: 0.5; } @@ -533,6 +533,11 @@ text-shadow: 0 0 8px #cfc; } +.variable-or-property[scope]:not(:focus) > .title > .name { + color: #00a; + text-shadow: 0 0 8px #ccf; +} + /* Variables and properties tooltips */ .variable-or-property > tooltip > label { diff --git a/build/unix/build-clang/tooltool.py b/build/unix/build-clang/tooltool.py index 1ef3f97a059d1d..ccb77aaea2872b 100644 --- a/build/unix/build-clang/tooltool.py +++ b/build/unix/build-clang/tooltool.py @@ -22,16 +22,13 @@ __version__ = '1' +import json import os import optparse import logging import hashlib import urllib2 import ConfigParser -try: - import simplejson as json # I hear simplejson is faster -except ImportError: - import json log = logging.getLogger(__name__) diff --git a/build/virtualenv_packages.txt b/build/virtualenv_packages.txt index bf6b7263fbe738..98003ce2bff181 100644 --- a/build/virtualenv_packages.txt +++ b/build/virtualenv_packages.txt @@ -1,4 +1,3 @@ -simplejson.pth:python/simplejson-2.1.1 marionette.pth:testing/marionette/client blessings.pth:python/blessings configobj.pth:python/configobj diff --git a/content/base/public/Element.h b/content/base/public/Element.h index 85d45220c4308e..f4dd0f42ef2cdb 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -766,7 +766,7 @@ class Element : public FragmentOrElement * will be respected. */ static nsresult DispatchClickEvent(nsPresContext* aPresContext, - nsInputEvent* aSourceEvent, + WidgetInputEvent* aSourceEvent, nsIContent* aTarget, bool aFullDispatch, const EventFlags* aFlags, diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index c59c5f8f1be056..a09b92872dbe77 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -1391,8 +1391,9 @@ class nsContentUtils * @param aCandidates [out] the candidate access key list. * the first item is most preferred. */ - static void GetAccessKeyCandidates(nsKeyEvent* aNativeKeyEvent, - nsTArray& aCandidates); + static void GetAccessKeyCandidates( + mozilla::WidgetKeyboardEvent* aNativeKeyEvent, + nsTArray& aCandidates); /** * Hide any XUL popups associated with aDocument, including any documents @@ -1406,9 +1407,9 @@ class nsContentUtils static already_AddRefed GetDragSession(); /* - * Initialize and set the dataTransfer field of an nsDragEvent. + * Initialize and set the dataTransfer field of an WidgetDragEvent. */ - static nsresult SetDataTransferInEvent(nsDragEvent* aDragEvent); + static nsresult SetDataTransferInEvent(mozilla::WidgetDragEvent* aDragEvent); // filters the drag and drop action to fit within the effects allowed and // returns it. @@ -1419,7 +1420,7 @@ class nsContentUtils * an ancestor of the document for the source of the drag. */ static bool CheckForSubFrameDrop(nsIDragSession* aDragSession, - nsDragEvent* aDropEvent); + mozilla::WidgetDragEvent* aDropEvent); /** * Return true if aURI is a local file URI (i.e. file://). diff --git a/content/base/public/nsISelectionPrivate.idl b/content/base/public/nsISelectionPrivate.idl index f7af605438195e..b17fadb9143366 100644 --- a/content/base/public/nsISelectionPrivate.idl +++ b/content/base/public/nsISelectionPrivate.idl @@ -23,7 +23,7 @@ template class nsTArray; [ptr] native nsIFrame(nsIFrame); [ptr] native RangeArray(nsTArray); -[ref] native constTextRangeStyleRef(const nsTextRangeStyle); +[ref] native constTextRangeStyleRef(const mozilla::TextRangeStyle); [ref] native nsPointRef(nsPoint); native nsDirection(nsDirection); native ScrollAxis(nsIPresShell::ScrollAxis); diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 6212d9f8dd7cfa..15526681ea6d92 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -1431,7 +1431,7 @@ Element::DispatchEvent(nsPresContext* aPresContext, /* static */ nsresult Element::DispatchClickEvent(nsPresContext* aPresContext, - nsInputEvent* aSourceEvent, + WidgetInputEvent* aSourceEvent, nsIContent* aTarget, bool aFullDispatch, const EventFlags* aExtraEventFlags, @@ -2245,7 +2245,8 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor) case NS_MOUSE_CLICK: if (aVisitor.mEvent->IsLeftClickEvent()) { - nsInputEvent* inputEvent = static_cast(aVisitor.mEvent); + WidgetInputEvent* inputEvent = + static_cast(aVisitor.mEvent); if (inputEvent->IsControl() || inputEvent->IsMeta() || inputEvent->IsAlt() ||inputEvent->IsShift()) { break; @@ -2256,8 +2257,8 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor) if (shell) { // single-click nsEventStatus status = nsEventStatus_eIgnore; - nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, - NS_UI_ACTIVATE, 1); + InternalUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, + NS_UI_ACTIVATE, 1); rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status); if (NS_SUCCEEDED(rv)) { @@ -2283,7 +2284,8 @@ Element::PostHandleEventForLinks(nsEventChainPostVisitor& aVisitor) case NS_KEY_PRESS: { if (aVisitor.mEvent->eventStructType == NS_KEY_EVENT) { - nsKeyEvent* keyEvent = static_cast(aVisitor.mEvent); + WidgetKeyboardEvent* keyEvent = + static_cast(aVisitor.mEvent); if (keyEvent->keyCode == NS_VK_RETURN) { nsEventStatus status = nsEventStatus_eIgnore; rv = DispatchClickEvent(aVisitor.mPresContext, keyEvent, this, diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 646e4bf1c4dba3..c57d8316dab6f7 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -4599,8 +4599,8 @@ nsContentUtils::GetAccelKeyCandidates(nsIDOMKeyEvent* aDOMKeyEvent, if (!eventType.EqualsLiteral("keypress")) return; - nsKeyEvent* nativeKeyEvent = - static_cast(GetNativeEvent(aDOMKeyEvent)); + WidgetKeyboardEvent* nativeKeyEvent = + static_cast(GetNativeEvent(aDOMKeyEvent)); if (nativeKeyEvent) { NS_ASSERTION(nativeKeyEvent->eventStructType == NS_KEY_EVENT, "wrong type of native event"); @@ -4691,7 +4691,7 @@ nsContentUtils::GetAccelKeyCandidates(nsIDOMKeyEvent* aDOMKeyEvent, /* static */ void -nsContentUtils::GetAccessKeyCandidates(nsKeyEvent* aNativeKeyEvent, +nsContentUtils::GetAccessKeyCandidates(WidgetKeyboardEvent* aNativeKeyEvent, nsTArray& aCandidates) { NS_PRECONDITION(aCandidates.IsEmpty(), "aCandidates must be empty"); @@ -4979,7 +4979,7 @@ nsContentUtils::GetDragSession() /* static */ nsresult -nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent) +nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent) { if (aDragEvent->dataTransfer || !aDragEvent->mFlags.mIsTrusted) return NS_OK; @@ -5081,7 +5081,8 @@ nsContentUtils::FilterDropEffect(uint32_t aAction, uint32_t aEffectAllowed) /* static */ bool -nsContentUtils::CheckForSubFrameDrop(nsIDragSession* aDragSession, nsDragEvent* aDropEvent) +nsContentUtils::CheckForSubFrameDrop(nsIDragSession* aDragSession, + WidgetDragEvent* aDropEvent) { nsCOMPtr target = do_QueryInterface(aDropEvent->originalTarget); if (!target) { diff --git a/content/canvas/public/nsICanvasRenderingContextInternal.h b/content/canvas/public/nsICanvasRenderingContextInternal.h index a0b2af18e916ae..b986f40a36df27 100644 --- a/content/canvas/public/nsICanvasRenderingContextInternal.h +++ b/content/canvas/public/nsICanvasRenderingContextInternal.h @@ -54,6 +54,12 @@ class nsICanvasRenderingContextInternal : public nsISupports { return mCanvasElement; } +#ifdef DEBUG + // Useful for testing + virtual int32_t GetWidth() const = 0; + virtual int32_t GetHeight() const = 0; +#endif + // Sets the dimensions of the canvas, in pixels. Called // whenever the size of the element changes. NS_IMETHOD SetDimensions(int32_t width, int32_t height) = 0; diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 98407cd4615500..14b2fc2998dd92 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -909,6 +909,20 @@ CanvasRenderingContext2D::EnsureTarget() } } +#ifdef DEBUG +int32_t +CanvasRenderingContext2D::GetWidth() const +{ + return mWidth; +} + +int32_t +CanvasRenderingContext2D::GetHeight() const +{ + return mHeight; +} +#endif + NS_IMETHODIMP CanvasRenderingContext2D::SetDimensions(int32_t width, int32_t height) { diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index 27b2b6e6b8c4a9..b5d8e124632263 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -371,6 +371,10 @@ typedef HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement nsresult Redraw(); +#ifdef DEBUG + virtual int32_t GetWidth() const MOZ_OVERRIDE; + virtual int32_t GetHeight() const MOZ_OVERRIDE; +#endif // nsICanvasRenderingContextInternal NS_IMETHOD SetDimensions(int32_t width, int32_t height) MOZ_OVERRIDE; NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, int32_t width, int32_t height) MOZ_OVERRIDE; diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index 1d4ccc1ac93eac..a05626789a28af 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -348,6 +348,20 @@ WebGLContext::SetContextOptions(JSContext* aCx, JS::Handle aOptions) return NS_OK; } +#ifdef DEBUG +int32_t +WebGLContext::GetWidth() const +{ + return mWidth; +} + +int32_t +WebGLContext::GetHeight() const +{ + return mHeight; +} +#endif + NS_IMETHODIMP WebGLContext::SetDimensions(int32_t width, int32_t height) { diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index df48d545f8f962..a410f8dcf09a56 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -153,6 +153,10 @@ class WebGLContext : NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT // nsICanvasRenderingContextInternal +#ifdef DEBUG + virtual int32_t GetWidth() const MOZ_OVERRIDE; + virtual int32_t GetHeight() const MOZ_OVERRIDE; +#endif NS_IMETHOD SetDimensions(int32_t width, int32_t height) MOZ_OVERRIDE; NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, int32_t width, int32_t height) MOZ_OVERRIDE { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/content/events/public/nsIPrivateTextRange.h b/content/events/public/nsIPrivateTextRange.h index 5ceb024c4c0f46..19c703943a6267 100644 --- a/content/events/public/nsIPrivateTextRange.h +++ b/content/events/public/nsIPrivateTextRange.h @@ -32,7 +32,7 @@ class nsIPrivateTextRange : public nsISupports { NS_IMETHOD GetRangeStart(uint16_t* aRangeStart)=0; NS_IMETHOD GetRangeEnd(uint16_t* aRangeEnd)=0; NS_IMETHOD GetRangeType(uint16_t* aRangeType)=0; - NS_IMETHOD GetRangeStyle(nsTextRangeStyle* aTextRangeStyle)=0; + NS_IMETHOD GetRangeStyle(mozilla::TextRangeStyle* aTextRangeStyle)=0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateTextRange, NS_IPRIVATETEXTRANGE_IID) diff --git a/content/events/src/TextComposition.cpp b/content/events/src/TextComposition.cpp index 7ec091943a9098..a8a7a69ff0ff4e 100644 --- a/content/events/src/TextComposition.cpp +++ b/content/events/src/TextComposition.cpp @@ -51,7 +51,7 @@ TextComposition::DispatchEvent(nsGUIEvent* aEvent, nsDispatchingCallback* aCallBack) { if (aEvent->message == NS_COMPOSITION_UPDATE) { - mLastData = static_cast(aEvent)->data; + mLastData = static_cast(aEvent)->data; } nsEventDispatcher::Dispatch(mNode, mPresContext, @@ -114,8 +114,9 @@ TextComposition::CompositionEventDispatcher::Run() nsEventStatus status = nsEventStatus_eIgnore; switch (mEventMessage) { case NS_COMPOSITION_START: { - nsCompositionEvent compStart(true, NS_COMPOSITION_START, mWidget); - nsQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT, mWidget); + WidgetCompositionEvent compStart(true, NS_COMPOSITION_START, mWidget); + WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT, + mWidget); nsContentEventHandler handler(mPresContext); handler.OnQuerySelectedText(&selectedText); NS_ASSERTION(selectedText.mSucceeded, "Failed to get selected text"); @@ -126,14 +127,14 @@ TextComposition::CompositionEventDispatcher::Run() } case NS_COMPOSITION_UPDATE: case NS_COMPOSITION_END: { - nsCompositionEvent compEvent(true, mEventMessage, mWidget); + WidgetCompositionEvent compEvent(true, mEventMessage, mWidget); compEvent.data = mData; nsIMEStateManager::DispatchCompositionEvent(mEventTarget, mPresContext, &compEvent, &status, nullptr); break; } case NS_TEXT_TEXT: { - nsTextEvent textEvent(true, NS_TEXT_TEXT, mWidget); + WidgetTextEvent textEvent(true, NS_TEXT_TEXT, mWidget); textEvent.theText = mData; nsIMEStateManager::DispatchCompositionEvent(mEventTarget, mPresContext, &textEvent, &status, nullptr); diff --git a/content/events/src/nsContentEventHandler.cpp b/content/events/src/nsContentEventHandler.cpp index ebbf3c93785d54..67576ece868899 100644 --- a/content/events/src/nsContentEventHandler.cpp +++ b/content/events/src/nsContentEventHandler.cpp @@ -85,7 +85,7 @@ nsContentEventHandler::InitCommon() } nsresult -nsContentEventHandler::Init(nsQueryContentEvent* aEvent) +nsContentEventHandler::Init(WidgetQueryContentEvent* aEvent) { NS_ASSERTION(aEvent, "aEvent must not be null"); @@ -114,7 +114,7 @@ nsContentEventHandler::Init(nsQueryContentEvent* aEvent) } nsresult -nsContentEventHandler::Init(nsSelectionEvent* aEvent) +nsContentEventHandler::Init(WidgetSelectionEvent* aEvent) { NS_ASSERTION(aEvent, "aEvent must not be null"); @@ -475,7 +475,7 @@ nsContentEventHandler::SetRangeFromFlatTextOffset( } nsresult -nsContentEventHandler::OnQuerySelectedText(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQuerySelectedText(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -518,7 +518,7 @@ nsContentEventHandler::OnQuerySelectedText(nsQueryContentEvent* aEvent) } nsresult -nsContentEventHandler::OnQueryTextContent(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQueryTextContent(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -579,7 +579,7 @@ static nsresult GetFrameForTextRect(nsINode* aNode, } nsresult -nsContentEventHandler::OnQueryTextRect(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQueryTextRect(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -669,7 +669,7 @@ nsContentEventHandler::OnQueryTextRect(nsQueryContentEvent* aEvent) } nsresult -nsContentEventHandler::OnQueryEditorRect(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQueryEditorRect(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -698,7 +698,7 @@ nsContentEventHandler::OnQueryEditorRect(nsQueryContentEvent* aEvent) } nsresult -nsContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQueryCaretRect(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -770,7 +770,7 @@ nsContentEventHandler::OnQueryCaretRect(nsQueryContentEvent* aEvent) } nsresult -nsContentEventHandler::OnQueryContentState(nsQueryContentEvent * aEvent) +nsContentEventHandler::OnQueryContentState(WidgetQueryContentEvent * aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -782,7 +782,8 @@ nsContentEventHandler::OnQueryContentState(nsQueryContentEvent * aEvent) } nsresult -nsContentEventHandler::OnQuerySelectionAsTransferable(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQuerySelectionAsTransferable( + WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -805,7 +806,7 @@ nsContentEventHandler::OnQuerySelectionAsTransferable(nsQueryContentEvent* aEven } nsresult -nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQueryCharacterAtPoint(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -828,8 +829,8 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent) NS_ENSURE_TRUE(rootWidget, NS_ERROR_FAILURE); } - nsQueryContentEvent eventOnRoot(true, NS_QUERY_CHARACTER_AT_POINT, - rootWidget); + WidgetQueryContentEvent eventOnRoot(true, NS_QUERY_CHARACTER_AT_POINT, + rootWidget); eventOnRoot.refPoint = aEvent->refPoint; if (rootWidget != aEvent->widget) { eventOnRoot.refPoint += LayoutDeviceIntPoint::FromUntyped( @@ -844,7 +845,7 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent) !nsContentUtils::ContentIsDescendantOf(targetFrame->GetContent(), mRootContent)) { // there is no character at the point. - aEvent->mReply.mOffset = nsQueryContentEvent::NOT_FOUND; + aEvent->mReply.mOffset = WidgetQueryContentEvent::NOT_FOUND; aEvent->mSucceeded = true; return NS_OK; } @@ -862,7 +863,7 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent) &nativeOffset); NS_ENSURE_SUCCESS(rv, rv); - nsQueryContentEvent textRect(true, NS_QUERY_TEXT_RECT, aEvent->widget); + WidgetQueryContentEvent textRect(true, NS_QUERY_TEXT_RECT, aEvent->widget); textRect.InitForQueryTextRect(nativeOffset, 1); rv = OnQueryTextRect(&textRect); NS_ENSURE_SUCCESS(rv, rv); @@ -876,7 +877,7 @@ nsContentEventHandler::OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent) } nsresult -nsContentEventHandler::OnQueryDOMWidgetHittest(nsQueryContentEvent* aEvent) +nsContentEventHandler::OnQueryDOMWidgetHittest(WidgetQueryContentEvent* aEvent) { nsresult rv = Init(aEvent); if (NS_FAILED(rv)) @@ -1051,7 +1052,7 @@ static void AdjustRangeForSelection(nsIContent* aRoot, } nsresult -nsContentEventHandler::OnSelectionEvent(nsSelectionEvent* aEvent) +nsContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent) { aEvent->mSucceeded = false; diff --git a/content/events/src/nsContentEventHandler.h b/content/events/src/nsContentEventHandler.h index 725c43d1f314ed..f35b16f33afe57 100644 --- a/content/events/src/nsContentEventHandler.h +++ b/content/events/src/nsContentEventHandler.h @@ -30,26 +30,27 @@ class MOZ_STACK_CLASS nsContentEventHandler { nsContentEventHandler(nsPresContext *aPresContext); // NS_QUERY_SELECTED_TEXT event handler - nsresult OnQuerySelectedText(nsQueryContentEvent* aEvent); + nsresult OnQuerySelectedText(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_TEXT_CONTENT event handler - nsresult OnQueryTextContent(nsQueryContentEvent* aEvent); + nsresult OnQueryTextContent(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_CARET_RECT event handler - nsresult OnQueryCaretRect(nsQueryContentEvent* aEvent); + nsresult OnQueryCaretRect(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_TEXT_RECT event handler - nsresult OnQueryTextRect(nsQueryContentEvent* aEvent); + nsresult OnQueryTextRect(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_EDITOR_RECT event handler - nsresult OnQueryEditorRect(nsQueryContentEvent* aEvent); + nsresult OnQueryEditorRect(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_CONTENT_STATE event handler - nsresult OnQueryContentState(nsQueryContentEvent* aEvent); + nsresult OnQueryContentState(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_SELECTION_AS_TRANSFERABLE event handler - nsresult OnQuerySelectionAsTransferable(nsQueryContentEvent* aEvent); + nsresult OnQuerySelectionAsTransferable( + mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_CHARACTER_AT_POINT event handler - nsresult OnQueryCharacterAtPoint(nsQueryContentEvent* aEvent); + nsresult OnQueryCharacterAtPoint(mozilla::WidgetQueryContentEvent* aEvent); // NS_QUERY_DOM_WIDGET_HITTEST event handler - nsresult OnQueryDOMWidgetHittest(nsQueryContentEvent* aEvent); + nsresult OnQueryDOMWidgetHittest(mozilla::WidgetQueryContentEvent* aEvent); // NS_SELECTION_* event - nsresult OnSelectionEvent(nsSelectionEvent* aEvent); + nsresult OnSelectionEvent(mozilla::WidgetSelectionEvent* aEvent); protected: nsPresContext* mPresContext; @@ -58,8 +59,8 @@ class MOZ_STACK_CLASS nsContentEventHandler { nsRefPtr mFirstSelectedRange; nsCOMPtr mRootContent; - nsresult Init(nsQueryContentEvent* aEvent); - nsresult Init(nsSelectionEvent* aEvent); + nsresult Init(mozilla::WidgetQueryContentEvent* aEvent); + nsresult Init(mozilla::WidgetSelectionEvent* aEvent); // InitCommon() is called from each Init(). nsresult InitCommon(); diff --git a/content/events/src/nsDOMCompositionEvent.cpp b/content/events/src/nsDOMCompositionEvent.cpp index 2c538eea4e780b..076bb192da8bd8 100644 --- a/content/events/src/nsDOMCompositionEvent.cpp +++ b/content/events/src/nsDOMCompositionEvent.cpp @@ -8,11 +8,13 @@ #include "prtime.h" #include "mozilla/TextEvents.h" +using namespace mozilla; + nsDOMCompositionEvent::nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsCompositionEvent* aEvent) + WidgetCompositionEvent* aEvent) : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent : - new nsCompositionEvent(false, 0, nullptr)) + new WidgetCompositionEvent(false, 0, nullptr)) { NS_ASSERTION(mEvent->eventStructType == NS_COMPOSITION_EVENT, "event type mismatch"); @@ -29,14 +31,14 @@ nsDOMCompositionEvent::nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner, mEvent->mFlags.mCancelable = false; } - mData = static_cast(mEvent)->data; + mData = static_cast(mEvent)->data; // TODO: Native event should have locale information. } nsDOMCompositionEvent::~nsDOMCompositionEvent() { if (mEventIsInternal) { - delete static_cast(mEvent); + delete static_cast(mEvent); mEvent = nullptr; } } @@ -83,7 +85,7 @@ nsresult NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsCompositionEvent *aEvent) + WidgetCompositionEvent* aEvent) { nsDOMCompositionEvent* event = new nsDOMCompositionEvent(aOwner, aPresContext, aEvent); diff --git a/content/events/src/nsDOMCompositionEvent.h b/content/events/src/nsDOMCompositionEvent.h index 3396160325ea79..e0294ff62d17c2 100644 --- a/content/events/src/nsDOMCompositionEvent.h +++ b/content/events/src/nsDOMCompositionEvent.h @@ -18,7 +18,7 @@ class nsDOMCompositionEvent : public nsDOMUIEvent, public: nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsCompositionEvent* aEvent); + mozilla::WidgetCompositionEvent* aEvent); virtual ~nsDOMCompositionEvent(); NS_DECL_ISUPPORTS_INHERITED diff --git a/content/events/src/nsDOMDragEvent.cpp b/content/events/src/nsDOMDragEvent.cpp index 2b8ffaeccb51e6..e28918378351ed 100644 --- a/content/events/src/nsDOMDragEvent.cpp +++ b/content/events/src/nsDOMDragEvent.cpp @@ -9,11 +9,13 @@ #include "prtime.h" #include "mozilla/MouseEvents.h" +using namespace mozilla; + nsDOMDragEvent::nsDOMDragEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent* aEvent) + WidgetInputEvent* aEvent) : nsDOMMouseEvent(aOwner, aPresContext, aEvent ? aEvent : - new nsDragEvent(false, 0, nullptr)) + new WidgetDragEvent(false, 0, nullptr)) { if (aEvent) { mEventIsInternal = false; @@ -30,7 +32,7 @@ nsDOMDragEvent::~nsDOMDragEvent() { if (mEventIsInternal) { if (mEvent->eventStructType == NS_DRAG_EVENT) - delete static_cast(mEvent); + delete static_cast(mEvent); mEvent = nullptr; } } @@ -60,7 +62,7 @@ nsDOMDragEvent::InitDragEvent(const nsAString & aType, NS_ENSURE_SUCCESS(rv, rv); if (mEventIsInternal && mEvent) { - nsDragEvent* dragEvent = static_cast(mEvent); + WidgetDragEvent* dragEvent = static_cast(mEvent); dragEvent->dataTransfer = aDataTransfer; } @@ -86,7 +88,7 @@ nsDOMDragEvent::GetDataTransfer() return nullptr; } - nsDragEvent* dragEvent = static_cast(mEvent); + WidgetDragEvent* dragEvent = static_cast(mEvent); // for synthetic events, just use the supplied data transfer object even if null if (!mEventIsInternal) { nsresult rv = nsContentUtils::SetDataTransferInEvent(dragEvent); @@ -99,7 +101,7 @@ nsDOMDragEvent::GetDataTransfer() nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsDragEvent *aEvent) + WidgetDragEvent* aEvent) { nsDOMDragEvent* event = new nsDOMDragEvent(aOwner, aPresContext, aEvent); return CallQueryInterface(event, aInstancePtrResult); diff --git a/content/events/src/nsDOMDragEvent.h b/content/events/src/nsDOMDragEvent.h index 3aab87f27ecd22..5ace30c643984b 100644 --- a/content/events/src/nsDOMDragEvent.h +++ b/content/events/src/nsDOMDragEvent.h @@ -16,7 +16,8 @@ class nsDOMDragEvent : public nsDOMMouseEvent, { public: nsDOMDragEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, nsInputEvent* aEvent); + nsPresContext* aPresContext, + mozilla::WidgetInputEvent* aEvent); virtual ~nsDOMDragEvent(); NS_DECL_ISUPPORTS_INHERITED @@ -54,6 +55,6 @@ class nsDOMDragEvent : public nsDOMMouseEvent, nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsDragEvent* aEvent); + mozilla::WidgetDragEvent* aEvent); #endif // nsDOMDragEvent_h__ diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index a66220cc3c6979..e559c982e78f4e 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -143,11 +143,13 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMEvent) case NS_MOUSE_SCROLL_EVENT: case NS_WHEEL_EVENT: case NS_SIMPLE_GESTURE_EVENT: - static_cast(tmp->mEvent)->relatedTarget = nullptr; + static_cast(tmp->mEvent)->relatedTarget = + nullptr; break; case NS_DRAG_EVENT: - static_cast(tmp->mEvent)->dataTransfer = nullptr; - static_cast(tmp->mEvent)->relatedTarget = nullptr; + static_cast(tmp->mEvent)->dataTransfer = nullptr; + static_cast(tmp->mEvent)->relatedTarget = + nullptr; break; case NS_CLIPBOARD_EVENT: static_cast(tmp->mEvent)->clipboardData = @@ -182,15 +184,15 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent) case NS_SIMPLE_GESTURE_EVENT: NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget"); cb.NoteXPCOMChild( - static_cast(tmp->mEvent)->relatedTarget); + static_cast(tmp->mEvent)->relatedTarget); break; case NS_DRAG_EVENT: NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->dataTransfer"); cb.NoteXPCOMChild( - static_cast(tmp->mEvent)->dataTransfer); + static_cast(tmp->mEvent)->dataTransfer); NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget"); cb.NoteXPCOMChild( - static_cast(tmp->mEvent)->relatedTarget); + static_cast(tmp->mEvent)->relatedTarget); break; case NS_CLIPBOARD_EVENT: NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->clipboardData"); @@ -530,16 +532,18 @@ nsDOMEvent::DuplicatePrivateData() } case NS_INPUT_EVENT: { - nsInputEvent* oldInputEvent = static_cast(mEvent); - nsInputEvent* inputEvent = new nsInputEvent(false, msg, nullptr); + WidgetInputEvent* oldInputEvent = static_cast(mEvent); + WidgetInputEvent* inputEvent = new WidgetInputEvent(false, msg, nullptr); inputEvent->AssignInputEventData(*oldInputEvent, true); newEvent = inputEvent; break; } case NS_KEY_EVENT: { - nsKeyEvent* oldKeyEvent = static_cast(mEvent); - nsKeyEvent* keyEvent = new nsKeyEvent(false, msg, nullptr); + WidgetKeyboardEvent* oldKeyEvent = + static_cast(mEvent); + WidgetKeyboardEvent* keyEvent = + new WidgetKeyboardEvent(false, msg, nullptr); keyEvent->AssignKeyEventData(*oldKeyEvent, true); newEvent = keyEvent; break; @@ -555,9 +559,8 @@ nsDOMEvent::DuplicatePrivateData() } case NS_DRAG_EVENT: { - nsDragEvent* oldDragEvent = static_cast(mEvent); - nsDragEvent* dragEvent = - new nsDragEvent(false, msg, nullptr); + WidgetDragEvent* oldDragEvent = static_cast(mEvent); + WidgetDragEvent* dragEvent = new WidgetDragEvent(false, msg, nullptr); dragEvent->AssignDragEventData(*oldDragEvent, true); newEvent = dragEvent; break; @@ -584,28 +587,28 @@ nsDOMEvent::DuplicatePrivateData() } case NS_TEXT_EVENT: { - nsTextEvent* oldTextEvent = static_cast(mEvent); - nsTextEvent* textEvent = new nsTextEvent(false, msg, nullptr); + WidgetTextEvent* oldTextEvent = static_cast(mEvent); + WidgetTextEvent* textEvent = new WidgetTextEvent(false, msg, nullptr); textEvent->AssignTextEventData(*oldTextEvent, true); newEvent = textEvent; break; } case NS_COMPOSITION_EVENT: { - nsCompositionEvent* compositionEvent = - new nsCompositionEvent(false, msg, nullptr); - nsCompositionEvent* oldCompositionEvent = - static_cast(mEvent); + WidgetCompositionEvent* compositionEvent = + new WidgetCompositionEvent(false, msg, nullptr); + WidgetCompositionEvent* oldCompositionEvent = + static_cast(mEvent); compositionEvent->AssignCompositionEventData(*oldCompositionEvent, true); newEvent = compositionEvent; break; } case NS_MOUSE_SCROLL_EVENT: { - nsMouseScrollEvent* oldMouseScrollEvent = - static_cast(mEvent); - nsMouseScrollEvent* mouseScrollEvent = - new nsMouseScrollEvent(false, msg, nullptr); + WidgetMouseScrollEvent* oldMouseScrollEvent = + static_cast(mEvent); + WidgetMouseScrollEvent* mouseScrollEvent = + new WidgetMouseScrollEvent(false, msg, nullptr); mouseScrollEvent->AssignMouseScrollEventData(*oldMouseScrollEvent, true); newEvent = mouseScrollEvent; break; @@ -678,8 +681,9 @@ nsDOMEvent::DuplicatePrivateData() } case NS_UI_EVENT: { - nsUIEvent* oldUIEvent = static_cast(mEvent); - nsUIEvent* uiEvent = new nsUIEvent(false, msg, oldUIEvent->detail); + InternalUIEvent* oldUIEvent = static_cast(mEvent); + InternalUIEvent* uiEvent = + new InternalUIEvent(false, msg, oldUIEvent->detail); uiEvent->AssignUIEventData(*oldUIEvent, true); newEvent = uiEvent; break; @@ -695,8 +699,8 @@ nsDOMEvent::DuplicatePrivateData() } case NS_SMIL_TIME_EVENT: { - nsUIEvent* oldUIEvent = static_cast(mEvent); - nsUIEvent* uiEvent = new nsUIEvent(false, msg, 0); + InternalUIEvent* oldUIEvent = static_cast(mEvent); + InternalUIEvent* uiEvent = new InternalUIEvent(false, msg, 0); uiEvent->eventStructType = NS_SMIL_TIME_EVENT; uiEvent->AssignUIEventData(*oldUIEvent, true); newEvent = uiEvent; @@ -895,7 +899,7 @@ nsDOMEvent::GetEventPopupControlState(nsEvent *aEvent) break; case NS_KEY_EVENT : if (aEvent->mFlags.mIsTrusted) { - uint32_t key = static_cast(aEvent)->keyCode; + uint32_t key = static_cast(aEvent)->keyCode; switch(aEvent->message) { case NS_KEY_PRESS : // return key on focused button. see note at NS_MOUSE_CLICK. diff --git a/content/events/src/nsDOMKeyboardEvent.cpp b/content/events/src/nsDOMKeyboardEvent.cpp index 2bd034a6763a7a..d538727cce1742 100644 --- a/content/events/src/nsDOMKeyboardEvent.cpp +++ b/content/events/src/nsDOMKeyboardEvent.cpp @@ -7,11 +7,13 @@ #include "prtime.h" #include "mozilla/TextEvents.h" +using namespace mozilla; + nsDOMKeyboardEvent::nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsKeyEvent* aEvent) + WidgetKeyboardEvent* aEvent) : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent : - new nsKeyEvent(false, 0, nullptr)) + new WidgetKeyboardEvent(false, 0, nullptr)) { NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch"); @@ -27,7 +29,7 @@ nsDOMKeyboardEvent::nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner, nsDOMKeyboardEvent::~nsDOMKeyboardEvent() { if (mEventIsInternal) { - delete static_cast(mEvent); + delete static_cast(mEvent); mEvent = nullptr; } } @@ -85,7 +87,7 @@ NS_IMETHODIMP nsDOMKeyboardEvent::GetKey(nsAString& aKeyName) { if (!mEventIsInternal) { - static_cast(mEvent)->GetDOMKeyName(aKeyName); + static_cast(mEvent)->GetDOMKeyName(aKeyName); } return NS_OK; } @@ -106,7 +108,7 @@ nsDOMKeyboardEvent::CharCode() case NS_KEY_DOWN: return 0; case NS_KEY_PRESS: - return static_cast(mEvent)->charCode; + return static_cast(mEvent)->charCode; } return 0; } @@ -126,7 +128,7 @@ nsDOMKeyboardEvent::KeyCode() case NS_KEY_UP: case NS_KEY_PRESS: case NS_KEY_DOWN: - return static_cast(mEvent)->keyCode; + return static_cast(mEvent)->keyCode; } return 0; } @@ -142,7 +144,7 @@ nsDOMKeyboardEvent::Which() //Special case for 4xp bug 62878. Try to make value of which //more closely mirror the values that 4.x gave for RETURN and BACKSPACE { - uint32_t keyCode = ((nsKeyEvent*)mEvent)->keyCode; + uint32_t keyCode = static_cast(mEvent)->keyCode; if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) { return keyCode; } @@ -171,7 +173,7 @@ nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool a nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0); NS_ENSURE_SUCCESS(rv, rv); - nsKeyEvent* keyEvent = static_cast(mEvent); + WidgetKeyboardEvent* keyEvent = static_cast(mEvent); keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey); keyEvent->keyCode = aKeyCode; keyEvent->charCode = aCharCode; @@ -182,7 +184,7 @@ nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool a nsresult NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsKeyEvent *aEvent) + WidgetKeyboardEvent* aEvent) { nsDOMKeyboardEvent* it = new nsDOMKeyboardEvent(aOwner, aPresContext, aEvent); return CallQueryInterface(it, aInstancePtrResult); diff --git a/content/events/src/nsDOMKeyboardEvent.h b/content/events/src/nsDOMKeyboardEvent.h index 99694299247571..1edcc7c5907a2f 100644 --- a/content/events/src/nsDOMKeyboardEvent.h +++ b/content/events/src/nsDOMKeyboardEvent.h @@ -17,7 +17,8 @@ class nsDOMKeyboardEvent : public nsDOMUIEvent, { public: nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, nsKeyEvent* aEvent); + nsPresContext* aPresContext, + mozilla::WidgetKeyboardEvent* aEvent); virtual ~nsDOMKeyboardEvent(); NS_DECL_ISUPPORTS_INHERITED @@ -36,22 +37,22 @@ class nsDOMKeyboardEvent : public nsDOMUIEvent, bool AltKey() { - return static_cast(mEvent)->IsAlt(); + return static_cast(mEvent)->IsAlt(); } bool CtrlKey() { - return static_cast(mEvent)->IsControl(); + return static_cast(mEvent)->IsControl(); } bool ShiftKey() { - return static_cast(mEvent)->IsShift(); + return static_cast(mEvent)->IsShift(); } bool MetaKey() { - return static_cast(mEvent)->IsMeta(); + return static_cast(mEvent)->IsMeta(); } bool GetModifierState(const nsAString& aKey) @@ -65,7 +66,7 @@ class nsDOMKeyboardEvent : public nsDOMUIEvent, uint32_t Location() { - return static_cast(mEvent)->location; + return static_cast(mEvent)->location; } void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable, diff --git a/content/events/src/nsDOMMouseEvent.cpp b/content/events/src/nsDOMMouseEvent.cpp index 26bff64e54b4ae..33f2cf1a495a83 100644 --- a/content/events/src/nsDOMMouseEvent.cpp +++ b/content/events/src/nsDOMMouseEvent.cpp @@ -13,12 +13,12 @@ using namespace mozilla; nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent* aEvent) + WidgetInputEvent* aEvent) : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent : new nsMouseEvent(false, 0, nullptr, nsMouseEvent::eReal)) { - // There's no way to make this class' ctor allocate an nsMouseScrollEvent. + // There's no way to make this class' ctor allocate an WidgetMouseScrollEvent. // It's not that important, though, since a scroll event is not a real // DOM event. @@ -86,9 +86,10 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool a case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: { - static_cast(mEvent)->relatedTarget = aRelatedTarget; - static_cast(mEvent)->button = aButton; - nsInputEvent* inputEvent = static_cast(mEvent); + static_cast(mEvent)->relatedTarget = + aRelatedTarget; + static_cast(mEvent)->button = aButton; + WidgetInputEvent* inputEvent = static_cast(mEvent); inputEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey); mClientPoint.x = aClientX; mClientPoint.y = aClientY; @@ -139,7 +140,7 @@ nsDOMMouseEvent::InitMouseEvent(const nsAString& aType, case NS_WHEEL_EVENT: case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: - static_cast(mEvent)->modifiers = modifiers; + static_cast(mEvent)->modifiers = modifiers; return NS_OK; default: MOZ_CRASH("There is no space to store the modifiers"); @@ -169,7 +170,7 @@ nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal, case NS_WHEEL_EVENT: case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: - static_cast(e->mEvent)->buttons = aParam.mButtons; + static_cast(e->mEvent)->buttons = aParam.mButtons; break; default: break; @@ -192,8 +193,8 @@ nsDOMMouseEvent::InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aMetaKey, aButton, aRelatedTarget); NS_ENSURE_SUCCESS(rv, rv); - static_cast(mEvent)->pressure = aPressure; - static_cast(mEvent)->inputSource = aInputSource; + static_cast(mEvent)->pressure = aPressure; + static_cast(mEvent)->inputSource = aInputSource; return NS_OK; } @@ -215,7 +216,7 @@ nsDOMMouseEvent::Button() case NS_WHEEL_EVENT: case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: - return static_cast(mEvent)->button; + return static_cast(mEvent)->button; default: NS_WARNING("Tried to get mouse button for non-mouse event!"); return nsMouseEvent::eLeftButton; @@ -240,7 +241,7 @@ nsDOMMouseEvent::Buttons() case NS_WHEEL_EVENT: case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: - return static_cast(mEvent)->buttons; + return static_cast(mEvent)->buttons; default: MOZ_CRASH("Tried to get mouse buttons for non-mouse event!"); } @@ -265,7 +266,8 @@ nsDOMMouseEvent::GetRelatedTarget() case NS_WHEEL_EVENT: case NS_DRAG_EVENT: case NS_SIMPLE_GESTURE_EVENT: - relatedTarget = do_QueryInterface(static_cast(mEvent)->relatedTarget); + relatedTarget = do_QueryInterface( + static_cast(mEvent)->relatedTarget); break; default: break; @@ -430,7 +432,7 @@ nsDOMMouseEvent::GetMozInputSource(uint16_t* aInputSource) nsresult NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent *aEvent) + WidgetInputEvent* aEvent) { nsDOMMouseEvent* it = new nsDOMMouseEvent(aOwner, aPresContext, aEvent); return CallQueryInterface(it, aInstancePtrResult); diff --git a/content/events/src/nsDOMMouseEvent.h b/content/events/src/nsDOMMouseEvent.h index 4d68d6b7633507..4616d267b52c43 100644 --- a/content/events/src/nsDOMMouseEvent.h +++ b/content/events/src/nsDOMMouseEvent.h @@ -16,7 +16,8 @@ class nsDOMMouseEvent : public nsDOMUIEvent, { public: nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, nsInputEvent* aEvent); + nsPresContext* aPresContext, + mozilla::WidgetInputEvent* aEvent); virtual ~nsDOMMouseEvent(); NS_DECL_ISUPPORTS_INHERITED @@ -45,19 +46,19 @@ class nsDOMMouseEvent : public nsDOMUIEvent, int32_t ClientY(); bool CtrlKey() { - return static_cast(mEvent)->IsControl(); + return static_cast(mEvent)->IsControl(); } bool ShiftKey() { - return static_cast(mEvent)->IsShift(); + return static_cast(mEvent)->IsShift(); } bool AltKey() { - return static_cast(mEvent)->IsAlt(); + return static_cast(mEvent)->IsAlt(); } bool MetaKey() { - return static_cast(mEvent)->IsMeta(); + return static_cast(mEvent)->IsMeta(); } uint16_t Button(); uint16_t Buttons(); @@ -94,11 +95,11 @@ class nsDOMMouseEvent : public nsDOMUIEvent, } float MozPressure() const { - return static_cast(mEvent)->pressure; + return static_cast(mEvent)->pressure; } uint16_t MozInputSource() const { - return static_cast(mEvent)->inputSource; + return static_cast(mEvent)->inputSource; } void InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable, nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX, diff --git a/content/events/src/nsDOMMouseScrollEvent.cpp b/content/events/src/nsDOMMouseScrollEvent.cpp index 01f1c8990fdad2..bcf6445b92cfd2 100644 --- a/content/events/src/nsDOMMouseScrollEvent.cpp +++ b/content/events/src/nsDOMMouseScrollEvent.cpp @@ -7,11 +7,14 @@ #include "prtime.h" #include "mozilla/MouseEvents.h" +using namespace mozilla; + nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent* aEvent) + WidgetInputEvent* aEvent) : nsDOMMouseEvent(aOwner, aPresContext, - aEvent ? aEvent : new nsMouseScrollEvent(false, 0, nullptr)) + aEvent ? aEvent : + new WidgetMouseScrollEvent(false, 0, nullptr)) { if (aEvent) { mEventIsInternal = false; @@ -23,7 +26,7 @@ nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner, } if(mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) { - mDetail = static_cast(mEvent)->delta; + mDetail = static_cast(mEvent)->delta; } } @@ -33,7 +36,7 @@ nsDOMMouseScrollEvent::~nsDOMMouseScrollEvent() switch (mEvent->eventStructType) { case NS_MOUSE_SCROLL_EVENT: - delete static_cast(mEvent); + delete static_cast(mEvent); break; default: delete mEvent; @@ -64,7 +67,7 @@ nsDOMMouseScrollEvent::InitMouseScrollEvent(const nsAString & aType, bool aCanBu NS_ENSURE_SUCCESS(rv, rv); if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) { - static_cast(mEvent)->isHorizontal = + static_cast(mEvent)->isHorizontal = (aAxis == HORIZONTAL_AXIS); } @@ -84,7 +87,7 @@ int32_t nsDOMMouseScrollEvent::Axis() { if (mEvent->eventStructType == NS_MOUSE_SCROLL_EVENT) { - return static_cast(mEvent)->isHorizontal ? + return static_cast(mEvent)->isHorizontal ? static_cast(HORIZONTAL_AXIS) : static_cast(VERTICAL_AXIS); } @@ -94,7 +97,7 @@ nsDOMMouseScrollEvent::Axis() nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent *aEvent) + WidgetInputEvent* aEvent) { nsDOMMouseScrollEvent* it = new nsDOMMouseScrollEvent(aOwner, aPresContext, aEvent); diff --git a/content/events/src/nsDOMMouseScrollEvent.h b/content/events/src/nsDOMMouseScrollEvent.h index c3b668690b685d..b8c1bc1019a4ee 100644 --- a/content/events/src/nsDOMMouseScrollEvent.h +++ b/content/events/src/nsDOMMouseScrollEvent.h @@ -15,7 +15,8 @@ class nsDOMMouseScrollEvent : public nsDOMMouseEvent, { public: nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, nsInputEvent* aEvent); + nsPresContext* aPresContext, + mozilla::WidgetInputEvent* aEvent); virtual ~nsDOMMouseScrollEvent(); NS_DECL_ISUPPORTS_INHERITED diff --git a/content/events/src/nsDOMTextEvent.cpp b/content/events/src/nsDOMTextEvent.cpp index ff7f8719725a8d..9e1dcac2df68f6 100644 --- a/content/events/src/nsDOMTextEvent.cpp +++ b/content/events/src/nsDOMTextEvent.cpp @@ -9,11 +9,13 @@ #include "prtime.h" #include "mozilla/TextEvents.h" +using namespace mozilla; + nsDOMTextEvent::nsDOMTextEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsTextEvent* aEvent) + WidgetTextEvent* aEvent) : nsDOMUIEvent(aOwner, aPresContext, - aEvent ? aEvent : new nsTextEvent(false, 0, nullptr)) + aEvent ? aEvent : new WidgetTextEvent(false, 0, nullptr)) { NS_ASSERTION(mEvent->eventStructType == NS_TEXT_EVENT, "event type mismatch"); @@ -28,7 +30,7 @@ nsDOMTextEvent::nsDOMTextEvent(mozilla::dom::EventTarget* aOwner, // // extract the IME composition string // - nsTextEvent *te = static_cast(mEvent); + WidgetTextEvent *te = static_cast(mEvent); mText = te->theText; // @@ -76,7 +78,7 @@ NS_METHOD_(already_AddRefed) nsDOMTextEvent::GetInputRa nsresult NS_NewDOMTextEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsTextEvent *aEvent) + WidgetTextEvent* aEvent) { nsDOMTextEvent* it = new nsDOMTextEvent(aOwner, aPresContext, aEvent); return CallQueryInterface(it, aInstancePtrResult); diff --git a/content/events/src/nsDOMTextEvent.h b/content/events/src/nsDOMTextEvent.h index fd1986766b7b78..8e2a13187dcf1c 100644 --- a/content/events/src/nsDOMTextEvent.h +++ b/content/events/src/nsDOMTextEvent.h @@ -17,7 +17,8 @@ class nsDOMTextEvent : public nsDOMUIEvent, { public: nsDOMTextEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, nsTextEvent* aEvent); + nsPresContext* aPresContext, + mozilla::WidgetTextEvent* aEvent); NS_DECL_ISUPPORTS_INHERITED diff --git a/content/events/src/nsDOMTouchEvent.cpp b/content/events/src/nsDOMTouchEvent.cpp index e9ecaee7ec3687..32880a6bc9e8e0 100644 --- a/content/events/src/nsDOMTouchEvent.cpp +++ b/content/events/src/nsDOMTouchEvent.cpp @@ -115,8 +115,8 @@ nsDOMTouchEvent::InitTouchEvent(const nsAString& aType, return; } - static_cast(mEvent)->InitBasicModifiers(aCtrlKey, aAltKey, - aShiftKey, aMetaKey); + static_cast(mEvent)-> + InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey); mTouches = aTouches; mTargetTouches = aTargetTouches; mChangedTouches = aChangedTouches; diff --git a/content/events/src/nsDOMTouchEvent.h b/content/events/src/nsDOMTouchEvent.h index c527d9dbb98c56..31f74c8f5e265e 100644 --- a/content/events/src/nsDOMTouchEvent.h +++ b/content/events/src/nsDOMTouchEvent.h @@ -101,22 +101,22 @@ class nsDOMTouchEvent : public nsDOMUIEvent bool AltKey() { - return static_cast(mEvent)->IsAlt(); + return static_cast(mEvent)->IsAlt(); } bool MetaKey() { - return static_cast(mEvent)->IsMeta(); + return static_cast(mEvent)->IsMeta(); } bool CtrlKey() { - return static_cast(mEvent)->IsControl(); + return static_cast(mEvent)->IsControl(); } bool ShiftKey() { - return static_cast(mEvent)->IsShift(); + return static_cast(mEvent)->IsShift(); } void InitTouchEvent(const nsAString& aType, diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp index 376beb223666d0..e9aed272468df1 100644 --- a/content/events/src/nsDOMUIEvent.cpp +++ b/content/events/src/nsDOMUIEvent.cpp @@ -24,9 +24,8 @@ using namespace mozilla; nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, nsGUIEvent* aEvent) - : nsDOMEvent(aOwner, aPresContext, aEvent ? - static_cast(aEvent) : - static_cast(new nsUIEvent(false, 0, 0))) + : nsDOMEvent(aOwner, aPresContext, + aEvent ? aEvent : new InternalUIEvent(false, 0, 0)) , mClientPoint(0, 0), mLayerPoint(0, 0), mPagePoint(0, 0), mMovementPoint(0, 0) , mIsPointerLocked(nsEventStateManager::sIsPointerLocked) , mLastClientPoint(nsEventStateManager::sLastClientPoint) @@ -45,7 +44,7 @@ nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner, { case NS_UI_EVENT: { - nsUIEvent *event = static_cast(mEvent); + InternalUIEvent *event = static_cast(mEvent); mDetail = event->detail; break; } @@ -349,9 +348,9 @@ nsDOMUIEvent::IsChar() const switch (mEvent->eventStructType) { case NS_KEY_EVENT: - return static_cast(mEvent)->isChar; + return static_cast(mEvent)->isChar; case NS_TEXT_EVENT: - return static_cast(mEvent)->isChar; + return static_cast(mEvent)->isChar; default: return false; } @@ -464,9 +463,9 @@ bool nsDOMUIEvent::GetModifierStateInternal(const nsAString& aKey) { if (!mEvent->IsInputDerivedEvent()) { - MOZ_CRASH("mEvent must be nsInputEvent or derived class"); + MOZ_CRASH("mEvent must be WidgetInputEvent or derived class"); } - nsInputEvent* inputEvent = static_cast(mEvent); + WidgetInputEvent* inputEvent = static_cast(mEvent); if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) { return inputEvent->IsShift(); } diff --git a/content/events/src/nsDOMXULCommandEvent.cpp b/content/events/src/nsDOMXULCommandEvent.cpp index e3de039f8423c1..f2233e61a7bd7c 100644 --- a/content/events/src/nsDOMXULCommandEvent.cpp +++ b/content/events/src/nsDOMXULCommandEvent.cpp @@ -7,11 +7,13 @@ #include "nsDOMXULCommandEvent.h" #include "prtime.h" +using namespace mozilla; + nsDOMXULCommandEvent::nsDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent* aEvent) + WidgetInputEvent* aEvent) : nsDOMUIEvent(aOwner, aPresContext, - aEvent ? aEvent : new nsInputEvent(false, 0, nullptr)) + aEvent ? aEvent : new WidgetInputEvent(false, 0, nullptr)) { if (aEvent) { mEventIsInternal = false; @@ -95,7 +97,7 @@ nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType, nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult, mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, - nsInputEvent *aEvent) + WidgetInputEvent* aEvent) { nsDOMXULCommandEvent* it = new nsDOMXULCommandEvent(aOwner, aPresContext, aEvent); diff --git a/content/events/src/nsDOMXULCommandEvent.h b/content/events/src/nsDOMXULCommandEvent.h index 3f6442555af193..52f40f943caa5d 100644 --- a/content/events/src/nsDOMXULCommandEvent.h +++ b/content/events/src/nsDOMXULCommandEvent.h @@ -18,7 +18,8 @@ class nsDOMXULCommandEvent : public nsDOMUIEvent, { public: nsDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner, - nsPresContext* aPresContext, nsInputEvent* aEvent); + nsPresContext* aPresContext, + mozilla::WidgetInputEvent* aEvent); NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent) @@ -76,8 +77,8 @@ class nsDOMXULCommandEvent : public nsDOMUIEvent, protected: // Convenience accessor for the event - nsInputEvent* Event() { - return static_cast(mEvent); + mozilla::WidgetInputEvent* Event() { + return static_cast(mEvent); } nsCOMPtr mSourceEvent; diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index eeb1419a21abdc..ca50c8b2b9ff30 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -703,29 +703,29 @@ nsEventDispatcher::CreateEvent(mozilla::dom::EventTarget* aOwner, static_cast(aEvent)); case NS_KEY_EVENT: return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext, - static_cast(aEvent)); + static_cast(aEvent)); case NS_COMPOSITION_EVENT: return NS_NewDOMCompositionEvent( aDOMEvent, aOwner, - aPresContext, static_cast(aEvent)); + aPresContext, static_cast(aEvent)); case NS_MOUSE_EVENT: return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext, - static_cast(aEvent)); + static_cast(aEvent)); case NS_FOCUS_EVENT: return NS_NewDOMFocusEvent(aDOMEvent, aOwner, aPresContext, static_cast(aEvent)); case NS_MOUSE_SCROLL_EVENT: return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext, - static_cast(aEvent)); + static_cast(aEvent)); case NS_WHEEL_EVENT: return NS_NewDOMWheelEvent(aDOMEvent, aOwner, aPresContext, static_cast(aEvent)); case NS_DRAG_EVENT: return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext, - static_cast(aEvent)); + static_cast(aEvent)); case NS_TEXT_EVENT: return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext, - static_cast(aEvent)); + static_cast(aEvent)); case NS_CLIPBOARD_EVENT: return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext, static_cast(aEvent)); diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index cef72cafece6e4..8face3cbeaed66 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -935,7 +935,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, case NS_KEY_PRESS: { - nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; + WidgetKeyboardEvent* keyEvent = static_cast(aEvent); int32_t modifierMask = 0; if (keyEvent->IsShift()) @@ -992,69 +992,72 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, } break; case NS_QUERY_SELECTED_TEXT: - DoQuerySelectedText(static_cast(aEvent)); + DoQuerySelectedText(static_cast(aEvent)); break; case NS_QUERY_TEXT_CONTENT: { if (RemoteQueryContentEvent(aEvent)) break; nsContentEventHandler handler(mPresContext); - handler.OnQueryTextContent((nsQueryContentEvent*)aEvent); + handler.OnQueryTextContent(static_cast(aEvent)); } break; case NS_QUERY_CARET_RECT: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQueryCaretRect((nsQueryContentEvent*)aEvent); + handler.OnQueryCaretRect(static_cast(aEvent)); } break; case NS_QUERY_TEXT_RECT: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQueryTextRect((nsQueryContentEvent*)aEvent); + handler.OnQueryTextRect(static_cast(aEvent)); } break; case NS_QUERY_EDITOR_RECT: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQueryEditorRect((nsQueryContentEvent*)aEvent); + handler.OnQueryEditorRect(static_cast(aEvent)); } break; case NS_QUERY_CONTENT_STATE: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQueryContentState(static_cast(aEvent)); + handler.OnQueryContentState(static_cast(aEvent)); } break; case NS_QUERY_SELECTION_AS_TRANSFERABLE: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQuerySelectionAsTransferable(static_cast(aEvent)); + handler.OnQuerySelectionAsTransferable( + static_cast(aEvent)); } break; case NS_QUERY_CHARACTER_AT_POINT: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQueryCharacterAtPoint(static_cast(aEvent)); + handler.OnQueryCharacterAtPoint( + static_cast(aEvent)); } break; case NS_QUERY_DOM_WIDGET_HITTEST: { // XXX remote event nsContentEventHandler handler(mPresContext); - handler.OnQueryDOMWidgetHittest(static_cast(aEvent)); + handler.OnQueryDOMWidgetHittest( + static_cast(aEvent)); } break; case NS_SELECTION_SET: { - nsSelectionEvent *selectionEvent = - static_cast(aEvent); + WidgetSelectionEvent *selectionEvent = + static_cast(aEvent); if (IsTargetCrossProcess(selectionEvent)) { // Will not be handled locally, remote the event if (GetCrossProcessTarget()->SendSelectionEvent(*selectionEvent)) @@ -1062,7 +1065,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, break; } nsContentEventHandler handler(mPresContext); - handler.OnSelectionEvent((nsSelectionEvent*)aEvent); + handler.OnSelectionEvent(static_cast(aEvent)); } break; case NS_CONTENT_COMMAND_CUT: @@ -1084,7 +1087,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, break; case NS_TEXT_TEXT: { - nsTextEvent *textEvent = static_cast(aEvent); + WidgetTextEvent *textEvent = static_cast(aEvent); if (IsTargetCrossProcess(textEvent)) { // Will not be handled locally, remote the event if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) { @@ -1098,10 +1101,10 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (aEvent->mFlags.mIsTrusted) { // If the event is trusted event, set the selected text to data of // composition event. - nsCompositionEvent *compositionEvent = - static_cast(aEvent); - nsQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT, - compositionEvent->widget); + WidgetCompositionEvent *compositionEvent = + static_cast(aEvent); + WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT, + compositionEvent->widget); DoQuerySelectedText(&selectedText); NS_ASSERTION(selectedText.mSucceeded, "Failed to get selected text"); compositionEvent->data = selectedText.mReply.mString; @@ -1110,8 +1113,8 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, case NS_COMPOSITION_UPDATE: case NS_COMPOSITION_END: { - nsCompositionEvent *compositionEvent = - static_cast(aEvent); + WidgetCompositionEvent *compositionEvent = + static_cast(aEvent); if (IsTargetCrossProcess(compositionEvent)) { // Will not be handled locally, remote the event if (GetCrossProcessTarget()->SendCompositionEvent(*compositionEvent)) { @@ -1278,7 +1281,7 @@ nsEventStateManager::GetAccessKeyLabelPrefix(nsAString& aPrefix) void nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext, - nsKeyEvent *aEvent, + WidgetKeyboardEvent* aEvent, nsEventStatus* aStatus, nsIDocShellTreeItem* aBubbledFrom, ProcessingAccessKeyState aAccessKeyState, @@ -1388,7 +1391,7 @@ nsEventStateManager::DispatchCrossProcessEvent(nsEvent* aEvent, return remote->SendRealMouseEvent(*mouseEvent); } case NS_KEY_EVENT: { - nsKeyEvent* keyEvent = static_cast(aEvent); + WidgetKeyboardEvent* keyEvent = static_cast(aEvent); return remote->SendRealKeyEvent(*keyEvent); } case NS_WHEEL_EVENT: { @@ -1925,12 +1928,12 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, nsCOMPtr widget = mCurrentTarget->GetNearestWidget(); // get the widget from the target frame - nsDragEvent startEvent(aEvent->mFlags.mIsTrusted, - NS_DRAGDROP_START, widget); + WidgetDragEvent startEvent(aEvent->mFlags.mIsTrusted, + NS_DRAGDROP_START, widget); FillInEventFromGestureDown(&startEvent); - nsDragEvent gestureEvent(aEvent->mFlags.mIsTrusted, - NS_DRAGDROP_GESTURE, widget); + WidgetDragEvent gestureEvent(aEvent->mFlags.mIsTrusted, + NS_DRAGDROP_GESTURE, widget); FillInEventFromGestureDown(&gestureEvent); startEvent.dataTransfer = gestureEvent.dataTransfer = dataTransfer; @@ -1958,7 +1961,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, nsEventDispatcher::Dispatch(targetContent, aPresContext, &startEvent, nullptr, &status); - nsDragEvent* event = &startEvent; + WidgetDragEvent* event = &startEvent; if (status != nsEventStatus_eConsumeNoDefault) { status = nsEventStatus_eIgnore; nsEventDispatcher::Dispatch(targetContent, aPresContext, &gestureEvent, nullptr, @@ -2083,7 +2086,7 @@ nsEventStateManager::DetermineDragTarget(nsPresContext* aPresContext, bool nsEventStateManager::DoDefaultDragStart(nsPresContext* aPresContext, - nsDragEvent* aDragEvent, + WidgetDragEvent* aDragEvent, nsDOMDataTransfer* aDataTransfer, nsIContent* aDragTarget, nsISelection* aSelection) @@ -2475,8 +2478,8 @@ nsEventStateManager::SendLineScrollEvent(nsIFrame* aTargetFrame, targetContent = targetContent->GetParent(); } - nsMouseScrollEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_SCROLL, - aEvent->widget); + WidgetMouseScrollEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_SCROLL, + aEvent->widget); if (*aStatus == nsEventStatus_eConsumeNoDefault) { event.mFlags.mDefaultPrevented = true; } @@ -2511,8 +2514,8 @@ nsEventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame, targetContent = targetContent->GetParent(); } - nsMouseScrollEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_PIXEL_SCROLL, - aEvent->widget); + WidgetMouseScrollEvent event(aEvent->mFlags.mIsTrusted, NS_MOUSE_PIXEL_SCROLL, + aEvent->widget); if (*aStatus == nsEventStatus_eConsumeNoDefault) { event.mFlags.mDefaultPrevented = true; } @@ -3250,7 +3253,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, nsCOMPtr initialDataTransfer; dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer)); - nsDragEvent *dragEvent = (nsDragEvent*)aEvent; + WidgetDragEvent *dragEvent = static_cast(aEvent); // collect any changes to moz cursor settings stored in the event's // data transfer. @@ -3345,8 +3348,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, getter_AddRefs(targetContent)); nsCOMPtr widget = mCurrentTarget->GetNearestWidget(); - nsDragEvent event(aEvent->mFlags.mIsTrusted, - NS_DRAGDROP_DRAGDROP, widget); + WidgetDragEvent event(aEvent->mFlags.mIsTrusted, + NS_DRAGDROP_DRAGDROP, widget); nsMouseEvent* mouseEvent = static_cast(aEvent); event.refPoint = mouseEvent->refPoint; @@ -3380,7 +3383,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, case NS_KEY_PRESS: if (nsEventStatus_eConsumeNoDefault != *aStatus) { - nsKeyEvent* keyEvent = (nsKeyEvent*)aEvent; + WidgetKeyboardEvent* keyEvent = static_cast(aEvent); //This is to prevent keyboard scrolling while alt modifier in use. if (!keyEvent->IsAlt()) { switch(keyEvent->keyCode) { @@ -3397,10 +3400,9 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, nsIFocusManager* fm = nsFocusManager::GetFocusManager(); if (fm && mDocument) { // Shift focus forward or back depending on shift key - bool isDocMove = ((nsInputEvent*)aEvent)->IsControl() || - (keyEvent->keyCode == NS_VK_F6); - uint32_t dir = - static_cast(aEvent)->IsShift() ? + bool isDocMove = + keyEvent->IsControl() || keyEvent->keyCode == NS_VK_F6; + uint32_t dir = keyEvent->IsShift() ? (isDocMove ? static_cast(nsIFocusManager::MOVEFOCUS_BACKWARDDOC) : static_cast(nsIFocusManager::MOVEFOCUS_BACKWARD)) : (isDocMove ? static_cast(nsIFocusManager::MOVEFOCUS_FORWARDDOC) : @@ -3448,8 +3450,8 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext, bool nsEventStateManager::RemoteQueryContentEvent(nsEvent *aEvent) { - nsQueryContentEvent *queryEvent = - static_cast(aEvent); + WidgetQueryContentEvent *queryEvent = + static_cast(aEvent); if (!IsTargetCrossProcess(queryEvent)) { return false; } @@ -4273,7 +4275,7 @@ nsEventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext, nsWeakFrame& aTargetFrame) { nsEventStatus status = nsEventStatus_eIgnore; - nsDragEvent event(aEvent->mFlags.mIsTrusted, aMsg, aEvent->widget); + WidgetDragEvent event(aEvent->mFlags.mIsTrusted, aMsg, aEvent->widget); event.refPoint = aEvent->refPoint; event.modifiers = ((nsMouseEvent*)aEvent)->modifiers; event.buttons = ((nsMouseEvent*)aEvent)->buttons; @@ -4306,7 +4308,7 @@ nsEventStateManager::FireDragEnterOrExit(nsPresContext* aPresContext, } void -nsEventStateManager::UpdateDragDataTransfer(nsDragEvent* dragEvent) +nsEventStateManager::UpdateDragDataTransfer(WidgetDragEvent* dragEvent) { NS_ASSERTION(dragEvent, "drag event is null in UpdateDragDataTransfer!"); if (!dragEvent->dataTransfer) @@ -5048,7 +5050,7 @@ nsEventStateManager::DoContentCommandScrollEvent( } void -nsEventStateManager::DoQuerySelectedText(nsQueryContentEvent* aEvent) +nsEventStateManager::DoQuerySelectedText(WidgetQueryContentEvent* aEvent) { if (RemoteQueryContentEvent(aEvent)) { return; diff --git a/content/events/src/nsEventStateManager.h b/content/events/src/nsEventStateManager.h index 9c25350325f945..f65e4db01c36b4 100644 --- a/content/events/src/nsEventStateManager.h +++ b/content/events/src/nsEventStateManager.h @@ -292,7 +292,7 @@ class nsEventStateManager : public nsSupportsWeakReference, * Update the initial drag session data transfer with any changes that occur * on cloned data transfer objects used for events. */ - void UpdateDragDataTransfer(nsDragEvent* dragEvent); + void UpdateDragDataTransfer(mozilla::WidgetDragEvent* dragEvent); nsresult SetClickCount(nsPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus); nsresult CheckForAndDispatchClick(nsPresContext* aPresContext, nsMouseEvent *aEvent, nsEventStatus* aStatus); @@ -328,7 +328,7 @@ class nsEventStateManager : public nsSupportsWeakReference, * @param aModifierMask modifier mask for the key event */ void HandleAccessKey(nsPresContext* aPresContext, - nsKeyEvent* aEvent, + mozilla::WidgetKeyboardEvent* aEvent, nsEventStatus* aStatus, nsIDocShellTreeItem* aBubbledFrom, ProcessingAccessKeyState aAccessKeyState, @@ -691,10 +691,10 @@ class nsEventStateManager : public nsSupportsWeakReference, * aSelection - the selection to be dragged */ bool DoDefaultDragStart(nsPresContext* aPresContext, - nsDragEvent* aDragEvent, - nsDOMDataTransfer* aDataTransfer, - nsIContent* aDragTarget, - nsISelection* aSelection); + mozilla::WidgetDragEvent* aDragEvent, + nsDOMDataTransfer* aDataTransfer, + nsIContent* aDragTarget, + nsISelection* aSelection); bool IsTrackingDragGesture ( ) const { return mGestureDownContent != nullptr; } /** @@ -709,7 +709,7 @@ class nsEventStateManager : public nsSupportsWeakReference, nsresult DoContentCommandScrollEvent( mozilla::WidgetContentCommandEvent* aEvent); - void DoQuerySelectedText(nsQueryContentEvent* aEvent); + void DoQuerySelectedText(mozilla::WidgetQueryContentEvent* aEvent); bool RemoteQueryContentEvent(nsEvent *aEvent); mozilla::dom::TabParent *GetCrossProcessTarget(); diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 8233bde547d145..79dca398216a58 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -599,7 +599,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, nsEventStatus status = nsEventStatus_eIgnore; if (!backup.GetLastData().IsEmpty()) { - nsTextEvent textEvent(true, NS_TEXT_TEXT, widget); + WidgetTextEvent textEvent(true, NS_TEXT_TEXT, widget); textEvent.theText = backup.GetLastData(); textEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&textEvent, status); @@ -609,7 +609,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, } status = nsEventStatus_eIgnore; - nsCompositionEvent endEvent(true, NS_COMPOSITION_END, widget); + WidgetCompositionEvent endEvent(true, NS_COMPOSITION_END, widget); endEvent.data = backup.GetLastData(); endEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&endEvent, status); @@ -622,7 +622,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, nsEventStatus status = nsEventStatus_eIgnore; if (!backup.GetLastData().IsEmpty()) { - nsCompositionEvent updateEvent(true, NS_COMPOSITION_UPDATE, widget); + WidgetCompositionEvent updateEvent(true, NS_COMPOSITION_UPDATE, widget); updateEvent.data = backup.GetLastData(); updateEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&updateEvent, status); @@ -631,7 +631,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, } status = nsEventStatus_eIgnore; - nsTextEvent textEvent(true, NS_TEXT_TEXT, widget); + WidgetTextEvent textEvent(true, NS_TEXT_TEXT, widget); textEvent.theText = backup.GetLastData(); textEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&textEvent, status); @@ -641,7 +641,7 @@ nsIMEStateManager::NotifyIME(NotificationToIME aNotification, } status = nsEventStatus_eIgnore; - nsCompositionEvent endEvent(true, NS_COMPOSITION_END, widget); + WidgetCompositionEvent endEvent(true, NS_COMPOSITION_END, widget); endEvent.data = backup.GetLastData(); endEvent.mFlags.mIsSynthesizedForTests = true; widget->DispatchEvent(&endEvent, status); diff --git a/content/events/src/nsPrivateTextRange.cpp b/content/events/src/nsPrivateTextRange.cpp index 69799ee6acb91f..76f89d56b5f643 100644 --- a/content/events/src/nsPrivateTextRange.cpp +++ b/content/events/src/nsPrivateTextRange.cpp @@ -6,7 +6,9 @@ #include "nsPrivateTextRange.h" #include "mozilla/TextEvents.h" -nsPrivateTextRange::nsPrivateTextRange(const nsTextRange &aTextRange) +using namespace mozilla; + +nsPrivateTextRange::nsPrivateTextRange(const TextRange &aTextRange) : mRangeStart(uint16_t(aTextRange.mStartOffset)), mRangeEnd(uint16_t(aTextRange.mEndOffset)), mRangeType(uint16_t(aTextRange.mRangeType)), @@ -38,7 +40,7 @@ NS_METHOD nsPrivateTextRange::GetRangeType(uint16_t* aRangeType) return NS_OK; } -NS_METHOD nsPrivateTextRange::GetRangeStyle(nsTextRangeStyle* aTextRangeStyle) +NS_METHOD nsPrivateTextRange::GetRangeStyle(TextRangeStyle* aTextRangeStyle) { NS_ENSURE_ARG_POINTER(aTextRangeStyle); *aTextRangeStyle = mRangeStyle; diff --git a/content/events/src/nsPrivateTextRange.h b/content/events/src/nsPrivateTextRange.h index 7d79db1ade195e..b38af526534536 100644 --- a/content/events/src/nsPrivateTextRange.h +++ b/content/events/src/nsPrivateTextRange.h @@ -17,20 +17,20 @@ class nsPrivateTextRange MOZ_FINAL : public nsIPrivateTextRange NS_DECL_ISUPPORTS public: - nsPrivateTextRange(const nsTextRange &aTextRange); + nsPrivateTextRange(const mozilla::TextRange &aTextRange); virtual ~nsPrivateTextRange(void); - NS_IMETHOD GetRangeStart(uint16_t* aRangeStart) MOZ_OVERRIDE; - NS_IMETHOD GetRangeEnd(uint16_t* aRangeEnd) MOZ_OVERRIDE; - NS_IMETHOD GetRangeType(uint16_t* aRangeType) MOZ_OVERRIDE; - NS_IMETHOD GetRangeStyle(nsTextRangeStyle* aRangeStyle) MOZ_OVERRIDE; + NS_IMETHOD GetRangeStart(uint16_t* aRangeStart) MOZ_OVERRIDE; + NS_IMETHOD GetRangeEnd(uint16_t* aRangeEnd) MOZ_OVERRIDE; + NS_IMETHOD GetRangeType(uint16_t* aRangeType) MOZ_OVERRIDE; + NS_IMETHOD GetRangeStyle(mozilla::TextRangeStyle* aRangeStyle) MOZ_OVERRIDE; protected: uint16_t mRangeStart; uint16_t mRangeEnd; uint16_t mRangeType; - nsTextRangeStyle mRangeStyle; + mozilla::TextRangeStyle mRangeStyle; }; class nsPrivateTextRangeList MOZ_FINAL : public nsIPrivateTextRangeList diff --git a/content/html/content/crashtests/916322-1.html b/content/html/content/crashtests/916322-1.html new file mode 100644 index 00000000000000..279a8e59f43fcb --- /dev/null +++ b/content/html/content/crashtests/916322-1.html @@ -0,0 +1,10 @@ + + diff --git a/content/html/content/crashtests/916322-2.html b/content/html/content/crashtests/916322-2.html new file mode 100644 index 00000000000000..29e39011949941 --- /dev/null +++ b/content/html/content/crashtests/916322-2.html @@ -0,0 +1,10 @@ + + diff --git a/content/html/content/crashtests/crashtests.list b/content/html/content/crashtests/crashtests.list index 89d167c1b9860c..14a739b2b1e6ef 100644 --- a/content/html/content/crashtests/crashtests.list +++ b/content/html/content/crashtests/crashtests.list @@ -53,3 +53,5 @@ load 862084.html load 865147.html load 877910.html load 903106.html +load 916322-1.html +load 916322-2.html diff --git a/content/html/content/public/HTMLCanvasElement.h b/content/html/content/public/HTMLCanvasElement.h index e1e06ba84655ed..1f8abf780f3c2a 100644 --- a/content/html/content/public/HTMLCanvasElement.h +++ b/content/html/content/public/HTMLCanvasElement.h @@ -188,6 +188,10 @@ class HTMLCanvasElement MOZ_FINAL : public nsGenericHTMLElement, virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, bool aNotify) MOZ_OVERRIDE; + + virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, + bool aNotify) MOZ_OVERRIDE; + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE; nsresult CopyInnerTo(mozilla::dom::Element* aDest); diff --git a/content/html/content/src/HTMLButtonElement.cpp b/content/html/content/src/HTMLButtonElement.cpp index 121b19fa4c469a..b9041789027b57 100644 --- a/content/html/content/src/HTMLButtonElement.cpp +++ b/content/html/content/src/HTMLButtonElement.cpp @@ -227,7 +227,8 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault && aVisitor.mEvent->IsLeftClickEvent()) { - nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE, 1); + InternalUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, + NS_UI_ACTIVATE, 1); nsCOMPtr shell = aVisitor.mPresContext->GetPresShell(); if (shell) { @@ -259,7 +260,8 @@ HTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) { // For backwards compat, trigger buttons with space or enter // (bug 25300) - nsKeyEvent * keyEvent = (nsKeyEvent *)aVisitor.mEvent; + WidgetKeyboardEvent* keyEvent = + static_cast(aVisitor.mEvent); if ((keyEvent->keyCode == NS_VK_RETURN && NS_KEY_PRESS == aVisitor.mEvent->message) || (keyEvent->keyCode == NS_VK_SPACE && diff --git a/content/html/content/src/HTMLCanvasElement.cpp b/content/html/content/src/HTMLCanvasElement.cpp index 9cd1c41c4868a3..5f9f6b989c33f4 100644 --- a/content/html/content/src/HTMLCanvasElement.cpp +++ b/content/html/content/src/HTMLCanvasElement.cpp @@ -198,6 +198,7 @@ HTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify); if (NS_SUCCEEDED(rv) && mCurrentContext && + aNameSpaceID == kNameSpaceID_None && (aName == nsGkAtoms::width || aName == nsGkAtoms::height || aName == nsGkAtoms::moz_opaque)) { rv = UpdateContext(nullptr, JS::NullHandleValue); @@ -207,6 +208,21 @@ HTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, return rv; } +nsresult +HTMLCanvasElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, + bool aNotify) +{ + nsresult rv = nsGenericHTMLElement::UnsetAttr(aNameSpaceID, aName, aNotify); + if (NS_SUCCEEDED(rv) && mCurrentContext && + aNameSpaceID == kNameSpaceID_None && + (aName == nsGkAtoms::width || aName == nsGkAtoms::height || aName == nsGkAtoms::moz_opaque)) + { + rv = UpdateContext(nullptr, JS::NullHandleValue); + NS_ENSURE_SUCCESS(rv, rv); + } + return rv; +} + void HTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType) { @@ -578,6 +594,14 @@ HTMLCanvasElement::ToBlob(JSContext* aCx, return; } +#ifdef DEBUG + if (mCurrentContext) { + nsIntSize elementSize = GetWidthHeight(); + MOZ_ASSERT(elementSize.width == mCurrentContext->GetWidth()); + MOZ_ASSERT(elementSize.height == mCurrentContext->GetHeight()); + } +#endif + bool fallbackToPNG = false; nsCOMPtr stream; diff --git a/content/html/content/src/HTMLInputElement.cpp b/content/html/content/src/HTMLInputElement.cpp index dc264a0a3af26f..95447dc765bcb1 100644 --- a/content/html/content/src/HTMLInputElement.cpp +++ b/content/html/content/src/HTMLInputElement.cpp @@ -3298,7 +3298,8 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) !IsSingleLineTextControl(true) && aVisitor.mEvent->IsLeftClickEvent() && !ShouldPreventDOMActivateDispatch(aVisitor.mEvent->originalTarget)) { - nsUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE, 1); + InternalUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted, + NS_UI_ACTIVATE, 1); nsCOMPtr shell = aVisitor.mPresContext->GetPresShell(); if (shell) { @@ -3416,7 +3417,8 @@ HTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) { // For backwards compat, trigger checks/radios/buttons with // space or enter (bug 25300) - nsKeyEvent* keyEvent = (nsKeyEvent*)aVisitor.mEvent; + WidgetKeyboardEvent* keyEvent = + static_cast(aVisitor.mEvent); if ((aVisitor.mEvent->message == NS_KEY_PRESS && keyEvent->keyCode == NS_VK_RETURN) || @@ -3694,7 +3696,8 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor if (nsIPresShell::GetCapturingContent()) { break; // don't start drag if someone else is already capturing } - nsInputEvent* inputEvent = static_cast(aVisitor.mEvent); + WidgetInputEvent* inputEvent = + static_cast(aVisitor.mEvent); if (inputEvent->IsShift() || inputEvent->IsControl() || inputEvent->IsAlt() || inputEvent->IsMeta() || inputEvent->IsAltGraph() || inputEvent->IsFn() || @@ -3730,8 +3733,9 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor CancelRangeThumbDrag(); break; } - SetValueOfRangeForUserEvent(rangeFrame->GetValueAtEventPoint( - static_cast(aVisitor.mEvent))); + SetValueOfRangeForUserEvent( + rangeFrame->GetValueAtEventPoint( + static_cast(aVisitor.mEvent))); aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true; break; @@ -3744,13 +3748,14 @@ HTMLInputElement::PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor // call CancelRangeThumbDrag() if that is the case. We just finish off // the drag and set our final value (unless someone has called // preventDefault() and prevents us getting here). - FinishRangeThumbDrag(static_cast(aVisitor.mEvent)); + FinishRangeThumbDrag(static_cast(aVisitor.mEvent)); aVisitor.mEvent->mFlags.mMultipleActionsPrevented = true; break; case NS_KEY_PRESS: if (mIsDraggingRange && - static_cast(aVisitor.mEvent)->keyCode == NS_VK_ESCAPE) { + static_cast(aVisitor.mEvent)->keyCode == + NS_VK_ESCAPE) { CancelRangeThumbDrag(); } break; diff --git a/content/html/content/src/HTMLLabelElement.cpp b/content/html/content/src/HTMLLabelElement.cpp index ea936ee5927d98..fbfe39bfd60ce3 100644 --- a/content/html/content/src/HTMLLabelElement.cpp +++ b/content/html/content/src/HTMLLabelElement.cpp @@ -197,7 +197,7 @@ HTMLLabelElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) EventFlags eventFlags; eventFlags.mMultipleActionsPrevented = true; DispatchClickEvent(aVisitor.mPresContext, - static_cast(aVisitor.mEvent), + static_cast(aVisitor.mEvent), content, false, &eventFlags, &status); // Do we care about the status this returned? I don't think we do... // Don't run another