From 6f2b52927a826fe6001805d623017e4b2a522c42 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Wed, 26 Dec 2012 23:40:15 +0530 Subject: [PATCH 001/180] Bug 824743 - Wrong stylesheet check while opening the respective editor, r=msucan --- browser/devtools/styleeditor/StyleEditorChrome.jsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/devtools/styleeditor/StyleEditorChrome.jsm b/browser/devtools/styleeditor/StyleEditorChrome.jsm index f827f7b6d0a8..c61d551943b0 100644 --- a/browser/devtools/styleeditor/StyleEditorChrome.jsm +++ b/browser/devtools/styleeditor/StyleEditorChrome.jsm @@ -400,7 +400,7 @@ StyleEditorChrome.prototype = { onEditorAdded: function SEC_selectSheet_onEditorAdded(aChrome, aEditor) { let sheet = self._styleSheetToSelect.sheet; if ((sheet && aEditor.styleSheet == sheet) || - aEditor.styleSheetIndex == 0) { + (aEditor.styleSheetIndex == 0 && sheet == null)) { aChrome.removeChromeListener(this); select(aEditor); } From 31f5fa692ed288ed702e6372d358d650b192bde6 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Wed, 26 Dec 2012 23:44:33 +0530 Subject: [PATCH 002/180] Bug 808264 - Intermittent browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js | Timed out while waiting for: source editor load, r=msucan --- browser/devtools/webconsole/test/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/devtools/webconsole/test/Makefile.in b/browser/devtools/webconsole/test/Makefile.in index 2ccc5fa453ea..f8f530c4efc0 100644 --- a/browser/devtools/webconsole/test/Makefile.in +++ b/browser/devtools/webconsole/test/Makefile.in @@ -104,7 +104,7 @@ MOCHITEST_BROWSER_FILES = \ browser_webconsole_bug_622303_persistent_filters.js \ browser_webconsole_bug_770099_bad_policyuri.js \ browser_webconsole_bug_770099_violation.js \ - $(filter disabled-temporarily--bug-808264, browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js) \ + browser_webconsole_bug_782653_CSS_links_in_Style_Editor.js \ browser_cached_messages.js \ browser_bug664688_sandbox_update_after_navigation.js \ browser_result_format_as_string.js \ From 2df4cb95cc0a4afb7c952150dfa4cdf680f88a09 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Sat, 22 Dec 2012 00:33:52 +0530 Subject: [PATCH 003/180] Bug 814641 - [toolbox] Panels appear behind the devtools window after undocking, r=paul --- browser/devtools/debugger/debugger-toolbar.js | 1 + browser/devtools/debugger/debugger.xul | 2 ++ 2 files changed, 3 insertions(+) diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index 4b42ebf34be3..ff7dc15dc70d 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -1056,6 +1056,7 @@ create({ constructor: FilteredSourcesView, proto: MenuContainer.prototype }, { let panel = this._panel = document.createElement("panel"); panel.id = "filtered-sources-panel"; panel.setAttribute("noautofocus", "true"); + panel.setAttribute("level", "top"); panel.setAttribute("position", FILTERED_SOURCES_POPUP_POSITION); document.documentElement.appendChild(panel); diff --git a/browser/devtools/debugger/debugger.xul b/browser/devtools/debugger/debugger.xul index 416df95b68ed..fd0415019380 100644 --- a/browser/devtools/debugger/debugger.xul +++ b/browser/devtools/debugger/debugger.xul @@ -238,6 +238,7 @@ @@ -267,6 +268,7 @@ From 1877527b34b66b8f7b66d09e4ed2fbc333e775d0 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Sat, 22 Dec 2012 15:17:08 +0530 Subject: [PATCH 004/180] Bug 818286 - [inspector] 'changes may be lost' dialog stays around after reload, r=dcamp --- browser/devtools/inspector/InspectorPanel.jsm | 2 -- 1 file changed, 2 deletions(-) diff --git a/browser/devtools/inspector/InspectorPanel.jsm b/browser/devtools/inspector/InspectorPanel.jsm index 706d2289b214..60a1cc92f1b3 100644 --- a/browser/devtools/inspector/InspectorPanel.jsm +++ b/browser/devtools/inspector/InspectorPanel.jsm @@ -259,9 +259,7 @@ InspectorPanel.prototype = { if (request) { request.resume(); request = null; - return true; } - return false; }.bind(this), }, { From c0c5ef85f46778dbfde82e4ebc43a312d6602502 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Sat, 22 Dec 2012 15:50:55 +0530 Subject: [PATCH 005/180] Bug 818295 - [inspector] 'changes may be lost' notification should be on the browser, not the toolbox, r=paul --- browser/devtools/inspector/InspectorPanel.jsm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/browser/devtools/inspector/InspectorPanel.jsm b/browser/devtools/inspector/InspectorPanel.jsm index 60a1cc92f1b3..711a50652e37 100644 --- a/browser/devtools/inspector/InspectorPanel.jsm +++ b/browser/devtools/inspector/InspectorPanel.jsm @@ -228,7 +228,15 @@ InspectorPanel.prototype = { request.suspend(); - let notificationBox = this._toolbox.getNotificationBox(); + let notificationBox = null; + if (this.target.isLocalTab) { + let gBrowser = this.target.tab.ownerDocument.defaultView.gBrowser; + notificationBox = gBrowser.getNotificationBox(); + } + else { + notificationBox = this._toolbox.getNotificationBox(); + } + let notification = notificationBox. getNotificationWithValue("inspector-page-navigation"); From 3b7298332cf7eb0c6e3e7371f595c4da44da3b01 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Tue, 18 Dec 2012 00:31:31 +0530 Subject: [PATCH 006/180] Bug 818428 - Don't use the word 'Toolbox' in the UI, r=dao --- browser/base/content/browser-menubar.inc | 2 +- browser/base/content/browser-sets.inc | 2 +- browser/base/content/browser.xul | 3 ++- browser/devtools/framework/gDevTools.jsm | 2 +- browser/locales/en-US/chrome/browser/browser.dtd | 7 ++++--- browser/themes/gnomestripe/browser.css | 8 ++++++++ browser/themes/pinstripe/browser.css | 8 ++++++++ browser/themes/winstripe/browser.css | 8 ++++++++ 8 files changed, 33 insertions(+), 7 deletions(-) diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc index 6254a599758c..b55a1e6ccfce 100644 --- a/browser/base/content/browser-menubar.inc +++ b/browser/base/content/browser-menubar.inc @@ -565,7 +565,7 @@ + accesskey="&devToolboxMenuItem.accesskey;"/> + observes="devtoolsMenuBroadcaster_DevToolbox" + tooltiptext="&devToolbarToolsButton.tooltip;"/> #ifndef XP_MACOSX - - + + - + + diff --git a/browser/themes/gnomestripe/browser.css b/browser/themes/gnomestripe/browser.css index 3c8c0c020e4d..6d73e781c9b4 100644 --- a/browser/themes/gnomestripe/browser.css +++ b/browser/themes/gnomestripe/browser.css @@ -2286,6 +2286,14 @@ html|*#gcli-output-frame { /* Developer Toolbar */ +#developer-toolbar-toolbox-button { + min-width: 18px; +} + +#developer-toolbar-toolbox-button > .toolbarbutton-text { + display: none; +} + .developer-toolbar-button { -moz-appearance: none; min-width: 78px; diff --git a/browser/themes/pinstripe/browser.css b/browser/themes/pinstripe/browser.css index e96ecaf5a0e1..2ba7ded10f24 100644 --- a/browser/themes/pinstripe/browser.css +++ b/browser/themes/pinstripe/browser.css @@ -3748,6 +3748,14 @@ html|*#gcli-output-frame { /* Developer Toolbar */ +#developer-toolbar-toolbox-button { + min-width: 18px; +} + +#developer-toolbar-toolbox-button > .toolbarbutton-text { + display: none; +} + .developer-toolbar-button { -moz-appearance: none; min-width: 78px; diff --git a/browser/themes/winstripe/browser.css b/browser/themes/winstripe/browser.css index 5d1d8236bf14..0c89ae1f0ac7 100644 --- a/browser/themes/winstripe/browser.css +++ b/browser/themes/winstripe/browser.css @@ -2970,6 +2970,14 @@ html|*#gcli-output-frame { /* Developer Toolbar */ +#developer-toolbar-toolbox-button { + min-width: 18px; +} + +#developer-toolbar-toolbox-button > .toolbarbutton-text { + display: none; +} + .developer-toolbar-button { -moz-appearance: none; min-width: 78px; From 9cacc6fa4000571ccaf7c900426ea5baaf9d9c35 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Wed, 2 Jan 2013 21:18:15 +0530 Subject: [PATCH 007/180] Bug 825902 - TEST-UNEXPECTED-FAIL | chrome://mochitests/content/browser/browser/devtools/inspector/test/browser_inspector_bug_566084_location_changed.js; r=paul --- .../test/browser_inspector_bug_566084_location_changed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser/devtools/inspector/test/browser_inspector_bug_566084_location_changed.js b/browser/devtools/inspector/test/browser_inspector_bug_566084_location_changed.js index 8c6a0046ca7e..309218051cc2 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_566084_location_changed.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_566084_location_changed.js @@ -25,7 +25,7 @@ function test() { let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = gDevTools.getToolbox(target); - notificationBox = toolbox.getNotificationBox(); + notificationBox = gBrowser.getNotificationBox(); notificationBox.addEventListener("AlertActive", alertActive1, false); ok(toolbox, "We have access to the notificationBox"); From 104a366b3ef0f39afcdd804b1de4265c14fb6a96 Mon Sep 17 00:00:00 2001 From: Girish Sharma Date: Wed, 19 Dec 2012 02:17:39 +0530 Subject: [PATCH 008/180] Bug 816958 - Launch buttons for Tilt and Responsive Mode should be of checkbox type. r=jwalker --- browser/devtools/framework/Toolbox.jsm | 2 +- .../devtools/responsivedesign/CmdResize.jsm | 19 ++++++++ .../responsivedesign/responsivedesign.jsm | 17 +++++-- browser/devtools/shared/DeveloperToolbar.jsm | 45 ++++++++++++------- browser/devtools/tilt/CmdTilt.jsm | 16 +++++++ browser/devtools/tilt/Tilt.jsm | 5 +++ 6 files changed, 84 insertions(+), 20 deletions(-) diff --git a/browser/devtools/framework/Toolbox.jsm b/browser/devtools/framework/Toolbox.jsm index 47b7a2d9f190..750228e63edd 100644 --- a/browser/devtools/framework/Toolbox.jsm +++ b/browser/devtools/framework/Toolbox.jsm @@ -331,7 +331,7 @@ Toolbox.prototype = { let requisition = new Requisition(environment); requisition.commandOutputManager = new CommandOutputManager(); - let buttons = CommandUtils.createButtons(toolbarSpec, this.doc, requisition); + let buttons = CommandUtils.createButtons(toolbarSpec, this._target, this.doc, requisition); let container = this.doc.getElementById("toolbox-buttons"); buttons.forEach(function(button) { diff --git a/browser/devtools/responsivedesign/CmdResize.jsm b/browser/devtools/responsivedesign/CmdResize.jsm index c6ab4c0c8124..bcb67ea46b37 100644 --- a/browser/devtools/responsivedesign/CmdResize.jsm +++ b/browser/devtools/responsivedesign/CmdResize.jsm @@ -35,6 +35,25 @@ gcli.addCommand({ tooltipText: gcli.lookup("resizeModeToggleTooltip"), description: gcli.lookup('resizeModeToggleDesc'), manual: gcli.lookup('resizeModeManual'), + state: { + isChecked: function(aTarget) { + let browserWindow = aTarget.tab.ownerDocument.defaultView; + let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; + return mgr.isActiveForTab(aTarget.tab); + }, + onChange: function(aTarget, aChangeHandler) { + let browserWindow = aTarget.tab.ownerDocument.defaultView; + let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; + mgr.on("on", aChangeHandler); + mgr.on("off", aChangeHandler); + }, + offChange: function(aTarget, aChangeHandler) { + let browserWindow = aTarget.tab.ownerDocument.defaultView; + let mgr = browserWindow.ResponsiveUI.ResponsiveUIManager; + mgr.off("on", aChangeHandler); + mgr.off("off", aChangeHandler); + }, + }, exec: gcli_cmd_resize }); diff --git a/browser/devtools/responsivedesign/responsivedesign.jsm b/browser/devtools/responsivedesign/responsivedesign.jsm index 97cc92a79821..626584e73946 100644 --- a/browser/devtools/responsivedesign/responsivedesign.jsm +++ b/browser/devtools/responsivedesign/responsivedesign.jsm @@ -35,10 +35,19 @@ this.ResponsiveUIManager = { if (aTab.__responsiveUI) { aTab.__responsiveUI.close(); } else { - aTab.__responsiveUI = new ResponsiveUI(aWindow, aTab); + new ResponsiveUI(aWindow, aTab); } }, + /** + * Returns true if responsive view is active for the provided tab. + * + * @param aTab the tab targeted. + */ + isActiveForTab: function(aTab) { + return !!aTab.__responsiveUI; + }, + /** * Handle gcli commands. * @@ -51,13 +60,13 @@ this.ResponsiveUIManager = { switch (aCommand) { case "resize to": if (!aTab.__responsiveUI) { - aTab.__responsiveUI = new ResponsiveUI(aWindow, aTab); + new ResponsiveUI(aWindow, aTab); } aTab.__responsiveUI.setSize(aArgs.width, aArgs.height); break; case "resize on": if (!aTab.__responsiveUI) { - aTab.__responsiveUI = new ResponsiveUI(aWindow, aTab); + new ResponsiveUI(aWindow, aTab); } break; case "resize off": @@ -167,6 +176,8 @@ function ResponsiveUI(aWindow, aTab) if (this._floatingScrollbars) switchToFloatingScrollbars(this.tab); + this.tab.__responsiveUI = this; + ResponsiveUIManager.emit("on", this.tab, this); } diff --git a/browser/devtools/shared/DeveloperToolbar.jsm b/browser/devtools/shared/DeveloperToolbar.jsm index efe9b8322384..311160a0608f 100644 --- a/browser/devtools/shared/DeveloperToolbar.jsm +++ b/browser/devtools/shared/DeveloperToolbar.jsm @@ -28,7 +28,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "PageErrorListener", "resource://gre/modules/devtools/WebConsoleUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "prefBranch", function() { - var prefService = Components.classes["@mozilla.org/preferences-service;1"] + let prefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefService); return prefService.getBranch(null) .QueryInterface(Components.interfaces.nsIPrefBranch2); @@ -51,12 +51,16 @@ this.CommandUtils = { /** * A toolbarSpec is an array of buttonSpecs. A buttonSpec is an array of * strings each of which is a GCLI command (including args if needed). + * + * Warning: this method uses the unload event of the window that owns the + * buttons that are of type checkbox. this means that we don't properly + * unregister event handlers until the window is destroyed. */ - createButtons: function CU_createButtons(toolbarSpec, document, requisition) { - var reply = []; + createButtons: function CU_createButtons(toolbarSpec, target, document, requisition) { + let reply = []; toolbarSpec.forEach(function(buttonSpec) { - var button = document.createElement("toolbarbutton"); + let button = document.createElement("toolbarbutton"); reply.push(button); if (typeof buttonSpec == "string") { @@ -66,7 +70,7 @@ this.CommandUtils = { requisition.update(buttonSpec.typed); // Ignore invalid commands - var command = requisition.commandAssignment.value; + let command = requisition.commandAssignment.value; if (command == null) { // TODO: Have a broken icon // button.icon = 'Broken'; @@ -101,15 +105,24 @@ this.CommandUtils = { }, false); // Allow the command button to be toggleable - /* - if (command.checkedState) { - button.setAttribute("type", "checkbox"); - button.setAttribute("checked", command.checkedState.get() ? "true" : "false"); - command.checkedState.on("change", function() { - button.checked = command.checkedState.get(); - }); + if (command.state) { + button.setAttribute("autocheck", false); + let onChange = function(event, eventTab) { + if (eventTab == target.tab) { + if (command.state.isChecked(target)) { + button.setAttribute("checked", true); + } + else if (button.hasAttribute("checked")) { + button.removeAttribute("checked"); + } + } + }; + command.state.onChange(target, onChange); + onChange(null, target.tab); + document.defaultView.addEventListener("unload", function() { + command.state.offChange(target, onChange); + }, false); } - */ } }); @@ -192,7 +205,7 @@ Object.defineProperty(DeveloperToolbar.prototype, 'visible', { enumerable: true }); -var _gSequenceId = 0; +let _gSequenceId = 0; /** * Getter for a unique ID. @@ -239,8 +252,8 @@ DeveloperToolbar.prototype.focusToggle = function DT_focusToggle() if (this.visible) { // If we have focus then the active element is the HTML input contained // inside the xul input element - var active = this._chromeWindow.document.activeElement; - var position = this._input.compareDocumentPosition(active); + let active = this._chromeWindow.document.activeElement; + let position = this._input.compareDocumentPosition(active); if (position & Node.DOCUMENT_POSITION_CONTAINED_BY) { this.hide(); } diff --git a/browser/devtools/tilt/CmdTilt.jsm b/browser/devtools/tilt/CmdTilt.jsm index 2ef83807cf74..1297e786a783 100644 --- a/browser/devtools/tilt/CmdTilt.jsm +++ b/browser/devtools/tilt/CmdTilt.jsm @@ -46,6 +46,22 @@ gcli.addCommand({ buttonClass: "command-button", tooltipText: gcli.lookup("tiltToggleTooltip"), hidden: true, + state: { + isChecked: function(aTarget) { + let browserWindow = aTarget.tab.ownerDocument.defaultView; + return !!TiltManager.getTiltForBrowser(browserWindow).currentInstance; + }, + onChange: function(aTarget, aChangeHandler) { + let browserWindow = aTarget.tab.ownerDocument.defaultView; + let tilt = TiltManager.getTiltForBrowser(browserWindow); + tilt.on("change", aChangeHandler); + }, + offChange: function(aTarget, aChangeHandler) { + let browserWindow = aTarget.tab.ownerDocument.defaultView; + let tilt = TiltManager.getTiltForBrowser(browserWindow); + tilt.off("change", aChangeHandler); + }, + }, exec: function(args, context) { let chromeWindow = context.environment.chromeDocument.defaultView; let Tilt = TiltManager.getTiltForBrowser(chromeWindow); diff --git a/browser/devtools/tilt/Tilt.jsm b/browser/devtools/tilt/Tilt.jsm index 51b828974f0b..5c97fa63e144 100644 --- a/browser/devtools/tilt/Tilt.jsm +++ b/browser/devtools/tilt/Tilt.jsm @@ -46,6 +46,7 @@ const TILT_NOTIFICATIONS = { Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/devtools/TiltGL.jsm"); Cu.import("resource:///modules/devtools/TiltUtils.jsm"); +Cu.import("resource:///modules/devtools/EventEmitter.jsm"); Cu.import("resource:///modules/devtools/TiltVisualizer.jsm"); this.EXPORTED_SYMBOLS = ["TiltManager"]; @@ -87,6 +88,8 @@ this.Tilt = function Tilt(aWindow) */ this.NOTIFICATIONS = TILT_NOTIFICATIONS; + EventEmitter.decorate(this); + this.setup(); } @@ -128,6 +131,7 @@ Tilt.prototype = { return; } + this.emit("change", this.chromeWindow.gBrowser.selectedTab); Services.obs.notifyObservers(null, TILT_NOTIFICATIONS.INITIALIZING, null); }, @@ -183,6 +187,7 @@ Tilt.prototype = { this._isDestroying = false; this.chromeWindow.gBrowser.selectedBrowser.focus(); + this.emit("change", this.chromeWindow.gBrowser.selectedTab); Services.obs.notifyObservers(null, TILT_NOTIFICATIONS.DESTROYED, null); }, From e35c6b9801736f5ab938b4024c683da4fc129c6a Mon Sep 17 00:00:00 2001 From: "adrian.tamas@softvision.ro" Date: Fri, 4 Jan 2013 10:53:22 +0200 Subject: [PATCH 009/180] Bug 826261 - Robocop: Add test for Share Link option from the Firefox Mobile Menu. r=jmaher --- mobile/android/base/tests/robocop.ini | 1 + .../android/base/tests/testShareLink.java.in | 123 ++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 mobile/android/base/tests/testShareLink.java.in diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index df2806e8abb3..acedec57da28 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -27,6 +27,7 @@ [testVkbOverlap] [testDoorHanger] [testTabHistory] +[testShareLink] # [testPermissions] # see bug 757475 # [testJarReader] # see bug 738890 diff --git a/mobile/android/base/tests/testShareLink.java.in b/mobile/android/base/tests/testShareLink.java.in new file mode 100644 index 000000000000..be03404f6e21 --- /dev/null +++ b/mobile/android/base/tests/testShareLink.java.in @@ -0,0 +1,123 @@ +#filter substitution +package @ANDROID_PACKAGE_NAME@.tests; + +import @ANDROID_PACKAGE_NAME@.*; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.widget.ListView; +import android.view.View; +import android.view.ViewGroup; +import java.util.ArrayList; +import java.util.List; +import android.widget.TextView; +import android.app.Activity; + +public class testShareLink extends BaseTest { + ListView list; + String url; + + @Override + protected int getTestType() { + return TEST_MOCHITEST; + } + + public void testShareLink() { + url = getAbsoluteUrl("/robocop/robocop_blank_01.html"); + ArrayList shareOptions; + + blockForGeckoReady(); + + loadUrl(url); + selectMenuItem("Share"); + mSolo.waitForText("Share Via"); + + // Get list of current avaliable share activities + shareOptions = getShareOptions(); + verifyOptions(shareOptions); + } + + // Create a SEND intent and get the possible activities offered + public ArrayList getShareOptions() { + ArrayList shareOptions = new ArrayList(); + Activity currentActivity = getActivity(); + final Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.putExtra(Intent.EXTRA_TEXT, url); + shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Robocop Blank 01"); + shareIntent.setType("text/plain"); + PackageManager pm = currentActivity.getPackageManager(); + List activities = pm.queryIntentActivities(shareIntent, 0); + for (ResolveInfo activity : activities) { + shareOptions.add(activity.loadLabel(pm).toString()); + } + return shareOptions; + } + + public void verifyOptions(ArrayList shareOptions) { + Device device = new Device(); + if (device.version.equals("2.x")) { + ArrayList displayedOptions = new ArrayList(); + ListView shareMenu = getDisplayedShareList(); + + /* Will have to go in the ListView, get each child, for the child separate the icon and the label + and from the label get the label text in a String Array */ + for (int i = 0; i < shareMenu.getAdapter().getCount();i++) { + View shareItem = shareMenu.getAdapter().getView(i, null, null); + ViewGroup shareItemEntry = (ViewGroup)shareItem; + for (int j = 0; j < shareItemEntry.getChildCount(); j++) { + View shareItemLabel = shareItemEntry.getChildAt(j); + if (shareItemLabel instanceof android.widget.LinearLayout) { + // The Item label is a LinearLayout of LinearLayouts + ViewGroup itemLabel = (ViewGroup)shareItemLabel; + for (int k = 0; k < itemLabel.getChildCount(); k++) { + View shareItemName = itemLabel.getChildAt(k); + if (shareItemName instanceof android.widget.TextView) { + /* The displayedOptions list array will also contain other elements that make up the + share item label but we will check the option to be present here so there is no need + at the moment to try and clean this array up further */ + displayedOptions.add(((android.widget.TextView)shareItemName).getText().toString()); + } + } + } + } + } + + for (String option:shareOptions) { + // Verify if the option is present in the list of displayed share options + mAsserter.ok(optionDisplayed(option, displayedOptions), "Share option found", option); + } + } + else { + // For Honeycomb and newer the share options list is displayed as a menu not as a list pop-up + for (String option:shareOptions) { + mAsserter.ok(mSolo.searchText(option), "Found the option in the share menu", option); + } + } + } + + private boolean optionDisplayed(String shareOption, ArrayList displayedOptions) { + for (String displayedOption: displayedOptions) { + if (shareOption.equals(displayedOption)) { + return true; + } + } + return false; + } + + private ListView getDisplayedShareList() { + final ArrayList views = mSolo.getCurrentListViews(); + + list = null; + boolean success = waitForTest(new BooleanTest() { + public boolean test() { + for (ListView view : views) { + list = view; + return true; + } + return false; + } + }, MAX_WAIT_MS); + mAsserter.ok(success,"Got the displayed share options?", "Got the share options list"); + return list; + } +} From b366d014bcb68255fef12327ae35f75a7b30c2ce Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Fri, 4 Jan 2013 14:01:44 +0000 Subject: [PATCH 010/180] bug 826288 - remove the obsolete aFamily parameter from gfxFontEntry constructor. r=roc --- gfx/thebes/gfxFont.h | 3 +-- gfx/thebes/gfxMacPlatformFontList.h | 2 +- gfx/thebes/gfxMacPlatformFontList.mm | 8 +++----- gfx/thebes/gfxUserFontSet.cpp | 5 ++--- gfx/thebes/gfxUserFontSet.h | 1 - 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 3cd26c71fa60..752175764020 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -203,8 +203,7 @@ class gfxFontEntry { public: NS_INLINE_DECL_REFCOUNTING(gfxFontEntry) - gfxFontEntry(const nsAString& aName, gfxFontFamily *aFamily = nullptr, - bool aIsStandardFace = false) : + gfxFontEntry(const nsAString& aName, bool aIsStandardFace = false) : mName(aName), mItalic(false), mFixedPitch(false), mIsProxy(false), mIsValid(true), mIsBadUnderlineFont(false), mIsUserFont(false), diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index 2e4a5b73e472..754ec2edfeee 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -27,7 +27,7 @@ public: friend class gfxMacPlatformFontList; MacOSFontEntry(const nsAString& aPostscriptName, int32_t aWeight, - gfxFontFamily *aFamily, bool aIsStandardFace = false); + bool aIsStandardFace = false); // for use with data fonts MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef, diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 75c10bfd9dcf..eaa926a913d2 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -344,9 +344,8 @@ MacOSFontEntry::IsCFF() MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, int32_t aWeight, - gfxFontFamily *aFamily, bool aIsStandardFace) - : gfxFontEntry(aPostscriptName, aFamily, aIsStandardFace), + : gfxFontEntry(aPostscriptName, aIsStandardFace), mFontRef(NULL), mFontRefInitialized(false), mRequiresAAT(false), @@ -361,7 +360,7 @@ MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName, uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle, bool aIsUserFont, bool aIsLocal) - : gfxFontEntry(aPostscriptName, nullptr, false), + : gfxFontEntry(aPostscriptName, false), mFontRef(NULL), mFontRefInitialized(false), mRequiresAAT(false), @@ -542,8 +541,7 @@ gfxMacFontFamily::FindStyleVariations() // create a font entry MacOSFontEntry *fontEntry = - new MacOSFontEntry(postscriptFontName, cssWeight, this, - isStandardFace); + new MacOSFontEntry(postscriptFontName, cssWeight, isStandardFace); if (!fontEntry) { break; } diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index 554b5f309d50..4c85fe569478 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -44,14 +44,13 @@ static uint64_t sFontSetGeneration = 0; // TODO: support for unicode ranges not yet implemented gfxProxyFontEntry::gfxProxyFontEntry(const nsTArray& aFontFaceSrcList, - gfxMixedFontFamily *aFamily, uint32_t aWeight, uint32_t aStretch, uint32_t aItalicStyle, const nsTArray& aFeatureSettings, uint32_t aLanguageOverride, gfxSparseBitSet *aUnicodeRanges) - : gfxFontEntry(NS_LITERAL_STRING("Proxy"), aFamily), + : gfxFontEntry(NS_LITERAL_STRING("Proxy")), mLoadingState(NOT_LOADING), mUnsupportedFormat(false), mLoader(nullptr) @@ -120,7 +119,7 @@ gfxUserFontSet::AddFontFace(const nsAString& aFamilyName, uint32_t languageOverride = gfxFontStyle::ParseFontLanguageOverride(aLanguageOverride); proxyEntry = - new gfxProxyFontEntry(aFontFaceSrcList, family, aWeight, aStretch, + new gfxProxyFontEntry(aFontFaceSrcList, aWeight, aStretch, aItalicStyle, aFeatureSettings, languageOverride, diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 77add7661ee6..9300280774d2 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -391,7 +391,6 @@ class gfxProxyFontEntry : public gfxFontEntry { public: gfxProxyFontEntry(const nsTArray& aFontFaceSrcList, - gfxMixedFontFamily *aFamily, uint32_t aWeight, uint32_t aStretch, uint32_t aItalicStyle, From 5bb3cb766b463ea5d993ae258e114d850596550d Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Fri, 4 Jan 2013 23:42:02 +0900 Subject: [PATCH 011/180] Bug 826611 - Disable MSVC warning C4819 because it causes useless warning spam on non-Western locales. r=ted --- configure.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 6d05f9c1e2af..277caecf117b 100644 --- a/configure.in +++ b/configure.in @@ -2204,7 +2204,10 @@ ia64*-hpux*) # because this also forces narrowing to a single byte, which can be a # perf hit. But this matters so little in practice (and often we want # that behavior) that it's better to turn it off. - CXXFLAGS="$CXXFLAGS -wd4345 -wd4351 -wd4800" + # MSVC warning C4819 warns some UTF-8 characters (e.g. copyright sign) + # on non-Western system locales even if it is in a comment. + CFLAGS="$CFLAGS -wd4819" + CXXFLAGS="$CXXFLAGS -wd4345 -wd4351 -wd4800 -wd4819" # make 'foo == bar;' error out CFLAGS="$CFLAGS -we4553" CXXFLAGS="$CXXFLAGS -we4553" From 44706c1699fd53ee5e51d6e473401c7bdf6e9104 Mon Sep 17 00:00:00 2001 From: Stephen Horlander Date: Fri, 4 Jan 2013 15:48:53 +0100 Subject: [PATCH 012/180] Bug 798336 - icons for camera and microphone access requests. r=dao --- .../gnomestripe/webRTC-shareDevice-16.png | Bin 854 -> 224 bytes .../gnomestripe/webRTC-shareDevice-64.png | Bin 4204 -> 1097 bytes .../pinstripe/webRTC-shareDevice-16.png | Bin 854 -> 224 bytes .../pinstripe/webRTC-shareDevice-16@2x.png | Bin 1563 -> 367 bytes .../pinstripe/webRTC-shareDevice-64.png | Bin 4204 -> 1097 bytes .../winstripe/webRTC-shareDevice-16.png | Bin 854 -> 233 bytes .../winstripe/webRTC-shareDevice-64.png | Bin 4204 -> 1097 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/browser/themes/gnomestripe/webRTC-shareDevice-16.png b/browser/themes/gnomestripe/webRTC-shareDevice-16.png index 0c8eafda08acf20c21eeef8ae63cc6630590084b..8bc5b3acaed5f864dd06c36ae9350dd15524df9a 100644 GIT binary patch delta 196 zcmV;#06YKI2H*jZB!8z#L_t(|+O5+u3c^qj1kh;&8yib2kLU>`ArJ@z0)g-e-o(-q zSlL^7h(yL&*dhc%KKT}}m}Qu5K{5&YzEAPLft!4V3%=fg+sjpe5P}(nD+cc#<>5D= z>pH_oXL(IB(6+5%q|Yn^P16`|1k`nHxDilQm0_g!ECXd(8a+lj$#ar{qA1KDTrqg} yAa}n3d7hgfqj16K9k`ub1jw>1N$NMI5BvaZ;$`%PBla2q0000|33b|a}HsQ zA>C)T=B_t6TpK_Lk;6WJaxvgd*GK*(a8~TED?ZrNVkvRERmow~839R#W6M83e)7KV z?p*ltsxK`8p(b-#!}U&AZS(nH+yW)Ogn~>Jk^s!bMaV)XY-Sa~;qJa){Z}t&N+M$5 z#8sxU6K(hMYkw~{dOQ)7=frTW-h!Q*t)K$MlwZcp;RuFi1mx^%InId1!6!S!#nqGp zM~VBujw^$20zm}=R6IYMh0+2W#%EO|6o%?85(0|~4)=r+kqJyDGp4)hPQ|9*KBk6x zLG_u7ac&c;ilS@=TUI89CX+bX8$d%(03(wL z>&RYtDGmu5d|{xj(+^b#beX~J(y%R;U`Yl1Aq5iSg=8Go;;JfQvTmeeh9e)M-2p`g z(KIlQl#?p|HIzG5bT{UrXq^R}gJJyeCAo+W!ktPct64DH3q^27O;$ie&TOy~@EibH z(Q&TEj(;L&7TRBiaDO<2OcUiIyl5PpmfA3?#6x~1JU4HIVK`WIkz;1qUFyK}0>i_R z1!PbLs&fHN=PQpZ8c1mIkeBM35(|GH9TkX}0vip+s&NPH1Ag3i>fwYM1jF5m0Oh^W z>9KL9C1z8n;GcMOYdPrADd?IDBhboC0^D0gn16{OxdP@hDv==OCmwY0E1;(cp}<(X)3*(i?IxNxM}1-pf$T%-h;1n*c^zZ{x+@%L3GM6_?OZ!508)M{}Q zP>w*Y+m2X5$LQxM1kr@#;&05pzug=9`lN;9qG=zKWG$@8tvJ?fE84Y36?2@_xGh>F zyg29?p9p??c2|zf4E*;st`!Jz5;4ogx0I<%0p90J*Y`(&0RX>pceXL)ZXy5x002ov JPDHLkV1k#2f~Wuh diff --git a/browser/themes/gnomestripe/webRTC-shareDevice-64.png b/browser/themes/gnomestripe/webRTC-shareDevice-64.png index a1a51b8d8f580a7c97b449aed9ae60207a6a5373..d125789fbce71eff4c4d5af890dd5ed6a862c50e 100644 GIT binary patch delta 1077 zcmV-51j_sDAjt@jBYy-CNkl2J1WX@+|)K&xHFA>p1?8qvQBHo1st`+_Vs4CZR*~tJZR&5_rBkA&pr3tLxyEp|20~G7N7-a0a}0-pap0FT7N*Uw6?b96D?rB1n}S` z?d|Qc-rnACeSLkF-|s(Acut)AtJmv&jx5&>QUDKp4*`-RBO})M__!4ch4KQ=%?!+f zOm}k>!0(*|w?L^-Kub%@6`0>19UWx=C14h0+CsKsVAv2f&+n9XcXw~}_xD>J9UYcX zKv!2+WN2uJCx2E7WMTu8k^=a*0^niesf)>xBo=@#ed4ei8yiy!X7c%biRR{J!^UpS z^Yfz^?%{!f0XENi!g{d)3^h}+=Isrb0s;K2u&u4_MIaEcH!m-sr>BR7O2TYSO-+Uk zdv^Z22v4pzXr3cxM?EgC)Cf>k0J3Egz~3)n{`xRDIDfcTz0?SxJtbkb#>Pg&1~c>L zbu_<@=0){l0eECs!^6W$f^0hkfHHi(h2~}I9Vftrt7-;=LD_n#bpW5aO2TXn4Gjh; zK=Xdy)41~4)Qbglc6M4YswBLJ>+9=}VZxhAHJ?>IdOO?#u&U!Qeud|`sQKIlV7bYI zD+!+OX@7F5mwOk$LV_o7BL<^7-fE^f4HjV_ni3Q+Iid#~S1igs`csw3% z95@p6CKSN^Grl)F67;48$ZU%8z1fkVH=zJ-DRIs1NYI;50C!fn-c}L5&2c@?pE=c| zx5F)f&+%|L9LK#(3Hu^|n+!a-ilm2d>BPjuOMl$Ye7VW09=!<#aI=BKOi7rny1JS< zZ%j{5Kf@LMiBXYFy_5i&Rg$!Tl!U9Zv$IbiVGAofnR@34ut~VExVRX^?XZDW-oFum zEhoM;DG9T=TrR@~GZ(F_tavdB5)i?Oa<6)^fV#Rm9z;o)t*WZZu#wJvDv?M$#zgm? zGk-l~WU3bnsI9G4RsgbP5BqvtLU|Sf$mRL@`4H+q z*3{JS5h@fw&ctG|Nfab$9rhR?FYw&Rz$=%WnVETtY^SpnK+c1QYin!1)zwwMi~w?R zX=y2lZKStYJbc0A^F1H%+|01Nyc|HLVm6#nfS41YP*wmr2X2E$z?~;}?lN$e%`WbO v{=dRnfEJ(yXaQP)7N7-a0a}0-kQ=`NqXz$3vl*3;00000NkvXXu0mjfnTP)@7@#Ta8uRaK_zI<;+^ z0bucXoR!OEIF18FQJ`rWB9REn~TZ0pq905rF;p6Y#wUn+Uam9|2SJX z`W5TYKc4_#xnTUC1b_!{i@ojsk3>>Ecl2h`NcDFi91VdNML6JKSOmHSSQdj_FH-_= z1Q3HjG|G?~>;p$FXk~41elCB{+{tzKRMJ~^iHm1G%l3ci834wm0z$Y%j&zi6yZ;;A zYuDa1xN!if{shE80J_Z~uL0#egJw`r2Vj%|%uAn1?T-UEjzE+G2nPa44o9#i(}%)* z;l}A>ga5f0A9y~TJ@QxP{(pK2fC+&9Zvr3+H+^nrFg1{jYOOq&9&$HPJc-gHZwUJb@HY5Q_yc{?;xm4)@=1@?g)eD$zAxkY3#R z=}M(ib^XMud<3cYh#f=$5}w@ALwmM9lHN3W)5ydSlxPU0Du--=LaQ<`FSkYBfIH;~ z1QF;8ItZhR>0@Vc?(mVr=IQ6|QV;&?tBf(TT@aS>yb1ug@QpjK6?#XW9KGg>_}cY- zut@;t7AVSP3f3qKvKnrie@u8lk{D8o33dKFj_*BO(x#sKJ#GI(&)c@Gw__4-1OP6) zZRcC$wPR0izJ5HGT$@Cp%3~(yz%p2e)<{-Ag#bhV;<61%&*SKxS5cmN`QGa8zyGG= zIMr4ltQLR^%un1f5lf`IF<0P_%R8W!x8|`r4wABkZM{W|B`l0}=>PylQNZ&&DwPTt zfY%mf?9BzSFBd{i7g{631BzrL&Wd>LH-}I>`oi7nOZR`DF{b%}uo?hJY}?LjgM;Hw zU3t@0u|ztFb9o@YNWpA>eNQSj-Zz@ZTlx&d<8j2}afHKR2!e3YQrs8iav6(-0t$r! z9-ET!=;=7BHt&xE0Yt$@oG#+%OZ!XZSAX{2>cNMfb3tGo0T2iTR!mkD1z7ioJ%M#M zKfQU|`9-H@?>=KPRmI&`EMRy|66ti>lWDd>Yii?sHjCZI7Vvj_QqXM9 z-z*3qa3(@V4##%yDXDwEalQ8X3#Z(Cf%yT@PBA3%>8)QJ9N#d}JD9>;0m$cVFpIh2 zt&VV!wxuih=wu#SH;-WLzyNqbSUw#dRQG+Vrx&+OX7Jb7%tH~Ji?f&qQNVUYRK+d~ zTrn1vHvPeud7h896Xsh1!0}uE^47%Ax<4M?xCSMSM{dEXsXg;x!ClZ`$i$8-3mDz7 z0pW0D8PjOE3O=AHN)We9X7HiSi$18~0tgnBK%yyh4{x|tnY{Od0D`S}T=pfUbQvX+ zNlEA)`r7EkFsLA7X5I!fDF|aAU?2>h^uCRY7#hkzQGzR(ZWLe(Kx8F|cVE+s4RPID z`t^cf1UiC<_YXi$Z@y3Jog4rltu_Z>6TvJz9osz?+aIJ#~-p64pjl@UJ`3&ADq7F-VgK*4aAg42eogp9m@B-EXph{i+6m+HK}OT>pnN%C}XGexH*cwh_?N4*_B0~nfv*EpFF z4ni;jDVFM&hVPhkogrz*336O4^R85X3KkQfS1CZ-DY9z!zVllE$jquL07Yb28?l-u zOQg{|w(7@;GNecXV)xi>=BdYa0az-Xy#a6w9zh7kZb~F$C~2tW`HXolpEQXG9arYH z8|}C%k7T@i1#e60|MIlaQE|!h0>oe#VmNiJ>j#Ry0GOtUXf!Gaa_ELoSi!lnD}7H9 zbjoOR@D#zpUE@Vuw?2Ztbibzt{MW&16RDHt>O~0nfC3@dHR%E%xU*O@A3!kl`|E;{ zNDQ0+)2K^&(A@4@=eTH^H7dM=d#}l3`=&4kGMT2gdg7qEJT!P2{|d)QzzY%tIRtUw zwsF@H5hJ!R~l zHagZk0)X%$csU483MRY&SfK&D5a^QR08ATTP8(H=p9DOqHdPU5jrk#$`6f~Bc-F+j z&y`lKd4%J@2_l5Z;G_!x=cfUL^2&HX6k%Eo6-+ZbW1af@+68xSEn++qyQuaaw>*(G z@fY7ckBUK8t$7>>I9>!Hgs<}f%>f{8o@rY(`)61!!>s9)w+(67G8ky8_KX2jSrhku zFAG&?-uEQ!J7bRHK{$?crBD3x09U1I{d=~;@wbv}t5jVP7;fKWATzwVX|eR=feIdc zI=`Ix)oR{FGa+pOz!(E4ZOB2}lPsD<%le5Ey#@yQQ{Z^Pv*`KRfeJqVSgtK6+7>dD zf;twcW3^Wf6RUj0G)zd8) z0hBVgQOf)PV78$a^r{Yp(Un1hwa28NpvDHm7o^{4-QRw;09B{$-?t6TV~!1K8nBC} zUTF&es?JPn>!|9TcdSzL7#OH!!q!z#t5WjX zLgQ9wz}Y9xRLjK@ajaTt$vPlhB=2kx2*|Zw0d0u+ubk1KYL0KOv3XChS(!}XSO#pZ z0&Diy$K1{k^#g!fmStMi;!BoR1sL_MyZuU1FM#?Z_VTsXT~g5_~;ZcOckqckw52 zByr=_BiK4%`FE1qP=9KhFiHzhbJMDJ`tg4Ukaz8$cDgxg0VrzOS3X2Ixs5*sJXMKp4aQ&wr0}l#n%jw@D82?14N5*y#qaD;&GA`U1=aiv)Y&7y(NF#O zQ2_G*RQQ}JY_)%G0VtGD{P1siIl560R?`JatpI~ z{zUWRE)~teGy4{sq}&Z#U-f2485~oCR+vL+_PAO;{^L(j{rr?G{gwx&+Bqm`1E?71 z{(Dyu&JKb*9s)yHiT8jP11rxJ`IyD`pE-|^%;8-(EZ2kVqKVIZZyKuZbkqQ0s4-tH zoJVPP3YF78f6&V9-3?&Y_560rxYh0*sP!C4N1K7H?OnqLlczQ;t&Hm897=OjYU$V`pRyKS zei6XgI_59wF}X$%5`1XwhUnM_zaHsXKN9LnLkh)fCgC1>?tE*sjs7NOa4a2$x(GEt zgL3xxnaYX(_>5gTaR9&!fLtr)-zWe}AOrx!0rZ78{pp{FddEKyPOO0(>4qqW!3iP= zS>@9>9-Slx25MU{wKDWl4wd{lsI&Wis2=~$!>+y0x*q@X9hLQ1ri9wTgQVCsJ`u{i z^KXJ(gI6l?UIapMh=EWI2##MFGTYD)#uylLKrIuNp~6rLs1~xQE}T44ef^nlS_}L4 zxuGuS7CV>su(VGUQCw|E%KdNOE~l<~uN)t|UWp_i1!E8bAqbLO+nwQffRGD-u*MD^ zV_?()bu2iR0n1Qfss(7}1?YvdN3^-!KQObqcDr^y?@HaX&i`!zuw)XFyZsykkPu>H z8|Bp2?NV&`)<8HlEGbclatORAgBK(ao?m7n%&p%Y%Y<#|uniSPwFFbm&zq&Qd$ieS zf9jN{P6AkTbNhmu;jQX{iAxQ@(%@Yn6aZltjHnRXI4s4-uIA-j!GnWg1dLV>4FoG^A zZUm9)c4@h~=;pYpY`CPk%vRmk1};89_J+pg2B6-f@pXWRE(tEx13+DJ-1@_EnO!>I zcu60d`)vWx2u3pk{5$@ad^82%%{c!5;psO!0RIEVdZI>;B6AG@0000`ArJ@z0)g-e-o(-q zSlL^7h(yL&*dhc%KKT}}m}Qu5K{5&YzEAPLft!4V3%=fg+sjpe5P}(nD+cc#<>5D= z>pH_oXL(IB(6+5%q|Yn^P16`|1k`nHxDilQm0_g!ECXd(8a+lj$#ar{qA1KDTrqg} yAa}n3d7hgfqj16K9k`ub1jw>1N$NMI5BvaZ;$`%PBla2q0000|33b|a}HsQ zA>C)T=B_t6TpK_Lk;6WJaxvgd*GK*(a8~TED?ZrNVkvRERmow~839R#W6M83e)7KV z?p*ltsxK`8p(b-#!}U&AZS(nH+yW)Ogn~>Jk^s!bMaV)XY-Sa~;qJa){Z}t&N+M$5 z#8sxU6K(hMYkw~{dOQ)7=frTW-h!Q*t)K$MlwZcp;RuFi1mx^%InId1!6!S!#nqGp zM~VBujw^$20zm}=R6IYMh0+2W#%EO|6o%?85(0|~4)=r+kqJyDGp4)hPQ|9*KBk6x zLG_u7ac&c;ilS@=TUI89CX+bX8$d%(03(wL z>&RYtDGmu5d|{xj(+^b#beX~J(y%R;U`Yl1Aq5iSg=8Go;;JfQvTmeeh9e)M-2p`g z(KIlQl#?p|HIzG5bT{UrXq^R}gJJyeCAo+W!ktPct64DH3q^27O;$ie&TOy~@EibH z(Q&TEj(;L&7TRBiaDO<2OcUiIyl5PpmfA3?#6x~1JU4HIVK`WIkz;1qUFyK}0>i_R z1!PbLs&fHN=PQpZ8c1mIkeBM35(|GH9TkX}0vip+s&NPH1Ag3i>fwYM1jF5m0Oh^W z>9KL9C1z8n;GcMOYdPrADd?IDBhboC0^D0gn16{OxdP@hDv==OCmwY0E1;(cp}<(X)3*(i?IxNxM}1-pf$T%-h;1n*c^zZ{x+@%L3GM6_?OZ!508)M{}Q zP>w*Y+m2X5$LQxM1kr@#;&05pzug=9`lN;9qG=zKWG$@8tvJ?fE84Y36?2@_xGh>F zyg29?p9p??c2|zf4E*;st`!Jz5;4ogx0I<%0p90J*Y`(&0RX>pceXL)ZXy5x002ov JPDHLkV1k#2f~Wuh diff --git a/browser/themes/pinstripe/webRTC-shareDevice-16@2x.png b/browser/themes/pinstripe/webRTC-shareDevice-16@2x.png index d13fb930a397810c8884b9882bbd5f6cb8ef8fcd..72d53e6d99366fab0c2b65044554b8c74e97e9a8 100644 GIT binary patch delta 341 zcmV-b0jmC+4DSMvBYy!lNkll6x;gK7s7%tHwfnPHR?)#Us2H;PP0b{`b3257P zLf5n)tY|?uH2Lj8ZtJuy0-C0o5tLl^Jbia-D1Ui1ckTOo^k8-wP*oK) z@w0Cq(A?T(Kv|a1WZgZYkIpUwrqd}jnVTo{)w9chq9~y3Y{@1A@;t|YWI&c>7?2D| z(-Z@e0ZEczKr$eXV+=?JL{WqR$$&5nq3m?YCIf;XfF^VEm_B=U8Q}XqG+B2K>7}#F z0MGNFiJyIYpH3dFT?V+W`%F;sWCxi0yL4}M8Q?h11wqMqH^98HMYkja%y>m}!iwH$ nMw=qQ!hK`>S3Cxc0YAP0GKwkS^a!u$00000NkvXXu0mjfC3l-Q delta 1547 zcmV+m2K4#w0-FqwBYy?rNklPs)yyE#rWLiZ z^@p-7yYiNoO~|T9l%$gKve=F-c9qs?y)7NfvFliQjYX-{)~KeLrluE_h)ACOPIH+v z%~W3h@IB{qy7zXw&-1&t&YeE`P)CQwV(GEjY<&e9J;ky2nty08D%iN6SMmb0dB-z{ zhx{YvM`mN>rW+U;eFNMz7ceaF^zDJu(|565+z&Q` z|5Fn<+Zw^ys()^T5`C`;yq!&O-q(P!iG?uxCjBIfJJ95)>NLC2Ggp(E#Tp8HO#+%+kq9!GtV3B@Ia2;AhEK8#oGnaIq9{G;$7)#mpMQ|BtbNR1DcsOCZqmqzYw$?B zN1?UgZdQpoQV5Aeg0{9cJbwVpT#sg` zf2P>T$1s=_PggFNq5O}B&c~wu*O5v?-z+)11qLL}D!ilNE zkU7Wi_Zl*JaF;j0%Kt=#dkTd|S80${$?=p~>5-gA;BBgY$tgjO+JE) ztK-r6=Ch82;!HID?g#m%o}9Q-3i}9&N~8pK-EiDgfsC{HkW+Y5D>_J<+Tp&vs>|}0 zi+{7g;w<$B|;_R?|f7@w4m`Z(7*^iT;FYZ>t)wrFk;Tk z&c6rx!{;8oGB%dN!pqgI(?*QY)IyY3H+F>HdjyCZ+7WW7uE+AWD{i7Mcdnme(P{;3 zzRkGo6kP^~wWXbuX$mjH>1+||DY#Cd1%L2Mu6m{N)&W;xU^{De=R2Th?wx#UY?KHN zYwoIqX;X?XqD3f{)}fYyYseqB9x`QnEXMuPz}XtsEFW z2}LNCH$(mqs3r-g?lGmiFKQKYm=-GudpID9T2H%eqUms5^ei3Jc)Dbi(O`;`SSo1F4Mub-`; zyBAV_Gmkx$4$E>NSb0Z_!VaN(3x6PPY=g8J9WpLfs!D4q&!>HBzcaM@McXOEkaRh^ zeQoDVv-CX-!SXx^R}?4(sf+xrR2k05Dt-(>5K~eM?xHIgFfKZmu5ZDtzT06L*)LsV zHRA*Xfw>Sa&m;M2eB(qYs(JRZK=6Jk70qW9yd)sJ#n~{OuwAalwirj(?tevIY1l@* zCE>$-=uUip6T-mT5H3^a5>f!aZKd#xD5Cv5rR6FDI)^hq3#P6KrM(AD{95q=o4nSr z**3G6n!E35=FL41VZbenT$-yAs122)ulyy~VKwa-j7NoCW>!w&Z#KR4jco1v3s+}; z=D81?@6Ld~FdIU;D;R07*qoL2J1WX@+|)K&xHFA>p1?8qvQBHo1st`+_Vs4CZR*~tJZR&5_rBkA&pr3tLxyEp|20~G7N7-a0a}0-pap0FT7N*Uw6?b96D?rB1n}S` z?d|Qc-rnACeSLkF-|s(Acut)AtJmv&jx5&>QUDKp4*`-RBO})M__!4ch4KQ=%?!+f zOm}k>!0(*|w?L^-Kub%@6`0>19UWx=C14h0+CsKsVAv2f&+n9XcXw~}_xD>J9UYcX zKv!2+WN2uJCx2E7WMTu8k^=a*0^niesf)>xBo=@#ed4ei8yiy!X7c%biRR{J!^UpS z^Yfz^?%{!f0XENi!g{d)3^h}+=Isrb0s;K2u&u4_MIaEcH!m-sr>BR7O2TYSO-+Uk zdv^Z22v4pzXr3cxM?EgC)Cf>k0J3Egz~3)n{`xRDIDfcTz0?SxJtbkb#>Pg&1~c>L zbu_<@=0){l0eECs!^6W$f^0hkfHHi(h2~}I9Vftrt7-;=LD_n#bpW5aO2TXn4Gjh; zK=Xdy)41~4)Qbglc6M4YswBLJ>+9=}VZxhAHJ?>IdOO?#u&U!Qeud|`sQKIlV7bYI zD+!+OX@7F5mwOk$LV_o7BL<^7-fE^f4HjV_ni3Q+Iid#~S1igs`csw3% z95@p6CKSN^Grl)F67;48$ZU%8z1fkVH=zJ-DRIs1NYI;50C!fn-c}L5&2c@?pE=c| zx5F)f&+%|L9LK#(3Hu^|n+!a-ilm2d>BPjuOMl$Ye7VW09=!<#aI=BKOi7rny1JS< zZ%j{5Kf@LMiBXYFy_5i&Rg$!Tl!U9Zv$IbiVGAofnR@34ut~VExVRX^?XZDW-oFum zEhoM;DG9T=TrR@~GZ(F_tavdB5)i?Oa<6)^fV#Rm9z;o)t*WZZu#wJvDv?M$#zgm? zGk-l~WU3bnsI9G4RsgbP5BqvtLU|Sf$mRL@`4H+q z*3{JS5h@fw&ctG|Nfab$9rhR?FYw&Rz$=%WnVETtY^SpnK+c1QYin!1)zwwMi~w?R zX=y2lZKStYJbc0A^F1H%+|01Nyc|HLVm6#nfS41YP*wmr2X2E$z?~;}?lN$e%`WbO v{=dRnfEJ(yXaQP)7N7-a0a}0-kQ=`NqXz$3vl*3;00000NkvXXu0mjfnTP)@7@#Ta8uRaK_zI<;+^ z0bucXoR!OEIF18FQJ`rWB9REn~TZ0pq905rF;p6Y#wUn+Uam9|2SJX z`W5TYKc4_#xnTUC1b_!{i@ojsk3>>Ecl2h`NcDFi91VdNML6JKSOmHSSQdj_FH-_= z1Q3HjG|G?~>;p$FXk~41elCB{+{tzKRMJ~^iHm1G%l3ci834wm0z$Y%j&zi6yZ;;A zYuDa1xN!if{shE80J_Z~uL0#egJw`r2Vj%|%uAn1?T-UEjzE+G2nPa44o9#i(}%)* z;l}A>ga5f0A9y~TJ@QxP{(pK2fC+&9Zvr3+H+^nrFg1{jYOOq&9&$HPJc-gHZwUJb@HY5Q_yc{?;xm4)@=1@?g)eD$zAxkY3#R z=}M(ib^XMud<3cYh#f=$5}w@ALwmM9lHN3W)5ydSlxPU0Du--=LaQ<`FSkYBfIH;~ z1QF;8ItZhR>0@Vc?(mVr=IQ6|QV;&?tBf(TT@aS>yb1ug@QpjK6?#XW9KGg>_}cY- zut@;t7AVSP3f3qKvKnrie@u8lk{D8o33dKFj_*BO(x#sKJ#GI(&)c@Gw__4-1OP6) zZRcC$wPR0izJ5HGT$@Cp%3~(yz%p2e)<{-Ag#bhV;<61%&*SKxS5cmN`QGa8zyGG= zIMr4ltQLR^%un1f5lf`IF<0P_%R8W!x8|`r4wABkZM{W|B`l0}=>PylQNZ&&DwPTt zfY%mf?9BzSFBd{i7g{631BzrL&Wd>LH-}I>`oi7nOZR`DF{b%}uo?hJY}?LjgM;Hw zU3t@0u|ztFb9o@YNWpA>eNQSj-Zz@ZTlx&d<8j2}afHKR2!e3YQrs8iav6(-0t$r! z9-ET!=;=7BHt&xE0Yt$@oG#+%OZ!XZSAX{2>cNMfb3tGo0T2iTR!mkD1z7ioJ%M#M zKfQU|`9-H@?>=KPRmI&`EMRy|66ti>lWDd>Yii?sHjCZI7Vvj_QqXM9 z-z*3qa3(@V4##%yDXDwEalQ8X3#Z(Cf%yT@PBA3%>8)QJ9N#d}JD9>;0m$cVFpIh2 zt&VV!wxuih=wu#SH;-WLzyNqbSUw#dRQG+Vrx&+OX7Jb7%tH~Ji?f&qQNVUYRK+d~ zTrn1vHvPeud7h896Xsh1!0}uE^47%Ax<4M?xCSMSM{dEXsXg;x!ClZ`$i$8-3mDz7 z0pW0D8PjOE3O=AHN)We9X7HiSi$18~0tgnBK%yyh4{x|tnY{Od0D`S}T=pfUbQvX+ zNlEA)`r7EkFsLA7X5I!fDF|aAU?2>h^uCRY7#hkzQGzR(ZWLe(Kx8F|cVE+s4RPID z`t^cf1UiC<_YXi$Z@y3Jog4rltu_Z>6TvJz9osz?+aIJ#~-p64pjl@UJ`3&ADq7F-VgK*4aAg42eogp9m@B-EXph{i+6m+HK}OT>pnN%C}XGexH*cwh_?N4*_B0~nfv*EpFF z4ni;jDVFM&hVPhkogrz*336O4^R85X3KkQfS1CZ-DY9z!zVllE$jquL07Yb28?l-u zOQg{|w(7@;GNecXV)xi>=BdYa0az-Xy#a6w9zh7kZb~F$C~2tW`HXolpEQXG9arYH z8|}C%k7T@i1#e60|MIlaQE|!h0>oe#VmNiJ>j#Ry0GOtUXf!Gaa_ELoSi!lnD}7H9 zbjoOR@D#zpUE@Vuw?2Ztbibzt{MW&16RDHt>O~0nfC3@dHR%E%xU*O@A3!kl`|E;{ zNDQ0+)2K^&(A@4@=eTH^H7dM=d#}l3`=&4kGMT2gdg7qEJT!P2{|d)QzzY%tIRtUw zwsF@H5hJ!R~l zHagZk0)X%$csU483MRY&SfK&D5a^QR08ATTP8(H=p9DOqHdPU5jrk#$`6f~Bc-F+j z&y`lKd4%J@2_l5Z;G_!x=cfUL^2&HX6k%Eo6-+ZbW1af@+68xSEn++qyQuaaw>*(G z@fY7ckBUK8t$7>>I9>!Hgs<}f%>f{8o@rY(`)61!!>s9)w+(67G8ky8_KX2jSrhku zFAG&?-uEQ!J7bRHK{$?crBD3x09U1I{d=~;@wbv}t5jVP7;fKWATzwVX|eR=feIdc zI=`Ix)oR{FGa+pOz!(E4ZOB2}lPsD<%le5Ey#@yQQ{Z^Pv*`KRfeJqVSgtK6+7>dD zf;twcW3^Wf6RUj0G)zd8) z0hBVgQOf)PV78$a^r{Yp(Un1hwa28NpvDHm7o^{4-QRw;09B{$-?t6TV~!1K8nBC} zUTF&es?JPn>!|9TcdSzL7#OH!!q!z#t5WjX zLgQ9wz}Y9xRLjK@ajaTt$vPlhB=2kx2*|Zw0d0u+ubk1KYL0KOv3XChS(!}XSO#pZ z0&Diy$K1{k^#g!fmStMi;!BoR1sL_MyZuU1FM#?Z_VTsXT~g5_~;ZcOckqckw52 zByr=_BiK4%`FE1qP=9KhFiHzhbJMDJ`tg4Ukaz8$cDgxg0VrzOS3X2Ixs5*sJXMKp4aQ&wr0}l#n%jw@D82?14N5*y#qaD;&GA`U1=aiv)Y&7y(NF#O zQ2_G*RQQ}JY_)%G0VtGD{P1siIl560R?`JatpI~ z{zUWRE)~teGy4{sq}&Z#U-f2485~oCR+vL+_PAO;{^L(j{rr?G{gwx&+Bqm`1E?71 z{(Dyu&JKb*9s)yHiT8jP11rxJ`IyD`pE-|^%;8-(EZ2kVqKVIZZyKuZbkqQ0s4-tH zoJVPP3YF78f6&V9-3?&Y_560rxYh0*sP!C4N1K7H?OnqLlczQ;t&Hm897=OjYU$V`pRyKS zei6XgI_59wF}X$%5`1XwhUnM_zaHsXKN9LnLkh)fCgC1>?tE*sjs7NOa4a2$x(GEt zgL3xxnaYX(_>5gTaR9&!fLtr)-zWe}AOrx!0rZ78{pp{FddEKyPOO0(>4qqW!3iP= zS>@9>9-Slx25MU{wKDWl4wd{lsI&Wis2=~$!>+y0x*q@X9hLQ1ri9wTgQVCsJ`u{i z^KXJ(gI6l?UIapMh=EWI2##MFGTYD)#uylLKrIuNp~6rLs1~xQE}T44ef^nlS_}L4 zxuGuS7CV>su(VGUQCw|E%KdNOE~l<~uN)t|UWp_i1!E8bAqbLO+nwQffRGD-u*MD^ zV_?()bu2iR0n1Qfss(7}1?YvdN3^-!KQObqcDr^y?@HaX&i`!zuw)XFyZsykkPu>H z8|Bp2?NV&`)<8HlEGbclatORAgBK(ao?m7n%&p%Y%Y<#|uniSPwFFbm&zq&Qd$ieS zf9jN{P6AkTbNhmu;jQX{iAxQ@(%@Yn6aZltjHnRXI4s4-uIA-j!GnWg1dLV>4FoG^A zZUm9)c4@h~=;pYpY`CPk%vRmk1};89_J+pg2B6-f@pXWRE(tEx13+DJ-1@_EnO!>I zcu60d`)vWx2u3pk{5$@ad^82%%{c!5;psO!0RIEVdZI>;B6AG@0000e?rPBBT2*g7y3Y7x*G1x{SQ(S6_xoZp4iF>g|Y00000NkvXX Hu0mjf+U{7` delta 831 zcmV-F1Hk<00oDePB!3xnMObuGZ)S9NVRB^vL1b@YWgtmyVP|DhWnpA_ami&o0008` zNkl|33b|a}HsQ zA>C)T=B_t6TpK_Lk;6WJaxvgd*GK*(a8~TED?ZrNVkvRERmow~839R#W6M83e)7KV z?p*ltsxK`8p(b-#!}U&AZS(nH+yW)Ogn~>Jk^s!bMaV)XY-Sa~;qJa){Z}t&N+M$5 z#8sxU6K(hMYkw~{dOQ)7=frTW-h!Q*t)K$MlwZcp;RuFi1mx^%InId1!6!S!#nqGp zM~VBujw^$20zm}=R6IYMh0+2W#%EO|6o%?85(0|~4)=r+kqJyDGp4)hPQ|9*KBk6x zLG_u7ac&c;ilS@=TUI89CX+bX8$d%(03(wL z>&RYtDGmu5d|{xj(+^b#beX~J(y%R;U`Yl1Aq5iSg=8Go;;JfQvTmeeh9e)M-2p`g z(KIlQl#?p|HIzG5bT{UrXq^R}gJJyeCAo+W!ktPct64DH3q^27O;$ie&TOy~@EibH z(Q&TEj(;L&7TRBiaDO<2OcUiIyl5PpmfA3?#6x~1JU4HIVK`WIkz;1qUFyK}0>i_R z1!PbLs&fHN=PQpZ8c1mIkeBM35(|GH9TkX}0vip+s&NPH1Ag3i>fwYM1jF5m0Oh^W z>9KL9C1z8n;GcMOYdPrADd?IDBhboC0^D0gn16{OxdP@hDv==OCmwY0E1;(cp}<(X)3*(i?IxNxM}1-pf$T%-h;1n*c^zZ{x+@%L3GM6_?OZ!508)M{}Q zP>w*Y+m2X5$LQxM1kr@#;&05pzug=9`lN;9qG=zKWG$@8tvJ?fE84Y36?2@_xGh>F zyg29?p9p??c2|zf4E*;st`!Jz5;4ogx0I<%0p90J*Y`(&0RX>pceXL)ZXy5x002ov JPDHLkV1l&1g0TPq diff --git a/browser/themes/winstripe/webRTC-shareDevice-64.png b/browser/themes/winstripe/webRTC-shareDevice-64.png index a1a51b8d8f580a7c97b449aed9ae60207a6a5373..d125789fbce71eff4c4d5af890dd5ed6a862c50e 100644 GIT binary patch delta 1077 zcmV-51j_sDAjt@jBYy-CNkl2J1WX@+|)K&xHFA>p1?8qvQBHo1st`+_Vs4CZR*~tJZR&5_rBkA&pr3tLxyEp|20~G7N7-a0a}0-pap0FT7N*Uw6?b96D?rB1n}S` z?d|Qc-rnACeSLkF-|s(Acut)AtJmv&jx5&>QUDKp4*`-RBO})M__!4ch4KQ=%?!+f zOm}k>!0(*|w?L^-Kub%@6`0>19UWx=C14h0+CsKsVAv2f&+n9XcXw~}_xD>J9UYcX zKv!2+WN2uJCx2E7WMTu8k^=a*0^niesf)>xBo=@#ed4ei8yiy!X7c%biRR{J!^UpS z^Yfz^?%{!f0XENi!g{d)3^h}+=Isrb0s;K2u&u4_MIaEcH!m-sr>BR7O2TYSO-+Uk zdv^Z22v4pzXr3cxM?EgC)Cf>k0J3Egz~3)n{`xRDIDfcTz0?SxJtbkb#>Pg&1~c>L zbu_<@=0){l0eECs!^6W$f^0hkfHHi(h2~}I9Vftrt7-;=LD_n#bpW5aO2TXn4Gjh; zK=Xdy)41~4)Qbglc6M4YswBLJ>+9=}VZxhAHJ?>IdOO?#u&U!Qeud|`sQKIlV7bYI zD+!+OX@7F5mwOk$LV_o7BL<^7-fE^f4HjV_ni3Q+Iid#~S1igs`csw3% z95@p6CKSN^Grl)F67;48$ZU%8z1fkVH=zJ-DRIs1NYI;50C!fn-c}L5&2c@?pE=c| zx5F)f&+%|L9LK#(3Hu^|n+!a-ilm2d>BPjuOMl$Ye7VW09=!<#aI=BKOi7rny1JS< zZ%j{5Kf@LMiBXYFy_5i&Rg$!Tl!U9Zv$IbiVGAofnR@34ut~VExVRX^?XZDW-oFum zEhoM;DG9T=TrR@~GZ(F_tavdB5)i?Oa<6)^fV#Rm9z;o)t*WZZu#wJvDv?M$#zgm? zGk-l~WU3bnsI9G4RsgbP5BqvtLU|Sf$mRL@`4H+q z*3{JS5h@fw&ctG|Nfab$9rhR?FYw&Rz$=%WnVETtY^SpnK+c1QYin!1)zwwMi~w?R zX=y2lZKStYJbc0A^F1H%+|01Nyc|HLVm6#nfS41YP*wmr2X2E$z?~;}?lN$e%`WbO v{=dRnfEJ(yXaQP)7N7-a0a}0-kQ=`NqXz$3vl*3;00000NkvXXu0mjfnTP)@7@#Ta8uRaK_zI<;+^ z0bucXoR!OEIF18FQJ`rWB9REn~TZ0pq905rF;p6Y#wUn+Uam9|2SJX z`W5TYKc4_#xnTUC1b_!{i@ojsk3>>Ecl2h`NcDFi91VdNML6JKSOmHSSQdj_FH-_= z1Q3HjG|G?~>;p$FXk~41elCB{+{tzKRMJ~^iHm1G%l3ci834wm0z$Y%j&zi6yZ;;A zYuDa1xN!if{shE80J_Z~uL0#egJw`r2Vj%|%uAn1?T-UEjzE+G2nPa44o9#i(}%)* z;l}A>ga5f0A9y~TJ@QxP{(pK2fC+&9Zvr3+H+^nrFg1{jYOOq&9&$HPJc-gHZwUJb@HY5Q_yc{?;xm4)@=1@?g)eD$zAxkY3#R z=}M(ib^XMud<3cYh#f=$5}w@ALwmM9lHN3W)5ydSlxPU0Du--=LaQ<`FSkYBfIH;~ z1QF;8ItZhR>0@Vc?(mVr=IQ6|QV;&?tBf(TT@aS>yb1ug@QpjK6?#XW9KGg>_}cY- zut@;t7AVSP3f3qKvKnrie@u8lk{D8o33dKFj_*BO(x#sKJ#GI(&)c@Gw__4-1OP6) zZRcC$wPR0izJ5HGT$@Cp%3~(yz%p2e)<{-Ag#bhV;<61%&*SKxS5cmN`QGa8zyGG= zIMr4ltQLR^%un1f5lf`IF<0P_%R8W!x8|`r4wABkZM{W|B`l0}=>PylQNZ&&DwPTt zfY%mf?9BzSFBd{i7g{631BzrL&Wd>LH-}I>`oi7nOZR`DF{b%}uo?hJY}?LjgM;Hw zU3t@0u|ztFb9o@YNWpA>eNQSj-Zz@ZTlx&d<8j2}afHKR2!e3YQrs8iav6(-0t$r! z9-ET!=;=7BHt&xE0Yt$@oG#+%OZ!XZSAX{2>cNMfb3tGo0T2iTR!mkD1z7ioJ%M#M zKfQU|`9-H@?>=KPRmI&`EMRy|66ti>lWDd>Yii?sHjCZI7Vvj_QqXM9 z-z*3qa3(@V4##%yDXDwEalQ8X3#Z(Cf%yT@PBA3%>8)QJ9N#d}JD9>;0m$cVFpIh2 zt&VV!wxuih=wu#SH;-WLzyNqbSUw#dRQG+Vrx&+OX7Jb7%tH~Ji?f&qQNVUYRK+d~ zTrn1vHvPeud7h896Xsh1!0}uE^47%Ax<4M?xCSMSM{dEXsXg;x!ClZ`$i$8-3mDz7 z0pW0D8PjOE3O=AHN)We9X7HiSi$18~0tgnBK%yyh4{x|tnY{Od0D`S}T=pfUbQvX+ zNlEA)`r7EkFsLA7X5I!fDF|aAU?2>h^uCRY7#hkzQGzR(ZWLe(Kx8F|cVE+s4RPID z`t^cf1UiC<_YXi$Z@y3Jog4rltu_Z>6TvJz9osz?+aIJ#~-p64pjl@UJ`3&ADq7F-VgK*4aAg42eogp9m@B-EXph{i+6m+HK}OT>pnN%C}XGexH*cwh_?N4*_B0~nfv*EpFF z4ni;jDVFM&hVPhkogrz*336O4^R85X3KkQfS1CZ-DY9z!zVllE$jquL07Yb28?l-u zOQg{|w(7@;GNecXV)xi>=BdYa0az-Xy#a6w9zh7kZb~F$C~2tW`HXolpEQXG9arYH z8|}C%k7T@i1#e60|MIlaQE|!h0>oe#VmNiJ>j#Ry0GOtUXf!Gaa_ELoSi!lnD}7H9 zbjoOR@D#zpUE@Vuw?2Ztbibzt{MW&16RDHt>O~0nfC3@dHR%E%xU*O@A3!kl`|E;{ zNDQ0+)2K^&(A@4@=eTH^H7dM=d#}l3`=&4kGMT2gdg7qEJT!P2{|d)QzzY%tIRtUw zwsF@H5hJ!R~l zHagZk0)X%$csU483MRY&SfK&D5a^QR08ATTP8(H=p9DOqHdPU5jrk#$`6f~Bc-F+j z&y`lKd4%J@2_l5Z;G_!x=cfUL^2&HX6k%Eo6-+ZbW1af@+68xSEn++qyQuaaw>*(G z@fY7ckBUK8t$7>>I9>!Hgs<}f%>f{8o@rY(`)61!!>s9)w+(67G8ky8_KX2jSrhku zFAG&?-uEQ!J7bRHK{$?crBD3x09U1I{d=~;@wbv}t5jVP7;fKWATzwVX|eR=feIdc zI=`Ix)oR{FGa+pOz!(E4ZOB2}lPsD<%le5Ey#@yQQ{Z^Pv*`KRfeJqVSgtK6+7>dD zf;twcW3^Wf6RUj0G)zd8) z0hBVgQOf)PV78$a^r{Yp(Un1hwa28NpvDHm7o^{4-QRw;09B{$-?t6TV~!1K8nBC} zUTF&es?JPn>!|9TcdSzL7#OH!!q!z#t5WjX zLgQ9wz}Y9xRLjK@ajaTt$vPlhB=2kx2*|Zw0d0u+ubk1KYL0KOv3XChS(!}XSO#pZ z0&Diy$K1{k^#g!fmStMi;!BoR1sL_MyZuU1FM#?Z_VTsXT~g5_~;ZcOckqckw52 zByr=_BiK4%`FE1qP=9KhFiHzhbJMDJ`tg4Ukaz8$cDgxg0VrzOS3X2Ixs5*sJXMKp4aQ&wr0}l#n%jw@D82?14N5*y#qaD;&GA`U1=aiv)Y&7y(NF#O zQ2_G*RQQ}JY_)%G0VtGD{P1siIl560R?`JatpI~ z{zUWRE)~teGy4{sq}&Z#U-f2485~oCR+vL+_PAO;{^L(j{rr?G{gwx&+Bqm`1E?71 z{(Dyu&JKb*9s)yHiT8jP11rxJ`IyD`pE-|^%;8-(EZ2kVqKVIZZyKuZbkqQ0s4-tH zoJVPP3YF78f6&V9-3?&Y_560rxYh0*sP!C4N1K7H?OnqLlczQ;t&Hm897=OjYU$V`pRyKS zei6XgI_59wF}X$%5`1XwhUnM_zaHsXKN9LnLkh)fCgC1>?tE*sjs7NOa4a2$x(GEt zgL3xxnaYX(_>5gTaR9&!fLtr)-zWe}AOrx!0rZ78{pp{FddEKyPOO0(>4qqW!3iP= zS>@9>9-Slx25MU{wKDWl4wd{lsI&Wis2=~$!>+y0x*q@X9hLQ1ri9wTgQVCsJ`u{i z^KXJ(gI6l?UIapMh=EWI2##MFGTYD)#uylLKrIuNp~6rLs1~xQE}T44ef^nlS_}L4 zxuGuS7CV>su(VGUQCw|E%KdNOE~l<~uN)t|UWp_i1!E8bAqbLO+nwQffRGD-u*MD^ zV_?()bu2iR0n1Qfss(7}1?YvdN3^-!KQObqcDr^y?@HaX&i`!zuw)XFyZsykkPu>H z8|Bp2?NV&`)<8HlEGbclatORAgBK(ao?m7n%&p%Y%Y<#|uniSPwFFbm&zq&Qd$ieS zf9jN{P6AkTbNhmu;jQX{iAxQ@(%@Yn6aZltjHnRXI4s4-uIA-j!GnWg1dLV>4FoG^A zZUm9)c4@h~=;pYpY`CPk%vRmk1};89_J+pg2B6-f@pXWRE(tEx13+DJ-1@_EnO!>I zcu60d`)vWx2u3pk{5$@ad^82%%{c!5;psO!0RIEVdZI>;B6AG@0000 Date: Fri, 4 Jan 2013 07:53:20 -0700 Subject: [PATCH 013/180] Bug 825447 - Populate safepoints directly in backtracking register allocator, r=jandem. --- js/src/ion/BacktrackingAllocator.cpp | 77 +++++++++++++++++++++++++++- js/src/ion/BacktrackingAllocator.h | 1 + js/src/ion/Ion.cpp | 8 ++- js/src/ion/LinearScan.cpp | 51 +----------------- js/src/ion/LinearScan.h | 2 - js/src/ion/LiveRangeAllocator.h | 42 +++++++++++++++ js/src/ion/RegisterAllocator.h | 11 ++++ 7 files changed, 137 insertions(+), 55 deletions(-) diff --git a/js/src/ion/BacktrackingAllocator.cpp b/js/src/ion/BacktrackingAllocator.cpp index 70ecb72503d5..6fa5c2279b56 100644 --- a/js/src/ion/BacktrackingAllocator.cpp +++ b/js/src/ion/BacktrackingAllocator.cpp @@ -140,7 +140,7 @@ BacktrackingAllocator::go() if (IonSpewEnabled(IonSpew_RegAlloc)) dumpAllocations(); - return resolveControlFlow() && reifyAllocations(); + return resolveControlFlow() && reifyAllocations() && populateSafepoints(); } static bool @@ -1021,6 +1021,8 @@ BacktrackingAllocator::reifyAllocations() } } } + + addLiveRegistersForInterval(reg, interval); } } @@ -1028,6 +1030,79 @@ BacktrackingAllocator::reifyAllocations() return true; } +bool +BacktrackingAllocator::populateSafepoints() +{ + size_t firstSafepoint = 0; + + for (uint32_t i = 0; i < vregs.numVirtualRegisters(); i++) { + BacktrackingVirtualRegister *reg = &vregs[i]; + + if (!reg->def() || (!IsTraceable(reg) && !IsNunbox(reg))) + continue; + + firstSafepoint = findFirstSafepoint(reg->getInterval(0), firstSafepoint); + if (firstSafepoint >= graph.numSafepoints()) + break; + + // Find the furthest endpoint. + CodePosition end = reg->getInterval(0)->end(); + for (size_t j = 1; j < reg->numIntervals(); j++) + end = Max(end, reg->getInterval(j)->end()); + + for (size_t j = firstSafepoint; j < graph.numSafepoints(); j++) { + LInstruction *ins = graph.getSafepoint(j); + + // Stop processing safepoints if we know we're out of this virtual + // register's range. + if (end < inputOf(ins)) + break; + + // Include temps but not instruction outputs. Also make sure MUST_REUSE_INPUT + // is not used with gcthings or nunboxes, or we would have to add the input reg + // to this safepoint. + if (ins == reg->ins() && !reg->isTemp()) { + DebugOnly def = reg->def(); + JS_ASSERT_IF(def->policy() == LDefinition::MUST_REUSE_INPUT, + def->type() == LDefinition::GENERAL || def->type() == LDefinition::DOUBLE); + continue; + } + + LSafepoint *safepoint = ins->safepoint(); + + LiveInterval *interval = reg->intervalFor(inputOf(ins)); + if (!interval) + continue; + + LAllocation *a = interval->getAllocation(); + if (a->isGeneralReg() && ins->isCall()) + continue; + + switch (reg->type()) { + case LDefinition::OBJECT: + safepoint->addGcPointer(*a); + break; +#ifdef JS_NUNBOX32 + case LDefinition::TYPE: + safepoint->addNunboxType(i, *a); + break; + case LDefinition::PAYLOAD: + safepoint->addNunboxPayload(i, *a); + break; +#else + case LDefinition::BOX: + safepoint->addBoxedValue(*a); + break; +#endif + default: + JS_NOT_REACHED("Bad register type"); + } + } + } + + return true; +} + void BacktrackingAllocator::dumpRegisterGroups() { diff --git a/js/src/ion/BacktrackingAllocator.h b/js/src/ion/BacktrackingAllocator.h index 82205daf7621..ebbbe95ee52f 100644 --- a/js/src/ion/BacktrackingAllocator.h +++ b/js/src/ion/BacktrackingAllocator.h @@ -201,6 +201,7 @@ class BacktrackingAllocator : public LiveRangeAllocatorgetAllocation(); - if (a->isRegister()) { - // Don't add output registers to the safepoint. - CodePosition start = interval->start(); - if (interval->index() == 0 && !reg->isTemp()) - start = start.next(); - - size_t i = findFirstNonCallSafepoint(start); - for (; i < graph.numNonCallSafepoints(); i++) { - LInstruction *ins = graph.getNonCallSafepoint(i); - CodePosition pos = inputOf(ins); - - // Safepoints are sorted, so we can shortcut out of this loop - // if we go out of range. - if (interval->end() < pos) - break; - - if (!interval->covers(pos)) - continue; - - LSafepoint *safepoint = ins->safepoint(); - safepoint->addLiveRegister(a->toRegister()); - } - } + addLiveRegistersForInterval(reg, interval); }} // Iteration over virtual register intervals. // Set the graph overall stack height @@ -455,31 +431,6 @@ LinearScanAllocator::reifyAllocations() return true; } -// Finds the first safepoint that is within range of an interval. -size_t -LinearScanAllocator::findFirstSafepoint(LiveInterval *interval, size_t startFrom) -{ - size_t i = startFrom; - for (; i < graph.numSafepoints(); i++) { - LInstruction *ins = graph.getSafepoint(i); - if (interval->start() <= inputOf(ins)) - break; - } - return i; -} - -size_t -LinearScanAllocator::findFirstNonCallSafepoint(CodePosition from) -{ - size_t i = 0; - for (; i < graph.numNonCallSafepoints(); i++) { - LInstruction *ins = graph.getNonCallSafepoint(i); - if (from <= inputOf(ins)) - break; - } - return i; -} - inline bool LinearScanAllocator::isSpilledAt(LiveInterval *interval, CodePosition pos) { diff --git a/js/src/ion/LinearScan.h b/js/src/ion/LinearScan.h index 8ec46814c3c1..3cf8d80740e3 100644 --- a/js/src/ion/LinearScan.h +++ b/js/src/ion/LinearScan.h @@ -110,8 +110,6 @@ class LinearScanAllocator : public LiveRangeAllocator bool canCoexist(LiveInterval *a, LiveInterval *b); bool moveInputAlloc(CodePosition pos, LAllocation *from, LAllocation *to); void setIntervalRequirement(LiveInterval *interval); - size_t findFirstSafepoint(LiveInterval *interval, size_t firstSafepoint); - size_t findFirstNonCallSafepoint(CodePosition from); bool isSpilledAt(LiveInterval *interval, CodePosition pos); #ifdef DEBUG diff --git a/js/src/ion/LiveRangeAllocator.h b/js/src/ion/LiveRangeAllocator.h index c277746ccd37..d48aece848d9 100644 --- a/js/src/ion/LiveRangeAllocator.h +++ b/js/src/ion/LiveRangeAllocator.h @@ -603,6 +603,48 @@ class LiveRangeAllocator : public RegisterAllocator LMoveGroup *moves = getMoveGroupAfter(pos); return addMove(moves, from, to); } + + void addLiveRegistersForInterval(VirtualRegister *reg, LiveInterval *interval) + { + // Fill in the live register sets for all non-call safepoints. + LAllocation *a = interval->getAllocation(); + if (!a->isRegister()) + return; + + // Don't add output registers to the safepoint. + CodePosition start = interval->start(); + if (interval->index() == 0 && !reg->isTemp()) + start = start.next(); + + size_t i = findFirstNonCallSafepoint(start); + for (; i < graph.numNonCallSafepoints(); i++) { + LInstruction *ins = graph.getNonCallSafepoint(i); + CodePosition pos = inputOf(ins); + + // Safepoints are sorted, so we can shortcut out of this loop + // if we go out of range. + if (interval->end() < pos) + break; + + if (!interval->covers(pos)) + continue; + + LSafepoint *safepoint = ins->safepoint(); + safepoint->addLiveRegister(a->toRegister()); + } + } + + // Finds the first safepoint that is within range of an interval. + size_t findFirstSafepoint(LiveInterval *interval, size_t startFrom) + { + size_t i = startFrom; + for (; i < graph.numSafepoints(); i++) { + LInstruction *ins = graph.getSafepoint(i); + if (interval->start() <= inputOf(ins)) + break; + } + return i; + } }; } // namespace ion diff --git a/js/src/ion/RegisterAllocator.h b/js/src/ion/RegisterAllocator.h index c7ca1c2254b2..ad9cecf946df 100644 --- a/js/src/ion/RegisterAllocator.h +++ b/js/src/ion/RegisterAllocator.h @@ -336,6 +336,17 @@ class RegisterAllocator LMoveGroup *getMoveGroupAfter(CodePosition pos) { return getMoveGroupAfter(pos.ins()); } + + size_t findFirstNonCallSafepoint(CodePosition from) + { + size_t i = 0; + for (; i < graph.numNonCallSafepoints(); i++) { + LInstruction *ins = graph.getNonCallSafepoint(i); + if (from <= inputOf(ins)) + break; + } + return i; + } }; } // namespace ion From 87d872a38f7070099a69be2c01146d5e351f4eff Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 3 Jan 2013 16:21:44 -0500 Subject: [PATCH 014/180] Bug 826439 - use floats instead of doubles for exponential histogram statistic calculations; r=vdjeric --- ipc/chromium/src/base/histogram.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index 90da947926fd..3123f0f8fb25 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -746,7 +746,7 @@ void Histogram::SampleSet::AccumulateWithExponentialStats(Sample value, size_t index) { Accumulate(value, count, index); DCHECK_GE(value, 0); - double value_log = log(static_cast(value) + 1); + float value_log = logf(static_cast(value) + 1.0f); log_sum_ += count * value_log; log_sum_squares_ += count * value_log * value_log; } From 1aa13912cbacad82dcd1f42bcd523ba6053391c5 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Fri, 4 Jan 2013 09:50:43 -0500 Subject: [PATCH 015/180] Bug 559432 - Don't fail the assert if the cached actor is null... that probably just means we're in the process of tearing down the instance, r=josh --HG-- extra : rebase_source : c7add3dc063f52127818fcdfc9b76e45ed45bf1a --- dom/plugins/ipc/PluginInstanceChild.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 18aa8128f684..38f7e961fed6 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -264,9 +264,9 @@ PluginInstanceChild::InternalGetNPObjectForValue(NPNVariable aValue, // Make sure that the current actor returned by the parent matches our // cached actor! - NS_ASSERTION(static_cast(currentActor) == + NS_ASSERTION(!currentActor || + static_cast(currentActor) == actor, "Cached actor is out of date!"); - NS_ASSERTION(currentResult == result, "Results don't match?!"); } #endif From b78d8ead5bb04a5e3e7f62790a9aeee6318b9693 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 4 Jan 2013 15:56:20 +0100 Subject: [PATCH 016/180] Bug 824330 - Build services/ during the platform tier and enable services in xulrunner. r=blassey,r=bsmedberg,r=gps --- b2g/build.mk | 2 -- browser/build.mk | 2 -- mobile/android/confvars.sh | 3 --- mobile/xul/build.mk | 4 ---- services/crypto/Makefile.in | 2 ++ toolkit/toolkit-tiers.mk | 2 +- xulrunner/confvars.sh | 6 ++++++ 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/b2g/build.mk b/b2g/build.mk index f4213b064349..87fdb931143d 100644 --- a/b2g/build.mk +++ b/b2g/build.mk @@ -18,8 +18,6 @@ ifdef MOZ_EXTENSIONS tier_app_dirs += extensions endif -tier_app_dirs += services - tier_app_dirs += \ $(MOZ_BRANDING_DIRECTORY) \ b2g \ diff --git a/browser/build.mk b/browser/build.mk index 1b572035bc72..037515a4699f 100644 --- a/browser/build.mk +++ b/browser/build.mk @@ -14,8 +14,6 @@ endif tier_app_dirs += $(MOZ_BRANDING_DIRECTORY) -tier_app_dirs += services - ifdef MOZ_WEBAPP_RUNTIME tier_app_dirs += webapprt endif diff --git a/mobile/android/confvars.sh b/mobile/android/confvars.sh index 32274c916374..1f4cba4afd81 100755 --- a/mobile/android/confvars.sh +++ b/mobile/android/confvars.sh @@ -19,9 +19,6 @@ MOZ_DISABLE_DOMCRYPTO=1 # Enable getUserMedia MOZ_MEDIA_NAVIGATOR=1 -MOZ_SERVICES_COMMON=1 -MOZ_SERVICES_METRICS=1 - if test "$LIBXUL_SDK"; then MOZ_XULRUNNER=1 else diff --git a/mobile/xul/build.mk b/mobile/xul/build.mk index a5523222d8ee..41884e52bcfa 100644 --- a/mobile/xul/build.mk +++ b/mobile/xul/build.mk @@ -21,10 +21,6 @@ ifdef MOZ_EXTENSIONS tier_app_dirs += extensions endif -ifdef MOZ_SERVICES_SYNC -tier_app_dirs += services -endif - tier_app_dirs += \ $(MOZ_BRANDING_DIRECTORY) \ mobile/xul \ diff --git a/services/crypto/Makefile.in b/services/crypto/Makefile.in index 9e96c7ab0a13..d26506ee309a 100644 --- a/services/crypto/Makefile.in +++ b/services/crypto/Makefile.in @@ -22,4 +22,6 @@ INSTALL_TARGETS += CRYPTO_MODULE TEST_DIRS += tests +DIRS += component + include $(topsrcdir)/config/rules.mk diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index a9c8fadea564..69401f435d47 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -260,7 +260,7 @@ ifdef MOZ_PREF_EXTENSIONS tier_platform_dirs += extensions/pref endif -tier_platform_dirs += services/crypto/component +tier_platform_dirs += services tier_platform_dirs += startupcache diff --git a/xulrunner/confvars.sh b/xulrunner/confvars.sh index 5fe2c3d207c2..04b37d5e3603 100755 --- a/xulrunner/confvars.sh +++ b/xulrunner/confvars.sh @@ -12,3 +12,9 @@ MOZ_APP_VERSION=$MOZILLA_VERSION MOZ_PLACES=1 MOZ_EXTENSIONS_DEFAULT=" gio" MOZ_URL_CLASSIFIER=1 +MOZ_SERVICES_AITC=1 +MOZ_SERVICES_COMMON=1 +MOZ_SERVICES_CRYPTO=1 +MOZ_SERVICES_METRICS=1 +MOZ_SERVICES_NOTIFICATIONS=1 +MOZ_SERVICES_SYNC=1 From 845c486ed9187393d790c52830606934757308a1 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Fri, 4 Jan 2013 16:00:21 +0100 Subject: [PATCH 017/180] Bug 823645 - [B2G][Keyboard] Keyboard does not show for advanced HTML editors r=vingtetun a=blocking-basecamp --- b2g/chrome/content/forms.js | 76 +++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 24 deletions(-) diff --git a/b2g/chrome/content/forms.js b/b2g/chrome/content/forms.js index eef79a9d3e9b..650f27d1a2c2 100644 --- a/b2g/chrome/content/forms.js +++ b/b2g/chrome/content/forms.js @@ -25,6 +25,10 @@ XPCOMUtils.defineLazyGetter(this, "domWindowUtils", function () { const RESIZE_SCROLL_DELAY = 20; +let HTMLDocument = Ci.nsIDOMHTMLDocument; +let HTMLHtmlElement = Ci.nsIDOMHTMLHtmlElement; +let HTMLBodyElement = Ci.nsIDOMHTMLBodyElement; +let HTMLIFrameElement = Ci.nsIDOMHTMLIFrameElement; let HTMLInputElement = Ci.nsIDOMHTMLInputElement; let HTMLTextAreaElement = Ci.nsIDOMHTMLTextAreaElement; let HTMLSelectElement = Ci.nsIDOMHTMLSelectElement; @@ -89,8 +93,10 @@ let FormAssistant = { switch (evt.type) { case "focus": - if (this.isTextInputElement(target) && this.isIMEDisabled()) - return; + if (target && isContentEditable(target)) { + this.showKeyboard(this.getTopLevelEditable(target)); + break; + } if (target && this.isFocusableElement(target)) this.showKeyboard(target); @@ -193,22 +199,9 @@ let FormAssistant = { }, observe: function fa_observe(subject, topic, data) { - switch (topic) { - case "xpcom-shutdown": - Services.obs.removeObserver(this, "xpcom-shutdown"); - removeMessageListener("Forms:Select:Choice", this); - removeMessageListener("Forms:Input:Value", this); - break; - } - }, - - isIMEDisabled: function fa_isIMEDisabled() { - let disabled = false; - try { - disabled = domWindowUtils.IMEStatus == domWindowUtils.IME_STATUS_DISABLED; - } catch (e) {} - - return disabled; + Services.obs.removeObserver(this, "xpcom-shutdown"); + removeMessageListener("Forms:Select:Choice", this); + removeMessageListener("Forms:Input:Value", this); }, showKeyboard: function fa_showKeyboard(target) { @@ -232,10 +225,6 @@ let FormAssistant = { }, isFocusableElement: function fa_isFocusableElement(element) { - if (element.contentEditable && element.contentEditable == "true") { - return true; - } - if (element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) return true; @@ -251,7 +240,31 @@ let FormAssistant = { isTextInputElement: function fa_isTextInputElement(element) { return element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || - (element.contentEditable && element.contentEditable == "true"); + isContentEditable(element); + }, + + getTopLevelEditable: function fa_getTopLevelEditable(element) { + function retrieveTopLevelEditable(element) { + // Retrieve the top element that is editable + if (element instanceof HTMLHtmlElement) + element = element.ownerDocument.body; + else if (element instanceof HTMLDocument) + element = element.body; + + while (element && !isContentEditable(element)) + element = element.parentNode; + + // Return the container frame if we are into a nested editable frame + if (element && + element instanceof HTMLBodyElement && + element.ownerDocument.defaultView != content.document.defaultView) + return element.ownerDocument.defaultView.frameElement; + } + + if (element instanceof HTMLIFrameElement) + return element; + + return retrieveTopLevelEditable(element) || element; }, sendKeyboardState: function(element) { @@ -270,12 +283,27 @@ let FormAssistant = { FormAssistant.init(); +function isContentEditable(element) { + if (element.isContentEditable || element.designMode == "on") + return true; + + // If a body element is editable and the body is the child of an + // iframe we can assume this is an advanced HTML editor + if (element instanceof HTMLIFrameElement && + element.contentDocument && + (element.contentDocument.body.isContentEditable || + element.contentDocument.designMode == "on")) + return true; + + return element.ownerDocument && element.ownerDocument.designMode == "on"; +} + function getJSON(element) { let type = element.type || ""; let value = element.value || "" // Treat contenteditble element as a special text field - if (element.contentEditable && element.contentEditable == "true") { + if (isContentEditable(element)) { type = "text"; value = element.textContent; } From f267e8833e831fce7b8c286356910439c515682f Mon Sep 17 00:00:00 2001 From: James Lal Date: Fri, 4 Jan 2013 16:00:21 +0100 Subject: [PATCH 018/180] Bug 819598 - When opening keyboard, don't scrollIntoView() input elements that are already in view r=djf a=blocking-basecamp --- b2g/chrome/content/forms.js | 145 +++++++++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 1 deletion(-) diff --git a/b2g/chrome/content/forms.js b/b2g/chrome/content/forms.js index 650f27d1a2c2..ec6cb3092d16 100644 --- a/b2g/chrome/content/forms.js +++ b/b2g/chrome/content/forms.js @@ -35,6 +35,149 @@ let HTMLSelectElement = Ci.nsIDOMHTMLSelectElement; let HTMLOptGroupElement = Ci.nsIDOMHTMLOptGroupElement; let HTMLOptionElement = Ci.nsIDOMHTMLOptionElement; +let FormVisibility = { + /** + * Searches upwards in the DOM for an element that has been scrolled. + * + * @param {HTMLElement} node element to start search at. + * @return {Window|HTMLElement|Null} null when none are found window/element otherwise. + */ + findScrolled: function fv_findScrolled(node) { + let win = node.ownerDocument.defaultView; + + while (!(node instanceof HTMLBodyElement)) { + + // We can skip elements that have not been scrolled. + // We only care about top now remember to add the scrollLeft + // check if we decide to care about the X axis. + if (node.scrollTop !== 0) { + // the element has been scrolled so we may need to adjust + // where we think the root element is located. + // + // Otherwise it may seem visible but be scrolled out of the viewport + // inside this scrollable node. + return node; + } else { + // this node does not effect where we think + // the node is even if it is scrollable it has not hidden + // the element we are looking for. + node = node.parentNode; + continue; + } + } + + // we also care about the window this is the more + // common case where the content is larger then + // the viewport/screen. + if (win.scrollMaxX || win.scrollMaxY) { + return win; + } + + return null; + }, + + /** + * Checks if "top and "bottom" points of the position is visible. + * + * @param {Number} top position. + * @param {Number} height of the element. + * @param {Number} maxHeight of the window. + * @return {Boolean} true when visible. + */ + yAxisVisible: function fv_yAxisVisible(top, height, maxHeight) { + return (top > 0 && (top + height) < maxHeight); + }, + + /** + * Searches up through the dom for scrollable elements + * which are not currently visible (relative to the viewport). + * + * @param {HTMLElement} element to start search at. + * @param {Object} pos .top, .height and .width of element. + */ + scrollablesVisible: function fv_scrollablesVisible(element, pos) { + while ((element = this.findScrolled(element))) { + if (element.window && element.self === element) + break; + + // remember getBoundingClientRect does not care + // about scrolling only where the element starts + // in the document. + let offset = element.getBoundingClientRect(); + + // the top of both the scrollable area and + // the form element itself are in the same document. + // We adjust the "top" so if the elements coordinates + // are relative to the viewport in the current document. + let adjustedTop = pos.top - offset.top; + + let visible = this.yAxisVisible( + adjustedTop, + pos.height, + pos.width + ); + + if (!visible) + return false; + + element = element.parentNode; + } + + return true; + }, + + /** + * Verifies the element is visible in the viewport. + * Handles scrollable areas, frames and scrollable viewport(s) (windows). + * + * @param {HTMLElement} element to verify. + * @return {Boolean} true when visible. + */ + isVisible: function fv_isVisible(element) { + // scrollable frames can be ignored we just care about iframes... + let rect = element.getBoundingClientRect(); + let parent = element.ownerDocument.defaultView; + + // used to calculate the inner position of frames / scrollables. + // The intent was to use this information to scroll either up or down. + // scrollIntoView(true) will _break_ some web content so we can't do + // this today. If we want that functionality we need to manually scroll + // the individual elements. + let pos = { + top: rect.top, + height: rect.height, + width: rect.width + }; + + let visible = true; + + do { + let frame = parent.frameElement; + visible = visible && + this.yAxisVisible(pos.top, pos.height, parent.innerHeight) && + this.scrollablesVisible(element, pos); + + // nothing we can do about this now... + // In the future we can use this information to scroll + // only the elements we need to at this point as we should + // have all the details we need to figure out how to scroll. + if (!visible) + return false; + + if (frame) { + let frameRect = frame.getBoundingClientRect(); + + pos.top += frameRect.top + frame.clientTop; + } + } while ( + (parent !== parent.parent) && + (parent = parent.parent) + ); + + return visible; + } +}; + let FormAssistant = { init: function fa_init() { addEventListener("focus", this, true, false); @@ -139,7 +282,7 @@ let FormAssistant = { if (this.focusedElement) { this.scrollIntoViewTimeout = content.setTimeout(function () { this.scrollIntoViewTimeout = null; - if (this.focusedElement) { + if (this.focusedElement && !FormVisibility.isVisible(this.focusedElement)) { this.focusedElement.scrollIntoView(false); } }.bind(this), RESIZE_SCROLL_DELAY); From 47cf762c149bb214cf0f1dede3f94020bcbfc1c2 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2013 10:12:11 -0500 Subject: [PATCH 019/180] Bug 826411 - Remove obsolete comment about compiler-specific workaround. r=mats --- layout/generic/nsGfxScrollFrame.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index cf864c12ffae..541abd69edc9 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2164,11 +2164,6 @@ static void HandleScrollPref(nsIScrollable *aScrollable, int32_t aOrientation, nsGfxScrollFrameInner::ScrollbarStyles nsGfxScrollFrameInner::GetScrollbarStylesFromFrame() const { - // XXX EVIL COMPILER BUG BE CAREFUL WHEN CHANGING THIS METHOD - // There's bugs in the Android compiler :( - // It was first worked around in bug 642205, then it failed - // on armv6 (bug 790624) *in a different way*. - nsPresContext* presContext = mOuter->PresContext(); if (!presContext->IsDynamic() && !(mIsRoot && presContext->HasPaginatedScrolling())) { From 9eb5cdb511864ccb251d6a543f405338633434a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Fri, 4 Jan 2013 10:27:41 -0500 Subject: [PATCH 020/180] Bug 826029 - Assertion in mozPoisonWriteMac due to Mac camera code trying to write a defaults file on exit | Assertion failure: ok, at ../../../xpcom/build/mozPoisonWriteMac.cpp:90. r=ehsan. --- browser/app/nsBrowserApp.cpp | 16 ++++++++++++++++ toolkit/xre/nsAppRunner.cpp | 5 +++++ xpcom/build/nsXULAppAPI.h | 2 ++ 3 files changed, 23 insertions(+) diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp index 17649dafea9a..7ac9bf1f55f9 100644 --- a/browser/app/nsBrowserApp.cpp +++ b/browser/app/nsBrowserApp.cpp @@ -111,6 +111,7 @@ XRE_SetupDllBlocklistType XRE_SetupDllBlocklist; XRE_TelemetryAccumulateType XRE_TelemetryAccumulate; XRE_StartupTimelineRecordType XRE_StartupTimelineRecord; XRE_mainType XRE_main; +XRE_DisableWritePoisoningType XRE_DisableWritePoisoning; static const nsDynamicFunctionLoad kXULFuncs[] = { { "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath }, @@ -122,6 +123,7 @@ static const nsDynamicFunctionLoad kXULFuncs[] = { { "XRE_TelemetryAccumulate", (NSFuncPtr*) &XRE_TelemetryAccumulate }, { "XRE_StartupTimelineRecord", (NSFuncPtr*) &XRE_StartupTimelineRecord }, { "XRE_main", (NSFuncPtr*) &XRE_main }, + { "XRE_DisableWritePoisoning", (NSFuncPtr*) &XRE_DisableWritePoisoning }, { nullptr, nullptr } }; @@ -387,5 +389,19 @@ int main(int argc, char* argv[]) } XPCOMGlueShutdown(); + + +#ifdef XP_MACOSX + // Allow writes again. While we would like to catch writes from static + // destructors to allow early exits to use _exit, we know that there is + // at least one such write that we don't control (see bug 826029). For + // now we enable writes again and early exits will have to use exit instead + // of _exit. + + // Currently write poisoning is only available on OS X. Since on OS X we never + // unload XUL, it is safe to call this function after XPCOMGlueShutdown. + XRE_DisableWritePoisoning(); +#endif + return result; } diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 0eded02be323..7665de214497 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4080,6 +4080,11 @@ XRE_mainMetro(int argc, char* argv[], const nsXREAppData* aAppData) void SetWindowsEnvironment(WindowsEnvironmentType aEnvID); #endif // MOZ_METRO || !defined(XP_WIN) +void +XRE_DisableWritePoisoning(void) { + mozilla::DisableWritePoisoning(); +} + int XRE_main(int argc, char* argv[], const nsXREAppData* aAppData, uint32_t aFlags) { diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 92738f34dabf..c8d338ba7dce 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -452,6 +452,8 @@ XRE_API(void, XRE_API(void, XRE_InitOmnijar, (nsIFile* greOmni, nsIFile* appOmni)) +XRE_API(void, + XRE_DisableWritePoisoning, (void)) #ifdef XP_WIN /** From 100ae41c83dec4eed474a446c46dc67db0824f18 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 4 Jan 2013 00:16:14 -0500 Subject: [PATCH 021/180] Bug 826602 - Rename nsHTMLCanvasElement to mozilla::dom::HTMLCanvasElement; r=bzbarsky --HG-- rename : content/html/content/public/nsHTMLCanvasElement.h => content/html/content/public/HTMLCanvasElement.h rename : content/html/content/src/nsHTMLCanvasElement.cpp => content/html/content/src/HTMLCanvasElement.cpp --- .../canvas/public/nsICanvasElementExternal.h | 2 +- .../nsICanvasRenderingContextInternal.h | 8 +- content/canvas/src/CanvasImageCache.cpp | 12 +- content/canvas/src/CanvasImageCache.h | 6 +- .../canvas/src/CanvasRenderingContext2D.cpp | 8 +- content/canvas/src/CanvasRenderingContext2D.h | 4 +- content/canvas/src/CanvasUtils.cpp | 4 +- content/canvas/src/CanvasUtils.h | 7 +- content/canvas/src/WebGLContext.cpp | 6 +- content/canvas/src/WebGLContext.h | 4 +- ...TMLCanvasElement.h => HTMLCanvasElement.h} | 42 ++-- content/html/content/public/Makefile.in | 7 +- ...anvasElement.cpp => HTMLCanvasElement.cpp} | 236 +++++++++--------- content/html/content/src/Makefile.in | 2 +- dom/bindings/Bindings.conf | 2 +- js/xpconnect/src/nsDOMQS.h | 4 +- layout/base/nsLayoutUtils.cpp | 10 +- layout/base/nsLayoutUtils.h | 4 +- layout/generic/nsHTMLCanvasFrame.cpp | 15 +- layout/generic/nsSimplePageSequence.cpp | 21 +- layout/generic/nsSimplePageSequence.h | 4 +- layout/printing/nsPrintEngine.h | 2 +- 22 files changed, 213 insertions(+), 197 deletions(-) rename content/html/content/public/{nsHTMLCanvasElement.h => HTMLCanvasElement.h} (85%) rename content/html/content/src/{nsHTMLCanvasElement.cpp => HTMLCanvasElement.cpp} (79%) diff --git a/content/canvas/public/nsICanvasElementExternal.h b/content/canvas/public/nsICanvasElementExternal.h index 79ce954d9d5a..44250c1422df 100644 --- a/content/canvas/public/nsICanvasElementExternal.h +++ b/content/canvas/public/nsICanvasElementExternal.h @@ -24,7 +24,7 @@ struct _cairo_surface; /* * This interface contains methods that are needed outside of the content/layout * modules, specifically widget. It should eventually go away when we support - * libxul builds, and nsHTMLCanvasElement be used directly. + * libxul builds, and HTMLCanvasElement be used directly. * * Code internal to content/layout should /never/ use this interface; if the * same functionality is needed in both places, two separate methods should be diff --git a/content/canvas/public/nsICanvasRenderingContextInternal.h b/content/canvas/public/nsICanvasRenderingContextInternal.h index 28afa79d4d67..eef50bc18d93 100644 --- a/content/canvas/public/nsICanvasRenderingContextInternal.h +++ b/content/canvas/public/nsICanvasRenderingContextInternal.h @@ -9,7 +9,7 @@ #include "nsISupports.h" #include "nsIInputStream.h" #include "nsIDocShell.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "gfxPattern.h" #include "mozilla/RefPtr.h" @@ -46,11 +46,11 @@ public: RenderFlagPremultAlpha = 0x1 }; - void SetCanvasElement(nsHTMLCanvasElement* aParentCanvas) + void SetCanvasElement(mozilla::dom::HTMLCanvasElement* aParentCanvas) { mCanvasElement = aParentCanvas; } - nsHTMLCanvasElement* GetParentObject() const + mozilla::dom::HTMLCanvasElement* GetParentObject() const { return mCanvasElement; } @@ -125,7 +125,7 @@ public: NS_IMETHOD SetIsIPC(bool isIPC) = 0; protected: - nsRefPtr mCanvasElement; + nsRefPtr mCanvasElement; }; namespace mozilla { diff --git a/content/canvas/src/CanvasImageCache.cpp b/content/canvas/src/CanvasImageCache.cpp index 3c071a1cc201..f1fb2948e60f 100644 --- a/content/canvas/src/CanvasImageCache.cpp +++ b/content/canvas/src/CanvasImageCache.cpp @@ -11,7 +11,7 @@ #include "gfxPoint.h" #include "mozilla/dom/Element.h" #include "nsTHashtable.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsContentUtils.h" namespace mozilla { @@ -19,10 +19,10 @@ namespace mozilla { using namespace dom; struct ImageCacheKey { - ImageCacheKey(Element* aImage, nsHTMLCanvasElement* aCanvas) + ImageCacheKey(Element* aImage, HTMLCanvasElement* aCanvas) : mImage(aImage), mCanvas(aCanvas) {} Element* mImage; - nsHTMLCanvasElement* mCanvas; + HTMLCanvasElement* mCanvas; }; struct ImageCacheEntryData { @@ -45,7 +45,7 @@ struct ImageCacheEntryData { // Key nsRefPtr mImage; nsIImageLoadingContent* mILC; - nsRefPtr mCanvas; + nsRefPtr mCanvas; // Value nsCOMPtr mRequest; nsRefPtr mSurface; @@ -113,7 +113,7 @@ public: void CanvasImageCache::NotifyDrawImage(Element* aImage, - nsHTMLCanvasElement* aCanvas, + HTMLCanvasElement* aCanvas, imgIRequest* aRequest, gfxASurface* aSurface, const gfxIntSize& aSize) @@ -144,7 +144,7 @@ CanvasImageCache::NotifyDrawImage(Element* aImage, gfxASurface* CanvasImageCache::Lookup(Element* aImage, - nsHTMLCanvasElement* aCanvas, + HTMLCanvasElement* aCanvas, gfxIntSize* aSize) { if (!gImageCache) diff --git a/content/canvas/src/CanvasImageCache.h b/content/canvas/src/CanvasImageCache.h index 07619960ab9d..91ae57ce490d 100644 --- a/content/canvas/src/CanvasImageCache.h +++ b/content/canvas/src/CanvasImageCache.h @@ -9,9 +9,9 @@ namespace mozilla { namespace dom { class Element; +class HTMLCanvasElement; } // namespace dom } // namespace mozilla -class nsHTMLCanvasElement; class imgIRequest; class gfxASurface; @@ -27,7 +27,7 @@ public: * in aSurface, and the image size is in aSize. */ static void NotifyDrawImage(dom::Element* aImage, - nsHTMLCanvasElement* aCanvas, + dom::HTMLCanvasElement* aCanvas, imgIRequest* aRequest, gfxASurface* aSurface, const gfxIntSize& aSize); @@ -39,7 +39,7 @@ public: * data, and the image size will be returned in aSize. */ static gfxASurface* Lookup(dom::Element* aImage, - nsHTMLCanvasElement* aCanvas, + dom::HTMLCanvasElement* aCanvas, gfxIntSize* aSize); }; diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 4c4ee01d0292..123f01fc783e 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -16,7 +16,7 @@ #include "nsContentUtils.h" #include "nsIDocument.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsSVGEffects.h" #include "nsPresContext.h" #include "nsIPresShell.h" @@ -621,7 +621,7 @@ CanvasRenderingContext2D::Reset() } static void -WarnAboutUnexpectedStyle(nsHTMLCanvasElement* canvasElement) +WarnAboutUnexpectedStyle(HTMLCanvasElement* canvasElement) { nsContentUtils::ReportToConsole( nsIScriptError::warningFlag, @@ -1400,7 +1400,7 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e Element* htmlElement; if (element.IsHTMLCanvasElement()) { - nsHTMLCanvasElement* canvas = element.GetAsHTMLCanvasElement(); + HTMLCanvasElement* canvas = element.GetAsHTMLCanvasElement(); htmlElement = canvas; nsIntSize size = canvas->GetSize(); @@ -2913,7 +2913,7 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image EnsureTarget(); if (image.IsHTMLCanvasElement()) { - nsHTMLCanvasElement* canvas = image.GetAsHTMLCanvasElement(); + HTMLCanvasElement* canvas = image.GetAsHTMLCanvasElement(); element = canvas; nsIntSize size = canvas->GetSize(); if (size.width == 0 || size.height == 0) { diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index afad9c6fab2e..cd4d1740590f 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -10,7 +10,7 @@ #include "nsICanvasRenderingContextInternal.h" #include "mozilla/RefPtr.h" #include "nsColor.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsHTMLVideoElement.h" #include "CanvasUtils.h" #include "gfxFont.h" @@ -141,7 +141,7 @@ public: virtual JSObject* WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap); - nsHTMLCanvasElement* GetCanvas() const + HTMLCanvasElement* GetCanvas() const { // corresponds to changes to the old bindings made in bug 745025 return mCanvasElement->GetOriginalCanvas(); diff --git a/content/canvas/src/CanvasUtils.cpp b/content/canvas/src/CanvasUtils.cpp index 6cf0f538b5a4..82ed8e31e652 100644 --- a/content/canvas/src/CanvasUtils.cpp +++ b/content/canvas/src/CanvasUtils.cpp @@ -14,7 +14,7 @@ #include "nsIDOMCanvasRenderingContext2D.h" #include "nsICanvasRenderingContextInternal.h" #include "nsIHTMLCollection.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsIPrincipal.h" #include "nsGfxCIID.h" @@ -30,7 +30,7 @@ namespace mozilla { namespace CanvasUtils { void -DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement, +DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement, nsIPrincipal *aPrincipal, bool forceWriteOnly, bool CORSUsed) diff --git a/content/canvas/src/CanvasUtils.h b/content/canvas/src/CanvasUtils.h index bef1ba7ff5df..178f56bb3775 100644 --- a/content/canvas/src/CanvasUtils.h +++ b/content/canvas/src/CanvasUtils.h @@ -10,7 +10,6 @@ #include "mozilla/CheckedInt.h" -class nsHTMLCanvasElement; class nsIPrincipal; namespace mozilla { @@ -19,6 +18,10 @@ namespace gfx { class Matrix; } +namespace dom { +class HTMLCanvasElement; +} + namespace CanvasUtils { @@ -39,7 +42,7 @@ inline bool CheckSaneSubrectSize(int32_t x, int32_t y, int32_t w, int32_t h, // Flag aCanvasElement as write-only if drawing an image with aPrincipal // onto it would make it such. -void DoDrawImageSecurityCheck(nsHTMLCanvasElement *aCanvasElement, +void DoDrawImageSecurityCheck(dom::HTMLCanvasElement *aCanvasElement, nsIPrincipal *aPrincipal, bool forceWriteOnly, bool CORSUsed); diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index 351352f891a5..42b0bb7e6c8c 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -802,7 +802,7 @@ namespace mozilla { class WebGLContextUserData : public LayerUserData { public: - WebGLContextUserData(nsHTMLCanvasElement *aContent) + WebGLContextUserData(HTMLCanvasElement *aContent) : mContent(aContent) {} /** DidTransactionCallback gets called by the Layers code everytime the WebGL canvas gets composite, @@ -811,7 +811,7 @@ public: static void DidTransactionCallback(void* aData) { WebGLContextUserData *userdata = static_cast(aData); - nsHTMLCanvasElement *canvas = userdata->mContent; + HTMLCanvasElement *canvas = userdata->mContent; WebGLContext *context = static_cast(canvas->GetContextAtIndex(0)); context->mBackbufferClearingStatus = BackbufferClearingStatus::NotClearedSinceLastPresented; @@ -821,7 +821,7 @@ public: } private: - nsRefPtr mContent; + nsRefPtr mContent; }; } // end namespace mozilla diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 44ef6ed887fd..883921b9ff99 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -28,7 +28,7 @@ #include "nsIDOMWebGLRenderingContext.h" #include "nsICanvasRenderingContextInternal.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsIDOMHTMLElement.h" #include "nsIMemoryReporter.h" #include "nsIJSNativeInitializer.h" @@ -332,7 +332,7 @@ public: } // WebIDL WebGLRenderingContext API - nsHTMLCanvasElement* GetCanvas() const { + dom::HTMLCanvasElement* GetCanvas() const { return mCanvasElement; } WebGLsizei DrawingBufferWidth() const { diff --git a/content/html/content/public/nsHTMLCanvasElement.h b/content/html/content/public/HTMLCanvasElement.h similarity index 85% rename from content/html/content/public/nsHTMLCanvasElement.h rename to content/html/content/public/HTMLCanvasElement.h index 5a9b50f4009b..e30e1ccc1731 100644 --- a/content/html/content/public/nsHTMLCanvasElement.h +++ b/content/html/content/public/HTMLCanvasElement.h @@ -3,8 +3,8 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#if !defined(nsHTMLCanvasElement_h__) -#define nsHTMLCanvasElement_h__ +#if !defined(mozilla_dom_HTMLCanvasElement_h) +#define mozilla_dom_HTMLCanvasElement_h #include "nsIDOMHTMLCanvasElement.h" #include "nsGenericHTMLElement.h" @@ -18,7 +18,6 @@ class nsICanvasRenderingContextInternal; class nsIDOMFile; -class nsHTMLCanvasPrintState; class nsITimerCallback; class nsIPropertyBag; @@ -33,20 +32,22 @@ namespace gfx { struct Rect; } -} +namespace dom { -class nsHTMLCanvasElement : public nsGenericHTMLElement, - public nsICanvasElementExternal, - public nsIDOMHTMLCanvasElement +class HTMLCanvasPrintState; + +class HTMLCanvasElement MOZ_FINAL : public nsGenericHTMLElement, + public nsICanvasElementExternal, + public nsIDOMHTMLCanvasElement { - typedef mozilla::layers::CanvasLayer CanvasLayer; - typedef mozilla::layers::LayerManager LayerManager; + typedef layers::CanvasLayer CanvasLayer; + typedef layers::LayerManager LayerManager; public: - nsHTMLCanvasElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLCanvasElement(); + HTMLCanvasElement(already_AddRefed aNodeInfo); + virtual ~HTMLCanvasElement(); - NS_IMPL_FROMCONTENT_HTML_WITH_TAG(nsHTMLCanvasElement, canvas) + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLCanvasElement, canvas) // nsISupports NS_DECL_ISUPPORTS_INHERITED @@ -64,7 +65,7 @@ public: NS_DECL_NSIDOMHTMLCANVASELEMENT // CC - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLCanvasElement, + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLCanvasElement, nsGenericHTMLElement) /** @@ -173,10 +174,10 @@ protected: void CallPrintCallback(); nsString mCurrentContextId; - nsRefPtr mOriginalCanvas; + nsRefPtr mOriginalCanvas; nsCOMPtr mPrintCallback; nsCOMPtr mCurrentContext; - nsCOMPtr mPrintState; + nsCOMPtr mPrintState; public: // Record whether this canvas should be write-only or not. @@ -193,13 +194,16 @@ public: void ResetPrintCallback(); - nsHTMLCanvasElement* GetOriginalCanvas(); + HTMLCanvasElement* GetOriginalCanvas(); }; inline nsISupports* -GetISupports(nsHTMLCanvasElement* p) +GetISupports(HTMLCanvasElement* p) { - return static_cast(p); + return static_cast(p); } -#endif /* nsHTMLCanvasElement_h__ */ +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLCanvasElement_h */ diff --git a/content/html/content/public/Makefile.in b/content/html/content/public/Makefile.in index 4aecefde6edd..f17452f32e88 100644 --- a/content/html/content/public/Makefile.in +++ b/content/html/content/public/Makefile.in @@ -31,10 +31,15 @@ EXPORTS = \ nsITextControlElement.h \ nsFormSubmission.h \ nsHTMLAudioElement.h \ - nsHTMLCanvasElement.h \ nsHTMLMediaElement.h \ nsHTMLVideoElement.h \ nsIHTMLCollection.h \ $(NULL) +EXPORTS_NAMESPACES = mozilla/dom + +EXPORTS_mozilla/dom = \ + HTMLCanvasElement.h \ + $(NULL) + include $(topsrcdir)/config/rules.mk diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/HTMLCanvasElement.cpp similarity index 79% rename from content/html/content/src/nsHTMLCanvasElement.cpp rename to content/html/content/src/HTMLCanvasElement.cpp index cbcab2dc26fa..16db0a0b3555 100644 --- a/content/html/content/src/nsHTMLCanvasElement.cpp +++ b/content/html/content/src/HTMLCanvasElement.cpp @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsAttrValueInlines.h" #include "mozilla/Base64.h" @@ -36,10 +36,15 @@ #define DEFAULT_CANVAS_WIDTH 300 #define DEFAULT_CANVAS_HEIGHT 150 -using namespace mozilla; -using namespace mozilla::dom; using namespace mozilla::layers; +nsGenericHTMLElement* +NS_NewHTMLCanvasElement(already_AddRefed aNodeInfo, + mozilla::dom::FromParser aFromParser) +{ + return new mozilla::dom::HTMLCanvasElement(aNodeInfo); +} + namespace { typedef mozilla::dom::HTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement @@ -69,12 +74,15 @@ private: } // anonymous namespace -class nsHTMLCanvasPrintState : public nsIDOMMozCanvasPrintState +namespace mozilla { +namespace dom { + +class HTMLCanvasPrintState : public nsIDOMMozCanvasPrintState { public: - nsHTMLCanvasPrintState(nsHTMLCanvasElement* aCanvas, - nsICanvasRenderingContextInternal* aContext, - nsITimerCallback* aCallback) + HTMLCanvasPrintState(HTMLCanvasElement* aCanvas, + nsICanvasRenderingContextInternal* aContext, + nsITimerCallback* aCallback) : mIsDone(false), mPendingNotify(false), mCanvas(aCanvas), mContext(aContext), mCallback(aCallback) { @@ -94,8 +102,8 @@ public: if (mCanvas) { mCanvas->InvalidateCanvas(); } - nsRefPtr > doneEvent = - NS_NewRunnableMethod(this, &nsHTMLCanvasPrintState::NotifyDone); + nsRefPtr > doneEvent = + NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) { mPendingNotify = true; } @@ -116,64 +124,55 @@ public: // CC NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(nsHTMLCanvasPrintState) + NS_DECL_CYCLE_COLLECTION_CLASS(HTMLCanvasPrintState) private: - virtual ~nsHTMLCanvasPrintState() + virtual ~HTMLCanvasPrintState() { } bool mPendingNotify; protected: - nsRefPtr mCanvas; + nsRefPtr mCanvas; nsCOMPtr mContext; nsCOMPtr mCallback; }; -NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHTMLCanvasPrintState) -NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHTMLCanvasPrintState) +NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLCanvasPrintState) +NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLCanvasPrintState) -DOMCI_DATA(MozCanvasPrintState, nsHTMLCanvasPrintState) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsHTMLCanvasPrintState) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLCanvasPrintState) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIDOMMozCanvasPrintState) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozCanvasPrintState) NS_INTERFACE_MAP_END -NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLCanvasPrintState) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHTMLCanvasPrintState) +NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLCanvasPrintState) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(HTMLCanvasPrintState) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCanvas) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHTMLCanvasPrintState) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(HTMLCanvasPrintState) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCanvas) NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback) NS_IMPL_CYCLE_COLLECTION_UNLINK_END // --------------------------------------------------------------------------- -nsGenericHTMLElement* -NS_NewHTMLCanvasElement(already_AddRefed aNodeInfo, - FromParser aFromParser) -{ - return new nsHTMLCanvasElement(aNodeInfo); -} - -nsHTMLCanvasElement::nsHTMLCanvasElement(already_AddRefed aNodeInfo) +HTMLCanvasElement::HTMLCanvasElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mWriteOnly(false) { } -nsHTMLCanvasElement::~nsHTMLCanvasElement() +HTMLCanvasElement::~HTMLCanvasElement() { ResetPrintCallback(); } -NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLCanvasElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLCanvasElement, +NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLCanvasElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLCanvasElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCurrentContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrintCallback) @@ -181,7 +180,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLCanvasElement, NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOriginalCanvas) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLCanvasElement, +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLCanvasElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCurrentContext) NS_IMPL_CYCLE_COLLECTION_UNLINK(mPrintCallback) @@ -189,23 +188,21 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLCanvasElement, NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalCanvas) NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_ADDREF_INHERITED(nsHTMLCanvasElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLCanvasElement, Element) +NS_IMPL_ADDREF_INHERITED(HTMLCanvasElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLCanvasElement, Element) -DOMCI_NODE_DATA(HTMLCanvasElement, nsHTMLCanvasElement) - -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLCanvasElement) - NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLCanvasElement, +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLCanvasElement) + NS_HTML_CONTENT_INTERFACE_TABLE2(HTMLCanvasElement, nsIDOMHTMLCanvasElement, nsICanvasElementExternal) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLCanvasElement, + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLCanvasElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLCanvasElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLCanvasElement) +NS_IMPL_ELEMENT_CLONE(HTMLCanvasElement) nsIntSize -nsHTMLCanvasElement::GetWidthHeight() +HTMLCanvasElement::GetWidthHeight() { nsIntSize size(DEFAULT_CANVAS_WIDTH, DEFAULT_CANVAS_HEIGHT); const nsAttrValue* value; @@ -225,14 +222,14 @@ nsHTMLCanvasElement::GetWidthHeight() return size; } -NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH) -NS_IMPL_UINT_ATTR_DEFAULT_VALUE(nsHTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT) -NS_IMPL_BOOL_ATTR(nsHTMLCanvasElement, MozOpaque, moz_opaque) +NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Width, width, DEFAULT_CANVAS_WIDTH) +NS_IMPL_UINT_ATTR_DEFAULT_VALUE(HTMLCanvasElement, Height, height, DEFAULT_CANVAS_HEIGHT) +NS_IMPL_BOOL_ATTR(HTMLCanvasElement, MozOpaque, moz_opaque) nsresult -nsHTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify) +HTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify) { nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix, aValue, aNotify); @@ -247,7 +244,7 @@ nsHTMLCanvasElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, } void -nsHTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType) +HTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType) { // Only call the print callback here if 1) we're in a print testing mode or // print preview mode, 2) the canvas has a print callback and 3) the callback @@ -263,7 +260,7 @@ nsHTMLCanvasElement::HandlePrintCallback(nsPresContext::nsPresContextType aType) } nsresult -nsHTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback) +HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback) { // For print reftests the context may not be initialized yet, so get a context // so mCurrentContext is set. @@ -274,15 +271,15 @@ nsHTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback) getter_AddRefs(context)); NS_ENSURE_SUCCESS(rv, rv); } - mPrintState = new nsHTMLCanvasPrintState(this, mCurrentContext, aCallback); + mPrintState = new HTMLCanvasPrintState(this, mCurrentContext, aCallback); - nsRefPtr > renderEvent = - NS_NewRunnableMethod(this, &nsHTMLCanvasElement::CallPrintCallback); + nsRefPtr > renderEvent = + NS_NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback); return NS_DispatchToCurrentThread(renderEvent); } void -nsHTMLCanvasElement::CallPrintCallback() +HTMLCanvasElement::CallPrintCallback() { nsCOMPtr printCallback; GetMozPrintCallback(getter_AddRefs(printCallback)); @@ -290,7 +287,7 @@ nsHTMLCanvasElement::CallPrintCallback() } void -nsHTMLCanvasElement::ResetPrintCallback() +HTMLCanvasElement::ResetPrintCallback() { if (mPrintState) { mPrintState = nullptr; @@ -298,7 +295,7 @@ nsHTMLCanvasElement::ResetPrintCallback() } bool -nsHTMLCanvasElement::IsPrintCallbackDone() +HTMLCanvasElement::IsPrintCallbackDone() { if (mPrintState == nullptr) { return true; @@ -307,20 +304,20 @@ nsHTMLCanvasElement::IsPrintCallbackDone() return mPrintState->mIsDone; } -nsHTMLCanvasElement* -nsHTMLCanvasElement::GetOriginalCanvas() +HTMLCanvasElement* +HTMLCanvasElement::GetOriginalCanvas() { return mOriginalCanvas ? mOriginalCanvas.get() : this; } nsresult -nsHTMLCanvasElement::CopyInnerTo(Element* aDest) +HTMLCanvasElement::CopyInnerTo(Element* aDest) { nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest); NS_ENSURE_SUCCESS(rv, rv); if (aDest->OwnerDoc()->IsStaticDocument()) { - nsHTMLCanvasElement* dest = static_cast(aDest); - nsHTMLCanvasElement* self = const_cast(this); + HTMLCanvasElement* dest = static_cast(aDest); + HTMLCanvasElement* self = const_cast(this); dest->mOriginalCanvas = self; nsCOMPtr cxt; @@ -328,8 +325,8 @@ nsHTMLCanvasElement::CopyInnerTo(Element* aDest) nsRefPtr context2d = static_cast(cxt.get()); if (context2d && !self->mPrintCallback) { - HTMLImageOrCanvasOrVideoElement element; - element.SetAsHTMLCanvasElement() = this; + HTMLImageOrCanvasOrVideoElement element; + element.SetAsHTMLCanvasElement() = this; ErrorResult err; context2d->DrawImage(element, 0.0, 0.0, err); @@ -340,8 +337,8 @@ nsHTMLCanvasElement::CopyInnerTo(Element* aDest) } nsChangeHint -nsHTMLCanvasElement::GetAttributeChangeHint(const nsIAtom* aAttribute, - int32_t aModType) const +HTMLCanvasElement::GetAttributeChangeHint(const nsIAtom* aAttribute, + int32_t aModType) const { nsChangeHint retval = nsGenericHTMLElement::GetAttributeChangeHint(aAttribute, aModType); @@ -357,10 +354,10 @@ nsHTMLCanvasElement::GetAttributeChangeHint(const nsIAtom* aAttribute, } bool -nsHTMLCanvasElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLCanvasElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { if (aNamespaceID == kNameSpaceID_None && (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height)) { @@ -372,11 +369,11 @@ nsHTMLCanvasElement::ParseAttribute(int32_t aNamespaceID, } -// nsHTMLCanvasElement::toDataURL +// HTMLCanvasElement::toDataURL NS_IMETHODIMP -nsHTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams, - uint8_t optional_argc, nsAString& aDataURL) +HTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams, + uint8_t optional_argc, nsAString& aDataURL) { // do a trust check if this is a write-only canvas if (mWriteOnly && !nsContentUtils::IsCallerChrome()) { @@ -386,11 +383,11 @@ nsHTMLCanvasElement::ToDataURL(const nsAString& aType, nsIVariant* aParams, return ToDataURLImpl(aType, aParams, aDataURL); } -// nsHTMLCanvasElement::mozFetchAsStream +// HTMLCanvasElement::mozFetchAsStream NS_IMETHODIMP -nsHTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback, - const nsAString& aType) +HTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback, + const nsAString& aType) { if (!nsContentUtils::IsCallerChrome()) return NS_ERROR_FAILURE; @@ -417,14 +414,14 @@ nsHTMLCanvasElement::MozFetchAsStream(nsIInputStreamCallback *aCallback, } NS_IMETHODIMP -nsHTMLCanvasElement::SetMozPrintCallback(nsIPrintCallback *aCallback) +HTMLCanvasElement::SetMozPrintCallback(nsIPrintCallback *aCallback) { mPrintCallback = aCallback; return NS_OK; } NS_IMETHODIMP -nsHTMLCanvasElement::GetMozPrintCallback(nsIPrintCallback** aCallback) +HTMLCanvasElement::GetMozPrintCallback(nsIPrintCallback** aCallback) { if (mOriginalCanvas) { mOriginalCanvas->GetMozPrintCallback(aCallback); @@ -435,10 +432,10 @@ nsHTMLCanvasElement::GetMozPrintCallback(nsIPrintCallback** aCallback) } nsresult -nsHTMLCanvasElement::ExtractData(const nsAString& aType, - const nsAString& aOptions, - nsIInputStream** aStream, - bool& aFellBackToPNG) +HTMLCanvasElement::ExtractData(const nsAString& aType, + const nsAString& aOptions, + nsIInputStream** aStream, + bool& aFellBackToPNG) { // note that if we don't have a current context, the spec says we're // supposed to just return transparent black pixels of the canvas @@ -500,9 +497,9 @@ nsHTMLCanvasElement::ExtractData(const nsAString& aType, } nsresult -nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType, - nsIVariant* aEncoderOptions, - nsAString& aDataURL) +HTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType, + nsIVariant* aEncoderOptions, + nsAString& aDataURL) { bool fallbackToPNG = false; @@ -585,10 +582,10 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType, // XXXkhuey the encoding should be off the main thread, but we're lazy. NS_IMETHODIMP -nsHTMLCanvasElement::ToBlob(nsIFileCallback* aCallback, - const nsAString& aType, - nsIVariant* aParams, - uint8_t optional_argc) +HTMLCanvasElement::ToBlob(nsIFileCallback* aCallback, + const nsAString& aType, + nsIVariant* aParams, + uint8_t optional_argc) { // do a trust check if this is a write-only canvas if (mWriteOnly && !nsContentUtils::IsCallerChrome()) { @@ -638,10 +635,10 @@ nsHTMLCanvasElement::ToBlob(nsIFileCallback* aCallback, } NS_IMETHODIMP -nsHTMLCanvasElement::MozGetAsFile(const nsAString& aName, - const nsAString& aType, - uint8_t optional_argc, - nsIDOMFile** aResult) +HTMLCanvasElement::MozGetAsFile(const nsAString& aName, + const nsAString& aType, + uint8_t optional_argc, + nsIDOMFile** aResult) { // do a trust check if this is a write-only canvas if ((mWriteOnly) && @@ -653,9 +650,9 @@ nsHTMLCanvasElement::MozGetAsFile(const nsAString& aName, } nsresult -nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName, - const nsAString& aType, - nsIDOMFile** aResult) +HTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName, + const nsAString& aType, + nsIDOMFile** aResult) { bool fallbackToPNG = false; @@ -692,8 +689,8 @@ nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName, } nsresult -nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId, - nsICanvasRenderingContextInternal **aContext) +HTMLCanvasElement::GetContextHelper(const nsAString& aContextId, + nsICanvasRenderingContextInternal **aContext) { NS_ENSURE_ARG(aContext); @@ -744,9 +741,9 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId, } NS_IMETHODIMP -nsHTMLCanvasElement::GetContext(const nsAString& aContextId, - const JS::Value& aContextOptions, - nsISupports **aContext) +HTMLCanvasElement::GetContext(const nsAString& aContextId, + const JS::Value& aContextOptions, + nsISupports **aContext) { nsresult rv; @@ -831,8 +828,8 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId, } NS_IMETHODIMP -nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId, - nsISupports **aContext) +HTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId, + nsISupports **aContext) { if(!nsContentUtils::IsCallerChrome()) { // XXX ERRMSG we need to report an error to developers here! (bug 329026) @@ -866,7 +863,7 @@ nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId, } nsresult -nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions) +HTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions) { if (!mCurrentContext) return NS_OK; @@ -898,25 +895,25 @@ nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions) } nsIntSize -nsHTMLCanvasElement::GetSize() +HTMLCanvasElement::GetSize() { return GetWidthHeight(); } bool -nsHTMLCanvasElement::IsWriteOnly() +HTMLCanvasElement::IsWriteOnly() { return mWriteOnly; } void -nsHTMLCanvasElement::SetWriteOnly() +HTMLCanvasElement::SetWriteOnly() { mWriteOnly = true; } void -nsHTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) +HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) { // We don't need to flush anything here; if there's no frame or if // we plan to reframe we don't need to invalidate it anyway. @@ -962,7 +959,7 @@ nsHTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) } void -nsHTMLCanvasElement::InvalidateCanvas() +HTMLCanvasElement::InvalidateCanvas() { // We don't need to flush anything here; if there's no frame or if // we plan to reframe we don't need to invalidate it anyway. @@ -974,7 +971,7 @@ nsHTMLCanvasElement::InvalidateCanvas() } int32_t -nsHTMLCanvasElement::CountContexts() +HTMLCanvasElement::CountContexts() { if (mCurrentContext) return 1; @@ -983,7 +980,7 @@ nsHTMLCanvasElement::CountContexts() } nsICanvasRenderingContextInternal * -nsHTMLCanvasElement::GetContextAtIndex(int32_t index) +HTMLCanvasElement::GetContextAtIndex(int32_t index) { if (mCurrentContext && index == 0) return mCurrentContext; @@ -992,15 +989,15 @@ nsHTMLCanvasElement::GetContextAtIndex(int32_t index) } bool -nsHTMLCanvasElement::GetIsOpaque() +HTMLCanvasElement::GetIsOpaque() { return HasAttr(kNameSpaceID_None, nsGkAtoms::moz_opaque); } already_AddRefed -nsHTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder, - CanvasLayer *aOldLayer, - LayerManager *aManager) +HTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder, + CanvasLayer *aOldLayer, + LayerManager *aManager) { if (!mCurrentContext) return nullptr; @@ -1009,13 +1006,13 @@ nsHTMLCanvasElement::GetCanvasLayer(nsDisplayListBuilder* aBuilder, } bool -nsHTMLCanvasElement::ShouldForceInactiveLayer(LayerManager *aManager) +HTMLCanvasElement::ShouldForceInactiveLayer(LayerManager *aManager) { return !mCurrentContext || mCurrentContext->ShouldForceInactiveLayer(aManager); } void -nsHTMLCanvasElement::MarkContextClean() +HTMLCanvasElement::MarkContextClean() { if (!mCurrentContext) return; @@ -1024,13 +1021,13 @@ nsHTMLCanvasElement::MarkContextClean() } NS_IMETHODIMP_(nsIntSize) -nsHTMLCanvasElement::GetSizeExternal() +HTMLCanvasElement::GetSizeExternal() { return GetWidthHeight(); } NS_IMETHODIMP -nsHTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, uint32_t aFlags) +HTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, uint32_t aFlags) { if (!mCurrentContext) return NS_OK; @@ -1038,3 +1035,8 @@ nsHTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::Gr return mCurrentContext->Render(aContext, aFilter, aFlags); } +} // namespace dom +} // namespace mozilla + +DOMCI_NODE_DATA(HTMLCanvasElement, mozilla::dom::HTMLCanvasElement) +DOMCI_DATA(MozCanvasPrintState, mozilla::dom::HTMLCanvasPrintState) diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index baa2d1467128..7ca94f30d374 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -55,7 +55,7 @@ CPPSRCS = \ nsHTMLBRElement.cpp \ HTMLBodyElement.cpp \ nsHTMLButtonElement.cpp \ - nsHTMLCanvasElement.cpp \ + HTMLCanvasElement.cpp \ HTMLDataListElement.cpp \ HTMLDivElement.cpp \ nsHTMLFieldSetElement.cpp \ diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 7cbd1557f9db..b3ff24e341dd 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1025,7 +1025,6 @@ def addExternalHTMLElement(element): addExternalIface(element, nativeType=nativeElement, headerFile=nativeElement + '.h') -addExternalHTMLElement('HTMLCanvasElement') addExternalHTMLElement('HTMLFormElement') addExternalHTMLElement('HTMLMenuElement') addExternalHTMLElement('HTMLOptionElement') @@ -1044,6 +1043,7 @@ addExternalIface('DOMStringList') addExternalIface('File') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('HTMLHeadElement', nativeType='mozilla::dom::Element') +addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LockedFile') diff --git a/js/xpconnect/src/nsDOMQS.h b/js/xpconnect/src/nsDOMQS.h index d800720fed4e..3b2dc1b37cca 100644 --- a/js/xpconnect/src/nsDOMQS.h +++ b/js/xpconnect/src/nsDOMQS.h @@ -7,7 +7,7 @@ #include "nsDOMClassInfoID.h" #include "nsGenericHTMLElement.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsHTMLFormElement.h" #include "mozilla/dom/HTMLImageElement.h" #include "nsHTMLOptionElement.h" @@ -168,7 +168,7 @@ xpc_qsUnwrapArg<_clazz>(JSContext *cx, jsval v, _clazz **ppArg, \ return rv; \ } -DEFINE_UNWRAP_CAST_HTML(canvas, nsHTMLCanvasElement) +DEFINE_UNWRAP_CAST_HTML(canvas, mozilla::dom::HTMLCanvasElement) DEFINE_UNWRAP_CAST_HTML(form, nsHTMLFormElement) DEFINE_UNWRAP_CAST_HTML(img, mozilla::dom::HTMLImageElement) DEFINE_UNWRAP_CAST_HTML(optgroup, nsHTMLOptGroupElement) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index c8d483b7cec5..164ea1e99b4f 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -49,7 +49,7 @@ #include "gfxTypes.h" #include "gfxUserFontSet.h" #include "nsTArray.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsICanvasRenderingContextInternal.h" #include "gfxPlatform.h" #include "nsClientRect.h" @@ -4520,7 +4520,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLImageElement *aElement, } nsLayoutUtils::SurfaceFromElementResult -nsLayoutUtils::SurfaceFromElement(nsHTMLCanvasElement* aElement, +nsLayoutUtils::SurfaceFromElement(HTMLCanvasElement* aElement, uint32_t aSurfaceFlags) { SurfaceFromElementResult result; @@ -4559,7 +4559,7 @@ nsLayoutUtils::SurfaceFromElement(nsHTMLCanvasElement* aElement, nsRefPtr ctx = new gfxContext(surf); // XXX shouldn't use the external interface, but maybe we can layerify this - uint32_t flags = premultAlpha ? nsHTMLCanvasElement::RenderFlagPremultAlpha : 0; + uint32_t flags = premultAlpha ? HTMLCanvasElement::RenderFlagPremultAlpha : 0; rv = aElement->RenderContextsExternal(ctx, gfxPattern::FILTER_NEAREST, flags); if (NS_FAILED(rv)) return result; @@ -4636,8 +4636,8 @@ nsLayoutUtils::SurfaceFromElement(dom::Element* aElement, uint32_t aSurfaceFlags) { // If it's a , we may be able to just grab its internal surface - if (nsHTMLCanvasElement* canvas = - nsHTMLCanvasElement::FromContentOrNull(aElement)) { + if (HTMLCanvasElement* canvas = + HTMLCanvasElement::FromContentOrNull(aElement)) { return SurfaceFromElement(canvas, aSurfaceFlags); } diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 49a4074953c5..16eb0088bf1e 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -18,7 +18,6 @@ class nsDisplayItem; class nsFontMetrics; class nsClientRectList; class nsFontFaceList; -class nsHTMLCanvasElement; class nsHTMLVideoElement; class nsIImageLoadingContent; @@ -47,6 +46,7 @@ namespace mozilla { namespace dom { class Element; class HTMLImageElement; +class HTMLCanvasElement; } // namespace dom } // namespace mozilla @@ -1476,7 +1476,7 @@ public: // for HTMLImageElement. static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLImageElement *aElement, uint32_t aSurfaceFlags = 0); - static SurfaceFromElementResult SurfaceFromElement(nsHTMLCanvasElement *aElement, + static SurfaceFromElementResult SurfaceFromElement(mozilla::dom::HTMLCanvasElement *aElement, uint32_t aSurfaceFlags = 0); static SurfaceFromElementResult SurfaceFromElement(nsHTMLVideoElement *aElement, uint32_t aSurfaceFlags = 0); diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 97b1a030cc67..6d87271c729b 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -11,7 +11,7 @@ #include "nsGkAtoms.h" #include "nsHTMLCanvasFrame.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsDisplayList.h" #include "nsLayoutUtils.h" #include "Layers.h" @@ -21,6 +21,7 @@ #include "gfxContext.h" using namespace mozilla; +using namespace mozilla::dom; using namespace mozilla::layers; class nsDisplayCanvas : public nsDisplayItem { @@ -42,8 +43,8 @@ public: bool* aSnap) { *aSnap = false; nsIFrame* f = GetUnderlyingFrame(); - nsHTMLCanvasElement *canvas = - nsHTMLCanvasElement::FromContent(f->GetContent()); + HTMLCanvasElement *canvas = + HTMLCanvasElement::FromContent(f->GetContent()); nsRegion result; if (canvas->GetIsOpaque()) { result = GetBounds(aBuilder, aSnap); @@ -68,7 +69,7 @@ public: LayerManager* aManager, const FrameLayerBuilder::ContainerParameters& aParameters) { - if (nsHTMLCanvasElement::FromContent(mFrame->GetContent())->ShouldForceInactiveLayer(aManager)) + if (HTMLCanvasElement::FromContent(mFrame->GetContent())->ShouldForceInactiveLayer(aManager)) return LAYER_INACTIVE; // If compositing is cheap, just do that @@ -111,8 +112,8 @@ nsIntSize nsHTMLCanvasFrame::GetCanvasSize() { nsIntSize size(0,0); - nsHTMLCanvasElement *canvas = - nsHTMLCanvasElement::FromContentOrNull(GetContent()); + HTMLCanvasElement *canvas = + HTMLCanvasElement::FromContentOrNull(GetContent()); if (canvas) { size = canvas->GetSize(); } else { @@ -245,7 +246,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder, const ContainerParameters& aContainerParameters) { nsRect area = GetContentRect() - GetPosition() + aItem->ToReferenceFrame(); - nsHTMLCanvasElement* element = static_cast(GetContent()); + HTMLCanvasElement* element = static_cast(GetContent()); nsIntSize canvasSize = GetCanvasSize(); nsPresContext* presContext = PresContext(); diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index 09baa2437af6..536dbda114b6 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -20,7 +20,7 @@ #include "nsDisplayList.h" #include "mozilla/Preferences.h" #include "nsHTMLCanvasFrame.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsICanvasRenderingContextInternal.h" // DateTime Includes @@ -34,6 +34,7 @@ #include "nsIServiceManager.h" using namespace mozilla; +using namespace mozilla::dom; static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printsettings-service;1"; @@ -482,7 +483,7 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext, } void -GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray >* aArr) +GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArray >* aArr) { if (!aFrame) { return; @@ -499,8 +500,8 @@ GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArrayGetContent()); + HTMLCanvasElement* canvas = + HTMLCanvasElement::FromContentOrNull(canvasFrame->GetContent()); nsCOMPtr printCallback; if (canvas && NS_SUCCEEDED(canvas->GetMozPrintCallback(getter_AddRefs(printCallback))) && @@ -519,8 +520,8 @@ GetPrintCanvasElementsInFrame(nsIFrame* aFrame, nsTArrayIsRootPaginatedDocument()) { *aDone = true; return NS_OK; @@ -623,7 +624,7 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a NS_ENSURE_TRUE(renderingSurface, NS_ERROR_OUT_OF_MEMORY); for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) { - nsHTMLCanvasElement* canvas = mCurrentCanvasList[i]; + HTMLCanvasElement* canvas = mCurrentCanvasList[i]; nsIntSize size = canvas->GetSize(); nsRefPtr printSurface = renderingSurface-> @@ -650,7 +651,7 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a } uint32_t doneCounter = 0; for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) { - nsHTMLCanvasElement* canvas = mCurrentCanvasList[i]; + HTMLCanvasElement* canvas = mCurrentCanvasList[i]; if (canvas->IsPrintCallbackDone()) { doneCounter++; @@ -666,7 +667,7 @@ NS_IMETHODIMP nsSimplePageSequenceFrame::ResetPrintCanvasList() { for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) { - nsHTMLCanvasElement* canvas = mCurrentCanvasList[i]; + HTMLCanvasElement* canvas = mCurrentCanvasList[i]; canvas->ResetPrintCallback(); } diff --git a/layout/generic/nsSimplePageSequence.h b/layout/generic/nsSimplePageSequence.h index 5955af075285..e91d8e276a6b 100644 --- a/layout/generic/nsSimplePageSequence.h +++ b/layout/generic/nsSimplePageSequence.h @@ -11,7 +11,7 @@ #include "nsIPrintSettings.h" #include "nsIPrintOptions.h" #include "nsIDateTimeFormat.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" //----------------------------------------------- // This class maintains all the data that @@ -135,7 +135,7 @@ protected: int32_t mFromPageNum; int32_t mToPageNum; nsTArray mPageRanges; - nsTArray > mCurrentCanvasList; + nsTArray > mCurrentCanvasList; // Selection Printing Info nscoord mSelectionHeight; diff --git a/layout/printing/nsPrintEngine.h b/layout/printing/nsPrintEngine.h index b3f2e0cf7bae..8a92c7a246b3 100644 --- a/layout/printing/nsPrintEngine.h +++ b/layout/printing/nsPrintEngine.h @@ -14,7 +14,7 @@ #include "nsFrameList.h" #include "mozilla/Attributes.h" #include "nsIWebProgress.h" -#include "nsHTMLCanvasElement.h" +#include "mozilla/dom/HTMLCanvasElement.h" #include "nsIWebProgressListener.h" #include "nsWeakReference.h" From 70bf42c4a29a57545235599846b0c6b84e1cf040 Mon Sep 17 00:00:00 2001 From: Yoshi Huang Date: Fri, 4 Jan 2013 13:34:01 +0800 Subject: [PATCH 022/180] Bug 826604 - B2G RIL: getOPL causes parcel error when reading unused octets. r=hsiniyi --- dom/system/gonk/ril_worker.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index 8226e774bdfd..3706eb21ea91 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -8969,8 +8969,11 @@ let ICCRecordHelper = { debug("OPL: [" + (opl.length + 1) + "]: " + JSON.stringify(oplElement)); } opl.push(oplElement); + } else { + Buf.seekIncoming(5 * PDU_HEX_OCTET_SIZE); } Buf.readStringDelimiter(len); + if (options.p1 < options.totalRecords) { ICCIOHelper.loadNextRecord(options); } else { From aa4c0c0f588e0bfdfee06f35044918a73ff3e10f Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Fri, 4 Jan 2013 16:07:27 +0000 Subject: [PATCH 023/180] Backout 6e391f971a13 (bug 826439) for xpcshell failures --- ipc/chromium/src/base/histogram.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index 3123f0f8fb25..90da947926fd 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -746,7 +746,7 @@ void Histogram::SampleSet::AccumulateWithExponentialStats(Sample value, size_t index) { Accumulate(value, count, index); DCHECK_GE(value, 0); - float value_log = logf(static_cast(value) + 1.0f); + double value_log = log(static_cast(value) + 1); log_sum_ += count * value_log; log_sum_squares_ += count * value_log * value_log; } From c95d254368f5f35d4e5075d5fa49659285cfcbf0 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Fri, 4 Jan 2013 17:11:32 +0100 Subject: [PATCH 024/180] Bug 825705: Creating this on caller-side shouldn't query prototype for unknown objects, r=jandem --- js/src/ion/CodeGenerator.cpp | 93 +++++++++++-------------- js/src/ion/CodeGenerator.h | 5 +- js/src/ion/IonBuilder.cpp | 58 ++++++---------- js/src/ion/IonBuilder.h | 3 +- js/src/ion/LIR-Common.h | 94 +++++++++++++------------- js/src/ion/LOpcodes.h | 4 +- js/src/ion/Lowering.cpp | 19 +++--- js/src/ion/Lowering.h | 1 + js/src/ion/MIR.h | 59 ++++++++++------ js/src/ion/MOpcodes.h | 1 + js/src/ion/VMFunctions.cpp | 26 +++++-- js/src/ion/VMFunctions.h | 1 + js/src/jit-test/tests/ion/bug825705.js | 23 +++++++ 13 files changed, 209 insertions(+), 178 deletions(-) create mode 100644 js/src/jit-test/tests/ion/bug825705.js diff --git a/js/src/ion/CodeGenerator.cpp b/js/src/ion/CodeGenerator.cpp index fb568b1403b6..8d7474104241 100644 --- a/js/src/ion/CodeGenerator.cpp +++ b/js/src/ion/CodeGenerator.cpp @@ -2010,6 +2010,46 @@ CodeGenerator::visitInitProp(LInitProp *lir) return callVM(InitPropInfo, lir); } +typedef bool (*CreateThisFn)(JSContext *cx, HandleObject callee, MutableHandleValue rval); +static const VMFunction CreateThisInfo = +FunctionInfo(CreateThis); + +bool +CodeGenerator::visitCreateThis(LCreateThis *lir) +{ + const LAllocation *callee = lir->getCallee(); + + if (callee->isConstant()) + pushArg(ImmGCPtr(&callee->toConstant()->toObject())); + else + pushArg(ToRegister(callee)); + + return callVM(CreateThisInfo, lir); +} + +typedef JSObject *(*CreateThisWithProtoFn)(JSContext *cx, HandleObject callee, JSObject *proto); +static const VMFunction CreateThisWithProtoInfo = +FunctionInfo(js_CreateThisForFunctionWithProto); + +bool +CodeGenerator::visitCreateThisWithProto(LCreateThisWithProto *lir) +{ + const LAllocation *callee = lir->getCallee(); + const LAllocation *proto = lir->getPrototype(); + + if (proto->isConstant()) + pushArg(ImmGCPtr(&proto->toConstant()->toObject())); + else + pushArg(ToRegister(proto)); + + if (callee->isConstant()) + pushArg(ImmGCPtr(&callee->toConstant()->toObject())); + else + pushArg(ToRegister(callee)); + + return callVM(CreateThisWithProtoInfo, lir); +} + typedef JSObject *(*NewGCThingFn)(JSContext *cx, gc::AllocKind allocKind, size_t thingSize); static const VMFunction NewGCThingInfo = FunctionInfo(js::ion::NewGCThing); @@ -2038,59 +2078,6 @@ CodeGenerator::visitCreateThisWithTemplate(LCreateThisWithTemplate *lir) return true; } -typedef JSObject *(*CreateThisFn)(JSContext *cx, HandleObject callee, JSObject *proto); -static const VMFunction CreateThisInfo = - FunctionInfo(js_CreateThisForFunctionWithProto); - -bool -CodeGenerator::emitCreateThisVM(LInstruction *lir, - const LAllocation *proto, - const LAllocation *callee) -{ - if (proto->isConstant()) - pushArg(ImmGCPtr(&proto->toConstant()->toObject())); - else - pushArg(ToRegister(proto)); - - if (callee->isConstant()) - pushArg(ImmGCPtr(&callee->toConstant()->toObject())); - else - pushArg(ToRegister(callee)); - - return callVM(CreateThisInfo, lir); -} - -bool -CodeGenerator::visitCreateThisV(LCreateThisV *lir) -{ - Label done, vm; - - const LAllocation *proto = lir->getPrototype(); - const LAllocation *callee = lir->getCallee(); - - // When callee could be a native, put MagicValue in return operand. - // Use the VMCall when callee turns out to not be a native. - masm.branchIfInterpreted(ToRegister(callee), &vm); - masm.moveValue(MagicValue(JS_IS_CONSTRUCTING), GetValueOutput(lir)); - masm.jump(&done); - - masm.bind(&vm); - if (!emitCreateThisVM(lir, proto, callee)) - return false; - - masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, GetValueOutput(lir)); - - masm.bind(&done); - - return true; -} - -bool -CodeGenerator::visitCreateThisO(LCreateThisO *lir) -{ - return emitCreateThisVM(lir, lir->getPrototype(), lir->getCallee()); -} - bool CodeGenerator::visitReturnFromCtor(LReturnFromCtor *lir) { diff --git a/js/src/ion/CodeGenerator.h b/js/src/ion/CodeGenerator.h index 096f3c1a738d..96918b7f78f0 100644 --- a/js/src/ion/CodeGenerator.h +++ b/js/src/ion/CodeGenerator.h @@ -99,9 +99,8 @@ class CodeGenerator : public CodeGeneratorSpecific bool visitNewCallObject(LNewCallObject *lir); bool visitNewStringObject(LNewStringObject *lir); bool visitInitProp(LInitProp *lir); - bool emitCreateThisVM(LInstruction *lir, const LAllocation *proto, const LAllocation *callee); - bool visitCreateThisV(LCreateThisV *lir); - bool visitCreateThisO(LCreateThisO *lir); + bool visitCreateThis(LCreateThis *lir); + bool visitCreateThisWithProto(LCreateThisWithProto *lir); bool visitCreateThisWithTemplate(LCreateThisWithTemplate *lir); bool visitReturnFromCtor(LReturnFromCtor *lir); bool visitArrayLength(LArrayLength *lir); diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index c9957be7d651..69de552e16fd 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -3574,15 +3574,6 @@ IonBuilder::createCallObject(MDefinition *callee, MDefinition *scope) return callObj; } -MDefinition * -IonBuilder::createThisNative() -{ - // Native constructors build the new Object themselves. - MConstant *magic = MConstant::New(MagicValue(JS_IS_CONSTRUCTING)); - current->add(magic); - return magic; -} - MDefinition * IonBuilder::createThisScripted(MDefinition *callee) { @@ -3610,7 +3601,7 @@ IonBuilder::createThisScripted(MDefinition *callee) current->add(getProto); // Create this from prototype - MCreateThis *createThis = MCreateThis::New(callee, getProto); + MCreateThisWithProto *createThis = MCreateThisWithProto::New(callee, getProto); current->add(createThis); return createThis; @@ -3633,8 +3624,13 @@ IonBuilder::getSingletonPrototype(JSFunction *target) } MDefinition * -IonBuilder::createThisScriptedSingleton(HandleFunction target, HandleObject proto, MDefinition *callee) +IonBuilder::createThisScriptedSingleton(HandleFunction target, MDefinition *callee) { + // Get the singleton prototype (if exists) + RootedObject proto(cx, getSingletonPrototype(target)); + if (!proto) + return NULL; + // Generate an inline path to create a new |this| object with // the given singleton prototype. types::TypeObject *type = proto->getNewType(cx, target); @@ -3661,36 +3657,26 @@ MDefinition * IonBuilder::createThis(HandleFunction target, MDefinition *callee) { // Create this for unknown target - if (!target) - return createThisScripted(callee); - - // Create this for native function - if (target->isNative()) { - if (!target->isNativeConstructor()) - return NULL; - return createThisNative(); + if (!target) { + MCreateThis *createThis = MCreateThis::New(callee); + current->add(createThis); + return createThis; } - // Create this with known prototype. - RootedObject proto(cx, getSingletonPrototype(target)); + // Native constructors build the new Object themselves. + if (target->isNative()) { + JS_ASSERT (target->isNativeConstructor()); + MConstant *magic = MConstant::New(MagicValue(JS_IS_CONSTRUCTING)); + current->add(magic); + return magic; + } // Try baking in the prototype. - if (proto) { - MDefinition *createThis = createThisScriptedSingleton(target, proto, callee); - if (createThis) - return createThis; - } + MDefinition *createThis = createThisScriptedSingleton(target, callee); + if (createThis) + return createThis; - MDefinition *createThis = createThisScripted(callee); - if (!createThis) - return NULL; - - // The native function case is already handled upfront. - // Here we can safely remove the native check for MCreateThis. - JS_ASSERT(createThis->isCreateThis()); - createThis->toCreateThis()->removeNativeCheck(); - - return createThis; + return createThisScripted(callee); } bool diff --git a/js/src/ion/IonBuilder.h b/js/src/ion/IonBuilder.h index c8a59d83bfc4..0a490503aa96 100644 --- a/js/src/ion/IonBuilder.h +++ b/js/src/ion/IonBuilder.h @@ -275,9 +275,8 @@ class IonBuilder : public MIRGenerator JSObject *getSingletonPrototype(JSFunction *target); - MDefinition *createThisNative(); MDefinition *createThisScripted(MDefinition *callee); - MDefinition *createThisScriptedSingleton(HandleFunction target, HandleObject proto, MDefinition *callee); + MDefinition *createThisScriptedSingleton(HandleFunction target, MDefinition *callee); MDefinition *createThis(HandleFunction target, MDefinition *callee); MInstruction *createDeclEnvObject(MDefinition *callee, MDefinition *scopeObj); MInstruction *createCallObject(MDefinition *callee, MDefinition *scopeObj); diff --git a/js/src/ion/LIR-Common.h b/js/src/ion/LIR-Common.h index 07f90291251c..b51f1c264911 100644 --- a/js/src/ion/LIR-Common.h +++ b/js/src/ion/LIR-Common.h @@ -432,6 +432,52 @@ class LToIdV : public LCallInstructionHelper } }; +// Allocate an object for |new| on the caller-side, +// when there is no templateObject or prototype known +class LCreateThis : public LCallInstructionHelper +{ + public: + LIR_HEADER(CreateThis) + + LCreateThis(const LAllocation &callee) + { + setOperand(0, callee); + } + + const LAllocation *getCallee() { + return getOperand(0); + } + + MCreateThis *mir() const { + return mir_->toCreateThis(); + } +}; + +// Allocate an object for |new| on the caller-side, +// when the prototype is known. +class LCreateThisWithProto : public LCallInstructionHelper<1, 2, 0> +{ + public: + LIR_HEADER(CreateThisWithProto) + + LCreateThisWithProto(const LAllocation &callee, const LAllocation &prototype) + { + setOperand(0, callee); + setOperand(1, prototype); + } + + const LAllocation *getCallee() { + return getOperand(0); + } + const LAllocation *getPrototype() { + return getOperand(1); + } + + MCreateThis *mir() const { + return mir_->toCreateThis(); + } +}; + // Allocate an object for |new| on the caller-side. // Always performs object initialization with a fast path. class LCreateThisWithTemplate : public LInstructionHelper<1, 0, 0> @@ -447,54 +493,6 @@ class LCreateThisWithTemplate : public LInstructionHelper<1, 0, 0> } }; -// Allocate an object for |new| on the caller-side, when there is no templateObject. -class LCreateThisV : public LCallInstructionHelper -{ - public: - LIR_HEADER(CreateThisV) - - LCreateThisV(const LAllocation &callee, const LAllocation &prototype) - { - setOperand(0, callee); - setOperand(1, prototype); - } - - const LAllocation *getCallee() { - return getOperand(0); - } - const LAllocation *getPrototype() { - return getOperand(1); - } - - MCreateThis *mir() const { - return mir_->toCreateThis(); - } -}; - -// Allocate an object for |new| on the caller-side, when there is no templateObject. -class LCreateThisO : public LCallInstructionHelper<1, 2, 0> -{ - public: - LIR_HEADER(CreateThisO) - - LCreateThisO(const LAllocation &callee, const LAllocation &prototype) - { - setOperand(0, callee); - setOperand(1, prototype); - } - - const LAllocation *getCallee() { - return getOperand(0); - } - const LAllocation *getPrototype() { - return getOperand(1); - } - - MCreateThis *mir() const { - return mir_->toCreateThis(); - } -}; - // If the Value is an Object, return unbox(Value). // Otherwise, return the other Object. class LReturnFromCtor : public LInstructionHelper<1, BOX_PIECES + 1, 0> diff --git a/js/src/ion/LOpcodes.h b/js/src/ion/LOpcodes.h index 8df6a3ec9bd7..a1dbecb5e3cf 100644 --- a/js/src/ion/LOpcodes.h +++ b/js/src/ion/LOpcodes.h @@ -39,8 +39,8 @@ _(ApplyArgsGeneric) \ _(StackArgT) \ _(StackArgV) \ - _(CreateThisV) \ - _(CreateThisO) \ + _(CreateThis) \ + _(CreateThisWithProto) \ _(CreateThisWithTemplate) \ _(ReturnFromCtor) \ _(BitNotI) \ diff --git a/js/src/ion/Lowering.cpp b/js/src/ion/Lowering.cpp index b791dbfcf4f6..47b79ec14d67 100644 --- a/js/src/ion/Lowering.cpp +++ b/js/src/ion/Lowering.cpp @@ -241,18 +241,19 @@ LIRGenerator::visitCreateThisWithTemplate(MCreateThisWithTemplate *ins) return define(lir, ins) && assignSafepoint(lir, ins); } +bool +LIRGenerator::visitCreateThisWithProto(MCreateThisWithProto *ins) +{ + LCreateThisWithProto *lir = + new LCreateThisWithProto(useRegisterOrConstantAtStart(ins->getCallee()), + useRegisterOrConstantAtStart(ins->getPrototype())); + return defineReturn(lir, ins) && assignSafepoint(lir, ins); +} + bool LIRGenerator::visitCreateThis(MCreateThis *ins) { - if (ins->needNativeCheck()) { - JS_ASSERT(ins->type() == MIRType_Value); - LCreateThisV *lir = new LCreateThisV(useRegisterAtStart(ins->getCallee()), - useRegisterOrConstantAtStart(ins->getPrototype())); - return defineReturn(lir, ins) && assignSafepoint(lir, ins); - } - - LCreateThisO *lir = new LCreateThisO(useRegisterOrConstantAtStart(ins->getCallee()), - useRegisterOrConstantAtStart(ins->getPrototype())); + LCreateThis *lir = new LCreateThis(useRegisterOrConstantAtStart(ins->getCallee())); return defineReturn(lir, ins) && assignSafepoint(lir, ins); } diff --git a/js/src/ion/Lowering.h b/js/src/ion/Lowering.h index bfbde745ee31..372f016a776b 100644 --- a/js/src/ion/Lowering.h +++ b/js/src/ion/Lowering.h @@ -91,6 +91,7 @@ class LIRGenerator : public LIRGeneratorSpecific bool visitPrepareCall(MPrepareCall *ins); bool visitPassArg(MPassArg *arg); bool visitCreateThisWithTemplate(MCreateThisWithTemplate *ins); + bool visitCreateThisWithProto(MCreateThisWithProto *ins); bool visitCreateThis(MCreateThis *ins); bool visitReturnFromCtor(MReturnFromCtor *ins); bool visitCall(MCall *call); diff --git a/js/src/ion/MIR.h b/js/src/ion/MIR.h index 2c20d0a1ad48..4b7f1d742a2c 100644 --- a/js/src/ion/MIR.h +++ b/js/src/ion/MIR.h @@ -1688,29 +1688,21 @@ class MCreateThisWithTemplate // Caller-side allocation of |this| for |new|: // Given a prototype operand, construct |this| for JSOP_NEW. -// For native constructors, returns MagicValue(JS_IS_CONSTRUCTING). -class MCreateThis - : public MAryInstruction<2>, +class MCreateThisWithProto + : public MBinaryInstruction, public MixPolicy, ObjectPolicy<1> > { - bool needNativeCheck_; - - MCreateThis(MDefinition *callee, MDefinition *prototype) - : needNativeCheck_(true) + MCreateThisWithProto(MDefinition *callee, MDefinition *prototype) + : MBinaryInstruction(callee, prototype) { - initOperand(0, callee); - initOperand(1, prototype); - - // Type is mostly object, except for native constructors - // therefore the need of Value type. - setResultType(MIRType_Value); + setResultType(MIRType_Object); } public: - INSTRUCTION_HEADER(CreateThis) - static MCreateThis *New(MDefinition *callee, MDefinition *prototype) + INSTRUCTION_HEADER(CreateThisWithProto) + static MCreateThisWithProto *New(MDefinition *callee, MDefinition *prototype) { - return new MCreateThis(callee, prototype); + return new MCreateThisWithProto(callee, prototype); } MDefinition *getCallee() const { @@ -1719,12 +1711,37 @@ class MCreateThis MDefinition *getPrototype() const { return getOperand(1); } - void removeNativeCheck() { - needNativeCheck_ = false; - setResultType(MIRType_Object); + + // Although creation of |this| modifies global state, it is safely repeatable. + AliasSet getAliasSet() const { + return AliasSet::None(); } - bool needNativeCheck() const { - return needNativeCheck_; + TypePolicy *typePolicy() { + return this; + } +}; + +// Caller-side allocation of |this| for |new|: +// Constructs |this| when possible, else MagicValue(JS_IS_CONSTRUCTING). +class MCreateThis + : public MUnaryInstruction, + public ObjectPolicy<0> +{ + MCreateThis(MDefinition *callee) + : MUnaryInstruction(callee) + { + setResultType(MIRType_Value); + } + + public: + INSTRUCTION_HEADER(CreateThis) + static MCreateThis *New(MDefinition *callee) + { + return new MCreateThis(callee); + } + + MDefinition *getCallee() const { + return getOperand(0); } // Although creation of |this| modifies global state, it is safely repeatable. diff --git a/js/src/ion/MOpcodes.h b/js/src/ion/MOpcodes.h index bddade367e82..c8e4724f0a44 100644 --- a/js/src/ion/MOpcodes.h +++ b/js/src/ion/MOpcodes.h @@ -31,6 +31,7 @@ namespace ion { _(DefVar) \ _(DefFun) \ _(CreateThis) \ + _(CreateThisWithProto) \ _(CreateThisWithTemplate) \ _(PrepareCall) \ _(PassArg) \ diff --git a/js/src/ion/VMFunctions.cpp b/js/src/ion/VMFunctions.cpp index 504da74f3849..745f6e3f4eae 100644 --- a/js/src/ion/VMFunctions.cpp +++ b/js/src/ion/VMFunctions.cpp @@ -437,18 +437,21 @@ NewStringObject(JSContext *cx, HandleString str) return StringObject::create(cx, str); } -bool SPSEnter(JSContext *cx, HandleScript script) +bool +SPSEnter(JSContext *cx, HandleScript script) { return cx->runtime->spsProfiler.enter(cx, script, script->function()); } -bool SPSExit(JSContext *cx, HandleScript script) +bool +SPSExit(JSContext *cx, HandleScript script) { cx->runtime->spsProfiler.exit(cx, script, script->function()); return true; } -bool OperatorIn(JSContext *cx, HandleValue key, HandleObject obj, JSBool *out) +bool +OperatorIn(JSContext *cx, HandleValue key, HandleObject obj, JSBool *out) { RootedValue dummy(cx); // Disregards atomization changes: no way to propagate. RootedId id(cx); @@ -464,10 +467,25 @@ bool OperatorIn(JSContext *cx, HandleValue key, HandleObject obj, JSBool *out) return true; } -bool GetIntrinsicValue(JSContext *cx, HandlePropertyName name, MutableHandleValue rval) +bool +GetIntrinsicValue(JSContext *cx, HandlePropertyName name, MutableHandleValue rval) { return cx->global()->getIntrinsicValue(cx, name, rval); } +bool +CreateThis(JSContext *cx, HandleObject callee, MutableHandleValue rval) +{ + rval.set(MagicValue(JS_IS_CONSTRUCTING)); + + if (callee->isFunction()) { + JSFunction *fun = callee->toFunction(); + if (fun->isInterpreted()) + rval.set(ObjectValue(*js_CreateThisForFunction(cx, callee, false))); + } + + return true; +} + } // namespace ion } // namespace js diff --git a/js/src/ion/VMFunctions.h b/js/src/ion/VMFunctions.h index 7e3f833dd1e4..e09e23d22611 100644 --- a/js/src/ion/VMFunctions.h +++ b/js/src/ion/VMFunctions.h @@ -464,6 +464,7 @@ bool OperatorIn(JSContext *cx, HandleValue key, HandleObject obj, JSBool *out); bool GetIntrinsicValue(JSContext *cx, HandlePropertyName name, MutableHandleValue rval); +bool CreateThis(JSContext *cx, HandleObject callee, MutableHandleValue rval); } // namespace ion } // namespace js diff --git a/js/src/jit-test/tests/ion/bug825705.js b/js/src/jit-test/tests/ion/bug825705.js new file mode 100644 index 000000000000..05689f6edec0 --- /dev/null +++ b/js/src/jit-test/tests/ion/bug825705.js @@ -0,0 +1,23 @@ +// Test 1: When constructing x, we shouldn't take the prototype for this. +// it will crash if that happens +evalcx("\ + var x = newGlobal().Object;\ + function f() { return new x; }\ + f();\ + f();\ +", newGlobal()); + +// Test 2: Don't take the prototype of proxy's to create |this|, +// as this will throw... Not expected behaviour. +var O = new Proxy(function() {}, { + get: function() { + throw "get trap"; + } +}); + +function f() { + new O(); +} + +f(); +f(); From 165c2513325a5b75c45a2284a79ed5c21cb23734 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 4 Jan 2013 17:14:33 +0100 Subject: [PATCH 025/180] Backout changeset 6656cdc8b20d (bug 824330) because of android and b2g bustage on clobber builds --- b2g/build.mk | 2 ++ browser/build.mk | 2 ++ mobile/android/confvars.sh | 3 +++ mobile/xul/build.mk | 4 ++++ services/crypto/Makefile.in | 2 -- toolkit/toolkit-tiers.mk | 2 +- xulrunner/confvars.sh | 6 ------ 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/b2g/build.mk b/b2g/build.mk index 87fdb931143d..f4213b064349 100644 --- a/b2g/build.mk +++ b/b2g/build.mk @@ -18,6 +18,8 @@ ifdef MOZ_EXTENSIONS tier_app_dirs += extensions endif +tier_app_dirs += services + tier_app_dirs += \ $(MOZ_BRANDING_DIRECTORY) \ b2g \ diff --git a/browser/build.mk b/browser/build.mk index 037515a4699f..1b572035bc72 100644 --- a/browser/build.mk +++ b/browser/build.mk @@ -14,6 +14,8 @@ endif tier_app_dirs += $(MOZ_BRANDING_DIRECTORY) +tier_app_dirs += services + ifdef MOZ_WEBAPP_RUNTIME tier_app_dirs += webapprt endif diff --git a/mobile/android/confvars.sh b/mobile/android/confvars.sh index 1f4cba4afd81..32274c916374 100755 --- a/mobile/android/confvars.sh +++ b/mobile/android/confvars.sh @@ -19,6 +19,9 @@ MOZ_DISABLE_DOMCRYPTO=1 # Enable getUserMedia MOZ_MEDIA_NAVIGATOR=1 +MOZ_SERVICES_COMMON=1 +MOZ_SERVICES_METRICS=1 + if test "$LIBXUL_SDK"; then MOZ_XULRUNNER=1 else diff --git a/mobile/xul/build.mk b/mobile/xul/build.mk index 41884e52bcfa..a5523222d8ee 100644 --- a/mobile/xul/build.mk +++ b/mobile/xul/build.mk @@ -21,6 +21,10 @@ ifdef MOZ_EXTENSIONS tier_app_dirs += extensions endif +ifdef MOZ_SERVICES_SYNC +tier_app_dirs += services +endif + tier_app_dirs += \ $(MOZ_BRANDING_DIRECTORY) \ mobile/xul \ diff --git a/services/crypto/Makefile.in b/services/crypto/Makefile.in index d26506ee309a..9e96c7ab0a13 100644 --- a/services/crypto/Makefile.in +++ b/services/crypto/Makefile.in @@ -22,6 +22,4 @@ INSTALL_TARGETS += CRYPTO_MODULE TEST_DIRS += tests -DIRS += component - include $(topsrcdir)/config/rules.mk diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index 69401f435d47..a9c8fadea564 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -260,7 +260,7 @@ ifdef MOZ_PREF_EXTENSIONS tier_platform_dirs += extensions/pref endif -tier_platform_dirs += services +tier_platform_dirs += services/crypto/component tier_platform_dirs += startupcache diff --git a/xulrunner/confvars.sh b/xulrunner/confvars.sh index 04b37d5e3603..5fe2c3d207c2 100755 --- a/xulrunner/confvars.sh +++ b/xulrunner/confvars.sh @@ -12,9 +12,3 @@ MOZ_APP_VERSION=$MOZILLA_VERSION MOZ_PLACES=1 MOZ_EXTENSIONS_DEFAULT=" gio" MOZ_URL_CLASSIFIER=1 -MOZ_SERVICES_AITC=1 -MOZ_SERVICES_COMMON=1 -MOZ_SERVICES_CRYPTO=1 -MOZ_SERVICES_METRICS=1 -MOZ_SERVICES_NOTIFICATIONS=1 -MOZ_SERVICES_SYNC=1 From dec2ab62ae45d756322b46d9749652abed2b6925 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 4 Jan 2013 00:20:57 -0800 Subject: [PATCH 026/180] bug 826584 - Increase event callback timeout for gum tests. r=jesup --- dom/media/tests/mochitest/test_getUserMedia_basicAudio.html | 2 +- dom/media/tests/mochitest/test_getUserMedia_basicVideo.html | 2 +- .../tests/mochitest/test_getUserMedia_basicVideoAudio.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html b/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html index e455e574064b..688813bb15e0 100644 --- a/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html +++ b/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html @@ -30,7 +30,7 @@ runTest(function () { navigator.mozGetUserMedia({audio: true, fake: true}, function(stream) { var testAudio = document.getElementById('testAudio'); var audioStreamPlayback = new MediaStreamPlayback(testAudio, stream); - audioStreamPlayback.playMedia(5000, function() { + audioStreamPlayback.playMedia(10000, function() { stream.stop(); SimpleTest.finish(); }, unexpectedCallbackAndFinish); diff --git a/dom/media/tests/mochitest/test_getUserMedia_basicVideo.html b/dom/media/tests/mochitest/test_getUserMedia_basicVideo.html index 3ccd48a6ce44..1e1d5625c49b 100644 --- a/dom/media/tests/mochitest/test_getUserMedia_basicVideo.html +++ b/dom/media/tests/mochitest/test_getUserMedia_basicVideo.html @@ -30,7 +30,7 @@ runTest(function () { navigator.mozGetUserMedia({video: true, fake: true}, function(stream) { var testVideo = document.getElementById('testVideo'); var videoStreamPlayback = new MediaStreamPlayback(testVideo, stream); - videoStreamPlayback.playMedia(5000, function() { + videoStreamPlayback.playMedia(10000, function() { stream.stop(); SimpleTest.finish(); }, unexpectedCallbackAndFinish); diff --git a/dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html b/dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html index 9e736c26417e..9e1c13170204 100644 --- a/dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html +++ b/dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html @@ -32,7 +32,7 @@ runTest(function () { var testVideoAudio = document.getElementById('testVideoAudio'); var videoAudioStreamPlayback = new MediaStreamPlayback(testVideoAudio, stream); - videoAudioStreamPlayback.playMedia(5000, function() { + videoAudioStreamPlayback.playMedia(10000, function() { stream.stop(); SimpleTest.finish(); }, unexpectedCallbackAndFinish); From e6faca59c7b546cd0ce4113a32e8282c92695a07 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 4 Jan 2013 06:54:59 -0800 Subject: [PATCH 027/180] bug 826584 - remove canplaythrough event listener if we timeout. r=jesup --- dom/media/tests/mochitest/mediaStreamPlayback.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dom/media/tests/mochitest/mediaStreamPlayback.js b/dom/media/tests/mochitest/mediaStreamPlayback.js index 629cd1fdc81c..a48b8b0608c2 100644 --- a/dom/media/tests/mochitest/mediaStreamPlayback.js +++ b/dom/media/tests/mochitest/mediaStreamPlayback.js @@ -118,6 +118,8 @@ function MediaStreamPlayback(mediaElement, mediaStream) { // If canplaythrough doesn't fire in enough time, we fail the test setTimeout(function() { if(!canPlayThroughFired) { + self.mediaElement.removeEventListener('canplaythrough', + canPlayThroughCallback, false); ok(false, "canplaythrough event never fired"); onError(); } From 9472b76aa924e6f330a4ad8cece2b43600425bb2 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 4 Jan 2013 17:42:34 +0100 Subject: [PATCH 028/180] Bug 826115 - Remove noisy NS_ENSURE_TRUE(rollupWidget, false) from nsWindow.cpp r=jimm --- widget/windows/nsWindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index ac43909479f3..a88cbf3e027f 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -8032,7 +8032,8 @@ nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLPara nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener(); NS_ENSURE_TRUE(rollupListener, false); nsCOMPtr rollupWidget = rollupListener->GetRollupWidget(); - NS_ENSURE_TRUE(rollupWidget, false); + if (!rollupWidget) + return false; inMsg = WinUtils::GetNativeMessage(inMsg); if (inMsg == WM_LBUTTONDOWN || inMsg == WM_RBUTTONDOWN || inMsg == WM_MBUTTONDOWN || From adadf55141eb3e48c2fdaa0894048aa1ee5e0d26 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 4 Jan 2013 12:02:13 -0500 Subject: [PATCH 029/180] Bug 826423. Fix SpecialPowers.wrap() to reliably detect Xrays. r=peterv --- js/xpconnect/idl/xpccomponents.idl | 4 +++- js/xpconnect/src/XPCComponents.cpp | 8 ++++++++ testing/specialpowers/content/specialpowersAPI.js | 8 +------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/js/xpconnect/idl/xpccomponents.idl b/js/xpconnect/idl/xpccomponents.idl index 6aa470fa082c..3b71dddc9af2 100644 --- a/js/xpconnect/idl/xpccomponents.idl +++ b/js/xpconnect/idl/xpccomponents.idl @@ -118,7 +118,7 @@ interface ScheduledGCCallback : nsISupports /** * interface of Components.utils */ -[scriptable, uuid(50799877-9ddc-4784-8a58-da7366c1368f)] +[scriptable, uuid(0d0fd2f7-3250-4092-9340-ca9bcb7be470)] interface nsIXPCComponents_Utils : nsISupports { @@ -404,6 +404,8 @@ interface nsIXPCComponents_Utils : nsISupports [implicit_jscontext] void nukeSandbox(in jsval obj); + + bool isXrayWrapper(in jsval obj); }; /** diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 20b226713c6c..5ff63d435be1 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -4514,6 +4514,14 @@ nsXPCComponents_Utils::NukeSandbox(const JS::Value &obj, JSContext *cx) return NS_OK; } +NS_IMETHODIMP +nsXPCComponents_Utils::IsXrayWrapper(const JS::Value &obj, bool* aRetval) +{ + *aRetval = + obj.isObject() && xpc::WrapperFactory::IsXrayWrapper(&obj.toObject()); + return NS_OK; +} + /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index b2ea482de6f1..3d91ba9f3f32 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -90,13 +90,7 @@ function unwrapIfWrapped(x) { }; function isXrayWrapper(x) { - try { - return /XrayWrapper/.exec(x.toString()); - } catch(e) { - // The toString() implementation could theoretically throw. But it never - // throws for Xray, so we can just assume non-xray in that case. - return false; - } + return Cu.isXrayWrapper(x); } function callGetOwnPropertyDescriptor(obj, name) { From 76c95fb6ab1c02a62e2c771b0a9bb9f6f153ba42 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 4 Jan 2013 12:02:13 -0500 Subject: [PATCH 030/180] Bug 824823 part 0. Fix a test to keep using an XPCWrappedNative element for now until bug 825053 is fixed. Verbal r=peterv --- js/xpconnect/tests/mochitest/test_bug655297.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/xpconnect/tests/mochitest/test_bug655297.html b/js/xpconnect/tests/mochitest/test_bug655297.html index 88e5c9fc41a3..c1aa879964c2 100644 --- a/js/xpconnect/tests/mochitest/test_bug655297.html +++ b/js/xpconnect/tests/mochitest/test_bug655297.html @@ -14,8 +14,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=655297 -

0

1

2

3

4

-

5

6

7

8

9

+
0
1
2
3
4
+
5
6
7
8
9
 
+    
+  
+  
+    
+  
+

From 05ca34ae175de73aade38eef4e58ae8a95b1a5e1 Mon Sep 17 00:00:00 2001
From: Benoit Girard 
Date: Fri, 4 Jan 2013 12:49:36 -0500
Subject: [PATCH 051/180] Bug 787513 - Give the proper update rectangle for
 NPAPI for CoreGraphics plugins on mac. r=smichaud

---
 dom/plugins/ipc/PluginUtilsOSX.mm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dom/plugins/ipc/PluginUtilsOSX.mm b/dom/plugins/ipc/PluginUtilsOSX.mm
index d5cb006eb3c4..8e3ea026262f 100644
--- a/dom/plugins/ipc/PluginUtilsOSX.mm
+++ b/dom/plugins/ipc/PluginUtilsOSX.mm
@@ -106,6 +106,8 @@ CGBitmapContextSetDataFunc CGBitmapContextSetDataPtr = NULL;
   ::CGContextTranslateCTM(aCGContext, 0, self.bounds.size.height);
   ::CGContextScaleCTM(aCGContext, (CGFloat) 1, (CGFloat) -1);
 
+  mUpdateRect = nsIntRect(0, 0, self.bounds.size.width, self.bounds.size.height);
+
   mDrawFunc(aCGContext, mPluginInstance, mUpdateRect);
 
   ::CGContextRestoreGState(aCGContext);

From c923e88653095e7f9f282f52c8c1ac602ba38cbb Mon Sep 17 00:00:00 2001
From: Andres Hernandez 
Date: Fri, 4 Jan 2013 10:05:32 -0600
Subject: [PATCH 052/180] Bug 824493 - Intermittent timeout in
 test_sts_privatebrowsing_perwindowpb.html; r=ehsan

---
 .../test_sts_privatebrowsing_perwindowpb.html      | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html b/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html
index a84d56be35b0..ef8a21ceb64d 100644
--- a/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html
+++ b/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html
@@ -29,6 +29,8 @@
     rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor).
     getInterface(Ci.nsIDOMWindow);
 
+  SpecialPowers.Services.prefs.setIntPref("browser.startup.page", 0);
+
   var testframes = {
     'samedom':
       {'url':     "http://example.com" + STSPATH + "/verify.sjs",
@@ -56,12 +58,12 @@
     var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
     win.addEventListener("load", function onLoad() {
       win.removeEventListener("load", onLoad, false);
-      win.addEventListener("DOMContentLoaded", function onInnerLoad() {
-        if (win.content.location.href == "about:privatebrowsing") {
+      win.gBrowser.addEventListener("DOMContentLoaded", function onInnerLoad() {
+        if (win.content.location.href != CONTENT_PAGE) {
           win.gBrowser.loadURI(CONTENT_PAGE);
           return;
         }
-        win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
+        win.gBrowser.removeEventListener("DOMContentLoaded", onInnerLoad, true);
         SimpleTest.executeSoon(function() { aCallback(win); });
       }, true);
       win.gBrowser.loadURI(CONTENT_PAGE);
@@ -216,8 +218,12 @@
     test_sts_after_exiting_private_mode
   ];
 
+  function finish() {
+    SpecialPowers.Services.prefs.clearUserPref("browser.startup.page")
+    SimpleTest.finish();
+  }
   function nextTest() {
-    SimpleTest.executeSoon(tests.length ? tests.shift() : SimpleTest.finish);
+    SimpleTest.executeSoon(tests.length ? tests.shift() : finish);
   }
   window.addEventListener('load', nextTest, false);
   

From a70aae143aaf488b8603752690f7ae7b682a8e12 Mon Sep 17 00:00:00 2001
From: Chris Peterson 
Date: Wed, 2 Jan 2013 16:33:46 -0800
Subject: [PATCH 053/180] Bug 826120 - mach's warning parser should not stop at
 first '['. r=gps

--HG--
extra : rebase_source : b752099f4f6da4ea05220f8120a5518ee39994ed
---
 python/mozbuild/mozbuild/compilation/warnings.py           | 2 +-
 python/mozbuild/mozbuild/test/compilation/test_warnings.py | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/python/mozbuild/mozbuild/compilation/warnings.py b/python/mozbuild/mozbuild/compilation/warnings.py
index 0f2e95494530..a538943d6f85 100644
--- a/python/mozbuild/mozbuild/compilation/warnings.py
+++ b/python/mozbuild/mozbuild/compilation/warnings.py
@@ -27,7 +27,7 @@ RE_CLANG_WARNING = re.compile(r"""
     (?P\d+)
     :
     \swarning:\s
-    (?P[^\[]+)
+    (?P.+)
     \[(?P[^\]]+)
     """, re.X)
 
diff --git a/python/mozbuild/mozbuild/test/compilation/test_warnings.py b/python/mozbuild/mozbuild/test/compilation/test_warnings.py
index ba39261e36fb..ab59ac9fa0dd 100644
--- a/python/mozbuild/mozbuild/test/compilation/test_warnings.py
+++ b/python/mozbuild/mozbuild/test/compilation/test_warnings.py
@@ -14,7 +14,11 @@ from mozbuild.compilation.warnings import WarningsDatabase
 
 CLANG_TESTS = [
     ('foobar.cpp:123:10: warning: you messed up [-Wfoo]',
-     'foobar.cpp', 123, 10, 'you messed up', '-Wfoo')
+     'foobar.cpp', 123, 10, 'you messed up', '-Wfoo'),
+    ("c_locale_dummy.c:457:1: warning: (near initialization for "
+     "'full_wmonthname[0]') [-Wpointer-sign]",
+     'c_locale_dummy.c', 457, 1,
+     "(near initialization for 'full_wmonthname[0]')", '-Wpointer-sign')
 ]
 
 MSVC_TESTS = [

From 1e64862110600a5cdc50bb9c41d116011074bb8b Mon Sep 17 00:00:00 2001
From: Chris Peterson 
Date: Wed, 2 Jan 2013 14:49:09 -0800
Subject: [PATCH 054/180] Bug 826144 - Add MOZ_UTF16_HELPER() intermediary
 macro to handle UTF-16 stringification and concatenation correctly. r=waldo

--HG--
extra : rebase_source : 4c68df10e6e59af34db1e325232d4671492cc72f
---
 mfbt/Char16.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/mfbt/Char16.h b/mfbt/Char16.h
index bc2835c3d40f..c6f9f87d4413 100644
--- a/mfbt/Char16.h
+++ b/mfbt/Char16.h
@@ -28,17 +28,27 @@
     * expressions (and pass char16_t pointers to Windows APIs). We #define our
     * char16_t as a macro to override yval.h's typedef of the same name.
     */
-#  define MOZ_UTF16(s) L##s
+#  define MOZ_UTF16_HELPER(s) L##s
 #  include 
 #  define char16_t wchar_t
 #elif defined(__cplusplus) && \
       (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
    /* C++11 has a builtin char16_t type. */
-#  define MOZ_UTF16(s) u##s
+#  define MOZ_UTF16_HELPER(s) u##s
 #else
 #  error "Char16.h requires C++11 (or something like it) for UTF-16 support."
 #endif
 
+/*
+ * Macro arguments used in concatenation or stringification won't be expanded.
+ * Therefore, in order for |MOZ_UTF16(FOO)| to work as expected (which is to
+ * expand |FOO| before doing whatever |MOZ_UTF16| needs to do to it) a helper
+ * macro, |MOZ_UTF16_HELPER| needs to be inserted in between to allow the macro
+ * argument to expand. See "3.10.6 Separate Expansion of Macro Arguments" of the
+ * CPP manual for a more accurate and precise explanation.
+ */
+#define MOZ_UTF16(s) MOZ_UTF16_HELPER(s)
+
 MOZ_STATIC_ASSERT(sizeof(char16_t) == 2, "Is char16_t type 16 bits?");
 MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16('A')) == 2, "Is char literal 16 bits?");
 MOZ_STATIC_ASSERT(sizeof(MOZ_UTF16("")[0]) == 2, "Is string char 16 bits?");

From a1270138396ac4be324e25454c5282c5b5629c73 Mon Sep 17 00:00:00 2001
From: Jeff Walden 
Date: Thu, 3 Jan 2013 15:31:36 -0600
Subject: [PATCH 055/180] Bug 826447 - Change all the proxy API signatures to
 take unsigned flags, rather than bool set, so that it's easier to find all
 tests of JSRESOLVE_ASSIGNING.  r=bz

--HG--
extra : rebase_source : 3b88b411965087984d7973a90f8fa1b06457a6ce
---
 dom/bindings/BindingUtils.cpp                 |  6 +-
 dom/bindings/BindingUtils.h                   |  2 +-
 dom/bindings/Codegen.py                       | 17 ++--
 dom/bindings/DOMJSClass.h                     |  2 +-
 dom/bindings/DOMJSProxyHandler.cpp            |  6 +-
 dom/bindings/DOMJSProxyHandler.h              | 16 ++--
 js/src/builtin/Object.cpp                     |  4 +-
 js/src/jsapi.cpp                              |  6 +-
 js/src/jsobj.cpp                              |  4 +-
 js/src/jsproxy.cpp                            | 77 +++++++++---------
 js/src/jsproxy.h                              | 25 +++---
 js/src/jswrapper.cpp                          | 34 ++++----
 js/src/jswrapper.h                            | 24 +++---
 js/src/shell/js.cpp                           |  2 +-
 js/src/vm/ScopeObject.cpp                     | 10 +--
 js/xpconnect/src/XPCComponents.cpp            | 14 ++--
 js/xpconnect/wrappers/ChromeObjectWrapper.cpp | 14 ++--
 js/xpconnect/wrappers/ChromeObjectWrapper.h   |  6 +-
 js/xpconnect/wrappers/FilteringWrapper.cpp    |  9 ++-
 js/xpconnect/wrappers/FilteringWrapper.h      |  4 +-
 js/xpconnect/wrappers/WaiveXrayWrapper.cpp    |  8 +-
 js/xpconnect/wrappers/WaiveXrayWrapper.h      |  4 +-
 js/xpconnect/wrappers/XrayWrapper.cpp         | 81 +++++++++----------
 js/xpconnect/wrappers/XrayWrapper.h           | 15 ++--
 24 files changed, 191 insertions(+), 199 deletions(-)

diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp
index 31d119b4a61d..3d328047470c 100644
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -611,15 +611,15 @@ GetNativePropertyHooks(JSContext *cx, JSObject *obj, DOMObjectType& type)
 
 bool
 XrayResolveOwnProperty(JSContext* cx, JSObject* wrapper, JSObject* obj, jsid id,
-                       bool set, JSPropertyDescriptor* desc)
+                       JSPropertyDescriptor* desc, unsigned flags)
 {
   DOMObjectType type;
   const NativePropertyHooks *nativePropertyHooks =
     GetNativePropertyHooks(cx, obj, type);
 
   return type != eInstance || !nativePropertyHooks->mResolveOwnProperty ||
-         nativePropertyHooks->mResolveOwnProperty(cx, wrapper, obj, id, set,
-                                                  desc);
+         nativePropertyHooks->mResolveOwnProperty(cx, wrapper, obj, id, desc,
+                                                  flags);
 }
 
 static bool
diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h
index 609fd68f75c9..7ccdd65e7dcd 100644
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -1575,7 +1575,7 @@ AddStringToIDVector(JSContext* cx, JS::AutoIdVector& vector, const char* name)
  */
 bool
 XrayResolveOwnProperty(JSContext* cx, JSObject* wrapper, JSObject* obj,
-                       jsid id, bool set, JSPropertyDescriptor* desc);
+                       jsid id, JSPropertyDescriptor* desc, unsigned flags);
 
 /**
  * This resolves operations, attributes and constants of the interfaces for obj.
diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py
index 1a7e063d5618..ebbd58208368 100644
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5599,13 +5599,13 @@ class CGResolveOwnProperty(CGAbstractMethod):
     def __init__(self, descriptor):
         args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'wrapper'),
                 Argument('JSObject*', 'obj'), Argument('jsid', 'id'),
-                Argument('bool', 'set'),
-                Argument('JSPropertyDescriptor*', 'desc')]
+                Argument('JSPropertyDescriptor*', 'desc'), Argument('unsigned', 'flags'),
+                ]
         CGAbstractMethod.__init__(self, descriptor, "ResolveOwnProperty", "bool", args)
     def definition_body(self):
         return """  // We rely on getOwnPropertyDescriptor not shadowing prototype properties by named
   // properties. If that changes we'll need to filter here.
-  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, set, desc);
+  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc, flags);
 """
 
 class CGEnumerateOwnProperties(CGAbstractMethod):
@@ -5862,8 +5862,8 @@ class CGDOMJSProxyHandler_CGDOMJSProxyHandler(ClassConstructor):
 class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
     def __init__(self, descriptor):
         args = [Argument('JSContext*', 'cx'), Argument('JSObject*', 'proxy'),
-                Argument('jsid', 'id'), Argument('bool', 'set'),
-                Argument('JSPropertyDescriptor*', 'desc')]
+                Argument('jsid', 'id'),
+                Argument('JSPropertyDescriptor*', 'desc'), Argument('unsigned', 'flags')]
         ClassMethod.__init__(self, "getOwnPropertyDescriptor", "bool", args)
         self.descriptor = descriptor
     def getBody(self):
@@ -5882,7 +5882,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
                    "}\n") % (self.descriptor.nativeType)
 
         if indexedSetter or self.descriptor.operations['NamedSetter']:
-            setOrIndexedGet += "if (set) {\n"
+            setOrIndexedGet += "if (flags & JSRESOLVE_ASSIGNING) {\n"
             if indexedSetter:
                 setOrIndexedGet += ("  if (IsArrayIndex(index)) {\n")
                 if not 'IndexedCreator' in self.descriptor.operations:
@@ -5912,7 +5912,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
                                     "}")
             setOrIndexedGet += "\n\n"
         elif indexedGetter:
-            setOrIndexedGet += ("if (!set) {\n" +
+            setOrIndexedGet += ("if (!(flags & JSRESOLVE_ASSIGNING)) {\n" +
                                 CGIndenter(CGGeneric(get)).define() +
                                 "}\n\n")
 
@@ -5924,7 +5924,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
             # Once we start supporting OverrideBuiltins we need to make
             # ResolveOwnProperty or EnumerateOwnProperties filter out named
             # properties that shadow prototype properties.
-            condition = "!set && !HasPropertyOnPrototype(cx, proxy, this, id)"
+            condition = "!(flags & JSRESOLVE_ASSIGNING) && !HasPropertyOnPrototype(cx, proxy, this, id)"
             if self.descriptor.supportsIndexedProperties():
                 condition = "!IsArrayIndex(index) && " + condition
             namedGet = ("\n" +
@@ -5936,7 +5936,6 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(ClassMethod):
 
         return setOrIndexedGet + """JSObject* expando;
 if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
-  unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0);
   if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc)) {
     return false;
   }
diff --git a/dom/bindings/DOMJSClass.h b/dom/bindings/DOMJSClass.h
index c4c013476e99..cc08a8221a32 100644
--- a/dom/bindings/DOMJSClass.h
+++ b/dom/bindings/DOMJSClass.h
@@ -50,7 +50,7 @@ namespace dom {
 
 typedef bool
 (* ResolveOwnProperty)(JSContext* cx, JSObject* wrapper, JSObject* obj, jsid id,
-                       bool set, JSPropertyDescriptor* desc);
+                       JSPropertyDescriptor* desc, unsigned flags);
 
 typedef bool
 (* EnumerateOwnProperties)(JSContext* cx, JSObject* wrapper, JSObject* obj,
diff --git a/dom/bindings/DOMJSProxyHandler.cpp b/dom/bindings/DOMJSProxyHandler.cpp
index 34de291441cb..ea1ac97b1fe5 100644
--- a/dom/bindings/DOMJSProxyHandler.cpp
+++ b/dom/bindings/DOMJSProxyHandler.cpp
@@ -76,10 +76,10 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JSObject* obj)
 }
 
 bool
-DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JSObject* proxy, jsid id, bool set,
-                                       JSPropertyDescriptor* desc)
+DOMProxyHandler::getPropertyDescriptor(JSContext* cx, JSObject* proxy, jsid id,
+                                       JSPropertyDescriptor* desc, unsigned flags)
 {
-  if (!getOwnPropertyDescriptor(cx, proxy, id, set, desc)) {
+  if (!getOwnPropertyDescriptor(cx, proxy, id, desc, flags)) {
     return false;
   }
   if (desc->obj) {
diff --git a/dom/bindings/DOMJSProxyHandler.h b/dom/bindings/DOMJSProxyHandler.h
index a689bfd2fd15..0045d13aff6a 100644
--- a/dom/bindings/DOMJSProxyHandler.h
+++ b/dom/bindings/DOMJSProxyHandler.h
@@ -6,12 +6,14 @@
 #ifndef mozilla_dom_DOMJSProxyHandler_h
 #define mozilla_dom_DOMJSProxyHandler_h
 
+#include "mozilla/Attributes.h"
+#include "mozilla/Likely.h"
+
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "jsproxy.h"
 #include "xpcpublic.h"
 #include "nsStringGlue.h"
-#include "mozilla/Likely.h"
 
 #define DOM_PROXY_OBJECT_SLOT js::JSSLOT_PROXY_PRIVATE
 
@@ -34,14 +36,14 @@ public:
   {
   }
 
-  bool getPropertyDescriptor(JSContext* cx, JSObject* proxy, jsid id, bool set,
-                             JSPropertyDescriptor* desc);
+  bool getPropertyDescriptor(JSContext* cx, JSObject* proxy, jsid id, JSPropertyDescriptor* desc,
+                             unsigned flags) MOZ_OVERRIDE;
   bool defineProperty(JSContext* cx, JSObject* proxy, jsid id,
-                      JSPropertyDescriptor* desc);
-  bool delete_(JSContext* cx, JSObject* proxy, jsid id, bool* bp);
-  bool enumerate(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props);
+                      JSPropertyDescriptor* desc) MOZ_OVERRIDE;
+  bool delete_(JSContext* cx, JSObject* proxy, jsid id, bool* bp) MOZ_OVERRIDE;
+  bool enumerate(JSContext* cx, JSObject* proxy, JS::AutoIdVector& props) MOZ_OVERRIDE;
   bool fix(JSContext* cx, JSObject* proxy, JS::Value* vp);
-  bool has(JSContext* cx, JSObject* proxy, jsid id, bool* bp);
+  bool has(JSContext* cx, JSObject* proxy, jsid id, bool* bp) MOZ_OVERRIDE;
   using js::BaseProxyHandler::obj_toString;
 
   static JSObject* GetExpandoObject(JSObject* obj)
diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp
index 9fddbb8957ba..ecd9f4769cc6 100644
--- a/js/src/builtin/Object.cpp
+++ b/js/src/builtin/Object.cpp
@@ -446,7 +446,7 @@ obj_lookupGetter(JSContext *cx, unsigned argc, Value *vp)
         // native. Handle proxies separately.
         args.rval().setUndefined();
         AutoPropertyDescriptorRooter desc(cx);
-        if (!Proxy::getPropertyDescriptor(cx, obj, id, false, &desc))
+        if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc, 0))
             return JS_FALSE;
         if (desc.obj && (desc.attrs & JSPROP_GETTER) && desc.getter)
             args.rval().set(CastAsObjectJsval(desc.getter));
@@ -482,7 +482,7 @@ obj_lookupSetter(JSContext *cx, unsigned argc, Value *vp)
         // native. Handle proxies separately.
         args.rval().setUndefined();
         AutoPropertyDescriptorRooter desc(cx);
-        if (!Proxy::getPropertyDescriptor(cx, obj, id, false, &desc))
+        if (!Proxy::getPropertyDescriptor(cx, obj, id, &desc, 0))
             return JS_FALSE;
         if (desc.obj && (desc.attrs & JSPROP_SETTER) && desc.setter)
             args.rval().set(CastAsObjectJsval(desc.setter));
diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
index 53b0a4fc7d41..c02b86f58452 100644
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3574,7 +3574,7 @@ LookupResult(JSContext *cx, HandleObject obj, HandleObject obj2, jsid id,
             return js_GetDenseArrayElementValue(cx, obj2, id, vp);
         if (obj2->isProxy()) {
             AutoPropertyDescriptorRooter desc(cx);
-            if (!Proxy::getPropertyDescriptor(cx, obj2, id, false, &desc))
+            if (!Proxy::getPropertyDescriptor(cx, obj2, id, &desc, 0))
                 return false;
             if (!(desc.attrs & JSPROP_SHARED)) {
                 *vp = desc.value;
@@ -4058,8 +4058,8 @@ GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned
         if (obj2->isProxy()) {
             JSAutoResolveFlags rf(cx, flags);
             return own
-                   ? Proxy::getOwnPropertyDescriptor(cx, obj2, id, false, desc)
-                   : Proxy::getPropertyDescriptor(cx, obj2, id, false, desc);
+                   ? Proxy::getOwnPropertyDescriptor(cx, obj2, id, desc, 0)
+                   : Proxy::getPropertyDescriptor(cx, obj2, id, desc, 0);
         }
         if (!JSObject::getGenericAttributes(cx, obj2, id, &desc->attrs))
             return false;
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index d2003e74012d..4a809b0acf96 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -257,7 +257,7 @@ js::GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, HandleId id,
 {
     // FIXME: Call TrapGetOwnProperty directly once ScriptedIndirectProxies is removed
     if (obj->isProxy())
-        return Proxy::getOwnPropertyDescriptor(cx, obj, id, false, desc);
+        return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc, 0);
 
     RootedObject pobj(cx);
     RootedShape shape(cx);
@@ -3610,7 +3610,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receive
         if (!pobj->isNative()) {
             if (pobj->isProxy()) {
                 AutoPropertyDescriptorRooter pd(cx);
-                if (!Proxy::getPropertyDescriptor(cx, pobj, id, true, &pd))
+                if (!Proxy::getPropertyDescriptor(cx, pobj, id, &pd, JSRESOLVE_ASSIGNING))
                     return false;
 
                 if ((pd.attrs & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
diff --git a/js/src/jsproxy.cpp b/js/src/jsproxy.cpp
index 66602f23c006..3d07c14d6a39 100644
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -63,7 +63,7 @@ bool
 BaseProxyHandler::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
 {
     AutoPropertyDescriptorRooter desc(cx);
-    if (!getPropertyDescriptor(cx, proxy, id, false, &desc))
+    if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
         return false;
     *bp = !!desc.obj;
     return true;
@@ -73,7 +73,7 @@ bool
 BaseProxyHandler::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp)
 {
     AutoPropertyDescriptorRooter desc(cx);
-    if (!getOwnPropertyDescriptor(cx, proxy, id, false, &desc))
+    if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
         return false;
     *bp = !!desc.obj;
     return true;
@@ -86,7 +86,7 @@ BaseProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver_, jsid
     RootedId id(cx, id_);
 
     AutoPropertyDescriptorRooter desc(cx);
-    if (!getPropertyDescriptor(cx, proxy, id, false, &desc))
+    if (!getPropertyDescriptor(cx, proxy, id, &desc, 0))
         return false;
     if (!desc.obj) {
         vp->setUndefined();
@@ -143,7 +143,7 @@ BaseProxyHandler::set(JSContext *cx, JSObject *proxy_, JSObject *receiver_, jsid
     RootedId id(cx, id_);
 
     AutoPropertyDescriptorRooter desc(cx);
-    if (!getOwnPropertyDescriptor(cx, proxy, id, true, &desc))
+    if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, JSRESOLVE_ASSIGNING))
         return false;
     /* The control-flow here differs from ::get() because of the fall-through case below. */
     if (desc.obj) {
@@ -173,7 +173,7 @@ BaseProxyHandler::set(JSContext *cx, JSObject *proxy_, JSObject *receiver_, jsid
         desc.value = *vp;
         return defineProperty(cx, receiver, id, &desc);
     }
-    if (!getPropertyDescriptor(cx, proxy, id, true, &desc))
+    if (!getPropertyDescriptor(cx, proxy, id, &desc, JSRESOLVE_ASSIGNING))
         return false;
     if (desc.obj) {
         // Check for read-only properties.
@@ -226,7 +226,7 @@ BaseProxyHandler::keys(JSContext *cx, JSObject *proxy, AutoIdVector &props)
     for (size_t j = 0, len = props.length(); j < len; j++) {
         JS_ASSERT(i <= j);
         jsid id = props[j];
-        if (!getOwnPropertyDescriptor(cx, proxy, id, false, &desc))
+        if (!getOwnPropertyDescriptor(cx, proxy, id, &desc, 0))
             return false;
         if (desc.obj && (desc.attrs & JSPROP_ENUMERATE))
             props[i++] = id;
@@ -375,8 +375,7 @@ BaseProxyHandler::getPrototypeOf(JSContext *cx, JSObject *proxy, JSObject **prot
 
 bool
 DirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy,
-                                          jsid id, bool set,
-                                          PropertyDescriptor *desc)
+                                          jsid id, PropertyDescriptor *desc, unsigned flags)
 {
     RootedObject target(cx, GetProxyTargetObject(proxy));
     return JS_GetPropertyDescriptorById(cx, target, id, 0, desc);
@@ -389,9 +388,7 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, jsid id, unsigned flag
     // If obj is a proxy, we can do better than just guessing. This is
     // important for certain types of wrappers that wrap other wrappers.
     if (obj->isProxy())
-        return Proxy::getOwnPropertyDescriptor(cx, obj, id,
-                                               flags & JSRESOLVE_ASSIGNING,
-                                               desc);
+        return Proxy::getOwnPropertyDescriptor(cx, obj, id, desc, flags);
 
     if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc))
         return false;
@@ -402,8 +399,7 @@ GetOwnPropertyDescriptor(JSContext *cx, HandleObject obj, jsid id, unsigned flag
 
 bool
 DirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
-                                             jsid id, bool set,
-                                             PropertyDescriptor *desc)
+                                             jsid id, PropertyDescriptor *desc, unsigned flags)
 {
     RootedObject target(cx, GetProxyTargetObject(proxy));
     return GetOwnPropertyDescriptor(cx, target, id, 0, desc);
@@ -723,10 +719,10 @@ class ScriptedIndirectProxyHandler : public BaseProxyHandler {
     virtual ~ScriptedIndirectProxyHandler();
 
     /* ES5 Harmony fundamental proxy traps. */
-    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
-    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
+    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
+                                       PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
+    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
+                                          PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
                                 PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props);
@@ -785,8 +781,8 @@ GetIndirectProxyHandlerObject(JSObject *proxy)
 }
 
 bool
-ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_, bool set,
-                                                    PropertyDescriptor *desc)
+ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_,
+                                                    PropertyDescriptor *desc, unsigned flags)
 {
     RootedId id(cx, id_);
     RootedObject proxy(cx, proxy_);
@@ -800,8 +796,8 @@ ScriptedIndirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *pro
 }
 
 bool
-ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_, bool set,
-                                                       PropertyDescriptor *desc)
+ScriptedIndirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_,
+                                                       PropertyDescriptor *desc, unsigned flags)
 {
     RootedId id(cx, id_);
     RootedObject proxy(cx, proxy_);
@@ -1002,10 +998,10 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
     virtual ~ScriptedDirectProxyHandler();
 
     /* ES5 Harmony fundamental proxy traps. */
-    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
-    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
+    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
+                                       PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
+    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
+                                          PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
                                 PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props);
@@ -1571,7 +1567,7 @@ ScriptedDirectProxyHandler::~ScriptedDirectProxyHandler()
 // FIXME: Move to Proxy::getPropertyDescriptor once ScriptedIndirectProxy is removed
 bool
 ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_,
-                                                  bool set, PropertyDescriptor *desc)
+                                                  PropertyDescriptor *desc, unsigned flags)
 {
     JS_CHECK_RECURSION(cx, return false);
     Rooted proxy(cx, proxy_);
@@ -1592,7 +1588,7 @@ ScriptedDirectProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy
 
 bool
 ScriptedDirectProxyHandler::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_,
-                                                     bool set, PropertyDescriptor *desc)
+                                                     PropertyDescriptor *desc, unsigned flags)
 {
     RootedObject proxy(cx, proxy_);
     RootedId id(cx, id_);
@@ -2197,16 +2193,16 @@ ScriptedDirectProxyHandler ScriptedDirectProxyHandler::singleton;
 
 
 bool
-Proxy::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_, bool set,
-                             PropertyDescriptor *desc)
+Proxy::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_, PropertyDescriptor *desc,
+                             unsigned flags)
 {
     JS_CHECK_RECURSION(cx, return false);
     RootedObject proxy(cx, proxy_);
     RootedId id(cx, id_);
     BaseProxyHandler *handler = GetProxyHandler(proxy);
     if (!handler->hasPrototype())
-        return handler->getPropertyDescriptor(cx, proxy, id, set, desc);
-    if (!handler->getOwnPropertyDescriptor(cx, proxy, id, set, desc))
+        return handler->getPropertyDescriptor(cx, proxy, id, desc, flags);
+    if (!handler->getOwnPropertyDescriptor(cx, proxy, id, desc, flags))
         return false;
     if (desc->obj)
         return true;
@@ -2215,31 +2211,32 @@ Proxy::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id_, bool set
 }
 
 bool
-Proxy::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id, bool set, Value *vp)
+Proxy::getPropertyDescriptor(JSContext *cx, JSObject *proxy_, unsigned flags, jsid id, Value *vp)
 {
     JS_CHECK_RECURSION(cx, return false);
     RootedObject proxy(cx, proxy_);
     AutoPropertyDescriptorRooter desc(cx);
-    return Proxy::getPropertyDescriptor(cx, proxy, id, set, &desc) &&
+    return Proxy::getPropertyDescriptor(cx, proxy, id, &desc, flags) &&
            NewPropertyDescriptorObject(cx, &desc, vp);
 }
 
 bool
-Proxy::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id, bool set,
-                                PropertyDescriptor *desc)
+Proxy::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id, PropertyDescriptor *desc,
+                                unsigned flags)
 {
     JS_CHECK_RECURSION(cx, return false);
     RootedObject proxy(cx, proxy_);
-    return GetProxyHandler(proxy)->getOwnPropertyDescriptor(cx, proxy, id, set, desc);
+    return GetProxyHandler(proxy)->getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
 }
 
 bool
-Proxy::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, jsid id, bool set, Value *vp)
+Proxy::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy_, unsigned flags, jsid id,
+                                Value *vp)
 {
     JS_CHECK_RECURSION(cx, return false);
     RootedObject proxy(cx, proxy_);
     AutoPropertyDescriptorRooter desc(cx);
-    return Proxy::getOwnPropertyDescriptor(cx, proxy, id, set, &desc) &&
+    return Proxy::getOwnPropertyDescriptor(cx, proxy, id, &desc, flags) &&
            NewPropertyDescriptorObject(cx, &desc, vp);
 }
 
@@ -2688,7 +2685,7 @@ static JSBool
 proxy_GetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigned *attrsp)
 {
     AutoPropertyDescriptorRooter desc(cx);
-    if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, false, &desc))
+    if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc, 0))
         return false;
     *attrsp = desc.attrs;
     return true;
@@ -2722,7 +2719,7 @@ proxy_SetGenericAttributes(JSContext *cx, HandleObject obj, HandleId id, unsigne
 {
     /* Lookup the current property descriptor so we have setter/getter/value. */
     AutoPropertyDescriptorRooter desc(cx);
-    if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, true, &desc))
+    if (!Proxy::getOwnPropertyDescriptor(cx, obj, id, &desc, JSRESOLVE_ASSIGNING))
         return false;
     desc.attrs = (*attrsp & (~JSPROP_SHORTID));
     return Proxy::defineProperty(cx, obj, id, &desc);
diff --git a/js/src/jsproxy.h b/js/src/jsproxy.h
index c693178a367c..25c60d3e3939 100644
--- a/js/src/jsproxy.h
+++ b/js/src/jsproxy.h
@@ -73,10 +73,9 @@ class JS_FRIEND_API(BaseProxyHandler) {
 
     /* ES5 Harmony fundamental proxy traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
-                                       bool set, PropertyDescriptor *desc) = 0;
+                                       PropertyDescriptor *desc, unsigned flags) = 0;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
-                                          jsid id, bool set,
-                                          PropertyDescriptor *desc) = 0;
+                                          jsid id, PropertyDescriptor *desc, unsigned flags) = 0;
     virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
                                 PropertyDescriptor *desc) = 0;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy,
@@ -128,11 +127,10 @@ public:
 
     /* ES5 Harmony fundamental proxy traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
-                                       bool set,
-                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                       PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
-                                          jsid id, bool set,
-                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                          jsid id, PropertyDescriptor *desc,
+                                          unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
                                 PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy,
@@ -178,12 +176,13 @@ public:
 class Proxy {
   public:
     /* ES5 Harmony fundamental proxy traps. */
-    static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                      PropertyDescriptor *desc);
-    static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, Value *vp);
-    static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                         PropertyDescriptor *desc);
-    static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
+    static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
+                                      PropertyDescriptor *desc, unsigned flags);
+    static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, unsigned flags, jsid id,
+                                      Value *vp);
+    static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
+                                         PropertyDescriptor *desc, unsigned flags);
+    static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, unsigned flags, jsid id,
                                          Value *vp);
     static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc);
     static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, const Value &v);
diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp
index 6fc4e26234f4..3510c232037a 100644
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -162,22 +162,20 @@ Wrapper::~Wrapper()
 
 bool
 Wrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                               jsid id, bool set,
-                               PropertyDescriptor *desc)
+                               jsid id, PropertyDescriptor *desc, unsigned flags)
 {
     JS_ASSERT(!hasPrototype()); // Should never be called when there's a prototype.
     desc->obj = NULL; // default result if we refuse to perform this action
-    CHECKED(DirectProxyHandler::getPropertyDescriptor(cx, wrapper, id, set, desc),
-            set ? SET : GET);
+    CHECKED(DirectProxyHandler::getPropertyDescriptor(cx, wrapper, id, desc, flags),
+            (flags & JSRESOLVE_ASSIGNING) ? SET : GET);
 }
 
 bool
 Wrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                  jsid id, bool set,
-                                  PropertyDescriptor *desc)
+                                  jsid id, PropertyDescriptor *desc, unsigned flags)
 {
     desc->obj = NULL; // default result if we refuse to perform this action
-    CHECKED(DirectProxyHandler::getOwnPropertyDescriptor(cx, wrapper, id, set, desc), GET);
+    CHECKED(DirectProxyHandler::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags), GET);
 }
 
 bool
@@ -417,21 +415,21 @@ CrossCompartmentWrapper::~CrossCompartmentWrapper()
 
 bool
 CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                               bool set, PropertyDescriptor *desc)
+                                               PropertyDescriptor *desc, unsigned flags)
 {
-    PIERCE(cx, wrapper, set ? SET : GET,
+    PIERCE(cx, wrapper, (flags & JSRESOLVE_ASSIGNING) ? SET : GET,
            cx->compartment->wrapId(cx, &id),
-           Wrapper::getPropertyDescriptor(cx, wrapper, id, set, desc),
+           Wrapper::getPropertyDescriptor(cx, wrapper, id, desc, flags),
            cx->compartment->wrap(cx, desc));
 }
 
 bool
 CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                                  bool set, PropertyDescriptor *desc)
+                                                  PropertyDescriptor *desc, unsigned flags)
 {
-    PIERCE(cx, wrapper, set ? SET : GET,
+    PIERCE(cx, wrapper, (flags & JSRESOLVE_ASSIGNING) ? SET : GET,
            cx->compartment->wrapId(cx, &id),
-           Wrapper::getOwnPropertyDescriptor(cx, wrapper, id, set, desc),
+           Wrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags),
            cx->compartment->wrap(cx, desc));
 }
 
@@ -823,18 +821,16 @@ DeadObjectProxy::DeadObjectProxy()
 }
 
 bool
-DeadObjectProxy::getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                       jsid id, bool set,
-                                       PropertyDescriptor *desc)
+DeadObjectProxy::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
+                                       PropertyDescriptor *desc, unsigned flags)
 {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
     return false;
 }
 
 bool
-DeadObjectProxy::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                          jsid id, bool set,
-                                          PropertyDescriptor *desc)
+DeadObjectProxy::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
+                                          PropertyDescriptor *desc, unsigned flags)
 {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEAD_OBJECT);
     return false;
diff --git a/js/src/jswrapper.h b/js/src/jswrapper.h
index 0b20a26232c9..ea23cd54b393 100644
--- a/js/src/jswrapper.h
+++ b/js/src/jswrapper.h
@@ -82,11 +82,11 @@ class JS_FRIEND_API(Wrapper) : public DirectProxyHandler
 
     /* ES5 Harmony fundamental wrapper traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                       jsid id, bool set,
-                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                       jsid id, PropertyDescriptor *desc,
+                                       unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                          jsid id, bool set,
-                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                          jsid id, PropertyDescriptor *desc,
+                                          unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
                                 PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper,
@@ -131,10 +131,10 @@ class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper
     virtual ~CrossCompartmentWrapper();
 
     /* ES5 Harmony fundamental wrapper traps. */
-    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set,
-                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
-    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set,
-                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
+    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
+                                       PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
+    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
+                                          PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
                                 PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE;
@@ -207,10 +207,10 @@ class JS_FRIEND_API(DeadObjectProxy) : public BaseProxyHandler
     explicit DeadObjectProxy();
 
     /* ES5 Harmony fundamental wrapper traps. */
-    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set,
-                                       PropertyDescriptor *desc) MOZ_OVERRIDE;
-    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set,
-                                          PropertyDescriptor *desc) MOZ_OVERRIDE;
+    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
+                                       PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
+    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
+                                          PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
                                 PropertyDescriptor *desc) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE;
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index d0338649cedc..29ef262c53c4 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2743,7 +2743,7 @@ CopyProperty(JSContext *cx, HandleObject obj, HandleObject referent, HandleId id
         propFlags = shape->getFlags();
     } else if (IsProxy(referent)) {
         PropertyDescriptor desc;
-        if (!Proxy::getOwnPropertyDescriptor(cx, referent, id, false, &desc))
+        if (!Proxy::getOwnPropertyDescriptor(cx, referent, id, &desc, 0))
             return false;
         if (!desc.obj)
             return true;
diff --git a/js/src/vm/ScopeObject.cpp b/js/src/vm/ScopeObject.cpp
index e842abdf9e79..1a4b08bdb4eb 100644
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -1316,14 +1316,14 @@ class DebugScopeProxy : public BaseProxyHandler
 
     DebugScopeProxy() : BaseProxyHandler(&family) {}
 
-    bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                               PropertyDescriptor *desc) MOZ_OVERRIDE
+    bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc,
+                               unsigned flags) MOZ_OVERRIDE
     {
-        return getOwnPropertyDescriptor(cx, proxy, id, set, desc);
+        return getOwnPropertyDescriptor(cx, proxy, id, desc, flags);
     }
 
-    bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid idArg, bool set,
-                                  PropertyDescriptor *desc) MOZ_OVERRIDE
+    bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid idArg,
+                                  PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE
     {
         Rooted debugScope(cx, &proxy->asDebugScope());
         Rooted scope(cx, &debugScope->scope());
diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp
index 5ff63d435be1..261637755504 100644
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3143,15 +3143,16 @@ XPC_WN_Helper_SetProperty(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBo
 
 bool
 xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy,
-                                                jsid id_, bool set,
-                                                PropertyDescriptor *desc)
+                                                jsid id_,
+                                                PropertyDescriptor *desc,
+                                                unsigned flags)
 {
     js::RootedObject obj(cx, wrappedObject(proxy));
     js::RootedId id(cx, id_);
 
     MOZ_ASSERT(js::GetObjectCompartment(obj) == js::GetObjectCompartment(proxy));
     if (!JS_GetPropertyDescriptorById(cx, obj, id,
-                                      (set ? JSRESOLVE_ASSIGNING : 0), desc))
+                                      flags, desc))
         return false;
 
     if (!desc->obj)
@@ -3191,10 +3192,11 @@ xpc::SandboxProxyHandler::getPropertyDescriptor(JSContext *cx, JSObject *proxy,
 bool
 xpc::SandboxProxyHandler::getOwnPropertyDescriptor(JSContext *cx,
                                                    JSObject *proxy,
-                                                   jsid id, bool set,
-                                                   PropertyDescriptor *desc)
+                                                   jsid id,
+                                                   PropertyDescriptor *desc,
+                                                   unsigned flags)
 {
-    if (!getPropertyDescriptor(cx, proxy, id, set, desc))
+    if (!getPropertyDescriptor(cx, proxy, id, desc, flags))
         return false;
 
     if (desc->obj != wrappedObject(proxy))
diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp
index afe43d8ab426..109c91286699 100644
--- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp
+++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp
@@ -25,15 +25,15 @@ PropIsFromStandardPrototype(JSContext *cx, JSPropertyDescriptor *desc)
 
 bool
 ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                           jsid id, bool set,
-                                           js::PropertyDescriptor *desc)
+                                           jsid id, js::PropertyDescriptor *desc,
+                                           unsigned flags)
 {
     // First, try the lookup on the base wrapper. This can throw for various
     // reasons, including sets (gets fail silently). There's nothing we can really
     // do for sets, so we can conveniently propagate any exception we hit here.
     desc->obj = NULL;
     if (!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id,
-                                                        set, desc)) {
+                                                        desc, flags)) {
         return false;
     }
 
@@ -46,8 +46,8 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
     // If we found something, were doing a set, or have no proto, we're done.
     JSObject *wrapperProto;
     if (!JS_GetPrototype(cx, wrapper, &wrapperProto))
-	return false;
-    if (desc->obj || set || !wrapperProto)
+      return false;
+    if (desc->obj || (flags & JSRESOLVE_ASSIGNING) || !wrapperProto)
         return true;
 
     // If not, try doing the lookup on the prototype.
@@ -86,8 +86,8 @@ ChromeObjectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
     // this because the call signature of ::get doesn't give us any way to
     // determine the object upon which the property was found.
     JSPropertyDescriptor desc;
-    if (!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id, false,
-                                                        &desc)) {
+    if (!ChromeObjectWrapperBase::getPropertyDescriptor(cx, wrapper, id, &desc,
+                                                        0)) {
         return false;
     }
 
diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.h b/js/xpconnect/wrappers/ChromeObjectWrapper.h
index d40adc2f36f5..b5e0b7e9708e 100644
--- a/js/xpconnect/wrappers/ChromeObjectWrapper.h
+++ b/js/xpconnect/wrappers/ChromeObjectWrapper.h
@@ -8,6 +8,8 @@
 #ifndef __ChromeObjectWrapper_h__
 #define __ChromeObjectWrapper_h__
 
+#include "mozilla/Attributes.h"
+
 #include "FilteringWrapper.h"
 #include "AccessCheck.h"
 
@@ -28,8 +30,8 @@ class ChromeObjectWrapper : public ChromeObjectWrapperBase
 
     /* Custom traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper,
-                                       jsid id, bool set,
-                                       js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                       jsid id, js::PropertyDescriptor *desc,
+                                       unsigned flags) MOZ_OVERRIDE;
     virtual bool has(JSContext *cx, JSObject *wrapper, jsid id,
                      bool *bp) MOZ_OVERRIDE;
     virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver,
diff --git a/js/xpconnect/wrappers/FilteringWrapper.cpp b/js/xpconnect/wrappers/FilteringWrapper.cpp
index 1e2ed93bbf52..fe299184f5df 100644
--- a/js/xpconnect/wrappers/FilteringWrapper.cpp
+++ b/js/xpconnect/wrappers/FilteringWrapper.cpp
@@ -61,9 +61,9 @@ FilterSetter(JSContext *cx, JSObject *wrapper, jsid id, js::PropertyDescriptor *
 template 
 bool
 FilteringWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                                      bool set, js::PropertyDescriptor *desc)
+                                                      js::PropertyDescriptor *desc, unsigned flags)
 {
-    if (!Base::getPropertyDescriptor(cx, wrapper, id, set, desc))
+    if (!Base::getPropertyDescriptor(cx, wrapper, id, desc, flags))
         return false;
     return FilterSetter(cx, wrapper, id, desc);
 }
@@ -71,9 +71,10 @@ FilteringWrapper::getPropertyDescriptor(JSContext *cx, JSObject *w
 template 
 bool
 FilteringWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                                         bool set, js::PropertyDescriptor *desc)
+                                                         js::PropertyDescriptor *desc,
+                                                         unsigned flags)
 {
-    if (!Base::getOwnPropertyDescriptor(cx, wrapper, id, set, desc))
+    if (!Base::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags))
         return false;
     return FilterSetter(cx, wrapper, id, desc);
 }
diff --git a/js/xpconnect/wrappers/FilteringWrapper.h b/js/xpconnect/wrappers/FilteringWrapper.h
index a6784158fe6b..b084da305292 100644
--- a/js/xpconnect/wrappers/FilteringWrapper.h
+++ b/js/xpconnect/wrappers/FilteringWrapper.h
@@ -19,8 +19,8 @@ class FilteringWrapper : public Base {
     FilteringWrapper(unsigned flags);
     virtual ~FilteringWrapper();
 
-    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
-    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+    virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
+    virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
     virtual bool enumerate(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
     virtual bool keys(JSContext *cx, JSObject *wrapper, js::AutoIdVector &props) MOZ_OVERRIDE;
diff --git a/js/xpconnect/wrappers/WaiveXrayWrapper.cpp b/js/xpconnect/wrappers/WaiveXrayWrapper.cpp
index 0a68d2c55448..4969170fdd12 100644
--- a/js/xpconnect/wrappers/WaiveXrayWrapper.cpp
+++ b/js/xpconnect/wrappers/WaiveXrayWrapper.cpp
@@ -25,17 +25,17 @@ WaiveXrayWrapper::~WaiveXrayWrapper()
 
 bool
 WaiveXrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                          bool set, js::PropertyDescriptor *desc)
+                                        js::PropertyDescriptor *desc, unsigned flags)
 {
-    return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, set, desc) &&
+    return CrossCompartmentWrapper::getPropertyDescriptor(cx, wrapper, id, desc, flags) &&
            WrapperFactory::WaiveXrayAndWrap(cx, &desc->value);
 }
 
 bool
 WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                             bool set, js::PropertyDescriptor *desc)
+                                           js::PropertyDescriptor *desc, unsigned flags)
 {
-    return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, set, desc) &&
+    return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags) &&
            WrapperFactory::WaiveXrayAndWrap(cx, &desc->value);
 }
 
diff --git a/js/xpconnect/wrappers/WaiveXrayWrapper.h b/js/xpconnect/wrappers/WaiveXrayWrapper.h
index 26992d579608..e4b2041aa069 100644
--- a/js/xpconnect/wrappers/WaiveXrayWrapper.h
+++ b/js/xpconnect/wrappers/WaiveXrayWrapper.h
@@ -21,9 +21,9 @@ class WaiveXrayWrapper : public js::CrossCompartmentWrapper {
     virtual ~WaiveXrayWrapper();
 
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                       bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                       js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                          bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                          js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id,
                      js::Value *vp) MOZ_OVERRIDE;
 
diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp
index c9b70afbbc82..c5b42a1943a5 100644
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -132,7 +132,7 @@ public:
 
     virtual bool resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper,
                                     JSObject *wrapper, JSObject *holder,
-                                    jsid id, bool set, JSPropertyDescriptor *desc);
+                                    jsid id, JSPropertyDescriptor *desc, unsigned flags);
 
     static bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp)
     {
@@ -183,10 +183,10 @@ class XPCWrappedNativeXrayTraits : public XrayTraits
 {
 public:
     static bool resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid id,
-                                      bool set, JSPropertyDescriptor *desc);
+                                      JSPropertyDescriptor *desc, unsigned flags);
     virtual bool resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper, JSObject *wrapper,
-                                    JSObject *holder, jsid id, bool set,
-                                    JSPropertyDescriptor *desc);
+                                    JSObject *holder, jsid id, JSPropertyDescriptor *desc,
+                                    unsigned flags);
     static bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
                                JSPropertyDescriptor *desc, bool *defined);
     static bool enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
@@ -198,7 +198,7 @@ public:
     static bool isResolving(JSContext *cx, JSObject *holder, jsid id);
 
     static bool resolveDOMCollectionProperty(JSContext *cx, JSObject *wrapper, JSObject *holder,
-                                             jsid id, bool set, PropertyDescriptor *desc);
+                                             jsid id, PropertyDescriptor *desc, unsigned flags);
 
     static XPCWrappedNative* getWN(JSObject *wrapper) {
         return GetWrappedNative(getTargetObject(wrapper));
@@ -223,10 +223,10 @@ class DOMXrayTraits : public XrayTraits
 {
 public:
     static bool resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid id,
-                                      bool set, JSPropertyDescriptor *desc);
+                                      JSPropertyDescriptor *desc, unsigned flags);
     virtual bool resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper, JSObject *wrapper,
-                                    JSObject *holder, jsid id, bool set,
-                                    JSPropertyDescriptor *desc);
+                                    JSObject *holder, jsid id, JSPropertyDescriptor *desc,
+                                    unsigned flags);
     static bool enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
                                JS::AutoIdVector &props);
     static bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp);
@@ -619,8 +619,8 @@ private:
 // any native property.
 bool
 XPCWrappedNativeXrayTraits::resolveDOMCollectionProperty(JSContext *cx, JSObject *wrapper,
-                                                         JSObject *holder, jsid id, bool set,
-                                                         PropertyDescriptor *desc)
+                                                         JSObject *holder, jsid id,
+                                                         PropertyDescriptor *desc, unsigned flags)
 {
     // If we are not currently resolving this id and resolveNative is called
     // we don't do anything. (see defineProperty in case of shadowing is forbidden).
@@ -638,7 +638,6 @@ XPCWrappedNativeXrayTraits::resolveDOMCollectionProperty(JSContext *cx, JSObject
 
     bool retval = true;
     JSObject *pobj = NULL;
-    unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0);
     nsresult rv = wn->GetScriptableInfo()->GetCallback()->NewResolve(wn, cx, wrapper, id,
                                                                      flags, &pobj, &retval);
     if (NS_FAILED(rv)) {
@@ -716,17 +715,17 @@ XPCWrappedNativeXrayTraits::preserveWrapper(JSObject *target)
 
 bool
 XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper,
-                                                  JSObject *holder, jsid id, bool set,
-                                                  JSPropertyDescriptor *desc)
+                                                  JSObject *holder, jsid id,
+                                                  JSPropertyDescriptor *desc, unsigned flags)
 {
     MOZ_ASSERT(js::GetObjectJSClass(holder) == &HolderClass);
     XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-    if (!set &&
+    if (!(flags & JSRESOLVE_ASSIGNING) &&
         id == rt->GetStringID(XPCJSRuntime::IDX_MOZMATCHESSELECTOR) &&
         Is(wrapper))
     {
         // XPC calling mechanism cannot handle call/bind properly in some cases
-        // especially through xray wrappers. This is a temoorary work around for
+        // especially through xray wrappers. This is a temporary work around for
         // this problem for mozMatchesSelector. See: bug 763897.
         desc->obj = wrapper;
         desc->attrs = JSPROP_ENUMERATE;
@@ -755,7 +754,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapp
     // check for those.
     if (!JSID_IS_STRING(id)) {
         /* Not found */
-        return resolveDOMCollectionProperty(cx, wrapper, holder, id, set, desc);
+        return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
     }
 
     XPCNativeInterface *iface;
@@ -766,7 +765,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapp
         !(iface = ccx.GetInterface()) ||
         !(member = ccx.GetMember())) {
         /* Not found */
-        return resolveDOMCollectionProperty(cx, wrapper, holder, id, set, desc);
+        return resolveDOMCollectionProperty(cx, wrapper, holder, id, desc, flags);
     }
 
     desc->obj = holder;
@@ -912,7 +911,7 @@ nodePrincipal_getter(JSContext *cx, JSHandleObject wrapper, JSHandleId id, JSMut
 bool
 XrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper,
                                JSObject *wrapper, JSObject *holder, jsid id,
-                               bool set, PropertyDescriptor *desc)
+                               PropertyDescriptor *desc, unsigned flags)
 {
     desc->obj = NULL;
     JSObject *target = getTargetObject(wrapper);
@@ -938,11 +937,11 @@ XrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper,
 bool
 XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper,
                                                JSObject *wrapper, JSObject *holder, jsid id,
-                                               bool set, PropertyDescriptor *desc)
+                                               PropertyDescriptor *desc, unsigned flags)
 {
     // Call the common code.
     bool ok = XrayTraits::resolveOwnProperty(cx, jsWrapper, wrapper, holder,
-                                             id, set, desc);
+                                             id, desc, flags);
     if (!ok || desc->obj)
         return ok;
 
@@ -957,7 +956,7 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWra
           (id == rt->GetStringID(XPCJSRuntime::IDX_DOCUMENTURIOBJECT) &&
           Is(wrapper)))) {
         bool status;
-        Wrapper::Action action = set ? Wrapper::SET : Wrapper::GET;
+        Wrapper::Action action = (flags & JSRESOLVE_ASSIGNING) ? Wrapper::SET : Wrapper::GET;
         desc->obj = NULL; // default value
         if (!jsWrapper.enter(cx, wrapper, id, action, &status))
             return status;
@@ -976,7 +975,6 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWra
         return true;
     }
 
-    unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0);
     JSBool hasProp;
     if (!JS_HasPropertyById(cx, holder, id, &hasProp)) {
         return false;
@@ -1118,7 +1116,7 @@ XPCWrappedNativeXrayTraits::construct(JSContext *cx, JSObject *wrapper,
 
 bool
 DOMXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid id,
-                                     bool set, JSPropertyDescriptor *desc)
+                                     JSPropertyDescriptor *desc, unsigned flags)
 {
     JSObject *obj = getTargetObject(wrapper);
     if (!XrayResolveNativeProperty(cx, wrapper, obj, id, desc))
@@ -1132,16 +1130,17 @@ DOMXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject
 
 bool
 DOMXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper, JSObject *wrapper,
-                                  JSObject *holder, jsid id, bool set, JSPropertyDescriptor *desc)
+                                  JSObject *holder, jsid id, JSPropertyDescriptor *desc,
+                                  unsigned flags)
 {
     // Call the common code.
     bool ok = XrayTraits::resolveOwnProperty(cx, jsWrapper, wrapper, holder,
-                                             id, set, desc);
+                                             id, desc, flags);
     if (!ok || desc->obj)
         return ok;
 
     JSObject *obj = getTargetObject(wrapper);
-    if (!XrayResolveOwnProperty(cx, wrapper, obj, id, set, desc))
+    if (!XrayResolveOwnProperty(cx, wrapper, obj, id, desc, flags))
         return false;
 
     NS_ASSERTION(!desc->obj || desc->obj == wrapper,
@@ -1302,7 +1301,7 @@ XrayToString(JSContext *cx, unsigned argc, jsval *vp)
 template 
 bool
 XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                                 bool set, js::PropertyDescriptor *desc)
+                                                 js::PropertyDescriptor *desc, unsigned flags)
 {
     JSObject *holder = Traits::singleton.ensureHolder(cx, wrapper);
     if (Traits::isResolving(cx, holder, id)) {
@@ -1311,7 +1310,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
     }
 
     bool status;
-    Wrapper::Action action = set ? Wrapper::SET : Wrapper::GET;
+    Wrapper::Action action = (flags & JSRESOLVE_ASSIGNING) ? Wrapper::SET : Wrapper::GET;
     desc->obj = NULL; // default value
     if (!this->enter(cx, wrapper, id, action, &status))
         return status;
@@ -1323,11 +1322,8 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
         JSObject *obj = Traits::getTargetObject(wrapper);
         {
             JSAutoCompartment ac(cx, obj);
-            if (!JS_GetPropertyDescriptorById(cx, obj, id,
-                                              (set ? JSRESOLVE_ASSIGNING : 0),
-                                              desc)) {
+            if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc))
                 return false;
-            }
         }
 
         if (desc->obj)
@@ -1345,7 +1341,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
     if (AccessCheck::wrapperSubsumes(wrapper) &&
         id == rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT)) {
         bool status;
-        Wrapper::Action action = set ? Wrapper::SET : Wrapper::GET;
+        Wrapper::Action action = (flags & JSRESOLVE_ASSIGNING) ? Wrapper::SET : Wrapper::GET;
         desc->obj = NULL; // default value
         if (!this->enter(cx, wrapper, id, action, &status))
             return status;
@@ -1359,7 +1355,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
         return true;
     }
 
-    if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, set, desc))
+    if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, flags))
         return false;
 
     if (desc->obj)
@@ -1373,7 +1369,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
     }
 
     // Nothing in the cache. Call through, and cache the result.
-    if (!Traits::resolveNativeProperty(cx, wrapper, holder, id, set, desc))
+    if (!Traits::resolveNativeProperty(cx, wrapper, holder, id, desc, flags))
         return false;
 
     if (!desc->obj) {
@@ -1393,7 +1389,6 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
 
     desc->obj = wrapper;
 
-    unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0);
     return JS_DefinePropertyById(cx, holder, id, desc->value, desc->getter, desc->setter,
                                  desc->attrs) &&
            JS_GetPropertyDescriptorById(cx, holder, id, flags, desc);
@@ -1402,7 +1397,7 @@ XrayWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
 template 
 bool
 XrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                                    bool set, PropertyDescriptor *desc)
+                                                    PropertyDescriptor *desc, unsigned flags)
 {
     JSObject *holder = Traits::singleton.ensureHolder(cx, wrapper);
     if (Traits::isResolving(cx, holder, id)) {
@@ -1411,7 +1406,7 @@ XrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wra
     }
 
     bool status;
-    Wrapper::Action action = set ? Wrapper::SET : Wrapper::GET;
+    Wrapper::Action action = (flags & JSRESOLVE_ASSIGNING) ? Wrapper::SET : Wrapper::GET;
     desc->obj = NULL; // default value
     if (!this->enter(cx, wrapper, id, action, &status))
         return status;
@@ -1425,24 +1420,20 @@ XrayWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wra
         JSObject *obj = Traits::getTargetObject(wrapper);
         {
             JSAutoCompartment ac(cx, obj);
-            if (!JS_GetPropertyDescriptorById(cx, obj, id,
-                                              (set ? JSRESOLVE_ASSIGNING : 0),
-                                              desc)) {
+            if (!JS_GetPropertyDescriptorById(cx, obj, id, flags, desc))
                 return false;
-            }
         }
 
         desc->obj = (desc->obj == obj) ? wrapper : nullptr;
         return JS_WrapPropertyDescriptor(cx, desc);
     }
 
-    if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, set, desc))
+    if (!Traits::singleton.resolveOwnProperty(cx, *this, wrapper, holder, id, desc, flags))
         return false;
 
     if (desc->obj)
         return true;
 
-    unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0);
     if (!JS_GetPropertyDescriptorById(cx, holder, id, flags, desc))
         return false;
 
@@ -1470,7 +1461,7 @@ XrayWrapper::defineProperty(JSContext *cx, JSObject *wrapper, jsid
     }
 
     PropertyDescriptor existing_desc;
-    if (!getOwnPropertyDescriptor(cx, wrapper, id, true, &existing_desc))
+    if (!getOwnPropertyDescriptor(cx, wrapper, id, &existing_desc, JSRESOLVE_ASSIGNING))
         return false;
 
     if (existing_desc.obj && (existing_desc.attrs & JSPROP_PERMANENT))
diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h
index ffba122faa83..06b9ac29e968 100644
--- a/js/xpconnect/wrappers/XrayWrapper.h
+++ b/js/xpconnect/wrappers/XrayWrapper.h
@@ -5,9 +5,11 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/Attributes.h"
+#include "mozilla/GuardObjects.h"
+
 #include "jsapi.h"
 #include "jswrapper.h"
-#include "mozilla/GuardObjects.h"
 
 // Xray wrappers re-resolve the original native properties on the native
 // object and always directly access to those properties.
@@ -62,9 +64,10 @@ class XrayWrapper : public Base {
 
     /* Fundamental proxy traps. */
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                       bool set, js::PropertyDescriptor *desc);
+                                       js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id,
-                                          bool set, js::PropertyDescriptor *desc);
+                                          js::PropertyDescriptor *desc,
+                                          unsigned flags) MOZ_OVERRIDE;
     virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id,
                                 js::PropertyDescriptor *desc);
     virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper,
@@ -108,10 +111,10 @@ public:
     }
 
     virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id,
-                                       bool set, js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                       js::PropertyDescriptor *desc, unsigned flags) MOZ_OVERRIDE;
     virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy,
-                                          jsid id, bool set,
-                                          js::PropertyDescriptor *desc) MOZ_OVERRIDE;
+                                          jsid id, js::PropertyDescriptor *desc,
+                                          unsigned flags) MOZ_OVERRIDE;
 
     // We just forward the derived traps to the BaseProxyHandler versions which
     // implement them in terms of the fundamental traps.

From afbf0d1b25e15cd80827bfd329fbf16391e9a82a Mon Sep 17 00:00:00 2001
From: Ehsan Akhgari 
Date: Fri, 4 Jan 2013 13:09:11 -0500
Subject: [PATCH 056/180] Bug 822017 - Remove the global PB specific code from
 the testpilot extension; r=dao

--HG--
rename : browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js => browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in
rename : browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js => browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in
---
 .../modules/{setup.js => setup.js.in}                       | 6 ++++++
 .../modules/{tasks.js => tasks.js.in}                       | 4 ++++
 2 files changed, 10 insertions(+)
 rename browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/{setup.js => setup.js.in} (99%)
 rename browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/{tasks.js => tasks.js.in} (99%)

diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in
similarity index 99%
rename from browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
rename to browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in
index 0a1319fcfd97..d75cad49c75d 100644
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js.in
@@ -172,8 +172,10 @@ let TestPilotSetup = {
       "testpilot:task:dataAutoSubmitted", this._onTaskDataAutoSubmitted, self);
     // Set up observation for application shutdown.
     this._obs.add("quit-application", this.globalShutdown, self);
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
     // Set up observation for enter/exit private browsing:
     this._obs.add("private-browsing", this.onPrivateBrowsingMode, self);
+#endif
 
     // Set up timers to remind user x minutes after startup
     // and once per day thereafter.  Use nsITimer so it doesn't belong to
@@ -243,7 +245,9 @@ let TestPilotSetup = {
     this._obs.remove(
       "testpilot:task:dataAutoSubmitted", this._onTaskDataAutoSubmitted, self);
     this._obs.remove("quit-application", this.globalShutdown, self);
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
     this._obs.remove("private-browsing", this.onPrivateBrowsingMode, self);
+#endif
     this._loader.unload();
     this._shortTimer.cancel();
     this._longTimer.cancel();
@@ -257,6 +261,7 @@ let TestPilotSetup = {
     return wm.getMostRecentWindow("navigator:browser");
   },
 
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
   onPrivateBrowsingMode: function TPS_onPrivateBrowsingMode(topic, data) {
     for (let i = 0; i < this.taskList.length; i++) {
       if (data == "enter") {
@@ -266,6 +271,7 @@ let TestPilotSetup = {
       }
     }
   },
+#endif
 
   onWindowUnload: function TPS__onWindowRegistered(window) {
     this._logger.trace("Called TestPilotSetup.onWindow unload!");
diff --git a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in
similarity index 99%
rename from browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js
rename to browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in
index 970236c1ffe9..71c1cd2837dc 100644
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/tasks.js.in
@@ -162,11 +162,13 @@ var TestPilotTask = {
     // Called by extension core when Firefox is shutting down.
   },
 
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
   onEnterPrivateBrowsing: function TestPilotTask_onEnterPrivate() {
   },
 
   onExitPrivateBrowsing: function TestPilotTask_onExitPrivate() {
   },
+#endif
 
   onNewWindow: function TestPilotTask_onNewWindow(window) {
   },
@@ -532,6 +534,7 @@ TestPilotExperiment.prototype = {
     }
   },
 
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
   onEnterPrivateBrowsing: function TestPilotExperiment_onEnterPrivate() {
     this._logger.trace("Task is entering private browsing.");
     if (this.experimentIsRunning()) {
@@ -553,6 +556,7 @@ TestPilotExperiment.prototype = {
       }
     }
   },
+#endif
 
   getStudyMetadata: function TestPilotExperiment_getStudyMetadata() {
     try {

From e49cc9e10e07bff81622d95ae50aff194337020e Mon Sep 17 00:00:00 2001
From: Randell Jesup 
Date: Fri, 4 Jan 2013 13:11:12 -0500
Subject: [PATCH 057/180] Bug 805632: backend for getUserMedia:revoke r=anant

---
 dom/media/MediaManager.cpp | 18 ++++++++++++++++--
 dom/media/MediaManager.h   |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp
index 84eb83eb551b..a5fb068c7b2b 100644
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -935,7 +935,8 @@ MediaManager::GetUserMedia(bool aPrivileged, nsPIDOMWindow* aWindow,
 
     // Convert window ID to string.
     char windowBuffer[32];
-    PR_snprintf(windowBuffer, 32, "%llu", aWindow->GetOuterWindow()->WindowID());
+    PR_snprintf(windowBuffer, sizeof(windowBuffer), "%llu",
+                aWindow->GetOuterWindow()->WindowID());
     data.Append(NS_ConvertUTF8toUTF16(windowBuffer));
 
     data.Append(NS_LITERAL_STRING(", \"callID\":\""));
@@ -1002,7 +1003,7 @@ MediaManager::OnNavigation(uint64_t aWindowID)
   // a call to content.
 
   // This is safe since we're on main-thread, and the windowlist can only
-  // be added to from the main-thread (see OnNavigation)
+  // be added to from the main-thread
   StreamListeners* listeners = GetWindowListeners(aWindowID);
   if (!listeners) {
     return;
@@ -1031,6 +1032,7 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
     obs->RemoveObserver(this, "xpcom-shutdown");
     obs->RemoveObserver(this, "getUserMedia:response:allow");
     obs->RemoveObserver(this, "getUserMedia:response:deny");
+    obs->RemoveObserver(this, "getUserMedia:revoke");
 
     // Close off any remaining active windows.
     {
@@ -1104,6 +1106,18 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
     return NS_OK;
   }
 
+  if (!strcmp(aTopic, "getUserMedia:revoke")) {
+    nsresult rv;
+    uint64_t windowID = nsString(aData).ToInteger64(&rv);
+    MOZ_ASSERT(NS_SUCCEEDED(rv));
+    if (NS_SUCCEEDED(rv)) {
+      LOG(("Revoking MediaCapture access for window %llu",windowID));
+      OnNavigation(windowID);
+    }
+
+    return NS_OK;
+  }
+
   return NS_OK;
 }
 
diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h
index 2cb759c29a21..928527c1a1f3 100644
--- a/dom/media/MediaManager.h
+++ b/dom/media/MediaManager.h
@@ -291,6 +291,7 @@ public:
       obs->AddObserver(sSingleton, "xpcom-shutdown", false);
       obs->AddObserver(sSingleton, "getUserMedia:response:allow", false);
       obs->AddObserver(sSingleton, "getUserMedia:response:deny", false);
+      obs->AddObserver(sSingleton, "getUserMedia:revoke", false);
     }
     return sSingleton;
   }

From ecb358d581cbbb88978549ffd800209e870ee842 Mon Sep 17 00:00:00 2001
From: Randell Jesup 
Date: Fri, 4 Jan 2013 13:11:14 -0500
Subject: [PATCH 058/180] Bug 802656: GetUserMediaDevices: Consider no devices
 available an error r=anant

---
 dom/media/MediaManager.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp
index a5fb068c7b2b..d35d3d0adf45 100644
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -162,8 +162,11 @@ public:
 
     int32_t len = mDevices.Length();
     if (len == 0) {
-      devices->SetAsEmptyArray();
-      success->OnSuccess(devices);
+      // XXX
+      // We should in the future return an empty array, and dynamically add
+      // devices to the dropdowns if things are hotplugged while the
+      // requester is up.
+      error->OnError(NS_LITERAL_STRING("NO_DEVICES_FOUND"));
       return NS_OK;
     }
 

From 83c1284aff325cd1d53c1ad1b08c8c1418333570 Mon Sep 17 00:00:00 2001
From: Bobby Holley 
Date: Fri, 4 Jan 2013 10:21:31 -0800
Subject: [PATCH 059/180] Bug 826146 - Add a pref-controlled install
 confirmation override for automation. r=sicking

---
 dom/apps/src/Webapps.jsm                          | 12 ++++++++++--
 testing/specialpowers/content/specialpowersAPI.js |  8 ++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/dom/apps/src/Webapps.jsm b/dom/apps/src/Webapps.jsm
index de8272bd782a..3bc96205aa88 100644
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1382,8 +1382,16 @@ this.DOMApplicationRegistry = {
           sendError("INVALID_SECURITY_LEVEL");
         } else {
           app.etag = xhr.getResponseHeader("Etag");
-          Services.obs.notifyObservers(aMm, "webapps-ask-install",
-                                       JSON.stringify(aData));
+          // We allow bypassing the install confirmation process to facilitate
+          // automation.
+          let prefName = "dom.mozApps.auto_confirm_install";
+          if (Services.prefs.prefHasUserValue(prefName) &&
+              Services.prefs.getBoolPref(prefName)) {
+            this.confirmInstall(aData);
+          } else {
+            Services.obs.notifyObservers(aMm, "webapps-ask-install",
+                                         JSON.stringify(aData));
+          }
         }
       } else {
         sendError("MANIFEST_URL_ERROR");
diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js
index 3d91ba9f3f32..bfe278247202 100644
--- a/testing/specialpowers/content/specialpowersAPI.js
+++ b/testing/specialpowers/content/specialpowersAPI.js
@@ -713,6 +713,14 @@ SpecialPowersAPI.prototype = {
     }
   },
 
+  // Disables the app install prompt for the duration of this test. There is
+  // no need to re-enable the prompt at the end of the test.
+  //
+  // The provided callback is invoked once the prompt is disabled.
+  autoConfirmAppInstall: function(cb) {
+    this.pushPrefEnv({set: [['dom.mozApps.auto_confirm_install', true]]}, cb);
+  },
+
   addObserver: function(obs, notification, weak) {
     var obsvc = Cc['@mozilla.org/observer-service;1']
                    .getService(Ci.nsIObserverService);

From 081ee211632a861cea899806f18894ddf981feac Mon Sep 17 00:00:00 2001
From: Terrence Cole 
Date: Wed, 2 Jan 2013 17:13:16 -0800
Subject: [PATCH 060/180] Bug 826126 - Just use an assert to check for
 aliasing; r=benjamin

This appears to be debug code that crept in for bug 767013.

--HG--
extra : rebase_source : 9f616676d77432ec5f05c5dfa7e9998ac649797a
---
 js/src/vm/Stack-inl.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/js/src/vm/Stack-inl.h b/js/src/vm/Stack-inl.h
index 1cd4707260af..a04216e1ceb3 100644
--- a/js/src/vm/Stack-inl.h
+++ b/js/src/vm/Stack-inl.h
@@ -243,9 +243,6 @@ StackFrame::unaliasedFormal(unsigned i, MaybeCheckAliasing checkAliasing)
 {
     JS_ASSERT(i < numFormalArgs());
     JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals());
-    if (checkAliasing && script()->formalIsAliased(i)) {
-        while (true) {}
-    }
     JS_ASSERT_IF(checkAliasing, !script()->formalIsAliased(i));
     return formals()[i];
 }

From 32fd2a26def56330089661f0289c7d80eb68f199 Mon Sep 17 00:00:00 2001
From: Jonathan Kew 
Date: Fri, 4 Jan 2013 18:35:37 +0000
Subject: [PATCH 061/180] bug 825871 - refactor gfxTextRun and gfxShapedWord to
 share a common abstract base class (gfxShapedText) and shaping interface.
 r=roc

---
 gfx/thebes/gfxCoreTextShaper.cpp  |  61 ++--
 gfx/thebes/gfxCoreTextShaper.h    |  17 +-
 gfx/thebes/gfxDWriteShaper.cpp    |  56 +--
 gfx/thebes/gfxDWriteShaper.h      |   9 +-
 gfx/thebes/gfxFT2Fonts.cpp        |  64 ++--
 gfx/thebes/gfxFT2Fonts.h          |  16 +-
 gfx/thebes/gfxFont.cpp            | 416 +++++++++++++---------
 gfx/thebes/gfxFont.h              | 559 ++++++++++++++++--------------
 gfx/thebes/gfxGDIFont.cpp         |  89 ++---
 gfx/thebes/gfxGDIFont.h           |  11 +-
 gfx/thebes/gfxGDIShaper.cpp       |  30 +-
 gfx/thebes/gfxGDIShaper.h         |   9 +-
 gfx/thebes/gfxGraphiteShaper.cpp  |  70 ++--
 gfx/thebes/gfxGraphiteShaper.h    |  16 +-
 gfx/thebes/gfxHarfBuzzShaper.cpp  | 144 ++++----
 gfx/thebes/gfxHarfBuzzShaper.h    |  18 +-
 gfx/thebes/gfxMacFont.cpp         |  12 +-
 gfx/thebes/gfxMacFont.h           |   9 +-
 gfx/thebes/gfxPangoFonts.cpp      | 146 ++++----
 gfx/thebes/gfxPlatform.cpp        |   3 +-
 gfx/thebes/gfxUniscribeShaper.cpp |  70 ++--
 gfx/thebes/gfxUniscribeShaper.h   |   9 +-
 22 files changed, 1042 insertions(+), 792 deletions(-)

diff --git a/gfx/thebes/gfxCoreTextShaper.cpp b/gfx/thebes/gfxCoreTextShaper.cpp
index a465573e57d6..f07f6bee8656 100644
--- a/gfx/thebes/gfxCoreTextShaper.cpp
+++ b/gfx/thebes/gfxCoreTextShaper.cpp
@@ -63,23 +63,25 @@ gfxCoreTextShaper::~gfxCoreTextShaper()
 }
 
 bool
-gfxCoreTextShaper::ShapeWord(gfxContext      *aContext,
-                             gfxShapedWord   *aShapedWord,
-                             const PRUnichar *aText)
+gfxCoreTextShaper::ShapeText(gfxContext      *aContext,
+                             const PRUnichar *aText,
+                             uint32_t         aOffset,
+                             uint32_t         aLength,
+                             int32_t          aScript,
+                             gfxShapedText   *aShapedText)
 {
     // Create a CFAttributedString with text and style info, so we can use CoreText to lay it out.
 
-    bool isRightToLeft = aShapedWord->IsRightToLeft();
-    uint32_t length = aShapedWord->Length();
+    bool isRightToLeft = aShapedText->IsRightToLeft();
+    uint32_t length = aLength;
 
     // we need to bidi-wrap the text if the run is RTL,
     // or if it is an LTR run but may contain (overridden) RTL chars
     bool bidiWrap = isRightToLeft;
-    if (!bidiWrap && !aShapedWord->TextIs8Bit()) {
-        const PRUnichar *text = aShapedWord->TextUnicode();
+    if (!bidiWrap && !aShapedText->TextIs8Bit()) {
         uint32_t i;
         for (i = 0; i < length; ++i) {
-            if (gfxFontUtils::PotentialRTLChar(text[i])) {
+            if (gfxFontUtils::PotentialRTLChar(aText[i])) {
                 bidiWrap = true;
                 break;
             }
@@ -115,7 +117,7 @@ gfxCoreTextShaper::ShapeWord(gfxContext      *aContext,
     }
 
     CFDictionaryRef attrObj;
-    if (aShapedWord->DisableLigatures()) {
+    if (aShapedText->DisableLigatures()) {
         // For letterspacing (or maybe other situations) we need to make a copy of the CTFont
         // with the ligature feature disabled
         CTFontRef ctFont =
@@ -156,7 +158,7 @@ gfxCoreTextShaper::ShapeWord(gfxContext      *aContext,
     for (uint32_t runIndex = 0; runIndex < numRuns; runIndex++) {
         CTRunRef aCTRun =
             (CTRunRef)::CFArrayGetValueAtIndex(glyphRuns, runIndex);
-        if (SetGlyphsFromRun(aShapedWord, aCTRun, startOffset) != NS_OK) {
+        if (SetGlyphsFromRun(aShapedText, aOffset, aLength, aCTRun, startOffset) != NS_OK) {
             success = false;
             break;
         }
@@ -172,22 +174,24 @@ gfxCoreTextShaper::ShapeWord(gfxContext      *aContext,
                             // without requiring a separate allocation
 
 nsresult
-gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedWord *aShapedWord,
-                                    CTRunRef aCTRun,
-                                    int32_t aStringOffset)
+gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText,
+                                    uint32_t       aOffset,
+                                    uint32_t       aLength,
+                                    CTRunRef       aCTRun,
+                                    int32_t        aStringOffset)
 {
     // The word has been bidi-wrapped; aStringOffset is the number
     // of chars at the beginning of the CTLine that we should skip.
     // aCTRun is a glyph run from the CoreText layout process.
 
-    int32_t direction = aShapedWord->IsRightToLeft() ? -1 : 1;
+    int32_t direction = aShapedText->IsRightToLeft() ? -1 : 1;
 
     int32_t numGlyphs = ::CTRunGetGlyphCount(aCTRun);
     if (numGlyphs == 0) {
         return NS_OK;
     }
 
-    int32_t wordLength = aShapedWord->Length();
+    int32_t wordLength = aLength;
 
     // character offsets get really confusing here, as we have to keep track of
     // (a) the text in the actual textRun we're constructing
@@ -257,8 +261,10 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedWord *aShapedWord,
     double runWidth = ::CTRunGetTypographicBounds(aCTRun, ::CFRangeMake(0, 0),
                                                   NULL, NULL, NULL);
 
-    nsAutoTArray detailedGlyphs;
-    gfxTextRun::CompressedGlyph g;
+    nsAutoTArray detailedGlyphs;
+    gfxShapedText::CompressedGlyph g;
+    gfxShapedText::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs() + aOffset;
 
     // CoreText gives us the glyphindex-to-charindex mapping, which relates each glyph
     // to a source text character; we also need the charindex-to-glyphindex mapping to
@@ -302,7 +308,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedWord *aShapedWord,
     // This may find characters that fall outside the range 0:wordLength,
     // so we won't necessarily use everything we find here.
 
-    bool isRightToLeft = aShapedWord->IsRightToLeft();
+    bool isRightToLeft = aShapedText->IsRightToLeft();
     int32_t glyphStart = 0; // looking for a clump that starts at this glyph index
     int32_t charStart = isRightToLeft ?
         stringRange.length - 1 : 0; // and this char index (in the stringRange of the glyph run)
@@ -438,7 +444,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedWord *aShapedWord,
 
         // Now we're ready to set the glyph info in the textRun; measure the glyph width
         // of the first (perhaps only) glyph, to see if it is "Simple"
-        int32_t appUnitsPerDevUnit = aShapedWord->AppUnitsPerDevUnit();
+        int32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();
         double toNextGlyph;
         if (glyphStart < numGlyphs-1) {
             toNextGlyph = positions[glyphStart+1].x - positions[glyphStart].x;
@@ -452,12 +458,11 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedWord *aShapedWord,
         if (glyphsInClump == 1 &&
             gfxTextRun::CompressedGlyph::IsSimpleGlyphID(glyphs[glyphStart]) &&
             gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance) &&
-            aShapedWord->IsClusterStart(baseCharIndex) &&
+            charGlyphs[baseCharIndex].IsClusterStart() &&
             positions[glyphStart].y == 0.0)
         {
-            aShapedWord->SetSimpleGlyph(baseCharIndex,
-                                        g.SetSimpleGlyph(advance,
-                                                         glyphs[glyphStart]));
+            charGlyphs[baseCharIndex].SetSimpleGlyph(advance,
+                                                     glyphs[glyphStart]);
         } else {
             // collect all glyphs in a list to be assigned to the first char;
             // there must be at least one in the clump, and we already measured its advance,
@@ -480,18 +485,18 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedWord *aShapedWord,
             }
 
             gfxTextRun::CompressedGlyph g;
-            g.SetComplex(aShapedWord->IsClusterStart(baseCharIndex),
+            g.SetComplex(charGlyphs[baseCharIndex].IsClusterStart(),
                          true, detailedGlyphs.Length());
-            aShapedWord->SetGlyphs(baseCharIndex, g, detailedGlyphs.Elements());
+            aShapedText->SetGlyphs(aOffset + baseCharIndex, g, detailedGlyphs.Elements());
 
             detailedGlyphs.Clear();
         }
 
         // the rest of the chars in the group are ligature continuations, no associated glyphs
         while (++baseCharIndex != endCharIndex && baseCharIndex < wordLength) {
-            g.SetComplex(inOrder && aShapedWord->IsClusterStart(baseCharIndex),
-                         false, 0);
-            aShapedWord->SetGlyphs(baseCharIndex, g, nullptr);
+            gfxShapedText::CompressedGlyph &g = charGlyphs[baseCharIndex];
+            NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
+            g.SetComplex(inOrder && g.IsClusterStart(), false, 0);
         }
 
         glyphStart = glyphEnd;
diff --git a/gfx/thebes/gfxCoreTextShaper.h b/gfx/thebes/gfxCoreTextShaper.h
index 05252268cfbf..aa22dcb6da42 100644
--- a/gfx/thebes/gfxCoreTextShaper.h
+++ b/gfx/thebes/gfxCoreTextShaper.h
@@ -22,9 +22,12 @@ public:
 
     virtual ~gfxCoreTextShaper();
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aText);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText);
 
     // clean up static objects that may have been cached
     static void Shutdown();
@@ -33,9 +36,11 @@ protected:
     CTFontRef mCTFont;
     CFDictionaryRef mAttributesDict;
 
-    nsresult SetGlyphsFromRun(gfxShapedWord *aShapedWord,
-                              CTRunRef aCTRun,
-                              int32_t aStringOffset);
+    nsresult SetGlyphsFromRun(gfxShapedText *aShapedText,
+                              uint32_t       aOffset,
+                              uint32_t       aLength,
+                              CTRunRef       aCTRun,
+                              int32_t        aStringOffset);
 
     CTFontRef CreateCTFontWithDisabledLigatures(CGFloat aSize);
 
diff --git a/gfx/thebes/gfxDWriteShaper.cpp b/gfx/thebes/gfxDWriteShaper.cpp
index a03d4e0dbc51..e27a7dc73f93 100644
--- a/gfx/thebes/gfxDWriteShaper.cpp
+++ b/gfx/thebes/gfxDWriteShaper.cpp
@@ -13,21 +13,24 @@
 #include "nsCRT.h"
 
 bool
-gfxDWriteShaper::ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString)
+gfxDWriteShaper::ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText)
 {
     HRESULT hr;
-    // TODO: Handle TEST_DISABLE_OPTIONAL_LIGATURES
+    // TODO: Handle TEXT_DISABLE_OPTIONAL_LIGATURES
 
     DWRITE_READING_DIRECTION readingDirection = 
-        aShapedWord->IsRightToLeft()
+        aShapedText->IsRightToLeft()
             ? DWRITE_READING_DIRECTION_RIGHT_TO_LEFT
             : DWRITE_READING_DIRECTION_LEFT_TO_RIGHT;
 
     gfxDWriteFont *font = static_cast(mFont);
 
-    gfxShapedWord::CompressedGlyph g;
+    gfxShapedText::CompressedGlyph g;
 
     IDWriteTextAnalyzer *analyzer =
         gfxWindowsPlatform::GetPlatform()->GetDWriteAnalyzer();
@@ -37,12 +40,12 @@ gfxDWriteShaper::ShapeWord(gfxContext *aContext,
 
     /**
      * There's an internal 16-bit limit on some things inside the analyzer,
-     * but we never attempt to shape a word longer than 64K characters
-     * in a single gfxShapedWord, so we cannot exceed that limit.
+     * but we never attempt to shape a word longer than 32K characters
+     * in a single call, so we cannot exceed that limit.
      */
-    UINT32 length = aShapedWord->Length();
+    UINT32 length = aLength;
 
-    TextAnalysis analysis(aString, length, NULL, readingDirection);
+    TextAnalysis analysis(aText, length, NULL, readingDirection);
     TextAnalysis::Run *runHead;
     hr = analysis.GenerateResults(analyzer, &runHead);
 
@@ -51,7 +54,7 @@ gfxDWriteShaper::ShapeWord(gfxContext *aContext,
         return false;
     }
 
-    uint32_t appUnitsPerDevPixel = aShapedWord->AppUnitsPerDevUnit();
+    uint32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
 
     UINT32 maxGlyphs = 0;
 trymoreglyphs:
@@ -77,7 +80,7 @@ trymoreglyphs:
 
     UINT32 actualGlyphs;
 
-    hr = analyzer->GetGlyphs(aString, length,
+    hr = analyzer->GetGlyphs(aText, length,
             font->GetFontFace(), FALSE, 
             readingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT,
             &runHead->mScript, NULL, NULL, NULL, NULL, 0,
@@ -104,7 +107,7 @@ trymoreglyphs:
 
     if (!static_cast(mFont)->mUseSubpixelPositions) {
         hr = analyzer->GetGdiCompatibleGlyphPlacements(
-                                          aString,
+                                          aText,
                                           clusters.Elements(),
                                           textProperties.Elements(),
                                           length,
@@ -126,7 +129,7 @@ trymoreglyphs:
                                           advances.Elements(),
                                           glyphOffsets.Elements());
     } else {
-        hr = analyzer->GetGlyphPlacements(aString,
+        hr = analyzer->GetGlyphPlacements(aText,
                                           clusters.Elements(),
                                           textProperties.Elements(),
                                           length,
@@ -150,16 +153,19 @@ trymoreglyphs:
         return false;
     }
 
-    nsAutoTArray detailedGlyphs;
+    nsAutoTArray detailedGlyphs;
+    gfxShapedText::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs();
 
     for (unsigned int c = 0; c < length; c++) {
         uint32_t k = clusters[c];
-        uint32_t absC = c;
+        uint32_t absC = aOffset + c;
 
         if (c > 0 && k == clusters[c - 1]) {
-            g.SetComplex(aShapedWord->IsClusterStart(absC), false, 0);
-            aShapedWord->SetGlyphs(absC, g, nullptr);
             // This is a cluster continuation. No glyph here.
+            gfxShapedText::CompressedGlyph &g = charGlyphs[absC];
+            NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
+            g.SetComplex(g.IsClusterStart(), false, 0);
             continue;
         }
 
@@ -177,12 +183,10 @@ trymoreglyphs:
         if (glyphCount == 1 && advance >= 0 &&
             glyphOffsets[k].advanceOffset == 0 &&
             glyphOffsets[k].ascenderOffset == 0 &&
-            aShapedWord->IsClusterStart(absC) &&
-            gfxShapedWord::CompressedGlyph::IsSimpleAdvance(advance) &&
-            gfxShapedWord::CompressedGlyph::IsSimpleGlyphID(indices[k])) {
-              aShapedWord->SetSimpleGlyph(absC, 
-                                          g.SetSimpleGlyph(advance, 
-                                                           indices[k]));
+            charGlyphs[absC].IsClusterStart() &&
+            gfxShapedText::CompressedGlyph::IsSimpleAdvance(advance) &&
+            gfxShapedText::CompressedGlyph::IsSimpleGlyphID(indices[k])) {
+              charGlyphs[absC].SetSimpleGlyph(advance, indices[k]);
         } else {
             if (detailedGlyphs.Length() < glyphCount) {
                 if (!detailedGlyphs.AppendElements(
@@ -212,9 +216,9 @@ trymoreglyphs:
                     appUnitsPerDevPixel;
                 totalAdvance += advances[k + z];
             }
-            aShapedWord->SetGlyphs(
+            aShapedText->SetGlyphs(
                 absC,
-                g.SetComplex(aShapedWord->IsClusterStart(absC),
+                g.SetComplex(charGlyphs[absC].IsClusterStart(),
                              true,
                              glyphCount),
                 detailedGlyphs.Elements());
diff --git a/gfx/thebes/gfxDWriteShaper.h b/gfx/thebes/gfxDWriteShaper.h
index bf5b73e7b362..874bd8913f2b 100644
--- a/gfx/thebes/gfxDWriteShaper.h
+++ b/gfx/thebes/gfxDWriteShaper.h
@@ -25,9 +25,12 @@ public:
         MOZ_COUNT_DTOR(gfxDWriteShaper);
     }
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText);
 };
 
 #endif /* GFX_DWRITESHAPER_H */
diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp
index 71db7688cc89..67fb0a34f12b 100644
--- a/gfx/thebes/gfxFT2Fonts.cpp
+++ b/gfx/thebes/gfxFT2Fonts.cpp
@@ -403,10 +403,13 @@ gfxFT2FontGroup::WhichSystemFontSupportsChar(uint32_t aCh, int32_t aRunScript)
  */
 
 bool
-gfxFT2Font::ShapeWord(gfxContext *aContext,
-                      gfxShapedWord *aShapedWord,
-                      const PRUnichar *aString,
-                      bool aPreferPlatformShaping)
+gfxFT2Font::ShapeText(gfxContext      *aContext,
+                      const PRUnichar *aText,
+                      uint32_t         aOffset,
+                      uint32_t         aLength,
+                      int32_t          aScript,
+                      gfxShapedText   *aShapedText,
+                      bool             aPreferPlatformShaping)
 {
     bool ok = false;
 
@@ -416,55 +419,56 @@ gfxFT2Font::ShapeWord(gfxContext *aContext,
             if (!mGraphiteShaper) {
                 mGraphiteShaper = new gfxGraphiteShaper(this);
             }
-            ok = mGraphiteShaper->ShapeWord(aContext, aShapedWord, aString);
+            ok = mGraphiteShaper->ShapeText(aContext, aText,
+                                            aOffset, aLength,
+                                            aScript, aShapedText);
         }
     }
 #endif
 
-    if (!ok && gfxPlatform::GetPlatform()->UseHarfBuzzForScript(aShapedWord->Script())) {
+    if (!ok && gfxPlatform::GetPlatform()->UseHarfBuzzForScript(aScript)) {
         if (!mHarfBuzzShaper) {
             gfxFT2LockedFace face(this);
             mFUnitsConvFactor = face.XScale();
 
             mHarfBuzzShaper = new gfxHarfBuzzShaper(this);
         }
-        ok = mHarfBuzzShaper->ShapeWord(aContext, aShapedWord, aString);
+        ok = mHarfBuzzShaper->ShapeText(aContext, aText,
+                                        aOffset, aLength,
+                                        aScript, aShapedText);
     }
 
     if (!ok) {
-        AddRange(aShapedWord, aString);
+        AddRange(aText, aOffset, aLength, aShapedText);
     }
 
-    if (IsSyntheticBold()) {
-        float synBoldOffset =
-            GetSyntheticBoldOffset() * CalcXScale(aContext);
-        aShapedWord->AdjustAdvancesForSyntheticBold(synBoldOffset);
-    }
+    PostShapingFixup(aContext, aText, aOffset, aLength, aShapedText);
 
     return true;
 }
 
 void
-gfxFT2Font::AddRange(gfxShapedWord *aShapedWord, const PRUnichar *str)
+gfxFT2Font::AddRange(const PRUnichar *aText, uint32_t aOffset,
+                     uint32_t aLength, gfxShapedText *aShapedText)
 {
-    const uint32_t appUnitsPerDevUnit = aShapedWord->AppUnitsPerDevUnit();
+    const uint32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();
     // we'll pass this in/figure it out dynamically, but at this point there can be only one face.
     gfxFT2LockedFace faceLock(this);
     FT_Face face = faceLock.get();
 
-    gfxShapedWord::CompressedGlyph g;
+    gfxShapedText::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs();
 
     const gfxFT2Font::CachedGlyphData *cgd = nullptr, *cgdNext = nullptr;
 
     FT_UInt spaceGlyph = GetSpaceGlyph();
 
-    uint32_t len = aShapedWord->Length();
-    for (uint32_t i = 0; i < len; i++) {
-        PRUnichar ch = str[i];
+    for (uint32_t i = 0; i < aLength; i++, aOffset++) {
+        PRUnichar ch = aText[i];
 
         if (ch == 0) {
             // treat this null byte as a missing glyph, don't create a glyph for it
-            aShapedWord->SetMissingGlyph(i, 0, this);
+            aShapedText->SetMissingGlyph(aOffset, 0, this);
             continue;
         }
 
@@ -489,8 +493,8 @@ gfxFT2Font::AddRange(gfxShapedWord *aShapedWord, const PRUnichar *str)
             FT_UInt gidNext = 0;
             FT_Pos lsbDeltaNext = 0;
 
-            if (FT_HAS_KERNING(face) && i + 1 < len) {
-                chNext = str[i + 1];
+            if (FT_HAS_KERNING(face) && i + 1 < aLength) {
+                chNext = aText[i + 1];
                 if (chNext != 0) {
                     cgdNext = GetGlyphDataForChar(chNext);
                     gidNext = cgdNext->glyphIndex;
@@ -520,21 +524,23 @@ gfxFT2Font::AddRange(gfxShapedWord *aShapedWord, const PRUnichar *str)
         }
 
         if (advance >= 0 &&
-            gfxShapedWord::CompressedGlyph::IsSimpleAdvance(advance) &&
-            gfxShapedWord::CompressedGlyph::IsSimpleGlyphID(gid)) {
-            aShapedWord->SetSimpleGlyph(i, g.SetSimpleGlyph(advance, gid));
+            gfxShapedText::CompressedGlyph::IsSimpleAdvance(advance) &&
+            gfxShapedText::CompressedGlyph::IsSimpleGlyphID(gid)) {
+            charGlyphs[aOffset].SetSimpleGlyph(advance, gid);
         } else if (gid == 0) {
             // gid = 0 only happens when the glyph is missing from the font
-            aShapedWord->SetMissingGlyph(i, ch, this);
+            aShapedText->SetMissingGlyph(aOffset, ch, this);
         } else {
             gfxTextRun::DetailedGlyph details;
             details.mGlyphID = gid;
-            NS_ASSERTION(details.mGlyphID == gid, "Seriously weird glyph ID detected!");
+            NS_ASSERTION(details.mGlyphID == gid,
+                         "Seriously weird glyph ID detected!");
             details.mAdvance = advance;
             details.mXOffset = 0;
             details.mYOffset = 0;
-            g.SetComplex(aShapedWord->IsClusterStart(i), true, 1);
-            aShapedWord->SetGlyphs(i, g, &details);
+            gfxShapedText::CompressedGlyph g;
+            g.SetComplex(charGlyphs[aOffset].IsClusterStart(), true, 1);
+            aShapedText->SetGlyphs(aOffset, g, &details);
         }
     }
 }
diff --git a/gfx/thebes/gfxFT2Fonts.h b/gfx/thebes/gfxFT2Fonts.h
index 70ae3279f62c..6794bd150a7d 100644
--- a/gfx/thebes/gfxFT2Fonts.h
+++ b/gfx/thebes/gfxFT2Fonts.h
@@ -69,14 +69,20 @@ public: // new functions
                                      FontCacheSizes*   aSizes) const;
 
 protected:
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString,
-                           bool aPreferPlatformShaping = false);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText,
+                           bool             aPreferPlatformShaping);
 
     void FillGlyphDataForChar(uint32_t ch, CachedGlyphData *gd);
 
-    void AddRange(gfxShapedWord *aShapedWord, const PRUnichar *str);
+    void AddRange(const PRUnichar *aText,
+                  uint32_t         aOffset,
+                  uint32_t         aLength,
+                  gfxShapedText   *aShapedText);
 
     typedef nsBaseHashtableET CharGlyphMapEntryType;
     typedef nsTHashtable CharGlyphMap;
diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp
index a25fcaec07fa..65dd392ccabc 100644
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2335,14 +2335,6 @@ gfxFont::Measure(gfxTextRun *aTextRun,
     return metrics;
 }
 
-#define MAX_SHAPING_LENGTH  32760 // slightly less than 32K, trying to avoid
-                                  // over-stressing platform shapers
-
-#define BACKTRACK_LIMIT  1024 // If we can't find a space or a cluster start
-                              // within 1K chars, just chop arbitrarily.
-                              // Limiting backtrack here avoids pathological
-                              // behavior on long runs with no whitespace.
-
 static bool
 IsBoundarySpace(PRUnichar aChar, PRUnichar aNextChar)
 {
@@ -2358,12 +2350,12 @@ HashMix(uint32_t aHash, PRUnichar aCh)
 template
 gfxShapedWord*
 gfxFont::GetShapedWord(gfxContext *aContext,
-                       const T *aText,
-                       uint32_t aLength,
-                       uint32_t aHash,
-                       int32_t aRunScript,
-                       int32_t aAppUnitsPerDevUnit,
-                       uint32_t aFlags)
+                       const T    *aText,
+                       uint32_t    aLength,
+                       uint32_t    aHash,
+                       int32_t     aRunScript,
+                       int32_t     aAppUnitsPerDevUnit,
+                       uint32_t    aFlags)
 {
     // if the cache is getting too big, flush it and start over
     if (mWordCache.Count() > 10000) {
@@ -2400,28 +2392,10 @@ gfxFont::GetShapedWord(gfxContext *aContext,
         return nullptr;
     }
 
-    DebugOnly ok = false;
-    if (sizeof(T) == sizeof(PRUnichar)) {
-        ok = ShapeWord(aContext, sw, (const PRUnichar*)aText);
-    } else {
-        nsAutoString utf16;
-        AppendASCIItoUTF16(nsDependentCSubstring((const char*)aText, aLength),
-                           utf16);
-        if (utf16.Length() == aLength) {
-            ok = ShapeWord(aContext, sw, utf16.BeginReading());
-        }
-    }
-    NS_WARN_IF_FALSE(ok, "failed to shape word - expect garbled text");
+    DebugOnly ok =
+        ShapeText(aContext, aText, 0, aLength, aRunScript, sw);
 
-    for (uint32_t i = 0; i < aLength; ++i) {
-        if (aText[i] == ' ') {
-            sw->SetIsSpace(i);
-        } else if (i > 0 &&
-                   NS_IS_HIGH_SURROGATE(aText[i - 1]) &&
-                   NS_IS_LOW_SURROGATE(aText[i])) {
-            sw->SetIsLowSurrogate(i);
-        }
-    }
+    NS_WARN_IF_FALSE(ok, "failed to shape word - expect garbled text");
 
     return sw;
 }
@@ -2433,9 +2407,9 @@ gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
     if (!sw) {
         return false;
     }
-    if (sw->Length() != aKey->mLength ||
+    if (sw->GetLength() != aKey->mLength ||
         sw->Flags() != aKey->mFlags ||
-        sw->AppUnitsPerDevUnit() != aKey->mAppUnitsPerDevUnit ||
+        sw->GetAppUnitsPerDevUnit() != aKey->mAppUnitsPerDevUnit ||
         sw->Script() != aKey->mScript) {
         return false;
     }
@@ -2464,22 +2438,46 @@ gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
 }
 
 bool
-gfxFont::ShapeWord(gfxContext *aContext,
-                   gfxShapedWord *aShapedWord,
+gfxFont::ShapeText(gfxContext    *aContext,
+                   const uint8_t *aText,
+                   uint32_t       aOffset,
+                   uint32_t       aLength,
+                   int32_t        aScript,
+                   gfxShapedText *aShapedText,
+                   bool           aPreferPlatformShaping)
+{
+    nsDependentCSubstring ascii((const char*)aText, aLength);
+    nsAutoString utf16;
+    AppendASCIItoUTF16(ascii, utf16);
+    if (utf16.Length() != aLength) {
+        return false;
+    }
+    return ShapeText(aContext, utf16.BeginReading(), aOffset, aLength,
+                     aScript, aShapedText, aPreferPlatformShaping);
+}
+
+bool
+gfxFont::ShapeText(gfxContext      *aContext,
                    const PRUnichar *aText,
-                   bool aPreferPlatformShaping)
+                   uint32_t         aOffset,
+                   uint32_t         aLength,
+                   int32_t          aScript,
+                   gfxShapedText   *aShapedText,
+                   bool             aPreferPlatformShaping)
 {
     bool ok = false;
 
 #ifdef MOZ_GRAPHITE
     if (mGraphiteShaper && gfxPlatform::GetPlatform()->UseGraphiteShaping()) {
-        ok = mGraphiteShaper->ShapeWord(aContext, aShapedWord, aText);
+        ok = mGraphiteShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                        aScript, aShapedText);
     }
 #endif
 
     if (!ok && mHarfBuzzShaper && !aPreferPlatformShaping) {
-        if (gfxPlatform::GetPlatform()->UseHarfBuzzForScript(aShapedWord->Script())) {
-            ok = mHarfBuzzShaper->ShapeWord(aContext, aShapedWord, aText);
+        if (gfxPlatform::GetPlatform()->UseHarfBuzzForScript(aScript)) {
+            ok = mHarfBuzzShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                            aScript, aShapedText);
         }
     }
 
@@ -2489,19 +2487,134 @@ gfxFont::ShapeWord(gfxContext *aContext,
             NS_ASSERTION(mPlatformShaper, "no platform shaper available!");
         }
         if (mPlatformShaper) {
-            ok = mPlatformShaper->ShapeWord(aContext, aShapedWord, aText);
+            ok = mPlatformShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                            aScript, aShapedText);
         }
     }
 
-    if (ok && IsSyntheticBold()) {
+    PostShapingFixup(aContext, aText, aOffset, aLength, aShapedText);
+
+    return ok;
+}
+
+void
+gfxFont::PostShapingFixup(gfxContext      *aContext,
+                          const PRUnichar *aText,
+                          uint32_t         aOffset,
+                          uint32_t         aLength,
+                          gfxShapedText   *aShapedText)
+{
+    if (IsSyntheticBold()) {
         float synBoldOffset =
                 GetSyntheticBoldOffset() * CalcXScale(aContext);
-        aShapedWord->AdjustAdvancesForSyntheticBold(synBoldOffset);
+        aShapedText->AdjustAdvancesForSyntheticBold(synBoldOffset,
+                                                    aOffset, aLength);
+    }
+}
+
+#define MAX_SHAPING_LENGTH  32760 // slightly less than 32K, trying to avoid
+                                  // over-stressing platform shapers
+#define BACKTRACK_LIMIT     16 // backtrack this far looking for a good place
+                               // to split into fragments for separate shaping
+
+template
+bool
+gfxFont::ShapeFragmentWithoutWordCache(gfxContext *aContext,
+                                       const T    *aText,
+                                       uint32_t    aOffset,
+                                       uint32_t    aLength,
+                                       int32_t     aScript,
+                                       gfxTextRun *aTextRun)
+{
+    aTextRun->SetupClusterBoundaries(aOffset, aText, aLength);
+
+    bool ok = true;
+
+    while (ok && aLength > 0) {
+        uint32_t fragLen = aLength;
+
+        // limit the length of text we pass to shapers in a single call
+        if (fragLen > MAX_SHAPING_LENGTH) {
+            fragLen = MAX_SHAPING_LENGTH;
+
+            // in the 8-bit case, there are no multi-char clusters,
+            // so we don't need to do this check
+            if (sizeof(T) == sizeof(PRUnichar)) {
+                uint32_t i;
+                for (i = 0; i < BACKTRACK_LIMIT; ++i) {
+                    if (aTextRun->IsClusterStart(aOffset + fragLen - i)) {
+                        fragLen -= i;
+                        break;
+                    }
+                }
+                if (i == BACKTRACK_LIMIT) {
+                    // if we didn't find any cluster start while backtracking,
+                    // just check that we're not in the middle of a surrogate
+                    // pair; back up by one code unit if we are.
+                    if (NS_IS_LOW_SURROGATE(aText[fragLen]) &&
+                        NS_IS_HIGH_SURROGATE(aText[fragLen - 1])) {
+                        --fragLen;
+                    }
+                }
+            }
+        }
+
+        ok = ShapeText(aContext, aText, aOffset, fragLen, aScript, aTextRun);
+
+        aText += fragLen;
+        aOffset += fragLen;
+        aLength -= fragLen;
     }
 
     return ok;
 }
 
+template
+bool
+gfxFont::ShapeTextWithoutWordCache(gfxContext *aContext,
+                                   const T    *aText,
+                                   uint32_t    aOffset,
+                                   uint32_t    aLength,
+                                   int32_t     aScript,
+                                   gfxTextRun *aTextRun)
+{
+    uint32_t fragStart = 0;
+    bool ok = true;
+
+    for (uint32_t i = 0; i <= aLength && ok; ++i) {
+        T ch = (i < aLength) ? aText[i] : '\n';
+        bool invalid = gfxFontGroup::IsInvalidChar(ch);
+        uint32_t length = i - fragStart;
+
+        // break into separate fragments when we hit an invalid char
+        if (!invalid) {
+            continue;
+        }
+
+        if (length > 0) {
+            ok = ShapeFragmentWithoutWordCache(aContext, aText + fragStart,
+                                               aOffset + fragStart, length,
+                                               aScript, aTextRun);
+        }
+
+        if (i == aLength) {
+            break;
+        }
+
+        // fragment was terminated by an invalid char: skip it,
+        // but record where TAB or NEWLINE occur
+        if (ch == '\t') {
+            aTextRun->SetIsTab(aOffset + i);
+        } else if (ch == '\n') {
+            aTextRun->SetIsNewline(aOffset + i);
+        }
+        fragStart = i + 1;
+    }
+
+    NS_WARN_IF_FALSE(ok, "failed to shape text - expect garbled text");
+    return ok;
+}
+
 inline static bool IsChar8Bit(uint8_t /*aCh*/) { return true; }
 inline static bool IsChar8Bit(PRUnichar aCh) { return aCh < 0x100; }
 
@@ -2548,7 +2661,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
         bool breakHere = boundary || invalid;
 
         if (!breakHere) {
-            // if we're approaching the max ShapedWord length, break anyway...
+            // if we're approaching the max length for shaping, break anyway...
             if (sizeof(T) == sizeof(uint8_t)) {
                 // in 8-bit text, no clusters or surrogates to worry about
                 if (length >= gfxShapedWord::kMaxLength) {
@@ -3768,7 +3881,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
     for (uint32_t r = 0; r < numRanges; r++) {
         const gfxTextRange& range = fontRanges[r];
         uint32_t matchedLength = range.Length();
-        gfxFont *matchedFont = (range.font ? range.font.get() : nullptr);
+        gfxFont *matchedFont = range.font;
 
         // create the glyph run for this range
         if (matchedFont) {
@@ -3787,14 +3900,11 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
         }
 
         if (!matchedFont) {
-            // for PRUnichar text, we need to set cluster boundaries so that
+            // We need to set cluster boundaries (and mark spaces) so that
             // surrogate pairs, combining characters, etc behave properly,
             // even if we don't have glyphs for them
-            if (sizeof(T) == sizeof(PRUnichar)) {
-                gfxShapedWord::SetupClusterBoundaries(aTextRun->GetCharacterGlyphs() + runStart,
-                                                      reinterpret_cast(aString) + runStart,
-                                                      matchedLength);
-            }
+            aTextRun->SetupClusterBoundaries(runStart, aString + runStart,
+                                             matchedLength);
 
             // various "missing" characters may need special handling,
             // so we check for them here
@@ -3822,9 +3932,9 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
                     {
                         aTextRun->SetMissingGlyph(index,
                                                   SURROGATE_TO_UCS4(ch,
-                                                                    aString[index + 1]));
+                                                                    aString[index + 1]),
+                                                  mainFont);
                         index++;
-                        aTextRun->SetIsLowSurrogate(index);
                         continue;
                     }
 
@@ -3834,16 +3944,16 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
                     if (wid >= 0.0) {
                         nscoord advance =
                             aTextRun->GetAppUnitsPerDevUnit() * floor(wid + 0.5);
-                        gfxTextRun::CompressedGlyph g;
-                        if (gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance)) {
-                            aTextRun->SetSimpleGlyph(index,
-                                                     g.SetSimpleGlyph(advance,
-                                                         mainFont->GetSpaceGlyph()));
+                        if (gfxShapedText::CompressedGlyph::IsSimpleAdvance(advance)) {
+                            aTextRun->GetCharacterGlyphs()[index].
+                                SetSimpleGlyph(advance,
+                                               mainFont->GetSpaceGlyph());
                         } else {
                             gfxTextRun::DetailedGlyph detailedGlyph;
                             detailedGlyph.mGlyphID = mainFont->GetSpaceGlyph();
                             detailedGlyph.mAdvance = advance;
                             detailedGlyph.mXOffset = detailedGlyph.mYOffset = 0;
+                            gfxShapedText::CompressedGlyph g;
                             g.SetComplex(true, true, 1);
                             aTextRun->SetGlyphs(index,
                                                 g, &detailedGlyph);
@@ -3858,7 +3968,7 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext,
                 }
 
                 // record char code so we can draw a box with the Unicode value
-                aTextRun->SetMissingGlyph(index, ch);
+                aTextRun->SetMissingGlyph(index, ch, mainFont);
             }
         }
 
@@ -4329,13 +4439,13 @@ gfxFontStyle::ComputeWeight() const
     return baseWeight;
 }
 
-// This is not a member function of gfxShapedWord because it is also used
-// by gfxFontGroup on missing-glyph runs, where we don't actually "shape"
-// anything but still need to set cluster info.
-/*static*/ void
-gfxShapedWord::SetupClusterBoundaries(CompressedGlyph *aGlyphs,
-                                      const PRUnichar *aString, uint32_t aLength)
+void
+gfxShapedText::SetupClusterBoundaries(uint32_t         aOffset,
+                                      const PRUnichar *aString,
+                                      uint32_t         aLength)
 {
+    CompressedGlyph *glyphs = GetCharacterGlyphs() + aOffset;
+
     gfxTextRun::CompressedGlyph extendCluster;
     extendCluster.SetComplex(false, true, 0);
 
@@ -4344,27 +4454,51 @@ gfxShapedWord::SetupClusterBoundaries(CompressedGlyph *aGlyphs,
     // the ClusterIterator won't be able to tell us if the string
     // _begins_ with a cluster-extender, so we handle that here
     if (aLength && IsClusterExtender(*aString)) {
-        *aGlyphs = extendCluster;
+        *glyphs = extendCluster;
     }
 
     while (!iter.AtEnd()) {
+        if (*iter == PRUnichar(' ')) {
+            glyphs->SetIsSpace();
+        }
         // advance iter to the next cluster-start (or end of text)
         iter.Next();
         // step past the first char of the cluster
         aString++;
-        aGlyphs++;
+        glyphs++;
         // mark all the rest as cluster-continuations
         while (aString < iter) {
-            *aGlyphs++ = extendCluster;
+            *glyphs = extendCluster;
+            if (NS_IS_LOW_SURROGATE(*aString)) {
+                glyphs->SetIsLowSurrogate();
+            }
+            glyphs++;
             aString++;
         }
     }
 }
 
-gfxShapedWord::DetailedGlyph *
-gfxShapedWord::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
+void
+gfxShapedText::SetupClusterBoundaries(uint32_t       aOffset,
+                                      const uint8_t *aString,
+                                      uint32_t       aLength)
 {
-    NS_ASSERTION(aIndex < Length(), "Index out of range");
+    CompressedGlyph *glyphs = GetCharacterGlyphs() + aOffset;
+    const uint8_t *limit = aString + aLength;
+
+    while (aString < limit) {
+        if (*aString == uint8_t(' ')) {
+            glyphs->SetIsSpace();
+        }
+        aString++;
+        glyphs++;
+    }
+}
+
+gfxShapedText::DetailedGlyph *
+gfxShapedText::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
+{
+    NS_ASSERTION(aIndex < GetLength(), "Index out of range");
 
     if (!mDetailedGlyphs) {
         mDetailedGlyphs = new DetailedGlyphStore();
@@ -4372,7 +4506,7 @@ gfxShapedWord::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
 
     DetailedGlyph *details = mDetailedGlyphs->Allocate(aIndex, aCount);
     if (!details) {
-        mCharacterGlyphs[aIndex].SetMissing(0);
+        GetCharacterGlyphs()[aIndex].SetMissing(0);
         return nullptr;
     }
 
@@ -4380,7 +4514,7 @@ gfxShapedWord::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
 }
 
 void
-gfxShapedWord::SetGlyphs(uint32_t aIndex, CompressedGlyph aGlyph,
+gfxShapedText::SetGlyphs(uint32_t aIndex, CompressedGlyph aGlyph,
                          const DetailedGlyph *aGlyphs)
 {
     NS_ASSERTION(!aGlyph.IsSimpleGlyph(), "Simple glyphs not handled here");
@@ -4395,7 +4529,7 @@ gfxShapedWord::SetGlyphs(uint32_t aIndex, CompressedGlyph aGlyph,
         }
         memcpy(details, aGlyphs, sizeof(DetailedGlyph)*glyphCount);
     }
-    mCharacterGlyphs[aIndex] = aGlyph;
+    GetCharacterGlyphs()[aIndex] = aGlyph;
 }
 
 #define ZWNJ 0x200C
@@ -4408,8 +4542,15 @@ IsDefaultIgnorable(uint32_t aChar)
 }
 
 void
-gfxShapedWord::SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont)
+gfxShapedText::SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont)
 {
+    uint8_t category = GetGeneralCategory(aChar);
+    if (category >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK &&
+        category <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
+    {
+        GetCharacterGlyphs()[aIndex].SetComplex(false, true, 0);
+    }
+
     DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, 1);
     if (!details) {
         return;
@@ -4426,21 +4567,20 @@ gfxShapedWord::SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont)
     }
     details->mXOffset = 0;
     details->mYOffset = 0;
-    mCharacterGlyphs[aIndex].SetMissing(1);
+    GetCharacterGlyphs()[aIndex].SetMissing(1);
 }
 
 bool
-gfxShapedWord::FilterIfIgnorable(uint32_t aIndex)
+gfxShapedText::FilterIfIgnorable(uint32_t aIndex, uint32_t aCh)
 {
-    uint32_t ch = GetCharAt(aIndex);
-    if (IsDefaultIgnorable(ch)) {
+    if (IsDefaultIgnorable(aCh)) {
         DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, 1);
         if (details) {
-            details->mGlyphID = ch;
+            details->mGlyphID = aCh;
             details->mAdvance = 0;
             details->mXOffset = 0;
             details->mYOffset = 0;
-            mCharacterGlyphs[aIndex].SetMissing(1);
+            GetCharacterGlyphs()[aIndex].SetMissing(1);
             return true;
         }
     }
@@ -4448,11 +4588,14 @@ gfxShapedWord::FilterIfIgnorable(uint32_t aIndex)
 }
 
 void
-gfxShapedWord::AdjustAdvancesForSyntheticBold(float aSynBoldOffset)
+gfxShapedText::AdjustAdvancesForSyntheticBold(float aSynBoldOffset,
+                                              uint32_t aOffset,
+                                              uint32_t aLength)
 {
     uint32_t synAppUnitOffset = aSynBoldOffset * mAppUnitsPerDevUnit;
-    for (uint32_t i = 0; i < Length(); ++i) {
-         CompressedGlyph *glyphData = &mCharacterGlyphs[i];
+    CompressedGlyph *charGlyphs = GetCharacterGlyphs();
+    for (uint32_t i = aOffset; i < aOffset + aLength; ++i) {
+         CompressedGlyph *glyphData = charGlyphs + i;
          if (glyphData->IsSimpleGlyph()) {
              // simple glyphs ==> just add the advance
              int32_t advance = glyphData->GetSimpleAdvance() + synAppUnitOffset;
@@ -4493,7 +4636,7 @@ gfxTextRun::GlyphRunIterator::NextRun()  {
 
     mStringStart = NS_MAX(mStartOffset, mGlyphRun->mCharacterOffset);
     uint32_t last = mNextIndex + 1 < mTextRun->mGlyphRuns.Length()
-        ? mTextRun->mGlyphRuns[mNextIndex + 1].mCharacterOffset : mTextRun->mCharacterCount;
+        ? mTextRun->mGlyphRuns[mNextIndex + 1].mCharacterOffset : mTextRun->GetLength();
     mStringEnd = NS_MIN(mEndOffset, last);
 
     ++mNextIndex;
@@ -4553,10 +4696,9 @@ gfxTextRun::Create(const gfxTextRunFactory::Parameters *aParams,
 
 gfxTextRun::gfxTextRun(const gfxTextRunFactory::Parameters *aParams,
                        uint32_t aLength, gfxFontGroup *aFontGroup, uint32_t aFlags)
-  : mUserData(aParams->mUserData),
-    mFontGroup(aFontGroup),
-    mAppUnitsPerDevUnit(aParams->mAppUnitsPerDevUnit),
-    mFlags(aFlags), mCharacterCount(aLength)
+    : gfxShapedText(aLength, aFlags, aParams->mAppUnitsPerDevUnit)
+    , mUserData(aParams->mUserData)
+    , mFontGroup(aFontGroup)
 {
     NS_ASSERTION(mAppUnitsPerDevUnit != 0, "Invalid app unit scale");
     MOZ_COUNT_CTOR(gfxTextRun);
@@ -4594,7 +4736,7 @@ gfxTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
                                    uint8_t *aBreakBefore,
                                    gfxContext *aRefContext)
 {
-    NS_ASSERTION(aStart + aLength <= mCharacterCount, "Overflow");
+    NS_ASSERTION(aStart + aLength <= GetLength(), "Overflow");
 
     uint32_t changed = 0;
     uint32_t i;
@@ -4617,7 +4759,7 @@ gfxTextRun::ComputeLigatureData(uint32_t aPartStart, uint32_t aPartEnd,
                                 PropertyProvider *aProvider)
 {
     NS_ASSERTION(aPartStart < aPartEnd, "Computing ligature data for empty range");
-    NS_ASSERTION(aPartEnd <= mCharacterCount, "Character length overflow");
+    NS_ASSERTION(aPartEnd <= GetLength(), "Character length overflow");
   
     LigatureData result;
     CompressedGlyph *charGlyphs = mCharacterGlyphs;
@@ -4627,7 +4769,7 @@ gfxTextRun::ComputeLigatureData(uint32_t aPartStart, uint32_t aPartEnd,
         NS_ASSERTION(i > 0, "Ligature at the start of the run??");
     }
     result.mLigatureStart = i;
-    for (i = aPartStart + 1; i < mCharacterCount && !charGlyphs[i].IsLigatureGroupStart(); ++i) {
+    for (i = aPartStart + 1; i < GetLength() && !charGlyphs[i].IsLigatureGroupStart(); ++i) {
     }
     result.mLigatureEnd = i;
 
@@ -4782,7 +4924,7 @@ gfxTextRun::ShrinkToLigatureBoundaries(uint32_t *aStart, uint32_t *aEnd)
     while (*aStart < *aEnd && !charGlyphs[*aStart].IsLigatureGroupStart()) {
         ++(*aStart);
     }
-    if (*aEnd < mCharacterCount) {
+    if (*aEnd < GetLength()) {
         while (*aEnd > *aStart && !charGlyphs[*aEnd].IsLigatureGroupStart()) {
             --(*aEnd);
         }
@@ -4947,7 +5089,7 @@ gfxTextRun::Draw(gfxContext *aContext, gfxPoint aPt, gfxFont::DrawMode aDrawMode
                  gfxTextObjectPaint *aObjectPaint,
                  gfxTextRun::DrawCallbacks *aCallbacks)
 {
-    NS_ASSERTION(aStart + aLength <= mCharacterCount, "Substring out of range");
+    NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
     NS_ASSERTION(aDrawMode <= gfxFont::GLYPH_PATH, "GLYPH_PATH cannot be used with GLYPH_FILL or GLYPH_STROKE");
     NS_ASSERTION(aDrawMode == gfxFont::GLYPH_PATH || !aCallbacks, "callback must not be specified unless using GLYPH_PATH");
 
@@ -5085,7 +5227,7 @@ gfxTextRun::MeasureText(uint32_t aStart, uint32_t aLength,
                         gfxContext *aRefContext,
                         PropertyProvider *aProvider)
 {
-    NS_ASSERTION(aStart + aLength <= mCharacterCount, "Substring out of range");
+    NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
 
     Metrics accumulatedMetrics;
     GlyphRunIterator iter(this, aStart, aLength);
@@ -5133,9 +5275,9 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
                                 bool aCanWordWrap,
                                 gfxBreakPriority *aBreakPriority)
 {
-    aMaxLength = NS_MIN(aMaxLength, mCharacterCount - aStart);
+    aMaxLength = NS_MIN(aMaxLength, GetLength() - aStart);
 
-    NS_ASSERTION(aStart + aMaxLength <= mCharacterCount, "Substring out of range");
+    NS_ASSERTION(aStart + aMaxLength <= GetLength(), "Substring out of range");
 
     uint32_t bufferStart = aStart;
     uint32_t bufferLength = NS_MIN(aMaxLength, MEASUREMENT_BUFFER_SIZE);
@@ -5294,7 +5436,7 @@ gfxFloat
 gfxTextRun::GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
                             PropertyProvider *aProvider)
 {
-    NS_ASSERTION(aStart + aLength <= mCharacterCount, "Substring out of range");
+    NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
 
     uint32_t ligatureRunStart = aStart;
     uint32_t ligatureRunEnd = aStart + aLength;
@@ -5338,10 +5480,10 @@ gfxTextRun::SetLineBreaks(uint32_t aStart, uint32_t aLength,
 uint32_t
 gfxTextRun::FindFirstGlyphRunContaining(uint32_t aOffset)
 {
-    NS_ASSERTION(aOffset <= mCharacterCount, "Bad offset looking for glyphrun");
-    NS_ASSERTION(mCharacterCount == 0 || mGlyphRuns.Length() > 0,
+    NS_ASSERTION(aOffset <= GetLength(), "Bad offset looking for glyphrun");
+    NS_ASSERTION(GetLength() == 0 || mGlyphRuns.Length() > 0,
                  "non-empty text but no glyph runs present!");
-    if (aOffset == mCharacterCount)
+    if (aOffset == GetLength())
         return mGlyphRuns.Length();
     uint32_t start = 0;
     uint32_t end = mGlyphRuns.Length();
@@ -5459,13 +5601,13 @@ gfxTextRun::SanitizeGlyphRuns()
     for (i = lastRunIndex; i >= 0; --i) {
         GlyphRun& run = mGlyphRuns[i];
         while (charGlyphs[run.mCharacterOffset].IsLigatureContinuation() &&
-               run.mCharacterOffset < mCharacterCount) {
+               run.mCharacterOffset < GetLength()) {
             run.mCharacterOffset++;
         }
         // if the run has become empty, eliminate it
         if ((i < lastRunIndex &&
              run.mCharacterOffset >= mGlyphRuns[i+1].mCharacterOffset) ||
-            (i == lastRunIndex && run.mCharacterOffset == mCharacterCount)) {
+            (i == lastRunIndex && run.mCharacterOffset == GetLength())) {
             mGlyphRuns.RemoveElementAt(i);
             --lastRunIndex;
         }
@@ -5477,7 +5619,7 @@ gfxTextRun::CountMissingGlyphs()
 {
     uint32_t i;
     uint32_t count = 0;
-    for (i = 0; i < mCharacterCount; ++i) {
+    for (i = 0; i < GetLength(); ++i) {
         if (mCharacterGlyphs[i].IsMissing()) {
             ++count;
         }
@@ -5488,7 +5630,7 @@ gfxTextRun::CountMissingGlyphs()
 gfxTextRun::DetailedGlyph *
 gfxTextRun::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
 {
-    NS_ASSERTION(aIndex < mCharacterCount, "Index out of range");
+    NS_ASSERTION(aIndex < GetLength(), "Index out of range");
 
     if (!mDetailedGlyphs) {
         mDetailedGlyphs = new DetailedGlyphStore();
@@ -5504,65 +5646,19 @@ gfxTextRun::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
 }
 
 void
-gfxTextRun::SetGlyphs(uint32_t aIndex, CompressedGlyph aGlyph,
-                      const DetailedGlyph *aGlyphs)
+gfxTextRun::CopyGlyphDataFrom(gfxShapedWord *aShapedWord, uint32_t aOffset)
 {
-    NS_ASSERTION(!aGlyph.IsSimpleGlyph(), "Simple glyphs not handled here");
-    NS_ASSERTION(aIndex > 0 || aGlyph.IsLigatureGroupStart(),
-                 "First character can't be a ligature continuation!");
-
-    uint32_t glyphCount = aGlyph.GetGlyphCount();
-    if (glyphCount > 0) {
-        DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, glyphCount);
-        if (!details)
-            return;
-        memcpy(details, aGlyphs, sizeof(DetailedGlyph)*glyphCount);
-    }
-    mCharacterGlyphs[aIndex] = aGlyph;
-}
-
-void
-gfxTextRun::SetMissingGlyph(uint32_t aIndex, uint32_t aChar)
-{
-    uint8_t category = GetGeneralCategory(aChar);
-    if (category >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK &&
-        category <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
-    {
-        mCharacterGlyphs[aIndex].SetComplex(false, true, 0);
-    }
-
-    DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, 1);
-    if (!details)
-        return;
-
-    details->mGlyphID = aChar;
-    GlyphRun *glyphRun = &mGlyphRuns[FindFirstGlyphRunContaining(aIndex)];
-    if (IsDefaultIgnorable(aChar)) {
-        // Setting advance width to zero will prevent drawing the hexbox
-        details->mAdvance = 0;
-    } else {
-        gfxFloat width = NS_MAX(glyphRun->mFont->GetMetrics().aveCharWidth,
-                                gfxFontMissingGlyphs::GetDesiredMinWidth(aChar));
-        details->mAdvance = uint32_t(width*GetAppUnitsPerDevUnit());
-    }
-    details->mXOffset = 0;
-    details->mYOffset = 0;
-    mCharacterGlyphs[aIndex].SetMissing(1);
-}
-
-void
-gfxTextRun::CopyGlyphDataFrom(const gfxShapedWord *aShapedWord, uint32_t aOffset)
-{
-    uint32_t wordLen = aShapedWord->Length();
+    uint32_t wordLen = aShapedWord->GetLength();
     NS_ASSERTION(aOffset + wordLen <= GetLength(),
                  "word overruns end of textrun!");
 
+    CompressedGlyph *charGlyphs = GetCharacterGlyphs();
     const CompressedGlyph *wordGlyphs = aShapedWord->GetCharacterGlyphs();
     if (aShapedWord->HasDetailedGlyphs()) {
         for (uint32_t i = 0; i < wordLen; ++i, ++aOffset) {
             const CompressedGlyph& g = wordGlyphs[i];
             if (g.IsSimpleGlyph()) {
-                SetSimpleGlyph(aOffset, g);
+                charGlyphs[aOffset] = g;
             } else {
                 const DetailedGlyph *details =
                     g.GetGlyphCount() > 0 ?
@@ -5571,7 +5667,7 @@ gfxTextRun::CopyGlyphDataFrom(const gfxShapedWord *aShapedWord, uint32_t aOffset
             }
         }
     } else {
-        memcpy(GetCharacterGlyphs() + aOffset, wordGlyphs,
+        memcpy(charGlyphs + aOffset, wordGlyphs,
                wordLen * sizeof(CompressedGlyph));
     }
 }
@@ -5696,7 +5792,7 @@ gfxTextRun::SetSpaceGlyphIfSimple(gfxFont *aFont, gfxContext *aContext,
     if (aSpaceChar == ' ') {
         g.SetIsSpace();
     }
-    SetSimpleGlyph(aCharIndex, g);
+    GetCharacterGlyphs()[aCharIndex] = g;
     return true;
 }
 
diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h
index 752175764020..b83c295bc930 100644
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -41,6 +41,7 @@ class gfxFontFamily;
 class gfxFontGroup;
 class gfxUserFontSet;
 class gfxUserFontData;
+class gfxShapedText;
 class gfxShapedWord;
 class gfxSVGGlyphs;
 class gfxTextObjectPaint;
@@ -1126,9 +1127,15 @@ public:
 
     virtual ~gfxFontShaper() { }
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aText) = 0;
+    // Shape a piece of text and store the resulting glyph data into
+    // aShapedText. Parameters aOffset/aLength indicate the range of
+    // aShapedText to be updated; aLength is also the length of aText.
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText) = 0;
 
     gfxFont *GetFont() const { return mFont; }
 
@@ -1561,13 +1568,61 @@ public:
     { return gfxPlatform::GetPlatform()->GetScaledFontForFont(aTarget, this); }
 
 protected:
+    // For 8-bit text, expand to 16-bit and then call the following method.
+    bool ShapeText(gfxContext    *aContext,
+                   const uint8_t *aText,
+                   uint32_t       aOffset, // dest offset in gfxShapedText
+                   uint32_t       aLength,
+                   int32_t        aScript,
+                   gfxShapedText *aShapedText, // where to store the result
+                   bool           aPreferPlatformShaping = false);
+
     // Call the appropriate shaper to generate glyphs for aText and store
-    // them into aShapedWord.
-    // The length of the text is aShapedWord->Length().
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
+    // them into aShapedText.
+    virtual bool ShapeText(gfxContext      *aContext,
                            const PRUnichar *aText,
-                           bool aPreferPlatformShaping = false);
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText,
+                           bool             aPreferPlatformShaping = false);
+
+    // Helper to adjust for synthetic bold and set character-type flags
+    // in the shaped text; implementations of ShapeText should call this
+    // after glyph shaping has been completed.
+    void PostShapingFixup(gfxContext      *aContext,
+                          const PRUnichar *aText,
+                          uint32_t         aOffset, // position within aShapedText
+                          uint32_t         aLength,
+                          gfxShapedText   *aShapedText);
+
+    // Shape text directly into a range within a textrun, without using the
+    // font's word cache. Intended for use when the font has layout features
+    // that involve space, and therefore require shaping complete runs rather
+    // than isolated words, or for long strings that are inefficient to cache.
+    // This will split the text on "invalid" characters (tab/newline) that are
+    // not handled via normal shaping, but does not otherwise divide up the
+    // text.
+    template
+    bool ShapeTextWithoutWordCache(gfxContext *aContext,
+                                   const T    *aText,
+                                   uint32_t    aOffset,
+                                   uint32_t    aLength,
+                                   int32_t     aScript,
+                                   gfxTextRun *aTextRun);
+
+    // Shape a fragment of text (a run that is known to contain only
+    // "valid" characters, no newlines/tabs/other control chars).
+    // All non-wordcache shaping goes through here; this is the function
+    // that will ensure we don't pass excessively long runs to the various
+    // platform shapers.
+    template
+    bool ShapeFragmentWithoutWordCache(gfxContext *aContext,
+                                       const T    *aText,
+                                       uint32_t    aOffset,
+                                       uint32_t    aLength,
+                                       int32_t     aScript,
+                                       gfxTextRun *aTextRun);
 
     nsRefPtr mFontEntry;
 
@@ -1724,8 +1779,9 @@ protected:
 #define DEFAULT_XHEIGHT_FACTOR 0.56f
 
 /*
- * gfxShapedWord stores a list of zero or more glyphs for each character. For each
- * glyph we store the glyph ID, the advance, and possibly an xoffset and yoffset.
+ * gfxShapedText is an abstract superclass for gfxShapedWord and gfxTextRun.
+ * These are objects that store a list of zero or more glyphs for each character.
+ * For each glyph we store the glyph ID, the advance, and possibly x/y-offsets.
  * The idea is that a string is rendered by a loop that draws each glyph
  * at its designated offset from the current point, then advances the current
  * point by the glyph's advance in the direction of the textrun (LTR or RTL).
@@ -1736,83 +1792,22 @@ protected:
  * and the glyph ID and advance are in a reasonable range so we can pack all
  * necessary data into 32 bits.
  *
- * This glyph data is copied into gfxTextRuns as needed from the cache of
- * ShapedWords associated with each gfxFont instance.
- *
- * gfxTextRun methods that measure or draw substrings will associate all the
- * glyphs in a cluster with the first character of the cluster; if that character
- * is in the substring, the glyphs will be measured or drawn, otherwise they
- * won't.
+ * gfxFontShaper can shape text into either a gfxShapedWord (cached by a gfxFont)
+ * or directly into a gfxTextRun (for cases where we want to shape textruns in
+ * their entirety rather than using cached words, because there may be layout
+ * features that depend on the inter-word spaces).
  */
-class gfxShapedWord
+class gfxShapedText
 {
 public:
-    static const uint32_t kMaxLength = 0x7fff;
+    gfxShapedText(uint32_t aLength, uint32_t aFlags,
+                  uint32_t aAppUnitsPerDevUnit)
+        : mLength(aLength)
+        , mFlags(aFlags)
+        , mAppUnitsPerDevUnit(aAppUnitsPerDevUnit)
+    { }
 
-    // Create a ShapedWord that can hold glyphs for aLength characters,
-    // with mCharacterGlyphs sized appropriately.
-    //
-    // Returns null on allocation failure (does NOT use infallible alloc)
-    // so caller must check for success.
-    //
-    // This does NOT perform shaping, so the returned word contains no
-    // glyph data; the caller must call gfxFont::Shape() with appropriate
-    // parameters to set up the glyphs.
-    static gfxShapedWord* Create(const uint8_t *aText, uint32_t aLength,
-                                 int32_t aRunScript,
-                                 int32_t aAppUnitsPerDevUnit,
-                                 uint32_t aFlags) {
-        NS_ASSERTION(aLength <= kMaxLength, "excessive length for gfxShapedWord!");
-
-        // Compute size needed including the mCharacterGlyphs array
-        // and a copy of the original text
-        uint32_t size =
-            offsetof(gfxShapedWord, mCharacterGlyphs) +
-            aLength * (sizeof(CompressedGlyph) + sizeof(uint8_t));
-        void *storage = moz_malloc(size);
-        if (!storage) {
-            return nullptr;
-        }
-
-        // Construct in the pre-allocated storage, using placement new
-        return new (storage) gfxShapedWord(aText, aLength, aRunScript,
-                                           aAppUnitsPerDevUnit, aFlags);
-    }
-
-    static gfxShapedWord* Create(const PRUnichar *aText, uint32_t aLength,
-                                 int32_t aRunScript,
-                                 int32_t aAppUnitsPerDevUnit,
-                                 uint32_t aFlags) {
-        NS_ASSERTION(aLength <= kMaxLength, "excessive length for gfxShapedWord!");
-
-        // In the 16-bit version of Create, if the TEXT_IS_8BIT flag is set,
-        // then we convert the text to an 8-bit version and call the 8-bit
-        // Create function instead.
-        if (aFlags & gfxTextRunFactory::TEXT_IS_8BIT) {
-            nsAutoCString narrowText;
-            LossyAppendUTF16toASCII(nsDependentSubstring(aText, aLength),
-                                    narrowText);
-            return Create((const uint8_t*)(narrowText.BeginReading()),
-                          aLength, aRunScript, aAppUnitsPerDevUnit, aFlags);
-        }
-
-        uint32_t size =
-            offsetof(gfxShapedWord, mCharacterGlyphs) +
-            aLength * (sizeof(CompressedGlyph) + sizeof(PRUnichar));
-        void *storage = moz_malloc(size);
-        if (!storage) {
-            return nullptr;
-        }
-
-        return new (storage) gfxShapedWord(aText, aLength, aRunScript,
-                                           aAppUnitsPerDevUnit, aFlags);
-    }
-
-    // Override operator delete to properly free the object that was
-    // allocated via moz_malloc.
-    void operator delete(void* p) {
-        moz_free(p);
-    }
+    virtual ~gfxShapedText() { }
 
     /**
      * This class records the information associated with a character in the
@@ -2012,6 +2007,10 @@ public:
         uint32_t mValue;
     };
 
+    // Accessor for the array of CompressedGlyph records, which will be in
+    // a different place in gfxShapedWord vs gfxTextRun
+    virtual CompressedGlyph *GetCharacterGlyphs() = 0;
+
     /**
      * When the glyphs for a character don't fit into a CompressedGlyph record
      * in SimpleGlyph format, we use an array of DetailedGlyphs instead.
@@ -2028,35 +2027,59 @@ public:
         float    mXOffset, mYOffset;
     };
 
+    void SetGlyphs(uint32_t aCharIndex, CompressedGlyph aGlyph,
+                   const DetailedGlyph *aGlyphs);
+
+    void SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont);
+
+    void SetIsSpace(uint32_t aIndex) {
+        GetCharacterGlyphs()[aIndex].SetIsSpace();
+    }
+
+    void SetIsLowSurrogate(uint32_t aIndex) {
+        SetGlyphs(aIndex, CompressedGlyph().SetComplex(false, false, 0), nullptr);
+        GetCharacterGlyphs()[aIndex].SetIsLowSurrogate();
+    }
+
+    bool HasDetailedGlyphs() const {
+        return mDetailedGlyphs != nullptr;
+    }
+
     bool IsClusterStart(uint32_t aPos) {
-        NS_ASSERTION(aPos < Length(), "aPos out of range");
-        return mCharacterGlyphs[aPos].IsClusterStart();
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
+        return GetCharacterGlyphs()[aPos].IsClusterStart();
     }
 
     bool IsLigatureGroupStart(uint32_t aPos) {
-        NS_ASSERTION(aPos < Length(), "aPos out of range");
-        return mCharacterGlyphs[aPos].IsLigatureGroupStart();
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
+        return GetCharacterGlyphs()[aPos].IsLigatureGroupStart();
     }
 
-    uint32_t Length() const {
-        return mLength;
+    // NOTE that this must not be called for a character offset that does
+    // not have any DetailedGlyph records; callers must have verified that
+    // GetCharacterGlyphs()[aCharIndex].GetGlyphCount() is greater than zero.
+    DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) {
+        NS_ASSERTION(GetCharacterGlyphs() && HasDetailedGlyphs() &&
+                     !GetCharacterGlyphs()[aCharIndex].IsSimpleGlyph() &&
+                     GetCharacterGlyphs()[aCharIndex].GetGlyphCount() > 0,
+                     "invalid use of GetDetailedGlyphs; check the caller!");
+        return mDetailedGlyphs->Get(aCharIndex);
     }
 
-    const uint8_t* Text8Bit() const {
-        NS_ASSERTION(TextIs8Bit(), "invalid use of Text8Bit()");
-        return reinterpret_cast(&mCharacterGlyphs[Length()]);
-    }
+    void AdjustAdvancesForSyntheticBold(float aSynBoldOffset,
+                                        uint32_t aOffset, uint32_t aLength);
 
-    const PRUnichar* TextUnicode() const {
-        NS_ASSERTION(!TextIs8Bit(), "invalid use of TextUnicode()");
-        return reinterpret_cast(&mCharacterGlyphs[Length()]);
-    }
-
-    PRUnichar GetCharAt(uint32_t aOffset) const {
-        NS_ASSERTION(aOffset < Length(), "aOffset out of range");
-        return TextIs8Bit() ?
-            PRUnichar(Text8Bit()[aOffset]) : TextUnicode()[aOffset];
-    }
+    // Mark clusters in the CompressedGlyph records, starting at aOffset,
+    // based on the Unicode properties of the text in aString.
+    // This is also responsible to set the IsSpace flag for space characters.
+    void SetupClusterBoundaries(uint32_t         aOffset,
+                                const PRUnichar *aString,
+                                uint32_t         aLength);
+    // In 8-bit text, there won't actually be any clusters, but we still need
+    // the space-marking functionality.
+    void SetupClusterBoundaries(uint32_t       aOffset,
+                                const uint8_t *aString,
+                                uint32_t       aLength);
 
     uint32_t Flags() const {
         return mFlags;
@@ -2078,105 +2101,17 @@ public:
         return (Flags() & gfxTextRunFactory::TEXT_IS_8BIT) != 0;
     }
 
-    int32_t Script() const {
-        return mScript;
-    }
-
-    int32_t AppUnitsPerDevUnit() const {
+    uint32_t GetAppUnitsPerDevUnit() const {
         return mAppUnitsPerDevUnit;
     }
 
-    void ResetAge() {
-        mAgeCounter = 0;
-    }
-    uint32_t IncrementAge() {
-        return ++mAgeCounter;
+    uint32_t GetLength() const {
+        return mLength;
     }
 
-    void SetSimpleGlyph(uint32_t aCharIndex, CompressedGlyph aGlyph) {
-        NS_ASSERTION(aGlyph.IsSimpleGlyph(), "Should be a simple glyph here");
-        NS_ASSERTION(mCharacterGlyphs, "mCharacterGlyphs pointer is null!");
-        mCharacterGlyphs[aCharIndex] = aGlyph;
-    }
-
-    void SetGlyphs(uint32_t aCharIndex, CompressedGlyph aGlyph,
-                   const DetailedGlyph *aGlyphs);
-
-    void SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont);
-
-    void SetIsSpace(uint32_t aIndex) {
-        mCharacterGlyphs[aIndex].SetIsSpace();
-    }
-
-    void SetIsLowSurrogate(uint32_t aIndex) {
-        SetGlyphs(aIndex, CompressedGlyph().SetComplex(false, false, 0), nullptr);
-        mCharacterGlyphs[aIndex].SetIsLowSurrogate();
-    }
-
-    bool FilterIfIgnorable(uint32_t aIndex);
-
-    const CompressedGlyph *GetCharacterGlyphs() const {
-        return &mCharacterGlyphs[0];
-    }
-
-    bool HasDetailedGlyphs() const {
-        return mDetailedGlyphs != nullptr;
-    }
-
-    // NOTE that this must not be called for a character offset that does
-    // not have any DetailedGlyph records; callers must have verified that
-    // mCharacterGlyphs[aCharIndex].GetGlyphCount() is greater than zero.
-    DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) const {
-        NS_ASSERTION(HasDetailedGlyphs() &&
-                     !mCharacterGlyphs[aCharIndex].IsSimpleGlyph() &&
-                     mCharacterGlyphs[aCharIndex].GetGlyphCount() > 0,
-                     "invalid use of GetDetailedGlyphs; check the caller!");
-        return mDetailedGlyphs->Get(aCharIndex);
-    }
-
-    void AdjustAdvancesForSyntheticBold(float aSynBoldOffset);
-
-    // this is a public static method in order to make it available
-    // for gfxTextRun to use directly on its own CompressedGlyph array,
-    // in addition to the use within ShapedWord
-    static void
-    SetupClusterBoundaries(CompressedGlyph *aGlyphs,
-                           const PRUnichar *aString, uint32_t aLength);
-
-private:
-    // so that gfxTextRun can share our DetailedGlyphStore class
-    friend class gfxTextRun;
-
-    // Construct storage for a ShapedWord, ready to receive glyph data
-    gfxShapedWord(const uint8_t *aText, uint32_t aLength,
-                  int32_t aRunScript, int32_t aAppUnitsPerDevUnit,
-                  uint32_t aFlags)
-        : mLength(aLength)
-        , mFlags(aFlags | gfxTextRunFactory::TEXT_IS_8BIT)
-        , mAppUnitsPerDevUnit(aAppUnitsPerDevUnit)
-        , mScript(aRunScript)
-        , mAgeCounter(0)
-    {
-        memset(mCharacterGlyphs, 0, aLength * sizeof(CompressedGlyph));
-        uint8_t *text = reinterpret_cast(&mCharacterGlyphs[aLength]);
-        memcpy(text, aText, aLength * sizeof(uint8_t));
-    }
-
-    gfxShapedWord(const PRUnichar *aText, uint32_t aLength,
-                  int32_t aRunScript, int32_t aAppUnitsPerDevUnit,
-                  uint32_t aFlags)
-        : mLength(aLength)
-        , mFlags(aFlags)
-        , mAppUnitsPerDevUnit(aAppUnitsPerDevUnit)
-        , mScript(aRunScript)
-        , mAgeCounter(0)
-    {
-        memset(mCharacterGlyphs, 0, aLength * sizeof(CompressedGlyph));
-        PRUnichar *text = reinterpret_cast(&mCharacterGlyphs[aLength]);
-        memcpy(text, aText, aLength * sizeof(PRUnichar));
-        SetupClusterBoundaries(&mCharacterGlyphs[0], aText, aLength);
-    }
+    bool FilterIfIgnorable(uint32_t aIndex, uint32_t aCh);
 
+protected:
     // Allocate aCount DetailedGlyphs for the given index
     DetailedGlyph *AllocateDetailedGlyphs(uint32_t aCharIndex,
                                           uint32_t aCount);
@@ -2303,25 +2238,164 @@ private:
 
     nsAutoPtr   mDetailedGlyphs;
 
-    // Number of PRUnichar characters and CompressedGlyph glyph records;
-    // note that gfx font code will never attempt to create a ShapedWord
-    // with a huge number of characters, so we could limit this to 16 bits
-    // to minimize memory usage for large numbers of cached words.
+    // Number of PRUnichar characters and CompressedGlyph glyph records
     uint32_t                        mLength;
 
+    // Shaping flags (direction, ligature-suppression)
     uint32_t                        mFlags;
 
-    int32_t                         mAppUnitsPerDevUnit;
-    int32_t                         mScript;
+    uint32_t                        mAppUnitsPerDevUnit;
+};
 
-    uint32_t                        mAgeCounter;
+/*
+ * gfxShapedWord: an individual (space-delimited) run of text shaped with a
+ * particular font, without regard to external context.
+ *
+ * The glyph data is copied into gfxTextRuns as needed from the cache of
+ * ShapedWords associated with each gfxFont instance.
+ */
+class gfxShapedWord : public gfxShapedText
+{
+public:
+    static const uint32_t kMaxLength = 0x7fff;
 
-    // The mCharacterGlyphs array is actually a variable-size member;
+    // Create a ShapedWord that can hold glyphs for aLength characters,
+    // with mCharacterGlyphs sized appropriately.
+    //
+    // Returns null on allocation failure (does NOT use infallible alloc)
+    // so caller must check for success.
+    //
+    // This does NOT perform shaping, so the returned word contains no
+    // glyph data; the caller must call gfxFont::ShapeText() with appropriate
+    // parameters to set up the glyphs.
+    static gfxShapedWord* Create(const uint8_t *aText, uint32_t aLength,
+                                 int32_t aRunScript,
+                                 int32_t aAppUnitsPerDevUnit,
+                                 uint32_t aFlags) {
+        NS_ASSERTION(aLength <= kMaxLength, "excessive length for gfxShapedWord!");
+
+        // Compute size needed including the mCharacterGlyphs array
+        // and a copy of the original text
+        uint32_t size =
+            offsetof(gfxShapedWord, mCharGlyphsStorage) +
+            aLength * (sizeof(CompressedGlyph) + sizeof(uint8_t));
+        void *storage = moz_malloc(size);
+        if (!storage) {
+            return nullptr;
+        }
+
+        // Construct in the pre-allocated storage, using placement new
+        return new (storage) gfxShapedWord(aText, aLength, aRunScript,
+                                           aAppUnitsPerDevUnit, aFlags);
+    }
+
+    static gfxShapedWord* Create(const PRUnichar *aText, uint32_t aLength,
+                                 int32_t aRunScript,
+                                 int32_t aAppUnitsPerDevUnit,
+                                 uint32_t aFlags) {
+        NS_ASSERTION(aLength <= kMaxLength, "excessive length for gfxShapedWord!");
+
+        // In the 16-bit version of Create, if the TEXT_IS_8BIT flag is set,
+        // then we convert the text to an 8-bit version and call the 8-bit
+        // Create function instead.
+        if (aFlags & gfxTextRunFactory::TEXT_IS_8BIT) {
+            nsAutoCString narrowText;
+            LossyAppendUTF16toASCII(nsDependentSubstring(aText, aLength),
+                                    narrowText);
+            return Create((const uint8_t*)(narrowText.BeginReading()),
+                          aLength, aRunScript, aAppUnitsPerDevUnit, aFlags);
+        }
+
+        uint32_t size =
+            offsetof(gfxShapedWord, mCharGlyphsStorage) +
+            aLength * (sizeof(CompressedGlyph) + sizeof(PRUnichar));
+        void *storage = moz_malloc(size);
+        if (!storage) {
+            return nullptr;
+        }
+
+        return new (storage) gfxShapedWord(aText, aLength, aRunScript,
+                                           aAppUnitsPerDevUnit, aFlags);
+    }
+
+    // Override operator delete to properly free the object that was
+    // allocated via moz_malloc.
+    void operator delete(void* p) {
+        moz_free(p);
+    }
+
+    CompressedGlyph *GetCharacterGlyphs() {
+        return &mCharGlyphsStorage[0];
+    }
+
+    const uint8_t* Text8Bit() const {
+        NS_ASSERTION(TextIs8Bit(), "invalid use of Text8Bit()");
+        return reinterpret_cast(mCharGlyphsStorage + GetLength());
+    }
+
+    const PRUnichar* TextUnicode() const {
+        NS_ASSERTION(!TextIs8Bit(), "invalid use of TextUnicode()");
+        return reinterpret_cast(mCharGlyphsStorage + GetLength());
+    }
+
+    PRUnichar GetCharAt(uint32_t aOffset) const {
+        NS_ASSERTION(aOffset < GetLength(), "aOffset out of range");
+        return TextIs8Bit() ?
+            PRUnichar(Text8Bit()[aOffset]) : TextUnicode()[aOffset];
+    }
+
+    int32_t Script() const {
+        return mScript;
+    }
+
+    void ResetAge() {
+        mAgeCounter = 0;
+    }
+    uint32_t IncrementAge() {
+        return ++mAgeCounter;
+    }
+
+private:
+    // so that gfxTextRun can share our DetailedGlyphStore class
+    friend class gfxTextRun;
+
+    // Construct storage for a ShapedWord, ready to receive glyph data
+    gfxShapedWord(const uint8_t *aText, uint32_t aLength,
+                  int32_t aRunScript, int32_t aAppUnitsPerDevUnit,
+                  uint32_t aFlags)
+        : gfxShapedText(aLength, aFlags | gfxTextRunFactory::TEXT_IS_8BIT,
+                        aAppUnitsPerDevUnit)
+        , mScript(aRunScript)
+        , mAgeCounter(0)
+    {
+        memset(mCharGlyphsStorage, 0, aLength * sizeof(CompressedGlyph));
+        uint8_t *text = reinterpret_cast(&mCharGlyphsStorage[aLength]);
+        memcpy(text, aText, aLength * sizeof(uint8_t));
+    }
+
+    gfxShapedWord(const PRUnichar *aText, uint32_t aLength,
+                  int32_t aRunScript, int32_t aAppUnitsPerDevUnit,
+                  uint32_t aFlags)
+        : gfxShapedText(aLength, aFlags, aAppUnitsPerDevUnit)
+        , mScript(aRunScript)
+        , mAgeCounter(0)
+    {
+        memset(mCharGlyphsStorage, 0, aLength * sizeof(CompressedGlyph));
+        PRUnichar *text = reinterpret_cast(&mCharGlyphsStorage[aLength]);
+        memcpy(text, aText, aLength * sizeof(PRUnichar));
+        SetupClusterBoundaries(0, aText, aLength);
+    }
+
+    int32_t          mScript;
+
+    uint32_t         mAgeCounter;
+
+    // The mCharGlyphsStorage array is actually a variable-size member;
     // when the ShapedWord is created, its size will be increased as necessary
     // to allow the proper number of glyphs to be stored.
     // The original text, in either 8-bit or 16-bit form, will be stored
     // immediately following the CompressedGlyphs.
-    CompressedGlyph                 mCharacterGlyphs[1];
+    CompressedGlyph  mCharGlyphsStorage[1];
 };
 
 /**
@@ -2343,13 +2417,8 @@ private:
  * It is important that zero-length substrings are handled correctly. This will
  * be on the test!
  */
-class THEBES_API gfxTextRun {
+class THEBES_API gfxTextRun : public gfxShapedText {
 public:
-    // we use the same glyph storage as gfxShapedWord, to facilitate copying
-    // glyph data from shaped words into text runs as needed
-    typedef gfxShapedWord::CompressedGlyph    CompressedGlyph;
-    typedef gfxShapedWord::DetailedGlyph      DetailedGlyph;
-    typedef gfxShapedWord::DetailedGlyphStore DetailedGlyphStore;
 
     // Override operator delete to properly free the object that was
     // allocated via moz_malloc.
@@ -2364,42 +2433,42 @@ public:
     // Public textrun API for general use
 
     bool IsClusterStart(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].IsClusterStart();
     }
     bool IsLigatureGroupStart(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].IsLigatureGroupStart();
     }
     bool CanBreakLineBefore(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].CanBreakBefore() ==
             CompressedGlyph::FLAG_BREAK_TYPE_NORMAL;
     }
     bool CanHyphenateBefore(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].CanBreakBefore() ==
             CompressedGlyph::FLAG_BREAK_TYPE_HYPHEN;
     }
 
     bool CharIsSpace(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].CharIsSpace();
     }
     bool CharIsTab(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].CharIsTab();
     }
     bool CharIsNewline(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].CharIsNewline();
     }
     bool CharIsLowSurrogate(uint32_t aPos) {
-        NS_ASSERTION(aPos < mCharacterCount, "aPos out of range");
+        NS_ASSERTION(aPos < GetLength(), "aPos out of range");
         return mCharacterGlyphs[aPos].CharIsLowSurrogate();
     }
 
-    uint32_t GetLength() { return mCharacterCount; }
+    uint32_t GetLength() { return mLength; }
 
     // All uint32_t aStart, uint32_t aLength ranges below are restricted to
     // grapheme cluster boundaries! All offsets are in terms of the string
@@ -2655,7 +2724,6 @@ public:
 
     // Utility getters
 
-    bool IsRightToLeft() const { return (mFlags & gfxTextRunFactory::TEXT_IS_RTL) != 0; }
     gfxFloat GetDirection() const { return (mFlags & gfxTextRunFactory::TEXT_IS_RTL) ? -1.0 : 1.0; }
     void *GetUserData() const { return mUserData; }
     void SetUserData(void *aUserData) { mUserData = aUserData; }
@@ -2671,7 +2739,6 @@ public:
       mFlags &= ~aFlags;
     }
     const gfxSkipChars& GetSkipChars() const { return mSkipChars; }
-    uint32_t GetAppUnitsPerDevUnit() const { return mAppUnitsPerDevUnit; }
     gfxFontGroup *GetFontGroup() const { return mFontGroup; }
 
 
@@ -2747,20 +2814,11 @@ public:
     void SortGlyphRuns();
     void SanitizeGlyphRuns();
 
-    // Call the following glyph-setters during initialization or during reshaping
-    // only. It is OK to overwrite existing data for a character.
-    void SetSimpleGlyph(uint32_t aCharIndex, CompressedGlyph aGlyph) {
-        NS_ASSERTION(aGlyph.IsSimpleGlyph(), "Should be a simple glyph here");
-        mCharacterGlyphs[aCharIndex] = aGlyph;
+    CompressedGlyph* GetCharacterGlyphs() {
+        NS_ASSERTION(mCharacterGlyphs, "failed to initialize mCharacterGlyphs");
+        return mCharacterGlyphs;
     }
-    /**
-     * Set the glyph data for a character. aGlyphs may be null if aGlyph is a
-     * simple glyph or has no associated glyphs. If non-null the data is copied,
-     * the caller retains ownership.
-     */
-    void SetGlyphs(uint32_t aCharIndex, CompressedGlyph aGlyph,
-                   const DetailedGlyph *aGlyphs);
-    void SetMissingGlyph(uint32_t aCharIndex, uint32_t aUnicodeChar);
+
     void SetSpaceGlyph(gfxFont *aFont, gfxContext *aContext, uint32_t aCharIndex);
 
     // Set the glyph data for the given character index to the font's
@@ -2820,22 +2878,6 @@ public:
      */
     void FetchGlyphExtents(gfxContext *aRefContext);
 
-    // API for access to the raw glyph data, needed by gfxFont::Draw
-    // and gfxFont::GetBoundingBox
-    CompressedGlyph *GetCharacterGlyphs() { return mCharacterGlyphs; }
-
-    // NOTE that this must not be called for a character offset that does
-    // not have any DetailedGlyph records; callers must have verified that
-    // mCharacterGlyphs[aCharIndex].GetGlyphCount() is greater than zero.
-    DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) {
-        NS_ASSERTION(mDetailedGlyphs != nullptr &&
-                     !mCharacterGlyphs[aCharIndex].IsSimpleGlyph() &&
-                     mCharacterGlyphs[aCharIndex].GetGlyphCount() > 0,
-                     "invalid use of GetDetailedGlyphs; check the caller!");
-        return mDetailedGlyphs->Get(aCharIndex);
-    }
-
-    bool HasDetailedGlyphs() { return mDetailedGlyphs != nullptr; }
     uint32_t CountMissingGlyphs();
     const GlyphRun *GetGlyphRuns(uint32_t *aNumGlyphRuns) {
         *aNumGlyphRuns = mGlyphRuns.Length();
@@ -2846,7 +2888,7 @@ public:
     uint32_t FindFirstGlyphRunContaining(uint32_t aOffset);
 
     // Copy glyph data from a ShapedWord into this textrun.
-    void CopyGlyphDataFrom(const gfxShapedWord *aSource, uint32_t aStart);
+    void CopyGlyphDataFrom(gfxShapedWord *aSource, uint32_t aStart);
 
     // Copy glyph data for a range of characters from aSource to this
     // textrun.
@@ -2911,11 +2953,9 @@ protected:
      */
     static void* AllocateStorageForTextRun(size_t aSize, uint32_t aLength);
 
-    // All our glyph data is in logical order, not visual.
-    // Space for mCharacterGlyphs is allocated fused with the textrun object,
-    // and then the constructor sets the pointer to the beginning of this
-    // storage area. Thus, this pointer must NOT be freed!
-    CompressedGlyph  *mCharacterGlyphs;
+    // Pointer to the array of CompressedGlyph records; must be initialized
+    // when the object is constructed.
+    CompressedGlyph *mCharacterGlyphs;
 
 private:
     // **** general helpers **** 
@@ -2975,8 +3015,6 @@ private:
                     uint32_t aEnd, PropertyProvider *aProvider,
                     uint32_t aSpacingStart, uint32_t aSpacingEnd);
 
-    nsAutoPtr   mDetailedGlyphs;
-
     // XXX this should be changed to a GlyphRun plus a maybe-null GlyphRun*,
     // for smaller size especially in the super-common one-glyphrun case
     nsAutoTArray        mGlyphRuns;
@@ -2985,9 +3023,6 @@ private:
     gfxFontGroup     *mFontGroup; // addrefed
     gfxSkipChars      mSkipChars;
     nsExpirationState mExpirationState;
-    uint32_t          mAppUnitsPerDevUnit;
-    uint32_t          mFlags;
-    uint32_t          mCharacterCount;
 
     bool              mSkipDrawing; // true if the font group we used had a user font
                                     // download that's in progress, so we should hide text
diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp
index b5908fcf586b..10b39e42c58d 100644
--- a/gfx/thebes/gfxGDIFont.cpp
+++ b/gfx/thebes/gfxGDIFont.cpp
@@ -82,10 +82,11 @@ gfxGDIFont::CopyWithAntialiasOption(AntialiasOption anAAOption)
 }
 
 static bool
-UseUniscribe(gfxShapedWord *aShapedWord,
-             const PRUnichar *aString)
+UseUniscribe(gfxShapedText *aShapedText,
+             const PRUnichar *aText,
+             uint32_t aLength)
 {
-    uint32_t flags = aShapedWord->Flags();
+    uint32_t flags = aShapedText->Flags();
     bool useGDI;
 
     bool isXP = (gfxWindowsPlatform::WindowsOSVersion() 
@@ -101,14 +102,17 @@ UseUniscribe(gfxShapedWord *aShapedWord,
              ) == gfxTextRunFactory::TEXT_OPTIMIZE_SPEED;
 
     return !useGDI ||
-        ScriptIsComplex(aString, aShapedWord->Length(), SIC_COMPLEX) == S_OK;
+        ScriptIsComplex(aText, aLength, SIC_COMPLEX) == S_OK;
 }
 
 bool
-gfxGDIFont::ShapeWord(gfxContext *aContext,
-                      gfxShapedWord *aShapedWord,
-                      const PRUnichar *aString,
-                      bool aPreferPlatformShaping)
+gfxGDIFont::ShapeText(gfxContext      *aContext,
+                      const PRUnichar *aText,
+                      uint32_t         aOffset,
+                      uint32_t         aLength,
+                      int32_t          aScript,
+                      gfxShapedText   *aShapedText,
+                      bool             aPreferPlatformShaping)
 {
     if (!mMetrics) {
         Initialize();
@@ -130,13 +134,16 @@ gfxGDIFont::ShapeWord(gfxContext *aContext,
 
 #ifdef MOZ_GRAPHITE
     if (mGraphiteShaper && gfxPlatform::GetPlatform()->UseGraphiteShaping()) {
-        ok = mGraphiteShaper->ShapeWord(aContext, aShapedWord, aString);
+        ok = mGraphiteShaper->ShapeText(aContext, aText,
+                                        aOffset, aLength,
+                                        aScript, aShapedText);
     }
 #endif
 
     if (!ok && mHarfBuzzShaper) {
-        if (gfxPlatform::GetPlatform()->UseHarfBuzzForScript(aShapedWord->Script())) {
-            ok = mHarfBuzzShaper->ShapeWord(aContext, aShapedWord, aString);
+        if (gfxPlatform::GetPlatform()->UseHarfBuzzForScript(aScript)) {
+            ok = mHarfBuzzShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                            aScript, aShapedText);
         }
     }
 
@@ -145,41 +152,42 @@ gfxGDIFont::ShapeWord(gfxContext *aContext,
         bool preferUniscribe =
             (!fe->IsTrueType() || fe->IsSymbolFont()) && !fe->mForceGDI;
 
-        if (preferUniscribe || UseUniscribe(aShapedWord, aString)) {
+        if (preferUniscribe || UseUniscribe(aShapedText, aText, aLength)) {
             // first try Uniscribe
             if (!mUniscribeShaper) {
                 mUniscribeShaper = new gfxUniscribeShaper(this);
             }
 
-            ok = mUniscribeShaper->ShapeWord(aContext, aShapedWord, aString);
-            if (ok) {
-                return true;
-            }
+            ok = mUniscribeShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                             aScript, aShapedText);
+            if (!ok) {
+                // fallback to GDI shaping
+                if (!mPlatformShaper) {
+                    CreatePlatformShaper();
+                }
 
-            // fallback to GDI shaping
-            if (!mPlatformShaper) {
-                CreatePlatformShaper();
+                ok = mPlatformShaper->ShapeText(aContext, aText, aOffset,
+                                                aLength, aScript, aShapedText);
             }
-
-            ok = mPlatformShaper->ShapeWord(aContext, aShapedWord, aString);
         } else {
             // first use GDI
             if (!mPlatformShaper) {
                 CreatePlatformShaper();
             }
 
-            ok = mPlatformShaper->ShapeWord(aContext, aShapedWord, aString);
-            if (ok) {
-                return true;
-            }
+            ok = mPlatformShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                            aScript, aShapedText);
+            if (!ok) {
+                // try Uniscribe if GDI failed
+                if (!mUniscribeShaper) {
+                    mUniscribeShaper = new gfxUniscribeShaper(this);
+                }
 
-            // try Uniscribe if GDI failed
-            if (!mUniscribeShaper) {
-                mUniscribeShaper = new gfxUniscribeShaper(this);
+                // use Uniscribe shaping
+                ok = mUniscribeShaper->ShapeText(aContext, aText,
+                                                 aOffset, aLength,
+                                                 aScript, aShapedText);
             }
-
-            // use Uniscribe shaping
-            ok = mUniscribeShaper->ShapeWord(aContext, aShapedWord, aString);
         }
 
 #if DEBUG
@@ -196,11 +204,7 @@ gfxGDIFont::ShapeWord(gfxContext *aContext,
 #endif
     }
 
-    if (ok && IsSyntheticBold()) {
-        float synBoldOffset =
-                GetSyntheticBoldOffset() * CalcXScale(aContext);
-        aShapedWord->AdjustAdvancesForSyntheticBold(synBoldOffset);
-    }
+    PostShapingFixup(aContext, aText, aOffset, aLength, aShapedText);
 
     return ok;
 }
@@ -421,14 +425,11 @@ gfxGDIFont::Initialize()
             mMetrics->zeroOrAveCharWidth = mMetrics->aveCharWidth;
         }
 
-        mSpaceGlyph = 0;
-        if (metrics.tmPitchAndFamily & TMPF_TRUETYPE) {
-            WORD glyph;
-            DWORD ret = GetGlyphIndicesW(dc.GetDC(), L" ", 1, &glyph,
-                                         GGI_MARK_NONEXISTING_GLYPHS);
-            if (ret != GDI_ERROR && glyph != 0xFFFF) {
-                mSpaceGlyph = glyph;
-            }
+        WORD glyph;
+        DWORD ret = GetGlyphIndicesW(dc.GetDC(), L" ", 1, &glyph,
+                                     GGI_MARK_NONEXISTING_GLYPHS);
+        if (ret != GDI_ERROR && glyph != 0xFFFF) {
+            mSpaceGlyph = glyph;
         }
 
         SanitizeMetrics(mMetrics, GetFontEntry()->mIsBadUnderlineFont);
diff --git a/gfx/thebes/gfxGDIFont.h b/gfx/thebes/gfxGDIFont.h
index c55c831d8766..26f9a2e00b5a 100644
--- a/gfx/thebes/gfxGDIFont.h
+++ b/gfx/thebes/gfxGDIFont.h
@@ -64,10 +64,13 @@ protected:
     virtual void CreatePlatformShaper();
 
     /* override to check for uniscribe failure and fall back to GDI */
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString,
-                           bool aPreferPlatformShaping = false);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText,
+                           bool             aPreferPlatformShaping);
 
     void Initialize(); // creates metrics and Cairo fonts
 
diff --git a/gfx/thebes/gfxGDIShaper.cpp b/gfx/thebes/gfxGDIShaper.cpp
index 0e0b178c52f1..d6e2c6adb230 100644
--- a/gfx/thebes/gfxGDIShaper.cpp
+++ b/gfx/thebes/gfxGDIShaper.cpp
@@ -14,21 +14,24 @@
  **********************************************************************/
 
 bool
-gfxGDIShaper::ShapeWord(gfxContext *aContext,
-                        gfxShapedWord *aShapedWord,
-                        const PRUnichar *aString)
+gfxGDIShaper::ShapeText(gfxContext      *aContext,
+                        const PRUnichar *aText,
+                        uint32_t         aOffset,
+                        uint32_t         aLength,
+                        int32_t          aScript,
+                        gfxShapedText   *aShapedText)
 {
     DCFromContext dc(aContext);
     AutoSelectFont selectFont(dc, static_cast(mFont)->GetHFONT());
 
-    uint32_t length = aShapedWord->Length();
+    uint32_t length = aLength;
     nsAutoTArray glyphArray;
     if (!glyphArray.SetLength(length)) {
         return false;
     }
     WORD *glyphs = glyphArray.Elements();
 
-    DWORD ret = ::GetGlyphIndicesW(dc, aString, length,
+    DWORD ret = ::GetGlyphIndicesW(dc, aText, length,
                                    glyphs, GGI_MARK_NONEXISTING_GLYPHS);
     if (ret == GDI_ERROR) {
         return false;
@@ -57,32 +60,33 @@ gfxGDIShaper::ShapeWord(gfxContext *aContext,
     }
 
     gfxTextRun::CompressedGlyph g;
+    gfxTextRun::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs();
     uint32_t i;
     int32_t lastWidth = 0;
-    uint32_t appUnitsPerDevPixel = aShapedWord->AppUnitsPerDevUnit();
+    uint32_t appUnitsPerDevPixel = aShapedText->GetAppUnitsPerDevUnit();
     for (i = 0; i < length; ++i) {
-        uint32_t offset = i;
+        uint32_t offset = aOffset + i;
         int32_t advancePixels = partialWidthArray[i] - lastWidth;
         lastWidth = partialWidthArray[i];
         int32_t advanceAppUnits = advancePixels * appUnitsPerDevPixel;
         WCHAR glyph = glyphs[i];
-        NS_ASSERTION(!gfxFontGroup::IsInvalidChar(aShapedWord->GetCharAt(offset)),
+        NS_ASSERTION(!gfxFontGroup::IsInvalidChar(aText[i]),
                      "Invalid character detected!");
-        bool atClusterStart = aShapedWord->IsClusterStart(offset);
+        bool atClusterStart = charGlyphs[offset].IsClusterStart();
         if (advanceAppUnits >= 0 &&
             gfxShapedWord::CompressedGlyph::IsSimpleAdvance(advanceAppUnits) &&
             gfxShapedWord::CompressedGlyph::IsSimpleGlyphID(glyph) &&
             atClusterStart)
         {
-            aShapedWord->SetSimpleGlyph(offset,
-                                        g.SetSimpleGlyph(advanceAppUnits, glyph));
+            charGlyphs[offset].SetSimpleGlyph(advanceAppUnits, glyph);
         } else {
-            gfxShapedWord::DetailedGlyph details;
+            gfxShapedText::DetailedGlyph details;
             details.mGlyphID = glyph;
             details.mAdvance = advanceAppUnits;
             details.mXOffset = 0;
             details.mYOffset = 0;
-            aShapedWord->SetGlyphs(offset,
+            aShapedText->SetGlyphs(offset,
                                    g.SetComplex(atClusterStart, true, 1),
                                    &details);
         }
diff --git a/gfx/thebes/gfxGDIShaper.h b/gfx/thebes/gfxGDIShaper.h
index e38e654747c1..839b203aaad0 100644
--- a/gfx/thebes/gfxGDIShaper.h
+++ b/gfx/thebes/gfxGDIShaper.h
@@ -22,9 +22,12 @@ public:
         MOZ_COUNT_DTOR(gfxGDIShaper);
     }
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText);
 };
 
 #endif /* GFX_GDISHAPER_H */
diff --git a/gfx/thebes/gfxGraphiteShaper.cpp b/gfx/thebes/gfxGraphiteShaper.cpp
index d31b0dbcb92a..cd9125d6634b 100644
--- a/gfx/thebes/gfxGraphiteShaper.cpp
+++ b/gfx/thebes/gfxGraphiteShaper.cpp
@@ -138,9 +138,12 @@ AddFeature(const uint32_t& aTag, uint32_t& aValue, void *aUserArg)
 }
 
 bool
-gfxGraphiteShaper::ShapeWord(gfxContext      *aContext,
-                             gfxShapedWord   *aShapedWord,
-                             const PRUnichar *aText)
+gfxGraphiteShaper::ShapeText(gfxContext      *aContext,
+                             const PRUnichar *aText,
+                             uint32_t         aOffset,
+                             uint32_t         aLength,
+                             int32_t          aScript,
+                             gfxShapedText   *aShapedText)
 {
     // some font back-ends require this in order to get proper hinted metrics
     if (!mFont->SetupCairoFont(aContext)) {
@@ -183,15 +186,15 @@ gfxGraphiteShaper::ShapeWord(gfxContext      *aContext,
     nsDataHashtable mergedFeatures;
 
     if (MergeFontFeatures(style->featureSettings, entry->mFeatureSettings,
-                          aShapedWord->DisableLigatures(), mergedFeatures)) {
+                          aShapedText->DisableLigatures(), mergedFeatures)) {
         // enumerate result and insert into Graphite feature list
         GrFontFeatures f = {mGrFace, grFeatures};
         mergedFeatures.Enumerate(AddFeature, &f);
     }
 
     gr_segment *seg = gr_make_seg(mGrFont, mGrFace, 0, grFeatures,
-                                  gr_utf16, aText, aShapedWord->Length(),
-                                  aShapedWord->IsRightToLeft());
+                                  gr_utf16, aText, aLength,
+                                  aShapedText->IsRightToLeft());
 
     gr_featureval_destroy(grFeatures);
 
@@ -199,7 +202,8 @@ gfxGraphiteShaper::ShapeWord(gfxContext      *aContext,
         return false;
     }
 
-    nsresult rv = SetGlyphsFromSegment(aShapedWord, seg);
+    nsresult rv = SetGlyphsFromSegment(aShapedText, aOffset, aLength,
+                                       aText, seg);
 
     gr_seg_destroy(seg);
 
@@ -218,11 +222,14 @@ struct Cluster {
 };
 
 nsresult
-gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
-                                        gr_segment *aSegment)
+gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedText   *aShapedText,
+                                        uint32_t         aOffset,
+                                        uint32_t         aLength,
+                                        const PRUnichar *aText,
+                                        gr_segment      *aSegment)
 {
-    int32_t dev2appUnits = aShapedWord->AppUnitsPerDevUnit();
-    bool rtl = aShapedWord->IsRightToLeft();
+    int32_t dev2appUnits = aShapedText->GetAppUnitsPerDevUnit();
+    bool rtl = aShapedText->IsRightToLeft();
 
     uint32_t glyphCount = gr_seg_n_slots(aSegment);
 
@@ -232,7 +239,7 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
     nsAutoTArray xLocs;
     nsAutoTArray yLocs;
 
-    if (!clusters.SetLength(aShapedWord->Length()) ||
+    if (!clusters.SetLength(aLength) ||
         !gids.SetLength(glyphCount) ||
         !xLocs.SetLength(glyphCount) ||
         !yLocs.SetLength(glyphCount))
@@ -268,7 +275,7 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
         if (gr_slot_can_insert_before(slot) && clusters[cIndex].nChars &&
             before >= clusters[cIndex].baseChar + clusters[cIndex].nChars)
         {
-            NS_ASSERTION(cIndex < aShapedWord->Length() - 1, "cIndex at end of word");
+            NS_ASSERTION(cIndex < aLength - 1, "cIndex at end of word");
             Cluster& c = clusters[cIndex + 1];
             c.baseChar = clusters[cIndex].baseChar + clusters[cIndex].nChars;
             c.nChars = before - c.baseChar;
@@ -278,7 +285,7 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
         }
 
         // increment cluster's glyph count to include current slot
-        NS_ASSERTION(cIndex < aShapedWord->Length(), "cIndex beyond word length");
+        NS_ASSERTION(cIndex < aLength, "cIndex beyond word length");
         ++clusters[cIndex].nGlyphs;
 
         // extend cluster if necessary to reach the glyph's "after" index
@@ -287,6 +294,9 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
         }
     }
 
+    gfxShapedText::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs() + aOffset;
+
     // now put glyphs into the textrun, one cluster at a time
     for (uint32_t i = 0; i <= cIndex; ++i) {
         const Cluster& c = clusters[i];
@@ -309,30 +319,26 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
         // Check for default-ignorable char that didn't get filtered, combined,
         // etc by the shaping process, and skip it.
         uint32_t offs = gr_cinfo_base(gr_seg_cinfo(aSegment, c.baseChar));
-        NS_ASSERTION(offs >= c.baseChar && offs < aShapedWord->Length(),
+        NS_ASSERTION(offs >= c.baseChar && offs < aLength,
                      "unexpected offset");
         if (c.nGlyphs == 1 && c.nChars == 1 &&
-            aShapedWord->FilterIfIgnorable(offs))
-        {
+            aShapedText->FilterIfIgnorable(aOffset + offs, aText[offs])) {
             continue;
         }
 
         uint32_t appAdvance = adv * dev2appUnits;
         if (c.nGlyphs == 1 &&
-            gfxShapedWord::CompressedGlyph::IsSimpleGlyphID(gids[c.baseGlyph]) &&
-            gfxShapedWord::CompressedGlyph::IsSimpleAdvance(appAdvance) &&
+            gfxShapedText::CompressedGlyph::IsSimpleGlyphID(gids[c.baseGlyph]) &&
+            gfxShapedText::CompressedGlyph::IsSimpleAdvance(appAdvance) &&
             yLocs[c.baseGlyph] == 0)
         {
-            gfxShapedWord::CompressedGlyph g;
-            aShapedWord->SetSimpleGlyph(offs,
-                                        g.SetSimpleGlyph(appAdvance,
-                                                         gids[c.baseGlyph]));
+            charGlyphs[offs].SetSimpleGlyph(appAdvance, gids[c.baseGlyph]);
         } else {
             // not a one-to-one mapping with simple metrics: use DetailedGlyph
-            nsAutoTArray details;
+            nsAutoTArray details;
             float clusterLoc;
             for (uint32_t j = c.baseGlyph; j < c.baseGlyph + c.nGlyphs; ++j) {
-                gfxShapedWord::DetailedGlyph* d = details.AppendElement();
+                gfxShapedText::DetailedGlyph* d = details.AppendElement();
                 d->mGlyphID = gids[j];
                 d->mYOffset = -yLocs[j] * dev2appUnits;
                 if (j == c.baseGlyph) {
@@ -346,19 +352,19 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
                     d->mAdvance = 0;
                 }
             }
-            gfxShapedWord::CompressedGlyph g;
-            g.SetComplex(aShapedWord->IsClusterStart(offs),
+            gfxShapedText::CompressedGlyph g;
+            g.SetComplex(charGlyphs[offs].IsClusterStart(),
                          true, details.Length());
-            aShapedWord->SetGlyphs(offs, g, details.Elements());
+            aShapedText->SetGlyphs(aOffset + offs, g, details.Elements());
         }
 
         for (uint32_t j = c.baseChar + 1; j < c.baseChar + c.nChars; ++j) {
             offs = gr_cinfo_base(gr_seg_cinfo(aSegment, j));
-            NS_ASSERTION(offs >= j && offs < aShapedWord->Length(),
+            NS_ASSERTION(offs >= j && offs < aLength,
                          "unexpected offset");
-            gfxShapedWord::CompressedGlyph g;
-            g.SetComplex(aShapedWord->IsClusterStart(offs), false, 0);
-            aShapedWord->SetGlyphs(offs, g, nullptr);
+            gfxShapedText::CompressedGlyph &g = charGlyphs[offs];
+            NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
+            g.SetComplex(g.IsClusterStart(), false, 0);
         }
     }
 
diff --git a/gfx/thebes/gfxGraphiteShaper.h b/gfx/thebes/gfxGraphiteShaper.h
index 05a5c64d0e8e..df18c000cce6 100644
--- a/gfx/thebes/gfxGraphiteShaper.h
+++ b/gfx/thebes/gfxGraphiteShaper.h
@@ -20,9 +20,12 @@ public:
     gfxGraphiteShaper(gfxFont *aFont);
     virtual ~gfxGraphiteShaper();
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aText);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText);
 
     const void* GetTable(uint32_t aTag, size_t *aLength);
 
@@ -41,8 +44,11 @@ public:
     };
 
 protected:
-    nsresult SetGlyphsFromSegment(gfxShapedWord *aShapedWord,
-                                  gr_segment *aSegment);
+    nsresult SetGlyphsFromSegment(gfxShapedText   *aShapedText,
+                                  uint32_t         aOffset,
+                                  uint32_t         aLength,
+                                  const PRUnichar *aText,
+                                  gr_segment      *aSegment);
 
     gr_face *mGrFace;
     gr_font *mGrFont;
diff --git a/gfx/thebes/gfxHarfBuzzShaper.cpp b/gfx/thebes/gfxHarfBuzzShaper.cpp
index ec57907f09bd..d6d2245b9aed 100644
--- a/gfx/thebes/gfxHarfBuzzShaper.cpp
+++ b/gfx/thebes/gfxHarfBuzzShaper.cpp
@@ -116,43 +116,55 @@ hb_codepoint_t
 gfxHarfBuzzShaper::GetGlyph(hb_codepoint_t unicode,
                             hb_codepoint_t variation_selector) const
 {
-    if (mUseFontGetGlyph) {
-        return mFont->GetGlyph(unicode, variation_selector);
-    }
-
-    // we only instantiate a harfbuzz shaper if there's a cmap available
-    NS_ASSERTION(mFont->GetFontEntry()->HasCmapTable(),
-                 "we cannot be using this font!");
-
-    NS_ASSERTION(mCmapTable && (mCmapFormat > 0) && (mSubtableOffset > 0),
-                 "cmap data not correctly set up, expect disaster");
-
-    const uint8_t* data = (const uint8_t*)hb_blob_get_data(mCmapTable, nullptr);
-
     hb_codepoint_t gid;
-    switch (mCmapFormat) {
-    case 4:
-        gid = unicode < UNICODE_BMP_LIMIT ?
-            gfxFontUtils::MapCharToGlyphFormat4(data + mSubtableOffset, unicode) : 0;
-        break;
-    case 12:
-        gid = gfxFontUtils::MapCharToGlyphFormat12(data + mSubtableOffset, unicode);
-        break;
-    default:
-        NS_WARNING("unsupported cmap format, glyphs will be missing");
-        gid = 0;
-        break;
+
+    if (mUseFontGetGlyph) {
+        gid = mFont->GetGlyph(unicode, variation_selector);
+    } else {
+        // we only instantiate a harfbuzz shaper if there's a cmap available
+        NS_ASSERTION(mFont->GetFontEntry()->HasCmapTable(),
+                     "we cannot be using this font!");
+
+        NS_ASSERTION(mCmapTable && (mCmapFormat > 0) && (mSubtableOffset > 0),
+                     "cmap data not correctly set up, expect disaster");
+
+        const uint8_t* data =
+            (const uint8_t*)hb_blob_get_data(mCmapTable, nullptr);
+
+        switch (mCmapFormat) {
+        case 4:
+            gid = unicode < UNICODE_BMP_LIMIT ?
+                gfxFontUtils::MapCharToGlyphFormat4(data + mSubtableOffset,
+                                                    unicode) : 0;
+            break;
+        case 12:
+            gid = gfxFontUtils::MapCharToGlyphFormat12(data + mSubtableOffset,
+                                                       unicode);
+            break;
+        default:
+            NS_WARNING("unsupported cmap format, glyphs will be missing");
+            gid = 0;
+            break;
+        }
+
+        if (gid && variation_selector && mUVSTableOffset) {
+            hb_codepoint_t varGID =
+                gfxFontUtils::MapUVSToGlyphFormat14(data + mUVSTableOffset,
+                                                    unicode,
+                                                    variation_selector);
+            if (varGID) {
+                gid = varGID;
+            }
+            // else the variation sequence was not supported, use default
+            // mapping of the character code alone
+        }
     }
 
-    if (gid && variation_selector && mUVSTableOffset) {
-        hb_codepoint_t varGID =
-            gfxFontUtils::MapUVSToGlyphFormat14(data + mUVSTableOffset,
-                                                unicode, variation_selector);
-        if (varGID) {
-            gid = varGID;
+    if (!gid) {
+        // if there's no glyph for  , just use the space glyph instead
+        if (unicode == 0xA0) {
+            gid = mFont->GetSpaceGlyph();
         }
-        // else the variation sequence was not supported, use default mapping
-        // of the character code alone
     }
 
     return gid;
@@ -830,9 +842,12 @@ static hb_font_funcs_t * sHBFontFuncs = nullptr;
 static hb_unicode_funcs_t * sHBUnicodeFuncs = nullptr;
 
 bool
-gfxHarfBuzzShaper::ShapeWord(gfxContext      *aContext,
-                             gfxShapedWord   *aShapedWord,
-                             const PRUnichar *aText)
+gfxHarfBuzzShaper::ShapeText(gfxContext      *aContext,
+                             const PRUnichar *aText,
+                             uint32_t         aOffset,
+                             uint32_t         aLength,
+                             int32_t          aScript,
+                             gfxShapedText   *aShapedText)
 {
     // some font back-ends require this in order to get proper hinted metrics
     if (!mFont->SetupCairoFont(aContext)) {
@@ -960,12 +975,12 @@ gfxHarfBuzzShaper::ShapeWord(gfxContext      *aContext,
 
     if (MergeFontFeatures(style->featureSettings,
                       mFont->GetFontEntry()->mFeatureSettings,
-                      aShapedWord->DisableLigatures(), mergedFeatures)) {
+                      aShapedText->DisableLigatures(), mergedFeatures)) {
         // enumerate result and insert into hb_feature array
         mergedFeatures.Enumerate(AddFeature, &features);
     }
 
-    bool isRightToLeft = aShapedWord->IsRightToLeft();
+    bool isRightToLeft = aShapedText->IsRightToLeft();
     hb_buffer_t *buffer = hb_buffer_create();
     hb_buffer_set_unicode_funcs(buffer, sHBUnicodeFuncs);
     hb_buffer_set_direction(buffer, isRightToLeft ? HB_DIRECTION_RTL :
@@ -973,10 +988,9 @@ gfxHarfBuzzShaper::ShapeWord(gfxContext      *aContext,
     // For unresolved "common" or "inherited" runs, default to Latin for now.
     // (Should we somehow use the language or locale to try and infer
     // a better default?)
-    int32_t scriptCode = aShapedWord->Script();
-    hb_script_t scriptTag = (scriptCode <= MOZ_SCRIPT_INHERITED) ?
+    hb_script_t scriptTag = (aScript <= MOZ_SCRIPT_INHERITED) ?
         HB_SCRIPT_LATIN :
-        hb_script_t(GetScriptTagForCode(scriptCode));
+        hb_script_t(GetScriptTagForCode(aScript));
     hb_buffer_set_script(buffer, scriptTag);
 
     hb_language_t language;
@@ -992,7 +1006,7 @@ gfxHarfBuzzShaper::ShapeWord(gfxContext      *aContext,
     }
     hb_buffer_set_language(buffer, language);
 
-    uint32_t length = aShapedWord->Length();
+    uint32_t length = aLength;
     hb_buffer_add_utf16(buffer,
                         reinterpret_cast(aText),
                         length, 0, length);
@@ -1003,7 +1017,8 @@ gfxHarfBuzzShaper::ShapeWord(gfxContext      *aContext,
         hb_buffer_reverse(buffer);
     }
 
-    nsresult rv = SetGlyphsFromRun(aContext, aShapedWord, buffer);
+    nsresult rv = SetGlyphsFromRun(aContext, aShapedText, aOffset, aLength,
+                                   aText, buffer);
 
     NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to store glyphs into gfxShapedWord");
     hb_buffer_destroy(buffer);
@@ -1091,9 +1106,12 @@ GetRoundOffsetsToPixels(gfxContext *aContext,
                             // for charToGlyphArray
 
 nsresult
-gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
-                                    gfxShapedWord *aShapedWord,
-                                    hb_buffer_t *aBuffer)
+gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext      *aContext,
+                                    gfxShapedText   *aShapedText,
+                                    uint32_t         aOffset,
+                                    uint32_t         aLength,
+                                    const PRUnichar *aText,
+                                    hb_buffer_t     *aBuffer)
 {
     uint32_t numGlyphs;
     const hb_glyph_info_t *ginfo = hb_buffer_get_glyph_infos(aBuffer, &numGlyphs);
@@ -1103,7 +1121,7 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
 
     nsAutoTArray detailedGlyphs;
 
-    uint32_t wordLength = aShapedWord->Length();
+    uint32_t wordLength = aLength;
     static const int32_t NO_GLYPH = -1;
     nsAutoTArray charToGlyphArray;
     if (!charToGlyphArray.SetLength(wordLength)) {
@@ -1129,11 +1147,13 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
     bool roundY;
     GetRoundOffsetsToPixels(aContext, &roundX, &roundY);
 
-    int32_t appUnitsPerDevUnit = aShapedWord->AppUnitsPerDevUnit();
+    int32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();
+    gfxShapedText::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs() + aOffset;
 
     // factor to convert 16.16 fixed-point pixels to app units
     // (only used if not rounding)
-    double hb2appUnits = FixedToFloat(aShapedWord->AppUnitsPerDevUnit());
+    double hb2appUnits = FixedToFloat(aShapedText->GetAppUnitsPerDevUnit());
 
     // Residual from rounding of previous advance, for use in rounding the
     // subsequent offset or advance appropriately.  16.16 fixed-point
@@ -1236,7 +1256,8 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
         // etc by the shaping process, and remove from the run.
         // (This may be done within harfbuzz eventually.)
         if (glyphsInClump == 1 && baseCharIndex + 1 == endCharIndex &&
-            aShapedWord->FilterIfIgnorable(baseCharIndex)) {
+            aShapedText->FilterIfIgnorable(aOffset + baseCharIndex,
+                                           aText[baseCharIndex])) {
             glyphStart = glyphEnd;
             charStart = charEnd;
             continue;
@@ -1261,14 +1282,12 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
         if (glyphsInClump == 1 &&
             gfxTextRun::CompressedGlyph::IsSimpleGlyphID(ginfo[glyphStart].codepoint) &&
             gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance) &&
-            aShapedWord->IsClusterStart(baseCharIndex) &&
+            charGlyphs[baseCharIndex].IsClusterStart() &&
             xOffset == 0 &&
             posInfo[glyphStart].y_offset == 0 && yPos == 0)
         {
-            gfxTextRun::CompressedGlyph g;
-            aShapedWord->SetSimpleGlyph(baseCharIndex,
-                                     g.SetSimpleGlyph(advance,
-                                         ginfo[glyphStart].codepoint));
+            charGlyphs[baseCharIndex].SetSimpleGlyph(advance,
+                                                     ginfo[glyphStart].codepoint);
         } else {
             // collect all glyphs in a list to be assigned to the first char;
             // there must be at least one in the clump, and we already measured
@@ -1317,11 +1336,11 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
                 }
             }
 
-            gfxTextRun::CompressedGlyph g;
-            g.SetComplex(aShapedWord->IsClusterStart(baseCharIndex),
+            gfxShapedText::CompressedGlyph g;
+            g.SetComplex(charGlyphs[baseCharIndex].IsClusterStart(),
                          true, detailedGlyphs.Length());
-            aShapedWord->SetGlyphs(baseCharIndex,
-                                g, detailedGlyphs.Elements());
+            aShapedText->SetGlyphs(aOffset + baseCharIndex,
+                                   g, detailedGlyphs.Elements());
 
             detailedGlyphs.Clear();
         }
@@ -1330,10 +1349,9 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
         // no associated glyphs
         while (++baseCharIndex != endCharIndex &&
                baseCharIndex < int32_t(wordLength)) {
-            gfxTextRun::CompressedGlyph g;
-            g.SetComplex(aShapedWord->IsClusterStart(baseCharIndex),
-                         false, 0);
-            aShapedWord->SetGlyphs(baseCharIndex, g, nullptr);
+            gfxShapedText::CompressedGlyph &g = charGlyphs[baseCharIndex];
+            NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
+            g.SetComplex(g.IsClusterStart(), false, 0);
         }
 
         glyphStart = glyphEnd;
diff --git a/gfx/thebes/gfxHarfBuzzShaper.h b/gfx/thebes/gfxHarfBuzzShaper.h
index 7f948af94ed0..a76af1963e5e 100644
--- a/gfx/thebes/gfxHarfBuzzShaper.h
+++ b/gfx/thebes/gfxHarfBuzzShaper.h
@@ -18,9 +18,12 @@ public:
     gfxHarfBuzzShaper(gfxFont *aFont);
     virtual ~gfxHarfBuzzShaper();
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aText);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText);
 
     // get a given font table in harfbuzz blob form
     hb_blob_t * GetFontTable(hb_tag_t aTag) const;
@@ -37,9 +40,12 @@ public:
                               uint16_t aSecondGlyph) const;
 
 protected:
-    nsresult SetGlyphsFromRun(gfxContext *aContext,
-                              gfxShapedWord *aShapedWord,
-                              hb_buffer_t *aBuffer);
+    nsresult SetGlyphsFromRun(gfxContext      *aContext,
+                              gfxShapedText   *aShapedText,
+                              uint32_t         aOffset,
+                              uint32_t         aLength,
+                              const PRUnichar *aText,
+                              hb_buffer_t     *aBuffer);
 
     // retrieve glyph positions, applying advance adjustments and attachments
     // returns results in appUnits
diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp
index db6c8984e1ef..80b1b9968b35 100644
--- a/gfx/thebes/gfxMacFont.cpp
+++ b/gfx/thebes/gfxMacFont.cpp
@@ -120,10 +120,13 @@ gfxMacFont::~gfxMacFont()
 }
 
 bool
-gfxMacFont::ShapeWord(gfxContext *aContext,
-                      gfxShapedWord *aShapedWord,
+gfxMacFont::ShapeText(gfxContext      *aContext,
                       const PRUnichar *aText,
-                      bool aPreferPlatformShaping)
+                      uint32_t         aOffset,
+                      uint32_t         aLength,
+                      int32_t          aScript,
+                      gfxShapedText   *aShapedText,
+                      bool             aPreferPlatformShaping)
 {
     if (!mIsValid) {
         NS_WARNING("invalid font! expect incorrect text rendering");
@@ -132,7 +135,8 @@ gfxMacFont::ShapeWord(gfxContext *aContext,
 
     bool requiresAAT =
         static_cast(GetFontEntry())->RequiresAATLayout();
-    return gfxFont::ShapeWord(aContext, aShapedWord, aText, requiresAAT);
+    return gfxFont::ShapeText(aContext, aText, aOffset, aLength,
+                              aScript, aShapedText, requiresAAT);
 }
 
 void
diff --git a/gfx/thebes/gfxMacFont.h b/gfx/thebes/gfxMacFont.h
index 81a006917a5b..77133a633c8d 100644
--- a/gfx/thebes/gfxMacFont.h
+++ b/gfx/thebes/gfxMacFont.h
@@ -57,10 +57,13 @@ protected:
     virtual void CreatePlatformShaper();
 
     // override to prefer CoreText shaping with fonts that depend on AAT
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
+    virtual bool ShapeText(gfxContext      *aContext,
                            const PRUnichar *aText,
-                           bool aPreferPlatformShaping = false);
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText,
+                           bool             aPreferPlatformShaping = false);
 
     void InitMetrics();
     void InitMetricsFromPlatform();
diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp
index 1c0d3241cfa7..1c8873302839 100644
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -83,7 +83,7 @@ static PangoLanguage *GuessPangoLanguage(nsIAtom *aLanguage);
 
 static cairo_scaled_font_t *
 CreateScaledFont(FcPattern *aPattern, cairo_font_face_t *aFace);
-static void SetMissingGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8,
+static void SetMissingGlyphs(gfxShapedText *aShapedText, const gchar *aUTF8,
                              uint32_t aUTF8Length, uint32_t *aUTF16Offset,
                              gfxFont *aFont);
 
@@ -286,7 +286,7 @@ gfxFcFontEntry::ShouldUseHarfBuzz(int32_t aRunScript) {
         return true;
     }
 
-    // Mimicing gfxHarfBuzzShaper::ShapeWord
+    // Mimicing gfxHarfBuzzShaper::ShapeText
     hb_script_t script = (aRunScript <= MOZ_SCRIPT_INHERITED) ?
         HB_SCRIPT_LATIN :
         hb_script_t(GetScriptTagForCode(aRunScript));
@@ -804,13 +804,19 @@ public:
     }
 
 protected:
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString,
-                           bool aPreferPlatformShaping);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText,
+                           bool             aPreferPlatformShaping);
 
-    bool InitGlyphRunWithPango(gfxShapedWord *aTextRun,
-                               const PRUnichar *aString);
+    bool InitGlyphRunWithPango(const PRUnichar *aString,
+                               uint32_t         aOffset,
+                               uint32_t         aLength,
+                               int32_t          aScript,
+                               gfxShapedText   *aShapedText);
 
 private:
     gfxFcFont(cairo_scaled_font_t *aCairoFont, gfxFcFontEntry *aFontEntry,
@@ -2247,45 +2253,55 @@ gfxFcFont::~gfxFcFont()
 }
 
 bool
-gfxFcFont::ShapeWord(gfxContext *aContext,
-                     gfxShapedWord *aShapedWord,
-                     const PRUnichar *aString,
-                     bool aPreferPlatformShaping)
+gfxFcFont::ShapeText(gfxContext      *aContext,
+                     const PRUnichar *aText,
+                     uint32_t         aOffset,
+                     uint32_t         aLength,
+                     int32_t          aScript,
+                     gfxShapedText   *aShapedText,
+                     bool             aPreferPlatformShaping)
 {
     gfxFcFontEntry *fontEntry = static_cast(GetFontEntry());
 
+    bool ok = false;
+
 #ifdef MOZ_GRAPHITE
     if (FontCanSupportGraphite()) {
         if (gfxPlatform::GetPlatform()->UseGraphiteShaping()) {
             if (!mGraphiteShaper) {
                 mGraphiteShaper = new gfxGraphiteShaper(this);
             }
-            if (mGraphiteShaper->ShapeWord(aContext, aShapedWord, aString)) {
-                return true;
-            }
+            ok = mGraphiteShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                            aScript, aShapedText);
         }
     }
 #endif
 
-    if (fontEntry->ShouldUseHarfBuzz(aShapedWord->Script())) {
+    if (!ok && fontEntry->ShouldUseHarfBuzz(aScript)) {
         if (!mHarfBuzzShaper) {
             gfxFT2LockedFace face(this);
             mHarfBuzzShaper = new gfxHarfBuzzShaper(this);
             // Used by gfxHarfBuzzShaper, currently only for kerning
             mFUnitsConvFactor = face.XScale();
         }
-        if (mHarfBuzzShaper->ShapeWord(aContext, aShapedWord, aString)) {
-            return true;
+        ok = mHarfBuzzShaper->ShapeText(aContext, aText, aOffset, aLength,
+                                        aScript, aShapedText);
+        if (!ok) {
+            // Wrong font type for HarfBuzz
+            fontEntry->SkipHarfBuzz();
+            mHarfBuzzShaper = nullptr;
         }
-
-        // Wrong font type for HarfBuzz
-        fontEntry->SkipHarfBuzz();
-        mHarfBuzzShaper = nullptr;
     }
 
-    bool ok = InitGlyphRunWithPango(aShapedWord, aString);
+    if (!ok) {
+        ok = InitGlyphRunWithPango(aText, aOffset, aLength, aScript,
+                                   aShapedText);
+    }
 
     NS_WARN_IF_FALSE(ok, "shaper failed, expect scrambled or missing text");
+
+    PostShapingFixup(aContext, aText, aOffset, aLength, aShapedText);
+
     return ok;
 }
 
@@ -2786,42 +2802,42 @@ ConvertPangoToAppUnits(int32_t aCoordinate, uint32_t aAppUnitsPerDevUnit)
  */ 
 static nsresult
 SetGlyphsForCharacterGroup(const PangoGlyphInfo *aGlyphs, uint32_t aGlyphCount,
-                           gfxShapedWord *aShapedWord,
+                           gfxShapedText *aShapedText,
                            const gchar *aUTF8, uint32_t aUTF8Length,
                            uint32_t *aUTF16Offset,
                            PangoGlyphUnit aOverrideSpaceWidth)
 {
     uint32_t utf16Offset = *aUTF16Offset;
-    uint32_t wordLength = aShapedWord->Length();
-    const uint32_t appUnitsPerDevUnit = aShapedWord->AppUnitsPerDevUnit();
+    uint32_t limit = aShapedText->GetLength();
+    const uint32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();
+    gfxShapedText::CompressedGlyph *charGlyphs =
+        aShapedText->GetCharacterGlyphs();
+    bool atClusterStart = charGlyphs[utf16Offset].IsClusterStart();
 
     // Override the width of a space, but only for spaces that aren't
     // clustered with something else (like a freestanding diacritical mark)
     PangoGlyphUnit width = aGlyphs[0].geometry.width;
     if (aOverrideSpaceWidth && aUTF8[0] == ' ' &&
-        (utf16Offset + 1 == wordLength ||
-         aShapedWord->IsClusterStart(utf16Offset))) {
+        (utf16Offset + 1 == limit || atClusterStart)) {
         width = aOverrideSpaceWidth;
     }
     int32_t advance = ConvertPangoToAppUnits(width, appUnitsPerDevUnit);
 
-    gfxShapedWord::CompressedGlyph g;
-    bool atClusterStart = aShapedWord->IsClusterStart(utf16Offset);
+    gfxShapedText::CompressedGlyph g;
     // See if we fit in the compressed area.
     if (aGlyphCount == 1 && advance >= 0 && atClusterStart &&
         aGlyphs[0].geometry.x_offset == 0 &&
         aGlyphs[0].geometry.y_offset == 0 &&
         !IS_EMPTY_GLYPH(aGlyphs[0].glyph) &&
-        gfxShapedWord::CompressedGlyph::IsSimpleAdvance(advance) &&
-        gfxShapedWord::CompressedGlyph::IsSimpleGlyphID(aGlyphs[0].glyph)) {
-        aShapedWord->SetSimpleGlyph(utf16Offset,
-                                    g.SetSimpleGlyph(advance, aGlyphs[0].glyph));
+        gfxShapedText::CompressedGlyph::IsSimpleAdvance(advance) &&
+        gfxShapedText::CompressedGlyph::IsSimpleGlyphID(aGlyphs[0].glyph)) {
+        charGlyphs[utf16Offset].SetSimpleGlyph(advance, aGlyphs[0].glyph);
     } else {
-        nsAutoTArray detailedGlyphs;
+        nsAutoTArray detailedGlyphs;
         if (!detailedGlyphs.AppendElements(aGlyphCount))
             return NS_ERROR_OUT_OF_MEMORY;
 
-        int32_t direction = aShapedWord->IsRightToLeft() ? -1 : 1;
+        int32_t direction = aShapedText->IsRightToLeft() ? -1 : 1;
         uint32_t pangoIndex = direction > 0 ? 0 : aGlyphCount - 1;
         uint32_t detailedIndex = 0;
         for (uint32_t i = 0; i < aGlyphCount; ++i) {
@@ -2832,7 +2848,7 @@ SetGlyphsForCharacterGroup(const PangoGlyphInfo *aGlyphs, uint32_t aGlyphCount,
             if (IS_EMPTY_GLYPH(glyph.glyph))
                 continue;
 
-            gfxShapedWord::DetailedGlyph *details = &detailedGlyphs[detailedIndex];
+            gfxShapedText::DetailedGlyph *details = &detailedGlyphs[detailedIndex];
             ++detailedIndex;
 
             details->mGlyphID = glyph.glyph;
@@ -2847,7 +2863,7 @@ SetGlyphsForCharacterGroup(const PangoGlyphInfo *aGlyphs, uint32_t aGlyphCount,
                 float(glyph.geometry.y_offset)*appUnitsPerDevUnit/PANGO_SCALE;
         }
         g.SetComplex(atClusterStart, true, detailedIndex);
-        aShapedWord->SetGlyphs(utf16Offset, g, detailedGlyphs.Elements());
+        aShapedText->SetGlyphs(utf16Offset, g, detailedGlyphs.Elements());
     }
 
     // Check for ligatures and set *aUTF16Offset.
@@ -2872,20 +2888,21 @@ SetGlyphsForCharacterGroup(const PangoGlyphInfo *aGlyphs, uint32_t aGlyphCount,
         if (p >= end)
             break;
 
-        if (utf16Offset >= wordLength) {
+        if (utf16Offset >= limit) {
             NS_ERROR("Someone has added too many glyphs!");
             return NS_ERROR_FAILURE;
         }
 
-        g.SetComplex(aShapedWord->IsClusterStart(utf16Offset), false, 0);
-        aShapedWord->SetGlyphs(utf16Offset, g, nullptr);
+        gfxShapedText::CompressedGlyph &g = charGlyphs[utf16Offset];
+        NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
+        g.SetComplex(g.IsClusterStart(), false, 0);
     }
     *aUTF16Offset = utf16Offset;
     return NS_OK;
 }
 
 static nsresult
-SetGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8, uint32_t aUTF8Length,
+SetGlyphs(gfxShapedText *aShapedText, const gchar *aUTF8, uint32_t aUTF8Length,
           uint32_t *aUTF16Offset, PangoGlyphString *aGlyphs,
           PangoGlyphUnit aOverrideSpaceWidth,
           gfxFont *aFont)
@@ -2921,13 +2938,13 @@ SetGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8, uint32_t aUTF8Length,
     }
 
     uint32_t utf16Offset = *aUTF16Offset;
-    uint32_t wordLength = aShapedWord->Length();
+    uint32_t limit = aShapedText->GetLength();
     utf8Index = 0;
     // The next glyph cluster in logical order. 
     gint nextGlyphClusterStart = logGlyphs[utf8Index];
     NS_ASSERTION(nextGlyphClusterStart >= 0, "No glyphs! - NUL in string?");
     while (utf8Index < aUTF8Length) {
-        if (utf16Offset >= wordLength) {
+        if (utf16Offset >= limit) {
           NS_ERROR("Someone has added too many glyphs!");
           return NS_ERROR_FAILURE;
         }
@@ -2935,7 +2952,7 @@ SetGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8, uint32_t aUTF8Length,
         // Find the utf8 text associated with this glyph cluster.
         uint32_t clusterUTF8Start = utf8Index;
         // Check whether we are consistent with pango_break data.
-        NS_WARN_IF_FALSE(aShapedWord->IsClusterStart(utf16Offset),
+        NS_WARN_IF_FALSE(aShapedText->IsClusterStart(utf16Offset),
                          "Glyph cluster not aligned on character cluster.");
         do {
             ++utf8Index;
@@ -2961,12 +2978,12 @@ SetGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8, uint32_t aUTF8Length,
 
         nsresult rv;
         if (haveMissingGlyph) {
-            SetMissingGlyphs(aShapedWord, clusterUTF8, clusterUTF8Length,
+            SetMissingGlyphs(aShapedText, clusterUTF8, clusterUTF8Length,
                              &utf16Offset, aFont);
         } else {
             rv = SetGlyphsForCharacterGroup(&glyphs[glyphClusterStart],
                                             glyphIndex - glyphClusterStart,
-                                            aShapedWord,
+                                            aShapedText,
                                             clusterUTF8, clusterUTF8Length,
                                             &utf16Offset, aOverrideSpaceWidth);
             NS_ENSURE_SUCCESS(rv,rv);
@@ -2977,19 +2994,19 @@ SetGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8, uint32_t aUTF8Length,
 }
 
 static void
-SetMissingGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8,
+SetMissingGlyphs(gfxShapedText *aShapedText, const gchar *aUTF8,
                  uint32_t aUTF8Length, uint32_t *aUTF16Offset,
                  gfxFont *aFont)
 {
     uint32_t utf16Offset = *aUTF16Offset;
-    uint32_t wordLength = aShapedWord->Length();
+    uint32_t limit = aShapedText->GetLength();
     for (uint32_t index = 0; index < aUTF8Length;) {
-        if (utf16Offset >= wordLength) {
+        if (utf16Offset >= limit) {
             NS_ERROR("Someone has added too many glyphs!");
             break;
         }
         gunichar ch = g_utf8_get_char(aUTF8 + index);
-        aShapedWord->SetMissingGlyph(utf16Offset, ch, aFont);
+        aShapedText->SetMissingGlyph(utf16Offset, ch, aFont);
 
         ++utf16Offset;
         NS_ASSERTION(!IS_SURROGATE(ch), "surrogates should not appear in UTF8");
@@ -3003,20 +3020,23 @@ SetMissingGlyphs(gfxShapedWord *aShapedWord, const gchar *aUTF8,
 }
 
 static void
-InitGlyphRunWithPangoAnalysis(gfxShapedWord *aShapedWord,
+InitGlyphRunWithPangoAnalysis(gfxShapedText *aShapedText,
+                              uint32_t aOffset, uint32_t aLength,
                               const gchar *aUTF8, uint32_t aUTF8Length,
                               PangoAnalysis *aAnalysis,
                               PangoGlyphUnit aOverrideSpaceWidth,
                               gfxFont *aFont)
 {
-    uint32_t utf16Offset = 0;
+    uint32_t utf16Offset = aOffset;
     PangoGlyphString *glyphString = pango_glyph_string_new();
 
     const gchar *p = aUTF8;
     const gchar *end = p + aUTF8Length;
     while (p < end) {
+        NS_ASSERTION(utf16Offset < aOffset + aLength,
+                     "overrun expected range of aShapedText");
         if (*p == 0) {
-            aShapedWord->SetMissingGlyph(utf16Offset, 0, aFont);
+            aShapedText->SetMissingGlyph(utf16Offset, 0, aFont);
             ++p;
             ++utf16Offset;
             continue;
@@ -3031,7 +3051,7 @@ InitGlyphRunWithPangoAnalysis(gfxShapedWord *aShapedWord,
         gint len = p - text;
 
         pango_shape(text, len, aAnalysis, glyphString);
-        SetGlyphs(aShapedWord, text, len, &utf16Offset, glyphString,
+        SetGlyphs(aShapedText, text, len, &utf16Offset, glyphString,
                   aOverrideSpaceWidth, aFont);
     }
 
@@ -3059,11 +3079,14 @@ typedef union {
 } PangoAnalysisUnion;
 
 bool
-gfxFcFont::InitGlyphRunWithPango(gfxShapedWord *aShapedWord,
-                                 const PRUnichar *aString)
+gfxFcFont::InitGlyphRunWithPango(const PRUnichar *aString,
+                                 uint32_t         aOffset,
+                                 uint32_t         aLength,
+                                 int32_t          aScript,
+                                 gfxShapedText   *aShapedText)
 {
-    const PangoScript script = static_cast(aShapedWord->Script());
-    NS_ConvertUTF16toUTF8 utf8(aString, aShapedWord->Length());
+    const PangoScript script = static_cast(aScript);
+    NS_ConvertUTF16toUTF8 utf8(aString, aLength);
 
     PangoFont *font = GetPangoFont();
 
@@ -3169,7 +3192,7 @@ gfxFcFont::InitGlyphRunWithPango(gfxShapedWord *aShapedWord,
         PANGO_ENGINE_LANG(pango_map_get_engine(langMap, script));
 
     analysis.local.font = font;
-    analysis.local.level = aShapedWord->IsRightToLeft() ? 1 : 0;
+    analysis.local.level = aShapedText->IsRightToLeft() ? 1 : 0;
     // gravity and flags are used in Pango 1.14.10 and newer.
     //
     // PANGO_GRAVITY_SOUTH is what we want for upright horizontal text.  The
@@ -3192,7 +3215,8 @@ gfxFcFont::InitGlyphRunWithPango(gfxShapedWord *aShapedWord,
     PangoGlyphUnit spaceWidth =
         moz_pango_units_from_double(GetMetrics().spaceWidth);
 
-    InitGlyphRunWithPangoAnalysis(aShapedWord, utf8.get(), utf8.Length(),
+    InitGlyphRunWithPangoAnalysis(aShapedText, aOffset, aLength,
+                                  utf8.get(), utf8.Length(),
                                   &analysis.pango, spaceWidth, this);
     return true;
 }
diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp
index c93516e86e64..490c6e9ac4ad 100644
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1601,8 +1601,7 @@ gfxPlatform::SetupClusterBoundaries(gfxTextRun *aTextRun, const PRUnichar *aStri
         return;
     }
 
-    gfxShapedWord::SetupClusterBoundaries(aTextRun->GetCharacterGlyphs(),
-                                          aString, aTextRun->GetLength());
+    aTextRun->SetupClusterBoundaries(0, aString, aTextRun->GetLength());
 }
 
 int32_t
diff --git a/gfx/thebes/gfxUniscribeShaper.cpp b/gfx/thebes/gfxUniscribeShaper.cpp
index 12381211961d..65d066823e88 100644
--- a/gfx/thebes/gfxUniscribeShaper.cpp
+++ b/gfx/thebes/gfxUniscribeShaper.cpp
@@ -217,7 +217,7 @@ public:
         }
     }
 
-    void SaveGlyphs(gfxShapedWord *aShapedWord) {
+    void SaveGlyphs(gfxShapedText *aShapedText, uint32_t aOffset) {
         uint32_t offsetInRun = mScriptItem->iCharPos;
 
         // XXX We should store this in the item and only fetch it once
@@ -225,15 +225,18 @@ public:
         ScriptFontProperties(&sfp);
 
         uint32_t offset = 0;
-        nsAutoTArray detailedGlyphs;
-        gfxShapedWord::CompressedGlyph g;
-        const uint32_t appUnitsPerDevUnit = aShapedWord->AppUnitsPerDevUnit();
+        nsAutoTArray detailedGlyphs;
+        gfxShapedText::CompressedGlyph g;
+        gfxShapedText::CompressedGlyph *charGlyphs =
+            aShapedText->GetCharacterGlyphs();
+        const uint32_t appUnitsPerDevUnit = aShapedText->GetAppUnitsPerDevUnit();
         while (offset < mItemLength) {
-            uint32_t runOffset = offsetInRun + offset;
-            bool atClusterStart = aShapedWord->IsClusterStart(runOffset);
+            uint32_t runOffset = aOffset + offsetInRun + offset;
+            bool atClusterStart = charGlyphs[runOffset].IsClusterStart();
             if (offset > 0 && mClusters[offset] == mClusters[offset - 1]) {
+                gfxShapedText::CompressedGlyph &g = charGlyphs[runOffset];
+                NS_ASSERTION(!g.IsSimpleGlyph(), "overwriting a simple glyph");
                 g.SetComplex(atClusterStart, false, 0);
-                aShapedWord->SetGlyphs(runOffset, g, nullptr);
             } else {
                 // Count glyphs for this character
                 uint32_t k = mClusters[offset];
@@ -260,21 +263,21 @@ public:
                     if (NS_IS_HIGH_SURROGATE(mItemString[offset]) &&
                         offset + 1 < mItemLength &&
                         NS_IS_LOW_SURROGATE(mItemString[offset + 1])) {
-                        aShapedWord->SetMissingGlyph(runOffset,
+                        aShapedText->SetMissingGlyph(runOffset,
                                                      SURROGATE_TO_UCS4(mItemString[offset],
                                                                        mItemString[offset + 1]),
                                                      mShaper->GetFont());
                     } else {
-                        aShapedWord->SetMissingGlyph(runOffset, mItemString[offset],
+                        aShapedText->SetMissingGlyph(runOffset, mItemString[offset],
                                                      mShaper->GetFont());
                     }
                 } else if (glyphCount == 1 && advance >= 0 &&
                     mOffsets[k].dv == 0 && mOffsets[k].du == 0 &&
-                    gfxShapedWord::CompressedGlyph::IsSimpleAdvance(advance) &&
-                    gfxShapedWord::CompressedGlyph::IsSimpleGlyphID(glyph) &&
+                    gfxShapedText::CompressedGlyph::IsSimpleAdvance(advance) &&
+                    gfxShapedText::CompressedGlyph::IsSimpleGlyphID(glyph) &&
                     atClusterStart)
                 {
-                    aShapedWord->SetSimpleGlyph(runOffset, g.SetSimpleGlyph(advance, glyph));
+                    charGlyphs[runOffset].SetSimpleGlyph(advance, glyph);
                 } else {
                     if (detailedGlyphs.Length() < glyphCount) {
                         if (!detailedGlyphs.AppendElements(glyphCount - detailedGlyphs.Length()))
@@ -286,10 +289,10 @@ public:
                         details->mGlyphID = mGlyphs[k + i];
                         details->mAdvance = mAdvances[k + i] * appUnitsPerDevUnit;
                         details->mXOffset = float(mOffsets[k + i].du) * appUnitsPerDevUnit *
-                            aShapedWord->GetDirection();
+                            aShapedText->GetDirection();
                         details->mYOffset = - float(mOffsets[k + i].dv) * appUnitsPerDevUnit;
                     }
-                    aShapedWord->SetGlyphs(runOffset,
+                    aShapedText->SetGlyphs(runOffset,
                                            g.SetComplex(atClusterStart, true,
                                                         glyphCount),
                                            detailedGlyphs.Elements());
@@ -367,8 +370,10 @@ class Uniscribe
 {
 public:
     Uniscribe(const PRUnichar *aString,
-              gfxShapedWord *aShapedWord):
-        mString(aString), mShapedWord(aShapedWord)
+              gfxShapedText *aShapedText,
+              uint32_t aOffset, uint32_t aLength):
+        mString(aString), mShapedText(aShapedText),
+        mOffset(aOffset), mLength(aLength)
     {
     }
 
@@ -377,7 +382,7 @@ public:
         memset(&mState, 0, sizeof(SCRIPT_STATE));
         // Lock the direction. Don't allow the itemizer to change directions
         // based on character type.
-        mState.uBidiLevel = mShapedWord->IsRightToLeft() ? 1 : 0;
+        mState.uBidiLevel = mShapedText->IsRightToLeft() ? 1 : 0;
         mState.fOverrideDirection = true;
     }
 
@@ -394,7 +399,7 @@ public:
         if (!mItems.SetLength(maxItems + 1)) {
             return 0;
         }
-        while ((rv = ScriptItemize(mString, mShapedWord->Length(),
+        while ((rv = ScriptItemize(mString, mLength,
                                    maxItems, &mControl, &mState,
                                    mItems.Elements(), &mNumItems)) == E_OUTOFMEMORY) {
             maxItems *= 2;
@@ -414,7 +419,9 @@ public:
 
 private:
     const PRUnichar *mString;
-    gfxShapedWord   *mShapedWord;
+    gfxShapedText   *mShapedText;
+    uint32_t         mOffset;
+    uint32_t         mLength;
 
     SCRIPT_CONTROL mControl;
     SCRIPT_STATE   mState;
@@ -424,21 +431,24 @@ private:
 
 
 bool
-gfxUniscribeShaper::ShapeWord(gfxContext *aContext,
-                              gfxShapedWord *aShapedWord,
-                              const PRUnichar *aString)
+gfxUniscribeShaper::ShapeText(gfxContext      *aContext,
+                              const PRUnichar *aText,
+                              uint32_t         aOffset,
+                              uint32_t         aLength,
+                              int32_t          aScript,
+                              gfxShapedText   *aShapedText)
 {
     DCFromContext aDC(aContext);
  
     bool result = true;
     HRESULT rv;
 
-    Uniscribe us(aString, aShapedWord);
+    Uniscribe us(aText, aShapedText, aOffset, aLength);
 
     /* itemize the string */
     int numItems = us.Itemize();
 
-    uint32_t length = aShapedWord->Length();
+    uint32_t length = aLength;
     SaveDC(aDC);
     uint32_t ivs = 0;
     for (int i = 0; i < numItems; ++i) {
@@ -454,18 +464,18 @@ gfxUniscribeShaper::ShapeWord(gfxContext *aContext,
         }
 
         if (i+1 < numItems && iCharPosNext <= length - 2
-            && aString[iCharPosNext] == H_SURROGATE(kUnicodeVS17)
-            && uint32_t(aString[iCharPosNext + 1]) - L_SURROGATE(kUnicodeVS17)
+            && aText[iCharPosNext] == H_SURROGATE(kUnicodeVS17)
+            && uint32_t(aText[iCharPosNext + 1]) - L_SURROGATE(kUnicodeVS17)
             <= L_SURROGATE(kUnicodeVS256) - L_SURROGATE(kUnicodeVS17)) {
 
-            ivs = SURROGATE_TO_UCS4(aString[iCharPosNext],
-                                    aString[iCharPosNext + 1]);
+            ivs = SURROGATE_TO_UCS4(aText[iCharPosNext],
+                                    aText[iCharPosNext + 1]);
         } else {
             ivs = 0;
         }
 
         UniscribeItem item(aContext, aDC, this,
-                           aString + iCharPos,
+                           aText + iCharPos,
                            iCharPosNext - iCharPos,
                            us.ScriptItem(i), ivs);
         if (!item.AllocateBuffers()) {
@@ -509,7 +519,7 @@ gfxUniscribeShaper::ShapeWord(gfxContext *aContext,
             break;
         }
 
-        item.SaveGlyphs(aShapedWord);
+        item.SaveGlyphs(aShapedText, aOffset);
     }
 
     RestoreDC(aDC, -1);
diff --git a/gfx/thebes/gfxUniscribeShaper.h b/gfx/thebes/gfxUniscribeShaper.h
index cc59d9d92686..c90518b6f6cd 100644
--- a/gfx/thebes/gfxUniscribeShaper.h
+++ b/gfx/thebes/gfxUniscribeShaper.h
@@ -29,9 +29,12 @@ public:
         MOZ_COUNT_DTOR(gfxUniscribeShaper);
     }
 
-    virtual bool ShapeWord(gfxContext *aContext,
-                           gfxShapedWord *aShapedWord,
-                           const PRUnichar *aString);
+    virtual bool ShapeText(gfxContext      *aContext,
+                           const PRUnichar *aText,
+                           uint32_t         aOffset,
+                           uint32_t         aLength,
+                           int32_t          aScript,
+                           gfxShapedText   *aShapedText);
 
     SCRIPT_CACHE *ScriptCache() { return &mScriptCache; }
 

From dc68a4ac60bcaf7501d05382cbc9ff65f3a44cbf Mon Sep 17 00:00:00 2001
From: Jonathan Kew 
Date: Fri, 4 Jan 2013 18:35:37 +0000
Subject: [PATCH 062/180] bug 825875 - shape long words directly into the
 textrun instead of using word caching. r=roc

---
 gfx/thebes/gfxFont.cpp | 78 +++++++++++++++---------------------------
 gfx/thebes/gfxFont.h   |  2 +-
 2 files changed, 29 insertions(+), 51 deletions(-)

diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp
index 65dd392ccabc..4423e3c3abff 100644
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2658,36 +2658,7 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
         // break into separate ShapedWords when we hit an invalid char,
         // or a boundary space (always handled individually),
         // or the first non-space after a space
-        bool breakHere = boundary || invalid;
-
-        if (!breakHere) {
-            // if we're approaching the max length for shaping, break anyway...
-            if (sizeof(T) == sizeof(uint8_t)) {
-                // in 8-bit text, no clusters or surrogates to worry about
-                if (length >= gfxShapedWord::kMaxLength) {
-                    breakHere = true;
-                }
-            } else {
-                // try to avoid breaking before combining mark or low surrogate
-                if (length >= gfxShapedWord::kMaxLength - 15) {
-                    if (!NS_IS_LOW_SURROGATE(ch)) {
-                        if (!IsClusterExtender(ch)) {
-                            breakHere = true;
-                        }
-                    }
-                    if (!breakHere && length >= gfxShapedWord::kMaxLength - 3) {
-                        if (!NS_IS_LOW_SURROGATE(ch)) {
-                            breakHere = true;
-                        }
-                    }
-                    if (!breakHere && length >= gfxShapedWord::kMaxLength) {
-                        breakHere = true;
-                    }
-                }
-            }
-        }
-
-        if (!breakHere) {
+        if (!boundary && !invalid) {
             if (!IsChar8Bit(ch)) {
                 wordIs8Bit = false;
             }
@@ -2696,10 +2667,21 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
             continue;
         }
 
-        // We've decided to break here (i.e. we're at the end of a "word",
-        // or the word is becoming excessively long): shape the word and
-        // add it to the textrun
-        if (length > 0) {
+        // We've decided to break here (i.e. we're at the end of a "word");
+        // shape the word and add it to the textrun.
+        // For words longer than gfxShapedWord::kMaxLength, we don't use the
+        // font's word cache but just shape directly into the textrun.
+        if (length > gfxShapedWord::kMaxLength) {
+            bool ok = ShapeFragmentWithoutWordCache(aContext,
+                                                    text + wordStart,
+                                                    aRunStart + wordStart,
+                                                    length,
+                                                    aRunScript,
+                                                    aTextRun);
+            if (!ok) {
+                return false;
+            }
+        } else if (length > 0) {
             uint32_t wordFlags = flags;
             // in the 8-bit version of this method, TEXT_IS_8BIT was
             // already set as part of |flags|, so no need for a per-word
@@ -2749,24 +2731,20 @@ gfxFont::SplitAndInitTextRun(gfxContext *aContext,
             break;
         }
 
-        if (invalid) {
-            // word was terminated by an invalid char: skip it,
-            // but record where TAB or NEWLINE occur
-            if (ch == '\t') {
-                aTextRun->SetIsTab(aRunStart + i);
-            } else if (ch == '\n') {
-                aTextRun->SetIsNewline(aRunStart + i);
-            }
-            hash = 0;
-            wordStart = i + 1;
-            wordIs8Bit = true;
-            continue;
+        NS_ASSERTION(invalid,
+                     "how did we get here except via an invalid char?");
+
+        // word was terminated by an invalid char: skip it,
+        // but record where TAB or NEWLINE occur
+        if (ch == '\t') {
+            aTextRun->SetIsTab(aRunStart + i);
+        } else if (ch == '\n') {
+            aTextRun->SetIsNewline(aRunStart + i);
         }
 
-        // word was forcibly broken, so current char will begin next word
-        hash = HashMix(0, ch);
-        wordStart = i;
-        wordIs8Bit = IsChar8Bit(ch);
+        hash = 0;
+        wordStart = i + 1;
+        wordIs8Bit = true;
     }
 
     return true;
diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h
index b83c295bc930..7f24bd2545b9 100644
--- a/gfx/thebes/gfxFont.h
+++ b/gfx/thebes/gfxFont.h
@@ -2257,7 +2257,7 @@ protected:
 class gfxShapedWord : public gfxShapedText
 {
 public:
-    static const uint32_t kMaxLength = 0x7fff;
+    static const uint32_t kMaxLength = 32;
 
     // Create a ShapedWord that can hold glyphs for aLength characters,
     // with mCharacterGlyphs sized appropriately.

From 2245ac0938023973f47e4a3fdc058902478fa15b Mon Sep 17 00:00:00 2001
From: Joel Maher 
Date: Fri, 4 Jan 2013 13:42:22 -0500
Subject: [PATCH 063/180] Bug 826308 - Robocop tests log output should contain
 begin/end block markers for the full test run. r=bc

---
 testing/mochitest/runtestsremote.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testing/mochitest/runtestsremote.py b/testing/mochitest/runtestsremote.py
index 9d17873b2f49..caeaa090c73e 100644
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -552,7 +552,9 @@ def main():
         else:
             # if we didn't have some kind of error running the tests, make
             # sure the tests actually passed
+            print "INFO | runtests.py | Test summary: start."
             overallResult = mochitest.printLog()
+            print "INFO | runtests.py | Test summary: end."
             if retVal == 0:
                 retVal = overallResult
     else:

From daa306bad0d52a5968fe8cd21446c4f79ec3c3e9 Mon Sep 17 00:00:00 2001
From: Joel Maher 
Date: Fri, 4 Jan 2013 13:42:32 -0500
Subject: [PATCH 064/180] Bug 826769 - make mochitest-robotium may fail with:
 OSError: [Errno 2] No such file or directory: '/tmp/xxx/tests.jar'. r=gbrown

---
 testing/mochitest/runtestsremote.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/testing/mochitest/runtestsremote.py b/testing/mochitest/runtestsremote.py
index caeaa090c73e..548c2e8f4146 100644
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -305,9 +305,11 @@ class MochiRemote(Mochitest):
             shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'worker-test@mozilla.org'))
             shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'workerbootstrap-test@mozilla.org'))
             shutil.rmtree(os.path.join(options.profilePath, 'extensions', 'staged', 'special-powers@mozilla.org'))
-            os.remove(os.path.join(options.profilePath, 'tests.jar'))
             os.remove(os.path.join(options.profilePath, 'userChrome.css'))
-            os.remove(os.path.join(options.profilePath, 'tests.manifest'))
+            if os.path.exists(os.path.join(options.profilePath, 'tests.jar')):
+                os.remove(os.path.join(options.profilePath, 'tests.jar'))
+            if os.path.exists(os.path.join(options.profilePath, 'tests.manifest')):
+                os.remove(os.path.join(options.profilePath, 'tests.manifest'))
 
         try:
             self._dm.pushDir(options.profilePath, self.remoteProfile)

From f34fa488f4b9483f58f25fd0b6984710fa888d2c Mon Sep 17 00:00:00 2001
From: William Chen 
Date: Thu, 3 Jan 2013 22:54:26 -0800
Subject: [PATCH 065/180] Bug 617532 - Implement UndoManager. r=ehsan

---
 browser/base/content/browser-places.js        |    8 +-
 .../places/content/bookmarkProperties.js      |    4 +-
 .../components/places/src/PlacesUIUtils.jsm   |    4 +-
 build/automation.py.in                        |    1 +
 content/base/public/Element.h                 |   16 +
 content/base/public/FragmentOrElement.h       |    8 +
 content/base/public/nsIDocument.h             |    3 +
 content/base/src/FragmentOrElement.cpp        |    6 +
 content/base/src/nsDocument.cpp               |   19 +
 content/base/src/nsDocument.h                 |   10 +
 content/base/src/nsGkAtomList.h               |    1 +
 content/events/src/nsEventDispatcher.cpp      |    2 +
 content/html/content/src/Makefile.in          |    5 +-
 content/html/content/src/UndoManager.cpp      | 1214 +++++++++++++++++
 content/html/content/src/UndoManager.h        |  104 ++
 .../html/content/src/nsGenericHTMLElement.cpp |   84 ++
 .../html/content/src/nsGenericHTMLElement.h   |    5 +
 content/html/content/test/Makefile.in         |    1 +
 .../html/content/test/test_undoManager.html   |  852 ++++++++++++
 dom/bindings/Bindings.conf                    |   10 +
 dom/interfaces/events/Makefile.in             |    1 +
 .../events/nsIDOMDOMTransactionEvent.idl      |   25 +
 dom/interfaces/html/Makefile.in               |    1 +
 .../html/nsIUndoManagerTransaction.idl        |   17 +
 .../mochitest/general/test_interfaces.html    |    2 +
 dom/webidl/DOMTransaction.webidl              |   20 +
 dom/webidl/Document.webidl                    |   11 +-
 dom/webidl/Element.webidl                     |   10 +
 dom/webidl/UndoManager.webidl                 |   26 +
 dom/webidl/WebIDL.mk                          |    2 +
 editor/libeditor/base/nsEditor.cpp            |    4 +-
 .../libeditor/text/tests/test_bug471319.html  |    4 +-
 editor/txmgr/idl/nsITransactionList.idl       |   10 +-
 editor/txmgr/idl/nsITransactionManager.idl    |   34 +-
 editor/txmgr/src/nsTransactionItem.cpp        |    2 +
 editor/txmgr/src/nsTransactionItem.h          |    7 +
 editor/txmgr/src/nsTransactionList.cpp        |   36 +
 editor/txmgr/src/nsTransactionManager.cpp     |   72 +-
 editor/txmgr/src/nsTransactionManager.h       |    9 +-
 editor/txmgr/tests/TestTXMgr.cpp              |  130 +-
 js/xpconnect/src/event_impl_gen.conf.in       |    1 +
 .../places/tests/unit/test_placesTxn.js       |    4 +-
 42 files changed, 2684 insertions(+), 101 deletions(-)
 create mode 100644 content/html/content/src/UndoManager.cpp
 create mode 100644 content/html/content/src/UndoManager.h
 create mode 100644 content/html/content/test/test_undoManager.html
 create mode 100644 dom/interfaces/events/nsIDOMDOMTransactionEvent.idl
 create mode 100644 dom/interfaces/html/nsIUndoManagerTransaction.idl
 create mode 100644 dom/webidl/DOMTransaction.webidl
 create mode 100644 dom/webidl/UndoManager.webidl

diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js
index 88d5a234ba11..49b578a3da3f 100644
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -64,7 +64,7 @@ var StarUI = {
           this._restoreCommandsState();
           this._itemId = -1;
           if (this._batching) {
-            PlacesUtils.transactionManager.endBatch();
+            PlacesUtils.transactionManager.endBatch(false);
             this._batching = false;
           }
 
@@ -76,13 +76,13 @@ var StarUI = {
             case "remove": {
               // Remove all bookmarks for the bookmark's url, this also removes
               // the tags for the url.
-              PlacesUtils.transactionManager.beginBatch();
+              PlacesUtils.transactionManager.beginBatch(null);
               let itemIds = PlacesUtils.getBookmarksForURI(this._uriForRemoval);
               for (let i = 0; i < itemIds.length; i++) {
                 let txn = new PlacesRemoveItemTransaction(itemIds[i]);
                 PlacesUtils.transactionManager.doTransaction(txn);
               }
-              PlacesUtils.transactionManager.endBatch();
+              PlacesUtils.transactionManager.endBatch(false);
               break;
             }
           }
@@ -235,7 +235,7 @@ var StarUI = {
 
   beginBatch: function SU_beginBatch() {
     if (!this._batching) {
-      PlacesUtils.transactionManager.beginBatch();
+      PlacesUtils.transactionManager.beginBatch(null);
       this._batching = true;
     }
   }
diff --git a/browser/components/places/content/bookmarkProperties.js b/browser/components/places/content/bookmarkProperties.js
index 2de8ed41deef..b307180d7576 100644
--- a/browser/components/places/content/bookmarkProperties.js
+++ b/browser/components/places/content/bookmarkProperties.js
@@ -405,7 +405,7 @@ var BookmarkPropertiesPanel = {
     if (this._batching)
       return;
 
-    PlacesUtils.transactionManager.beginBatch();
+    PlacesUtils.transactionManager.beginBatch(null);
     this._batching = true;
   },
 
@@ -413,7 +413,7 @@ var BookmarkPropertiesPanel = {
     if (!this._batching)
       return;
 
-    PlacesUtils.transactionManager.endBatch();
+    PlacesUtils.transactionManager.endBatch(false);
     this._batching = false;
   },
 
diff --git a/browser/components/places/src/PlacesUIUtils.jsm b/browser/components/places/src/PlacesUIUtils.jsm
index 6c3f04f6c5ce..f6275722ec27 100644
--- a/browser/components/places/src/PlacesUIUtils.jsm
+++ b/browser/components/places/src/PlacesUIUtils.jsm
@@ -1153,10 +1153,10 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ptm", function() {
     //// nsITransactionManager forwarders.
 
     beginBatch: function()
-      PlacesUtils.transactionManager.beginBatch(),
+      PlacesUtils.transactionManager.beginBatch(null),
 
     endBatch: function()
-      PlacesUtils.transactionManager.endBatch(),
+      PlacesUtils.transactionManager.endBatch(false),
 
     doTransaction: function(txn)
       PlacesUtils.transactionManager.doTransaction(txn),
diff --git a/build/automation.py.in b/build/automation.py.in
index fe2448279512..5abf661d5047 100644
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -407,6 +407,7 @@ user_pref("app.update.enabled", false);
 user_pref("app.update.staging.enabled", false);
 user_pref("browser.panorama.experienced_first_run", true); // Assume experienced
 user_pref("dom.w3c_touch_events.enabled", 1);
+user_pref("dom.undo_manager.enabled", true);
 // Set a future policy version to avoid the telemetry prompt.
 user_pref("toolkit.telemetry.prompted", 999);
 user_pref("toolkit.telemetry.notifiedOptOut", 999);
diff --git a/content/base/public/Element.h b/content/base/public/Element.h
index 5a65e38adbcf..5fabce8920db 100644
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -116,6 +116,7 @@ namespace mozilla {
 namespace dom {
 
 class Link;
+class UndoManager;
 
 // IID for the dom::Element interface
 #define NS_ELEMENT_IID \
@@ -695,6 +696,21 @@ public:
            nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().XMost()) :
            0;
   }
+
+  virtual already_AddRefed GetUndoManager()
+  {
+    return nullptr;
+  }
+
+  virtual bool UndoScope()
+  {
+    return false;
+  }
+
+  virtual void SetUndoScope(bool aUndoScope, mozilla::ErrorResult& aError)
+  {
+  }
+
   virtual void GetInnerHTML(nsAString& aInnerHTML,
                             mozilla::ErrorResult& aError);
   virtual void SetInnerHTML(const nsAString& aInnerHTML,
diff --git a/content/base/public/FragmentOrElement.h b/content/base/public/FragmentOrElement.h
index 5e7c7de78ec1..8643e818b15d 100644
--- a/content/base/public/FragmentOrElement.h
+++ b/content/base/public/FragmentOrElement.h
@@ -166,6 +166,8 @@ class nsInlineEventHandlersTearoff;
 namespace mozilla {
 namespace dom {
 
+class UndoManager;
+
 class FragmentOrElement : public nsIContent
 {
 public:
@@ -312,6 +314,12 @@ public:
      */
     nsDOMStringMap* mDataset; // [Weak]
 
+    /**
+     * The .undoManager property.
+     * @see nsGenericHTMLElement::GetUndoManager
+     */
+    nsRefPtr mUndoManager;
+
     /**
      * SMIL Overridde style rules (for SMIL animation of CSS properties)
      * @see nsIContent::GetSMILOverrideStyle
diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h
index 153ed3a873dc..12544516354b 100644
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -90,6 +90,7 @@ class DocumentType;
 class DOMImplementation;
 class Element;
 class Link;
+class UndoManager;
 template class Sequence;
 } // namespace dom
 } // namespace mozilla
@@ -1647,6 +1648,8 @@ public:
    */
   virtual Element* LookupImageElement(const nsAString& aElementId) = 0;
 
+  virtual already_AddRefed GetUndoManager() = 0;
+
   nsresult ScheduleFrameRequestCallback(nsIFrameRequestCallback* aCallback,
                                         int32_t *aHandle);
   void CancelFrameRequestCallback(int32_t aHandle);
diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp
index b1b0809e0617..e43cd5301611 100644
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -101,6 +101,7 @@
 #include "nsAsyncDOMEvent.h"
 #include "nsTextNode.h"
 #include "mozilla/dom/NodeListBinding.h"
+#include "mozilla/dom/UndoManager.h"
 
 #ifdef MOZ_XUL
 #include "nsIXULDocument.h"
@@ -539,6 +540,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsInlineEventHandlersTearoff)
 FragmentOrElement::nsDOMSlots::nsDOMSlots()
   : nsINode::nsSlots(),
     mDataset(nullptr),
+    mUndoManager(nullptr),
     mBindingParent(nullptr)
 {
 }
@@ -566,6 +568,9 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb,
   NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mAttributeMap");
   cb.NoteXPCOMChild(mAttributeMap.get());
 
+  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mUndoManager");
+  cb.NoteXPCOMChild(mUndoManager.get());
+
   if (aIsXUL) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mControllers");
     cb.NoteXPCOMChild(mControllers);
@@ -590,6 +595,7 @@ FragmentOrElement::nsDOMSlots::Unlink(bool aIsXUL)
   if (aIsXUL)
     NS_IF_RELEASE(mControllers);
   mChildrenList = nullptr;
+  mUndoManager = nullptr;
   if (mClassList) {
     mClassList->DropReference();
     mClassList = nullptr;
diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp
index 2fa181aac709..fb018d1a03da 100644
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -184,6 +184,7 @@
 #include "nsIAppsService.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/DocumentFragment.h"
+#include "mozilla/dom/UndoManager.h"
 #include "nsFrame.h" 
 #include "nsDOMCaretPosition.h"
 #include "nsIDOMHTMLTextAreaElement.h"
@@ -1679,6 +1680,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOriginalDocument)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCachedEncoder)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStateObjectCached)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUndoManager)
 
   // Traverse all our nsCOMArrays.
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheets)
@@ -1736,6 +1738,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalDocument)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK(mUndoManager)
 
   tmp->mParentDocument = nullptr;
 
@@ -2640,6 +2643,22 @@ nsDocument::GetAllowPlugins(bool * aAllowPlugins)
   return NS_OK;
 }
 
+already_AddRefed
+nsDocument::GetUndoManager()
+{
+  Element* rootElement = GetRootElement();
+  if (!rootElement) {
+    return nullptr;
+  }
+
+  if (!mUndoManager) {
+    mUndoManager = new UndoManager(rootElement);
+  }
+
+  nsRefPtr undoManager = mUndoManager;
+  return undoManager.forget();
+}
+
 /* Return true if the document is in the focused top-level window, and is an
  * ancestor of the focused DOMWindow. */
 NS_IMETHODIMP
diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h
index da169c38f805..adbd2a66bd11 100644
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -94,6 +94,12 @@ class nsDOMNavigationTiming;
 class nsWindowSizes;
 class nsHtml5TreeOpExecutor;
 
+namespace mozilla {
+namespace dom {
+class UndoManager;
+}
+}
+
 /**
  * Right now our identifier map entries contain information for 'name'
  * and 'id' mappings of a given string. This is so that
@@ -569,6 +575,8 @@ public:
 
   virtual nsresult GetAllowPlugins(bool* aAllowPlugins);
 
+  virtual already_AddRefed GetUndoManager();
+
   virtual nsresult SetSubDocumentFor(Element* aContent,
                                      nsIDocument* aSubDoc);
   virtual nsIDocument* GetSubDocumentFor(nsIContent* aContent) const;
@@ -1349,6 +1357,8 @@ private:
   // Tracking for plugins in the document.
   nsTHashtable< nsPtrHashKey > mPlugins;
 
+  nsRefPtr mUndoManager;
+
 #ifdef DEBUG
 protected:
   bool mWillReparent;
diff --git a/content/base/src/nsGkAtomList.h b/content/base/src/nsGkAtomList.h
index 331db5274a7b..86833efdfb05 100644
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1090,6 +1090,7 @@ GK_ATOM(u, "u")
 GK_ATOM(ul, "ul")
 GK_ATOM(underflow, "underflow")
 GK_ATOM(undetermined, "undetermined")
+GK_ATOM(undoscope, "undoscope")
 GK_ATOM(unload, "unload")
 GK_ATOM(unparsedEntityUri, "unparsed-entity-uri")
 GK_ATOM(upperFirst, "upper-first")
diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp
index 17dc6bd757ab..0aa702cc196f 100644
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -881,6 +881,8 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
     return NS_NewDOMBeforeUnloadEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("pagetransition"))
     return NS_NewDOMPageTransitionEvent(aDOMEvent, aPresContext, nullptr);
+  if (aEventType.LowerCaseEqualsLiteral("domtransaction"))
+    return NS_NewDOMDOMTransactionEvent(aDOMEvent, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("scrollareaevent"))
     return NS_NewDOMScrollAreaEvent(aDOMEvent, aPresContext, nullptr);
   // FIXME: Should get spec to say what the right string is here!  This
diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in
index 44823a99ee08..6b1dd51f6d48 100644
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -45,7 +45,9 @@ EXPORTS_mozilla/dom = \
 		HTMLSharedListElement.h \
 		HTMLSpanElement.h \
 		HTMLTitleElement.h \
-		HTMLUnknownElement.h
+		HTMLUnknownElement.h \
+		UndoManager.h \
+		$(NULL)
 
 CPPSRCS		= \
 		HTMLPropertiesCollection.cpp \
@@ -111,6 +113,7 @@ CPPSRCS		= \
 		nsIConstraintValidation.cpp \
 		nsRadioVisitor.cpp \
 		nsDOMStringMap.cpp \
+		UndoManager.cpp \
 		$(NULL)
 
 ifdef MOZ_MEDIA
diff --git a/content/html/content/src/UndoManager.cpp b/content/html/content/src/UndoManager.cpp
new file mode 100644
index 000000000000..dbeb514fa803
--- /dev/null
+++ b/content/html/content/src/UndoManager.cpp
@@ -0,0 +1,1214 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/dom/UndoManager.h"
+
+#include "nsDOMClassInfoID.h"
+#include "nsIClassInfo.h"
+#include "nsIXPCScriptable.h"
+#include "nsIVariant.h"
+#include "nsVariant.h"
+#include "nsINode.h"
+#include "nsIDOMDOMTransactionEvent.h"
+#include "nsEventDispatcher.h"
+#include "nsContentUtils.h"
+#include "jsapi.h"
+
+#include "mozilla/Preferences.h"
+#include "mozilla/ErrorResult.h"
+
+#include "nsIUndoManagerTransaction.h"
+
+// Includes for mutation observer.
+#include "nsIDOMHTMLElement.h"
+#include "nsStubMutationObserver.h"
+#include "nsAutoPtr.h"
+#include "nsTransactionManager.h"
+
+// Includes for attribute changed transaction.
+#include "nsITransaction.h"
+#include "nsIContent.h"
+#include "nsIDOMMutationEvent.h"
+#include "mozilla/dom/Element.h"
+
+// Includes for text content changed.
+#include "nsTextFragment.h"
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+/////////////////////////////////////////////////
+// UndoTxn
+/////////////////////////////////////////////////
+
+/**
+ * A base class to implement methods that behave the same for all
+ * UndoManager transactions.
+ */
+class UndoTxn : public nsITransaction {
+  NS_DECL_NSITRANSACTION
+protected:
+  virtual ~UndoTxn() {}
+};
+
+/* void doTransaction (); */
+NS_IMETHODIMP
+UndoTxn::DoTransaction()
+{
+  // Do not do anything the first time we apply this transaction,
+  // changes should already have been applied.
+  return NS_OK;
+}
+
+/* void doTransaction (); */
+NS_IMETHODIMP
+UndoTxn::RedoTransaction()
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void doTransaction (); */
+NS_IMETHODIMP
+UndoTxn::UndoTransaction()
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute boolean isTransient; */
+NS_IMETHODIMP
+UndoTxn::GetIsTransient(bool* aIsTransient)
+{
+  *aIsTransient = false;
+  return NS_OK;
+}
+
+/* boolean merge (in nsITransaction aTransaction); */
+NS_IMETHODIMP
+UndoTxn::Merge(nsITransaction* aTransaction, bool* aResult)
+{
+  *aResult = false;
+  return NS_OK;
+}
+
+/////////////////////////////////////////////////
+// UndoAttrChanged
+/////////////////////////////////////////////////
+
+/**
+ * Transaction to handle an attribute change to a nsIContent.
+ */
+class UndoAttrChanged : public UndoTxn {
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(UndoAttrChanged)
+  NS_IMETHOD RedoTransaction();
+  NS_IMETHOD UndoTransaction();
+  nsresult Init();
+  UndoAttrChanged(mozilla::dom::Element* aElement, int32_t aNameSpaceID,
+                  nsIAtom* aAttribute, int32_t aModType);
+protected:
+  nsresult SaveRedoState();
+  nsCOMPtr mElement;
+  int32_t mNameSpaceID;
+  nsCOMPtr mAttrAtom;
+  int32_t mModType;
+  nsString mRedoValue;
+  nsString mUndoValue;
+};
+
+NS_IMPL_CYCLE_COLLECTION_2(UndoAttrChanged, mElement, mAttrAtom)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UndoAttrChanged)
+  NS_INTERFACE_MAP_ENTRY(nsITransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(UndoAttrChanged)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(UndoAttrChanged)
+
+UndoAttrChanged::UndoAttrChanged(mozilla::dom::Element* aElement,
+                                 int32_t aNameSpaceID, nsIAtom* aAttribute,
+                                 int32_t aModType)
+  : mElement(aElement), mNameSpaceID(aNameSpaceID), mAttrAtom(aAttribute),
+    mModType(aModType) {}
+
+nsresult
+UndoAttrChanged::SaveRedoState()
+{
+   mElement->GetAttr(mNameSpaceID, mAttrAtom, mRedoValue);
+   return NS_OK;
+}
+
+nsresult
+UndoAttrChanged::Init()
+{
+  mElement->GetAttr(mNameSpaceID, mAttrAtom, mUndoValue);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+UndoAttrChanged::UndoTransaction()
+{
+  nsresult rv = SaveRedoState();
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  switch (mModType) {
+  case nsIDOMMutationEvent::MODIFICATION:
+    mElement->SetAttr(mNameSpaceID, mAttrAtom, mUndoValue, true);
+    return NS_OK;
+  case nsIDOMMutationEvent::ADDITION:
+    mElement->UnsetAttr(mNameSpaceID, mAttrAtom, true);
+    return NS_OK;
+  case nsIDOMMutationEvent::REMOVAL:
+    if (!mElement->HasAttr(mNameSpaceID, mAttrAtom)) {
+      mElement->SetAttr(mNameSpaceID, mAttrAtom, mUndoValue, true);
+    }
+    return NS_OK;
+  }
+
+  return NS_ERROR_UNEXPECTED;
+}
+
+NS_IMETHODIMP
+UndoAttrChanged::RedoTransaction()
+{
+  switch (mModType) {
+  case nsIDOMMutationEvent::MODIFICATION:
+    mElement->SetAttr(mNameSpaceID, mAttrAtom, mRedoValue, true);
+    return NS_OK;
+  case nsIDOMMutationEvent::ADDITION:
+    if (!mElement->HasAttr(mNameSpaceID, mAttrAtom)) {
+      mElement->SetAttr(mNameSpaceID, mAttrAtom, mRedoValue, true);
+    }
+    return NS_OK;
+  case nsIDOMMutationEvent::REMOVAL:
+    mElement->UnsetAttr(mNameSpaceID, mAttrAtom, true);
+    return NS_OK;
+  }
+
+  return NS_ERROR_UNEXPECTED;
+}
+
+/////////////////////////////////////////////////
+// UndoTextChanged
+/////////////////////////////////////////////////
+
+struct UndoCharacterChangedData {
+  bool mAppend;
+  uint32_t mChangeStart;
+  uint32_t mChangeEnd;
+  uint32_t mReplaceLength;
+  explicit UndoCharacterChangedData(CharacterDataChangeInfo* aChange)
+    : mAppend(aChange->mAppend), mChangeStart(aChange->mChangeStart),
+      mChangeEnd(aChange->mChangeEnd),
+      mReplaceLength(aChange->mReplaceLength) {}
+};
+
+/**
+ * Transaction to handle a text change to a nsIContent.
+ */
+class UndoTextChanged : public UndoTxn {
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(UndoTextChanged)
+  NS_IMETHOD RedoTransaction();
+  NS_IMETHOD UndoTransaction();
+  UndoTextChanged(nsIContent* aContent,
+                  CharacterDataChangeInfo* aChange);
+protected:
+  void SaveRedoState();
+  nsCOMPtr mContent;
+  UndoCharacterChangedData mChange;
+  nsString mRedoValue;
+  nsString mUndoValue;
+};
+
+NS_IMPL_CYCLE_COLLECTION_1(UndoTextChanged, mContent)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UndoTextChanged)
+  NS_INTERFACE_MAP_ENTRY(nsITransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(UndoTextChanged)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(UndoTextChanged)
+
+UndoTextChanged::UndoTextChanged(nsIContent* aContent,
+                                 CharacterDataChangeInfo* aChange)
+  : mContent(aContent), mChange(aChange)
+{
+  const nsTextFragment* text = mContent->GetText();
+  int32_t numReplaced = mChange.mChangeEnd - mChange.mChangeStart;
+  text->AppendTo(mUndoValue, mChange.mChangeStart, numReplaced);
+}
+
+nsresult
+UndoTextChanged::RedoTransaction()
+{
+  nsAutoString text;
+  mContent->AppendTextTo(text);
+
+  if (text.Length() < mChange.mChangeStart) {
+    return NS_OK;
+  }
+
+  if (mChange.mAppend) {
+    mContent->AppendText(mRedoValue.get(), mRedoValue.Length(), true);
+  } else {
+    int32_t numReplaced = mChange.mChangeEnd - mChange.mChangeStart;
+    text.Replace(mChange.mChangeStart, numReplaced, mRedoValue);
+    mContent->SetText(text, true);
+  }
+
+  return NS_OK;
+}
+
+nsresult
+UndoTextChanged::UndoTransaction()
+{
+  SaveRedoState();
+
+  nsAutoString text;
+  mContent->AppendTextTo(text);
+
+  if (text.Length() < mChange.mChangeStart) {
+    return NS_OK;
+  }
+
+  if (mChange.mAppend) {
+    text.Truncate(text.Length() - mRedoValue.Length());
+  } else {
+    text.Replace(mChange.mChangeStart, mRedoValue.Length(), mUndoValue);
+  }
+  mContent->SetText(text, true);
+
+  return NS_OK;
+}
+
+void
+UndoTextChanged::SaveRedoState()
+{
+  const nsTextFragment* text = mContent->GetText();
+  text->AppendTo(mRedoValue, mChange.mChangeStart, mChange.mReplaceLength);
+}
+
+/////////////////////////////////////////////////
+// UndoContentAppend
+/////////////////////////////////////////////////
+
+/**
+ * Transaction to handle appending content to a nsIContent.
+ */
+class UndoContentAppend : public UndoTxn {
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(UndoContentAppend)
+  nsresult Init(int32_t aFirstIndex);
+  NS_IMETHOD RedoTransaction();
+  NS_IMETHOD UndoTransaction();
+  UndoContentAppend(nsIContent* aContent);
+protected:
+  nsCOMPtr mContent;
+  nsCOMArray mChildren;
+};
+
+NS_IMPL_CYCLE_COLLECTION_2(UndoContentAppend, mContent, mChildren)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UndoContentAppend)
+  NS_INTERFACE_MAP_ENTRY(nsITransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(UndoContentAppend)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(UndoContentAppend)
+
+UndoContentAppend::UndoContentAppend(nsIContent* aContent)
+{
+  mContent = aContent;
+}
+
+nsresult
+UndoContentAppend::Init(int32_t aFirstIndex)
+{
+  for (uint32_t i = aFirstIndex; i < mContent->GetChildCount(); i++) {
+    NS_ENSURE_TRUE(mChildren.AppendObject(mContent->GetChildAt(i)),
+                   NS_ERROR_OUT_OF_MEMORY);
+  }
+
+  return NS_OK;
+}
+
+nsresult
+UndoContentAppend::RedoTransaction()
+{
+  for (int32_t i = 0; i < mChildren.Count(); i++) {
+    if (!mChildren[i]->GetParent()) {
+      mContent->AppendChildTo(mChildren[i], true);
+    }
+  }
+
+  return NS_OK;
+}
+
+nsresult
+UndoContentAppend::UndoTransaction()
+{
+  for (int32_t i = mChildren.Count() - 1; i >= 0; i--) {
+    if (mChildren[i]->GetParent() == mContent) {
+      ErrorResult error;
+      mContent->RemoveChild(*mChildren[i], error);
+    }
+  }
+
+  return NS_OK;
+}
+
+/////////////////////////////////////////////////
+// UndoContentInsert
+/////////////////////////////////////////////////
+
+/**
+ * Transaction to handle inserting content into a nsIContent.
+ */
+class UndoContentInsert : public UndoTxn {
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(UndoContentInsert)
+  NS_IMETHOD UndoTransaction();
+  NS_IMETHOD RedoTransaction();
+  UndoContentInsert(nsIContent* aContent, nsIContent* aChild,
+                    int32_t aInsertIndex);
+protected:
+  nsCOMPtr mContent;
+  nsCOMPtr mChild;
+  nsCOMPtr mNextNode;
+};
+
+NS_IMPL_CYCLE_COLLECTION_3(UndoContentInsert, mContent, mChild, mNextNode)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UndoContentInsert)
+  NS_INTERFACE_MAP_ENTRY(nsITransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(UndoContentInsert)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(UndoContentInsert)
+
+UndoContentInsert::UndoContentInsert(nsIContent* aContent,
+                                     nsIContent* aChild,
+                                     int32_t aInsertIndex)
+  : mContent(aContent), mChild(aChild)
+{
+  mNextNode = mContent->GetChildAt(aInsertIndex + 1);
+}
+
+nsresult
+UndoContentInsert::RedoTransaction()
+{
+  if (!mChild) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  // Check if node already has parent.
+  if (mChild->GetParent()) {
+    return NS_OK;
+  }
+
+  // Check to see if next sibling has same parent.
+  if (mNextNode && mNextNode->GetParent() != mContent) {
+    return NS_OK;
+  }
+
+  ErrorResult error;
+  mContent->InsertBefore(*mChild, mNextNode, error);
+  return NS_OK;
+}
+
+nsresult
+UndoContentInsert::UndoTransaction()
+{
+  if (!mChild) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  // Check if the parent is the same.
+  if (mChild->GetParent() != mContent) {
+    return NS_OK;
+  }
+
+  // Check of the parent of the next node is the same.
+  if (mNextNode && mNextNode->GetParent() != mContent) {
+    return NS_OK;
+  }
+
+  // Check that the next node has not changed.
+  if (mChild->GetNextSibling() != mNextNode) {
+    return NS_OK;
+  }
+
+  ErrorResult error;
+  mContent->RemoveChild(*mChild, error);
+  return NS_OK;
+}
+
+/////////////////////////////////////////////////
+// UndoContentRemove
+/////////////////////////////////////////////////
+
+/**
+ * Transaction to handle removing content from an nsIContent.
+ */
+class UndoContentRemove : public UndoTxn {
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(UndoContentRemove)
+  NS_IMETHOD UndoTransaction();
+  NS_IMETHOD RedoTransaction();
+  nsresult Init(int32_t aInsertIndex);
+  UndoContentRemove(nsIContent* aContent, nsIContent* aChild,
+                    int32_t aInsertIndex);
+protected:
+  nsCOMPtr mContent;
+  nsCOMPtr mChild;
+  nsCOMPtr mNextNode;
+};
+
+NS_IMPL_CYCLE_COLLECTION_3(UndoContentRemove, mContent, mChild, mNextNode)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UndoContentRemove)
+  NS_INTERFACE_MAP_ENTRY(nsITransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(UndoContentRemove)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(UndoContentRemove)
+
+nsresult
+UndoContentRemove::Init(int32_t aInsertIndex)
+{
+  return NS_OK;
+}
+
+UndoContentRemove::UndoContentRemove(nsIContent* aContent, nsIContent* aChild,
+                                     int32_t aInsertIndex)
+  : mContent(aContent), mChild(aChild)
+{
+  mNextNode = mContent->GetChildAt(aInsertIndex);
+}
+
+nsresult
+UndoContentRemove::UndoTransaction()
+{
+  if (!mChild) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  // Check if child has a parent.
+  if (mChild->GetParent()) {
+    return NS_OK;
+  }
+
+  // Make sure next sibling is still under same parent.
+  if (mNextNode && mNextNode->GetParent() != mContent) {
+    return NS_OK;
+  }
+
+  ErrorResult error;
+  mContent->InsertBefore(*mChild, mNextNode, error);
+  return NS_OK;
+}
+
+nsresult
+UndoContentRemove::RedoTransaction()
+{
+  if (!mChild) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
+  // Check that the parent has not changed.
+  if (mChild->GetParent() != mContent) {
+    return NS_OK;
+  }
+
+  // Check that the next node still has the same parent.
+  if (mNextNode && mNextNode->GetParent() != mContent) {
+    return NS_OK;
+  }
+
+  // Check that the next sibling has not changed.
+  if (mChild->GetNextSibling() != mNextNode) {
+    return NS_OK;
+  }
+
+  ErrorResult error;
+  mContent->RemoveChild(*mChild, error);
+  return NS_OK;
+}
+
+/////////////////////////////////////////////////
+// UndoMutationObserver
+/////////////////////////////////////////////////
+
+/**
+ * Watches for DOM mutations in a particular element and its
+ * descendants to create transactions that undo and redo
+ * the mutations. Each UndoMutationObserver corresponds
+ * to an undo scope.
+ */
+class UndoMutationObserver : public nsStubMutationObserver {
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTEWILLCHANGE
+  NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATAWILLCHANGE
+  NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
+  NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
+  NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
+  explicit UndoMutationObserver(nsITransactionManager* aTxnManager);
+
+protected:
+  /**
+   * Checks if |aContent| is within the undo scope of this
+   * UndoMutationObserver.
+   */
+  bool IsManagerForMutation(nsIContent* aContent);
+  virtual ~UndoMutationObserver() {}
+  nsITransactionManager* mTxnManager; // [RawPtr] UndoManager holds strong
+                                      // reference.
+};
+
+NS_IMPL_ISUPPORTS1(UndoMutationObserver, nsIMutationObserver)
+
+bool
+UndoMutationObserver::IsManagerForMutation(nsIContent* aContent)
+{
+  nsCOMPtr content = aContent;
+  nsRefPtr undoManager;
+
+  // Get the UndoManager of nearest ancestor with an UndoManager.
+  while (content && !undoManager) {
+    nsCOMPtr htmlElem = do_QueryInterface(content);
+    if (htmlElem) {
+      undoManager = htmlElem->GetUndoManager();
+    }
+
+    content = content->GetParent();
+  }
+
+  if (!undoManager) {
+    // Check against document UndoManager if we were unable to find an
+    // UndoManager in an ancestor element.
+    nsIDocument* doc = aContent->OwnerDoc();
+    NS_ENSURE_TRUE(doc, false);
+    undoManager = doc->GetUndoManager();
+  }
+
+  // Check if the nsITransactionManager is the same for both the
+  // mutation observer and the nsIContent.
+  return undoManager->GetTransactionManager() == mTxnManager;
+}
+
+UndoMutationObserver::UndoMutationObserver(nsITransactionManager* aTxnManager)
+  : mTxnManager(aTxnManager) {}
+
+void
+UndoMutationObserver::AttributeWillChange(nsIDocument* aDocument,
+                                          mozilla::dom::Element* aElement,
+                                          int32_t aNameSpaceID,
+                                          nsIAtom* aAttribute,
+                                          int32_t aModType)
+{
+  if (!IsManagerForMutation(aElement)) {
+    return;
+  }
+
+  nsRefPtr undoTxn = new UndoAttrChanged(aElement,
+                                                          aNameSpaceID,
+                                                          aAttribute,
+                                                          aModType);
+  if (NS_SUCCEEDED(undoTxn->Init())) {
+    mTxnManager->DoTransaction(undoTxn);
+  }
+}
+
+void
+UndoMutationObserver::CharacterDataWillChange(nsIDocument* aDocument,
+                                              nsIContent* aContent,
+                                              CharacterDataChangeInfo* aInfo)
+{
+  if (!IsManagerForMutation(aContent)) {
+    return;
+  }
+
+  nsRefPtr undoTxn = new UndoTextChanged(aContent, aInfo);
+  mTxnManager->DoTransaction(undoTxn);
+}
+
+void
+UndoMutationObserver::ContentAppended(nsIDocument* aDocument,
+                                      nsIContent* aContainer,
+                                      nsIContent* aFirstNewContent,
+                                      int32_t aNewIndexInContainer)
+{
+  if (!IsManagerForMutation(aContainer)) {
+    return;
+  }
+
+  nsRefPtr txn = new UndoContentAppend(aContainer);
+  if (NS_SUCCEEDED(txn->Init(aNewIndexInContainer))) {
+    mTxnManager->DoTransaction(txn);
+  }
+}
+
+void
+UndoMutationObserver::ContentInserted(nsIDocument* aDocument,
+                                      nsIContent* aContainer,
+                                      nsIContent* aChild,
+                                      int32_t aIndexInContainer)
+{
+  if (!IsManagerForMutation(aContainer)) {
+    return;
+  }
+
+  nsRefPtr txn = new UndoContentInsert(aContainer, aChild,
+                                                          aIndexInContainer);
+  mTxnManager->DoTransaction(txn);
+}
+
+void
+UndoMutationObserver::ContentRemoved(nsIDocument *aDocument,
+                                     nsIContent* aContainer,
+                                     nsIContent* aChild,
+                                     int32_t aIndexInContainer,
+                                     nsIContent* aPreviousSibling)
+{
+  if (!IsManagerForMutation(aContainer)) {
+    return;
+  }
+
+  nsRefPtr txn = new UndoContentRemove(aContainer, aChild,
+                                                          aIndexInContainer);
+  mTxnManager->DoTransaction(txn);
+}
+
+/////////////////////////////////////////////////
+// FunctionCallTxn
+/////////////////////////////////////////////////
+
+/**
+ * A transaction that calls members on the transaction
+ * object.
+ */
+class FunctionCallTxn : public UndoTxn {
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_CLASS(FunctionCallTxn)
+
+  // Flags
+  static const uint32_t CALL_ON_REDO = 1;
+  static const uint32_t CALL_ON_UNDO = 2;
+
+  NS_IMETHOD RedoTransaction();
+  NS_IMETHOD UndoTransaction();
+  FunctionCallTxn(nsIUndoManagerTransaction* aTransaction, uint32_t aFlags);
+protected:
+  /**
+   * Call a function member on the transaction object with the
+   * specified function name.
+   */
+  nsresult CallTransactionMember(const char* aFunctionName);
+  nsCOMPtr mTransaction;
+  uint32_t mFlags;
+};
+
+NS_IMPL_CYCLE_COLLECTION_1(FunctionCallTxn, mTransaction)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FunctionCallTxn)
+  NS_INTERFACE_MAP_ENTRY(nsITransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(FunctionCallTxn)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(FunctionCallTxn)
+
+FunctionCallTxn::FunctionCallTxn(nsIUndoManagerTransaction* aTransaction,
+                                 uint32_t aFlags)
+  : mTransaction(aTransaction), mFlags(aFlags) {}
+
+nsresult
+FunctionCallTxn::RedoTransaction()
+{
+  if (!(mFlags & CALL_ON_REDO)) {
+    return NS_OK;
+  }
+
+  mTransaction->Redo();
+
+  return NS_OK;
+}
+
+nsresult
+FunctionCallTxn::UndoTransaction()
+{
+  if (!(mFlags & CALL_ON_UNDO)) {
+    return NS_OK;
+  }
+
+  mTransaction->Undo();
+
+  return NS_OK;
+}
+
+/////////////////////////////////////////////////
+// TxnScopeGuard
+/////////////////////////////////////////////////
+namespace mozilla {
+namespace dom {
+
+class TxnScopeGuard {
+public:
+  explicit TxnScopeGuard(UndoManager* aUndoManager)
+    : mUndoManager(aUndoManager)
+  {
+    mUndoManager->mInTransaction = true;
+  }
+
+  ~TxnScopeGuard()
+  {
+    mUndoManager->mInTransaction = false;
+  }
+protected:
+  UndoManager* mUndoManager;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+/////////////////////////////////////////////////
+// UndoManager
+/////////////////////////////////////////////////
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(UndoManager, mTxnManager, mHostNode)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(UndoManager)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(UndoManager)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(UndoManager)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+UndoManager::UndoManager(nsIContent* aNode)
+  : mHostNode(aNode), mInTransaction(false), mIsDisconnected(false)
+{
+  SetIsDOMBinding();
+  mTxnManager = new nsTransactionManager();
+}
+
+UndoManager::~UndoManager() {}
+
+void
+UndoManager::Transact(JSContext* aCx, nsIUndoManagerTransaction& aTransaction,
+                      bool aMerge, ErrorResult& aRv)
+{
+  if (mIsDisconnected || mInTransaction) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+    return;
+  }
+
+  TxnScopeGuard guard(this);
+
+  // First try executing an automatic transaction.
+  AutomaticTransact(&aTransaction, aRv);
+
+  if (aRv.ErrorCode() == NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED) {
+    // If the automatic transaction didn't work due to the function being
+    // undefined, then try a manual transaction.
+    aRv = NS_OK;
+    ManualTransact(&aTransaction, aRv);
+  }
+
+  if (aRv.Failed()) {
+    return;
+  }
+
+  if (aMerge) {
+    nsresult rv = mTxnManager->BatchTopUndo();
+    if (NS_FAILED(rv)) {
+      aRv.Throw(rv);
+      return;
+    }
+  }
+
+  DispatchTransactionEvent(aCx, NS_LITERAL_STRING("DOMTransaction"), 0, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+}
+
+void
+UndoManager::AutomaticTransact(nsIUndoManagerTransaction* aTransaction,
+                               ErrorResult& aRv)
+{
+  nsCOMPtr mutationObserver =
+    new UndoMutationObserver(mTxnManager);
+
+  // Transaction to call the "undo" method after the automatic transaction
+  // has been undone.
+  nsRefPtr undoTxn = new FunctionCallTxn(aTransaction,
+      FunctionCallTxn::CALL_ON_UNDO);
+
+  // Transaction to call the "redo" method after the automatic transaction
+  // has been redone.
+  nsRefPtr redoTxn = new FunctionCallTxn(aTransaction,
+      FunctionCallTxn::CALL_ON_REDO);
+
+  mTxnManager->BeginBatch(aTransaction);
+  mTxnManager->DoTransaction(undoTxn);
+  mHostNode->AddMutationObserver(mutationObserver);
+
+  nsresult rv = aTransaction->ExecuteAutomatic();
+
+  mHostNode->RemoveMutationObserver(mutationObserver);
+  mTxnManager->DoTransaction(redoTxn);
+  mTxnManager->EndBatch(true);
+
+  if (NS_FAILED(rv)) {
+    mTxnManager->RemoveTopUndo();
+    aRv.Throw(rv);
+    return;
+  }
+}
+
+void
+UndoManager::ManualTransact(nsIUndoManagerTransaction* aTransaction,
+                            ErrorResult& aRv)
+{
+  nsRefPtr txn = new FunctionCallTxn(aTransaction,
+      FunctionCallTxn::CALL_ON_REDO | FunctionCallTxn::CALL_ON_UNDO);
+
+  nsresult rv = aTransaction->Execute();
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+
+  mTxnManager->BeginBatch(aTransaction);
+  mTxnManager->DoTransaction(txn);
+  mTxnManager->EndBatch(true);
+}
+
+uint32_t
+UndoManager::GetPosition(ErrorResult& aRv)
+{
+  int32_t numRedo;
+  nsresult rv = mTxnManager->GetNumberOfRedoItems(&numRedo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return 0;
+  }
+
+  MOZ_ASSERT(numRedo >= 0, "Number of redo items should not be negative");
+  return numRedo;
+}
+
+uint32_t
+UndoManager::GetLength(ErrorResult& aRv)
+{
+  int32_t numRedo;
+  nsresult rv = mTxnManager->GetNumberOfRedoItems(&numRedo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return 0;
+  }
+
+  int32_t numUndo;
+  rv = mTxnManager->GetNumberOfUndoItems(&numUndo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return 0;
+  }
+
+  return numRedo + numUndo;
+}
+
+void
+UndoManager::ItemInternal(uint32_t aIndex,
+                          nsTArray& aItems,
+                          ErrorResult& aRv)
+{
+  int32_t numRedo;
+  nsresult rv = mTxnManager->GetNumberOfRedoItems(&numRedo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+  MOZ_ASSERT(numRedo >= 0, "Number of redo items should not be negative");
+
+  int32_t numUndo;
+  rv = mTxnManager->GetNumberOfUndoItems(&numUndo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+  MOZ_ASSERT(numUndo >= 0, "Number of undo items should not be negative");
+
+  MOZ_ASSERT(aIndex < (uint32_t) numRedo + numUndo,
+             "Index should be within bounds.");
+
+  nsCOMPtr txnList;
+  int32_t listIndex = aIndex;
+  if (aIndex < (uint32_t) numRedo) {
+    // Index is an redo.
+    mTxnManager->GetRedoList(getter_AddRefs(txnList));
+  } else {
+    // Index is a undo.
+    mTxnManager->GetUndoList(getter_AddRefs(txnList));
+    // We need to adjust the index because the undo list indices will
+    // be in the reverse order.
+    listIndex = numRedo + numUndo - aIndex - 1;
+  }
+
+  // Obtain data from transaction list and convert to list of
+  // nsIUndoManagerTransaction.
+  nsISupports** listData;
+  uint32_t listDataLength;
+  rv = txnList->GetData(listIndex, &listDataLength, &listData);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+
+  for (uint32_t i = 0; i < listDataLength; i++) {
+    nsCOMPtr transaction =
+        do_QueryInterface(listData[i]);
+    MOZ_ASSERT(transaction,
+               "Only nsIUndoManagerTransaction should be stored as data.");
+    aItems.AppendElement(transaction);
+    NS_RELEASE(listData[i]);
+  }
+  NS_Free(listData);
+}
+
+void
+UndoManager::Item(uint32_t aIndex,
+                  Nullable>>& aItems,
+                  ErrorResult& aRv)
+{
+  int32_t numRedo;
+  nsresult rv = mTxnManager->GetNumberOfRedoItems(&numRedo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+  MOZ_ASSERT(numRedo >= 0, "Number of redo items should not be negative");
+
+  int32_t numUndo;
+  rv = mTxnManager->GetNumberOfUndoItems(&numUndo);
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+  MOZ_ASSERT(numUndo >= 0, "Number of undo items should not be negative");
+
+  if (aIndex >= (uint32_t) numRedo + numUndo) {
+    // If the index is out of bounds, then return null.
+    aItems.SetNull();
+    return;
+  }
+
+  nsTArray transactions;
+  ItemInternal(aIndex, transactions, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+
+  nsTArray>& items = aItems.SetValue();
+  for (uint32_t i = 0; i < transactions.Length(); i++) {
+    items.AppendElement(transactions[i]);
+  }
+}
+
+void
+UndoManager::Undo(JSContext* aCx, ErrorResult& aRv)
+{
+  if (mIsDisconnected || mInTransaction) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+    return;
+  }
+
+  uint32_t position = GetPosition(aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+
+  uint32_t length = GetLength(aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+
+  // Stop if there are no transactions left to undo.
+  if (position >= length) {
+    return;
+  }
+
+  TxnScopeGuard guard(this);
+
+  nsresult rv = mTxnManager->UndoTransaction();
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+
+  DispatchTransactionEvent(aCx, NS_LITERAL_STRING("undo"), position, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+}
+
+void
+UndoManager::Redo(JSContext* aCx, ErrorResult& aRv)
+{
+  if (mIsDisconnected || mInTransaction) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+    return;
+  }
+
+  uint32_t position = GetPosition(aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+
+  // Stop if there are no transactions left to redo.
+  if (position <= 0) {
+    return;
+  }
+
+  TxnScopeGuard guard(this);
+
+  nsresult rv = mTxnManager->RedoTransaction();
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+
+  DispatchTransactionEvent(aCx, NS_LITERAL_STRING("redo"), position - 1, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+}
+
+void
+UndoManager::DispatchTransactionEvent(JSContext* aCx, const nsAString& aType,
+                                      uint32_t aPreviousPosition,
+                                      ErrorResult& aRv)
+{
+  nsTArray items;
+  ItemInternal(aPreviousPosition, items, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+
+  nsIDocument* ownerDoc = mHostNode->OwnerDoc();
+  if (!ownerDoc) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return;
+  }
+
+  nsCOMPtr domDoc = do_QueryInterface(ownerDoc);
+  if (!domDoc) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
+    return;
+  }
+
+  nsCOMPtr event;
+  nsresult rv = domDoc->CreateEvent(NS_LITERAL_STRING("domtransaction"),
+                                    getter_AddRefs(event));
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+
+  nsCOMPtr transactions = new nsVariant();
+
+  // Unwrap the nsIUndoManagerTransactions into jsvals, then convert
+  // to nsIVariant then put into a nsIVariant array. Arrays in XPIDL suck.
+  JSObject* obj;
+  nsCOMArray keepAlive;
+  nsTArray transactionItems;
+  for (uint32_t i = 0; i < items.Length(); i++) {
+    nsCOMPtr wrappedJS = do_QueryInterface(items[i]);
+    MOZ_ASSERT(wrappedJS, "All transactions should be WrappedJS.");
+    wrappedJS->GetJSObject(&obj);
+    jsval txVal = JS::ObjectValue(*obj);
+    if (!JS_WrapValue(aCx, &txVal)) {
+      aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+      return;
+    }
+    nsCOMPtr txVariant;
+    rv = nsContentUtils::XPConnect()->JSToVariant(aCx, txVal,
+                                                  getter_AddRefs(txVariant));
+    if (NS_SUCCEEDED(rv)) {
+      keepAlive.AppendObject(txVariant);
+      transactionItems.AppendElement(txVariant.get());
+    }
+  }
+
+  transactions->SetAsArray(nsIDataType::VTYPE_INTERFACE_IS,
+                           &NS_GET_IID(nsIVariant),
+                           transactionItems.Length(),
+                           transactionItems.Elements());
+
+  nsCOMPtr ptEvent = do_QueryInterface(event);
+  if (ptEvent &&
+      NS_SUCCEEDED(ptEvent->InitDOMTransactionEvent(aType, true, false,
+                                                    transactions))) {
+    event->SetTrusted(true);
+    event->SetTarget(mHostNode);
+    nsEventDispatcher::DispatchDOMEvent(mHostNode, nullptr, event,
+                                        nullptr, nullptr);
+  }
+}
+
+void
+UndoManager::ClearUndo(ErrorResult& aRv)
+{
+  if (mIsDisconnected || mInTransaction) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+    return;
+  }
+
+  nsresult rv = mTxnManager->ClearUndoStack();
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+}
+
+void
+UndoManager::ClearRedo(ErrorResult& aRv)
+{
+  if (mIsDisconnected || mInTransaction) {
+    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
+    return;
+  }
+
+  nsresult rv = mTxnManager->ClearRedoStack();
+  if (NS_FAILED(rv)) {
+    aRv.Throw(rv);
+    return;
+  }
+}
+
+nsITransactionManager*
+UndoManager::GetTransactionManager()
+{
+  return mTxnManager;
+}
+
+void
+UndoManager::Disconnect()
+{
+  mIsDisconnected = true;
+}
+
+bool
+UndoManager::PrefEnabled()
+{
+  static bool sPrefValue = Preferences::GetBool("dom.undo_manager.enabled", false);
+  return sPrefValue;
+}
+
diff --git a/content/html/content/src/UndoManager.h b/content/html/content/src/UndoManager.h
new file mode 100644
index 000000000000..609b389c34cc
--- /dev/null
+++ b/content/html/content/src/UndoManager.h
@@ -0,0 +1,104 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_UndoManager_h
+#define mozilla_dom_UndoManager_h
+
+#include "mozilla/dom/UndoManagerBinding.h"
+
+#include "nsCycleCollectionParticipant.h"
+#include "nsCOMPtr.h"
+#include "nsCOMArray.h"
+#include "nsTArray.h"
+#include "nsWrapperCache.h"
+#include "mozilla/dom/Nullable.h"
+#include "nsIContent.h"
+
+class nsIUndoManagerTransaction;
+class nsITransactionManager;
+class nsIMutationObserver;
+
+namespace mozilla {
+class ErrorResult;
+namespace dom {
+
+class UndoManager : public nsISupports,
+                    public nsWrapperCache
+{
+  friend class TxnScopeGuard;
+public:
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(UndoManager)
+
+  explicit UndoManager(nsIContent* aNode);
+
+  void Transact(JSContext* aCx, nsIUndoManagerTransaction& aTransaction,
+                bool aMerge, ErrorResult& aRv);
+  void Undo(JSContext* aCx, ErrorResult& aRv);
+  void Redo(JSContext* acx, ErrorResult& aRv);
+  void Item(uint32_t aIndex,
+            Nullable>>& aItems,
+            ErrorResult& aRv);
+  uint32_t GetLength(ErrorResult& aRv);
+  uint32_t GetPosition(ErrorResult& aRv);
+  void ClearUndo(ErrorResult& aRv);
+  void ClearRedo(ErrorResult& aRv);
+  static bool PrefEnabled();
+  void Disconnect();
+
+  nsISupports* GetParentObject() const
+  {
+    return mHostNode;
+  }
+
+  JSObject* WrapObject(JSContext* aCx, JSObject* aScope,
+                       bool* aTriedToWrap)
+  {
+    return mozilla::dom::UndoManagerBinding::Wrap(aCx, aScope, this,
+                                                  aTriedToWrap);
+  }
+
+  nsITransactionManager* GetTransactionManager();
+
+protected:
+  virtual ~UndoManager();
+  nsCOMPtr mTxnManager;
+  nsCOMPtr mHostNode;
+
+  /**
+   * Executes |aTransaction| as a manual transaction.
+   */
+  void ManualTransact(nsIUndoManagerTransaction* aTransaction,
+                      ErrorResult& aRv);
+
+  /**
+   * Executes |aTransaction| as an automatic transaction.
+   */
+  void AutomaticTransact(nsIUndoManagerTransaction* aTransaction,
+                         ErrorResult& aRv);
+
+  /**
+   * Appends the transactions in the undo transaction history at |aIndex|
+   * to the array |aItems|.
+   */
+  void ItemInternal(uint32_t aIndex,
+                    nsTArray& aItems,
+                    ErrorResult& aRv);
+
+  /**
+   * Dispatches an event to the undo scope host.
+   * @param aPreviousPosition The index of the transaction that
+   *                          triggered the event.
+   */
+  void DispatchTransactionEvent(JSContext* aCx, const nsAString& aType,
+                                uint32_t aPreviousPosition,
+                                ErrorResult& aRv);
+  bool mInTransaction;
+  bool mIsDisconnected;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif
diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp
index 68000750971e..559d8aea071a 100644
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -87,6 +87,7 @@
 #include "nsDOMMutationObserver.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/FromParser.h"
+#include "mozilla/dom/UndoManager.h"
 #include "mozilla/BloomFilter.h"
 
 #include "HTMLPropertiesCollection.h"
@@ -981,6 +982,8 @@ nsGenericHTMLElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
 {
   bool contentEditable = aNameSpaceID == kNameSpaceID_None &&
                            aName == nsGkAtoms::contenteditable;
+  bool undoScope = aNameSpaceID == kNameSpaceID_None &&
+                           aName == nsGkAtoms::undoscope;
   bool accessKey = aName == nsGkAtoms::accesskey && 
                      aNameSpaceID == kNameSpaceID_None;
 
@@ -1006,6 +1009,11 @@ nsGenericHTMLElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
     ChangeEditableState(change);
   }
 
+  if (undoScope) {
+    rv = SetUndoScopeInternal(true);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
   if (accessKey && !aValue.IsEmpty()) {
     SetFlags(NODE_HAS_ACCESSKEY);
     RegAccessKey();
@@ -1032,6 +1040,10 @@ nsGenericHTMLElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
       contentEditable = true;
       contentEditableChange = GetContentEditableValue() == eTrue ? -1 : 0;
     }
+    else if (aAttribute == nsGkAtoms::undoscope) {
+      nsresult rv = SetUndoScopeInternal(false);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
     else if (aAttribute == nsGkAtoms::accesskey) {
       // Have to unregister before clearing flag. See UnregAccessKey
       UnregAccessKey();
@@ -2065,6 +2077,78 @@ nsGenericHTMLElement::IsLabelable() const
          Tag() == nsGkAtoms::meter;
 }
 
+already_AddRefed
+nsGenericHTMLElement::GetUndoManager()
+{
+  nsDOMSlots* slots = GetExistingDOMSlots();
+  if (slots && slots->mUndoManager) {
+    nsRefPtr undoManager = slots->mUndoManager;
+    return undoManager.forget();
+  } else {
+    return nullptr;
+  }
+}
+
+bool
+nsGenericHTMLElement::UndoScope()
+{
+  nsDOMSlots* slots = GetExistingDOMSlots();
+  return slots && slots->mUndoManager;
+}
+
+void
+nsGenericHTMLElement::SetUndoScope(bool aUndoScope, mozilla::ErrorResult& aError)
+{
+  nsresult rv = SetUndoScopeInternal(aUndoScope);
+  if (NS_FAILED(rv)) {
+    aError.Throw(rv);
+    return;
+  }
+
+  // The undoScope property must reflect the undoscope boolean attribute.
+  if (aUndoScope) {
+    rv = SetAttr(kNameSpaceID_None, nsGkAtoms::undoscope,
+                 NS_LITERAL_STRING(""), true);
+  } else {
+    rv = UnsetAttr(kNameSpaceID_None, nsGkAtoms::undoscope, true);
+  }
+
+  if (NS_FAILED(rv)) {
+    aError.Throw(rv);
+    return;
+  }
+}
+
+nsresult
+nsGenericHTMLElement::SetUndoScopeInternal(bool aUndoScope)
+{
+  if (aUndoScope) {
+    nsDOMSlots* slots = DOMSlots();
+    if (!slots->mUndoManager) {
+      slots->mUndoManager = new UndoManager(this);
+    }
+  } else {
+    nsDOMSlots* slots = GetExistingDOMSlots();
+    if (slots && slots->mUndoManager) {
+      // Clear transaction history and disconnect.
+      ErrorResult rv;
+      slots->mUndoManager->ClearRedo(rv);
+      if (rv.Failed()) {
+        return rv.ErrorCode();
+      }
+
+      slots->mUndoManager->ClearUndo(rv);
+      if (rv.Failed()) {
+        return rv.ErrorCode();
+      }
+
+      slots->mUndoManager->Disconnect();
+      slots->mUndoManager = nullptr;
+    }
+  }
+  return NS_OK;
+}
+
 // static
 bool
 nsGenericHTMLElement::PrefEnabled()
diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h
index 4fe39610391b..bb6f83268597 100644
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -323,6 +323,9 @@ protected:
   nsresult SetTokenList(nsIAtom* aAtom, nsIVariant* aValue);
 public:
   nsresult SetContentEditable(const nsAString &aContentEditable);
+  virtual already_AddRefed GetUndoManager();
+  virtual bool UndoScope();
+  virtual void SetUndoScope(bool aUndoScope, mozilla::ErrorResult& aError);
   nsresult GetDataset(nsISupports** aDataset);
   // Callback for destructor of of dataset to ensure to null out weak pointer.
   nsresult ClearDataset();
@@ -1022,6 +1025,8 @@ protected:
    */
   bool IsEditableRoot() const;
 
+  nsresult SetUndoScopeInternal(bool aUndoScope);
+
 private:
   void ChangeEditableState(int32_t aChange);
 };
diff --git a/content/html/content/test/Makefile.in b/content/html/content/test/Makefile.in
index c7c421f3f6be..a22e35fdb7a3 100644
--- a/content/html/content/test/Makefile.in
+++ b/content/html/content/test/Makefile.in
@@ -242,6 +242,7 @@ MOCHITEST_FILES = \
 		test_bug677463.html \
 		test_bug682886.html \
 		test_bug717819.html \
+		test_undoManager.html \
 		file_fullscreen-utils.js \
 		file_fullscreen-api.html \
 		file_fullscreen-api-keys.html \
diff --git a/content/html/content/test/test_undoManager.html b/content/html/content/test/test_undoManager.html
new file mode 100644
index 000000000000..4c5f3b00427e
--- /dev/null
+++ b/content/html/content/test/test_undoManager.html
@@ -0,0 +1,852 @@
+
+
+
+
+  Test for Bug 617532
+  
+  
+  
+
+
+Mozilla Bug 617532
+

+
+
+
+
+ + diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 2fe110771dea..ecfc1c3feb4d 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -293,6 +293,16 @@ DOMInterfaces = { 'workers': True, }, +'DOMTransaction': [ +{ + 'nativeType': 'nsIUndoManagerTransaction', +}], + +'UndoManager': [ +{ + 'implicitJSContext' : [ 'undo', 'redo', 'transact' ] +}], + 'FormData': [ { 'nativeType': 'nsFormData' diff --git a/dom/interfaces/events/Makefile.in b/dom/interfaces/events/Makefile.in index 232af1e077bf..950096a984c7 100644 --- a/dom/interfaces/events/Makefile.in +++ b/dom/interfaces/events/Makefile.in @@ -31,6 +31,7 @@ XPIDLSRCS = \ nsIDOMMutationEvent.idl \ nsIDOMDragEvent.idl \ nsIDOMDataTransfer.idl \ + nsIDOMDOMTransactionEvent.idl \ nsIDOMPopupBlockedEvent.idl \ nsIDOMBeforeUnloadEvent.idl \ nsIDOMSmartCardEvent.idl \ diff --git a/dom/interfaces/events/nsIDOMDOMTransactionEvent.idl b/dom/interfaces/events/nsIDOMDOMTransactionEvent.idl new file mode 100644 index 000000000000..4d390252b334 --- /dev/null +++ b/dom/interfaces/events/nsIDOMDOMTransactionEvent.idl @@ -0,0 +1,25 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsIDOMEvent.idl" + +interface nsIVariant; + +[scriptable, builtinclass, uuid(f57f7c46-d420-4f32-a61b-0eb585d30ee1)] +interface nsIDOMDOMTransactionEvent : nsIDOMEvent +{ + readonly attribute nsIVariant transactions; + + void initDOMTransactionEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean canCancelArg, + in nsIVariant transactions); +}; + +dictionary DOMTransactionEventInit : EventInit +{ + nsIVariant transactions; +}; + diff --git a/dom/interfaces/html/Makefile.in b/dom/interfaces/html/Makefile.in index 2a5355a50e5e..3cbf57e42c69 100644 --- a/dom/interfaces/html/Makefile.in +++ b/dom/interfaces/html/Makefile.in @@ -84,6 +84,7 @@ SDK_XPIDLSRCS = \ nsIDOMHTMLVideoElement.idl \ nsIDOMHTMLAudioElement.idl \ nsIDOMValidityState.idl \ + nsIUndoManagerTransaction.idl \ nsIDOMMozBrowserFrame.idl \ $(NULL) diff --git a/dom/interfaces/html/nsIUndoManagerTransaction.idl b/dom/interfaces/html/nsIUndoManagerTransaction.idl new file mode 100644 index 000000000000..dc3da8716af3 --- /dev/null +++ b/dom/interfaces/html/nsIUndoManagerTransaction.idl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsISupports.idl" + +[scriptable, uuid(3802f155-e0f5-49ba-9972-e1aadcf2fdf0)] +interface nsIUndoManagerTransaction : nsISupports +{ + attribute DOMString label; + void executeAutomatic(); + void execute(); + void undo(); + void redo(); +}; + diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index bb627a95fa72..c06a9689a37e 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -513,6 +513,8 @@ var interfaceNamesInGlobalScope = "CameraManager", "CSSSupportsRule", "MozMobileCellInfo", + "UndoManager", + "DOMTransactionEvent", "MozCanvasPrintState", "TCPSocket", "MozTimeManager", diff --git a/dom/webidl/DOMTransaction.webidl b/dom/webidl/DOMTransaction.webidl new file mode 100644 index 000000000000..5378ad610f0e --- /dev/null +++ b/dom/webidl/DOMTransaction.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +callback interface DOMTransaction { + attribute DOMString label; + void executeAutomatic(); + void execute(); + void undo(); + void redo(); +}; + diff --git a/dom/webidl/Document.webidl b/dom/webidl/Document.webidl index b2641d49c12e..973a52d3d5b9 100644 --- a/dom/webidl/Document.webidl +++ b/dom/webidl/Document.webidl @@ -377,7 +377,16 @@ partial interface Document { */ Element? elementFromPoint (float x, float y); //(Not implemented)CaretPosition? caretPositionFromPoint (float x, float y); -/*}; +/* +}; + +http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html +partial interface Document { +*/ + [Pref="dom.undo_manager.enabled"] + readonly attribute UndoManager? undoManager; +/* +}; http://dev.w3.org/2006/webapi/selectors-api2/#interface-definitions partial interface Document { diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 9b4db0c27dac..b0f6cf21f6f5 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -169,6 +169,16 @@ partial interface Element { /* }; +// http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html +partial interface Element { +*/ + [Pref="dom.undo_manager.enabled"] + readonly attribute UndoManager? undoManager; + [SetterThrows,Pref="dom.undo_manager.enabled"] + attribute boolean undoScope; +/* +}; + // http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface partial interface Element { */ diff --git a/dom/webidl/UndoManager.webidl b/dom/webidl/UndoManager.webidl new file mode 100644 index 000000000000..405322f12f8e --- /dev/null +++ b/dom/webidl/UndoManager.webidl @@ -0,0 +1,26 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface DOMTransaction; + +[PrefControlled] +interface UndoManager { + [Throws] void transact(DOMTransaction transaction, boolean merge); + [Throws] void undo(); + [Throws] void redo(); + [Throws] sequence? item(unsigned long index); + [Throws] readonly attribute unsigned long length; + [Throws] readonly attribute unsigned long position; + [Throws] void clearUndo(); + [Throws] void clearRedo(); +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 67c4cd1441a3..05ef83eee284 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -38,6 +38,7 @@ webidl_files = \ DOMSettableTokenList.webidl \ DOMStringMap.webidl \ DOMTokenList.webidl \ + DOMTransaction.webidl \ DynamicsCompressorNode.webidl \ Element.webidl \ EventHandler.webidl \ @@ -111,6 +112,7 @@ webidl_files = \ TextEncoder.webidl \ URL.webidl \ WebSocket.webidl \ + UndoManager.webidl \ XMLHttpRequest.webidl \ XMLHttpRequestEventTarget.webidl \ XMLHttpRequestUpload.webidl \ diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index b2464cc8ecad..d108a3602372 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -869,7 +869,7 @@ nsEditor::BeginTransaction() BeginUpdateViewBatch(); if (mTxnMgr) { - mTxnMgr->BeginBatch(); + mTxnMgr->BeginBatch(nullptr); } return NS_OK; @@ -879,7 +879,7 @@ NS_IMETHODIMP nsEditor::EndTransaction() { if (mTxnMgr) { - mTxnMgr->EndBatch(); + mTxnMgr->EndBatch(false); } EndUpdateViewBatch(); diff --git a/editor/libeditor/text/tests/test_bug471319.html b/editor/libeditor/text/tests/test_bug471319.html index 0811a7055986..d2a8cb885f75 100644 --- a/editor/libeditor/text/tests/test_bug471319.html +++ b/editor/libeditor/text/tests/test_bug471319.html @@ -55,10 +55,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=471319 // Test 3: Undoing a batched transaction where both end points of the // transaction are the bogus node - the bogus node should still be // recognized as bogus - t1Editor.transactionManager.beginBatch(); + t1Editor.transactionManager.beginBatch(null); t1.value = "mozilla"; t1.value = ""; - t1Editor.transactionManager.endBatch(); + t1Editor.transactionManager.endBatch(false); t1Editor.undo(1); ok(!t1.value, "recreated
from undo transaction recognized as bogus"); diff --git a/editor/txmgr/idl/nsITransactionList.idl b/editor/txmgr/idl/nsITransactionList.idl index dc1a2d8670e7..de6d191de0b4 100644 --- a/editor/txmgr/idl/nsITransactionList.idl +++ b/editor/txmgr/idl/nsITransactionList.idl @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsISupports.idl" + interface nsITransaction; /* @@ -14,7 +15,7 @@ interface nsITransaction; * Undo or Redo stacks as well as any auto-aggregated children that a * transaction may have. */ -[scriptable, uuid(97f863f3-f886-11d4-9d39-0060b0f8baff)] +[scriptable, uuid(d007ceff-c978-486a-b697-384ca01997be)] interface nsITransactionList : nsISupports { @@ -43,6 +44,13 @@ interface nsITransactionList : nsISupports */ nsITransaction getItem(in long aIndex); + /** + * getData() returns the data (of type nsISupports array) associated with + * the transaction list. + */ + void getData(in long aIndex, [optional] out unsigned long aLength, + [array, size_is(aLength), retval] out nsISupports aData); + /** * getNumChildrenForItem() returns the number of child (auto-aggreated) * transactions the item at aIndex has. diff --git a/editor/txmgr/idl/nsITransactionManager.idl b/editor/txmgr/idl/nsITransactionManager.idl index d7e9e8168363..0587d5ca1d58 100644 --- a/editor/txmgr/idl/nsITransactionManager.idl +++ b/editor/txmgr/idl/nsITransactionManager.idl @@ -20,7 +20,7 @@ * This interface is implemented by an object that wants to * manage/track transactions. */ -[scriptable, builtinclass, uuid(58e330c2-7b48-11d2-98b9-00805f297d89)] +[scriptable, builtinclass, uuid(c77763df-0fb9-41a8-8074-8e882f605755)] interface nsITransactionManager : nsISupports { /** @@ -51,19 +51,34 @@ interface nsITransactionManager : nsISupports */ void clear(); + /** + * Clears the undo stack only. + */ + void clearUndoStack(); + + /** + * Clears the redo stack only. + */ + void clearRedoStack(); + /** * Turns on the transaction manager's batch mode, forcing all transactions * executed by the transaction manager's doTransaction() method to be * aggregated together until EndBatch() is called. This mode allows an * application to execute and group together several independent transactions * so they can be undone with a single call to undoTransaction(). + * @param aData An arbitrary nsISupports object that is associated with the + * batch. Can be retrieved from nsITransactionList. */ - void beginBatch(); + void beginBatch(in nsISupports aData); /** * Turns off the transaction manager's batch mode. + * @param aAllowEmpty If true, a batch containing no children will be + * pushed onto the undo stack. Otherwise, ending a batch with no + * children will result in no transactions being pushed on the undo stack. */ - void endBatch(); + void endBatch(in boolean aAllowEmpty); /** * The number of items on the undo stack. @@ -90,6 +105,19 @@ interface nsITransactionManager : nsISupports */ attribute long maxTransactionCount; + /** + * Combines the transaction at the top of the undo stack (if any) with the + * preceding undo transaction (if any) into a batch transaction. Thus, + * a call to undoTransaction() will undo both transactions. + */ + void batchTopUndo(); + + /** + * Removes the transaction at the top of the undo stack (if any) without + * transacting. + */ + void removeTopUndo(); + /** * Returns an AddRef'd pointer to the transaction at the top of the * undo stack. Callers should be aware that this method could return diff --git a/editor/txmgr/src/nsTransactionItem.cpp b/editor/txmgr/src/nsTransactionItem.cpp index ed506f29b443..3ef6bf0c4348 100644 --- a/editor/txmgr/src/nsTransactionItem.cpp +++ b/editor/txmgr/src/nsTransactionItem.cpp @@ -32,6 +32,7 @@ NS_IMPL_CYCLE_COLLECTING_NATIVE_RELEASE(nsTransactionItem) NS_IMPL_CYCLE_COLLECTION_NATIVE_CLASS(nsTransactionItem) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTransactionItem) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mData) NS_IMPL_CYCLE_COLLECTION_UNLINK(mTransaction) if (tmp->mRedoStack) { tmp->mRedoStack->DoUnlink(); @@ -42,6 +43,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTransactionItem) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTransactionItem) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mData) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTransaction) if (tmp->mRedoStack) { tmp->mRedoStack->DoTraverse(cb); diff --git a/editor/txmgr/src/nsTransactionItem.h b/editor/txmgr/src/nsTransactionItem.h index 2b619d594d4f..921cc6911148 100644 --- a/editor/txmgr/src/nsTransactionItem.h +++ b/editor/txmgr/src/nsTransactionItem.h @@ -7,6 +7,7 @@ #define nsTransactionItem_h__ #include "nsCOMPtr.h" +#include "nsCOMArray.h" #include "nsCycleCollectionParticipant.h" #include "nsISupportsImpl.h" #include "nscore.h" @@ -17,6 +18,7 @@ class nsTransactionStack; class nsTransactionItem { + nsCOMArray mData; nsCOMPtr mTransaction; nsTransactionStack *mUndoStack; nsTransactionStack *mRedoStack; @@ -40,6 +42,11 @@ public: virtual nsresult UndoTransaction(nsTransactionManager *aTxMgr); virtual nsresult RedoTransaction(nsTransactionManager *aTxMgr); + nsCOMArray& GetData() + { + return mData; + } + private: virtual nsresult UndoChildren(nsTransactionManager *aTxMgr); diff --git a/editor/txmgr/src/nsTransactionList.cpp b/editor/txmgr/src/nsTransactionList.cpp index 5eabc492290b..de2a585adfba 100644 --- a/editor/txmgr/src/nsTransactionList.cpp +++ b/editor/txmgr/src/nsTransactionList.cpp @@ -87,6 +87,42 @@ NS_IMETHODIMP nsTransactionList::ItemIsBatch(int32_t aIndex, bool *aIsBatch) return item->GetIsBatch(aIsBatch); } +/* void getData (in long aIndex, + [optional] out unsigned long aLength, + [array, size_is (aLength), retval] + out nsISupports aData); */ +NS_IMETHODIMP nsTransactionList::GetData(int32_t aIndex, + uint32_t *aLength, + nsISupports ***aData) +{ + nsCOMPtr txMgr = do_QueryReferent(mTxnMgr); + + NS_ENSURE_TRUE(txMgr, NS_ERROR_FAILURE); + + nsRefPtr item; + + if (mTxnStack) { + item = mTxnStack->GetItem(aIndex); + } else if (mTxnItem) { + nsresult result = mTxnItem->GetChild(aIndex, getter_AddRefs(item)); + NS_ENSURE_SUCCESS(result, result); + } + + nsCOMArray& data = item->GetData(); + + nsISupports** ret = static_cast(NS_Alloc(data.Count() * + sizeof(nsISupports*))); + + for (int32_t i = 0; i < data.Count(); i++) { + NS_ADDREF(ret[i] = data[i]); + } + + *aLength = data.Count(); + *aData = ret; + + return NS_OK; +} + /* nsITransaction getItem (in long aIndex); */ NS_IMETHODIMP nsTransactionList::GetItem(int32_t aIndex, nsITransaction **aItem) { diff --git a/editor/txmgr/src/nsTransactionManager.cpp b/editor/txmgr/src/nsTransactionManager.cpp index f6dc2521c1b2..39f93eaf4571 100644 --- a/editor/txmgr/src/nsTransactionManager.cpp +++ b/editor/txmgr/src/nsTransactionManager.cpp @@ -76,14 +76,14 @@ nsTransactionManager::DoTransaction(nsITransaction *aTransaction) return NS_OK; } - result = BeginTransaction(aTransaction); + result = BeginTransaction(aTransaction, nullptr); if (NS_FAILED(result)) { DidDoNotify(aTransaction, result); return result; } - result = EndTransaction(); + result = EndTransaction(false); nsresult result2 = DidDoNotify(aTransaction, result); @@ -216,7 +216,7 @@ nsTransactionManager::Clear() } NS_IMETHODIMP -nsTransactionManager::BeginBatch() +nsTransactionManager::BeginBatch(nsISupports* aData) { nsresult result; @@ -237,7 +237,7 @@ nsTransactionManager::BeginBatch() return NS_OK; } - result = BeginTransaction(0); + result = BeginTransaction(0, aData); nsresult result2 = DidBeginBatchNotify(result); @@ -248,7 +248,7 @@ nsTransactionManager::BeginBatch() } NS_IMETHODIMP -nsTransactionManager::EndBatch() +nsTransactionManager::EndBatch(bool aAllowEmpty) { nsCOMPtr ti; nsresult result; @@ -286,7 +286,7 @@ nsTransactionManager::EndBatch() return NS_OK; } - result = EndTransaction(); + result = EndTransaction(aAllowEmpty); nsresult result2 = DidEndBatchNotify(result); @@ -455,6 +455,50 @@ nsTransactionManager::GetRedoList(nsITransactionList **aTransactionList) return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; } +nsresult +nsTransactionManager::BatchTopUndo() +{ + if (mUndoStack.GetSize() < 2) { + // Not enough transactions to merge into one batch. + return NS_OK; + } + + nsRefPtr lastUndo; + nsRefPtr previousUndo; + + lastUndo = mUndoStack.Pop(); + MOZ_ASSERT(lastUndo, "There should be at least two transactions."); + + previousUndo = mUndoStack.Peek(); + MOZ_ASSERT(previousUndo, "There should be at least two transactions."); + + nsresult result = previousUndo->AddChild(lastUndo); + + // Transfer data from the transactions that is going to be + // merged to the transaction that it is being merged with. + nsCOMArray& lastData = lastUndo->GetData(); + nsCOMArray& previousData = previousUndo->GetData(); + NS_ENSURE_TRUE(previousData.AppendObjects(lastData), NS_ERROR_UNEXPECTED); + lastData.Clear(); + + return result; +} + +nsresult +nsTransactionManager::RemoveTopUndo() +{ + nsRefPtr lastUndo; + + lastUndo = mUndoStack.Peek(); + if (!lastUndo) { + return NS_OK; + } + + lastUndo = mUndoStack.Pop(); + + return NS_OK; +} + NS_IMETHODIMP nsTransactionManager::AddListener(nsITransactionListener *aListener) { @@ -471,14 +515,14 @@ nsTransactionManager::RemoveListener(nsITransactionListener *aListener) return mListeners.RemoveObject(aListener) ? NS_OK : NS_ERROR_FAILURE; } -nsresult +NS_IMETHODIMP nsTransactionManager::ClearUndoStack() { mUndoStack.Clear(); return NS_OK; } -nsresult +NS_IMETHODIMP nsTransactionManager::ClearRedoStack() { mRedoStack.Clear(); @@ -717,7 +761,8 @@ nsTransactionManager::DidMergeNotify(nsITransaction *aTop, } nsresult -nsTransactionManager::BeginTransaction(nsITransaction *aTransaction) +nsTransactionManager::BeginTransaction(nsITransaction *aTransaction, + nsISupports *aData) { nsresult result = NS_OK; @@ -725,6 +770,11 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction) // We could use a factory that pre-allocates/recycles transaction items. nsRefPtr tx = new nsTransactionItem(aTransaction); + if (aData) { + nsCOMArray& data = tx->GetData(); + data.AppendObject(aData); + } + if (!tx) { return NS_ERROR_OUT_OF_MEMORY; } @@ -742,7 +792,7 @@ nsTransactionManager::BeginTransaction(nsITransaction *aTransaction) } nsresult -nsTransactionManager::EndTransaction() +nsTransactionManager::EndTransaction(bool aAllowEmpty) { nsresult result = NS_OK; @@ -753,7 +803,7 @@ nsTransactionManager::EndTransaction() nsCOMPtr tint = tx->GetTransaction(); - if (!tint) { + if (!tint && !aAllowEmpty) { int32_t nc = 0; // If we get here, the transaction must be a dummy batch transaction diff --git a/editor/txmgr/src/nsTransactionManager.h b/editor/txmgr/src/nsTransactionManager.h index 8b800c955566..72486fa116ff 100644 --- a/editor/txmgr/src/nsTransactionManager.h +++ b/editor/txmgr/src/nsTransactionManager.h @@ -9,6 +9,7 @@ #include "nsCOMArray.h" #include "nsCOMPtr.h" #include "nsCycleCollectionParticipant.h" +#include "nsTransactionStack.h" #include "nsISupportsImpl.h" #include "nsITransactionManager.h" #include "nsTransactionStack.h" @@ -51,9 +52,6 @@ public: /* nsITransactionManager method implementations. */ NS_DECL_NSITRANSACTIONMANAGER - /* nsTransactionManager specific methods. */ - virtual nsresult ClearUndoStack(void); - virtual nsresult ClearRedoStack(void); already_AddRefed PeekUndoStack(); already_AddRefed PeekRedoStack(); @@ -78,8 +76,9 @@ public: private: /* nsTransactionManager specific private methods. */ - virtual nsresult BeginTransaction(nsITransaction *aTransaction); - virtual nsresult EndTransaction(void); + virtual nsresult BeginTransaction(nsITransaction *aTransaction, + nsISupports *aData); + virtual nsresult EndTransaction(bool aAllowEmpty); }; #endif // nsTransactionManager_h__ diff --git a/editor/txmgr/tests/TestTXMgr.cpp b/editor/txmgr/tests/TestTXMgr.cpp index ed0cb970bca4..a2980d41e1d9 100644 --- a/editor/txmgr/tests/TestTXMgr.cpp +++ b/editor/txmgr/tests/TestTXMgr.cpp @@ -613,7 +613,7 @@ public: return NS_OK; if (mFlags & BATCH_FLAG) { - result = mTXMgr->BeginBatch(); + result = mTXMgr->BeginBatch(nullptr); if (NS_FAILED(result)) { return result; } @@ -647,7 +647,7 @@ public: i, mLevel, result); if (mFlags & BATCH_FLAG) - mTXMgr->EndBatch(); + mTXMgr->EndBatch(false); return NS_ERROR_OUT_OF_MEMORY; } @@ -659,7 +659,7 @@ public: i, mLevel, result); if (mFlags & BATCH_FLAG) - mTXMgr->EndBatch(); + mTXMgr->EndBatch(false); return result; } @@ -672,7 +672,7 @@ public: tx->Release(); if (mFlags & BATCH_FLAG) - mTXMgr->EndBatch(); + mTXMgr->EndBatch(false); return result; } @@ -681,7 +681,7 @@ public: } if (mFlags & BATCH_FLAG) - mTXMgr->EndBatch(); + mTXMgr->EndBatch(false); return result; } @@ -2700,7 +2700,7 @@ quick_batch_test(TestTransactionFactory *factory) /******************************************************************* * - * Make sure an unbalanced call to EndBatch() with empty undo stack + * Make sure an unbalanced call to EndBatch(false) with empty undo stack * throws an error! * *******************************************************************/ @@ -2719,10 +2719,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (result != NS_ERROR_FAILURE) { - fail("EndBatch() returned unexpected status. (%d)\n", result); + fail("EndBatch(false) returned unexpected status. (%d)\n", result); return result; } @@ -2740,7 +2740,7 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - passed("Test unbalanced EndBatch() with empty undo stack"); + passed("Test unbalanced EndBatch(false) with empty undo stack"); /******************************************************************* * @@ -2763,10 +2763,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -2784,10 +2784,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -2818,10 +2818,10 @@ quick_batch_test(TestTransactionFactory *factory) * *******************************************************************/ - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -2864,10 +2864,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -2917,10 +2917,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -2949,10 +2949,10 @@ quick_batch_test(TestTransactionFactory *factory) tx->Release(); } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -3021,10 +3021,10 @@ quick_batch_test(TestTransactionFactory *factory) * *******************************************************************/ - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3064,10 +3064,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3107,10 +3107,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3150,24 +3150,24 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -3323,15 +3323,15 @@ quick_batch_test(TestTransactionFactory *factory) /******************************************************************* * - * Make sure an unbalanced call to EndBatch() throws an error and + * Make sure an unbalanced call to EndBatch(false) throws an error and * doesn't affect the undo and redo stacks! * *******************************************************************/ - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (result != NS_ERROR_FAILURE) { - fail("EndBatch() returned unexpected status. (%d)\n", result); + fail("EndBatch(false) returned unexpected status. (%d)\n", result); return result; } @@ -3363,7 +3363,7 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - passed("Test effect of unbalanced EndBatch() on undo and redo stacks"); + passed("Test effect of unbalanced EndBatch(false) on undo and redo stacks"); /******************************************************************* * @@ -3373,10 +3373,10 @@ quick_batch_test(TestTransactionFactory *factory) * *******************************************************************/ - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3408,10 +3408,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -3451,10 +3451,10 @@ quick_batch_test(TestTransactionFactory *factory) * *******************************************************************/ - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3511,10 +3511,10 @@ quick_batch_test(TestTransactionFactory *factory) return NS_ERROR_FAILURE; } - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -3636,10 +3636,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3652,10 +3652,10 @@ quick_batch_test(TestTransactionFactory *factory) tx->Release(); - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -3739,10 +3739,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3755,10 +3755,10 @@ quick_batch_test(TestTransactionFactory *factory) tx->Release(); - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -3870,10 +3870,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -3886,10 +3886,10 @@ quick_batch_test(TestTransactionFactory *factory) tx->Release(); - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -4082,10 +4082,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -4097,10 +4097,10 @@ quick_batch_test(TestTransactionFactory *factory) tx->Release(); - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } @@ -4167,10 +4167,10 @@ quick_batch_test(TestTransactionFactory *factory) return result; } - result = mgr->BeginBatch(); + result = mgr->BeginBatch(nullptr); if (NS_FAILED(result)) { - fail("BeginBatch() failed. (%d)\n", result); + fail("BeginBatch(nullptr) failed. (%d)\n", result); return result; } @@ -4182,10 +4182,10 @@ quick_batch_test(TestTransactionFactory *factory) tx->Release(); - result = mgr->EndBatch(); + result = mgr->EndBatch(false); if (NS_FAILED(result)) { - fail("EndBatch() failed. (%d)\n", result); + fail("EndBatch(false) failed. (%d)\n", result); return result; } diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in index 81d664ff825d..294d582cb57e 100644 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -15,6 +15,7 @@ simple_events = [ 'UserProximityEvent', 'CustomEvent', 'PageTransitionEvent', + 'DOMTransactionEvent', 'PopStateEvent', 'HashChangeEvent', 'CloseEvent', diff --git a/toolkit/components/places/tests/unit/test_placesTxn.js b/toolkit/components/places/tests/unit/test_placesTxn.js index 0467f6913f52..343514bddd15 100644 --- a/toolkit/components/places/tests/unit/test_placesTxn.js +++ b/toolkit/components/places/tests/unit/test_placesTxn.js @@ -119,8 +119,8 @@ add_test(function test_create_folder_with_description() { // This checks that calling undoTransaction on an "empty batch" doesn't // undo the previous transaction (getItemTitle will fail) - txnManager.beginBatch(); - txnManager.endBatch(); + txnManager.beginBatch(null); + txnManager.endBatch(false); txnManager.undoTransaction(); let folderId = observer._itemAddedId; From 2379c9e9a44f325154e6b5e9e70f1b6cedd9bcba Mon Sep 17 00:00:00 2001 From: Mihnea Dobrescu-Balaur Date: Fri, 4 Jan 2013 14:07:48 -0500 Subject: [PATCH 066/180] Bug 819482 - Remove retry code from b2g automation now that devicemanager handles it, r=ahal --- testing/marionette/client/marionette/emulator.py | 11 ++--------- testing/xpcshell/remotexpcshelltests.py | 11 ++--------- testing/xpcshell/runtestsb2g.py | 11 ++--------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/testing/marionette/client/marionette/emulator.py b/testing/marionette/client/marionette/emulator.py index 1ed10822e0f7..811a83b55d8a 100644 --- a/testing/marionette/client/marionette/emulator.py +++ b/testing/marionette/client/marionette/emulator.py @@ -429,16 +429,9 @@ waitFor( def install_busybox(self, busybox): self._run_adb(['remount']) - push_attempts = 10 remote_file = "/system/bin/busybox" - for retry in range(1, push_attempts+1): - print 'pushing', remote_file, '(attempt %s of %s)' % (retry, push_attempts) - try: - self.dm.pushFile(busybox, remote_file) - break - except DMError: - if retry == push_attempts: - raise + print 'pushing %s' % remote_file + self.dm.pushFile(busybox, remote_file, retryLimit=10) self._run_adb(['shell', 'cd /system/bin; chmod 555 busybox; for x in `./busybox --list`; do ln -s ./busybox $x; done']) self.dm._verifyZip() diff --git a/testing/xpcshell/remotexpcshelltests.py b/testing/xpcshell/remotexpcshelltests.py index 42285fa15246..157449045e45 100644 --- a/testing/xpcshell/remotexpcshelltests.py +++ b/testing/xpcshell/remotexpcshelltests.py @@ -151,15 +151,8 @@ class XPCShellRemote(xpcshell.XPCShellTests, object): self.device.pushDir(self.testingModulesDir, self.remoteModulesDir) def setupTestDir(self): - push_attempts = 10 - for retry in range(1, push_attempts+1): - print 'pushing', self.xpcDir, '(attempt %s of %s)' % (retry, push_attempts) - try: - self.device.pushDir(self.xpcDir, self.remoteScriptsDir) - break - except DMError: - if retry == push_attempts: - raise + print 'pushing %s' % self.xpcDir + self.device.pushDir(self.xpcDir, self.remoteScriptsDir, retryLimit=10) def buildTestList(self): xpcshell.XPCShellTests.buildTestList(self) diff --git a/testing/xpcshell/runtestsb2g.py b/testing/xpcshell/runtestsb2g.py index c7df0c97f300..60b12a9ac634 100644 --- a/testing/xpcshell/runtestsb2g.py +++ b/testing/xpcshell/runtestsb2g.py @@ -37,19 +37,12 @@ class B2GXPCShellRemote(XPCShellRemote): if self.device._useZip: return XPCShellRemote.setupTestDir(self) - push_attempts = 10 for root, dirs, files in os.walk(self.xpcDir): for filename in files: rel_path = os.path.relpath(os.path.join(root, filename), self.xpcDir) test_file = os.path.join(self.remoteScriptsDir, rel_path) - for retry in range(1, push_attempts+1): - print 'pushing', test_file, '(attempt %s of %s)' % (retry, push_attempts) - try: - self.device.pushFile(os.path.join(root, filename), test_file) - break - except DMError: - if retry == push_attempts: - raise + print 'pushing %s' % test_file + self.device.pushFile(os.path.join(root, filename), test_file, retryLimit=10) # Overridden def pushLibs(self): From 518f686d009a3f987a6c865639cd031e796a2f6a Mon Sep 17 00:00:00 2001 From: Wes Johnston Date: Fri, 4 Jan 2013 11:18:38 -0800 Subject: [PATCH 067/180] Bug 826074 - Use Pinning terminology for customizing about:home. r=mfinkle --- mobile/android/base/AboutHomeContent.java | 35 +++++++++++++++---- mobile/android/base/BrowserApp.java | 12 ++++--- .../base/locales/en-US/android_strings.dtd | 5 +-- .../menu/abouthome_topsites_contextmenu.xml | 11 +++--- mobile/android/base/strings.xml.in | 5 +-- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/mobile/android/base/AboutHomeContent.java b/mobile/android/base/AboutHomeContent.java index ebcfda660a3a..f28fb6a7dc09 100644 --- a/mobile/android/base/AboutHomeContent.java +++ b/mobile/android/base/AboutHomeContent.java @@ -203,13 +203,13 @@ public class AboutHomeContent extends ScrollView // If nothing is pinned at all, hide both clear items TopSitesCursorWrapper cursor = (TopSitesCursorWrapper)mTopSitesAdapter.getCursor(); if (!cursor.hasPinnedSites()) { - menu.findItem(R.id.abouthome_topsites_clearall).setVisible(false); - menu.findItem(R.id.abouthome_topsites_clear).setVisible(false); + menu.findItem(R.id.abouthome_topsites_unpinall).setVisible(false); + menu.findItem(R.id.abouthome_topsites_unpin).setVisible(false); } else { // If there's nothing pinned here, hide the clear item PinnedSite site = cursor.getPinnedSite(info.position); if (site == null) { - menu.findItem(R.id.abouthome_topsites_clear).setVisible(false); + menu.findItem(R.id.abouthome_topsites_unpin).setVisible(false); } } } @@ -916,7 +916,7 @@ public class AboutHomeContent extends ScrollView holder.thumbnailView.setScaleType(ImageView.ScaleType.FIT_CENTER); } - public void clearAllSites() { + public void unpinAllSites() { final ContentResolver resolver = mActivity.getContentResolver(); // Clear the view quickly to make things appear responsive @@ -941,7 +941,7 @@ public class AboutHomeContent extends ScrollView }).execute(); } - public void clearSite() { + public void unpinSite() { final int position = mTopSitesGrid.getSelectedPosition(); View v = mTopSitesGrid.getChildAt(position); TopSitesViewHolder holder = (TopSitesViewHolder) v.getTag(); @@ -963,9 +963,32 @@ public class AboutHomeContent extends ScrollView }).execute(); } + public void pinSite() { + final int position = mTopSitesGrid.getSelectedPosition(); + View v = mTopSitesGrid.getChildAt(position); + + TopSitesViewHolder holder = (TopSitesViewHolder) v.getTag(); + final String url = holder.url; + final String title = holder.titleView.getText().toString(); + // update the database on a background thread + (new GeckoAsyncTask(GeckoApp.mAppContext, GeckoAppShell.getHandler()) { + @Override + public Void doInBackground(Void... params) { + final ContentResolver resolver = mActivity.getContentResolver(); + BrowserDB.pinSite(resolver, url, (title == null || TextUtils.isEmpty(title) ? url : title), position); + return null; + } + + @Override + public void onPostExecute(Void v) { + update(EnumSet.of(UpdateFlags.TOP_SITES)); + } + }).execute(); + } + public void editSite() { int position = mTopSitesGrid.getSelectedPosition(); - View v = mTopSitesGrid.getChildAt(position); + View v = mTopSitesGrid.getChildAt(position); TopSitesViewHolder holder = (TopSitesViewHolder) v.getTag(); editSite(holder.url, position); diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index f426da13e8ee..6812a1b3f857 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -1038,12 +1038,16 @@ abstract public class BrowserApp extends GeckoApp mAboutHomeContent.editSite(); return true; - case R.id.abouthome_topsites_clear: - mAboutHomeContent.clearSite(); + case R.id.abouthome_topsites_unpin: + mAboutHomeContent.unpinSite(); return true; - case R.id.abouthome_topsites_clearall: - mAboutHomeContent.clearAllSites(); + case R.id.abouthome_topsites_unpinall: + mAboutHomeContent.unpinAllSites(); + return true; + + case R.id.abouthome_topsites_pin: + mAboutHomeContent.pinSite(); return true; } return super.onContextItemSelected(item); diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 9346b1ef767f..51df2c7193d9 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -202,8 +202,9 @@ size. --> - - + + + - + diff --git a/mobile/android/base/resources/menu/awesomebar_contextmenu.xml b/mobile/android/base/resources/menu/awesomebar_contextmenu.xml index c086aed7815e..5fcb9c7d65b8 100644 --- a/mobile/android/base/resources/menu/awesomebar_contextmenu.xml +++ b/mobile/android/base/resources/menu/awesomebar_contextmenu.xml @@ -8,8 +8,8 @@ - + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 232192850cca..5618d8a72938 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -161,7 +161,7 @@ &reader; &contextmenu_open_new_tab; - &contextmenu_open_new_private_tab; + &contextmenu_open_private_tab; &contextmenu_open_in_reader; &contextmenu_remove_history; &contextmenu_remove_bookmark; diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index d024264cb539..b7d2ae2bab65 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -328,7 +328,7 @@ var BrowserApp = { NativeWindow.toast.show(label, "short"); }); - NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.openInNewPrivateTab"), + NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.openInPrivateTab"), NativeWindow.contextmenus.linkOpenableContext, function(aTarget) { let url = NativeWindow.contextmenus._getLinkURL(aTarget); diff --git a/mobile/android/locales/en-US/chrome/browser.properties b/mobile/android/locales/en-US/chrome/browser.properties index 2fb954b7b9e0..1787d2c506de 100644 --- a/mobile/android/locales/en-US/chrome/browser.properties +++ b/mobile/android/locales/en-US/chrome/browser.properties @@ -215,7 +215,7 @@ selectionHelper.textCopied=Text copied to clipboard # Context menu contextmenu.openInNewTab=Open Link in New Tab -contextmenu.openInNewPrivateTab=Open Link in New Private Tab +contextmenu.openInPrivateTab=Open Link in Private Tab contextmenu.share=Share contextmenu.copyLink=Copy Link contextmenu.shareLink=Share Link From 4d67a1d3834e8856cb8ef93e94e8180b1bdbf107 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Fri, 4 Jan 2013 15:11:57 -0500 Subject: [PATCH 071/180] Bug 817440 - Intermittent testAddonManager | GeckoEventExpecter - blockForEvent timeout: Tab:Added r=gbrown --- mobile/android/base/tests/robocop.ini | 2 +- .../base/tests/testAddonManager.java.in | 34 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index acedec57da28..e9611f16faa6 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -22,7 +22,7 @@ [testSearchSuggestions] [testTabsTrayMenu] # [testThumbnails] # see bug 813107 -# [testAddonManager] # see bug 817440 +[testAddonManager] [testHistory] [testVkbOverlap] [testDoorHanger] diff --git a/mobile/android/base/tests/testAddonManager.java.in b/mobile/android/base/tests/testAddonManager.java.in index a0a4b26a94df..a9032d27a605 100755 --- a/mobile/android/base/tests/testAddonManager.java.in +++ b/mobile/android/base/tests/testAddonManager.java.in @@ -10,6 +10,10 @@ import android.content.ContentResolver; import android.app.Instrumentation; import android.util.DisplayMetrics; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + public class testAddonManager extends PixelTest { Actions.EventExpecter tabEventExpecter; Actions.EventExpecter contentEventExpecter; @@ -50,6 +54,34 @@ public class testAddonManager extends PixelTest { loadAndPaint(url); verifyPageTitle("Add-ons"); + // Change the AMO URL so we do not try to navigate to a live webpage + JSONObject jsonPref = new JSONObject(); + try { + jsonPref.put("name", "extensions.getAddons.browseAddons"); + jsonPref.put("type", "string"); + jsonPref.put("value", getAbsoluteUrl("/robocop/robocop_blank_01.html")); + mActions.sendGeckoEvent("Preferences:Set", jsonPref.toString()); + + // Wait for confirmation of the pref change before proceeding with the test. + JSONArray getPrefData = new JSONArray(); + getPrefData.put("extensions.getAddons.browseAddons"); + JSONObject message = new JSONObject(); + message.put("requestId", "testAddonManager"); + message.put("preferences", getPrefData); + Actions.RepeatedEventExpecter contentEventExpecter = mActions.expectGeckoEvent("Preferences:Data"); + mActions.sendGeckoEvent("Preferences:Get", message.toString()); + // Receiving a Preferences:Data event is not conclusive evidence that *our* + // preference has been set -- another component may be changing preferences + // at the same time. Mitigate this risk by waiting for a Preference:Data + // and then waiting for a period of time in which no more Preference:Data + // events are received. + // TODO: add a new expectGeckoEvent function that listens for a Preferences:Data + // message with a specific requestId + contentEventExpecter.blockUntilClear(2000); + } catch (Exception ex) { + mAsserter.ok(false, "exception in testAddonManager", ex.toString()); + } + // Load AMO page by clicking the AMO icon DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); @@ -75,7 +107,7 @@ public class testAddonManager extends PixelTest { verifyTabCount(2); // Verify the page was opened - verifyPageTitle("Add-ons for Android"); + verifyPageTitle("Browser Blank Page 01"); // Addons Manager is not opened 2 separate times when opened from the menu selectMenuItem("Add-ons"); From ec25adc6cd75c5ba65d91af2d7b7da22472c7529 Mon Sep 17 00:00:00 2001 From: Maire Reavy Date: Fri, 4 Jan 2013 14:41:25 -0500 Subject: [PATCH 072/180] bug 822956 - correct chunk_remaining calculation r=ekr --- media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 7e51b5a1477e..9934bb8e22b6 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -741,7 +741,7 @@ void MediaPipelineTransmit::PipelineListener::ProcessAudioChunk( if (tocpy > 0) { conduit->SendAudioFrame(samples_tmp, tocpy, rate, 0); samples_tmp += tocpy; - chunk_remaining = chunk.mDuration - tocpy; + chunk_remaining -= tocpy; } // Copy what remains for the next run From 3475845a400bf11043c9689b0c3a669a37cf16f8 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Sun, 30 Dec 2012 10:21:52 -0800 Subject: [PATCH 073/180] Bug 813867 - 'Report memory for web workers that use ctypes'. r=jlebar+jorendorff. --HG-- extra : rebase_source : 8ecb268167e840f26dd53a774c7e978b15ae3017 --- dom/workers/ChromeWorkerScope.cpp | 76 ++--- dom/workers/RuntimeService.cpp | 24 ++ dom/workers/WorkerPrivate.cpp | 468 +++++++++++++++++------------- dom/workers/WorkerPrivate.h | 31 +- js/src/ctypes/CTypes.cpp | 8 + js/src/jsapi.cpp | 1 + js/src/jscntxt.h | 2 + js/src/jsfriendapi.cpp | 6 + js/src/jsfriendapi.h | 17 +- 9 files changed, 371 insertions(+), 262 deletions(-) diff --git a/dom/workers/ChromeWorkerScope.cpp b/dom/workers/ChromeWorkerScope.cpp index 2923e4580c77..bdffcec38b7c 100644 --- a/dom/workers/ChromeWorkerScope.cpp +++ b/dom/workers/ChromeWorkerScope.cpp @@ -13,14 +13,13 @@ #include "WorkerPrivate.h" -#define CTYPES_STR "ctypes" - using namespace mozilla::dom; USING_WORKERS_NAMESPACE namespace { #ifdef BUILD_CTYPES + char* UnicodeToNative(JSContext* aCx, const jschar* aSource, size_t aSourceLen) { @@ -42,60 +41,7 @@ UnicodeToNative(JSContext* aCx, const jschar* aSource, size_t aSourceLen) return result; } -JSCTypesCallbacks gCTypesCallbacks = { - UnicodeToNative -}; - -JSBool -CTypesLazyGetter(JSContext* aCx, JSHandleObject aObj, JSHandleId aId, JSMutableHandleValue aVp) -{ - NS_ASSERTION(JS_GetGlobalObject(aCx) == aObj, "Not a global object!"); - NS_ASSERTION(JSID_IS_STRING(aId), "Bad id!"); - NS_ASSERTION(JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(aId), CTYPES_STR), - "Bad id!"); - - WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx); - NS_ASSERTION(worker->IsChromeWorker(), "This should always be true!"); - - if (!worker->DisableMemoryReporter()) { - return false; - } - - jsval ctypes; - if (!JS_DeletePropertyById(aCx, aObj, aId) || - !JS_InitCTypesClass(aCx, aObj) || - !JS_GetPropertyById(aCx, aObj, aId, &ctypes)) { - return false; - } - JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &gCTypesCallbacks); - return JS_GetPropertyById(aCx, aObj, aId, aVp.address()); -} -#endif - -inline bool -DefineCTypesLazyGetter(JSContext* aCx, JSObject* aGlobal) -{ -#ifdef BUILD_CTYPES - { - JSString* ctypesStr = JS_InternString(aCx, CTYPES_STR); - if (!ctypesStr) { - return false; - } - - jsid ctypesId = INTERNED_STRING_TO_JSID(aCx, ctypesStr); - - // We use a lazy getter here to let us unregister the blocking memory - // reporter since ctypes can easily block the worker thread and we can - // deadlock. Remove once bug 673323 is fixed. - if (!JS_DefinePropertyById(aCx, aGlobal, ctypesId, JSVAL_VOID, - CTypesLazyGetter, NULL, 0)) { - return false; - } - } -#endif - - return true; -} +#endif // BUILD_CTYPES } // anonymous namespace @@ -105,7 +51,23 @@ bool DefineChromeWorkerFunctions(JSContext* aCx, JSObject* aGlobal) { // Currently ctypes is the only special property given to ChromeWorkers. - return DefineCTypesLazyGetter(aCx, aGlobal); +#ifdef BUILD_CTYPES + { + jsval ctypes; + if (!JS_InitCTypesClass(aCx, aGlobal) || + !JS_GetProperty(aCx, aGlobal, "ctypes", &ctypes)) { + return false; + } + + static JSCTypesCallbacks callbacks = { + UnicodeToNative + }; + + JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &callbacks); + } +#endif // BUILD_CTYPES + + return true; } END_WORKERS_NAMESPACE diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index ba0d5f75cf58..0fc13112554d 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -22,6 +22,7 @@ #include "nsLayoutStatics.h" #include "jsdbgapi.h" +#include "jsfriendapi.h" #include "mozilla/dom/EventTargetBinding.h" #include "mozilla/Preferences.h" #include "nsContentUtils.h" @@ -372,6 +373,27 @@ ContentSecurityPolicyAllows(JSContext* aCx) return false; } +void +CTypesActivityCallback(JSContext* aCx, + js::CTypesActivityType aType) +{ + WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx); + worker->AssertIsOnWorkerThread(); + + switch (aType) { + case js::CTYPES_CALL_BEGIN: + worker->BeginCTypesCall(); + break; + + case js::CTYPES_CALL_END: + worker->EndCTypesCall(); + break; + + default: + MOZ_NOT_REACHED("Unknown type flag!"); + } +} + JSContext* CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate) { @@ -418,6 +440,8 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate) JS_SetOperationCallback(workerCx, OperationCallback); + js::SetCTypesActivityCallback(runtime, CTypesActivityCallback); + NS_ASSERTION((aWorkerPrivate->GetJSContextOptions() & kRequiredJSContextOptions) == kRequiredJSContextOptions, "Somehow we lost our required options!"); diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 26d2b3c2f7af..c3ff5c62d0e1 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -1398,134 +1398,59 @@ public: } }; -class CollectRuntimeStatsRunnable : public WorkerControlRunnable +class WorkerJSRuntimeStats : public JS::RuntimeStats { - typedef mozilla::Mutex Mutex; - typedef mozilla::CondVar CondVar; - - Mutex mMutex; - CondVar mCondVar; - volatile bool mDone; - bool mIsQuick; - void* mData; - bool* mSucceeded; + const nsACString& mRtPath; public: - CollectRuntimeStatsRunnable(WorkerPrivate* aWorkerPrivate, bool aIsQuick, - void* aData, bool* aSucceeded) - : WorkerControlRunnable(aWorkerPrivate, WorkerThread, UnchangedBusyCount), - mMutex("CollectRuntimeStatsRunnable::mMutex"), - mCondVar(mMutex, "CollectRuntimeStatsRunnable::mCondVar"), mDone(false), - mIsQuick(aIsQuick), mData(aData), mSucceeded(aSucceeded) + WorkerJSRuntimeStats(const nsACString& aRtPath) + : JS::RuntimeStats(JsWorkerMallocSizeOf), mRtPath(aRtPath) { } - bool - PreDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate) + ~WorkerJSRuntimeStats() { - AssertIsOnMainThread(); - return true; - } - - void - PostDispatch(JSContext* aCx, WorkerPrivate* aWorkerPrivate, - bool aDispatchResult) - { - AssertIsOnMainThread(); - } - - bool - DispatchInternal() - { - AssertIsOnMainThread(); - - if (!WorkerControlRunnable::DispatchInternal()) { - NS_WARNING("Failed to dispatch runnable!"); - return false; - } - - { - MutexAutoLock lock(mMutex); - while (!mDone) { - mCondVar.Wait(); - } - } - - return true; - } - - bool - WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) - { - JSRuntime *rt = JS_GetRuntime(aCx); - if (mIsQuick) { - *static_cast(mData) = JS::GetExplicitNonHeapForRuntime(rt, JsWorkerMallocSizeOf); - *mSucceeded = true; - } else { - *mSucceeded = JS::CollectRuntimeStats(rt, static_cast(mData), nullptr); - } - - { - MutexAutoLock lock(mMutex); - mDone = true; - mCondVar.Notify(); - } - - return true; - } -}; - -} /* anonymous namespace */ - -struct WorkerJSRuntimeStats : public JS::RuntimeStats -{ - WorkerJSRuntimeStats(nsACString &aRtPath) - : JS::RuntimeStats(JsWorkerMallocSizeOf), mRtPath(aRtPath) { } - - ~WorkerJSRuntimeStats() { for (size_t i = 0; i != compartmentStatsVector.length(); i++) { free(compartmentStatsVector[i].extra1); - // no need to free |extra2|, because it's a static string + // No need to free |extra2| because it's a static string. } } - virtual void initExtraCompartmentStats(JSCompartment *c, - JS::CompartmentStats *cstats) MOZ_OVERRIDE + virtual void + initExtraCompartmentStats(JSCompartment* aCompartment, + JS::CompartmentStats* aCompartmentStats) + MOZ_OVERRIDE { - MOZ_ASSERT(!cstats->extra1); - MOZ_ASSERT(!cstats->extra2); + MOZ_ASSERT(!aCompartmentStats->extra1); + MOZ_ASSERT(!aCompartmentStats->extra2); - // ReportJSRuntimeExplicitTreeStats expects that cstats->{extra1,extra2} - // are char pointers. + // ReportJSRuntimeExplicitTreeStats expects that + // aCompartmentStats->{extra1,extra2} are char pointers. // This is the |cJSPathPrefix|. Each worker has exactly two compartments: // one for atoms, and one for everything else. - nsCString cJSPathPrefix(mRtPath); - cJSPathPrefix += js::IsAtomsCompartment(c) + nsAutoCString cJSPathPrefix(mRtPath); + cJSPathPrefix += js::IsAtomsCompartment(aCompartment) ? NS_LITERAL_CSTRING("compartment(web-worker-atoms)/") : NS_LITERAL_CSTRING("compartment(web-worker)/"); - cstats->extra1 = strdup(cJSPathPrefix.get()); + aCompartmentStats->extra1 = strdup(cJSPathPrefix.get()); - // This is the |cDOMPathPrefix|, which should never be used when reporting - // with workers (hence the "?!"). - cstats->extra2 = (void *)"explicit/workers/?!/"; + // This should never be used when reporting with workers (hence the "?!"). + static const char bogusMemoryReporterPath[] = "explicit/workers/?!/"; + aCompartmentStats->extra2 = const_cast(bogusMemoryReporterPath); } - -private: - nsCString mRtPath; }; -BEGIN_WORKERS_NAMESPACE - -class WorkerMemoryReporter MOZ_FINAL : public nsIMemoryMultiReporter +class MemoryReporter MOZ_FINAL : public nsIMemoryMultiReporter { + friend class WorkerPrivate; + WorkerPrivate* mWorkerPrivate; - nsCString mAddressString; nsCString mRtPath; public: NS_DECL_ISUPPORTS - WorkerMemoryReporter(WorkerPrivate* aWorkerPrivate) + MemoryReporter(WorkerPrivate* aWorkerPrivate) : mWorkerPrivate(aWorkerPrivate) { aWorkerPrivate->AssertIsOnWorkerThread(); @@ -1536,51 +1461,22 @@ public: NS_ConvertUTF16toUTF8 escapedURL(aWorkerPrivate->ScriptURL()); escapedURL.ReplaceChar('/', '\\'); - { - // 64bit address plus '0x' plus null terminator. - char address[21]; - uint32_t addressSize = - JS_snprintf(address, sizeof(address), "%p", aWorkerPrivate); - if (addressSize != uint32_t(-1)) { - mAddressString.Assign(address, addressSize); - } - else { - NS_WARNING("JS_snprintf failed!"); - mAddressString.AssignLiteral(""); - } - } + nsAutoCString addressString; + addressString.AppendPrintf("0x%p", static_cast(aWorkerPrivate)); mRtPath = NS_LITERAL_CSTRING("explicit/workers/workers(") + escapedDomain + NS_LITERAL_CSTRING(")/worker(") + - escapedURL + NS_LITERAL_CSTRING(", ") + mAddressString + + escapedURL + NS_LITERAL_CSTRING(", ") + addressString + NS_LITERAL_CSTRING(")/"); } - nsresult - CollectForRuntime(bool aIsQuick, void* aData) + ~MemoryReporter() { - AssertIsOnMainThread(); - - if (!mWorkerPrivate) { -#ifdef DEBUG - nsAutoCString message("Unable to report memory for "); - message += NS_LITERAL_CSTRING("Worker (") + mAddressString + - NS_LITERAL_CSTRING(")! It is either using ctypes or is in " - "the process of being destroyed"); - NS_WARNING(message.get()); -#endif - *static_cast(aData) = 0; - return NS_OK; - } - - if (!mWorkerPrivate->BlockAndCollectRuntimeStats(aIsQuick, aData)) { - return NS_ERROR_FAILURE; - } - - return NS_OK; + mWorkerPrivate->NoteDeadMemoryReporter(); } - NS_IMETHOD GetName(nsACString &aName) + NS_IMETHOD + GetName(nsACString& aName) { aName.AssignLiteral("workers"); return NS_OK; @@ -1593,9 +1489,9 @@ public: AssertIsOnMainThread(); WorkerJSRuntimeStats rtStats(mRtPath); - nsresult rv = CollectForRuntime(/* isQuick = */false, &rtStats); - if (NS_FAILED(rv)) { - return rv; + if (!mWorkerPrivate->BlockAndCollectRuntimeStats(/* aIsQuick = */ false, + &rtStats)) { + return NS_ERROR_FAILURE; } // Always report, even if we're disabled, so that we at least get an entry @@ -1605,33 +1501,22 @@ public: } NS_IMETHOD - GetExplicitNonHeap(int64_t *aAmount) + GetExplicitNonHeap(int64_t* aAmount) { AssertIsOnMainThread(); - return CollectForRuntime(/* isQuick = */true, aAmount); - } - - void Disable() - { -#ifdef DEBUG - // Setting mWorkerPrivate to nullptr is safe only because we've locked the - // worker's mutex on the worker's thread, in the caller. So we check that. - // - // Also, we may have already disabled the reporter (and thus set - // mWorkerPrivate to nullptr) due to the use of CTypes (see - // ChromeWorkerScope.cpp). That's why the NULL check is necessary. - if (mWorkerPrivate) { - mWorkerPrivate->mMutex.AssertCurrentThreadOwns(); + if (!mWorkerPrivate->BlockAndCollectRuntimeStats(/* aIsQuick = */ true, + aAmount)) { + return NS_ERROR_FAILURE; } -#endif - mWorkerPrivate = nullptr; + + return NS_OK; } }; -END_WORKERS_NAMESPACE +} /* anonymous namespace */ -NS_IMPL_THREADSAFE_ISUPPORTS1(WorkerMemoryReporter, nsIMemoryMultiReporter) +NS_IMPL_THREADSAFE_ISUPPORTS1(MemoryReporter, nsIMemoryMultiReporter) #ifdef DEBUG void @@ -1909,6 +1794,7 @@ WorkerPrivateParent::WorkerPrivateParent( bool aEvalAllowed) : EventTarget(aParent ? aCx : NULL), mMutex("WorkerPrivateParent Mutex"), mCondVar(mMutex, "WorkerPrivateParent CondVar"), + mMemoryReportCondVar(mMutex, "WorkerPrivateParent Memory Report CondVar"), mJSObject(aObject), mParent(aParent), mParentJSContext(aParentJSContext), mScriptURL(aScriptURL), mDomain(aDomain), mBusyCount(0), mParentStatus(Pending), mJSContextOptions(0), mJSRuntimeHeapSize(0), @@ -2480,7 +2366,8 @@ WorkerPrivate::WorkerPrivate(JSContext* aCx, JSObject* aObject, mJSContext(nullptr), mErrorHandlerRecursionCount(0), mNextTimeoutId(1), mStatus(Pending), mSuspended(false), mTimerRunning(false), mRunningExpiredTimeouts(false), mCloseHandlerStarted(false), - mCloseHandlerFinished(false), mMemoryReporterRunning(false), + mCloseHandlerFinished(false), mMemoryReporterAlive(false), + mMemoryReporterRunning(false), mBlockedForMemoryReporter(false), mXHRParamsAllowed(aXHRParamsAllowed) { MOZ_COUNT_CTOR(mozilla::dom::workers::WorkerPrivate); @@ -2737,12 +2624,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx) idleGCEvent = runnable; } - mMemoryReporter = new WorkerMemoryReporter(this); - - if (NS_FAILED(NS_RegisterMemoryMultiReporter(mMemoryReporter))) { - NS_WARNING("Failed to register memory reporter!"); - mMemoryReporter = nullptr; - } + EnableMemoryReporter(); for (;;) { Status currentStatus; @@ -2753,7 +2635,7 @@ WorkerPrivate::DoRunLoop(JSContext* aCx) MutexAutoLock lock(mMutex); while (!mControlQueue.Pop(event) && !mQueue.Pop(event)) { - mCondVar.Wait(); + WaitForWorkerEvents(); } bool eventIsNotIdleGCEvent; @@ -2854,17 +2736,8 @@ WorkerPrivate::DoRunLoop(JSContext* aCx) NS_WARNING("Failed to cancel the GC timer!"); } - // Call this before unregistering the reporter as we may be racing with - // the main thread. DisableMemoryReporter(); - if (mMemoryReporter) { - if (NS_FAILED(NS_UnregisterMemoryMultiReporter(mMemoryReporter))) { - NS_WARNING("Failed to unregister memory reporter!"); - } - mMemoryReporter = nullptr; - } - StopAcceptingEvents(); return; } @@ -2898,7 +2771,7 @@ WorkerPrivate::OperationCallback(JSContext* aCx) break; } - mCondVar.Wait(PR_MillisecondsToInterval(RemainingRunTimeMS())); + WaitForWorkerEvents(PR_MillisecondsToInterval(RemainingRunTimeMS())); } } @@ -2954,49 +2827,181 @@ WorkerPrivate::BlockAndCollectRuntimeStats(bool aIsQuick, void* aData) AssertIsOnMainThread(); NS_ASSERTION(aData, "Null data!"); + JSRuntime* rt; + { MutexAutoLock lock(mMutex); + + // If the worker is being torn down then we just bail out now. + if (!mMemoryReporter) { + if (aIsQuick) { + *static_cast(aData) = 0; + } + return true; + } + + // This signals the worker that it should block itself as soon as possible. mMemoryReporterRunning = true; + + NS_ASSERTION(mJSContext, "This must never be null!"); + rt = JS_GetRuntime(mJSContext); + + // If the worker is not already blocked (e.g. waiting for a worker event or + // currently in a ctypes call) then we need to trigger the operation + // callback to trap the worker. + if (!mBlockedForMemoryReporter) { + JS_TriggerOperationCallback(rt); + + // Wait until the worker actually blocks. + while (!mBlockedForMemoryReporter) { + mMemoryReportCondVar.Wait(); + } + } } bool succeeded; - nsRefPtr runnable = - new CollectRuntimeStatsRunnable(this, aIsQuick, aData, &succeeded); - if (!runnable->Dispatch(nullptr)) { - NS_WARNING("Failed to dispatch runnable!"); - succeeded = false; + // Now do the actual report. + if (aIsQuick) { + *static_cast(aData) = + JS::GetExplicitNonHeapForRuntime(rt, JsWorkerMallocSizeOf); + succeeded = true; + } else { + succeeded = + JS::CollectRuntimeStats(rt, static_cast(aData), + nullptr); } - { - MutexAutoLock lock(mMutex); - mMemoryReporterRunning = false; - } + MutexAutoLock lock(mMutex); + + NS_ASSERTION(mMemoryReporterRunning, "This isn't possible!"); + NS_ASSERTION(mBlockedForMemoryReporter, "Somehow we got unblocked!"); + + // Tell the worker that it can now continue its execution. + mMemoryReporterRunning = false; + + // The worker may be waiting so we must notify. + mMemoryReportCondVar.Notify(); return succeeded; } -bool +void +WorkerPrivate::NoteDeadMemoryReporter() +{ + // This may happen on the worker thread or the main thread. + MutexAutoLock lock(mMutex); + + NS_ASSERTION(mMemoryReporterAlive, "Must be alive!"); + + // Tell the worker that the memory reporter has died. + mMemoryReporterAlive = false; + + // The worker may be waiting so we must notify. + mMemoryReportCondVar.Notify(); +} + +void +WorkerPrivate::EnableMemoryReporter() +{ + AssertIsOnWorkerThread(); + + NS_ASSERTION(!mMemoryReporterAlive, "This isn't possible!"); + + // No need to lock here since the main thread can't race until we've + // successfully registered the reporter. + mMemoryReporterAlive = true; + mMemoryReporter = new MemoryReporter(this); + + if (NS_FAILED(NS_RegisterMemoryMultiReporter(mMemoryReporter))) { + NS_WARNING("Failed to register memory reporter!"); + // No need to lock here since a failed registration means our memory + // reporter can't start running. Just clean up. + mMemoryReporter = nullptr; + + // That should have killed the memory reporter. + NS_ASSERTION(!mMemoryReporterAlive, "Must be dead!"); + + return; + } +} + +void WorkerPrivate::DisableMemoryReporter() { AssertIsOnWorkerThread(); - bool result = true; - + // First swap out our memory reporter so that the main thread stops trying to + // signal us when it's reporting memory. + nsCOMPtr memoryReporter; { MutexAutoLock lock(mMutex); - - while (mMemoryReporterRunning) { - MutexAutoUnlock unlock(mMutex); - result = ProcessAllControlRunnables() && result; - } - - if (mMemoryReporter) { - mMemoryReporter->Disable(); - } + mMemoryReporter.swap(memoryReporter); } - return result; + // The main thread could immediately try to report memory again here but it + // will not actually do anything since we've cleared mMemoryReporter. + + // If we never registered the memory reporter (e.g. some kind of error in + // NS_RegisterMemoryMultiReporter) then there's nothing else we need to do + // here. + if (!memoryReporter) { + return; + } + + NS_ASSERTION(mMemoryReporterAlive, "Huh?!"); + + // Unregister. + if (NS_FAILED(NS_UnregisterMemoryMultiReporter(memoryReporter))) { + // If this fails then the memory reporter will probably never die and we'll + // hang below waiting for it. If this ever happens we need to fix + // NS_UnregisterMemoryMultiReporter. + MOZ_NOT_REACHED("Failed to unregister memory reporter! Worker is going to " + "hang!"); + } + + // Now drop our reference to the memory reporter. The main thread could be + // holding another reference so it may not die immediately. + memoryReporter = nullptr; + + MutexAutoLock lock(mMutex); + + // Wait once again to make sure that the main thread is done with the memory + // reporter. + while (mMemoryReporterAlive) { + mMemoryReportCondVar.Wait(); + } +} + +void +WorkerPrivate::WaitForWorkerEvents(PRIntervalTime aInterval) +{ + AssertIsOnWorkerThread(); + mMutex.AssertCurrentThreadOwns(); + + NS_ASSERTION(!mBlockedForMemoryReporter, + "Can't be blocked in more than one place at the same time!"); + + // Let the main thread know that the worker is blocked and that memory + // reporting may proceed. + mBlockedForMemoryReporter = true; + + // The main thread may be waiting so we must notify. + mMemoryReportCondVar.Notify(); + + // Now wait for an actual worker event. + mCondVar.Wait(aInterval); + + // We've gotten some kind of signal but we can't continue until the memory + // reporter has finished. Wait again. + while (mMemoryReporterRunning) { + mMemoryReportCondVar.Wait(); + } + + NS_ASSERTION(mBlockedForMemoryReporter, "Somehow we got unblocked!"); + + // No need to notify here as the main thread isn't watching for this state. + mBlockedForMemoryReporter = false; } bool @@ -3010,6 +3015,32 @@ WorkerPrivate::ProcessAllControlRunnables() WorkerRunnable* event; { MutexAutoLock lock(mMutex); + + // Block here if the memory reporter is trying to run. + if (mMemoryReporterRunning) { + NS_ASSERTION(!mBlockedForMemoryReporter, + "Can't be blocked in more than one place at the same " + "time!"); + + // Let the main thread know that we've received the block request and + // that memory reporting may proceed. + mBlockedForMemoryReporter = true; + + // The main thread is almost certainly waiting so we must notify here. + mMemoryReportCondVar.Notify(); + + // Wait for the memory report to finish. + while (mMemoryReporterRunning) { + mMemoryReportCondVar.Wait(); + } + + NS_ASSERTION(mBlockedForMemoryReporter, "Somehow we got unblocked!"); + + // No need to notify here as the main thread isn't watching for this + // state. + mBlockedForMemoryReporter = false; + } + if (!mControlQueue.Pop(event)) { break; } @@ -3021,6 +3052,7 @@ WorkerPrivate::ProcessAllControlRunnables() NS_RELEASE(event); } + return result; } @@ -3371,7 +3403,7 @@ WorkerPrivate::RunSyncLoop(JSContext* aCx, uint32_t aSyncLoopKey) MutexAutoLock lock(mMutex); while (!mControlQueue.Pop(event) && !syncQueue->mQueue.Pop(event)) { - mCondVar.Wait(); + WaitForWorkerEvents(); } } @@ -4119,6 +4151,46 @@ WorkerPrivate::GetContentSecurityPolicy(JSContext* aCx, return true; } +void +WorkerPrivate::BeginCTypesCall() +{ + AssertIsOnWorkerThread(); + + MutexAutoLock lock(mMutex); + + NS_ASSERTION(!mBlockedForMemoryReporter, + "Can't be blocked in more than one place at the same time!"); + + // Let the main thread know that the worker is effectively blocked while in + // this ctypes call. It isn't technically true (obviously the call could do + // non-blocking things), but we're assuming that ctypes can't call back into + // JSAPI here and therefore any work the ctypes call does will not alter the + // data structures of this JS runtime. + mBlockedForMemoryReporter = true; + + // The main thread may be waiting on us so it must be notified. + mMemoryReportCondVar.Notify(); +} + +void +WorkerPrivate::EndCTypesCall() +{ + AssertIsOnWorkerThread(); + + MutexAutoLock lock(mMutex); + + NS_ASSERTION(mBlockedForMemoryReporter, "Somehow we got unblocked!"); + + // Don't continue until the memory reporter has finished. + while (mMemoryReporterRunning) { + mMemoryReportCondVar.Wait(); + } + + // No need to notify the main thread here as it shouldn't be waiting to see + // this state. + mBlockedForMemoryReporter = false; +} + BEGIN_WORKERS_NAMESPACE // Force instantiation. diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index cd6753ecdbdc..50a66bebbb2a 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -32,6 +32,7 @@ class JSAutoStructuredCloneBuffer; class nsIDocument; +class nsIMemoryMultiReporter; class nsIPrincipal; class nsIScriptContext; class nsIURI; @@ -41,7 +42,6 @@ class nsIXPCScriptNotify; BEGIN_WORKERS_NAMESPACE -class WorkerMemoryReporter; class WorkerPrivate; class WorkerRunnable : public nsIRunnable @@ -167,6 +167,7 @@ public: protected: mozilla::Mutex mMutex; mozilla::CondVar mCondVar; + mozilla::CondVar mMemoryReportCondVar; private: JSObject* mJSObject; @@ -518,7 +519,6 @@ public: class WorkerPrivate : public WorkerPrivateParent { friend class WorkerPrivateParent; - friend class WorkerMemoryReporter; typedef WorkerPrivateParent ParentType; struct TimeoutInfo; @@ -558,7 +558,7 @@ class WorkerPrivate : public WorkerPrivateParent nsTArray > mTimeouts; nsCOMPtr mTimer; - nsRefPtr mMemoryReporter; + nsCOMPtr mMemoryReporter; mozilla::TimeStamp mKillTime; uint32_t mErrorHandlerRecursionCount; @@ -569,7 +569,9 @@ class WorkerPrivate : public WorkerPrivateParent bool mRunningExpiredTimeouts; bool mCloseHandlerStarted; bool mCloseHandlerFinished; + bool mMemoryReporterAlive; bool mMemoryReporterRunning; + bool mBlockedForMemoryReporter; bool mXHRParamsAllowed; #ifdef DEBUG @@ -710,10 +712,10 @@ public: ScheduleDeletion(bool aWasPending); bool - BlockAndCollectRuntimeStats(bool isQuick, void* aData); + BlockAndCollectRuntimeStats(bool aIsQuick, void* aData); - bool - DisableMemoryReporter(); + void + NoteDeadMemoryReporter(); bool XHRParamsAllowed() const @@ -761,6 +763,14 @@ public: WorkerCrossThreadDispatcher* GetCrossThreadDispatcher(); + // This may block! + void + BeginCTypesCall(); + + // This may block! + void + EndCTypesCall(); + private: WorkerPrivate(JSContext* aCx, JSObject* aObject, WorkerPrivate* aParent, JSContext* aParentJSContext, const nsAString& aScriptURL, @@ -830,6 +840,15 @@ private: bool ProcessAllControlRunnables(); + void + EnableMemoryReporter(); + + void + DisableMemoryReporter(); + + void + WaitForWorkerEvents(PRIntervalTime interval = PR_INTERVAL_NO_TIMEOUT); + static bool CheckXHRParamsAllowed(nsPIDOMWindow* aWindow); }; diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 26254a74d818..95560ae20f79 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -5789,6 +5789,11 @@ FunctionType::Call(JSContext* cx, return false; } + // Let the runtime callback know that we are about to call into C. + js::CTypesActivityCallback activityCallback = cx->runtime->ctypesActivityCallback; + if (activityCallback) + activityCallback(cx, js::CTYPES_CALL_BEGIN); + uintptr_t fn = *reinterpret_cast(CData::GetData(obj)); #if defined(XP_WIN) @@ -5816,6 +5821,9 @@ FunctionType::Call(JSContext* cx, errno = savedErrno; + if (activityCallback) + activityCallback(cx, js::CTYPES_CALL_END); + // Store the error value for later consultation with |ctypes.getStatus| JSObject *objCTypes = CType::GetGlobalCTypes(cx, typeObj); if (!objCTypes) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index c02b86f58452..75e0348dd3d6 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -888,6 +888,7 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads) ionPcScriptCache(NULL), threadPool(this), ionReturnOverride_(MagicValue(JS_ARG_POISON)), + ctypesActivityCallback(NULL), useHelperThreads_(useHelperThreads), requestedHelperThreadCount(-1) { diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index 8891c7c97b5a..47982188b4c4 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -1042,6 +1042,8 @@ struct JSRuntime : js::RuntimeFriendFields js::ThreadPool threadPool; + js::CTypesActivityCallback ctypesActivityCallback; + private: // In certain cases, we want to optimize certain opcodes to typed instructions, // to avoid carrying an extra register to feed into an unbox. Unfortunately, diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 72f7087c784b..353c3855a344 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -984,3 +984,9 @@ js::GetListBaseExpandoSlot() { return gListBaseExpandoSlot; } + +JS_FRIEND_API(void) +js::SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb) +{ + rt->ctypesActivityCallback = cb; +} diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index c9d5094669d3..5bf16e02a49d 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -1561,6 +1561,21 @@ IsReadOnlyDateMethod(JS::IsAcceptableThis test, JS::NativeImpl method); extern JS_FRIEND_API(bool) IsTypedArrayThisCheck(JS::IsAcceptableThis test); +enum CTypesActivityType { + CTYPES_CALL_BEGIN, + CTYPES_CALL_END +}; + +typedef void +(* CTypesActivityCallback)(JSContext *cx, CTypesActivityType type); + +/* + * Sets a callback that is run whenever js-ctypes is about to be used when + * calling into C. + */ +JS_FRIEND_API(void) +SetCTypesActivityCallback(JSRuntime *rt, CTypesActivityCallback cb); + } /* namespace js */ -#endif /* jsfriendapi_h___ */ +#endif /* jsfriendapi_h___ */ \ No newline at end of file From ef2616d682cc0a51571a47fe7fab46f2c18cc992 Mon Sep 17 00:00:00 2001 From: Neil Rashbrook Date: Fri, 4 Jan 2013 20:31:50 +0000 Subject: [PATCH 074/180] Bug 826541 Suboptimal string copying in nsAttrValue::ToString r=bz --- content/base/src/nsAttrValue.cpp | 15 ++++++--------- content/base/src/nsAttrValueInlines.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/content/base/src/nsAttrValue.cpp b/content/base/src/nsAttrValue.cpp index 5fbd6696c302..2333850841af 100644 --- a/content/base/src/nsAttrValue.cpp +++ b/content/base/src/nsAttrValue.cpp @@ -30,7 +30,7 @@ using namespace mozilla; reinterpret_cast((_cont)->mStringBits & NS_ATTRVALUE_POINTERVALUE_MASK) bool -MiscContainer::GetString(nsDependentString& aString) const +MiscContainer::GetString(nsAString& aString) const { void* ptr = MISC_STR_PTR(this); @@ -46,8 +46,7 @@ MiscContainer::GetString(nsDependentString& aString) const return false; } - aString.Rebind(reinterpret_cast(buffer->Data()), - buffer->StorageSize() / sizeof(PRUnichar) - 1); + buffer->ToString(buffer->StorageSize() / sizeof(PRUnichar) - 1, aString); return true; } @@ -56,7 +55,7 @@ MiscContainer::GetString(nsDependentString& aString) const return false; } - aString.Rebind(atom->GetUTF16String(), atom->GetLength()); + atom->ToString(aString); return true; } @@ -75,7 +74,7 @@ MiscContainer::Cache() return; } - nsDependentString str; + nsString str; bool gotString = GetString(str); if (!gotString) { return; @@ -107,7 +106,7 @@ MiscContainer::Evict() nsHTMLCSSStyleSheet* sheet = rule->GetHTMLCSSStyleSheet(); MOZ_ASSERT(sheet); - nsDependentString str; + nsString str; DebugOnly gotString = GetString(str); MOZ_ASSERT(gotString); @@ -578,9 +577,7 @@ nsAttrValue::ToString(nsAString& aResult) const if (BaseType() == eOtherBase) { cont = GetMiscContainer(); - nsDependentString str; - if (cont->GetString(str)) { - aResult = str; + if (cont->GetString(aResult)) { return; } } diff --git a/content/base/src/nsAttrValueInlines.h b/content/base/src/nsAttrValueInlines.h index a30d0c28ef0a..177b1f004251 100644 --- a/content/base/src/nsAttrValueInlines.h +++ b/content/base/src/nsAttrValueInlines.h @@ -67,7 +67,7 @@ struct MiscContainer MOZ_COUNT_DTOR(MiscContainer); } - bool GetString(nsDependentString& aString) const; + bool GetString(nsAString& aString) const; inline bool IsRefCounted() const { From 0395b78f276e56c8ed705fc26c32a690569751df Mon Sep 17 00:00:00 2001 From: Neil Rashbrook Date: Fri, 4 Jan 2013 20:33:09 +0000 Subject: [PATCH 075/180] Bug 826479 Assertion failure: mInitialized when using Ctrl+Middle-click paste r=ehsan --- editor/libeditor/text/nsPlaintextEditor.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index 05aaefbeb62b..5edd50a0ac2c 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -1329,13 +1329,11 @@ nsPlaintextEditor::PasteAsQuotation(int32_t aSelectionType) nsCOMPtr clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv)); NS_ENSURE_SUCCESS(rv, rv); - // Create generic Transferable for getting the data - nsCOMPtr trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv); + // Get the nsITransferable interface for getting the data from the clipboard + nsCOMPtr trans; + rv = PrepareTransferable(getter_AddRefs(trans)); if (NS_SUCCEEDED(rv) && trans) { - // We only handle plaintext pastes here - trans->AddDataFlavor(kUnicodeMime); - // Get the Data from the clipboard clipboard->GetData(trans, aSelectionType); @@ -1357,7 +1355,8 @@ nsPlaintextEditor::PasteAsQuotation(int32_t aSelectionType) #ifdef DEBUG_clipboard printf("Got flavor [%s]\n", flav); #endif - if (0 == nsCRT::strcmp(flav, kUnicodeMime)) + if (0 == nsCRT::strcmp(flav, kUnicodeMime) || + 0 == nsCRT::strcmp(flav, kMozTextInternal)) { nsCOMPtr textDataObj ( do_QueryInterface(genericDataObj) ); if (textDataObj && len > 0) From e657c8cc0889c601a013db67d92e2228f74df758 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Fri, 4 Jan 2013 16:01:22 -0500 Subject: [PATCH 076/180] Bug 826729 - about:downloads download item buttons look strange, and context menus don't update. r=mak. --- .../downloads/content/allDownloadsViewOverlay.xul | 5 ++++- .../pinstripe/downloads/contentAreaDownloadsView.css | 10 ++++++++++ .../winstripe/downloads/allDownloadsViewOverlay.css | 2 +- .../winstripe/downloads/contentAreaDownloadsView.css | 10 ++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/browser/components/downloads/content/allDownloadsViewOverlay.xul b/browser/components/downloads/content/allDownloadsViewOverlay.xul index ee9d8a3dad11..6fc702e6c3a4 100644 --- a/browser/components/downloads/content/allDownloadsViewOverlay.xul +++ b/browser/components/downloads/content/allDownloadsViewOverlay.xul @@ -43,7 +43,10 @@ seltype="multiple" id="downloadsRichListBox" context="downloadsContextMenu" onkeypress="return this._placesView.onKeyPress(event);" - oncontextmenu="return this._placesView.onContextMenu(event);"/> + oncontextmenu="return this._placesView.onContextMenu(event);" + onfocus="goUpdateDownloadCommands();" + onselect="goUpdateDownloadCommands();" + onblur="goUpdateDownloadCommands();"/> Date: Fri, 4 Jan 2013 15:56:20 +0100 Subject: [PATCH 077/180] Bug 824330 - Build services/ during the platform tier and enable services in xulrunner. r=blassey,r=bsmedberg,r=gps --- b2g/build.mk | 2 -- browser/build.mk | 2 -- mobile/android/confvars.sh | 3 --- mobile/xul/build.mk | 4 ---- services/Makefile.in | 4 ---- services/crypto/Makefile.in | 2 ++ toolkit/toolkit-tiers.mk | 2 +- xulrunner/confvars.sh | 6 ++++++ 8 files changed, 9 insertions(+), 16 deletions(-) diff --git a/b2g/build.mk b/b2g/build.mk index f4213b064349..87fdb931143d 100644 --- a/b2g/build.mk +++ b/b2g/build.mk @@ -18,8 +18,6 @@ ifdef MOZ_EXTENSIONS tier_app_dirs += extensions endif -tier_app_dirs += services - tier_app_dirs += \ $(MOZ_BRANDING_DIRECTORY) \ b2g \ diff --git a/browser/build.mk b/browser/build.mk index 1b572035bc72..037515a4699f 100644 --- a/browser/build.mk +++ b/browser/build.mk @@ -14,8 +14,6 @@ endif tier_app_dirs += $(MOZ_BRANDING_DIRECTORY) -tier_app_dirs += services - ifdef MOZ_WEBAPP_RUNTIME tier_app_dirs += webapprt endif diff --git a/mobile/android/confvars.sh b/mobile/android/confvars.sh index 32274c916374..1f4cba4afd81 100755 --- a/mobile/android/confvars.sh +++ b/mobile/android/confvars.sh @@ -19,9 +19,6 @@ MOZ_DISABLE_DOMCRYPTO=1 # Enable getUserMedia MOZ_MEDIA_NAVIGATOR=1 -MOZ_SERVICES_COMMON=1 -MOZ_SERVICES_METRICS=1 - if test "$LIBXUL_SDK"; then MOZ_XULRUNNER=1 else diff --git a/mobile/xul/build.mk b/mobile/xul/build.mk index a5523222d8ee..41884e52bcfa 100644 --- a/mobile/xul/build.mk +++ b/mobile/xul/build.mk @@ -21,10 +21,6 @@ ifdef MOZ_EXTENSIONS tier_app_dirs += extensions endif -ifdef MOZ_SERVICES_SYNC -tier_app_dirs += services -endif - tier_app_dirs += \ $(MOZ_BRANDING_DIRECTORY) \ mobile/xul \ diff --git a/services/Makefile.in b/services/Makefile.in index f5575e9062c6..253883f0e7a0 100644 --- a/services/Makefile.in +++ b/services/Makefile.in @@ -9,13 +9,9 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -ifdef MOZ_SERVICES_COMMON PARALLEL_DIRS += common -endif -ifdef MOZ_SERVICES_CRYPTO PARALLEL_DIRS += crypto -endif ifdef MOZ_SERVICES_AITC PARALLEL_DIRS += aitc diff --git a/services/crypto/Makefile.in b/services/crypto/Makefile.in index 9e96c7ab0a13..d26506ee309a 100644 --- a/services/crypto/Makefile.in +++ b/services/crypto/Makefile.in @@ -22,4 +22,6 @@ INSTALL_TARGETS += CRYPTO_MODULE TEST_DIRS += tests +DIRS += component + include $(topsrcdir)/config/rules.mk diff --git a/toolkit/toolkit-tiers.mk b/toolkit/toolkit-tiers.mk index a9c8fadea564..69401f435d47 100644 --- a/toolkit/toolkit-tiers.mk +++ b/toolkit/toolkit-tiers.mk @@ -260,7 +260,7 @@ ifdef MOZ_PREF_EXTENSIONS tier_platform_dirs += extensions/pref endif -tier_platform_dirs += services/crypto/component +tier_platform_dirs += services tier_platform_dirs += startupcache diff --git a/xulrunner/confvars.sh b/xulrunner/confvars.sh index 5fe2c3d207c2..04b37d5e3603 100755 --- a/xulrunner/confvars.sh +++ b/xulrunner/confvars.sh @@ -12,3 +12,9 @@ MOZ_APP_VERSION=$MOZILLA_VERSION MOZ_PLACES=1 MOZ_EXTENSIONS_DEFAULT=" gio" MOZ_URL_CLASSIFIER=1 +MOZ_SERVICES_AITC=1 +MOZ_SERVICES_COMMON=1 +MOZ_SERVICES_CRYPTO=1 +MOZ_SERVICES_METRICS=1 +MOZ_SERVICES_NOTIFICATIONS=1 +MOZ_SERVICES_SYNC=1 From 93e8e665524f702bf4f1a8eb02ad9cafebfa4993 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 4 Jan 2013 22:02:26 +0100 Subject: [PATCH 078/180] Bug 826625 - Group rss/pss/vsize entries by filename in about:memory. r=jlebar --- xpcom/base/MapsMemoryReporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xpcom/base/MapsMemoryReporter.cpp b/xpcom/base/MapsMemoryReporter.cpp index 2a2f247dbece..2ef4c2667f10 100644 --- a/xpcom/base/MapsMemoryReporter.cpp +++ b/xpcom/base/MapsMemoryReporter.cpp @@ -412,7 +412,7 @@ MapsReporter::GetReporterNameAndDescription( "by brk() / sbrk()."); } - aName.Append(" ["); + aName.Append("/["); aName.Append(aPerms); aName.Append("]"); From 9a55db7b612ceaa09a44b63ff0703af0ebe34cf0 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 4 Jan 2013 13:57:27 -0500 Subject: [PATCH 079/180] Bug 826779 - Get DMD to build on Windows; r=bbondy --- memory/replace/dmd/DMD.cpp | 26 ++++++++++++++++++-------- memory/replace/dmd/Makefile.in | 4 ++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index 24342660033e..e6059182dca0 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -15,10 +15,8 @@ #include #ifdef XP_WIN -#error "Windows not supported yet, sorry." -// XXX: This will be needed when Windows is supported (bug 819839). -//#include -//#define getpid _getpid +#include +#include #else #include #endif @@ -42,7 +40,21 @@ // PAGE_SIZE. Nb: sysconf() is expensive, but it's only used for (the obsolete // and rarely used) valloc. #define MOZ_REPLACE_ONLY_MEMALIGN 1 +#ifdef XP_WIN +#define PAGE_SIZE GetPageSize() +static long GetPageSize() +{ + SYSTEM_INFO si; + GetSystemInfo(&si); + return si.dwPageSize; +} +static void* valloc(size_t size) +{ + return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); +} +#else #define PAGE_SIZE sysconf(_SC_PAGESIZE) +#endif #include "replace_malloc.h" #undef MOZ_REPLACE_ONLY_MEMALIGN #undef PAGE_SIZE @@ -275,8 +287,6 @@ static const size_t kNoSize = size_t(-1); // MutexBase implements the platform-specific parts of a mutex. #ifdef XP_WIN -#include - class MutexBase { CRITICAL_SECTION mCS; @@ -407,9 +417,9 @@ public: #ifdef XP_WIN #define DMD_TLS_INDEX_TYPE DWORD -#define DMD_CREATE_TLS_INDEX(i_) PR_BEGIN_MACRO \ +#define DMD_CREATE_TLS_INDEX(i_) do { \ (i_) = TlsAlloc(); \ - PR_END_MACRO + } while (0) #define DMD_DESTROY_TLS_INDEX(i_) TlsFree((i_)) #define DMD_GET_TLS_DATA(i_) TlsGetValue((i_)) #define DMD_SET_TLS_DATA(i_, v_) TlsSetValue((i_), (v_)) diff --git a/memory/replace/dmd/Makefile.in b/memory/replace/dmd/Makefile.in index 9d1424f0336a..bfa5f7eafbcd 100644 --- a/memory/replace/dmd/Makefile.in +++ b/memory/replace/dmd/Makefile.in @@ -35,5 +35,9 @@ MOZ_GLUE_LDFLAGS= STL_FLAGS = +ifeq ($(OS_ARCH),WINNT) +OS_LIBS += $(call EXPAND_LIBNAME,dbghelp) +endif + include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/rules.mk From bb1df4e10b255f10f97cc052ce020aa1b5ff3724 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2013 16:24:50 -0500 Subject: [PATCH 080/180] Bug 826381 - Update test to go with cset 11f420dd6b47. r=fix-test --- mobile/android/base/tests/testBookmark.java.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/android/base/tests/testBookmark.java.in b/mobile/android/base/tests/testBookmark.java.in index 0d226136d06e..9925b55d3292 100644 --- a/mobile/android/base/tests/testBookmark.java.in +++ b/mobile/android/base/tests/testBookmark.java.in @@ -27,7 +27,7 @@ public class testBookmark extends PixelTest { private String[] defaultBookmarks = new String[] { "about:firefox", "about:home", - "http://support.mozilla.org/en-US/mobile", + "http://support.mozilla.org/en-US/products/mobile", "https://addons.mozilla.org/en-US/android/" }; From c83f321ef0a773d7c01caae8819d9af080922ca2 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Fri, 4 Jan 2013 13:11:27 -0700 Subject: [PATCH 081/180] Bug 824067 - Disable robocop testPasswordEncrypt for too many intermittent failures; DONTBUILD --- mobile/android/base/tests/robocop.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/android/base/tests/robocop.ini b/mobile/android/base/tests/robocop.ini index e9611f16faa6..eaeaf81b1cab 100644 --- a/mobile/android/base/tests/robocop.ini +++ b/mobile/android/base/tests/robocop.ini @@ -16,7 +16,7 @@ # [testAboutPage] # see bug 770483 [testWebContentContextMenu] [testPasswordProvider] -[testPasswordEncrypt] +# [testPasswordEncrypt] # see bug 824067 [testFormHistory] [testBrowserProvider] [testSearchSuggestions] From 19cc88082ddeff6dc88d1c2bdd683c964f0b83c6 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 4 Jan 2013 13:28:37 -0800 Subject: [PATCH 082/180] Bug 824224: Always log protocol errors. r=bent --- ipc/glue/AsyncChannel.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ipc/glue/AsyncChannel.cpp b/ipc/glue/AsyncChannel.cpp index 93001f9b39da..e4e37f3c2b5d 100644 --- a/ipc/glue/AsyncChannel.cpp +++ b/ipc/glue/AsyncChannel.cpp @@ -570,10 +570,8 @@ AsyncChannel::Clear() static void PrintErrorMessage(bool isChild, const char* channelName, const char* msg) { - if (LoggingEnabled()) { - printf_stderr("\n###!!! [%s][%s] Error: %s\n\n", - isChild ? "Child" : "Parent", channelName, msg); - } + printf_stderr("\n###!!! [%s][%s] Error: %s\n\n", + isChild ? "Child" : "Parent", channelName, msg); } bool From 36428f7dd6f0c0e1a7c767ea5b3da21b36332804 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 4 Jan 2013 13:28:37 -0800 Subject: [PATCH 083/180] Bug 824224: Make mozalloc_abort() not MOZ_NORETURN and log errors to logcat. r=glandium --- memory/mozalloc/mozalloc_abort.cpp | 11 +++++++++-- memory/mozalloc/mozalloc_abort.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/memory/mozalloc/mozalloc_abort.cpp b/memory/mozalloc/mozalloc_abort.cpp index 3b6a1919d695..e1513f027f59 100644 --- a/memory/mozalloc/mozalloc_abort.cpp +++ b/memory/mozalloc/mozalloc_abort.cpp @@ -9,17 +9,24 @@ # define MOZALLOC_EXPORT __declspec(dllexport) #endif -#include "mozilla/Assertions.h" +#include "mozilla/mozalloc_abort.h" +#ifdef ANDROID +# include +#endif #include -#include "mozilla/mozalloc_abort.h" +#include "mozilla/Assertions.h" void mozalloc_abort(const char* const msg) { +#ifndef ANDROID fputs(msg, stderr); fputs("\n", stderr); +#else + __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg); +#endif MOZ_CRASH(); } diff --git a/memory/mozalloc/mozalloc_abort.h b/memory/mozalloc/mozalloc_abort.h index d68fd8231413..9369d2bde02a 100644 --- a/memory/mozalloc/mozalloc_abort.h +++ b/memory/mozalloc/mozalloc_abort.h @@ -27,7 +27,7 @@ * Terminate this process in such a way that breakpad is triggered, if * at all possible. */ -MOZ_NORETURN MOZALLOC_EXPORT void mozalloc_abort(const char* const msg); +MOZALLOC_EXPORT void mozalloc_abort(const char* const msg); #endif /* ifndef mozilla_mozalloc_abort_h */ From 4da7f9b90e2014fd6b365b00d3348f3789fe0a29 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 4 Jan 2013 16:32:58 -0500 Subject: [PATCH 084/180] Bug 826381 - Update more tests to go with cset 11f420dd6b47. r=fix-test --- mobile/android/base/tests/testAllPagesTab.java.in | 2 +- mobile/android/base/tests/testBookmarksTab.java.in | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/mobile/android/base/tests/testAllPagesTab.java.in b/mobile/android/base/tests/testAllPagesTab.java.in index c6c2eba3e807..671976fa509c 100644 --- a/mobile/android/base/tests/testAllPagesTab.java.in +++ b/mobile/android/base/tests/testAllPagesTab.java.in @@ -35,7 +35,7 @@ public class testAllPagesTab extends BaseTest { private String[] bookmarks = new String[] { "about:firefox", "about:home", - "http://support.mozilla.org/en-US/mobile", + "http://support.mozilla.org/en-US/products/mobile", "https://addons.mozilla.org/en-US/android/" }; diff --git a/mobile/android/base/tests/testBookmarksTab.java.in b/mobile/android/base/tests/testBookmarksTab.java.in index f3d37b7ae84a..a28dd2383fa4 100644 --- a/mobile/android/base/tests/testBookmarksTab.java.in +++ b/mobile/android/base/tests/testBookmarksTab.java.in @@ -28,12 +28,6 @@ import java.io.File; */ public class testBookmarksTab extends BaseTest { - private String[] defaultBookmarksUrls = new String[] { - "about:firefox", - "about:home", - "http://support.mozilla.org/en-US/mobile", - "https://addons.mozilla.org/en-US/android/" - }; private View mFirstChild; @Override From 96c005f6f92744049bbc8166063b6bde84a581a3 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 3 Jan 2013 16:21:44 -0500 Subject: [PATCH 085/180] Bug 826439 - use floats instead of doubles for exponential histogram statistic calculations; r=vdjeric --- ipc/chromium/src/base/histogram.cc | 2 +- .../components/telemetry/tests/unit/test_nsITelemetry.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index 90da947926fd..3123f0f8fb25 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -746,7 +746,7 @@ void Histogram::SampleSet::AccumulateWithExponentialStats(Sample value, size_t index) { Accumulate(value, count, index); DCHECK_GE(value, 0); - double value_log = log(static_cast(value) + 1); + float value_log = logf(static_cast(value) + 1.0f); log_sum_ += count * value_log; log_sum_squares_ += count * value_log * value_log; } diff --git a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js index 6a66fe39753f..928096ac2193 100644 --- a/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js +++ b/toolkit/components/telemetry/tests/unit/test_nsITelemetry.js @@ -30,8 +30,11 @@ function test_histogram(histogram_type, name, min, max, bucket_count) { // verify properties do_check_eq(sum, s.sum); if (histogram_type == Telemetry.HISTOGRAM_EXPONENTIAL) { - do_check_eq(log_sum, s.log_sum); - do_check_eq(log_sum_squares, s.log_sum_squares); + // We do the log with float precision in C++ and double precision in + // JS, so there's bound to be tiny discrepancies. Just check the + // integer part. + do_check_eq(Math.floor(log_sum), Math.floor(s.log_sum)); + do_check_eq(Math.floor(log_sum_squares), Math.floor(s.log_sum_squares)); do_check_false("sum_squares_lo" in s); do_check_false("sum_squares_hi" in s); } else { From 6b9f00f448c681d07a7f9a6884de8ee83a2b0d6d Mon Sep 17 00:00:00 2001 From: Jeff Hammel Date: Fri, 4 Jan 2013 13:55:29 -0800 Subject: [PATCH 086/180] Bug 811527 - generate_diff.py does not ensure that m-c mirror of mozbase is internally compatible;r=wlach ; DONTBUILD because NPOTB --- testing/mozbase/generate_diff.py | 95 +++++++++++++++++++++++++++- testing/mozbase/setup_development.py | 38 +++++++---- 2 files changed, 118 insertions(+), 15 deletions(-) diff --git a/testing/mozbase/generate_diff.py b/testing/mozbase/generate_diff.py index b1e612e03f11..72f39efbe6cc 100755 --- a/testing/mozbase/generate_diff.py +++ b/testing/mozbase/generate_diff.py @@ -22,8 +22,7 @@ files that show up in `hg st`. See: https://bugzilla.mozilla.org/show_bug.cgi?id=702832 """ -from __future__ import with_statement - +import imp import optparse import os import re @@ -32,12 +31,17 @@ import subprocess import sys import tempfile +from pkg_resources import parse_version from subprocess import check_call as call # globals here = os.path.dirname(os.path.abspath(__file__)) MOZBASE = 'git://github.com/mozilla/mozbase.git' version_regex = r"""PACKAGE_VERSION *= *['"]([0-9.]+)["'].*""" +setup_development = imp.load_source('setup_development', + os.path.join(here, 'setup_development.py')) +current_package = None +current_package_info = {} def error(msg): """err out with a message""" @@ -123,6 +127,51 @@ def parse_versions(*args): def version_tag(directory, version): return '%s-%s' % (directory, version) +def setup(**kwargs): + """monkey-patch function for setuptools.setup""" + assert current_package + current_package_info[current_package] = kwargs + +def check_consistency(*package_info): + """checks consistency between a set of packages""" + + # set versions and dependencies per package + versions = {} + dependencies = {} + for package in package_info: + name = package['name'] + versions[name] = package['version'] + for dep in package.get('install_requires', []): + dependencies.setdefault(name, []).append(dep) + + func_map = {'==': tuple.__eq__, + '<=': tuple.__le__, + '>=': tuple.__ge__} + + # check dependencies + errors = [] + for package, deps in dependencies.items(): + for dep in deps: + parsed = setup_development.dependency_info(dep) + if parsed['Name'] not in versions: + # external dependency + continue + if parsed.get('Version') is None: + # no version specified for dependency + continue + + # check versions + func = func_map[parsed['Type']] + comparison = func(parse_version(versions[parsed['Name']]), + parse_version(parsed['Version'])) + + if not comparison: + # an error + errors.append("Dependency for package '%s' failed: %s-%s not %s %s" % (package, parsed['Name'], versions[parsed['Name']], parsed['Type'], parsed['Version'])) + + # raise an Exception if errors exist + if errors: + raise Exception('\n'.join(errors)) ### @@ -151,6 +200,24 @@ def main(args=sys.argv[1:]): parser.exit() output = options.output + # gather info from current mozbase packages + global current_package + setuptools = sys.modules.get('setuptools') + sys.modules['setuptools'] = sys.modules[__name__] + try: + for package in setup_development.mozbase_packages: + current_package = package + imp.load_source('setup', os.path.join(here, package, 'setup.py')) + finally: + current_package = None + sys.modules.pop('setuptools') + if setuptools: + sys.modules['setuptools'] = setuptools + assert set(current_package_info.keys()) == set(setup_development.mozbase_packages) + + # check consistency of current set of packages + check_consistency(*current_package_info.values()) + # calculate hg root hg_root = os.path.dirname(os.path.dirname(here)) # testing/mozbase hg_dir = os.path.join(hg_root, '.hg') @@ -203,6 +270,30 @@ def main(args=sys.argv[1:]): if tag not in _tags: error("Tag for '%s' -- %s -- not in tags") + # ensure that the versions to mirror are compatible with what is in m-c + old_package_info = current_package_info.copy() + setuptools = sys.modules.get('setuptools') + sys.modules['setuptools'] = sys.modules[__name__] + try: + for directory, version in versions: + + # checkout appropriate revision of mozbase + tag = version_tag(directory, version) + checkout(src, tag) + + # update the package information + setup_py = os.path.join(src, directory, 'setup.py') + current_package = directory + imp.load_source('setup', setup_py) + finally: + current_package = None + sys.modules.pop('setuptools') + if setuptools: + sys.modules['setuptools'] = setuptools + checkout(src, 'HEAD') + current_package_info['mozprocess']['version'] = '0.9' + check_consistency(*current_package_info.values()) + # copy mozbase directories to m-c for directory, version in versions: diff --git a/testing/mozbase/setup_development.py b/testing/mozbase/setup_development.py index 3e8d9fbacdca..db1f35ed3e5f 100755 --- a/testing/mozbase/setup_development.py +++ b/testing/mozbase/setup_development.py @@ -15,9 +15,9 @@ See https://wiki.mozilla.org/Auto-tools/Projects/MozBase import pkg_resources import os +import subprocess import sys from optparse import OptionParser - from subprocess import PIPE try: from subprocess import check_call as call @@ -29,8 +29,9 @@ except ImportError: here = os.path.dirname(os.path.abspath(__file__)) # all python packages -all_packages = [i for i in os.listdir(here) - if os.path.exists(os.path.join(here, i, 'setup.py'))] +mozbase_packages = [i for i in os.listdir(here) + if os.path.exists(os.path.join(here, i, 'setup.py'))] +extra_packages = ["sphinx"] def cycle_check(order, dependencies): """ensure no cyclic dependencies""" @@ -46,7 +47,11 @@ def info(directory): assert os.path.exists(os.path.join(directory, 'setup.py')) # setup the egg info - call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=PIPE) + try: + call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=PIPE) + except subprocess.CalledProcessError: + print "Error running setup.py in %s" % directory + raise # get the .egg-info directory egg_info = [entry for entry in os.listdir(directory) @@ -148,12 +153,15 @@ def main(args=sys.argv[1:]): help="list what will be installed") options, packages = parser.parse_args(args) + install_extra_packages = False + if not packages: # install all packages - packages = sorted(all_packages) + packages = sorted(mozbase_packages) + install_extra_packages = True # ensure specified packages are in the list - assert set(packages).issubset(all_packages), "Packages should be in %s (You gave: %s)" % (all_packages, packages) + assert set(packages).issubset(mozbase_packages), "Packages should be in %s (You gave: %s)" % (mozbase_packages, packages) if options.list_dependencies: # list the package dependencies @@ -182,7 +190,7 @@ def main(args=sys.argv[1:]): flag = False for value in deps.values(): for dep in value: - if dep in all_packages and dep not in deps: + if dep in mozbase_packages and dep not in deps: key, value = get_dependencies(os.path.join(here, dep)) deps[key] = [sanitize_dependency(dep) for dep in value] @@ -195,7 +203,7 @@ def main(args=sys.argv[1:]): break # get the remaining names for the mapping - for package in all_packages: + for package in mozbase_packages: if package in mapping: continue key, value = get_dependencies(os.path.join(here, package)) @@ -216,8 +224,12 @@ def main(args=sys.argv[1:]): print package parser.exit() + # set up the packages for development + for package in unrolled: + call([sys.executable, 'setup.py', 'develop', '--no-deps'], + cwd=os.path.join(here, reverse_mapping[package])) + # install non-mozbase dependencies - # (currently none on modern python) # these need to be installed separately and the --no-deps flag # subsequently used due to a bug in setuptools; see # https://bugzilla.mozilla.org/show_bug.cgi?id=759836 @@ -227,10 +239,10 @@ def main(args=sys.argv[1:]): # easy_install should be available since we rely on setuptools call(['easy_install', version]) - # set up the packages for development - for package in unrolled: - call([sys.executable, 'setup.py', 'develop', '--no-deps'], - cwd=os.path.join(here, reverse_mapping[package])) + # install extra non-mozbase packages if desired + if install_extra_packages: + for package in extra_packages: + call(['easy_install', package]) if __name__ == '__main__': main() From fad4a3787c715e9d2ba9eeeb0767e4f41c542b85 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:04 -0500 Subject: [PATCH 087/180] Bug 824327: Add a namespaced version of NS_NewSVGXXXElement r=bz --- content/svg/content/src/nsSVGElement.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index 19b210ed230b..6f802305753d 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -640,6 +640,25 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ return rv; \ } +#define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(_elementName) \ +nsresult \ +NS_NewSVG##_elementName##Element(nsIContent **aResult, \ + already_AddRefed aNodeInfo) \ +{ \ + nsRefPtr it = \ + new mozilla::dom::SVG##_elementName##Element(aNodeInfo); \ + \ + nsresult rv = it->Init(); \ + \ + if (NS_FAILED(rv)) { \ + return rv; \ + } \ + \ + it.forget(aResult); \ + \ + return rv; \ +} + #define NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(_elementName) \ nsresult \ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ From b3c0addb84229615b7529b482c7d3ae5ae9581ca Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:05 -0500 Subject: [PATCH 088/180] Bug 824327: Convert SVGDescElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGDescElement.cpp => content/svg/content/src/SVGDescElement.cpp rename : content/svg/content/src/nsSVGDescElement.cpp => content/svg/content/src/SVGDescElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGDescElement.cpp | 50 +++++++++++++ content/svg/content/src/SVGDescElement.h | 52 ++++++++++++++ content/svg/content/src/nsSVGDescElement.cpp | 76 -------------------- dom/webidl/SVGDescElement.webidl | 15 ++++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 content/svg/content/src/SVGDescElement.cpp create mode 100644 content/svg/content/src/SVGDescElement.h delete mode 100644 content/svg/content/src/nsSVGDescElement.cpp create mode 100644 dom/webidl/SVGDescElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index d108e94c186c..b7fa04ced7ae 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -45,7 +45,6 @@ CPPSRCS = \ nsSVGClipPathElement.cpp \ nsSVGDataParser.cpp \ nsSVGDefsElement.cpp \ - nsSVGDescElement.cpp \ nsSVGElement.cpp \ nsSVGElementFactory.cpp \ nsSVGEllipseElement.cpp \ @@ -122,6 +121,7 @@ CPPSRCS = \ nsSVGSetElement.cpp \ SVGAttrValueWrapper.cpp \ SVGContentUtils.cpp \ + SVGDescElement.cpp \ SVGIntegerPairSMILType.cpp \ SVGLengthListSMILType.cpp \ SVGMotionSMILType.cpp \ @@ -154,6 +154,7 @@ EXPORTS_mozilla/dom = \ SVGAngle.h \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ + SVGDescElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/src/SVGDescElement.cpp b/content/svg/content/src/SVGDescElement.cpp new file mode 100644 index 000000000000..cf1bba764011 --- /dev/null +++ b/content/svg/content/src/SVGDescElement.cpp @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGDescElement.h" +#include "mozilla/dom/SVGDescElementBinding.h" + +DOMCI_NODE_DATA(SVGDescElement, mozilla::dom::SVGDescElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Desc) + +namespace mozilla { +namespace dom { + +JSObject* +SVGDescElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGDescElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGDescElement, SVGDescElementBase) +NS_IMPL_RELEASE_INHERITED(SVGDescElement, SVGDescElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGDescElement) + NS_NODE_INTERFACE_TABLE4(SVGDescElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGDescElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement) +NS_INTERFACE_MAP_END_INHERITING(SVGDescElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGDescElement::SVGDescElement(already_AddRefed aNodeInfo) + : SVGDescElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDescElement) + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGDescElement.h b/content/svg/content/src/SVGDescElement.h new file mode 100644 index 000000000000..f259b8922934 --- /dev/null +++ b/content/svg/content/src/SVGDescElement.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGDescElement_h +#define mozilla_dom_SVGDescElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGDescElement.h" + +nsresult NS_NewSVGDescElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGDescElementBase; + +namespace mozilla { +namespace dom { + +class SVGDescElement MOZ_FINAL : public SVGDescElementBase, + public nsIDOMSVGDescElement +{ +protected: + friend nsresult (::NS_NewSVGDescElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGDescElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGDESCELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGDescElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGDescElement_h + diff --git a/content/svg/content/src/nsSVGDescElement.cpp b/content/svg/content/src/nsSVGDescElement.cpp deleted file mode 100644 index 81c158ec49cf..000000000000 --- a/content/svg/content/src/nsSVGDescElement.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsIDOMSVGDescElement.h" - -typedef nsSVGElement nsSVGDescElementBase; - -class nsSVGDescElement : public nsSVGDescElementBase, - public nsIDOMSVGDescElement -{ -protected: - friend nsresult NS_NewSVGDescElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGDescElement(already_AddRefed aNodeInfo); - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGDESCELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDescElementBase::) - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Desc) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGDescElement, nsSVGDescElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGDescElement, nsSVGDescElementBase) - -DOMCI_NODE_DATA(SVGDescElement, nsSVGDescElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGDescElement) - NS_NODE_INTERFACE_TABLE4(nsSVGDescElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGDescElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGDescElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -nsSVGDescElement::nsSVGDescElement(already_AddRefed aNodeInfo) - : nsSVGDescElementBase(aNodeInfo) -{ -} - - -nsresult -nsSVGDescElement::Init() -{ - return nsSVGDescElementBase::Init(); -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDescElement) - diff --git a/dom/webidl/SVGDescElement.webidl b/dom/webidl/SVGDescElement.webidl new file mode 100644 index 000000000000..1841ff54585d --- /dev/null +++ b/dom/webidl/SVGDescElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGDescElement : SVGElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 05ef83eee284..2df530c21b23 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -96,6 +96,7 @@ webidl_files = \ SVGAnimatedNumberList.webidl \ SVGAnimatedPreserveAspectRatio.webidl \ SVGAnimatedTransformList.webidl \ + SVGDescElement.webidl \ SVGElement.webidl \ SVGLengthList.webidl \ SVGMatrix.webidl \ From fd80af77b5b05d4a488ddee6c881b9e6ccd3ea17 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:05 -0500 Subject: [PATCH 089/180] Bug 824327: Convert SVGTitleElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGTitleElement.cpp => content/svg/content/src/SVGTitleElement.cpp rename : content/svg/content/src/nsSVGTitleElement.cpp => content/svg/content/src/SVGTitleElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGTitleElement.cpp | 131 +++++++++++++ content/svg/content/src/SVGTitleElement.h | 69 +++++++ content/svg/content/src/nsSVGTitleElement.cpp | 173 ------------------ dom/bindings/Bindings.conf | 4 + dom/webidl/SVGTitleElement.webidl | 15 ++ dom/webidl/WebIDL.mk | 1 + 7 files changed, 222 insertions(+), 174 deletions(-) create mode 100644 content/svg/content/src/SVGTitleElement.cpp create mode 100644 content/svg/content/src/SVGTitleElement.h delete mode 100644 content/svg/content/src/nsSVGTitleElement.cpp create mode 100644 dom/webidl/SVGTitleElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index b7fa04ced7ae..52acd6df50cd 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -87,7 +87,6 @@ CPPSRCS = \ nsSVGTextElement.cpp \ nsSVGTextPathElement.cpp \ nsSVGTextPositioningElement.cpp \ - nsSVGTitleElement.cpp \ nsSVGUnknownElement.cpp \ nsSVGUseElement.cpp \ nsSVGViewBox.cpp \ @@ -110,6 +109,7 @@ CPPSRCS = \ SVGPointList.cpp \ SVGPreserveAspectRatio.cpp \ SVGStringList.cpp \ + SVGTitleElement.cpp \ SVGTransform.cpp \ SVGTransformList.cpp \ SVGTransformListParser.cpp \ @@ -155,6 +155,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ SVGDescElement.h \ + SVGTitleElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/src/SVGTitleElement.cpp b/content/svg/content/src/SVGTitleElement.cpp new file mode 100644 index 000000000000..8d80be1ab114 --- /dev/null +++ b/content/svg/content/src/SVGTitleElement.cpp @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGTitleElement.h" +#include "mozilla/dom/SVGTitleElementBinding.h" + +DOMCI_NODE_DATA(SVGTitleElement, mozilla::dom::SVGTitleElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Title) + +namespace mozilla { +namespace dom { + +JSObject* +SVGTitleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGTitleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGTitleElement, SVGTitleElementBase) +NS_IMPL_RELEASE_INHERITED(SVGTitleElement, SVGTitleElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGTitleElement) + NS_NODE_INTERFACE_TABLE4(SVGTitleElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, + nsIMutationObserver) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement) +NS_INTERFACE_MAP_END_INHERITING(SVGTitleElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGTitleElement::SVGTitleElement(already_AddRefed aNodeInfo) + : SVGTitleElementBase(aNodeInfo) +{ + SetIsDOMBinding(); + AddMutationObserver(this); +} + +void +SVGTitleElement::CharacterDataChanged(nsIDocument *aDocument, + nsIContent *aContent, + CharacterDataChangeInfo *aInfo) +{ + SendTitleChangeEvent(false); +} + +void +SVGTitleElement::ContentAppended(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aFirstNewContent, + int32_t aNewIndexInContainer) +{ + SendTitleChangeEvent(false); +} + +void +SVGTitleElement::ContentInserted(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aChild, + int32_t aIndexInContainer) +{ + SendTitleChangeEvent(false); +} + +void +SVGTitleElement::ContentRemoved(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aChild, + int32_t aIndexInContainer, + nsIContent *aPreviousSibling) +{ + SendTitleChangeEvent(false); +} + +nsresult +SVGTitleElement::BindToTree(nsIDocument *aDocument, + nsIContent *aParent, + nsIContent *aBindingParent, + bool aCompileEventHandlers) +{ + // Let this fall through. + nsresult rv = SVGTitleElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + SendTitleChangeEvent(true); + + return NS_OK; +} + +void +SVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent) +{ + SendTitleChangeEvent(false); + + // Let this fall through. + SVGTitleElementBase::UnbindFromTree(aDeep, aNullParent); +} + +void +SVGTitleElement::DoneAddingChildren(bool aHaveNotified) +{ + if (!aHaveNotified) { + SendTitleChangeEvent(false); + } +} + +void +SVGTitleElement::SendTitleChangeEvent(bool aBound) +{ + nsIDocument* doc = GetCurrentDoc(); + if (doc) { + doc->NotifyPossibleTitleChange(aBound); + } +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement) + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGTitleElement.h b/content/svg/content/src/SVGTitleElement.h new file mode 100644 index 000000000000..dc51df00c139 --- /dev/null +++ b/content/svg/content/src/SVGTitleElement.h @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGTitleElement_h +#define mozilla_dom_SVGTitleElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGTitleElement.h" +#include "nsStubMutationObserver.h" + +typedef nsSVGElement SVGTitleElementBase; + +nsresult NS_NewSVGTitleElement(nsIContent **aResult, + already_AddRefed aNodeInfo); +namespace mozilla { +namespace dom { + +class SVGTitleElement MOZ_FINAL : public SVGTitleElementBase, + public nsStubMutationObserver, + public nsIDOMSVGTitleElement +{ +protected: + friend nsresult (::NS_NewSVGTitleElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGTitleElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGTitleElementBase::) + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, + nsIContent *aBindingParent, + bool aCompileEventHandlers); + + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true); + + virtual void DoneAddingChildren(bool aHaveNotified); + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +private: + void SendTitleChangeEvent(bool aBound); +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGTitleElement_h + diff --git a/content/svg/content/src/nsSVGTitleElement.cpp b/content/svg/content/src/nsSVGTitleElement.cpp deleted file mode 100644 index e6a19bb299cf..000000000000 --- a/content/svg/content/src/nsSVGTitleElement.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsIDOMSVGTitleElement.h" -#include "nsStubMutationObserver.h" - -typedef nsSVGElement nsSVGTitleElementBase; - -class nsSVGTitleElement : public nsSVGTitleElementBase, - public nsIDOMSVGTitleElement, - public nsStubMutationObserver -{ -protected: - friend nsresult NS_NewSVGTitleElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGTitleElement(already_AddRefed aNodeInfo); - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGTITLEELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::) - - // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, - nsIContent *aBindingParent, - bool aCompileEventHandlers); - - virtual void UnbindFromTree(bool aDeep = true, - bool aNullParent = true); - - virtual void DoneAddingChildren(bool aHaveNotified); - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -private: - void SendTitleChangeEvent(bool aBound); -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Title) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase) - -DOMCI_NODE_DATA(SVGTitleElement, nsSVGTitleElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement) - NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGTitleElement, - nsIMutationObserver) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -nsSVGTitleElement::nsSVGTitleElement(already_AddRefed aNodeInfo) - : nsSVGTitleElementBase(aNodeInfo) -{ - AddMutationObserver(this); -} - -nsresult -nsSVGTitleElement::Init() -{ - return nsSVGTitleElementBase::Init(); -} - -void -nsSVGTitleElement::CharacterDataChanged(nsIDocument *aDocument, - nsIContent *aContent, - CharacterDataChangeInfo *aInfo) -{ - SendTitleChangeEvent(false); -} - -void -nsSVGTitleElement::ContentAppended(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aFirstNewContent, - int32_t aNewIndexInContainer) -{ - SendTitleChangeEvent(false); -} - -void -nsSVGTitleElement::ContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - int32_t aIndexInContainer) -{ - SendTitleChangeEvent(false); -} - -void -nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - int32_t aIndexInContainer, - nsIContent *aPreviousSibling) -{ - SendTitleChangeEvent(false); -} - -nsresult -nsSVGTitleElement::BindToTree(nsIDocument *aDocument, - nsIContent *aParent, - nsIContent *aBindingParent, - bool aCompileEventHandlers) -{ - // Let this fall through. - nsresult rv = nsSVGTitleElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); - NS_ENSURE_SUCCESS(rv, rv); - - SendTitleChangeEvent(true); - - return NS_OK; -} - -void -nsSVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent) -{ - SendTitleChangeEvent(false); - - // Let this fall through. - nsSVGTitleElementBase::UnbindFromTree(aDeep, aNullParent); -} - -void -nsSVGTitleElement::DoneAddingChildren(bool aHaveNotified) -{ - if (!aHaveNotified) { - SendTitleChangeEvent(false); - } -} - -void -nsSVGTitleElement::SendTitleChangeEvent(bool aBound) -{ - nsIDocument* doc = GetCurrentDoc(); - if (doc) { - doc->NotifyPossibleTitleChange(aBound); - } -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index ecfc1c3feb4d..59c9ce6d4fb9 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -716,6 +716,10 @@ DOMInterfaces = { 'headerFile': 'SVGPreserveAspectRatio.h' }, +'SVGTitleElement': { + 'hasInstanceInterface': 'nsIDOMSVGTitleElement', +}, + 'SVGTransform': { 'nativeType': 'mozilla::DOMSVGTransform', 'headerFile': 'DOMSVGTransform.h' diff --git a/dom/webidl/SVGTitleElement.webidl b/dom/webidl/SVGTitleElement.webidl new file mode 100644 index 000000000000..d40c63373ea7 --- /dev/null +++ b/dom/webidl/SVGTitleElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGTitleElement : SVGElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 2df530c21b23..abfb2486e1b2 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -106,6 +106,7 @@ webidl_files = \ SVGPoint.webidl \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ + SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ Text.webidl \ From 66927a4c04ee2974d0a11009d3bf2a6f6de339d7 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:05 -0500 Subject: [PATCH 090/180] Bug 824327: Convert SVGStopElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGStopElement.cpp => content/svg/content/src/SVGStopElement.cpp rename : content/svg/content/src/nsSVGStopElement.cpp => content/svg/content/src/SVGStopElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGStopElement.cpp | 93 +++++++++++++++ content/svg/content/src/SVGStopElement.h | 65 ++++++++++ content/svg/content/src/nsSVGStopElement.cpp | 118 ------------------- dom/bindings/Bindings.conf | 1 + dom/webidl/SVGStopElement.webidl | 18 +++ dom/webidl/WebIDL.mk | 1 + 7 files changed, 180 insertions(+), 119 deletions(-) create mode 100644 content/svg/content/src/SVGStopElement.cpp create mode 100644 content/svg/content/src/SVGStopElement.h delete mode 100644 content/svg/content/src/nsSVGStopElement.cpp create mode 100644 dom/webidl/SVGStopElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 52acd6df50cd..54a2a416ce2e 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -78,7 +78,6 @@ CPPSRCS = \ nsSVGRect.cpp \ nsSVGRectElement.cpp \ nsSVGSVGElement.cpp \ - nsSVGStopElement.cpp \ nsSVGStyleElement.cpp \ nsSVGSwitchElement.cpp \ nsSVGSymbolElement.cpp \ @@ -133,6 +132,7 @@ CPPSRCS = \ SVGOrientSMILType.cpp \ SVGPathSegListSMILType.cpp \ SVGPointListSMILType.cpp \ + SVGStopElement.cpp \ SVGTransformListSMILType.cpp \ SVGViewBoxSMILType.cpp \ $(NULL) @@ -155,6 +155,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ SVGDescElement.h \ + SVGStopElement.h \ SVGTitleElement.h \ $(NULL) diff --git a/content/svg/content/src/SVGStopElement.cpp b/content/svg/content/src/SVGStopElement.cpp new file mode 100644 index 000000000000..0f0327d45f1d --- /dev/null +++ b/content/svg/content/src/SVGStopElement.cpp @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGStopElement.h" +#include "mozilla/dom/SVGStopElementBinding.h" + +DOMCI_NODE_DATA(SVGStopElement, mozilla::dom::SVGStopElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Stop) + +namespace mozilla { +namespace dom { + +JSObject* +SVGStopElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGStopElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +nsSVGElement::NumberInfo SVGStopElement::sNumberInfo = +{ &nsGkAtoms::offset, 0, true }; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGStopElement, SVGStopElementBase) +NS_IMPL_RELEASE_INHERITED(SVGStopElement, SVGStopElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGStopElement) + NS_NODE_INTERFACE_TABLE4(SVGStopElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGStopElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement) +NS_INTERFACE_MAP_END_INHERITING(SVGStopElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGStopElement::SVGStopElement(already_AddRefed aNodeInfo) + : SVGStopElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGStopElement methods + +/* readonly attribute nsIDOMSVGAnimatedNumber offset; */ +NS_IMETHODIMP SVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset) +{ + return mOffset.ToDOMAnimatedNumber(aOffset,this); +} + +already_AddRefed +SVGStopElement::Offset() +{ + nsCOMPtr offset; + mOffset.ToDOMAnimatedNumber(getter_AddRefs(offset), this); + return offset.forget(); +} + +//---------------------------------------------------------------------- +// sSVGElement methods + +nsSVGElement::NumberAttributesInfo +SVGStopElement::GetNumberInfo() +{ + return NumberAttributesInfo(&mOffset, &sNumberInfo, 1); +} + +//---------------------------------------------------------------------- +// nsIContent methods + +NS_IMETHODIMP_(bool) +SVGStopElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sGradientStopMap + }; + + return FindAttributeDependence(name, map) || + SVGStopElementBase::IsAttributeMapped(name); +} + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGStopElement.h b/content/svg/content/src/SVGStopElement.h new file mode 100644 index 000000000000..02968e54338c --- /dev/null +++ b/content/svg/content/src/SVGStopElement.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGStopElement_h +#define mozilla_dom_SVGStopElement_h + +#include "nsSVGElement.h" +#include "nsSVGNumber2.h" +#include "nsIDOMSVGStopElement.h" + +nsresult NS_NewSVGStopElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGStopElementBase; + +namespace mozilla { +namespace dom { + +class SVGStopElement MOZ_FINAL : public SVGStopElementBase, + public nsIDOMSVGStopElement +{ +protected: + friend nsresult (::NS_NewSVGStopElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGStopElement(already_AddRefed aNodeInfo); + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSTOPELEMENT + + // xxx If xpcom allowed virtual inheritance we wouldn't need to + // forward here :-( + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGStopElementBase::) + + // nsIContent interface + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + already_AddRefed Offset(); + +protected: + + virtual NumberAttributesInfo GetNumberInfo(); + // nsIDOMSVGStopElement properties: + nsSVGNumber2 mOffset; + static NumberInfo sNumberInfo; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGStopElement_h diff --git a/content/svg/content/src/nsSVGStopElement.cpp b/content/svg/content/src/nsSVGStopElement.cpp deleted file mode 100644 index 3c133cb81556..000000000000 --- a/content/svg/content/src/nsSVGStopElement.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Util.h" - -#include "nsSVGElement.h" -#include "nsIDOMSVGStopElement.h" -#include "nsSVGNumber2.h" -#include "nsGenericHTMLElement.h" - -using namespace mozilla; - -typedef nsSVGElement nsSVGStopElementBase; - -class nsSVGStopElement : public nsSVGStopElementBase, - public nsIDOMSVGStopElement -{ -protected: - friend nsresult NS_NewSVGStopElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGStopElement(already_AddRefed aNodeInfo); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSTOPELEMENT - - // xxx If xpcom allowed virtual inheritance we wouldn't need to - // forward here :-( - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStopElementBase::) - - // nsIContent interface - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - - virtual NumberAttributesInfo GetNumberInfo(); - // nsIDOMSVGStopElement properties: - nsSVGNumber2 mOffset; - static NumberInfo sNumberInfo; -}; - -nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo = -{ &nsGkAtoms::offset, 0, true }; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Stop) - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase) - -DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGStopElement) - NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGStopElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase) - -//---------------------------------------------------------------------- -// Implementation - -nsSVGStopElement::nsSVGStopElement(already_AddRefed aNodeInfo) - : nsSVGStopElementBase(aNodeInfo) -{ - -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement) - -//---------------------------------------------------------------------- -// nsIDOMSVGStopElement methods - -/* readonly attribute nsIDOMSVGAnimatedNumber offset; */ -NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset) -{ - return mOffset.ToDOMAnimatedNumber(aOffset,this); -} - -//---------------------------------------------------------------------- -// nsSVGElement methods - -nsSVGElement::NumberAttributesInfo -nsSVGStopElement::GetNumberInfo() -{ - return NumberAttributesInfo(&mOffset, &sNumberInfo, 1); -} - -//---------------------------------------------------------------------- -// nsIContent methods - -NS_IMETHODIMP_(bool) -nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const -{ - static const MappedAttributeEntry* const map[] = { - sGradientStopMap - }; - - return FindAttributeDependence(name, map) || - nsSVGStopElementBase::IsAttributeMapped(name); -} - - diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 59c9ce6d4fb9..0e564339cd97 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1122,6 +1122,7 @@ addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction addExternalIface('Range', nativeType='nsRange') addExternalIface('Selection', nativeType='nsISelection') addExternalIface('StyleSheetList') +addExternalIface('SVGAnimatedNumber') addExternalIface('SVGAnimatedString') addExternalIface('SVGLength') addExternalIface('SVGNumber') diff --git a/dom/webidl/SVGStopElement.webidl b/dom/webidl/SVGStopElement.webidl new file mode 100644 index 000000000000..85e19bda33ac --- /dev/null +++ b/dom/webidl/SVGStopElement.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGAnimatedNumber; + +interface SVGStopElement : SVGElement { + readonly attribute SVGAnimatedNumber offset; +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index abfb2486e1b2..cd81eac1adfa 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -106,6 +106,7 @@ webidl_files = \ SVGPoint.webidl \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ + SVGStopElement.webidl \ SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ From c42bfb2a913ac489e3acd0ed6fd837ba5a9578c3 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:05 -0500 Subject: [PATCH 091/180] Bug 824327: Convert SVGStyleElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGStyleElement.cpp => content/svg/content/src/SVGStyleElement.cpp rename : content/svg/content/src/nsSVGStyleElement.cpp => content/svg/content/src/SVGStyleElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGStyleElement.cpp | 307 +++++++++++++++ content/svg/content/src/SVGStyleElement.h | 114 ++++++ content/svg/content/src/nsSVGStyleElement.cpp | 363 ------------------ dom/webidl/SVGStyleElement.webidl | 23 ++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 447 insertions(+), 364 deletions(-) create mode 100644 content/svg/content/src/SVGStyleElement.cpp create mode 100644 content/svg/content/src/SVGStyleElement.h delete mode 100644 content/svg/content/src/nsSVGStyleElement.cpp create mode 100644 dom/webidl/SVGStyleElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 54a2a416ce2e..cababe8b1d02 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -78,7 +78,6 @@ CPPSRCS = \ nsSVGRect.cpp \ nsSVGRectElement.cpp \ nsSVGSVGElement.cpp \ - nsSVGStyleElement.cpp \ nsSVGSwitchElement.cpp \ nsSVGSymbolElement.cpp \ nsSVGTSpanElement.cpp \ @@ -133,6 +132,7 @@ CPPSRCS = \ SVGPathSegListSMILType.cpp \ SVGPointListSMILType.cpp \ SVGStopElement.cpp \ + SVGStyleElement.cpp \ SVGTransformListSMILType.cpp \ SVGViewBoxSMILType.cpp \ $(NULL) @@ -156,6 +156,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedBoolean.h \ SVGDescElement.h \ SVGStopElement.h \ + SVGStyleElement.h \ SVGTitleElement.h \ $(NULL) diff --git a/content/svg/content/src/SVGStyleElement.cpp b/content/svg/content/src/SVGStyleElement.cpp new file mode 100644 index 000000000000..bef78f677b1b --- /dev/null +++ b/content/svg/content/src/SVGStyleElement.cpp @@ -0,0 +1,307 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGStyleElement.h" +#include "nsContentUtils.h" +#include "nsStubMutationObserver.h" +#include "mozilla/dom/SVGStyleElementBinding.h" + +DOMCI_NODE_DATA(SVGStyleElement, mozilla::dom::SVGStyleElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Style) + +namespace mozilla { +namespace dom { + +JSObject* +SVGStyleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGStyleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGStyleElement, SVGStyleElementBase) +NS_IMPL_RELEASE_INHERITED(SVGStyleElement, SVGStyleElementBase) + +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGStyleElement) + NS_NODE_INTERFACE_TABLE7(SVGStyleElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGStyleElement, + nsIDOMLinkStyle, nsIStyleSheetLinkingElement, + nsIMutationObserver) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement) +NS_INTERFACE_MAP_END_INHERITING(SVGStyleElementBase) + +NS_IMPL_CYCLE_COLLECTION_CLASS(SVGStyleElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGStyleElement, + SVGStyleElementBase) + tmp->nsStyleLinkElement::Traverse(cb); +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement, + SVGStyleElementBase) + tmp->nsStyleLinkElement::Unlink(); +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + +//---------------------------------------------------------------------- +// Implementation + +SVGStyleElement::SVGStyleElement(already_AddRefed aNodeInfo) + : SVGStyleElementBase(aNodeInfo) +{ + SetIsDOMBinding(); + AddMutationObserver(this); +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement) + + +//---------------------------------------------------------------------- +// nsIContent methods + +nsresult +SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) +{ + nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal; + nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + + return rv; +} + +void +SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) +{ + nsCOMPtr oldDoc = GetCurrentDoc(); + + SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent); + UpdateStyleSheetInternal(oldDoc); +} + +nsresult +SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify) +{ + nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, + aValue, aNotify); + if (NS_SUCCEEDED(rv)) { + UpdateStyleSheetInternal(nullptr, + aNameSpaceID == kNameSpaceID_None && + (aName == nsGkAtoms::title || + aName == nsGkAtoms::media || + aName == nsGkAtoms::type)); + } + + return rv; +} + +nsresult +SVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, + bool aNotify) +{ + nsresult rv = SVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, + aNotify); + if (NS_SUCCEEDED(rv)) { + UpdateStyleSheetInternal(nullptr, + aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::title || + aAttribute == nsGkAtoms::media || + aAttribute == nsGkAtoms::type)); + } + + return rv; +} + +bool +SVGStyleElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) +{ + if (aNamespaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::crossorigin) { + ParseCORSValue(aValue, aResult); + return true; + } + + return SVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, + aResult); +} + +//---------------------------------------------------------------------- +// nsIMutationObserver methods + +void +SVGStyleElement::CharacterDataChanged(nsIDocument* aDocument, + nsIContent* aContent, + CharacterDataChangeInfo* aInfo) +{ + ContentChanged(aContent); +} + +void +SVGStyleElement::ContentAppended(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aFirstNewContent, + int32_t aNewIndexInContainer) +{ + ContentChanged(aContainer); +} + +void +SVGStyleElement::ContentInserted(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer) +{ + ContentChanged(aChild); +} + +void +SVGStyleElement::ContentRemoved(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer, + nsIContent* aPreviousSibling) +{ + ContentChanged(aChild); +} + +void +SVGStyleElement::ContentChanged(nsIContent* aContent) +{ + if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { + UpdateStyleSheetInternal(nullptr); + } +} + +//---------------------------------------------------------------------- +// nsIDOMSVGStyleElement methods + +/* attribute DOMString xmlspace; */ +NS_IMETHODIMP SVGStyleElement::GetXmlspace(nsAString & aXmlspace) +{ + GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetXmlspace(const nsAString & aXmlspace) +{ + return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); +} +void +SVGStyleElement::SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); +} + +/* attribute DOMString type; */ +NS_IMETHODIMP SVGStyleElement::GetType(nsAString & aType) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetType(const nsAString & aType) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); +} +void +SVGStyleElement::SetType(const nsAString & aType, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); +} + +/* attribute DOMString media; */ +NS_IMETHODIMP SVGStyleElement::GetMedia(nsAString & aMedia) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetMedia(const nsAString & aMedia) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); +} +void +SVGStyleElement::SetMedia(const nsAString & aMedia, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); +} + +/* attribute DOMString title; */ +NS_IMETHODIMP SVGStyleElement::GetTitle(nsAString & aTitle) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetTitle(const nsAString & aTitle) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); +} +void +SVGStyleElement::SetTitle(const nsAString & aTitle, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); +} + +//---------------------------------------------------------------------- +// nsStyleLinkElement methods + +already_AddRefed +SVGStyleElement::GetStyleSheetURL(bool* aIsInline) +{ + *aIsInline = true; + return nullptr; +} + +void +SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, + nsAString& aType, + nsAString& aMedia, + bool* aIsAlternate) +{ + *aIsAlternate = false; + + nsAutoString title; + GetAttr(kNameSpaceID_None, nsGkAtoms::title, title); + title.CompressWhitespace(); + aTitle.Assign(title); + + GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); + // The SVG spec is formulated in terms of the CSS2 spec, + // which specifies that media queries are case insensitive. + nsContentUtils::ASCIIToLower(aMedia); + + GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); + if (aType.IsEmpty()) { + aType.AssignLiteral("text/css"); + } + + return; +} + +CORSMode +SVGStyleElement::GetCORSMode() const +{ + return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); +} + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGStyleElement.h b/content/svg/content/src/SVGStyleElement.h new file mode 100644 index 000000000000..c2a3d3f4b67a --- /dev/null +++ b/content/svg/content/src/SVGStyleElement.h @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGStyleElement_h +#define mozilla_dom_SVGStyleElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGStyleElement.h" +#include "nsStyleLinkElement.h" +#include "nsStubMutationObserver.h" + +nsresult NS_NewSVGStyleElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGStyleElementBase; + +namespace mozilla { +namespace dom { + +class SVGStyleElement MOZ_FINAL : public SVGStyleElementBase, + public nsIDOMSVGStyleElement, + public nsStyleLinkElement, + public nsStubMutationObserver +{ +protected: + friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGStyleElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSTYLEELEMENT + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement, + SVGStyleElementBase) + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGStyleElementBase::) + + // nsIContent + virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers); + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true); + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAString& aValue, bool aNotify) + { + return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); + } + virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify); + virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, + bool aNotify); + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv); + void SetType(const nsAString & aType, ErrorResult& rv); + void SetMedia(const nsAString & aMedia, ErrorResult& rv); + void SetTitle(const nsAString & aTitle, ErrorResult& rv); + +protected: + // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and + // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be + // completely optimized away. + inline nsresult Init() + { + return NS_OK; + } + + // nsStyleLinkElement overrides + already_AddRefed GetStyleSheetURL(bool* aIsInline); + + void GetStyleSheetInfo(nsAString& aTitle, + nsAString& aType, + nsAString& aMedia, + bool* aIsAlternate); + virtual CORSMode GetCORSMode() const; + + /** + * Common method to call from the various mutation observer methods. + * aContent is a content node that's either the one that changed or its + * parent; we should only respond to the change if aContent is non-anonymous. + */ + void ContentChanged(nsIContent* aContent); +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGStyleElement_h diff --git a/content/svg/content/src/nsSVGStyleElement.cpp b/content/svg/content/src/nsSVGStyleElement.cpp deleted file mode 100644 index 7d43a7519a53..000000000000 --- a/content/svg/content/src/nsSVGStyleElement.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsGkAtoms.h" -#include "nsIDOMSVGStyleElement.h" -#include "nsUnicharUtils.h" -#include "nsIDocument.h" -#include "nsStyleLinkElement.h" -#include "nsContentUtils.h" -#include "nsStubMutationObserver.h" - -using namespace mozilla; - -typedef nsSVGElement nsSVGStyleElementBase; - -class nsSVGStyleElement : public nsSVGStyleElementBase, - public nsIDOMSVGStyleElement, - public nsStyleLinkElement, - public nsStubMutationObserver -{ -protected: - friend nsresult NS_NewSVGStyleElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGStyleElement(already_AddRefed aNodeInfo); - -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSTYLEELEMENT - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGStyleElement, - nsSVGStyleElementBase) - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::) - - // nsIContent - virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers); - virtual void UnbindFromTree(bool aDeep = true, - bool aNullParent = true); - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } - virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify); - virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify); - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and - // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be - // completely optimized away. - inline nsresult Init() - { - return NS_OK; - } - - // nsStyleLinkElement overrides - already_AddRefed GetStyleSheetURL(bool* aIsInline); - - void GetStyleSheetInfo(nsAString& aTitle, - nsAString& aType, - nsAString& aMedia, - bool* aIsAlternate); - virtual CORSMode GetCORSMode() const; - - /** - * Common method to call from the various mutation observer methods. - * aContent is a content node that's either the one that changed or its - * parent; we should only respond to the change if aContent is non-anonymous. - */ - void ContentChanged(nsIContent* aContent); -}; - - -NS_IMPL_NS_NEW_SVG_ELEMENT(Style) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase) - -DOMCI_NODE_DATA(SVGStyleElement, nsSVGStyleElement) - -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGStyleElement) - NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGStyleElement, - nsIDOMLinkStyle, nsIStyleSheetLinkingElement, - nsIMutationObserver) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase) - -NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGStyleElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGStyleElement, - nsSVGStyleElementBase) - tmp->nsStyleLinkElement::Traverse(cb); -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGStyleElement, - nsSVGStyleElementBase) - tmp->nsStyleLinkElement::Unlink(); -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -//---------------------------------------------------------------------- -// Implementation - -nsSVGStyleElement::nsSVGStyleElement(already_AddRefed aNodeInfo) - : nsSVGStyleElementBase(aNodeInfo) -{ - AddMutationObserver(this); -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement) - - -//---------------------------------------------------------------------- -// nsIContent methods - -nsresult -nsSVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) -{ - nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); - NS_ENSURE_SUCCESS(rv, rv); - - void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); - - return rv; -} - -void -nsSVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) -{ - nsCOMPtr oldDoc = GetCurrentDoc(); - - nsSVGStyleElementBase::UnbindFromTree(aDeep, aNullParent); - UpdateStyleSheetInternal(oldDoc); -} - -nsresult -nsSVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify) -{ - nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, - aValue, aNotify); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheetInternal(nullptr, - aNameSpaceID == kNameSpaceID_None && - (aName == nsGkAtoms::title || - aName == nsGkAtoms::media || - aName == nsGkAtoms::type)); - } - - return rv; -} - -nsresult -nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) -{ - nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, - aNotify); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheetInternal(nullptr, - aNameSpaceID == kNameSpaceID_None && - (aAttribute == nsGkAtoms::title || - aAttribute == nsGkAtoms::media || - aAttribute == nsGkAtoms::type)); - } - - return rv; -} - -bool -nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aNamespaceID == kNameSpaceID_None && - aAttribute == nsGkAtoms::crossorigin) { - ParseCORSValue(aValue, aResult); - return true; - } - - return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, - aResult); -} - -//---------------------------------------------------------------------- -// nsIMutationObserver methods - -void -nsSVGStyleElement::CharacterDataChanged(nsIDocument* aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo) -{ - ContentChanged(aContent); -} - -void -nsSVGStyleElement::ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aFirstNewContent, - int32_t aNewIndexInContainer) -{ - ContentChanged(aContainer); -} - -void -nsSVGStyleElement::ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer) -{ - ContentChanged(aChild); -} - -void -nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer, - nsIContent* aPreviousSibling) -{ - ContentChanged(aChild); -} - -void -nsSVGStyleElement::ContentChanged(nsIContent* aContent) -{ - if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { - UpdateStyleSheetInternal(nullptr); - } -} - -//---------------------------------------------------------------------- -// nsIDOMSVGStyleElement methods - -/* attribute DOMString xmlspace; */ -NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace) -{ - GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace) -{ - return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); -} - -/* attribute DOMString type; */ -NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); -} - -/* attribute DOMString media; */ -NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); -} - -/* attribute DOMString title; */ -NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); -} - -//---------------------------------------------------------------------- -// nsStyleLinkElement methods - -already_AddRefed -nsSVGStyleElement::GetStyleSheetURL(bool* aIsInline) -{ - *aIsInline = true; - return nullptr; -} - -void -nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, - nsAString& aType, - nsAString& aMedia, - bool* aIsAlternate) -{ - *aIsAlternate = false; - - nsAutoString title; - GetAttr(kNameSpaceID_None, nsGkAtoms::title, title); - title.CompressWhitespace(); - aTitle.Assign(title); - - GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - // The SVG spec is formulated in terms of the CSS2 spec, - // which specifies that media queries are case insensitive. - nsContentUtils::ASCIIToLower(aMedia); - - GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); - if (aType.IsEmpty()) { - aType.AssignLiteral("text/css"); - } - - return; -} - -CORSMode -nsSVGStyleElement::GetCORSMode() const -{ - return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); -} diff --git a/dom/webidl/SVGStyleElement.webidl b/dom/webidl/SVGStyleElement.webidl new file mode 100644 index 000000000000..07f6f3c5a691 --- /dev/null +++ b/dom/webidl/SVGStyleElement.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGStyleElement : SVGElement { + [SetterThrows] + attribute DOMString xmlspace; // Spec claims this should be on SVGElement + [SetterThrows] + attribute DOMString type; + [SetterThrows] + attribute DOMString media; + [SetterThrows] + attribute DOMString title; +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index cd81eac1adfa..97aa4aea4265 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -107,6 +107,7 @@ webidl_files = \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ SVGStopElement.webidl \ + SVGStyleElement.webidl \ SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ From cc611854d036bd09dc051d866a4b28ee6cb0fe97 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:05 -0500 Subject: [PATCH 092/180] Bug 824327: Convert SVGMetadataElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGMetadataElement.cpp => content/svg/content/src/SVGMetadataElement.cpp rename : content/svg/content/src/nsSVGMetadataElement.cpp => content/svg/content/src/SVGMetadataElement.h --- content/svg/content/src/Makefile.in | 3 +- .../svg/content/src/SVGMetadataElement.cpp | 59 +++++++++++++++ content/svg/content/src/SVGMetadataElement.h | 52 +++++++++++++ .../svg/content/src/nsSVGMetadataElement.cpp | 75 ------------------- dom/webidl/SVGMetadataElement.webidl | 15 ++++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 129 insertions(+), 76 deletions(-) create mode 100644 content/svg/content/src/SVGMetadataElement.cpp create mode 100644 content/svg/content/src/SVGMetadataElement.h delete mode 100644 content/svg/content/src/nsSVGMetadataElement.cpp create mode 100644 dom/webidl/SVGMetadataElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index cababe8b1d02..7740ba24f97e 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -63,7 +63,6 @@ CPPSRCS = \ nsSVGLineElement.cpp \ nsSVGMarkerElement.cpp \ nsSVGMaskElement.cpp \ - nsSVGMetadataElement.cpp \ nsSVGNumber2.cpp \ nsSVGNumberPair.cpp \ nsSVGPathDataParser.cpp \ @@ -122,6 +121,7 @@ CPPSRCS = \ SVGDescElement.cpp \ SVGIntegerPairSMILType.cpp \ SVGLengthListSMILType.cpp \ + SVGMetadataElement.cpp \ SVGMotionSMILType.cpp \ SVGMotionSMILAttr.cpp \ SVGMotionSMILAnimationFunction.cpp \ @@ -155,6 +155,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ SVGDescElement.h \ + SVGMetadataElement.h \ SVGStopElement.h \ SVGStyleElement.h \ SVGTitleElement.h \ diff --git a/content/svg/content/src/SVGMetadataElement.cpp b/content/svg/content/src/SVGMetadataElement.cpp new file mode 100644 index 000000000000..036113b0468c --- /dev/null +++ b/content/svg/content/src/SVGMetadataElement.cpp @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGMetadataElement.h" +#include "mozilla/dom/SVGMetadataElementBinding.h" + +DOMCI_NODE_DATA(SVGMetadataElement, mozilla::dom::SVGMetadataElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Metadata) + +namespace mozilla { +namespace dom { + +JSObject* +SVGMetadataElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGMetadataElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGMetadataElement, SVGMetadataElementBase) +NS_IMPL_RELEASE_INHERITED(SVGMetadataElement, SVGMetadataElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGMetadataElement) + NS_NODE_INTERFACE_TABLE4(SVGMetadataElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGMetadataElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement) +NS_INTERFACE_MAP_END_INHERITING(SVGMetadataElementBase) + + +//---------------------------------------------------------------------- +// Implementation + +SVGMetadataElement::SVGMetadataElement(already_AddRefed aNodeInfo) + : SVGMetadataElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + + +nsresult +SVGMetadataElement::Init() +{ + return NS_OK; +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMetadataElement) + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGMetadataElement.h b/content/svg/content/src/SVGMetadataElement.h new file mode 100644 index 000000000000..7a6d1baf5451 --- /dev/null +++ b/content/svg/content/src/SVGMetadataElement.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGMetadataElement_h +#define mozilla_dom_SVGMetadataElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGMetadataElement.h" + +nsresult NS_NewSVGMetadataElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGMetadataElementBase; + +namespace mozilla { +namespace dom { + +class SVGMetadataElement MOZ_FINAL : public SVGMetadataElementBase, + public nsIDOMSVGMetadataElement +{ +protected: + friend nsresult (::NS_NewSVGMetadataElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGMetadataElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + nsresult Init(); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGMETADATAELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGMetadataElement_h diff --git a/content/svg/content/src/nsSVGMetadataElement.cpp b/content/svg/content/src/nsSVGMetadataElement.cpp deleted file mode 100644 index af52ffae835c..000000000000 --- a/content/svg/content/src/nsSVGMetadataElement.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsIDOMSVGMetadataElement.h" - -typedef nsSVGElement nsSVGMetadataElementBase; - -class nsSVGMetadataElement : public nsSVGMetadataElementBase, - public nsIDOMSVGMetadataElement -{ -protected: - friend nsresult NS_NewSVGMetadataElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGMetadataElement(already_AddRefed aNodeInfo); - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGMETADATAELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Metadata) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase) - -DOMCI_NODE_DATA(SVGMetadataElement, nsSVGMetadataElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGMetadataElement) - NS_NODE_INTERFACE_TABLE4(nsSVGMetadataElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGMetadataElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGMetadataElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -nsSVGMetadataElement::nsSVGMetadataElement(already_AddRefed aNodeInfo) - : nsSVGMetadataElementBase(aNodeInfo) -{ -} - - -nsresult -nsSVGMetadataElement::Init() -{ - return NS_OK; -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMetadataElement) diff --git a/dom/webidl/SVGMetadataElement.webidl b/dom/webidl/SVGMetadataElement.webidl new file mode 100644 index 000000000000..1c404f91f2d0 --- /dev/null +++ b/dom/webidl/SVGMetadataElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGMetadataElement : SVGElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 97aa4aea4265..a21f2f079a46 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -100,6 +100,7 @@ webidl_files = \ SVGElement.webidl \ SVGLengthList.webidl \ SVGMatrix.webidl \ + SVGMetadataElement.webidl \ SVGNumberList.webidl \ SVGPathSeg.webidl \ SVGPathSegList.webidl \ From a9871f90381209aa50d113b65df67660dce87c86 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 17:28:41 -0500 Subject: [PATCH 093/180] Bug 824327: Convert SVGMPathElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGMpathElement.cpp => content/svg/content/src/SVGMPathElement.cpp rename : content/svg/content/src/nsSVGMpathElement.h => content/svg/content/src/SVGMPathElement.h --- content/svg/content/src/Makefile.in | 3 +- ...VGMpathElement.cpp => SVGMPathElement.cpp} | 129 ++++++++++-------- ...{nsSVGMpathElement.h => SVGMPathElement.h} | 47 ++++--- .../src/SVGMotionSMILAnimationFunction.cpp | 12 +- .../src/SVGMotionSMILAnimationFunction.h | 7 +- .../svg/content/src/nsSVGElementFactory.cpp | 4 +- dom/webidl/SVGMPathElement.webidl | 17 +++ dom/webidl/SVGURIReference.webidl | 19 +++ dom/webidl/WebIDL.mk | 2 + 9 files changed, 159 insertions(+), 81 deletions(-) rename content/svg/content/src/{nsSVGMpathElement.cpp => SVGMPathElement.cpp} (62%) rename content/svg/content/src/{nsSVGMpathElement.h => SVGMPathElement.h} (70%) create mode 100644 dom/webidl/SVGMPathElement.webidl create mode 100644 dom/webidl/SVGURIReference.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 7740ba24f97e..d34d99282636 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -114,7 +114,6 @@ CPPSRCS = \ nsSVGAnimateTransformElement.cpp \ nsSVGAnimateMotionElement.cpp \ nsSVGAnimationElement.cpp \ - nsSVGMpathElement.cpp \ nsSVGSetElement.cpp \ SVGAttrValueWrapper.cpp \ SVGContentUtils.cpp \ @@ -126,6 +125,7 @@ CPPSRCS = \ SVGMotionSMILAttr.cpp \ SVGMotionSMILAnimationFunction.cpp \ SVGMotionSMILPathUtils.cpp \ + SVGMPathElement.cpp \ SVGNumberListSMILType.cpp \ SVGNumberPairSMILType.cpp \ SVGOrientSMILType.cpp \ @@ -156,6 +156,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedBoolean.h \ SVGDescElement.h \ SVGMetadataElement.h \ + SVGMPathElement.h \ SVGStopElement.h \ SVGStyleElement.h \ SVGTitleElement.h \ diff --git a/content/svg/content/src/nsSVGMpathElement.cpp b/content/svg/content/src/SVGMPathElement.cpp similarity index 62% rename from content/svg/content/src/nsSVGMpathElement.cpp rename to content/svg/content/src/SVGMPathElement.cpp index ea5bb5f8e584..927cdcbff1c4 100644 --- a/content/svg/content/src/nsSVGMpathElement.cpp +++ b/content/svg/content/src/SVGMPathElement.cpp @@ -5,49 +5,56 @@ #include "mozilla/Util.h" -#include "nsSVGMpathElement.h" +#include "mozilla/dom/SVGMPathElement.h" #include "nsAutoPtr.h" #include "nsDebug.h" #include "nsSVGPathElement.h" #include "nsSVGAnimateMotionElement.h" #include "nsContentUtils.h" +#include "mozilla/dom/SVGMPathElementBinding.h" -using namespace mozilla; -using namespace mozilla::dom; +DOMCI_NODE_DATA(SVGMpathElement, mozilla::dom::SVGMPathElement) -nsSVGElement::StringInfo nsSVGMpathElement::sStringInfo[1] = +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(MPath) + +namespace mozilla { +namespace dom { + +JSObject* +SVGMPathElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGMPathElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +nsSVGElement::StringInfo SVGMPathElement::sStringInfo[1] = { { &nsGkAtoms::href, kNameSpaceID_XLink, false } }; -NS_IMPL_NS_NEW_SVG_ELEMENT(Mpath) - // Cycle collection magic -- based on nsSVGUseElement -NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGMpathElement) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGMpathElement, - nsSVGMpathElementBase) +NS_IMPL_CYCLE_COLLECTION_CLASS(SVGMPathElement) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGMPathElement, + SVGMPathElementBase) tmp->UnlinkHrefTarget(false); NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGMpathElement, - nsSVGMpathElementBase) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGMPathElement, + SVGMPathElementBase) tmp->mHrefTarget.Traverse(&cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END //---------------------------------------------------------------------- // nsISupports methods -NS_IMPL_ADDREF_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase) +NS_IMPL_ADDREF_INHERITED(SVGMPathElement,SVGMPathElementBase) +NS_IMPL_RELEASE_INHERITED(SVGMPathElement,SVGMPathElementBase) -DOMCI_NODE_DATA(SVGMpathElement, nsSVGMpathElement) - -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGMpathElement) - NS_NODE_INTERFACE_TABLE6(nsSVGMpathElement, nsIDOMNode, nsIDOMElement, +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGMPathElement) + NS_NODE_INTERFACE_TABLE6(SVGMPathElement, nsIDOMNode, nsIDOMElement, nsIDOMSVGElement, nsIDOMSVGURIReference, nsIDOMSVGMpathElement, nsIMutationObserver) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMpathElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGMpathElementBase) +NS_INTERFACE_MAP_END_INHERITING(SVGMPathElementBase) // Constructor #ifdef _MSC_VER @@ -57,16 +64,17 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGMpathElementBase) #pragma warning(push) #pragma warning(disable:4355) #endif -nsSVGMpathElement::nsSVGMpathElement(already_AddRefed aNodeInfo) - : nsSVGMpathElementBase(aNodeInfo), +SVGMPathElement::SVGMPathElement(already_AddRefed aNodeInfo) + : SVGMPathElementBase(aNodeInfo), mHrefTarget(this) #ifdef _MSC_VER #pragma warning(pop) #endif { + SetIsDOMBinding(); } -nsSVGMpathElement::~nsSVGMpathElement() +SVGMPathElement::~SVGMPathElement() { UnlinkHrefTarget(false); } @@ -74,33 +82,42 @@ nsSVGMpathElement::~nsSVGMpathElement() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMpathElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMPathElement) //---------------------------------------------------------------------- // nsIDOMSVGURIReference methods /* readonly attribute nsIDOMSVGAnimatedString href; */ -NS_IMETHODIMP -nsSVGMpathElement::GetHref(nsIDOMSVGAnimatedString** aHref) +already_AddRefed +SVGMPathElement::Href() { - return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this); + nsCOMPtr href; + mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this); + return href.forget(); +} + +NS_IMETHODIMP +SVGMPathElement::GetHref(nsIDOMSVGAnimatedString** aHref) +{ + *aHref = Href().get(); + return NS_OK; } //---------------------------------------------------------------------- // nsIContent methods nsresult -nsSVGMpathElement::BindToTree(nsIDocument* aDocument, - nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) +SVGMPathElement::BindToTree(nsIDocument* aDocument, + nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) { NS_ABORT_IF_FALSE(!mHrefTarget.get(), "Shouldn't have href-target yet " "(or it should've been cleared)"); - nsresult rv = nsSVGMpathElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); + nsresult rv = SVGMPathElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); NS_ENSURE_SUCCESS(rv,rv); if (aDocument) { @@ -115,20 +132,20 @@ nsSVGMpathElement::BindToTree(nsIDocument* aDocument, } void -nsSVGMpathElement::UnbindFromTree(bool aDeep, bool aNullParent) +SVGMPathElement::UnbindFromTree(bool aDeep, bool aNullParent) { UnlinkHrefTarget(true); - nsSVGMpathElementBase::UnbindFromTree(aDeep, aNullParent); + SVGMPathElementBase::UnbindFromTree(aDeep, aNullParent); } bool -nsSVGMpathElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +SVGMPathElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { bool returnVal = - nsSVGMpathElementBase::ParseAttribute(aNamespaceID, aAttribute, + SVGMPathElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, aResult); if (aNamespaceID == kNameSpaceID_XLink && aAttribute == nsGkAtoms::href && @@ -141,11 +158,11 @@ nsSVGMpathElement::ParseAttribute(int32_t aNamespaceID, } nsresult -nsSVGMpathElement::UnsetAttr(int32_t aNamespaceID, - nsIAtom* aAttribute, bool aNotify) +SVGMPathElement::UnsetAttr(int32_t aNamespaceID, + nsIAtom* aAttribute, bool aNotify) { - nsresult rv = nsSVGMpathElementBase::UnsetAttr(aNamespaceID, aAttribute, - aNotify); + nsresult rv = SVGMPathElementBase::UnsetAttr(aNamespaceID, aAttribute, + aNotify); NS_ENSURE_SUCCESS(rv, rv); if (aNamespaceID == kNameSpaceID_XLink && @@ -160,7 +177,7 @@ nsSVGMpathElement::UnsetAttr(int32_t aNamespaceID, // nsSVGElement methods nsSVGElement::StringAttributesInfo -nsSVGMpathElement::GetStringInfo() +SVGMPathElement::GetStringInfo() { return StringAttributesInfo(mStringAttributes, sStringInfo, ArrayLength(sStringInfo)); @@ -170,11 +187,11 @@ nsSVGMpathElement::GetStringInfo() // nsIMutationObserver methods void -nsSVGMpathElement::AttributeChanged(nsIDocument* aDocument, - Element* aElement, - int32_t aNameSpaceID, - nsIAtom* aAttribute, - int32_t aModType) +SVGMPathElement::AttributeChanged(nsIDocument* aDocument, + Element* aElement, + int32_t aNameSpaceID, + nsIAtom* aAttribute, + int32_t aModType) { if (aNameSpaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::d) { @@ -187,7 +204,7 @@ nsSVGMpathElement::AttributeChanged(nsIDocument* aDocument, // Public helper methods nsSVGPathElement* -nsSVGMpathElement::GetReferencedPath() +SVGMPathElement::GetReferencedPath() { if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) { NS_ABORT_IF_FALSE(!mHrefTarget.get(), @@ -207,8 +224,8 @@ nsSVGMpathElement::GetReferencedPath() // Protected helper methods void -nsSVGMpathElement::UpdateHrefTarget(nsIContent* aParent, - const nsAString& aHrefStr) +SVGMPathElement::UpdateHrefTarget(nsIContent* aParent, + const nsAString& aHrefStr) { nsCOMPtr targetURI; nsCOMPtr baseURI = GetBaseURI(); @@ -240,7 +257,7 @@ nsSVGMpathElement::UpdateHrefTarget(nsIContent* aParent, } void -nsSVGMpathElement::UnlinkHrefTarget(bool aNotifyParent) +SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent) { // Stop observing old target (if any) if (mHrefTarget.get()) { @@ -254,7 +271,7 @@ nsSVGMpathElement::UnlinkHrefTarget(bool aNotifyParent) } void -nsSVGMpathElement::NotifyParentOfMpathChange(nsIContent* aParent) +SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent) { if (aParent && aParent->IsSVG(nsGkAtoms::animateMotion)) { @@ -265,3 +282,7 @@ nsSVGMpathElement::NotifyParentOfMpathChange(nsIContent* aParent) AnimationNeedsResample(); } } + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/nsSVGMpathElement.h b/content/svg/content/src/SVGMPathElement.h similarity index 70% rename from content/svg/content/src/nsSVGMpathElement.h rename to content/svg/content/src/SVGMPathElement.h index 736ebea2d705..b6b00c736ed9 100644 --- a/content/svg/content/src/nsSVGMpathElement.h +++ b/content/svg/content/src/SVGMPathElement.h @@ -3,8 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef NS_SVGMPATHELEMENT_H_ -#define NS_SVGMPATHELEMENT_H_ +#ifndef mozilla_dom_SVGMPathElement_h +#define mozilla_dom_SVGMPathElement_h #include "nsIDOMSVGMpathElement.h" #include "nsIDOMSVGURIReference.h" @@ -14,20 +14,26 @@ #include "nsSVGString.h" #include "nsReferencedElement.h" +nsresult NS_NewSVGMPathElement(nsIContent **aResult, + already_AddRefed aNodeInfo); -typedef nsSVGElement nsSVGMpathElementBase; +typedef nsSVGElement SVGMPathElementBase; -class nsSVGMpathElement : public nsSVGMpathElementBase, - public nsIDOMSVGMpathElement, - public nsIDOMSVGURIReference, - public nsStubMutationObserver +namespace mozilla { +namespace dom { + +class SVGMPathElement MOZ_FINAL : public SVGMPathElementBase, + public nsIDOMSVGMpathElement, + public nsIDOMSVGURIReference, + public nsStubMutationObserver { protected: - friend nsresult NS_NewSVGMpathElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGMpathElement(already_AddRefed aNodeInfo); - ~nsSVGMpathElement(); + friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGMPathElement(already_AddRefed aNodeInfo); + ~SVGMPathElement(); + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; public: // interfaces: @@ -35,15 +41,15 @@ public: NS_DECL_NSIDOMSVGMPATHELEMENT NS_DECL_NSIDOMSVGURIREFERENCE - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGMpathElement, - nsSVGMpathElementBase) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGMPathElement, + SVGMPathElementBase) NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED // Forward interface implementations to base class NS_FORWARD_NSIDOMNODE_TO_NSINODE NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGMpathElementBase::) + NS_FORWARD_NSIDOMSVGELEMENT(SVGMPathElementBase::) // nsIContent interface virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; @@ -68,10 +74,14 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + already_AddRefed Href(); + protected: class PathReference : public nsReferencedElement { public: - PathReference(nsSVGMpathElement* aMpathElement) : + PathReference(SVGMPathElement* aMpathElement) : mMpathElement(aMpathElement) {} protected: // We need to be notified when target changes, in order to request a sample @@ -92,7 +102,7 @@ protected: // first time the target changes) virtual bool IsPersistent() { return true; } private: - nsSVGMpathElement* const mMpathElement; + SVGMPathElement* const mMpathElement; }; virtual StringAttributesInfo GetStringInfo(); @@ -107,4 +117,7 @@ protected: PathReference mHrefTarget; }; -#endif // NS_SVGMPATHELEMENT_H_ +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGMPathElement_h diff --git a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp index 560e06a33c79..b7bdbd4c0996 100644 --- a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp +++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp @@ -11,11 +11,13 @@ #include "SVGMotionSMILPathUtils.h" #include "nsSVGPathDataParser.h" #include "nsSVGPathElement.h" // for nsSVGPathList -#include "nsSVGMpathElement.h" +#include "SVGMPathElement.h" #include "nsAttrValueInlines.h" namespace mozilla { +using namespace dom; + SVGMotionSMILAnimationFunction::SVGMotionSMILAnimationFunction() : mRotateType(eRotateType_Explicit), mRotateAngle(0.0f), @@ -124,14 +126,14 @@ SVGMotionSMILAnimationFunction::GetCalcMode() const * Returns the first child of the given element */ -static nsSVGMpathElement* +static SVGMPathElement* GetFirstMpathChild(nsIContent* aElem) { for (nsIContent* child = aElem->GetFirstChild(); child; child = child->GetNextSibling()) { if (child->IsSVG(nsGkAtoms::mpath)) { - return static_cast(child); + return static_cast(child); } } @@ -210,7 +212,7 @@ SVGMotionSMILAnimationFunction:: void SVGMotionSMILAnimationFunction:: - RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem) + RebuildPathAndVerticesFromMpathElem(SVGMPathElement* aMpathElem) { mPathSourceType = ePathSourceType_Mpath; @@ -270,7 +272,7 @@ SVGMotionSMILAnimationFunction:: // Do we have a mpath child? if so, it trumps everything. Otherwise, we look // through our list of path-defining attributes, in order of priority. - nsSVGMpathElement* firstMpathChild = + SVGMPathElement* firstMpathChild = GetFirstMpathChild(&mAnimationElement->AsElement()); if (firstMpathChild) { diff --git a/content/svg/content/src/SVGMotionSMILAnimationFunction.h b/content/svg/content/src/SVGMotionSMILAnimationFunction.h index ebfdbef0d0dd..82f24c5b0ffd 100644 --- a/content/svg/content/src/SVGMotionSMILAnimationFunction.h +++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.h @@ -17,10 +17,13 @@ class nsIAtom; class nsIContent; class nsISMILAttr; class nsSMILValue; -class nsSVGMpathElement; namespace mozilla { +namespace dom { +class SVGMPathElement; +} + //---------------------------------------------------------------------- // SVGMotionSMILAnimationFunction // @@ -72,7 +75,7 @@ protected: // Helpers for GetValues void MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute); void RebuildPathAndVertices(const nsIContent* aContextElem); - void RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem); + void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem); void RebuildPathAndVerticesFromPathAttr(); void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem); bool GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath, diff --git a/content/svg/content/src/nsSVGElementFactory.cpp b/content/svg/content/src/nsSVGElementFactory.cpp index 473729d15472..98d1072808b7 100644 --- a/content/svg/content/src/nsSVGElementFactory.cpp +++ b/content/svg/content/src/nsSVGElementFactory.cpp @@ -201,7 +201,7 @@ nsresult NS_NewSVGAnimateMotionElement(nsIContent **aResult, already_AddRefed aNodeInfo); nsresult -NS_NewSVGMpathElement(nsIContent **aResult, +NS_NewSVGMPathElement(nsIContent **aResult, already_AddRefed aNodeInfo); nsresult NS_NewSVGSetElement(nsIContent **aResult, @@ -348,7 +348,7 @@ NS_NewSVGElement(nsIContent** aResult, already_AddRefed aNodeInfo, if (name == nsGkAtoms::animateMotion) return NS_NewSVGAnimateMotionElement(aResult, aNodeInfo); if (name == nsGkAtoms::mpath) - return NS_NewSVGMpathElement(aResult, aNodeInfo); + return NS_NewSVGMPathElement(aResult, aNodeInfo); if (name == nsGkAtoms::set) return NS_NewSVGSetElement(aResult, aNodeInfo); } diff --git a/dom/webidl/SVGMPathElement.webidl b/dom/webidl/SVGMPathElement.webidl new file mode 100644 index 000000000000..7165b6cf7459 --- /dev/null +++ b/dom/webidl/SVGMPathElement.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGMPathElement : SVGElement { +}; + +SVGMPathElement implements SVGURIReference; + diff --git a/dom/webidl/SVGURIReference.webidl b/dom/webidl/SVGURIReference.webidl new file mode 100644 index 000000000000..29426b3acb96 --- /dev/null +++ b/dom/webidl/SVGURIReference.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGAnimatedString; + +[NoInterfaceObject] +interface SVGURIReference { + readonly attribute SVGAnimatedString href; +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index a21f2f079a46..6148d120130b 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -101,6 +101,7 @@ webidl_files = \ SVGLengthList.webidl \ SVGMatrix.webidl \ SVGMetadataElement.webidl \ + SVGMPathElement.webidl \ SVGNumberList.webidl \ SVGPathSeg.webidl \ SVGPathSegList.webidl \ @@ -112,6 +113,7 @@ webidl_files = \ SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ + SVGURIReference.webidl \ Text.webidl \ TextDecoder.webidl \ TextEncoder.webidl \ From 530668ebeda01c42907dd82bede17e0fbcb4d498 Mon Sep 17 00:00:00 2001 From: Gregor Wagner Date: Fri, 4 Jan 2013 14:30:28 -0800 Subject: [PATCH 094/180] Bug 825840 - [build] Mac Gecko build an flash are broken. r=philikon --- b2g/chrome/content/shell.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index 5d2baa36548d..f77e649d59d5 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -81,8 +81,12 @@ var shell = { get CrashSubmit() { delete this.CrashSubmit; +#ifdef MOZ_CRASHREPORTER Cu.import("resource://gre/modules/CrashSubmit.jsm", this); return this.CrashSubmit; +#else + return this.CrashSubmit = null; +#endif }, onlineForCrashReport: function shell_onlineForCrashReport() { @@ -103,7 +107,7 @@ var shell = { } catch(e) { } // Bail if there isn't a valid crashID. - if (!crashID && !this.CrashSubmit.pendingIDs().length) { + if (!this.CrashSubmit || !crashID && !this.CrashSubmit.pendingIDs().length) { return; } From 40dcbd78462e928ab7936e54bf1cd2dc02c822a9 Mon Sep 17 00:00:00 2001 From: Steven Michaud Date: Fri, 4 Jan 2013 16:39:22 -0600 Subject: [PATCH 095/180] Bug 825734 - Plugins stop rendering when top half of plugin scrolled off top of page, in HiDPI mode. r=jfkthame --- widget/cocoa/nsChildView.h | 1 + widget/cocoa/nsChildView.mm | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 353a5cc9f34d..a19cf7c5f279 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -440,6 +440,7 @@ public: NS_IMETHOD OnIMEFocusChange(bool aFocus); // nsIPluginWidget + // outClipRect and outOrigin are in display pixels (not device pixels) NS_IMETHOD GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, bool& outWidgetVisible); NS_IMETHOD StartDrawPlugin(); NS_IMETHOD EndDrawPlugin(); diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index e2f401a4df2d..0f84ca234fec 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -927,6 +927,8 @@ bool nsChildView::ShowsResizeIndicator(nsIntRect* aResizerRect) // specific code to work around this bug, which breaks when we fix it (see bmo // bug 477077). So we'll need to coordinate releasing a fix for this bug with // Adobe and other major plugin vendors that support the CoreGraphics mode. +// +// outClipRect and outOrigin are in display pixels, not device pixels. NS_IMETHODIMP nsChildView::GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& outOrigin, bool& outWidgetVisible) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; @@ -964,7 +966,11 @@ NS_IMETHODIMP nsChildView::GetPluginClipRect(nsIntRect& outClipRect, nsIntPoint& if (mClipRects) { nsIntRect clipBounds; for (uint32_t i = 0; i < mClipRectCount; ++i) { - clipBounds.UnionRect(clipBounds, mClipRects[i]); + NSRect cocoaPoints = DevPixelsToCocoaPoints(mClipRects[i]); + clipBounds.UnionRect(clipBounds, nsIntRect(NSToIntRound(cocoaPoints.origin.x), + NSToIntRound(cocoaPoints.origin.y), + NSToIntRound(cocoaPoints.size.width), + NSToIntRound(cocoaPoints.size.height))); } outClipRect.IntersectRect(outClipRect, clipBounds - outOrigin); } From 3c3dcb655a2534668dd748f58b934ccabd8f48e3 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 4 Jan 2013 09:45:12 -0800 Subject: [PATCH 096/180] Bug 826421 - Remove Places onBeforeDeleteURI and onBeforeItemRemoved notifications in Sync. r=mak --- services/sync/modules/engines/bookmarks.js | 12 +++-- services/sync/modules/engines/history.js | 55 ++++++++++++---------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 9b5fe9ae1fcf..0dd0ce50ad9e 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -1414,12 +1414,13 @@ BookmarksTracker.prototype = { this._add(folder, parentGuid); }, - onItemRemoved: function BMT_onItemRemoved(itemId, parentId, index, type, uri, - guid, parentGuid) { - if (this._ignore(itemId, parentId, guid)) + onItemRemoved: function (itemId, parentId, index, type, uri, + guid, parentGuid) { + if (this._ignore(itemId, parentId, guid)) { return; + } - this._log.trace("onBeforeItemRemoved: " + itemId); + this._log.trace("onItemRemoved: " + itemId); this._add(itemId, guid); this._add(parentId, parentGuid); }, @@ -1509,6 +1510,7 @@ BookmarksTracker.prototype = { onBeginUpdateBatch: function () {}, onEndUpdateBatch: function () {}, + onItemVisited: function () {}, onBeforeItemRemoved: function () {}, - onItemVisited: function () {} + batching: function () {}, }; diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index a97515733c70..89d4066cb752 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -385,22 +385,25 @@ HistoryTracker.prototype = { Ci.nsISupportsWeakReference ]), - onBeginUpdateBatch: function HT_onBeginUpdateBatch() {}, - onEndUpdateBatch: function HT_onEndUpdateBatch() {}, - onPageChanged: function HT_onPageChanged() {}, - onTitleChanged: function HT_onTitleChanged() {}, - onDeleteVisits: function () {}, - onDeleteURI: function () {}, - - /* Every add is worth 1 point. - * OnBeforeDeleteURI will triggger a sync for MULTI-DEVICE (see below) - * Clearing all history will trigger a sync for MULTI-DEVICE (see below) - */ - _upScoreXLarge: function HT__upScoreXLarge() { - this.score += SCORE_INCREMENT_XLARGE; + onDeleteAffectsGUID: function (uri, guid, reason, source, increment) { + if (this.ignoreAll || reason == Ci.nsINavHistoryObserver.REASON_EXPIRED) { + return; + } + this._log.trace(source + ": " + uri.spec + ", reason " + reason); + if (this.addChangedID(guid)) { + this.score += increment; + } }, - onVisit: function HT_onVisit(uri, vid, time, session, referrer, trans, guid) { + onDeleteVisits: function (uri, visitTime, guid, reason) { + this.onDeleteAffectsGUID(uri, guid, reason, "onDeleteVisits", SCORE_INCREMENT_SMALL); + }, + + onDeleteURI: function (uri, guid, reason) { + this.onDeleteAffectsGUID(uri, guid, reason, "onDeleteURI", SCORE_INCREMENT_XLARGE); + }, + + onVisit: function (uri, vid, time, session, referrer, trans, guid) { if (this.ignoreAll) { return; } @@ -410,18 +413,18 @@ HistoryTracker.prototype = { } }, - onBeforeDeleteURI: function onBeforeDeleteURI(uri, guid, reason) { - if (this.ignoreAll || reason == Ci.nsINavHistoryObserver.REASON_EXPIRED) { - return; - } - this._log.trace("onBeforeDeleteURI: " + uri.spec); - if (this.addChangedID(guid)) { - this._upScoreXLarge(); - } + onClearHistory: function () { + this._log.trace("onClearHistory"); + // Note that we're going to trigger a sync, but none of the cleared + // pages are tracked, so the deletions will not be propagated. + // See Bug 578694. + this.score += SCORE_INCREMENT_XLARGE; }, - onClearHistory: function HT_onClearHistory() { - this._log.trace("onClearHistory"); - this._upScoreXLarge(); - } + onBeginUpdateBatch: function () {}, + onEndUpdateBatch: function () {}, + onPageChanged: function () {}, + onTitleChanged: function () {}, + onBeforeDeleteURI: function () {}, + batching: function () {}, }; From 2b91478e8aa18bcbaa741c9aa5ab246ff01f85ea Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Fri, 4 Jan 2013 17:59:05 -0500 Subject: [PATCH 097/180] Bug 805591 - Win32 implementation of the Plugin Hang UI r=bsmedberg,bbondy --- browser/installer/package-manifest.in | 1 + dom/Makefile.in | 6 + dom/locales/en-US/chrome/dom/dom.properties | 4 + dom/plugins/ipc/Makefile.in | 13 + dom/plugins/ipc/MiniShmParent.cpp | 219 +++++++++++ dom/plugins/ipc/MiniShmParent.h | 96 +++++ dom/plugins/ipc/PluginHangUIParent.cpp | 348 ++++++++++++++++++ dom/plugins/ipc/PluginHangUIParent.h | 152 ++++++++ dom/plugins/ipc/PluginModuleParent.cpp | 203 +++++++++- dom/plugins/ipc/PluginModuleParent.h | 37 ++ dom/plugins/ipc/hangui/HangUIDlg.h | 18 + dom/plugins/ipc/hangui/HangUIDlg.rc | 26 ++ dom/plugins/ipc/hangui/Makefile.in | 39 ++ dom/plugins/ipc/hangui/MiniShmBase.h | 315 ++++++++++++++++ dom/plugins/ipc/hangui/MiniShmChild.cpp | 170 +++++++++ dom/plugins/ipc/hangui/MiniShmChild.h | 68 ++++ dom/plugins/ipc/hangui/PluginHangUI.h | 54 +++ dom/plugins/ipc/hangui/PluginHangUIChild.cpp | 289 +++++++++++++++ dom/plugins/ipc/hangui/PluginHangUIChild.h | 109 ++++++ dom/plugins/ipc/hangui/module.ver | 6 + .../ipc/hangui/plugin-hang-ui.exe.manifest | 35 ++ modules/libpref/src/init/all.js | 11 + toolkit/components/telemetry/Histograms.json | 9 + 23 files changed, 2217 insertions(+), 11 deletions(-) create mode 100644 dom/plugins/ipc/MiniShmParent.cpp create mode 100644 dom/plugins/ipc/MiniShmParent.h create mode 100644 dom/plugins/ipc/PluginHangUIParent.cpp create mode 100644 dom/plugins/ipc/PluginHangUIParent.h create mode 100644 dom/plugins/ipc/hangui/HangUIDlg.h create mode 100644 dom/plugins/ipc/hangui/HangUIDlg.rc create mode 100644 dom/plugins/ipc/hangui/Makefile.in create mode 100644 dom/plugins/ipc/hangui/MiniShmBase.h create mode 100644 dom/plugins/ipc/hangui/MiniShmChild.cpp create mode 100644 dom/plugins/ipc/hangui/MiniShmChild.h create mode 100644 dom/plugins/ipc/hangui/PluginHangUI.h create mode 100644 dom/plugins/ipc/hangui/PluginHangUIChild.cpp create mode 100644 dom/plugins/ipc/hangui/PluginHangUIChild.h create mode 100644 dom/plugins/ipc/hangui/module.ver create mode 100644 dom/plugins/ipc/hangui/plugin-hang-ui.exe.manifest diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 73e7be16cdef..ebbc84ac9c74 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -78,6 +78,7 @@ @BINPATH@/@MOZ_CHILD_PROCESS_NAME@ #endif #ifdef XP_WIN32 +@BINPATH@/plugin-hang-ui@BIN_SUFFIX@ #ifndef MOZ_DEBUG #if MOZ_MSVC_REDIST == 1400 @BINPATH@/Microsoft.VC80.CRT.manifest diff --git a/dom/Makefile.in b/dom/Makefile.in index 47cd2534639a..b7433c2fab15 100644 --- a/dom/Makefile.in +++ b/dom/Makefile.in @@ -78,6 +78,12 @@ PARALLEL_DIRS += \ audiochannel \ $(NULL) +ifeq (WINNT,$(OS_ARCH)) +PARALLEL_DIRS += \ + plugins/ipc/hangui \ + $(NULL) +endif + ifdef MOZ_B2G_RIL PARALLEL_DIRS += \ telephony \ diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index cad8698cfbe1..3b7d36b6e8f0 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -114,5 +114,9 @@ MutationEventWarning=Use of Mutation Events is deprecated. Use MutationObserver MozSliceWarning=Use of mozSlice on the Blob object is deprecated. Use slice instead. # LOCALIZATION NOTE: Do not translate "Components" ComponentsWarning=The Components object is deprecated. It will soon be removed. +PluginHangUITitle=Warning: Unresponsive plugin +PluginHangUIMessage=%S may be busy, or it may have stopped responding. You can stop the plugin now, or you can continue to see if the plugin will complete. +PluginHangUIWaitButton=Continue +PluginHangUIStopButton=Stop plugin # LOCALIZATION NOTE: Do not translate "mozHidden", "mozVisibilityState", "hidden", or "visibilityState" PrefixedVisibilityApiWarning='mozHidden' and 'mozVisibilityState' are deprecated. Please use the unprefixed 'hidden' and 'visibilityState' instead. diff --git a/dom/plugins/ipc/Makefile.in b/dom/plugins/ipc/Makefile.in index 870c2713d437..9dde0b57a04c 100644 --- a/dom/plugins/ipc/Makefile.in +++ b/dom/plugins/ipc/Makefile.in @@ -94,6 +94,12 @@ ifeq (WINNT,$(OS_ARCH)) CPPSRCS += \ COMMessageFilter.cpp \ PluginSurfaceParent.cpp \ + MiniShmParent.cpp \ + PluginHangUIParent.cpp \ + $(NULL) + +DEFINES += \ + -DMOZ_HANGUI_PROCESS_NAME=\"plugin-hang-ui$(BIN_SUFFIX)\" \ $(NULL) EXPORTS_mozilla/plugins += \ @@ -121,6 +127,13 @@ LOCAL_INCLUDES = \ -I$(topsrcdir)/xpcom/base/ \ $(NULL) +ifeq (WINNT,$(OS_ARCH)) +LOCAL_INCLUDES += \ + -I$(srcdir)/hangui \ + -I$(topsrcdir)/widget/shared \ + $(NULL) +endif + include $(topsrcdir)/config/config.mk include $(topsrcdir)/ipc/chromium/chromium-config.mk diff --git a/dom/plugins/ipc/MiniShmParent.cpp b/dom/plugins/ipc/MiniShmParent.cpp new file mode 100644 index 000000000000..8633dcaf33ba --- /dev/null +++ b/dom/plugins/ipc/MiniShmParent.cpp @@ -0,0 +1,219 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "MiniShmParent.h" + +#include "base/scoped_handle.h" + +#include + +namespace mozilla { +namespace plugins { + +// static +const unsigned int MiniShmParent::kDefaultMiniShmSectionSize = 0x1000; + +MiniShmParent::MiniShmParent() + : mSectionSize(0), + mParentEvent(NULL), + mParentGuard(NULL), + mChildEvent(NULL), + mChildGuard(NULL), + mRegWait(NULL), + mFileMapping(NULL), + mView(nullptr), + mIsConnected(false), + mTimeout(INFINITE) +{ +} + +MiniShmParent::~MiniShmParent() +{ + CleanUp(); +} + +void +MiniShmParent::CleanUp() +{ + if (mRegWait) { + ::UnregisterWaitEx(mRegWait, INVALID_HANDLE_VALUE); + mRegWait = NULL; + } + if (mParentEvent) { + ::CloseHandle(mParentEvent); + mParentEvent = NULL; + } + if (mParentGuard) { + ::CloseHandle(mParentGuard); + mParentGuard = NULL; + } + if (mChildEvent) { + ::CloseHandle(mChildEvent); + mChildEvent = NULL; + } + if (mChildGuard) { + ::CloseHandle(mChildGuard); + mChildGuard = NULL; + } + if (mView) { + ::UnmapViewOfFile(mView); + mView = nullptr; + } + if (mFileMapping) { + ::CloseHandle(mFileMapping); + mFileMapping = NULL; + } +} + +nsresult +MiniShmParent::Init(MiniShmObserver* aObserver, const DWORD aTimeout, + const unsigned int aSectionSize) +{ + if (!aObserver || !aSectionSize || (aSectionSize % 0x1000) || !aTimeout) { + return NS_ERROR_ILLEGAL_VALUE; + } + if (mFileMapping) { + return NS_ERROR_ALREADY_INITIALIZED; + } + SECURITY_ATTRIBUTES securityAttributes = {sizeof(securityAttributes), + nullptr, + TRUE}; + ScopedHandle parentEvent(::CreateEvent(&securityAttributes, + FALSE, + FALSE, + nullptr)); + if (!parentEvent.IsValid()) { + return NS_ERROR_FAILURE; + } + ScopedHandle parentGuard(::CreateEvent(&securityAttributes, + FALSE, + TRUE, + nullptr)); + if (!parentGuard.IsValid()) { + return NS_ERROR_FAILURE; + } + ScopedHandle childEvent(::CreateEvent(&securityAttributes, + FALSE, + FALSE, + nullptr)); + if (!childEvent.IsValid()) { + return NS_ERROR_FAILURE; + } + ScopedHandle childGuard(::CreateEvent(&securityAttributes, + FALSE, + TRUE, + nullptr)); + if (!childGuard.IsValid()) { + return NS_ERROR_FAILURE; + } + ScopedHandle mapping(::CreateFileMapping(INVALID_HANDLE_VALUE, + &securityAttributes, + PAGE_READWRITE, + 0, + aSectionSize, + nullptr)); + if (!mapping.IsValid()) { + return NS_ERROR_FAILURE; + } + ScopedMappedFileView view(::MapViewOfFile(mapping, + FILE_MAP_WRITE, + 0, 0, 0)); + if (!view.IsValid()) { + return NS_ERROR_FAILURE; + } + nsresult rv = SetView(view, aSectionSize, false); + NS_ENSURE_SUCCESS(rv, rv); + + MiniShmInit* initStruct = nullptr; + rv = GetWritePtrInternal(initStruct); + NS_ENSURE_SUCCESS(rv, rv); + initStruct->mParentEvent = parentEvent; + initStruct->mParentGuard = parentGuard; + initStruct->mChildEvent = childEvent; + initStruct->mChildGuard = childGuard; + + if (!::RegisterWaitForSingleObject(&mRegWait, + parentEvent, + &SOnEvent, + this, + INFINITE, + WT_EXECUTEDEFAULT)) { + return NS_ERROR_FAILURE; + } + + mParentEvent = parentEvent.Take(); + mParentGuard = parentGuard.Take(); + mChildEvent = childEvent.Take(); + mChildGuard = childGuard.Take(); + mFileMapping = mapping.Take(); + mView = view.Take(); + mSectionSize = aSectionSize; + SetObserver(aObserver); + mTimeout = aTimeout; + return NS_OK; +} + +nsresult +MiniShmParent::GetCookie(std::wstring& cookie) +{ + if (!mFileMapping) { + return NS_ERROR_NOT_INITIALIZED; + } + std::wostringstream oss; + oss << mFileMapping; + if (!oss) { + return NS_ERROR_FAILURE; + } + cookie = oss.str(); + return NS_OK; +} + +nsresult +MiniShmParent::Send() +{ + if (!mChildEvent || !mChildGuard) { + return NS_ERROR_NOT_INITIALIZED; + } + if (::WaitForSingleObject(mChildGuard, mTimeout) != WAIT_OBJECT_0) { + return NS_ERROR_FAILURE; + } + if (!::SetEvent(mChildEvent)) { + return NS_ERROR_FAILURE; + } + return NS_OK; +} + +bool +MiniShmParent::IsConnected() const +{ + return mIsConnected; +} + +void +MiniShmParent::OnEvent() +{ + if (mIsConnected) { + MiniShmBase::OnEvent(); + } else { + FinalizeConnection(); + } + ::SetEvent(mParentGuard); +} + +void +MiniShmParent::FinalizeConnection() +{ + const MiniShmInitComplete* initCompleteStruct = nullptr; + nsresult rv = GetReadPtr(initCompleteStruct); + mIsConnected = NS_SUCCEEDED(rv) && initCompleteStruct->mSucceeded; + if (mIsConnected) { + OnConnect(); + } +} + +} // namespace plugins +} // namespace mozilla + diff --git a/dom/plugins/ipc/MiniShmParent.h b/dom/plugins/ipc/MiniShmParent.h new file mode 100644 index 000000000000..e27c17328a8d --- /dev/null +++ b/dom/plugins/ipc/MiniShmParent.h @@ -0,0 +1,96 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_MiniShmParent_h +#define mozilla_plugins_MiniShmParent_h + +#include "MiniShmBase.h" + +#include + +namespace mozilla { +namespace plugins { + +/** + * This class provides a lightweight shared memory interface for a parent + * process in Win32. + * This code assumes that there is a parent-child relationship between + * processes, as it creates inheritable handles. + * Note that this class is *not* an IPDL actor. + * + * @see MiniShmChild + */ +class MiniShmParent : public MiniShmBase +{ +public: + MiniShmParent(); + virtual ~MiniShmParent(); + + static const unsigned int kDefaultMiniShmSectionSize; + + /** + * Initialize shared memory on the parent side. + * + * @param aObserver A MiniShmObserver object to receive event notifications. + * @param aTimeout Timeout in milliseconds. + * @param aSectionSize Desired size of the shared memory section. This is + * expected to be a multiple of 0x1000 (4KiB). + * @return nsresult error code + */ + nsresult + Init(MiniShmObserver* aObserver, const DWORD aTimeout, + const unsigned int aSectionSize = kDefaultMiniShmSectionSize); + + /** + * Destroys the shared memory section. Useful to explicitly release + * resources if it is known that they won't be needed again. + */ + void + CleanUp(); + + /** + * Provides a cookie string that should be passed to MiniShmChild + * during its initialization. + * + * @param aCookie A std::wstring variable to receive the cookie. + * @return nsresult error code + */ + nsresult + GetCookie(std::wstring& aCookie); + + virtual nsresult + Send() MOZ_OVERRIDE; + + bool + IsConnected() const; + +protected: + void + OnEvent() MOZ_OVERRIDE; + +private: + void + FinalizeConnection(); + + unsigned int mSectionSize; + HANDLE mParentEvent; + HANDLE mParentGuard; + HANDLE mChildEvent; + HANDLE mChildGuard; + HANDLE mRegWait; + HANDLE mFileMapping; + LPVOID mView; + bool mIsConnected; + DWORD mTimeout; + + DISALLOW_COPY_AND_ASSIGN(MiniShmParent); +}; + +} // namespace plugins +} // namespace mozilla + +#endif // mozilla_plugins_MiniShmParent_h + diff --git a/dom/plugins/ipc/PluginHangUIParent.cpp b/dom/plugins/ipc/PluginHangUIParent.cpp new file mode 100644 index 000000000000..2749f2ca2d5f --- /dev/null +++ b/dom/plugins/ipc/PluginHangUIParent.cpp @@ -0,0 +1,348 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "PluginHangUI.h" + +#include "PluginHangUIParent.h" + +#include "mozilla/Telemetry.h" +#include "mozilla/plugins/PluginModuleParent.h" + +#include "nsContentUtils.h" +#include "nsDirectoryServiceDefs.h" +#include "nsIFile.h" +#include "nsIProperties.h" +#include "nsIWindowMediator.h" +#include "nsServiceManagerUtils.h" + +#include "WidgetUtils.h" + +using base::ProcessHandle; + +using mozilla::widget::WidgetUtils; + +using std::string; +using std::vector; + +namespace { +class nsPluginHangUITelemetry : public nsRunnable +{ +public: + nsPluginHangUITelemetry(int aResponseCode, int aDontAskCode) + : mResponseCode(aResponseCode), + mDontAskCode(aDontAskCode) + { + } + + NS_IMETHOD + Run() + { + mozilla::Telemetry::Accumulate( + mozilla::Telemetry::PLUGIN_HANG_UI_USER_RESPONSE, mResponseCode); + mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLUGIN_HANG_UI_DONT_ASK, + mDontAskCode); + return NS_OK; + } + +private: + int mResponseCode; + int mDontAskCode; +}; +} // anonymous namespace + +namespace mozilla { +namespace plugins { + +const DWORD PluginHangUIParent::kTimeout = 5000U; + +PluginHangUIParent::PluginHangUIParent(PluginModuleParent* aModule) + : mModule(aModule), + mMainThreadMessageLoop(MessageLoop::current()), + mIsShowing(false), + mLastUserResponse(0), + mHangUIProcessHandle(NULL), + mMainWindowHandle(NULL), + mRegWait(NULL), + mShowEvent(NULL), + mShowTicks(0), + mResponseTicks(0) +{ +} + +PluginHangUIParent::~PluginHangUIParent() +{ + if (mRegWait) { + ::UnregisterWaitEx(mRegWait, INVALID_HANDLE_VALUE); + } + if (mShowEvent) { + ::CloseHandle(mShowEvent); + } + if (mHangUIProcessHandle) { + ::CloseHandle(mHangUIProcessHandle); + } +} + +bool +PluginHangUIParent::DontShowAgain() const +{ + return (mLastUserResponse & HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN); +} + +bool +PluginHangUIParent::WasLastHangStopped() const +{ + return (mLastUserResponse & HANGUI_USER_RESPONSE_STOP); +} + +unsigned int +PluginHangUIParent::LastShowDurationMs() const +{ + // We only return something if there was a user response + if (!mLastUserResponse) { + return 0; + } + return static_cast(mResponseTicks - mShowTicks); +} + +bool +PluginHangUIParent::Init(const nsString& aPluginName) +{ + if (mHangUIProcessHandle) { + return false; + } + + nsresult rv; + rv = mMiniShm.Init(this, ::IsDebuggerPresent() ? INFINITE : kTimeout); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr + directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID)); + if (!directoryService) { + return false; + } + nsCOMPtr greDir; + rv = directoryService->Get(NS_GRE_DIR, + NS_GET_IID(nsIFile), + getter_AddRefs(greDir)); + if (NS_FAILED(rv)) { + return false; + } + nsAutoString path; + greDir->GetPath(path); + + FilePath exePath(path.get()); + exePath = exePath.AppendASCII(MOZ_HANGUI_PROCESS_NAME); + CommandLine commandLine(exePath.value()); + + nsXPIDLString localizedStr; + const PRUnichar* formatParams[] = { aPluginName.get() }; + rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES, + "PluginHangUIMessage", + formatParams, + localizedStr); + if (NS_FAILED(rv)) { + return false; + } + commandLine.AppendLooseValue(localizedStr.get()); + + const char* keys[] = { "PluginHangUITitle", + "PluginHangUIWaitButton", + "PluginHangUIStopButton", + "DontAskAgain" }; + for (unsigned int i = 0; i < ArrayLength(keys); ++i) { + rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES, + keys[i], + localizedStr); + if (NS_FAILED(rv)) { + return false; + } + commandLine.AppendLooseValue(localizedStr.get()); + } + + rv = GetHangUIOwnerWindowHandle(mMainWindowHandle); + if (NS_FAILED(rv)) { + return false; + } + nsAutoString hwndStr; + hwndStr.AppendPrintf("%p", mMainWindowHandle); + commandLine.AppendLooseValue(hwndStr.get()); + + ScopedHandle procHandle(::OpenProcess(SYNCHRONIZE, + TRUE, + GetCurrentProcessId())); + if (!procHandle.IsValid()) { + return false; + } + nsAutoString procHandleStr; + procHandleStr.AppendPrintf("%p", procHandle); + commandLine.AppendLooseValue(procHandleStr.get()); + + std::wstring ipcCookie; + rv = mMiniShm.GetCookie(ipcCookie); + if (NS_FAILED(rv)) { + return false; + } + commandLine.AppendLooseValue(ipcCookie); + + mShowEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL); + ScopedHandle showEvent(::CreateEvent(NULL, FALSE, FALSE, NULL)); + if (!showEvent.IsValid()) { + return false; + } + mShowEvent = showEvent.Get(); + + STARTUPINFO startupInfo = { sizeof(STARTUPINFO) }; + PROCESS_INFORMATION processInfo = { NULL }; + BOOL isProcessCreated = ::CreateProcess(exePath.value().c_str(), + const_cast(commandLine.command_line_string().c_str()), + nullptr, + nullptr, + TRUE, + DETACHED_PROCESS, + nullptr, + nullptr, + &startupInfo, + &processInfo); + if (isProcessCreated) { + ::CloseHandle(processInfo.hThread); + mHangUIProcessHandle = processInfo.hProcess; + ::RegisterWaitForSingleObject(&mRegWait, + processInfo.hProcess, + &SOnHangUIProcessExit, + this, + INFINITE, + WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE); + ::WaitForSingleObject(mShowEvent, kTimeout); + } + mShowEvent = NULL; + return !(!isProcessCreated); +} + +// static +VOID CALLBACK PluginHangUIParent::SOnHangUIProcessExit(PVOID aContext, + BOOLEAN aIsTimer) +{ + PluginHangUIParent* object = static_cast(aContext); + // If the Hang UI child process died unexpectedly, act as if the UI cancelled + if (object->IsShowing()) { + object->RecvUserResponse(HANGUI_USER_RESPONSE_CANCEL); + // Firefox window was disabled automatically when the Hang UI was shown. + // If plugin-hang-ui.exe was unexpectedly terminated, we need to re-enable. + ::EnableWindow(object->mMainWindowHandle, TRUE); + } + object->mMiniShm.CleanUp(); +} + +bool +PluginHangUIParent::Cancel() +{ + bool result = mIsShowing && SendCancel(); + if (result) { + mIsShowing = false; + } + return result; +} + +bool +PluginHangUIParent::SendCancel() +{ + PluginHangUICommand* cmd = nullptr; + nsresult rv = mMiniShm.GetWritePtr(cmd); + if (NS_FAILED(rv)) { + return false; + } + cmd->mCode = PluginHangUICommand::HANGUI_CMD_CANCEL; + return NS_SUCCEEDED(mMiniShm.Send()); +} + +bool +PluginHangUIParent::RecvUserResponse(const unsigned int& aResponse) +{ + mLastUserResponse = aResponse; + mResponseTicks = GetTickCount(); + mIsShowing = false; + // responseCode: 1 = Stop, 2 = Continue, 3 = Cancel + int responseCode; + if (aResponse & HANGUI_USER_RESPONSE_STOP) { + // User clicked Stop + mModule->TerminateChildProcess(mMainThreadMessageLoop); + responseCode = 1; + } else if(aResponse & HANGUI_USER_RESPONSE_CONTINUE) { + // User clicked Continue + responseCode = 2; + } else { + // Dialog was cancelled + responseCode = 3; + } + int dontAskCode = (aResponse & HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN) ? 1 : 0; + nsCOMPtr workItem = new nsPluginHangUITelemetry(responseCode, + dontAskCode); + NS_DispatchToMainThread(workItem, NS_DISPATCH_NORMAL); + return true; +} + +nsresult +PluginHangUIParent::GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle) +{ + windowHandle = NULL; + + nsresult rv; + nsCOMPtr winMediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, + &rv)); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr navWin; + rv = winMediator->GetMostRecentWindow(NS_LITERAL_STRING("navigator:browser").get(), + getter_AddRefs(navWin)); + NS_ENSURE_SUCCESS(rv, rv); + if (!navWin) { + return NS_ERROR_FAILURE; + } + + nsCOMPtr widget = WidgetUtils::DOMWindowToWidget(navWin); + if (!widget) { + return NS_ERROR_FAILURE; + } + + windowHandle = reinterpret_cast(widget->GetNativeData(NS_NATIVE_WINDOW)); + if (!windowHandle) { + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + +void +PluginHangUIParent::OnMiniShmEvent(MiniShmBase *aMiniShmObj) +{ + const PluginHangUIResponse* response = nullptr; + nsresult rv = aMiniShmObj->GetReadPtr(response); + NS_ASSERTION(NS_SUCCEEDED(rv), + "Couldn't obtain read pointer OnMiniShmEvent"); + if (NS_SUCCEEDED(rv)) { + RecvUserResponse(response->mResponseBits); + } +} + +void +PluginHangUIParent::OnMiniShmConnect(MiniShmBase* aMiniShmObj) +{ + PluginHangUICommand* cmd = nullptr; + nsresult rv = aMiniShmObj->GetWritePtr(cmd); + NS_ASSERTION(NS_SUCCEEDED(rv), + "Couldn't obtain write pointer OnMiniShmConnect"); + if (NS_FAILED(rv)) { + return; + } + cmd->mCode = PluginHangUICommand::HANGUI_CMD_SHOW; + mIsShowing = NS_SUCCEEDED(aMiniShmObj->Send()); + if (mIsShowing) { + mShowTicks = GetTickCount(); + } + ::SetEvent(mShowEvent); +} + +} // namespace plugins +} // namespace mozilla diff --git a/dom/plugins/ipc/PluginHangUIParent.h b/dom/plugins/ipc/PluginHangUIParent.h new file mode 100644 index 000000000000..d5ef0e915251 --- /dev/null +++ b/dom/plugins/ipc/PluginHangUIParent.h @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_PluginHangUIParent_h +#define mozilla_plugins_PluginHangUIParent_h + +#include "nsString.h" + +#include "base/process.h" +#include "base/process_util.h" + +#include "mozilla/plugins/PluginMessageUtils.h" + +#include "MiniShmParent.h" + +namespace mozilla { +namespace plugins { + +class PluginModuleParent; + +/** + * This class is responsible for launching and communicating with the + * plugin-hang-ui process. + * + * NOTE: PluginHangUIParent is *not* an IPDL actor! In this case, "Parent" + * is describing the fact that firefox is the parent process to the + * plugin-hang-ui process, which is the PluginHangUIChild. + * PluginHangUIParent and PluginHangUIChild are a matched pair. + * @see PluginHangUIChild + */ +class PluginHangUIParent : public MiniShmObserver +{ +public: + PluginHangUIParent(PluginModuleParent* aModule); + virtual ~PluginHangUIParent(); + + /** + * Spawn the plugin-hang-ui.exe child process and terminate the given + * plugin container process if the user elects to stop the hung plugin. + * + * @param aPluginName Human-readable name of the affected plugin. + * @return true if the plugin hang ui process was successfully launched, + * otherwise false. + */ + bool + Init(const nsString& aPluginName); + + /** + * If the Plugin Hang UI is being shown, send a cancel notification to the + * Plugin Hang UI child process. + * + * @return true if the UI was shown and the cancel command was successfully + * sent to the child process, otherwise false. + */ + bool + Cancel(); + + /** + * Returns whether the Plugin Hang UI is currently being displayed. + * + * @return true if the Plugin Hang UI is showing, otherwise false. + */ + bool + IsShowing() const { return mIsShowing; } + + /** + * Returns whether this Plugin Hang UI instance has been shown. Note + * that this does not necessarily mean that the UI is showing right now. + * + * @return true if the Plugin Hang UI has shown, otherwise false. + */ + bool + WasShown() const { return mIsShowing || mLastUserResponse != 0; } + + /** + * Returns whether the user checked the "Don't ask me again" checkbox. + * + * @return true if the user does not want to see the Hang UI again. + */ + bool + DontShowAgain() const; + + /** + * Returns whether the user clicked stop during the last time that the + * Plugin Hang UI was displayed, if applicable. + * + * @return true if the UI was shown and the user chose to stop the + * plugin, otherwise false + */ + bool + WasLastHangStopped() const; + + /** + * @return unsigned int containing the response bits from the last + * time the Plugin Hang UI ran. + */ + unsigned int + LastUserResponse() const { return mLastUserResponse; } + + /** + * @return unsigned int containing the number of milliseconds that + * the Plugin Hang UI was displayed before the user responded. + * Returns 0 if the Plugin Hang UI has not been shown or was cancelled. + */ + unsigned int + LastShowDurationMs() const; + + virtual void + OnMiniShmEvent(MiniShmBase* aMiniShmObj) MOZ_OVERRIDE; + + virtual void + OnMiniShmConnect(MiniShmBase* aMiniShmObj) MOZ_OVERRIDE; + +private: + nsresult + GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle); + + bool + SendCancel(); + + bool + RecvUserResponse(const unsigned int& aResponse); + + static + VOID CALLBACK SOnHangUIProcessExit(PVOID aContext, BOOLEAN aIsTimer); + +private: + PluginModuleParent* mModule; + MessageLoop* mMainThreadMessageLoop; + volatile bool mIsShowing; + unsigned int mLastUserResponse; + base::ProcessHandle mHangUIProcessHandle; + NativeWindowHandle mMainWindowHandle; + HANDLE mRegWait; + HANDLE mShowEvent; + DWORD mShowTicks; + DWORD mResponseTicks; + MiniShmParent mMiniShm; + + static const DWORD kTimeout; + + DISALLOW_COPY_AND_ASSIGN(PluginHangUIParent); +}; + +} // namespace plugins +} // namespace mozilla + +#endif // mozilla_plugins_PluginHangUIParent_h + diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 35952c4b1154..c288b89762bc 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -35,6 +35,7 @@ #include "prsystem.h" #ifdef XP_WIN +#include "PluginHangUIParent.h" #include "mozilla/widget/AudioSession.h" #endif #include "sampler.h" @@ -59,6 +60,13 @@ using namespace CrashReporter; static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs"; static const char kParentTimeoutPref[] = "dom.ipc.plugins.parentTimeoutSecs"; static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs"; +#ifdef XP_WIN +static const char kHangUITimeoutPref[] = "dom.ipc.plugins.hangUITimeoutSecs"; +static const char kHangUIMinDisplayPref[] = "dom.ipc.plugins.hangUIMinDisplaySecs"; +#define CHILD_TIMEOUT_PREF kHangUITimeoutPref +#else +#define CHILD_TIMEOUT_PREF kChildTimeoutPref +#endif template<> struct RunnableMethodTraits @@ -87,7 +95,7 @@ PluginModuleParent::LoadModule(const char* aFilePath) parent->Open(parent->mSubprocess->GetChannel(), parent->mSubprocess->GetChildProcessHandle()); - TimeoutChanged(kChildTimeoutPref, parent); + TimeoutChanged(CHILD_TIMEOUT_PREF, parent); #ifdef MOZ_CRASHREPORTER // If this fails, we're having IPC troubles, and we're doomed anyways. @@ -111,6 +119,9 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath) , mTaskFactory(this) #ifdef XP_WIN , mPluginCpuUsageOnHang() + , mHangUIParent(nullptr) + , mHangUIEnabled(true) + , mIsTimerReset(true) #endif #ifdef MOZ_CRASHREPORTER_INJECTOR , mFlashProcess1(0) @@ -123,6 +134,10 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath) Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this); Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this); +#ifdef XP_WIN + Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this); + Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this); +#endif } PluginModuleParent::~PluginModuleParent() @@ -150,6 +165,15 @@ PluginModuleParent::~PluginModuleParent() Preferences::UnregisterCallback(TimeoutChanged, kChildTimeoutPref, this); Preferences::UnregisterCallback(TimeoutChanged, kParentTimeoutPref, this); +#ifdef XP_WIN + Preferences::UnregisterCallback(TimeoutChanged, kHangUITimeoutPref, this); + Preferences::UnregisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this); + + if (mHangUIParent) { + delete mHangUIParent; + mHangUIParent = nullptr; + } +#endif } #ifdef MOZ_CRASHREPORTER @@ -206,16 +230,29 @@ PluginModuleParent::WriteExtraDataForMinidump(AnnotationTable& notes) } #endif // MOZ_CRASHREPORTER +void +PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout) +{ + int32_t timeoutMs = (aChildTimeout > 0) ? (1000 * aChildTimeout) : + SyncChannel::kNoTimeout; + SetReplyTimeoutMs(timeoutMs); +} + int PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule) { - NS_ASSERTION(NS_IsMainThread(), "Wrong thead!"); + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); +#ifndef XP_WIN if (!strcmp(aPref, kChildTimeoutPref)) { // The timeout value used by the parent for children int32_t timeoutSecs = Preferences::GetInt(kChildTimeoutPref, 0); - int32_t timeoutMs = (timeoutSecs > 0) ? (1000 * timeoutSecs) : - SyncChannel::kNoTimeout; - static_cast(aModule)->SetReplyTimeoutMs(timeoutMs); + static_cast(aModule)->SetChildTimeout(timeoutSecs); +#else + if (!strcmp(aPref, kChildTimeoutPref) || + !strcmp(aPref, kHangUIMinDisplayPref) || + !strcmp(aPref, kHangUITimeoutPref)) { + static_cast(aModule)->EvaluateHangUIState(true); +#endif // XP_WIN } else if (!strcmp(aPref, kParentTimeoutPref)) { // The timeout value used by the child for its parent int32_t timeoutSecs = Preferences::GetInt(kParentTimeoutPref, 0); @@ -308,6 +345,13 @@ GetProcessCpuUsage(const InfallibleTArray& processHandles, } } // anonymous namespace + +void +PluginModuleParent::ExitedCxxStack() +{ + FinishHangUI(); +} + #endif // #ifdef XP_WIN #ifdef MOZ_CRASHREPORTER_INJECTOR @@ -334,10 +378,36 @@ CreateFlashMinidump(DWORD processId, ThreadId childThread, bool PluginModuleParent::ShouldContinueFromReplyTimeout() { +#ifdef XP_WIN + if (LaunchHangUI()) { + return true; + } + // If LaunchHangUI returned false then we should proceed with the + // original plugin hang behaviour and kill the plugin container. + FinishHangUI(); +#endif // XP_WIN + TerminateChildProcess(MessageLoop::current()); + return false; +} + +void +PluginModuleParent::TerminateChildProcess(MessageLoop* aMsgLoop) +{ #ifdef MOZ_CRASHREPORTER CrashReporterParent* crashReporter = CrashReporter(); crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("PluginHang"), NS_LITERAL_CSTRING("1")); +#ifdef XP_WIN + if (mHangUIParent) { + unsigned int hangUIDuration = mHangUIParent->LastShowDurationMs(); + if (hangUIDuration) { + nsPrintfCString strHangUIDuration("%u", hangUIDuration); + crashReporter->AnnotateCrashReport( + NS_LITERAL_CSTRING("PluginHangUIDuration"), + strHangUIDuration); + } + } +#endif // XP_WIN if (crashReporter->GeneratePairedMinidump(this)) { mPluginDumpID = crashReporter->ChildDumpID(); PLUGIN_LOG_DEBUG( @@ -395,17 +465,128 @@ PluginModuleParent::ShouldContinueFromReplyTimeout() // this must run before the error notification from the channel, // or not at all - MessageLoop::current()->PostTask( - FROM_HERE, - mTaskFactory.NewRunnableMethod( - &PluginModuleParent::CleanupFromTimeout)); + if (aMsgLoop == MessageLoop::current()) { + aMsgLoop->PostTask( + FROM_HERE, + mTaskFactory.NewRunnableMethod( + &PluginModuleParent::CleanupFromTimeout)); + } else { + // If we're posting from a different thread we can't create + // the task via mTaskFactory + aMsgLoop->PostTask(FROM_HERE, + NewRunnableMethod(this, + &PluginModuleParent::CleanupFromTimeout)); + } if (!KillProcess(OtherProcess(), 1, false)) NS_WARNING("failed to kill subprocess!"); - - return false; } +#ifdef XP_WIN +void +PluginModuleParent::EvaluateHangUIState(const bool aReset) +{ + int32_t minDispSecs = Preferences::GetInt(kHangUIMinDisplayPref, 10); + int32_t autoStopSecs = Preferences::GetInt(kChildTimeoutPref, 0); + int32_t timeoutSecs = 0; + if (autoStopSecs > 0 && autoStopSecs < minDispSecs) { + /* If we're going to automatically terminate the plugin within a + time frame shorter than minDispSecs, there's no point in + showing the hang UI; it would just flash briefly on the screen. */ + mHangUIEnabled = false; + } else { + timeoutSecs = Preferences::GetInt(kHangUITimeoutPref, 0); + mHangUIEnabled = timeoutSecs > 0; + } + if (mHangUIEnabled) { + if (aReset) { + mIsTimerReset = true; + SetChildTimeout(timeoutSecs); + return; + } else if (mIsTimerReset) { + /* The Hang UI is being shown, so now we're setting the + timeout to kChildTimeoutPref while we wait for a user + response. ShouldContinueFromReplyTimeout will fire + after (reply timeout / 2) seconds, which is not what + we want. Doubling the timeout value here so that we get + the right result. */ + autoStopSecs *= 2; + } + } + mIsTimerReset = false; + SetChildTimeout(autoStopSecs); +} + +bool +PluginModuleParent::GetPluginName(nsAString& aPluginName) +{ + nsPluginHost* host = nsPluginHost::GetInst(); + if (!host) { + return false; + } + nsPluginTag* pluginTag = host->TagForPlugin(mPlugin); + if (!pluginTag) { + return false; + } + CopyUTF8toUTF16(pluginTag->mName, aPluginName); + return true; +} + +bool +PluginModuleParent::LaunchHangUI() +{ + if (!mHangUIEnabled) { + return false; + } + if (mHangUIParent) { + if (mHangUIParent->IsShowing()) { + // We've already shown the UI but the timeout has expired again. + return false; + } + if (mHangUIParent->DontShowAgain()) { + return !mHangUIParent->WasLastHangStopped(); + } + delete mHangUIParent; + mHangUIParent = nullptr; + } + mHangUIParent = new PluginHangUIParent(this); + nsAutoString pluginName; + if (!GetPluginName(pluginName)) { + return false; + } + bool retval = mHangUIParent->Init(pluginName); + if (retval) { + /* Once the UI is shown we switch the timeout over to use + kChildTimeoutPref, allowing us to terminate a hung plugin + after kChildTimeoutPref seconds if the user doesn't respond to + the hang UI. */ + EvaluateHangUIState(false); + } + return retval; +} + +void +PluginModuleParent::FinishHangUI() +{ + if (mHangUIEnabled && mHangUIParent) { + bool needsCancel = mHangUIParent->IsShowing(); + // If we're still showing, send a Cancel notification + if (needsCancel) { + mHangUIParent->Cancel(); + } + /* If we cancelled the UI or if the user issued a response, + we need to reset the child process timeout. */ + if (needsCancel || + !mIsTimerReset && mHangUIParent->WasShown()) { + /* We changed the timeout to kChildTimeoutPref when the plugin hang + UI was displayed. Now that we're finishing the UI, we need to + switch it back to kHangUITimeoutPref. */ + EvaluateHangUIState(true); + } + } +} +#endif // XP_WIN + #ifdef MOZ_CRASHREPORTER CrashReporterParent* PluginModuleParent::CrashReporter() diff --git a/dom/plugins/ipc/PluginModuleParent.h b/dom/plugins/ipc/PluginModuleParent.h index 2005929d7bbc..e3ad28a9bdf5 100644 --- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -45,6 +45,10 @@ namespace plugins { class BrowserStreamParent; +#ifdef XP_WIN +class PluginHangUIParent; +#endif + /** * PluginModuleParent * @@ -130,6 +134,13 @@ public: void ProcessRemoteNativeEventsInRPCCall(); + void TerminateChildProcess(MessageLoop* aMsgLoop); + +#ifdef XP_WIN + void + ExitedCxxStack() MOZ_OVERRIDE; +#endif // XP_WIN + protected: virtual mozilla::ipc::RPCChannel::RacyRPCPolicy MediateRPCRace(const Message& parent, const Message& child) MOZ_OVERRIDE @@ -286,6 +297,7 @@ private: void WriteExtraDataForMinidump(CrashReporter::AnnotationTable& notes); #endif void CleanupFromTimeout(); + void SetChildTimeout(const int32_t aChildTimeout); static int TimeoutChanged(const char* aPref, void* aModule); void NotifyPluginCrashed(); @@ -304,6 +316,31 @@ private: nsString mHangID; #ifdef XP_WIN InfallibleTArray mPluginCpuUsageOnHang; + PluginHangUIParent *mHangUIParent; + bool mHangUIEnabled; + bool mIsTimerReset; + + void + EvaluateHangUIState(const bool aReset); + + bool + GetPluginName(nsAString& aPluginName); + + /** + * Launches the Plugin Hang UI. + * + * @return true if plugin-hang-ui.exe has been successfully launched. + * false if the Plugin Hang UI is disabled, already showing, + * or the launch failed. + */ + bool + LaunchHangUI(); + + /** + * Finishes the Plugin Hang UI and cancels if it is being shown to the user. + */ + void + FinishHangUI(); #endif #ifdef MOZ_X11 diff --git a/dom/plugins/ipc/hangui/HangUIDlg.h b/dom/plugins/ipc/hangui/HangUIDlg.h new file mode 100644 index 000000000000..47339acc2107 --- /dev/null +++ b/dom/plugins/ipc/hangui/HangUIDlg.h @@ -0,0 +1,18 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_HangUIDlg_h +#define mozilla_plugins_HangUIDlg_h + +#define IDD_HANGUIDLG 102 +#define IDC_MSG 1000 +#define IDC_CONTINUE 1001 +#define IDC_STOP 1002 +#define IDC_NOFUTURE 1003 +#define IDC_DLGICON 1004 + +#endif // mozilla_plugins_HangUIDlg_h + diff --git a/dom/plugins/ipc/hangui/HangUIDlg.rc b/dom/plugins/ipc/hangui/HangUIDlg.rc new file mode 100644 index 000000000000..62e98ca24924 --- /dev/null +++ b/dom/plugins/ipc/hangui/HangUIDlg.rc @@ -0,0 +1,26 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "HangUIDlg.h" +#include + +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_HANGUIDLG DIALOGEX 0, 0, 400, 75 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Continue",IDC_CONTINUE,283,51,50,18 + PUSHBUTTON "Stop",IDC_STOP,341,51,50,18 + CONTROL "Check1",IDC_NOFUTURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,32,354,10 + LTEXT "Static",IDC_MSG,37,7,353,24 + ICON "",IDC_DLGICON,7,7,20,20 +END + diff --git a/dom/plugins/ipc/hangui/Makefile.in b/dom/plugins/ipc/hangui/Makefile.in new file mode 100644 index 000000000000..a759dbdb22a8 --- /dev/null +++ b/dom/plugins/ipc/hangui/Makefile.in @@ -0,0 +1,39 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DEPTH = @DEPTH@ +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ +FAIL_ON_WARNINGS := 1 + +include $(DEPTH)/config/autoconf.mk + +CPPSRCS = \ + MiniShmChild.cpp \ + PluginHangUIChild.cpp \ + $(NULL) + +PROGRAM = plugin-hang-ui$(BIN_SUFFIX) + +OS_LIBS = comctl32.lib + +RCINCLUDE = HangUIDlg.rc + +include $(topsrcdir)/config/config.mk + +DEFINES += \ + -DNS_NO_XPCOM \ + $(NULL) + +STL_FLAGS = \ + -D_HAS_EXCEPTIONS=0 \ + $(NULL) + +MOZ_GLUE_LDFLAGS = + +include $(topsrcdir)/ipc/chromium/chromium-config.mk + +include $(topsrcdir)/config/rules.mk + diff --git a/dom/plugins/ipc/hangui/MiniShmBase.h b/dom/plugins/ipc/hangui/MiniShmBase.h new file mode 100644 index 000000000000..ac1203e08c51 --- /dev/null +++ b/dom/plugins/ipc/hangui/MiniShmBase.h @@ -0,0 +1,315 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_MiniShmBase_h +#define mozilla_plugins_MiniShmBase_h + +#include "base/basictypes.h" + +#include "nsDebug.h" + +#include + +namespace mozilla { +namespace plugins { + +/** + * This class is used to provide RAII semantics for mapped views. + * @see ScopedHandle + */ +class ScopedMappedFileView +{ +public: + explicit + ScopedMappedFileView(LPVOID aView) + : mView(aView) + { + } + + ~ScopedMappedFileView() + { + Close(); + } + + void + Close() + { + if (mView) { + ::UnmapViewOfFile(mView); + mView = nullptr; + } + } + + void + Set(LPVOID aView) + { + Close(); + mView = aView; + } + + LPVOID + Get() const + { + return mView; + } + + LPVOID + Take() + { + LPVOID result = mView; + mView = nullptr; + return result; + } + + operator LPVOID() + { + return mView; + } + + bool + IsValid() const + { + return (mView); + } + +private: + DISALLOW_COPY_AND_ASSIGN(ScopedMappedFileView); + + LPVOID mView; +}; + +class MiniShmBase; + +class MiniShmObserver +{ +public: + /** + * This function is called whenever there is a new shared memory request. + * @param aMiniShmObj MiniShmBase object that may be used to read and + * write from shared memory. + */ + virtual void OnMiniShmEvent(MiniShmBase *aMiniShmObj) = 0; + /** + * This function is called once when a MiniShmParent and a MiniShmChild + * object have successfully negotiated a connection. + * + * @param aMiniShmObj MiniShmBase object that may be used to read and + * write from shared memory. + */ + virtual void OnMiniShmConnect(MiniShmBase *aMiniShmObj) { } +}; + +/** + * Base class for MiniShm connections. This class defines the common + * interfaces and code between parent and child. + */ +class MiniShmBase +{ +public: + /** + * Obtains a writable pointer into shared memory of type T. + * typename T must be plain-old-data and contain an unsigned integral + * member T::identifier that uniquely identifies T with respect to + * other types used by the protocol being implemented. + * + * @param aPtr Pointer to receive the shared memory address. + * This value is set if and only if the function + * succeeded. + * @return NS_OK if and only if aPtr was successfully obtained. + * NS_ERROR_ILLEGAL_VALUE if type T is not valid for MiniShm. + * NS_ERROR_NOT_INITIALIZED if there is no valid MiniShm connection. + */ + template nsresult + GetWritePtr(T*& aPtr) + { + if (!mWriteHeader) { + return NS_ERROR_NOT_INITIALIZED; + } + if (sizeof(T) > mPayloadMaxLen || + T::identifier <= RESERVED_CODE_LAST) { + return NS_ERROR_ILLEGAL_VALUE; + } + mWriteHeader->mId = T::identifier; + mWriteHeader->mPayloadLen = sizeof(T); + aPtr = reinterpret_cast(mWriteHeader + 1); + return NS_OK; + } + + /** + * Obtains a readable pointer into shared memory of type T. + * typename T must be plain-old-data and contain an unsigned integral + * member T::identifier that uniquely identifies T with respect to + * other types used by the protocol being implemented. + * + * @param aPtr Pointer to receive the shared memory address. + * This value is set if and only if the function + * succeeded. + * @return NS_OK if and only if aPtr was successfully obtained. + * NS_ERROR_ILLEGAL_VALUE if type T is not valid for MiniShm or if + * type T does not match the type of the data + * stored in shared memory. + * NS_ERROR_NOT_INITIALIZED if there is no valid MiniShm connection. + */ + template nsresult + GetReadPtr(const T*& aPtr) + { + if (!mReadHeader) { + return NS_ERROR_NOT_INITIALIZED; + } + if (mReadHeader->mId != T::identifier || + sizeof(T) != mReadHeader->mPayloadLen) { + return NS_ERROR_ILLEGAL_VALUE; + } + aPtr = reinterpret_cast(mReadHeader + 1); + return NS_OK; + } + + /** + * Fires the peer's event causing its request handler to execute. + * + * @return Should return NS_OK if the send was successful. + */ + virtual nsresult + Send() = 0; + +protected: + /** + * MiniShm reserves some identifier codes for its own use. Any + * identifiers used by MiniShm protocol implementations must be + * greater than RESERVED_CODE_LAST. + */ + enum ReservedCodes + { + RESERVED_CODE_INIT = 0, + RESERVED_CODE_INIT_COMPLETE = 1, + RESERVED_CODE_LAST = RESERVED_CODE_INIT_COMPLETE + }; + + struct MiniShmHeader + { + unsigned int mId; + unsigned int mPayloadLen; + }; + + struct MiniShmInit + { + enum identifier_t + { + identifier = RESERVED_CODE_INIT + }; + HANDLE mParentEvent; + HANDLE mParentGuard; + HANDLE mChildEvent; + HANDLE mChildGuard; + }; + + struct MiniShmInitComplete + { + enum identifier_t + { + identifier = RESERVED_CODE_INIT_COMPLETE + }; + bool mSucceeded; + }; + + MiniShmBase() + : mObserver(nullptr), + mWriteHeader(nullptr), + mReadHeader(nullptr), + mPayloadMaxLen(0) + { + } + virtual ~MiniShmBase() + { } + + virtual void + OnEvent() + { + if (mObserver) { + mObserver->OnMiniShmEvent(this); + } + } + + virtual void + OnConnect() + { + if (mObserver) { + mObserver->OnMiniShmConnect(this); + } + } + + nsresult + SetView(LPVOID aView, const unsigned int aSize, bool aIsChild) + { + if (!aView || aSize <= 2 * sizeof(MiniShmHeader)) { + return NS_ERROR_ILLEGAL_VALUE; + } + // Divide the region into halves for parent and child + if (aIsChild) { + mReadHeader = static_cast(aView); + mWriteHeader = reinterpret_cast(static_cast(aView) + + aSize / 2U); + } else { + mWriteHeader = static_cast(aView); + mReadHeader = reinterpret_cast(static_cast(aView) + + aSize / 2U); + } + mPayloadMaxLen = aSize / 2U - sizeof(MiniShmHeader); + return NS_OK; + } + + inline void + SetObserver(MiniShmObserver *aObserver) { mObserver = aObserver; } + + /** + * Obtains a writable pointer into shared memory of type T. This version + * differs from GetWritePtr in that it allows typename T to be one of + * the private data structures declared in MiniShmBase. + * + * @param aPtr Pointer to receive the shared memory address. + * This value is set if and only if the function + * succeeded. + * @return NS_OK if and only if aPtr was successfully obtained. + * NS_ERROR_ILLEGAL_VALUE if type T not an internal MiniShm struct. + * NS_ERROR_NOT_INITIALIZED if there is no valid MiniShm connection. + */ + template nsresult + GetWritePtrInternal(T*& aPtr) + { + if (!mWriteHeader) { + return NS_ERROR_NOT_INITIALIZED; + } + if (sizeof(T) > mPayloadMaxLen || + T::identifier > RESERVED_CODE_LAST) { + return NS_ERROR_ILLEGAL_VALUE; + } + mWriteHeader->mId = T::identifier; + mWriteHeader->mPayloadLen = sizeof(T); + aPtr = reinterpret_cast(mWriteHeader + 1); + return NS_OK; + } + + static VOID CALLBACK + SOnEvent(PVOID aContext, BOOLEAN aIsTimer) + { + MiniShmBase* object = static_cast(aContext); + object->OnEvent(); + } + +private: + MiniShmObserver* mObserver; + MiniShmHeader* mWriteHeader; + MiniShmHeader* mReadHeader; + unsigned int mPayloadMaxLen; + + DISALLOW_COPY_AND_ASSIGN(MiniShmBase); +}; + +} // namespace plugins +} // namespace mozilla + +#endif // mozilla_plugins_MiniShmBase_h + diff --git a/dom/plugins/ipc/hangui/MiniShmChild.cpp b/dom/plugins/ipc/hangui/MiniShmChild.cpp new file mode 100644 index 000000000000..2fd1a6bbfd33 --- /dev/null +++ b/dom/plugins/ipc/hangui/MiniShmChild.cpp @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "MiniShmChild.h" + +#include +#include + +namespace mozilla { +namespace plugins { + +MiniShmChild::MiniShmChild() + : mParentEvent(NULL), + mParentGuard(NULL), + mChildEvent(NULL), + mChildGuard(NULL), + mFileMapping(NULL), + mRegWait(NULL), + mView(nullptr), + mTimeout(INFINITE) +{} + +MiniShmChild::~MiniShmChild() +{ + if (mRegWait) { + ::UnregisterWaitEx(mRegWait, INVALID_HANDLE_VALUE); + } + if (mParentEvent) { + ::CloseHandle(mParentEvent); + } + if (mParentGuard) { + ::CloseHandle(mParentGuard); + } + if (mChildEvent) { + ::CloseHandle(mChildEvent); + } + if (mChildGuard) { + ::CloseHandle(mChildGuard); + } + if (mView) { + ::UnmapViewOfFile(mView); + } + if (mFileMapping) { + ::CloseHandle(mFileMapping); + } +} + +nsresult +MiniShmChild::Init(MiniShmObserver* aObserver, const std::wstring& aCookie, + const DWORD aTimeout) +{ + if (aCookie.empty() || !aTimeout) { + return NS_ERROR_ILLEGAL_VALUE; + } + if (mFileMapping) { + return NS_ERROR_ALREADY_INITIALIZED; + } + std::wistringstream iss(aCookie); + HANDLE mapHandle = NULL; + iss >> mapHandle; + if (!iss) { + return NS_ERROR_ILLEGAL_VALUE; + } + ScopedMappedFileView view(::MapViewOfFile(mapHandle, + FILE_MAP_WRITE, + 0, 0, 0)); + if (!view.IsValid()) { + return NS_ERROR_FAILURE; + } + MEMORY_BASIC_INFORMATION memInfo = {0}; + SIZE_T querySize = ::VirtualQuery(view, &memInfo, sizeof(memInfo)); + unsigned int mappingSize = 0; + if (querySize) { + if (memInfo.RegionSize <= std::numeric_limits::max()) { + mappingSize = static_cast(memInfo.RegionSize); + } + } + if (!querySize || !mappingSize) { + return NS_ERROR_FAILURE; + } + nsresult rv = SetView(view, mappingSize, true); + if (NS_FAILED(rv)) { + return rv; + } + + const MiniShmInit* initStruct = nullptr; + rv = GetReadPtr(initStruct); + if (NS_FAILED(rv)) { + return rv; + } + if (!initStruct->mParentEvent || !initStruct->mParentGuard || + !initStruct->mChildEvent || !initStruct->mChildGuard) { + return NS_ERROR_FAILURE; + } + if (!::RegisterWaitForSingleObject(&mRegWait, + initStruct->mChildEvent, + &SOnEvent, + this, + INFINITE, + WT_EXECUTEDEFAULT)) { + return NS_ERROR_FAILURE; + } + + MiniShmInitComplete* initCompleteStruct = nullptr; + rv = GetWritePtrInternal(initCompleteStruct); + if (NS_FAILED(rv)) { + ::UnregisterWaitEx(mRegWait, INVALID_HANDLE_VALUE); + mRegWait = NULL; + return NS_ERROR_FAILURE; + } + + initCompleteStruct->mSucceeded = true; + + // We must set the member variables before we signal the event + mFileMapping = mapHandle; + mView = view.Take(); + mParentEvent = initStruct->mParentEvent; + mParentGuard = initStruct->mParentGuard; + mChildEvent = initStruct->mChildEvent; + mChildGuard = initStruct->mChildGuard; + SetObserver(aObserver); + mTimeout = aTimeout; + + rv = Send(); + if (NS_FAILED(rv)) { + initCompleteStruct->mSucceeded = false; + mFileMapping = NULL; + view.Set(mView); + mView = nullptr; + mParentEvent = NULL; + mParentGuard = NULL; + mChildEvent = NULL; + mChildGuard = NULL; + ::UnregisterWaitEx(mRegWait, INVALID_HANDLE_VALUE); + mRegWait = NULL; + return rv; + } + + OnConnect(); + return NS_OK; +} + +nsresult +MiniShmChild::Send() +{ + if (!mParentEvent || !mParentGuard) { + return NS_ERROR_NOT_INITIALIZED; + } + if (::WaitForSingleObject(mParentGuard, mTimeout) != WAIT_OBJECT_0) { + return NS_ERROR_FAILURE; + } + if (!::SetEvent(mParentEvent)) { + return NS_ERROR_FAILURE; + } + return NS_OK; +} + +void +MiniShmChild::OnEvent() +{ + MiniShmBase::OnEvent(); + ::SetEvent(mChildGuard); +} + +} // namespace plugins +} // namespace mozilla + diff --git a/dom/plugins/ipc/hangui/MiniShmChild.h b/dom/plugins/ipc/hangui/MiniShmChild.h new file mode 100644 index 000000000000..b6660103355e --- /dev/null +++ b/dom/plugins/ipc/hangui/MiniShmChild.h @@ -0,0 +1,68 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_MiniShmChild_h +#define mozilla_plugins_MiniShmChild_h + +#include "MiniShmBase.h" + +#include + +namespace mozilla { +namespace plugins { + +/** + * This class provides a lightweight shared memory interface for a child + * process in Win32. + * This code assumes that there is a parent-child relationship between + * processes, as it inherits handles from the parent process. + * Note that this class is *not* an IPDL actor. + * + * @see MiniShmParent + */ +class MiniShmChild : public MiniShmBase +{ +public: + MiniShmChild(); + virtual ~MiniShmChild(); + + /** + * Initialize shared memory on the child side. + * + * @param aObserver A MiniShmObserver object to receive event notifications. + * @param aCookie Cookie obtained from MiniShmParent::GetCookie + * @param aTimeout Timeout in milliseconds. + * @return nsresult error code + */ + nsresult + Init(MiniShmObserver* aObserver, const std::wstring& aCookie, + const DWORD aTimeout); + + virtual nsresult + Send() MOZ_OVERRIDE; + +protected: + void + OnEvent() MOZ_OVERRIDE; + +private: + HANDLE mParentEvent; + HANDLE mParentGuard; + HANDLE mChildEvent; + HANDLE mChildGuard; + HANDLE mFileMapping; + HANDLE mRegWait; + LPVOID mView; + DWORD mTimeout; + + DISALLOW_COPY_AND_ASSIGN(MiniShmChild); +}; + +} // namespace plugins +} // namespace mozilla + +#endif // mozilla_plugins_MiniShmChild_h + diff --git a/dom/plugins/ipc/hangui/PluginHangUI.h b/dom/plugins/ipc/hangui/PluginHangUI.h new file mode 100644 index 000000000000..2c6df78bb209 --- /dev/null +++ b/dom/plugins/ipc/hangui/PluginHangUI.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_PluginHangUI_h +#define mozilla_plugins_PluginHangUI_h + +namespace mozilla { +namespace plugins { + +enum HangUIUserResponse +{ + HANGUI_USER_RESPONSE_CANCEL = 1, + HANGUI_USER_RESPONSE_CONTINUE = 2, + HANGUI_USER_RESPONSE_STOP = 4, + HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN = 8 +}; + +enum PluginHangUIStructID +{ + PLUGIN_HANGUI_COMMAND = 0x10, + PLUGIN_HANGUI_RESULT +}; + +struct PluginHangUICommand +{ + enum + { + identifier = PLUGIN_HANGUI_COMMAND + }; + enum CmdCode + { + HANGUI_CMD_SHOW = 1, + HANGUI_CMD_CANCEL = 2 + }; + CmdCode mCode; +}; + +struct PluginHangUIResponse +{ + enum + { + identifier = PLUGIN_HANGUI_RESULT + }; + unsigned int mResponseBits; +}; + +} // namespace plugins +} // namespace mozilla + +#endif // mozilla_plugins_PluginHangUI_h + diff --git a/dom/plugins/ipc/hangui/PluginHangUIChild.cpp b/dom/plugins/ipc/hangui/PluginHangUIChild.cpp new file mode 100644 index 000000000000..9518e747cad8 --- /dev/null +++ b/dom/plugins/ipc/hangui/PluginHangUIChild.cpp @@ -0,0 +1,289 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "PluginHangUI.h" + +#include "PluginHangUIChild.h" +#include "HangUIDlg.h" + +#include +#include +#include +#include + +namespace mozilla { +namespace plugins { + +PluginHangUIChild* PluginHangUIChild::sSelf = nullptr; +const int PluginHangUIChild::kExpectedMinimumArgc = 9; +const DWORD PluginHangUIChild::kProcessTimeout = 1200000U; +const DWORD PluginHangUIChild::kShmTimeout = 5000U; + +PluginHangUIChild::PluginHangUIChild() + : mResponseBits(0), + mParentWindow(NULL), + mDlgHandle(NULL), + mMainThread(NULL), + mParentProcess(NULL), + mRegWaitProcess(NULL) +{ +} + +PluginHangUIChild::~PluginHangUIChild() +{ + if (mMainThread) { + CloseHandle(mMainThread); + } + if (mRegWaitProcess) { + UnregisterWaitEx(mRegWaitProcess, INVALID_HANDLE_VALUE); + } + if (mParentProcess) { + CloseHandle(mParentProcess); + } + sSelf = nullptr; +} + +bool +PluginHangUIChild::Init(int aArgc, wchar_t* aArgv[]) +{ + if (aArgc < kExpectedMinimumArgc) { + return false; + } + unsigned int i = 1; + mMessageText = aArgv[i]; + mWindowTitle = aArgv[++i]; + mWaitBtnText = aArgv[++i]; + mKillBtnText = aArgv[++i]; + mNoFutureText = aArgv[++i]; + std::wistringstream issHwnd(aArgv[++i]); + issHwnd >> reinterpret_cast(mParentWindow); + if (!issHwnd) { + return false; + } + std::wistringstream issProc(aArgv[++i]); + issProc >> mParentProcess; + if (!issProc) { + return false; + } + + nsresult rv = mMiniShm.Init(this, + std::wstring(aArgv[++i]), + IsDebuggerPresent() ? INFINITE : kShmTimeout); + if (NS_FAILED(rv)) { + return false; + } + sSelf = this; + return true; +} + +void +PluginHangUIChild::OnMiniShmEvent(MiniShmBase* aMiniShmObj) +{ + const PluginHangUICommand* cmd = nullptr; + nsresult rv = aMiniShmObj->GetReadPtr(cmd); + assert(NS_SUCCEEDED(rv)); + bool returnStatus = false; + if (NS_SUCCEEDED(rv)) { + switch (cmd->mCode) { + case PluginHangUICommand::HANGUI_CMD_SHOW: + returnStatus = RecvShow(); + break; + case PluginHangUICommand::HANGUI_CMD_CANCEL: + returnStatus = RecvCancel(); + break; + default: + break; + } + } +} + +// static +INT_PTR CALLBACK +PluginHangUIChild::SHangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, + WPARAM aWParam, LPARAM aLParam) +{ + PluginHangUIChild *self = PluginHangUIChild::sSelf; + if (self) { + return self->HangUIDlgProc(aDlgHandle, aMsgCode, aWParam, aLParam); + } + return FALSE; +} + +INT_PTR +PluginHangUIChild::HangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, + LPARAM aLParam) +{ + mDlgHandle = aDlgHandle; + switch (aMsgCode) { + case WM_INITDIALOG: { + // Disentangle our input queue from the hung Firefox process + AttachThreadInput(GetCurrentThreadId(), + GetWindowThreadProcessId(mParentWindow, nullptr), + FALSE); + // Register a wait on the Firefox process so that we will be informed + // if it dies while the dialog is showing + RegisterWaitForSingleObject(&mRegWaitProcess, + mParentProcess, + &SOnParentProcessExit, + this, + INFINITE, + WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE); + SetWindowText(aDlgHandle, mWindowTitle); + SetDlgItemText(aDlgHandle, IDC_MSG, mMessageText); + SetDlgItemText(aDlgHandle, IDC_NOFUTURE, mNoFutureText); + SetDlgItemText(aDlgHandle, IDC_CONTINUE, mWaitBtnText); + SetDlgItemText(aDlgHandle, IDC_STOP, mKillBtnText); + HANDLE icon = LoadImage(NULL, IDI_QUESTION, IMAGE_ICON, 0, 0, + LR_DEFAULTSIZE | LR_SHARED); + if (icon) { + SendDlgItemMessage(aDlgHandle, IDC_DLGICON, STM_SETICON, (WPARAM)icon, 0); + } + return TRUE; + } + case WM_CLOSE: { + mResponseBits |= HANGUI_USER_RESPONSE_CANCEL; + EndDialog(aDlgHandle, 0); + return TRUE; + } + case WM_COMMAND: { + switch (LOWORD(aWParam)) { + case IDC_CONTINUE: + if (HIWORD(aWParam) == BN_CLICKED) { + mResponseBits |= HANGUI_USER_RESPONSE_CONTINUE; + EndDialog(aDlgHandle, 1); + return TRUE; + } + break; + case IDC_STOP: + if (HIWORD(aWParam) == BN_CLICKED) { + mResponseBits |= HANGUI_USER_RESPONSE_STOP; + EndDialog(aDlgHandle, 1); + return TRUE; + } + break; + case IDC_NOFUTURE: + if (HIWORD(aWParam) == BN_CLICKED) { + if (Button_GetCheck(GetDlgItem(aDlgHandle, + IDC_NOFUTURE)) == BST_CHECKED) { + mResponseBits |= HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN; + } else { + mResponseBits &= + ~static_cast(HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN); + } + return TRUE; + } + default: + break; + } + return FALSE; + } + default: + return FALSE; + } +} + +// static +VOID CALLBACK +PluginHangUIChild::SOnParentProcessExit(PVOID aObject, BOOLEAN aIsTimer) +{ + // Simulate a cancel if the parent process died + PluginHangUIChild* object = static_cast(aObject); + object->RecvCancel(); +} + +bool +PluginHangUIChild::RecvShow() +{ + return (QueueUserAPC(&ShowAPC, + mMainThread, + reinterpret_cast(this))); +} + +bool +PluginHangUIChild::Show() +{ + INT_PTR dlgResult = DialogBox(GetModuleHandle(NULL), + MAKEINTRESOURCE(IDD_HANGUIDLG), + mParentWindow, + &SHangUIDlgProc); + mDlgHandle = NULL; + assert(dlgResult != -1); + bool result = false; + if (dlgResult != -1) { + PluginHangUIResponse* response = nullptr; + nsresult rv = mMiniShm.GetWritePtr(response); + if (NS_SUCCEEDED(rv)) { + response->mResponseBits = mResponseBits; + result = NS_SUCCEEDED(mMiniShm.Send()); + } + } + return result; +} + +// static +VOID CALLBACK +PluginHangUIChild::ShowAPC(ULONG_PTR aContext) +{ + PluginHangUIChild* object = reinterpret_cast(aContext); + object->Show(); +} + +bool +PluginHangUIChild::RecvCancel() +{ + if (mDlgHandle) { + PostMessage(mDlgHandle, WM_CLOSE, 0, 0); + } + return true; +} + +bool +PluginHangUIChild::WaitForDismissal() +{ + if (!SetMainThread()) { + return false; + } + DWORD waitResult = WaitForSingleObjectEx(mParentProcess, + kProcessTimeout, + TRUE); + return waitResult == WAIT_OBJECT_0 || + waitResult == WAIT_IO_COMPLETION; +} + +bool +PluginHangUIChild::SetMainThread() +{ + if (mMainThread) { + CloseHandle(mMainThread); + mMainThread = NULL; + } + mMainThread = OpenThread(THREAD_SET_CONTEXT, + FALSE, + GetCurrentThreadId()); + return !(!mMainThread); +} + +} // namespace plugins +} // namespace mozilla + +int +wmain(int argc, wchar_t *argv[]) +{ + INITCOMMONCONTROLSEX icc = { sizeof(INITCOMMONCONTROLSEX), + ICC_STANDARD_CLASSES }; + if (!InitCommonControlsEx(&icc)) { + return 1; + } + mozilla::plugins::PluginHangUIChild hangui; + if (!hangui.Init(argc, argv)) { + return 1; + } + if (!hangui.WaitForDismissal()) { + return 1; + } + return 0; +} + diff --git a/dom/plugins/ipc/hangui/PluginHangUIChild.h b/dom/plugins/ipc/hangui/PluginHangUIChild.h new file mode 100644 index 000000000000..13fbfacfeac7 --- /dev/null +++ b/dom/plugins/ipc/hangui/PluginHangUIChild.h @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_plugins_PluginHangUIChild_h +#define mozilla_plugins_PluginHangUIChild_h + +#include "MiniShmChild.h" + +#include + +#include + +namespace mozilla { +namespace plugins { + +/** + * This class implements the plugin-hang-ui. + * + * NOTE: PluginHangUIChild is *not* an IPDL actor! In this case, "Child" + * is describing the fact that plugin-hang-ui is a child process to the + * firefox process, which is the PluginHangUIParent. + * PluginHangUIParent and PluginHangUIChild are a matched pair. + * @see PluginHangUIParent + */ +class PluginHangUIChild : public MiniShmObserver +{ +public: + PluginHangUIChild(); + virtual ~PluginHangUIChild(); + + bool + Init(int aArgc, wchar_t* aArgv[]); + + /** + * Displays the Plugin Hang UI and does not return until the UI has + * been dismissed. + * + * @return true if the UI was displayed and the user response was + * successfully sent back to the parent. Otherwise false. + */ + bool + Show(); + + /** + * Causes the calling thread to wait either for the Hang UI to be + * dismissed or for the parent process to terminate. This should + * be called by the main thread. + * + * @return true unless there was an error initiating the wait + */ + bool + WaitForDismissal(); + + virtual void + OnMiniShmEvent(MiniShmBase* aMiniShmObj) MOZ_OVERRIDE; + +private: + bool + RecvShow(); + + bool + RecvCancel(); + + bool + SetMainThread(); + + INT_PTR + HangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, LPARAM aLParam); + + static VOID CALLBACK + ShowAPC(ULONG_PTR aContext); + + static INT_PTR CALLBACK + SHangUIDlgProc(HWND aDlgHandle, UINT aMsgCode, WPARAM aWParam, + LPARAM aLParam); + + static VOID CALLBACK + SOnParentProcessExit(PVOID aObject, BOOLEAN aIsTimer); + + static PluginHangUIChild *sSelf; + + const wchar_t* mMessageText; + const wchar_t* mWindowTitle; + const wchar_t* mWaitBtnText; + const wchar_t* mKillBtnText; + const wchar_t* mNoFutureText; + unsigned int mResponseBits; + HWND mParentWindow; + HWND mDlgHandle; + HANDLE mMainThread; + HANDLE mParentProcess; + HANDLE mRegWaitProcess; + MiniShmChild mMiniShm; + + static const int kExpectedMinimumArgc; + static const DWORD kProcessTimeout; + static const DWORD kShmTimeout; + + DISALLOW_COPY_AND_ASSIGN(PluginHangUIChild); +}; + +} // namespace plugins +} // namespace mozilla + +#endif // mozilla_plugins_PluginHangUIChild_h + diff --git a/dom/plugins/ipc/hangui/module.ver b/dom/plugins/ipc/hangui/module.ver new file mode 100644 index 000000000000..18bee790e889 --- /dev/null +++ b/dom/plugins/ipc/hangui/module.ver @@ -0,0 +1,6 @@ +WIN32_MODULE_COMPANYNAME=Mozilla Corporation +WIN32_MODULE_PRODUCTVERSION=@MOZ_APP_WINVERSION@ +WIN32_MODULE_PRODUCTVERSION_STRING=@MOZ_APP_VERSION@ +WIN32_MODULE_DESCRIPTION=Plugin Hang UI for @MOZ_APP_DISPLAYNAME@ +WIN32_MODULE_PRODUCTNAME=@MOZ_APP_DISPLAYNAME@ +WIN32_MODULE_NAME=@MOZ_APP_DISPLAYNAME@ diff --git a/dom/plugins/ipc/hangui/plugin-hang-ui.exe.manifest b/dom/plugins/ipc/hangui/plugin-hang-ui.exe.manifest new file mode 100644 index 000000000000..004e47d35ebb --- /dev/null +++ b/dom/plugins/ipc/hangui/plugin-hang-ui.exe.manifest @@ -0,0 +1,35 @@ + + + +Firefox Plugin Hang User Interface + + + + + + + + + + + + + + + + + + + diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 97d42cb998ca..33f3a05a17fe 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -1755,11 +1755,22 @@ pref("dom.ipc.plugins.parentTimeoutSecs", 0); // How long a plugin launch is allowed to take before // we consider it failed. pref("dom.ipc.plugins.processLaunchTimeoutSecs", 45); +#ifdef XP_WIN +// How long a plugin is allowed to process a synchronous IPC message +// before we display the plugin hang UI +pref("dom.ipc.plugins.hangUITimeoutSecs", 5); +// Minimum time that the plugin hang UI will be displayed +pref("dom.ipc.plugins.hangUIMinDisplaySecs", 10); +#endif #else // No timeout in DEBUG builds pref("dom.ipc.plugins.timeoutSecs", 0); pref("dom.ipc.plugins.processLaunchTimeoutSecs", 0); pref("dom.ipc.plugins.parentTimeoutSecs", 0); +#ifdef XP_WIN +pref("dom.ipc.plugins.hangUITimeoutSecs", 0); +pref("dom.ipc.plugins.hangUIMinDisplaySecs", 0); +#endif #endif #ifdef XP_WIN diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 82289a9e60e0..df619ca33190 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -1463,6 +1463,15 @@ "n_buckets": 10, "description": "Time spent checking if Java is enabled (ms)" }, + "PLUGIN_HANG_UI_USER_RESPONSE": { + "kind": "enumerated", + "n_values": 3, + "description": "User response to Plugin Hang UI" + }, + "PLUGIN_HANG_UI_DONT_ASK": { + "kind": "boolean", + "description": "Whether the user has requested not to see the Plugin Hang UI again" + }, "PLUGIN_SHUTDOWN_MS": { "kind": "exponential", "high": "5000", From bf3f84f8f185c705fe76f841ee2e4df77d81172f Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Thu, 3 Jan 2013 16:46:50 -0600 Subject: [PATCH 098/180] Bug 824217 - Remove the mode argument from the PIERCE macro to eliminate all but one use of JSRESOLVE_ASSIGNING from jswrapper.cpp. r=bholley --HG-- extra : rebase_source : 107e4a30956092daf38887cd4b329a6f3711f025 --- js/src/jswrapper.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/js/src/jswrapper.cpp b/js/src/jswrapper.cpp index 3510c232037a..7a5605b4e602 100644 --- a/js/src/jswrapper.cpp +++ b/js/src/jswrapper.cpp @@ -401,7 +401,7 @@ CrossCompartmentWrapper::~CrossCompartmentWrapper() { } -#define PIERCE(cx, wrapper, mode, pre, op, post) \ +#define PIERCE(cx, wrapper, pre, op, post) \ JS_BEGIN_MACRO \ bool ok; \ { \ @@ -417,7 +417,7 @@ bool CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, PropertyDescriptor *desc, unsigned flags) { - PIERCE(cx, wrapper, (flags & JSRESOLVE_ASSIGNING) ? SET : GET, + PIERCE(cx, wrapper, cx->compartment->wrapId(cx, &id), Wrapper::getPropertyDescriptor(cx, wrapper, id, desc, flags), cx->compartment->wrap(cx, desc)); @@ -427,7 +427,7 @@ bool CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, PropertyDescriptor *desc, unsigned flags) { - PIERCE(cx, wrapper, (flags & JSRESOLVE_ASSIGNING) ? SET : GET, + PIERCE(cx, wrapper, cx->compartment->wrapId(cx, &id), Wrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc, flags), cx->compartment->wrap(cx, desc)); @@ -437,7 +437,7 @@ bool CrossCompartmentWrapper::defineProperty(JSContext *cx, JSObject *wrapper, jsid id, PropertyDescriptor *desc) { AutoPropertyDescriptorRooter desc2(cx, desc); - PIERCE(cx, wrapper, SET, + PIERCE(cx, wrapper, cx->compartment->wrapId(cx, &id) && cx->compartment->wrap(cx, &desc2), Wrapper::defineProperty(cx, wrapper, id, &desc2), NOTHING); @@ -446,7 +446,7 @@ CrossCompartmentWrapper::defineProperty(JSContext *cx, JSObject *wrapper, jsid i bool CrossCompartmentWrapper::getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, NOTHING, Wrapper::getOwnPropertyNames(cx, wrapper, props), cx->compartment->wrap(cx, props)); @@ -455,7 +455,7 @@ CrossCompartmentWrapper::getOwnPropertyNames(JSContext *cx, JSObject *wrapper, A bool CrossCompartmentWrapper::delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) { - PIERCE(cx, wrapper, SET, + PIERCE(cx, wrapper, cx->compartment->wrapId(cx, &id), Wrapper::delete_(cx, wrapper, id, bp), NOTHING); @@ -464,7 +464,7 @@ CrossCompartmentWrapper::delete_(JSContext *cx, JSObject *wrapper, jsid id, bool bool CrossCompartmentWrapper::enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, NOTHING, Wrapper::enumerate(cx, wrapper, props), cx->compartment->wrap(cx, props)); @@ -473,7 +473,7 @@ CrossCompartmentWrapper::enumerate(JSContext *cx, JSObject *wrapper, AutoIdVecto bool CrossCompartmentWrapper::has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) { - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, cx->compartment->wrapId(cx, &id), Wrapper::has(cx, wrapper, id, bp), NOTHING); @@ -482,7 +482,7 @@ CrossCompartmentWrapper::has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp bool CrossCompartmentWrapper::hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) { - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, cx->compartment->wrapId(cx, &id), Wrapper::hasOwn(cx, wrapper, id, bp), NOTHING); @@ -495,7 +495,7 @@ CrossCompartmentWrapper::get(JSContext *cx, JSObject *wrapperArg, JSObject *rece RootedObject wrapper(cx, wrapperArg); RootedObject receiver(cx, receiverArg); RootedId id(cx, idArg); - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, cx->compartment->wrap(cx, receiver.address()) && cx->compartment->wrapId(cx, id.address()), Wrapper::get(cx, wrapper, receiver, id, vp), cx->compartment->wrap(cx, vp)); @@ -508,7 +508,7 @@ CrossCompartmentWrapper::set(JSContext *cx, JSObject *wrapper_, JSObject *receiv RootedObject wrapper(cx, wrapper_), receiver(cx, receiver_); RootedId id(cx, id_); RootedValue value(cx, *vp); - PIERCE(cx, wrapper, SET, + PIERCE(cx, wrapper, cx->compartment->wrap(cx, receiver.address()) && cx->compartment->wrapId(cx, id.address()) && cx->compartment->wrap(cx, value.address()), @@ -519,7 +519,7 @@ CrossCompartmentWrapper::set(JSContext *cx, JSObject *wrapper_, JSObject *receiv bool CrossCompartmentWrapper::keys(JSContext *cx, JSObject *wrapper, AutoIdVector &props) { - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, NOTHING, Wrapper::keys(cx, wrapper, props), cx->compartment->wrap(cx, props)); @@ -606,7 +606,7 @@ Reify(JSContext *cx, JSCompartment *origin, Value *vp) bool CrossCompartmentWrapper::iterate(JSContext *cx, JSObject *wrapper, unsigned flags, Value *vp) { - PIERCE(cx, wrapper, GET, + PIERCE(cx, wrapper, NOTHING, Wrapper::iterate(cx, wrapper, flags, vp), CanReify(vp) ? Reify(cx, cx->compartment, vp) : cx->compartment->wrap(cx, vp)); From 4a62a2dda655ba4976d9a1b76e50b5352d5395cb Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Thu, 3 Jan 2013 17:55:58 -0600 Subject: [PATCH 099/180] Bug 824217 - Make ChromeObjectWrapper::getPropertyDescriptor not pretend no descriptor exists when the property exists along the prototype chain, when the property is being resolved just before an assignment. r=bholley --- js/xpconnect/wrappers/ChromeObjectWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp index 109c91286699..d5fd96373ff6 100644 --- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp @@ -43,11 +43,11 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx, JSObject *wrapper, if (desc->obj && PropIsFromStandardPrototype(cx, desc)) desc->obj = NULL; - // If we found something, were doing a set, or have no proto, we're done. + // If we found something or have no proto, we're done. JSObject *wrapperProto; if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) return false; - if (desc->obj || (flags & JSRESOLVE_ASSIGNING) || !wrapperProto) + if (desc->obj || !wrapperProto) return true; // If not, try doing the lookup on the prototype. From 192b78fa9c6e3e6901e3262f4ac721c380ebe6c3 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Fri, 4 Jan 2013 17:00:43 -0600 Subject: [PATCH 100/180] Whitespace tab-killing patrol. No bug, r=sparky --- js/xpconnect/wrappers/ChromeObjectWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp index d5fd96373ff6..f2f6c79e6aff 100644 --- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp @@ -65,7 +65,7 @@ ChromeObjectWrapper::has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) // If we found something or have no prototype, we're done. JSObject *wrapperProto; if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) - return false; + return false; if (*bp || !wrapperProto) return true; @@ -106,7 +106,7 @@ ChromeObjectWrapper::get(JSContext *cx, JSObject *wrapper, JSObject *receiver, // If we have no proto, we're done. JSObject *wrapperProto; if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) - return false; + return false; if (!wrapperProto) return true; From bae49490f6c10f00f076564a5fdfff011122ff44 Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Fri, 4 Jan 2013 12:48:50 -0800 Subject: [PATCH 101/180] Bug 826820: Remove "synced tabs" menu item in Tabs Panel. [r=mfinkle] --- mobile/android/base/Makefile.in | 3 --- mobile/android/base/TabsPanel.java | 24 ------------------ .../base/locales/en-US/android_strings.dtd | 1 - .../drawable-hdpi/ic_menu_synced_tabs.png | Bin 1883 -> 0 bytes .../drawable-xhdpi/ic_menu_synced_tabs.png | Bin 2116 -> 0 bytes .../drawable/ic_menu_synced_tabs.png | Bin 1700 -> 0 bytes .../base/resources/menu-v11/tabs_menu.xml | 5 ---- .../android/base/resources/menu/tabs_menu.xml | 5 ---- mobile/android/base/strings.xml.in | 1 - 9 files changed, 39 deletions(-) delete mode 100644 mobile/android/base/resources/drawable-hdpi/ic_menu_synced_tabs.png delete mode 100644 mobile/android/base/resources/drawable-xhdpi/ic_menu_synced_tabs.png delete mode 100644 mobile/android/base/resources/drawable/ic_menu_synced_tabs.png diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 20773ee862b9..0d2aee13954f 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -527,7 +527,6 @@ RES_DRAWABLE_BASE = \ res/drawable/ic_menu_new_private_tab_small.png \ res/drawable/ic_menu_new_tab_small.png \ res/drawable/ic_menu_reload.png \ - res/drawable/ic_menu_synced_tabs.png \ res/drawable/ic_menu_quit.xml \ res/drawable/ic_status_logo.png \ res/drawable/remote_tabs_off.png \ @@ -617,7 +616,6 @@ RES_DRAWABLE_HDPI = \ res/drawable-hdpi/ic_menu_new_tab.png \ res/drawable-hdpi/ic_menu_new_tab_small.png \ res/drawable-hdpi/ic_menu_reload.png \ - res/drawable-hdpi/ic_menu_synced_tabs.png \ res/drawable-hdpi/ic_status_logo.png \ res/drawable-hdpi/remote_tabs_off.png \ res/drawable-hdpi/remote_tabs_on.png \ @@ -705,7 +703,6 @@ RES_DRAWABLE_XHDPI = \ res/drawable-xhdpi/ic_menu_new_tab.png \ res/drawable-xhdpi/ic_menu_new_tab_small.png \ res/drawable-xhdpi/ic_menu_reload.png \ - res/drawable-xhdpi/ic_menu_synced_tabs.png \ res/drawable-xhdpi/ic_status_logo.png \ res/drawable-xhdpi/tab_new.png \ res/drawable-xhdpi/tab_close.png \ diff --git a/mobile/android/base/TabsPanel.java b/mobile/android/base/TabsPanel.java index 38f9ae905b93..ac4225867329 100644 --- a/mobile/android/base/TabsPanel.java +++ b/mobile/android/base/TabsPanel.java @@ -203,26 +203,6 @@ public class TabsPanel extends TabHost mMenu.findItem(R.id.close_all_tabs).setEnabled(true); mPopupMenu.show(); - - final Context context = mContext; - new SyncAccounts.AccountsExistTask() { - @Override - protected void onPostExecute(Boolean result) { - if (!result.booleanValue()) { - return; - } - TabsAccessor.areClientsAvailable(context, new TabsAccessor.OnClientsAvailableListener() { - @Override - public void areAvailable(boolean available) { - TabsPanel.this.enableRemoteTabs(available); - } - }); - } - }.execute(context); - } - - public void enableRemoteTabs(boolean enable) { - mMenu.findItem(R.id.synced_tabs).setEnabled(enable); } public void openTabsSwitcherMenu() { @@ -247,10 +227,6 @@ public class TabsPanel extends TabHost show(Panel.REMOTE_TABS); return true; - case R.id.synced_tabs: - show(Panel.REMOTE_TABS); - return true; - case R.id.close_all_tabs: for (Tab tab : Tabs.getInstance().getTabsInOrder()) { Tabs.getInstance().closeTab(tab); diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 21ac429fb686..c0f55c96d645 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -137,7 +137,6 @@ size. --> - diff --git a/mobile/android/base/resources/drawable-hdpi/ic_menu_synced_tabs.png b/mobile/android/base/resources/drawable-hdpi/ic_menu_synced_tabs.png deleted file mode 100644 index 9051d910b359814aaf08120783bbfba244d23678..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1883 zcmbVNX;c$e6pm^n3Z*2@Uk*O!=;$Ldhs94%6cdiHeNGfdCB_jfdcv zDt^NaT*P1uR}*0?s1@=+p_0_FFslyBsL|1A21B&asKb=&aSDjUqY14TeDzZ)2oNeU zxSS_v%XLy*P53A1@z8{zFlEAer9cHP^a4aiAx)scDGV@bVzdUKQ49|73hA{~41vIa z3bkGgzH@4YJQ$FYdK}=fIPOX|3V3+D3peAo>@*f0XI>4)zQbA>#<5b*#8FOasT zS49a!P}!g@dM5_e6r~eFP+VLbD~`h=_0bS45D2Us2;xp_xEtcN6lQeS8fFeLptwP) zCv+4+Y5^-F7D>iZVvzRqT?iVTT>hR|YZy!voifOX=^&WJhBO*$Tm#w$Dg^)6jSp%Y z!s2x}6oMPbSiO=ykEoeLU^;gnH)K_$y%8$(1brx23`#0vHMo`vK*b>ag{2}?LYb$B z42C_pY!8IZ_k>|jwkJpCg9s!7sV{kmtV)3m;5b=Fq@5%J93dCHNyxZte* zy;mZ!{h5_}H{NrOd)m5dN=zZQwemKr;e3OOE2pq5xi`71{!K~gV&-?j`JlJ+*tF*M zsphi%yZp7|6QS;uSvUMTI$7&nTG}SCPvn(&7sKt(8smzNJa7zmC@=GV?i7B_r|H*4 z7FWyD`jWRZjrWqai)Syl8RACXZOlhCqd)-jriL7(F_vY;LNy#C20Qa^WKK?97EPh5c21 z)!R`U#m?MjNbPndTeNvmdsyFwjq8q`JJ+TMUW%H|?H-%ke95kG_cN4)paB*v1EerR<~JhJT4ML6Al?M#VE{R(*Mo0G(8ak)R^kz=x7 z`ut0T2^iJ5=4w&rnZW$^)I%;Ahh303G9CuRUkIsP`x-?L6$V` zxv@57>FX0(mHBzZE)K3&%^I68#VSl6UZd#?oGCY1)G46ec&mba(BZ5%g^5^`fS+CEcn8ftlIM8lQMsm=5O?=esscnl$@) z>C#`y|2liop$k5Z0)M}7N3iqymQxl@a1^Ox1iUyJg25;*wY6~@X~_r*x_AU zSFSRa+GVSoxsUpLZ}zl27Y$|zCmcdPsFx=0Kr%J_W%F@ diff --git a/mobile/android/base/resources/drawable-xhdpi/ic_menu_synced_tabs.png b/mobile/android/base/resources/drawable-xhdpi/ic_menu_synced_tabs.png deleted file mode 100644 index 8fe0f6a2933201426f3a5ee0113703dcf7888d46..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2116 zcmbVNd010d7SEtyj9{@aP*5QTtdWrx)U875FZH=2FD{hsRqLEHeHgo$rE2zW&t zj}XBSQABD1Bv<&SX`ryQ&Ec}NBpEx7@bO1@Pdx`EP(p|luU96kv>ZK;Fwe_D=O!_k zfS*@El6ZtSPDw;!ya3ifcm|2)E~5Ydp2;KubOw_NY{FA10F_KZAErA%=P;NYst11I zBB0hZaq*l`(09QWy5bS!2%_eY$vT~mq@$5wO#&HUv)LvND%Bm;aMz})5UJi>rFB_k z03oeRqfjFXScNw+N_W612#L1)#B6EPx4sfDZupQ28`( zKAR2#3>q6?uqfanR;bbA@U)j}afwSbp6x{kO+Y0=Mz-BDW&2wqWM&ig-9=7~5FYB%_ zr+~3L>nugx{?^1oRUefuACbKSdl9V<jkv_ z*zMo@N{q8T*O~N~kTG0K?aOK`*+*8{4L=`q-(AJM-2Xyance;C_SKH$OS2OnaIq~0 z2SHWsw@I46jsMW)O?#ZnNdUj&**$WysUDd!-K96q9b(m&dI9?$L|w1!mPz69E~jWGLlk#k+lE|6Ix91B zdGxI!z;;D?i#QN-9-nKMm{NQpuV9^B?vma!22S6&dFPEP*MRqh>uvJxZWI=LBkUQT z{%iNyx`KdJ+)I~Md~u+_|4hvG@&VFrE8|yxiLCuV@z455r~3eL`acmyEz=^>GA-{! zOfc+a*%wq89XN2drpbO~w~lz@rw}hByd$=Pb;=q=yUsi^Pv9_0TuB!))aGq1tus+(#s-36H1NB7PgtCq z({`U8ANU_bn?fa!a>gA3#u8$H9 zsq;LOGq6S3oxw*aLwrdA(PEE`JF=~8q$7|N+!)yb^0}Q$GK*4Dj~9WzPK%!w<&C?U zwO>pW&fIj*%P*e_I5A*+#xQ&(x#Imz{1hQ;FhU+#Je>3N-&er3PdSM5?EV{7Mb33d z#@e>Y^o)V}O5%X!?I*8dTsG9U^6K}G-ofVX9Yy;*(`yyl=X~RQpM&QjX0a4Zzu(Sa Sqq=hb$1e2Q3^sYkX8r+@cUu(z diff --git a/mobile/android/base/resources/drawable/ic_menu_synced_tabs.png b/mobile/android/base/resources/drawable/ic_menu_synced_tabs.png deleted file mode 100644 index 9a9ad251968389feeac60d3b037b80cdf42f80dd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1700 zcmbVNc~BEq7>}ZI3Dt_0Iw)(j5UNRbHwQ@|#E?xmBpe|s3LZHY5=pXgvmr55Ww-`( z#uGd!-~lL7MXKYdD3uY>p;o!-G1k`BRh*C={QVXhcDdpSxacE9dR6ws4 zQkQe&pxi7$b^2%rjwU(M_fY=-^7g_|sAOtf(^5N1Uwt&MGz@fm{MJ27_ z+H`>ek&W3RS3;_eAj|?L(`K_VY%B(bXD}f?pYP&;VLGWnw`?#GDm&d|nLo~epcW0T zHxqiy1h^PgYRpOqsidcGLNJ=;^0&k$%UGhwlrilpGZSKfOry~i*QmCIP@w<0@lI`v za)TLVDo_h%#Wm!4q|YA*lev4pA(tZQjUWNnlZT=*AehE#L`_5tBBYW#46R-(knuug z5ERM=Lt&81gCHKrW62_6zL+nO!Y~UO=Xe)Z%3*P2G6^3-$QzQvVpgP>&qg2)iw|*l zATo}PFctM=P{Rbb)SWcRQcu79Sa-jmDbr>|m#$6EFA(KSKC?u+*EHSD4+50d5Vu8B z`xFsMYi$=@{?Px`Hrrv}posFYYgx5_NP`~;4-5>yj)>os6jJl8Shvo%EN?Em;|JS7 z;BBjBZXv7V#?%!7PZriYe@acWkDM3^^7UkgpGo2_+BTFQ$$Q9ogL zGAAgm^Jtyg|A>0U9_INgsfGMgNuq$K&nwQ~Dz$l2dXKc~%Vt%UH{wUrA~+YAT?LEt zpjX4r9#&3ThI&m_l_L{q*n6f%)YEXu%Q3sA>#pH@OOgB2p{};CD*)}lFt4JU*4>@q z(|))*>^3{Dsz3PFzRFFnWQ~o>*jaz`B=hfdAfhzx5T6P!1Me5H6g9FfStmc%Jv>U@(s8<>w%*Arlx`M*xNh*5!MNvb&%P@A z^}1Kk)5B&ok~IeeJs999e(XdNsTtPch^Z zd5;r+vFU8z-;WOVw%n^r^e-y8-u30V`s}znEmw!aPnIix&wW%?xqr@a-O4Rnc6@YY z-Qo=mZY&=DWa&thi7c&=jDw=d{*;N-mw^v - - diff --git a/mobile/android/base/resources/menu/tabs_menu.xml b/mobile/android/base/resources/menu/tabs_menu.xml index db0b237e4400..56d272a5eb38 100644 --- a/mobile/android/base/resources/menu/tabs_menu.xml +++ b/mobile/android/base/resources/menu/tabs_menu.xml @@ -13,11 +13,6 @@ android:icon="@drawable/ic_menu_new_private_tab_small" android:title="@string/new_private_tab"/> - - diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 5618d8a72938..1a2cf3824324 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -140,7 +140,6 @@ &char_encoding; &new_tab; &new_private_tab; - &synced_tabs; &close_all_tabs; &tabs_normal; &tabs_private; From 6cce2e667e47386efde5e5c8fe3c40868254a582 Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Fri, 4 Jan 2013 18:13:12 -0500 Subject: [PATCH 102/180] Bug 825594: Pref on mozGetUserMedia by default rs=jlebar --- modules/libpref/src/init/all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 33f3a05a17fe..1b42f77b21f8 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -175,7 +175,7 @@ pref("media.dash.enabled", false); pref("media.gstreamer.enabled", true); #endif #ifdef MOZ_WEBRTC -pref("media.navigator.enabled", false); +pref("media.navigator.enabled", true); pref("media.peerconnection.enabled", false); pref("media.navigator.permission.disabled", false); #else From 6bac6039fa4b4b4098a17b196d463c7ceebebdd0 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Sat, 5 Jan 2013 10:24:53 +1100 Subject: [PATCH 103/180] Bug 826195 - Tweak nsPrintObject sanity assertions. r=dholbert --- layout/printing/nsPrintData.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layout/printing/nsPrintData.cpp b/layout/printing/nsPrintData.cpp index c4c97f927ef2..9319ac643fd4 100644 --- a/layout/printing/nsPrintData.cpp +++ b/layout/printing/nsPrintData.cpp @@ -104,12 +104,12 @@ AssertPresShellsAndContextsSane(nsPrintObject* aPO, if (!aPO->mPresShell && aPO->mPresContext) { ASSERT_AND_NOTE("print object has pres context but no pres shell"); } - if (aPO->mPresContext && aPO->mPresContext->GetPresShell() != aPO->mPresShell) { + if (aPO->mPresContext && + aPO->mPresShell && + aPO->mPresContext->GetPresShell() && + aPO->mPresContext->GetPresShell() != aPO->mPresShell) { ASSERT_AND_NOTE("print object has mismatching pres shell and pres context"); } - if (aPO->mPresContext && !aPO->mPresContext->GetPresShell()) { - ASSERT_AND_NOTE("mPresShell->GetPresShell() is null"); - } for (uint32_t i = 0; i < aPO->mKids.Length(); i++) { AssertPresShellsAndContextsSane(aPO->mKids[i], aPresShells, aPresContexts); From 9e5ffb8cc2095c95ab161827802bf0d0127c06a1 Mon Sep 17 00:00:00 2001 From: Gregor Wagner Date: Fri, 4 Jan 2013 16:04:28 -0800 Subject: [PATCH 104/180] Bug 821814 - Settings: upgrade settings DB after settings.json changed. r=bent --- dom/settings/SettingsDB.jsm | 61 +++++++--- dom/settings/SettingsManager.js | 115 +++++++++++-------- dom/settings/tests/test_settings_basics.html | 97 +++++++++++++--- 3 files changed, 195 insertions(+), 78 deletions(-) diff --git a/dom/settings/SettingsDB.jsm b/dom/settings/SettingsDB.jsm index 60f570641e14..bc4004855cfc 100644 --- a/dom/settings/SettingsDB.jsm +++ b/dom/settings/SettingsDB.jsm @@ -2,19 +2,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + let Cc = Components.classes; let Ci = Components.interfaces; let Cu = Components.utils; this.EXPORTED_SYMBOLS = ["SettingsDB", "SETTINGSDB_NAME", "SETTINGSSTORE_NAME"]; -const DEBUG = false; +const DEBUG = true; function debug(s) { if (DEBUG) dump("-*- SettingsDB: " + s + "\n"); } this.SETTINGSDB_NAME = "settings"; -this.SETTINGSDB_VERSION = 1; +this.SETTINGSDB_VERSION = 2; this.SETTINGSSTORE_NAME = "settings"; Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); @@ -28,13 +30,17 @@ SettingsDB.prototype = { __proto__: IndexedDBHelper.prototype, upgradeSchema: function upgradeSchema(aTransaction, aDb, aOldVersion, aNewVersion) { - let objectStore = aDb.createObjectStore(SETTINGSSTORE_NAME, - { keyPath: "settingName" }); - objectStore.createIndex("settingValue", "settingValue", { unique: false }); - if (DEBUG) debug("Created object stores and indexes"); - - if (aOldVersion != 0) { - return; + let objectStore; + if (aOldVersion == 0) { + objectStore = aDb.createObjectStore(SETTINGSSTORE_NAME, { keyPath: "settingName" }); + if (DEBUG) debug("Created object stores"); + } else if (aOldVersion == 1) { + if (DEBUG) debug("Get object store for upgrade and remove old index"); + objectStore = aTransaction.objectStore(SETTINGSSTORE_NAME); + objectStore.deleteIndex("settingValue"); + } else { + if (DEBUG) debug("Get object store for upgrade"); + objectStore = aTransaction.objectStore(SETTINGSSTORE_NAME); } // Loading resource://app/defaults/settings.json doesn't work because @@ -66,12 +72,39 @@ SettingsDB.prototype = { if (DEBUG) debug("Error parsing " + settingsFile.path + " : " + e); return; } + stream.close(); - for (let setting in settings) { - if (DEBUG) debug("Adding setting " + setting); - objectStore.put({ settingName: setting, - settingValue: settings[setting] }); - } + objectStore.openCursor().onsuccess = function(event) { + let cursor = event.target.result; + if (cursor) { + let value = cursor.value; + if (value.settingName in settings) { + if (DEBUG) debug("Upgrade " +settings[value.settingName]); + value.defaultValue = settings[value.settingName]; + delete settings[value.settingName]; + if ("settingValue" in value) { + value.userValue = value.settingValue; + delete value.settingValue; + } + cursor.update(value); + } else if ("userValue" in value || "settingValue" in value) { + value.defaultValue = undefined; + if (aOldVersion == 1 && value.settingValue) { + value.userValue = value.settingValue; + delete value.settingValue; + } + cursor.update(value); + } else { + cursor.delete(); + } + cursor.continue(); + } else { + for (let name in settings) { + if (DEBUG) debug("Set new:" + name +", " + settings[name]); + objectStore.add({ settingName: name, defaultValue: settings[name], userValue: undefined }); + } + } + }; }, init: function init(aGlobal) { diff --git a/dom/settings/SettingsManager.js b/dom/settings/SettingsManager.js index 3bd9d01250b7..578f770e03d7 100644 --- a/dom/settings/SettingsManager.js +++ b/dom/settings/SettingsManager.js @@ -4,7 +4,7 @@ "use strict"; -const DEBUG = false; +const DEBUG = true; function debug(s) { if (DEBUG) dump("-*- SettingsManager: " + s + "\n"); } @@ -30,6 +30,7 @@ const nsIDOMSettingsLock = Ci.nsIDOMSettingsLock; function SettingsLock(aSettingsManager) { this._open = true; + this._isBusy = false; this._requests = new Queue(); this._settingsManager = aSettingsManager; this._transaction = null; @@ -48,11 +49,15 @@ SettingsLock.prototype = { let request = info.request; switch (info.intent) { case "clear": - let req = store.clear(); - req.onsuccess = function() { this._open = true; - Services.DOMRequest.fireSuccess(request, 0); - this._open = false; }.bind(lock); - req.onerror = function() { Services.DOMRequest.fireError(request, 0) }; + let clearReq = store.clear(); + clearReq.onsuccess = function() { + this._open = true; + Services.DOMRequest.fireSuccess(request, 0); + this._open = false; + }.bind(lock); + clearReq.onerror = function() { + Services.DOMRequest.fireError(request, 0) + }; break; case "set": let keys = Object.getOwnPropertyNames(info.settings); @@ -60,49 +65,64 @@ SettingsLock.prototype = { let key = keys[i]; let last = i === keys.length - 1; if (DEBUG) debug("key: " + key + ", val: " + JSON.stringify(info.settings[key]) + ", type: " + typeof(info.settings[key])); - + lock._isBusy = true; let checkKeyRequest = store.get(key); + checkKeyRequest.onsuccess = function (event) { - if (!event.target.result) { - if (DEBUG) debug("MOZSETTINGS-SET-WARNING: " + key + " is not in the database. Please add it to build/settings.js\n"); + let defaultValue; + let userValue = info.settings[key]; + if (event.target.result) { + defaultValue = event.target.result.defaultValue; + } else { + defaultValue = null; + if (DEBUG) debug("MOZSETTINGS-SET-WARNING: " + key + " is not in the database.\n"); } + + let setReq; + if (typeof(info.settings[key]) != 'object') { + let obj = {settingName: key, defaultValue: defaultValue, userValue: userValue}; + if (DEBUG) debug("store1: " + JSON.stringify(obj)); + setReq = store.put(obj); + } else { + //Workaround for cloning issues + let defaultVal = JSON.parse(JSON.stringify(defaultValue)); + let userVal = JSON.parse(JSON.stringify(userValue)); + let obj = {settingName: key, defaultValue: defaultVal, userValue: userVal}; + if (DEBUG) debug("store2: " + JSON.stringify(obj)); + setReq = store.put(obj); + } + + setReq.onsuccess = function() { + lock._isBusy = false; + cpmm.sendAsyncMessage("Settings:Changed", { key: key, value: userValue }); + if (last && !request.error) { + lock._open = true; + Services.DOMRequest.fireSuccess(request, 0); + lock._open = false; + if (!lock._requests.isEmpty()) { + lock.process(); + } + } + }; + + setReq.onerror = function() { + if (!request.error) { + Services.DOMRequest.fireError(request, setReq.error.name) + } + }; } - - if(typeof(info.settings[key]) != 'object') { - req = store.put({settingName: key, settingValue: info.settings[key]}); - } else { - //Workaround for cloning issues - let obj = JSON.parse(JSON.stringify(info.settings[key])); - req = store.put({settingName: key, settingValue: obj}); - } - - req.onsuccess = function() { - if (last && !request.error) { - lock._open = true; - Services.DOMRequest.fireSuccess(request, 0); - lock._open = false; - } - cpmm.sendAsyncMessage("Settings:Changed", { key: key, value: info.settings[key] }); - }; - - req.onerror = function() { - if (!request.error) { - Services.DOMRequest.fireError(request, req.error.name) - } - }; } break; case "get": - req = (info.name === "*") ? store.mozGetAll() - : store.mozGetAll(info.name); + let getReq = (info.name === "*") ? store.mozGetAll() + : store.mozGetAll(info.name); - req.onsuccess = function(event) { + getReq.onsuccess = function(event) { if (DEBUG) debug("Request for '" + info.name + "' successful. " + "Record count: " + event.target.result.length); - if (DEBUG) debug("result: " + JSON.stringify(event.target.result)); if (event.target.result.length == 0) { - if (DEBUG) debug("MOZSETTINGS-GET-WARNING: " + info.name + " is not in the database. Please add it to build/settings.js\n"); + if (DEBUG) debug("MOZSETTINGS-GET-WARNING: " + info.name + " is not in the database.\n"); } let results = { @@ -113,7 +133,8 @@ SettingsLock.prototype = { for (var i in event.target.result) { let result = event.target.result[i]; var name = result.settingName; - var value = result.settingValue; + if (DEBUG) debug("VAL: " + result.userValue +", " + result.defaultValue + "\n"); + var value = result.userValue !== undefined ? result.userValue : result.defaultValue; results[name] = value; results.__exposedProps__[name] = "r"; // If the value itself is an object, expose the properties. @@ -129,14 +150,12 @@ SettingsLock.prototype = { this._open = false; }.bind(lock); - req.onerror = function() { + getReq.onerror = function() { Services.DOMRequest.fireError(request, 0) }; break; } } - if (!lock._requests.isEmpty()) - throw Components.results.NS_ERROR_ABORT; lock._open = true; }, @@ -148,10 +167,15 @@ SettingsLock.prototype = { let transactionType = this._settingsManager.hasWritePrivileges ? "readwrite" : "readonly"; lock._transaction = lock._settingsManager._settingsDB._db.transaction(SETTINGSSTORE_NAME, transactionType); } - lock.process(); + if (!lock._isBusy) { + lock.process(); + } else { + this._settingsManager._locks.enqueue(lock); + } } - if (!this._requests.isEmpty()) + if (!this._requests.isEmpty() && !this._isBusy) { this.process(); + } } }, @@ -181,7 +205,8 @@ SettingsLock.prototype = { if (this._settingsManager.hasWritePrivileges) { let req = Services.DOMRequest.createRequest(this._settingsManager._window); if (DEBUG) debug("send: " + JSON.stringify(aSettings)); - this._requests.enqueue({request: req, intent: "set", settings: aSettings}); + let settings = JSON.parse(JSON.stringify(aSettings)); + this._requests.enqueue({request: req, intent: "set", settings: settings}); this.createTransactionAndProcess(); return req; } else { @@ -266,7 +291,7 @@ SettingsManager.prototype = { this._locks.enqueue(lock); this._settingsDB.ensureDB( function() { lock.createTransactionAndProcess(); }, - function() { dump("ensureDB error cb!\n"); }, + function() { dump("Cannot open Settings DB. Trying to open an old version?\n"); }, myGlobal ); this.nextTick(function() { this._open = false; }, lock); return lock; diff --git a/dom/settings/tests/test_settings_basics.html b/dom/settings/tests/test_settings_basics.html index a879fb064f67..b7caac14a48b 100644 --- a/dom/settings/tests/test_settings_basics.html +++ b/dom/settings/tests/test_settings_basics.html @@ -35,11 +35,13 @@ function onFailure() { ok(false, "in on Failure!"); } -var wifi = {"net3g.apn": "internet.mnc012.mcc345.gprs"}; -var wifi2 = {"net3g.apn": "internet.mnc012.mcc345.test"}; +const wifi = {"net3g.apn": "internet.mnc012.mcc345.gprs"}; +const wifi2 = {"net3g.apn": "internet.mnc012.mcc345.test"}; +var wifi3 = {"net3g.apn2": "internet.mnc012.mcc345.test3"}; var wifiEnabled = {"wifi.enabled": true}; var wifiDisabled = {"wifi.enabled": false}; var screenBright = {"screen.brightness": 0.7}; +var screenBright2 = {"screen.brightness": 0.1}; var wifiNetworks0 = { "wifi.networks[0]": { ssid: "myfreenetwork", mac: "01:23:45:67:89:ab", passwd: "secret"}}; var wifiNetworks1 = { "wifi.networks[1]": { ssid: "myfreenetwork2", mac: "01:23:45:67:89:ab", passwd: "secret2"}}; @@ -47,7 +49,8 @@ var combination = { "wifi.enabled": false, "screen.brightness": 0.7, "wifi.networks[0]": { ssid: "myfreenetwork", mac: "01:23:45:67:89:ab", passwd: "secret" }, - "test.test": true + "test.test": true, + "net3g.apn2": "internet.mnc012.mcc345.gprs" } function equals(o1, o2) { @@ -101,14 +104,70 @@ var steps = [ req = lock.clear(); req.onsuccess = function () { ok(true, "Deleted the database"); + next(); + }; + }, + function () { + ok(true, "Setting wifi"); + var lock = mozSettings.createLock(); + req = lock.set(wifi); + req.onsuccess = function () { + ok(true, "set done"); + } + req.onerror = onFailure; + + var lock2 = mozSettings.createLock(); + req2 = lock2.get("net3g.apn"); + req2.onsuccess = function () { + is(Object.keys(req2.result).length, 1, "length 1"); + check(wifi, req2.result); + ok(true, "Get net3g.apn Done"); + next(); + }; + req2.onerror = onFailure; + }, + function () { + ok(true, "Change wifi1"); + var lock = mozSettings.createLock(); + req = lock.set(wifi2); + req.onsuccess = function () { + ok(true, "Set Done"); }; req.onerror = onFailure; - req2 = lock.set(screenBright); + ok(true, "Get changed net3g.apn"); + req2 = lock.get("net3g.apn"); req2.onsuccess = function () { + is(Object.keys(req2.result).length, 1, "length 1"); + check(wifi2, req2.result); + ok(true, "Get net3g.apn Done"); + next(); + }; + req2.onerror = onFailure; + }, + function () { + ok(true, "Set Combination"); + var lock = mozSettings.createLock(); + req3 = lock.set(combination); + req3.onsuccess = function () { ok(true, "set done"); + req4 = lock.get("net3g.apn2"); + req4.onsuccess = function() { + ok(true, "Done"); + check(combination["net3g.apn2"], req4.result["net3g.apn2"]); + next(); + } + } + req3.onerror = onFailure; + }, + function() { + var lock = mozSettings.createLock(); + req4 = lock.get("net3g.apn2"); + req4.onsuccess = function() { + ok(true, "Done"); + check(combination["net3g.apn2"], req4.result["net3g.apn2"]); next(); } - req2.onerror = onFailure; + req4.onerror = onFailure; }, function() { ok(true, "Get unknown key"); @@ -293,7 +352,7 @@ var steps = [ req2.onerror = onFailure; }, function () { - ok(true, "Change wifi"); + ok(true, "Change wifi1"); var lock = mozSettings.createLock(); req = lock.set(wifi2); req.onsuccess = function () { @@ -354,34 +413,34 @@ var steps = [ }; { var lock2 = mozSettings.createLock(); - req = lock2.get("*"); - req.onsuccess = function () { - is(Object.keys(req.result).length, 32, "length 12"); - ok(true, JSON.stringify(req.result)); + req2 = lock2.get("*"); + req2.onsuccess = function () { + is(Object.keys(req2.result).length, 32, "length 12"); + ok(true, JSON.stringify(req2.result)); ok(true, "Get all settings Done"); }; - req.onerror = onFailure; + req2.onerror = onFailure; } var lock2 = mozSettings.createLock(); var obj = {}; obj["wifi.enabled" + 30] = true; - req2 = lock2.set( obj ); - req2.onsuccess = function () { + req3 = lock2.set( obj ); + req3.onsuccess = function () { ok(true, "Set12 Done"); }; - req2.onerror = onFailure; + req3.onerror = onFailure; var lock3 = mozSettings.createLock(); // with one lock for (var i = 0; i < 30; i++) { - req3 = lock3.get("wifi.enabled" + i); + req4 = lock3.get("wifi.enabled" + i); var testObj = {}; testObj["wifi.enabled" + i] = true; - req3.onsuccess = function () { + req4.onsuccess = function () { check(this.request.result, this.testObj); ok(true, "Get1 Done"); - }.bind({testObj: testObj, request: req3}); - req3.onerror = onFailure; + }.bind({testObj: testObj, request: req4}); + req4.onerror = onFailure; } ok(true, "start next2!"); @@ -483,7 +542,7 @@ var steps = [ req.onerror = onFailure; }, function () { - ok(true, "Change wifi"); + ok(true, "Change wifi2"); var lock = mozSettings.createLock(); req = lock.set(wifi2); req.onsuccess = function () { From fabf6fc785ae80ed84f9a1cff1a7313a1b1fcdf2 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Fri, 4 Jan 2013 16:19:00 -0800 Subject: [PATCH 105/180] Bug 822754 - Fix B2G AutoMounter to deal with out-of-order events. r=philikon --- dom/system/gonk/Volume.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dom/system/gonk/Volume.cpp b/dom/system/gonk/Volume.cpp index 727211becb43..25800144fa0f 100644 --- a/dom/system/gonk/Volume.cpp +++ b/dom/system/gonk/Volume.cpp @@ -52,12 +52,13 @@ Volume::SetMediaPresent(bool aMediaPresent) // The AutoMounter needs to know whether the media is present or not when // processing the Idle state. - if (mMediaPresent != aMediaPresent) { - LOG("Volume: %s media %s", NameStr(), aMediaPresent ? "inserted" : "removed"); - mMediaPresent = aMediaPresent; - // No need to broadcast the change. A state change will be coming right away, - // and that will serve the purpose. + if (mMediaPresent == aMediaPresent) { + return; } + + LOG("Volume: %s media %s", NameStr(), aMediaPresent ? "inserted" : "removed"); + mMediaPresent = aMediaPresent; + mEventObserverList.Broadcast(this); } void From 1e2c5f46c88d716931d9a50dd5f9de2553feb84f Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Fri, 4 Jan 2013 16:30:31 -0800 Subject: [PATCH 106/180] Back out 13acd3b74386:68ded29fc68e (bug 824327) for browser_bug329212.js failures --- content/svg/content/src/Makefile.in | 18 +- content/svg/content/src/SVGDescElement.cpp | 50 --- content/svg/content/src/SVGDescElement.h | 52 --- .../svg/content/src/SVGMetadataElement.cpp | 59 --- content/svg/content/src/SVGMetadataElement.h | 52 --- .../src/SVGMotionSMILAnimationFunction.cpp | 12 +- .../src/SVGMotionSMILAnimationFunction.h | 7 +- content/svg/content/src/SVGStopElement.cpp | 93 ----- content/svg/content/src/SVGStopElement.h | 65 ---- content/svg/content/src/SVGStyleElement.cpp | 307 --------------- content/svg/content/src/SVGStyleElement.h | 114 ------ content/svg/content/src/SVGTitleElement.cpp | 131 ------- content/svg/content/src/SVGTitleElement.h | 69 ---- content/svg/content/src/nsSVGDescElement.cpp | 76 ++++ content/svg/content/src/nsSVGElement.h | 19 - .../svg/content/src/nsSVGElementFactory.cpp | 4 +- .../svg/content/src/nsSVGMetadataElement.cpp | 75 ++++ ...MPathElement.cpp => nsSVGMpathElement.cpp} | 127 +++--- ...{SVGMPathElement.h => nsSVGMpathElement.h} | 47 +-- content/svg/content/src/nsSVGStopElement.cpp | 118 ++++++ content/svg/content/src/nsSVGStyleElement.cpp | 363 ++++++++++++++++++ content/svg/content/src/nsSVGTitleElement.cpp | 173 +++++++++ dom/bindings/Bindings.conf | 5 - dom/webidl/SVGDescElement.webidl | 15 - dom/webidl/SVGMPathElement.webidl | 17 - dom/webidl/SVGMetadataElement.webidl | 15 - dom/webidl/SVGStopElement.webidl | 18 - dom/webidl/SVGStyleElement.webidl | 23 -- dom/webidl/SVGTitleElement.webidl | 15 - dom/webidl/SVGURIReference.webidl | 19 - dom/webidl/WebIDL.mk | 7 - 31 files changed, 890 insertions(+), 1275 deletions(-) delete mode 100644 content/svg/content/src/SVGDescElement.cpp delete mode 100644 content/svg/content/src/SVGDescElement.h delete mode 100644 content/svg/content/src/SVGMetadataElement.cpp delete mode 100644 content/svg/content/src/SVGMetadataElement.h delete mode 100644 content/svg/content/src/SVGStopElement.cpp delete mode 100644 content/svg/content/src/SVGStopElement.h delete mode 100644 content/svg/content/src/SVGStyleElement.cpp delete mode 100644 content/svg/content/src/SVGStyleElement.h delete mode 100644 content/svg/content/src/SVGTitleElement.cpp delete mode 100644 content/svg/content/src/SVGTitleElement.h create mode 100644 content/svg/content/src/nsSVGDescElement.cpp create mode 100644 content/svg/content/src/nsSVGMetadataElement.cpp rename content/svg/content/src/{SVGMPathElement.cpp => nsSVGMpathElement.cpp} (62%) rename content/svg/content/src/{SVGMPathElement.h => nsSVGMpathElement.h} (70%) create mode 100644 content/svg/content/src/nsSVGStopElement.cpp create mode 100644 content/svg/content/src/nsSVGStyleElement.cpp create mode 100644 content/svg/content/src/nsSVGTitleElement.cpp delete mode 100644 dom/webidl/SVGDescElement.webidl delete mode 100644 dom/webidl/SVGMPathElement.webidl delete mode 100644 dom/webidl/SVGMetadataElement.webidl delete mode 100644 dom/webidl/SVGStopElement.webidl delete mode 100644 dom/webidl/SVGStyleElement.webidl delete mode 100644 dom/webidl/SVGTitleElement.webidl delete mode 100644 dom/webidl/SVGURIReference.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index d34d99282636..d108e94c186c 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -45,6 +45,7 @@ CPPSRCS = \ nsSVGClipPathElement.cpp \ nsSVGDataParser.cpp \ nsSVGDefsElement.cpp \ + nsSVGDescElement.cpp \ nsSVGElement.cpp \ nsSVGElementFactory.cpp \ nsSVGEllipseElement.cpp \ @@ -63,6 +64,7 @@ CPPSRCS = \ nsSVGLineElement.cpp \ nsSVGMarkerElement.cpp \ nsSVGMaskElement.cpp \ + nsSVGMetadataElement.cpp \ nsSVGNumber2.cpp \ nsSVGNumberPair.cpp \ nsSVGPathDataParser.cpp \ @@ -77,6 +79,8 @@ CPPSRCS = \ nsSVGRect.cpp \ nsSVGRectElement.cpp \ nsSVGSVGElement.cpp \ + nsSVGStopElement.cpp \ + nsSVGStyleElement.cpp \ nsSVGSwitchElement.cpp \ nsSVGSymbolElement.cpp \ nsSVGTSpanElement.cpp \ @@ -84,6 +88,7 @@ CPPSRCS = \ nsSVGTextElement.cpp \ nsSVGTextPathElement.cpp \ nsSVGTextPositioningElement.cpp \ + nsSVGTitleElement.cpp \ nsSVGUnknownElement.cpp \ nsSVGUseElement.cpp \ nsSVGViewBox.cpp \ @@ -106,7 +111,6 @@ CPPSRCS = \ SVGPointList.cpp \ SVGPreserveAspectRatio.cpp \ SVGStringList.cpp \ - SVGTitleElement.cpp \ SVGTransform.cpp \ SVGTransformList.cpp \ SVGTransformListParser.cpp \ @@ -114,25 +118,21 @@ CPPSRCS = \ nsSVGAnimateTransformElement.cpp \ nsSVGAnimateMotionElement.cpp \ nsSVGAnimationElement.cpp \ + nsSVGMpathElement.cpp \ nsSVGSetElement.cpp \ SVGAttrValueWrapper.cpp \ SVGContentUtils.cpp \ - SVGDescElement.cpp \ SVGIntegerPairSMILType.cpp \ SVGLengthListSMILType.cpp \ - SVGMetadataElement.cpp \ SVGMotionSMILType.cpp \ SVGMotionSMILAttr.cpp \ SVGMotionSMILAnimationFunction.cpp \ SVGMotionSMILPathUtils.cpp \ - SVGMPathElement.cpp \ SVGNumberListSMILType.cpp \ SVGNumberPairSMILType.cpp \ SVGOrientSMILType.cpp \ SVGPathSegListSMILType.cpp \ SVGPointListSMILType.cpp \ - SVGStopElement.cpp \ - SVGStyleElement.cpp \ SVGTransformListSMILType.cpp \ SVGViewBoxSMILType.cpp \ $(NULL) @@ -154,12 +154,6 @@ EXPORTS_mozilla/dom = \ SVGAngle.h \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ - SVGDescElement.h \ - SVGMetadataElement.h \ - SVGMPathElement.h \ - SVGStopElement.h \ - SVGStyleElement.h \ - SVGTitleElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/src/SVGDescElement.cpp b/content/svg/content/src/SVGDescElement.cpp deleted file mode 100644 index cf1bba764011..000000000000 --- a/content/svg/content/src/SVGDescElement.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/SVGDescElement.h" -#include "mozilla/dom/SVGDescElementBinding.h" - -DOMCI_NODE_DATA(SVGDescElement, mozilla::dom::SVGDescElement) - -NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Desc) - -namespace mozilla { -namespace dom { - -JSObject* -SVGDescElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) -{ - return SVGDescElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); -} - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(SVGDescElement, SVGDescElementBase) -NS_IMPL_RELEASE_INHERITED(SVGDescElement, SVGDescElementBase) - -NS_INTERFACE_TABLE_HEAD(SVGDescElement) - NS_NODE_INTERFACE_TABLE4(SVGDescElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGDescElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement) -NS_INTERFACE_MAP_END_INHERITING(SVGDescElementBase) - -//---------------------------------------------------------------------- -// Implementation - -SVGDescElement::SVGDescElement(already_AddRefed aNodeInfo) - : SVGDescElementBase(aNodeInfo) -{ - SetIsDOMBinding(); -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDescElement) - -} // namespace dom -} // namespace mozilla - diff --git a/content/svg/content/src/SVGDescElement.h b/content/svg/content/src/SVGDescElement.h deleted file mode 100644 index f259b8922934..000000000000 --- a/content/svg/content/src/SVGDescElement.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_SVGDescElement_h -#define mozilla_dom_SVGDescElement_h - -#include "nsSVGElement.h" -#include "nsIDOMSVGDescElement.h" - -nsresult NS_NewSVGDescElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - -typedef nsSVGElement SVGDescElementBase; - -namespace mozilla { -namespace dom { - -class SVGDescElement MOZ_FINAL : public SVGDescElementBase, - public nsIDOMSVGDescElement -{ -protected: - friend nsresult (::NS_NewSVGDescElement(nsIContent **aResult, - already_AddRefed aNodeInfo)); - SVGDescElement(already_AddRefed aNodeInfo); - - virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGDESCELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(SVGDescElementBase::) - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_SVGDescElement_h - diff --git a/content/svg/content/src/SVGMetadataElement.cpp b/content/svg/content/src/SVGMetadataElement.cpp deleted file mode 100644 index 036113b0468c..000000000000 --- a/content/svg/content/src/SVGMetadataElement.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/SVGMetadataElement.h" -#include "mozilla/dom/SVGMetadataElementBinding.h" - -DOMCI_NODE_DATA(SVGMetadataElement, mozilla::dom::SVGMetadataElement) - -NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Metadata) - -namespace mozilla { -namespace dom { - -JSObject* -SVGMetadataElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) -{ - return SVGMetadataElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); -} - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(SVGMetadataElement, SVGMetadataElementBase) -NS_IMPL_RELEASE_INHERITED(SVGMetadataElement, SVGMetadataElementBase) - -NS_INTERFACE_TABLE_HEAD(SVGMetadataElement) - NS_NODE_INTERFACE_TABLE4(SVGMetadataElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGMetadataElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement) -NS_INTERFACE_MAP_END_INHERITING(SVGMetadataElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -SVGMetadataElement::SVGMetadataElement(already_AddRefed aNodeInfo) - : SVGMetadataElementBase(aNodeInfo) -{ - SetIsDOMBinding(); -} - - -nsresult -SVGMetadataElement::Init() -{ - return NS_OK; -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMetadataElement) - -} // namespace dom -} // namespace mozilla - diff --git a/content/svg/content/src/SVGMetadataElement.h b/content/svg/content/src/SVGMetadataElement.h deleted file mode 100644 index 7a6d1baf5451..000000000000 --- a/content/svg/content/src/SVGMetadataElement.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_SVGMetadataElement_h -#define mozilla_dom_SVGMetadataElement_h - -#include "nsSVGElement.h" -#include "nsIDOMSVGMetadataElement.h" - -nsresult NS_NewSVGMetadataElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - -typedef nsSVGElement SVGMetadataElementBase; - -namespace mozilla { -namespace dom { - -class SVGMetadataElement MOZ_FINAL : public SVGMetadataElementBase, - public nsIDOMSVGMetadataElement -{ -protected: - friend nsresult (::NS_NewSVGMetadataElement(nsIContent **aResult, - already_AddRefed aNodeInfo)); - SVGMetadataElement(already_AddRefed aNodeInfo); - - virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGMETADATAELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_SVGMetadataElement_h diff --git a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp index b7bdbd4c0996..560e06a33c79 100644 --- a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp +++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp @@ -11,13 +11,11 @@ #include "SVGMotionSMILPathUtils.h" #include "nsSVGPathDataParser.h" #include "nsSVGPathElement.h" // for nsSVGPathList -#include "SVGMPathElement.h" +#include "nsSVGMpathElement.h" #include "nsAttrValueInlines.h" namespace mozilla { -using namespace dom; - SVGMotionSMILAnimationFunction::SVGMotionSMILAnimationFunction() : mRotateType(eRotateType_Explicit), mRotateAngle(0.0f), @@ -126,14 +124,14 @@ SVGMotionSMILAnimationFunction::GetCalcMode() const * Returns the first child of the given element */ -static SVGMPathElement* +static nsSVGMpathElement* GetFirstMpathChild(nsIContent* aElem) { for (nsIContent* child = aElem->GetFirstChild(); child; child = child->GetNextSibling()) { if (child->IsSVG(nsGkAtoms::mpath)) { - return static_cast(child); + return static_cast(child); } } @@ -212,7 +210,7 @@ SVGMotionSMILAnimationFunction:: void SVGMotionSMILAnimationFunction:: - RebuildPathAndVerticesFromMpathElem(SVGMPathElement* aMpathElem) + RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem) { mPathSourceType = ePathSourceType_Mpath; @@ -272,7 +270,7 @@ SVGMotionSMILAnimationFunction:: // Do we have a mpath child? if so, it trumps everything. Otherwise, we look // through our list of path-defining attributes, in order of priority. - SVGMPathElement* firstMpathChild = + nsSVGMpathElement* firstMpathChild = GetFirstMpathChild(&mAnimationElement->AsElement()); if (firstMpathChild) { diff --git a/content/svg/content/src/SVGMotionSMILAnimationFunction.h b/content/svg/content/src/SVGMotionSMILAnimationFunction.h index 82f24c5b0ffd..ebfdbef0d0dd 100644 --- a/content/svg/content/src/SVGMotionSMILAnimationFunction.h +++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.h @@ -17,13 +17,10 @@ class nsIAtom; class nsIContent; class nsISMILAttr; class nsSMILValue; +class nsSVGMpathElement; namespace mozilla { -namespace dom { -class SVGMPathElement; -} - //---------------------------------------------------------------------- // SVGMotionSMILAnimationFunction // @@ -75,7 +72,7 @@ protected: // Helpers for GetValues void MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute); void RebuildPathAndVertices(const nsIContent* aContextElem); - void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem); + void RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem); void RebuildPathAndVerticesFromPathAttr(); void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem); bool GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath, diff --git a/content/svg/content/src/SVGStopElement.cpp b/content/svg/content/src/SVGStopElement.cpp deleted file mode 100644 index 0f0327d45f1d..000000000000 --- a/content/svg/content/src/SVGStopElement.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/SVGStopElement.h" -#include "mozilla/dom/SVGStopElementBinding.h" - -DOMCI_NODE_DATA(SVGStopElement, mozilla::dom::SVGStopElement) - -NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Stop) - -namespace mozilla { -namespace dom { - -JSObject* -SVGStopElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) -{ - return SVGStopElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); -} - -nsSVGElement::NumberInfo SVGStopElement::sNumberInfo = -{ &nsGkAtoms::offset, 0, true }; - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(SVGStopElement, SVGStopElementBase) -NS_IMPL_RELEASE_INHERITED(SVGStopElement, SVGStopElementBase) - -NS_INTERFACE_TABLE_HEAD(SVGStopElement) - NS_NODE_INTERFACE_TABLE4(SVGStopElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGStopElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement) -NS_INTERFACE_MAP_END_INHERITING(SVGStopElementBase) - -//---------------------------------------------------------------------- -// Implementation - -SVGStopElement::SVGStopElement(already_AddRefed aNodeInfo) - : SVGStopElementBase(aNodeInfo) -{ - SetIsDOMBinding(); -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement) - -//---------------------------------------------------------------------- -// nsIDOMSVGStopElement methods - -/* readonly attribute nsIDOMSVGAnimatedNumber offset; */ -NS_IMETHODIMP SVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset) -{ - return mOffset.ToDOMAnimatedNumber(aOffset,this); -} - -already_AddRefed -SVGStopElement::Offset() -{ - nsCOMPtr offset; - mOffset.ToDOMAnimatedNumber(getter_AddRefs(offset), this); - return offset.forget(); -} - -//---------------------------------------------------------------------- -// sSVGElement methods - -nsSVGElement::NumberAttributesInfo -SVGStopElement::GetNumberInfo() -{ - return NumberAttributesInfo(&mOffset, &sNumberInfo, 1); -} - -//---------------------------------------------------------------------- -// nsIContent methods - -NS_IMETHODIMP_(bool) -SVGStopElement::IsAttributeMapped(const nsIAtom* name) const -{ - static const MappedAttributeEntry* const map[] = { - sGradientStopMap - }; - - return FindAttributeDependence(name, map) || - SVGStopElementBase::IsAttributeMapped(name); -} - -} // namespace dom -} // namespace mozilla - diff --git a/content/svg/content/src/SVGStopElement.h b/content/svg/content/src/SVGStopElement.h deleted file mode 100644 index 02968e54338c..000000000000 --- a/content/svg/content/src/SVGStopElement.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_SVGStopElement_h -#define mozilla_dom_SVGStopElement_h - -#include "nsSVGElement.h" -#include "nsSVGNumber2.h" -#include "nsIDOMSVGStopElement.h" - -nsresult NS_NewSVGStopElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - -typedef nsSVGElement SVGStopElementBase; - -namespace mozilla { -namespace dom { - -class SVGStopElement MOZ_FINAL : public SVGStopElementBase, - public nsIDOMSVGStopElement -{ -protected: - friend nsresult (::NS_NewSVGStopElement(nsIContent **aResult, - already_AddRefed aNodeInfo)); - SVGStopElement(already_AddRefed aNodeInfo); - virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSTOPELEMENT - - // xxx If xpcom allowed virtual inheritance we wouldn't need to - // forward here :-( - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(SVGStopElementBase::) - - // nsIContent interface - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } - - // WebIDL - already_AddRefed Offset(); - -protected: - - virtual NumberAttributesInfo GetNumberInfo(); - // nsIDOMSVGStopElement properties: - nsSVGNumber2 mOffset; - static NumberInfo sNumberInfo; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_SVGStopElement_h diff --git a/content/svg/content/src/SVGStyleElement.cpp b/content/svg/content/src/SVGStyleElement.cpp deleted file mode 100644 index bef78f677b1b..000000000000 --- a/content/svg/content/src/SVGStyleElement.cpp +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/SVGStyleElement.h" -#include "nsContentUtils.h" -#include "nsStubMutationObserver.h" -#include "mozilla/dom/SVGStyleElementBinding.h" - -DOMCI_NODE_DATA(SVGStyleElement, mozilla::dom::SVGStyleElement) - -NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Style) - -namespace mozilla { -namespace dom { - -JSObject* -SVGStyleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) -{ - return SVGStyleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); -} - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(SVGStyleElement, SVGStyleElementBase) -NS_IMPL_RELEASE_INHERITED(SVGStyleElement, SVGStyleElementBase) - -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGStyleElement) - NS_NODE_INTERFACE_TABLE7(SVGStyleElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGStyleElement, - nsIDOMLinkStyle, nsIStyleSheetLinkingElement, - nsIMutationObserver) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement) -NS_INTERFACE_MAP_END_INHERITING(SVGStyleElementBase) - -NS_IMPL_CYCLE_COLLECTION_CLASS(SVGStyleElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGStyleElement, - SVGStyleElementBase) - tmp->nsStyleLinkElement::Traverse(cb); -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement, - SVGStyleElementBase) - tmp->nsStyleLinkElement::Unlink(); -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -//---------------------------------------------------------------------- -// Implementation - -SVGStyleElement::SVGStyleElement(already_AddRefed aNodeInfo) - : SVGStyleElementBase(aNodeInfo) -{ - SetIsDOMBinding(); - AddMutationObserver(this); -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement) - - -//---------------------------------------------------------------------- -// nsIContent methods - -nsresult -SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) -{ - nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); - NS_ENSURE_SUCCESS(rv, rv); - - void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); - - return rv; -} - -void -SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) -{ - nsCOMPtr oldDoc = GetCurrentDoc(); - - SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent); - UpdateStyleSheetInternal(oldDoc); -} - -nsresult -SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify) -{ - nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, - aValue, aNotify); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheetInternal(nullptr, - aNameSpaceID == kNameSpaceID_None && - (aName == nsGkAtoms::title || - aName == nsGkAtoms::media || - aName == nsGkAtoms::type)); - } - - return rv; -} - -nsresult -SVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) -{ - nsresult rv = SVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, - aNotify); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheetInternal(nullptr, - aNameSpaceID == kNameSpaceID_None && - (aAttribute == nsGkAtoms::title || - aAttribute == nsGkAtoms::media || - aAttribute == nsGkAtoms::type)); - } - - return rv; -} - -bool -SVGStyleElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aNamespaceID == kNameSpaceID_None && - aAttribute == nsGkAtoms::crossorigin) { - ParseCORSValue(aValue, aResult); - return true; - } - - return SVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, - aResult); -} - -//---------------------------------------------------------------------- -// nsIMutationObserver methods - -void -SVGStyleElement::CharacterDataChanged(nsIDocument* aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo) -{ - ContentChanged(aContent); -} - -void -SVGStyleElement::ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aFirstNewContent, - int32_t aNewIndexInContainer) -{ - ContentChanged(aContainer); -} - -void -SVGStyleElement::ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer) -{ - ContentChanged(aChild); -} - -void -SVGStyleElement::ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer, - nsIContent* aPreviousSibling) -{ - ContentChanged(aChild); -} - -void -SVGStyleElement::ContentChanged(nsIContent* aContent) -{ - if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { - UpdateStyleSheetInternal(nullptr); - } -} - -//---------------------------------------------------------------------- -// nsIDOMSVGStyleElement methods - -/* attribute DOMString xmlspace; */ -NS_IMETHODIMP SVGStyleElement::GetXmlspace(nsAString & aXmlspace) -{ - GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace); - - return NS_OK; -} -NS_IMETHODIMP SVGStyleElement::SetXmlspace(const nsAString & aXmlspace) -{ - return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); -} -void -SVGStyleElement::SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv) -{ - rv = SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); -} - -/* attribute DOMString type; */ -NS_IMETHODIMP SVGStyleElement::GetType(nsAString & aType) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); - - return NS_OK; -} -NS_IMETHODIMP SVGStyleElement::SetType(const nsAString & aType) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); -} -void -SVGStyleElement::SetType(const nsAString & aType, ErrorResult& rv) -{ - rv = SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); -} - -/* attribute DOMString media; */ -NS_IMETHODIMP SVGStyleElement::GetMedia(nsAString & aMedia) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - - return NS_OK; -} -NS_IMETHODIMP SVGStyleElement::SetMedia(const nsAString & aMedia) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); -} -void -SVGStyleElement::SetMedia(const nsAString & aMedia, ErrorResult& rv) -{ - rv = SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); -} - -/* attribute DOMString title; */ -NS_IMETHODIMP SVGStyleElement::GetTitle(nsAString & aTitle) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle); - - return NS_OK; -} -NS_IMETHODIMP SVGStyleElement::SetTitle(const nsAString & aTitle) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); -} -void -SVGStyleElement::SetTitle(const nsAString & aTitle, ErrorResult& rv) -{ - rv = SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); -} - -//---------------------------------------------------------------------- -// nsStyleLinkElement methods - -already_AddRefed -SVGStyleElement::GetStyleSheetURL(bool* aIsInline) -{ - *aIsInline = true; - return nullptr; -} - -void -SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, - nsAString& aType, - nsAString& aMedia, - bool* aIsAlternate) -{ - *aIsAlternate = false; - - nsAutoString title; - GetAttr(kNameSpaceID_None, nsGkAtoms::title, title); - title.CompressWhitespace(); - aTitle.Assign(title); - - GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - // The SVG spec is formulated in terms of the CSS2 spec, - // which specifies that media queries are case insensitive. - nsContentUtils::ASCIIToLower(aMedia); - - GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); - if (aType.IsEmpty()) { - aType.AssignLiteral("text/css"); - } - - return; -} - -CORSMode -SVGStyleElement::GetCORSMode() const -{ - return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); -} - -} // namespace dom -} // namespace mozilla - diff --git a/content/svg/content/src/SVGStyleElement.h b/content/svg/content/src/SVGStyleElement.h deleted file mode 100644 index c2a3d3f4b67a..000000000000 --- a/content/svg/content/src/SVGStyleElement.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_SVGStyleElement_h -#define mozilla_dom_SVGStyleElement_h - -#include "nsSVGElement.h" -#include "nsIDOMSVGStyleElement.h" -#include "nsStyleLinkElement.h" -#include "nsStubMutationObserver.h" - -nsresult NS_NewSVGStyleElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - -typedef nsSVGElement SVGStyleElementBase; - -namespace mozilla { -namespace dom { - -class SVGStyleElement MOZ_FINAL : public SVGStyleElementBase, - public nsIDOMSVGStyleElement, - public nsStyleLinkElement, - public nsStubMutationObserver -{ -protected: - friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult, - already_AddRefed aNodeInfo)); - SVGStyleElement(already_AddRefed aNodeInfo); - - virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; - -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSTYLEELEMENT - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement, - SVGStyleElementBase) - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(SVGStyleElementBase::) - - // nsIContent - virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers); - virtual void UnbindFromTree(bool aDeep = true, - bool aNullParent = true); - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } - virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify); - virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify); - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } - - // WebIDL - void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv); - void SetType(const nsAString & aType, ErrorResult& rv); - void SetMedia(const nsAString & aMedia, ErrorResult& rv); - void SetTitle(const nsAString & aTitle, ErrorResult& rv); - -protected: - // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and - // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be - // completely optimized away. - inline nsresult Init() - { - return NS_OK; - } - - // nsStyleLinkElement overrides - already_AddRefed GetStyleSheetURL(bool* aIsInline); - - void GetStyleSheetInfo(nsAString& aTitle, - nsAString& aType, - nsAString& aMedia, - bool* aIsAlternate); - virtual CORSMode GetCORSMode() const; - - /** - * Common method to call from the various mutation observer methods. - * aContent is a content node that's either the one that changed or its - * parent; we should only respond to the change if aContent is non-anonymous. - */ - void ContentChanged(nsIContent* aContent); -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_SVGStyleElement_h diff --git a/content/svg/content/src/SVGTitleElement.cpp b/content/svg/content/src/SVGTitleElement.cpp deleted file mode 100644 index 8d80be1ab114..000000000000 --- a/content/svg/content/src/SVGTitleElement.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/SVGTitleElement.h" -#include "mozilla/dom/SVGTitleElementBinding.h" - -DOMCI_NODE_DATA(SVGTitleElement, mozilla::dom::SVGTitleElement) - -NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Title) - -namespace mozilla { -namespace dom { - -JSObject* -SVGTitleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) -{ - return SVGTitleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); -} - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(SVGTitleElement, SVGTitleElementBase) -NS_IMPL_RELEASE_INHERITED(SVGTitleElement, SVGTitleElementBase) - -NS_INTERFACE_TABLE_HEAD(SVGTitleElement) - NS_NODE_INTERFACE_TABLE4(SVGTitleElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, - nsIMutationObserver) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement) -NS_INTERFACE_MAP_END_INHERITING(SVGTitleElementBase) - -//---------------------------------------------------------------------- -// Implementation - -SVGTitleElement::SVGTitleElement(already_AddRefed aNodeInfo) - : SVGTitleElementBase(aNodeInfo) -{ - SetIsDOMBinding(); - AddMutationObserver(this); -} - -void -SVGTitleElement::CharacterDataChanged(nsIDocument *aDocument, - nsIContent *aContent, - CharacterDataChangeInfo *aInfo) -{ - SendTitleChangeEvent(false); -} - -void -SVGTitleElement::ContentAppended(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aFirstNewContent, - int32_t aNewIndexInContainer) -{ - SendTitleChangeEvent(false); -} - -void -SVGTitleElement::ContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - int32_t aIndexInContainer) -{ - SendTitleChangeEvent(false); -} - -void -SVGTitleElement::ContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - int32_t aIndexInContainer, - nsIContent *aPreviousSibling) -{ - SendTitleChangeEvent(false); -} - -nsresult -SVGTitleElement::BindToTree(nsIDocument *aDocument, - nsIContent *aParent, - nsIContent *aBindingParent, - bool aCompileEventHandlers) -{ - // Let this fall through. - nsresult rv = SVGTitleElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); - NS_ENSURE_SUCCESS(rv, rv); - - SendTitleChangeEvent(true); - - return NS_OK; -} - -void -SVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent) -{ - SendTitleChangeEvent(false); - - // Let this fall through. - SVGTitleElementBase::UnbindFromTree(aDeep, aNullParent); -} - -void -SVGTitleElement::DoneAddingChildren(bool aHaveNotified) -{ - if (!aHaveNotified) { - SendTitleChangeEvent(false); - } -} - -void -SVGTitleElement::SendTitleChangeEvent(bool aBound) -{ - nsIDocument* doc = GetCurrentDoc(); - if (doc) { - doc->NotifyPossibleTitleChange(aBound); - } -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement) - -} // namespace dom -} // namespace mozilla - diff --git a/content/svg/content/src/SVGTitleElement.h b/content/svg/content/src/SVGTitleElement.h deleted file mode 100644 index dc51df00c139..000000000000 --- a/content/svg/content/src/SVGTitleElement.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_SVGTitleElement_h -#define mozilla_dom_SVGTitleElement_h - -#include "nsSVGElement.h" -#include "nsIDOMSVGTitleElement.h" -#include "nsStubMutationObserver.h" - -typedef nsSVGElement SVGTitleElementBase; - -nsresult NS_NewSVGTitleElement(nsIContent **aResult, - already_AddRefed aNodeInfo); -namespace mozilla { -namespace dom { - -class SVGTitleElement MOZ_FINAL : public SVGTitleElementBase, - public nsStubMutationObserver, - public nsIDOMSVGTitleElement -{ -protected: - friend nsresult (::NS_NewSVGTitleElement(nsIContent **aResult, - already_AddRefed aNodeInfo)); - SVGTitleElement(already_AddRefed aNodeInfo); - - virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(SVGTitleElementBase::) - - // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, - nsIContent *aBindingParent, - bool aCompileEventHandlers); - - virtual void UnbindFromTree(bool aDeep = true, - bool aNullParent = true); - - virtual void DoneAddingChildren(bool aHaveNotified); - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -private: - void SendTitleChangeEvent(bool aBound); -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_SVGTitleElement_h - diff --git a/content/svg/content/src/nsSVGDescElement.cpp b/content/svg/content/src/nsSVGDescElement.cpp new file mode 100644 index 000000000000..81c158ec49cf --- /dev/null +++ b/content/svg/content/src/nsSVGDescElement.cpp @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsSVGElement.h" +#include "nsIDOMSVGDescElement.h" + +typedef nsSVGElement nsSVGDescElementBase; + +class nsSVGDescElement : public nsSVGDescElementBase, + public nsIDOMSVGDescElement +{ +protected: + friend nsresult NS_NewSVGDescElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + nsSVGDescElement(already_AddRefed aNodeInfo); + nsresult Init(); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGDESCELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDescElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(Desc) + + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGDescElement, nsSVGDescElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGDescElement, nsSVGDescElementBase) + +DOMCI_NODE_DATA(SVGDescElement, nsSVGDescElement) + +NS_INTERFACE_TABLE_HEAD(nsSVGDescElement) + NS_NODE_INTERFACE_TABLE4(nsSVGDescElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGDescElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGDescElementBase) + + +//---------------------------------------------------------------------- +// Implementation + +nsSVGDescElement::nsSVGDescElement(already_AddRefed aNodeInfo) + : nsSVGDescElementBase(aNodeInfo) +{ +} + + +nsresult +nsSVGDescElement::Init() +{ + return nsSVGDescElementBase::Init(); +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDescElement) + diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index 6f802305753d..19b210ed230b 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -640,25 +640,6 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ return rv; \ } -#define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(_elementName) \ -nsresult \ -NS_NewSVG##_elementName##Element(nsIContent **aResult, \ - already_AddRefed aNodeInfo) \ -{ \ - nsRefPtr it = \ - new mozilla::dom::SVG##_elementName##Element(aNodeInfo); \ - \ - nsresult rv = it->Init(); \ - \ - if (NS_FAILED(rv)) { \ - return rv; \ - } \ - \ - it.forget(aResult); \ - \ - return rv; \ -} - #define NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(_elementName) \ nsresult \ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ diff --git a/content/svg/content/src/nsSVGElementFactory.cpp b/content/svg/content/src/nsSVGElementFactory.cpp index 98d1072808b7..473729d15472 100644 --- a/content/svg/content/src/nsSVGElementFactory.cpp +++ b/content/svg/content/src/nsSVGElementFactory.cpp @@ -201,7 +201,7 @@ nsresult NS_NewSVGAnimateMotionElement(nsIContent **aResult, already_AddRefed aNodeInfo); nsresult -NS_NewSVGMPathElement(nsIContent **aResult, +NS_NewSVGMpathElement(nsIContent **aResult, already_AddRefed aNodeInfo); nsresult NS_NewSVGSetElement(nsIContent **aResult, @@ -348,7 +348,7 @@ NS_NewSVGElement(nsIContent** aResult, already_AddRefed aNodeInfo, if (name == nsGkAtoms::animateMotion) return NS_NewSVGAnimateMotionElement(aResult, aNodeInfo); if (name == nsGkAtoms::mpath) - return NS_NewSVGMPathElement(aResult, aNodeInfo); + return NS_NewSVGMpathElement(aResult, aNodeInfo); if (name == nsGkAtoms::set) return NS_NewSVGSetElement(aResult, aNodeInfo); } diff --git a/content/svg/content/src/nsSVGMetadataElement.cpp b/content/svg/content/src/nsSVGMetadataElement.cpp new file mode 100644 index 000000000000..af52ffae835c --- /dev/null +++ b/content/svg/content/src/nsSVGMetadataElement.cpp @@ -0,0 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsSVGElement.h" +#include "nsIDOMSVGMetadataElement.h" + +typedef nsSVGElement nsSVGMetadataElementBase; + +class nsSVGMetadataElement : public nsSVGMetadataElementBase, + public nsIDOMSVGMetadataElement +{ +protected: + friend nsresult NS_NewSVGMetadataElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + nsSVGMetadataElement(already_AddRefed aNodeInfo); + nsresult Init(); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGMETADATAELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(Metadata) + + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase) + +DOMCI_NODE_DATA(SVGMetadataElement, nsSVGMetadataElement) + +NS_INTERFACE_TABLE_HEAD(nsSVGMetadataElement) + NS_NODE_INTERFACE_TABLE4(nsSVGMetadataElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGMetadataElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGMetadataElementBase) + + +//---------------------------------------------------------------------- +// Implementation + +nsSVGMetadataElement::nsSVGMetadataElement(already_AddRefed aNodeInfo) + : nsSVGMetadataElementBase(aNodeInfo) +{ +} + + +nsresult +nsSVGMetadataElement::Init() +{ + return NS_OK; +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMetadataElement) diff --git a/content/svg/content/src/SVGMPathElement.cpp b/content/svg/content/src/nsSVGMpathElement.cpp similarity index 62% rename from content/svg/content/src/SVGMPathElement.cpp rename to content/svg/content/src/nsSVGMpathElement.cpp index 927cdcbff1c4..ea5bb5f8e584 100644 --- a/content/svg/content/src/SVGMPathElement.cpp +++ b/content/svg/content/src/nsSVGMpathElement.cpp @@ -5,56 +5,49 @@ #include "mozilla/Util.h" -#include "mozilla/dom/SVGMPathElement.h" +#include "nsSVGMpathElement.h" #include "nsAutoPtr.h" #include "nsDebug.h" #include "nsSVGPathElement.h" #include "nsSVGAnimateMotionElement.h" #include "nsContentUtils.h" -#include "mozilla/dom/SVGMPathElementBinding.h" -DOMCI_NODE_DATA(SVGMpathElement, mozilla::dom::SVGMPathElement) +using namespace mozilla; +using namespace mozilla::dom; -NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(MPath) - -namespace mozilla { -namespace dom { - -JSObject* -SVGMPathElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) -{ - return SVGMPathElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); -} - -nsSVGElement::StringInfo SVGMPathElement::sStringInfo[1] = +nsSVGElement::StringInfo nsSVGMpathElement::sStringInfo[1] = { { &nsGkAtoms::href, kNameSpaceID_XLink, false } }; +NS_IMPL_NS_NEW_SVG_ELEMENT(Mpath) + // Cycle collection magic -- based on nsSVGUseElement -NS_IMPL_CYCLE_COLLECTION_CLASS(SVGMPathElement) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGMPathElement, - SVGMPathElementBase) +NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGMpathElement) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGMpathElement, + nsSVGMpathElementBase) tmp->UnlinkHrefTarget(false); NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGMPathElement, - SVGMPathElementBase) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGMpathElement, + nsSVGMpathElementBase) tmp->mHrefTarget.Traverse(&cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END //---------------------------------------------------------------------- // nsISupports methods -NS_IMPL_ADDREF_INHERITED(SVGMPathElement,SVGMPathElementBase) -NS_IMPL_RELEASE_INHERITED(SVGMPathElement,SVGMPathElementBase) +NS_IMPL_ADDREF_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase) -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGMPathElement) - NS_NODE_INTERFACE_TABLE6(SVGMPathElement, nsIDOMNode, nsIDOMElement, +DOMCI_NODE_DATA(SVGMpathElement, nsSVGMpathElement) + +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGMpathElement) + NS_NODE_INTERFACE_TABLE6(nsSVGMpathElement, nsIDOMNode, nsIDOMElement, nsIDOMSVGElement, nsIDOMSVGURIReference, nsIDOMSVGMpathElement, nsIMutationObserver) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMpathElement) -NS_INTERFACE_MAP_END_INHERITING(SVGMPathElementBase) +NS_INTERFACE_MAP_END_INHERITING(nsSVGMpathElementBase) // Constructor #ifdef _MSC_VER @@ -64,17 +57,16 @@ NS_INTERFACE_MAP_END_INHERITING(SVGMPathElementBase) #pragma warning(push) #pragma warning(disable:4355) #endif -SVGMPathElement::SVGMPathElement(already_AddRefed aNodeInfo) - : SVGMPathElementBase(aNodeInfo), +nsSVGMpathElement::nsSVGMpathElement(already_AddRefed aNodeInfo) + : nsSVGMpathElementBase(aNodeInfo), mHrefTarget(this) #ifdef _MSC_VER #pragma warning(pop) #endif { - SetIsDOMBinding(); } -SVGMPathElement::~SVGMPathElement() +nsSVGMpathElement::~nsSVGMpathElement() { UnlinkHrefTarget(false); } @@ -82,42 +74,33 @@ SVGMPathElement::~SVGMPathElement() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMPathElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMpathElement) //---------------------------------------------------------------------- // nsIDOMSVGURIReference methods /* readonly attribute nsIDOMSVGAnimatedString href; */ -already_AddRefed -SVGMPathElement::Href() -{ - nsCOMPtr href; - mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this); - return href.forget(); -} - NS_IMETHODIMP -SVGMPathElement::GetHref(nsIDOMSVGAnimatedString** aHref) +nsSVGMpathElement::GetHref(nsIDOMSVGAnimatedString** aHref) { - *aHref = Href().get(); - return NS_OK; + return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this); } //---------------------------------------------------------------------- // nsIContent methods nsresult -SVGMPathElement::BindToTree(nsIDocument* aDocument, - nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) +nsSVGMpathElement::BindToTree(nsIDocument* aDocument, + nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) { NS_ABORT_IF_FALSE(!mHrefTarget.get(), "Shouldn't have href-target yet " "(or it should've been cleared)"); - nsresult rv = SVGMPathElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); + nsresult rv = nsSVGMpathElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); NS_ENSURE_SUCCESS(rv,rv); if (aDocument) { @@ -132,20 +115,20 @@ SVGMPathElement::BindToTree(nsIDocument* aDocument, } void -SVGMPathElement::UnbindFromTree(bool aDeep, bool aNullParent) +nsSVGMpathElement::UnbindFromTree(bool aDeep, bool aNullParent) { UnlinkHrefTarget(true); - SVGMPathElementBase::UnbindFromTree(aDeep, aNullParent); + nsSVGMpathElementBase::UnbindFromTree(aDeep, aNullParent); } bool -SVGMPathElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +nsSVGMpathElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { bool returnVal = - SVGMPathElementBase::ParseAttribute(aNamespaceID, aAttribute, + nsSVGMpathElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, aResult); if (aNamespaceID == kNameSpaceID_XLink && aAttribute == nsGkAtoms::href && @@ -158,11 +141,11 @@ SVGMPathElement::ParseAttribute(int32_t aNamespaceID, } nsresult -SVGMPathElement::UnsetAttr(int32_t aNamespaceID, - nsIAtom* aAttribute, bool aNotify) +nsSVGMpathElement::UnsetAttr(int32_t aNamespaceID, + nsIAtom* aAttribute, bool aNotify) { - nsresult rv = SVGMPathElementBase::UnsetAttr(aNamespaceID, aAttribute, - aNotify); + nsresult rv = nsSVGMpathElementBase::UnsetAttr(aNamespaceID, aAttribute, + aNotify); NS_ENSURE_SUCCESS(rv, rv); if (aNamespaceID == kNameSpaceID_XLink && @@ -177,7 +160,7 @@ SVGMPathElement::UnsetAttr(int32_t aNamespaceID, // nsSVGElement methods nsSVGElement::StringAttributesInfo -SVGMPathElement::GetStringInfo() +nsSVGMpathElement::GetStringInfo() { return StringAttributesInfo(mStringAttributes, sStringInfo, ArrayLength(sStringInfo)); @@ -187,11 +170,11 @@ SVGMPathElement::GetStringInfo() // nsIMutationObserver methods void -SVGMPathElement::AttributeChanged(nsIDocument* aDocument, - Element* aElement, - int32_t aNameSpaceID, - nsIAtom* aAttribute, - int32_t aModType) +nsSVGMpathElement::AttributeChanged(nsIDocument* aDocument, + Element* aElement, + int32_t aNameSpaceID, + nsIAtom* aAttribute, + int32_t aModType) { if (aNameSpaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::d) { @@ -204,7 +187,7 @@ SVGMPathElement::AttributeChanged(nsIDocument* aDocument, // Public helper methods nsSVGPathElement* -SVGMPathElement::GetReferencedPath() +nsSVGMpathElement::GetReferencedPath() { if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) { NS_ABORT_IF_FALSE(!mHrefTarget.get(), @@ -224,8 +207,8 @@ SVGMPathElement::GetReferencedPath() // Protected helper methods void -SVGMPathElement::UpdateHrefTarget(nsIContent* aParent, - const nsAString& aHrefStr) +nsSVGMpathElement::UpdateHrefTarget(nsIContent* aParent, + const nsAString& aHrefStr) { nsCOMPtr targetURI; nsCOMPtr baseURI = GetBaseURI(); @@ -257,7 +240,7 @@ SVGMPathElement::UpdateHrefTarget(nsIContent* aParent, } void -SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent) +nsSVGMpathElement::UnlinkHrefTarget(bool aNotifyParent) { // Stop observing old target (if any) if (mHrefTarget.get()) { @@ -271,7 +254,7 @@ SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent) } void -SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent) +nsSVGMpathElement::NotifyParentOfMpathChange(nsIContent* aParent) { if (aParent && aParent->IsSVG(nsGkAtoms::animateMotion)) { @@ -282,7 +265,3 @@ SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent) AnimationNeedsResample(); } } - -} // namespace dom -} // namespace mozilla - diff --git a/content/svg/content/src/SVGMPathElement.h b/content/svg/content/src/nsSVGMpathElement.h similarity index 70% rename from content/svg/content/src/SVGMPathElement.h rename to content/svg/content/src/nsSVGMpathElement.h index b6b00c736ed9..736ebea2d705 100644 --- a/content/svg/content/src/SVGMPathElement.h +++ b/content/svg/content/src/nsSVGMpathElement.h @@ -3,8 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozilla_dom_SVGMPathElement_h -#define mozilla_dom_SVGMPathElement_h +#ifndef NS_SVGMPATHELEMENT_H_ +#define NS_SVGMPATHELEMENT_H_ #include "nsIDOMSVGMpathElement.h" #include "nsIDOMSVGURIReference.h" @@ -14,26 +14,20 @@ #include "nsSVGString.h" #include "nsReferencedElement.h" -nsresult NS_NewSVGMPathElement(nsIContent **aResult, - already_AddRefed aNodeInfo); -typedef nsSVGElement SVGMPathElementBase; +typedef nsSVGElement nsSVGMpathElementBase; -namespace mozilla { -namespace dom { - -class SVGMPathElement MOZ_FINAL : public SVGMPathElementBase, - public nsIDOMSVGMpathElement, - public nsIDOMSVGURIReference, - public nsStubMutationObserver +class nsSVGMpathElement : public nsSVGMpathElementBase, + public nsIDOMSVGMpathElement, + public nsIDOMSVGURIReference, + public nsStubMutationObserver { protected: - friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult, - already_AddRefed aNodeInfo)); - SVGMPathElement(already_AddRefed aNodeInfo); - ~SVGMPathElement(); + friend nsresult NS_NewSVGMpathElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + nsSVGMpathElement(already_AddRefed aNodeInfo); + ~nsSVGMpathElement(); - virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; public: // interfaces: @@ -41,15 +35,15 @@ public: NS_DECL_NSIDOMSVGMPATHELEMENT NS_DECL_NSIDOMSVGURIREFERENCE - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGMPathElement, - SVGMPathElementBase) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGMpathElement, + nsSVGMpathElementBase) NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED // Forward interface implementations to base class NS_FORWARD_NSIDOMNODE_TO_NSINODE NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(SVGMPathElementBase::) + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGMpathElementBase::) // nsIContent interface virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; @@ -74,14 +68,10 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } - - // WebIDL - already_AddRefed Href(); - protected: class PathReference : public nsReferencedElement { public: - PathReference(SVGMPathElement* aMpathElement) : + PathReference(nsSVGMpathElement* aMpathElement) : mMpathElement(aMpathElement) {} protected: // We need to be notified when target changes, in order to request a sample @@ -102,7 +92,7 @@ protected: // first time the target changes) virtual bool IsPersistent() { return true; } private: - SVGMPathElement* const mMpathElement; + nsSVGMpathElement* const mMpathElement; }; virtual StringAttributesInfo GetStringInfo(); @@ -117,7 +107,4 @@ protected: PathReference mHrefTarget; }; -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_SVGMPathElement_h +#endif // NS_SVGMPATHELEMENT_H_ diff --git a/content/svg/content/src/nsSVGStopElement.cpp b/content/svg/content/src/nsSVGStopElement.cpp new file mode 100644 index 000000000000..3c133cb81556 --- /dev/null +++ b/content/svg/content/src/nsSVGStopElement.cpp @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Util.h" + +#include "nsSVGElement.h" +#include "nsIDOMSVGStopElement.h" +#include "nsSVGNumber2.h" +#include "nsGenericHTMLElement.h" + +using namespace mozilla; + +typedef nsSVGElement nsSVGStopElementBase; + +class nsSVGStopElement : public nsSVGStopElementBase, + public nsIDOMSVGStopElement +{ +protected: + friend nsresult NS_NewSVGStopElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + nsSVGStopElement(already_AddRefed aNodeInfo); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSTOPELEMENT + + // xxx If xpcom allowed virtual inheritance we wouldn't need to + // forward here :-( + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStopElementBase::) + + // nsIContent interface + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +protected: + + virtual NumberAttributesInfo GetNumberInfo(); + // nsIDOMSVGStopElement properties: + nsSVGNumber2 mOffset; + static NumberInfo sNumberInfo; +}; + +nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo = +{ &nsGkAtoms::offset, 0, true }; + +NS_IMPL_NS_NEW_SVG_ELEMENT(Stop) + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase) + +DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement) + +NS_INTERFACE_TABLE_HEAD(nsSVGStopElement) + NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGStopElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase) + +//---------------------------------------------------------------------- +// Implementation + +nsSVGStopElement::nsSVGStopElement(already_AddRefed aNodeInfo) + : nsSVGStopElementBase(aNodeInfo) +{ + +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGStopElement methods + +/* readonly attribute nsIDOMSVGAnimatedNumber offset; */ +NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset) +{ + return mOffset.ToDOMAnimatedNumber(aOffset,this); +} + +//---------------------------------------------------------------------- +// nsSVGElement methods + +nsSVGElement::NumberAttributesInfo +nsSVGStopElement::GetNumberInfo() +{ + return NumberAttributesInfo(&mOffset, &sNumberInfo, 1); +} + +//---------------------------------------------------------------------- +// nsIContent methods + +NS_IMETHODIMP_(bool) +nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sGradientStopMap + }; + + return FindAttributeDependence(name, map) || + nsSVGStopElementBase::IsAttributeMapped(name); +} + + diff --git a/content/svg/content/src/nsSVGStyleElement.cpp b/content/svg/content/src/nsSVGStyleElement.cpp new file mode 100644 index 000000000000..7d43a7519a53 --- /dev/null +++ b/content/svg/content/src/nsSVGStyleElement.cpp @@ -0,0 +1,363 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsSVGElement.h" +#include "nsGkAtoms.h" +#include "nsIDOMSVGStyleElement.h" +#include "nsUnicharUtils.h" +#include "nsIDocument.h" +#include "nsStyleLinkElement.h" +#include "nsContentUtils.h" +#include "nsStubMutationObserver.h" + +using namespace mozilla; + +typedef nsSVGElement nsSVGStyleElementBase; + +class nsSVGStyleElement : public nsSVGStyleElementBase, + public nsIDOMSVGStyleElement, + public nsStyleLinkElement, + public nsStubMutationObserver +{ +protected: + friend nsresult NS_NewSVGStyleElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + nsSVGStyleElement(already_AddRefed aNodeInfo); + +public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSTYLEELEMENT + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGStyleElement, + nsSVGStyleElementBase) + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::) + + // nsIContent + virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers); + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true); + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAString& aValue, bool aNotify) + { + return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); + } + virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify); + virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, + bool aNotify); + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +protected: + // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and + // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be + // completely optimized away. + inline nsresult Init() + { + return NS_OK; + } + + // nsStyleLinkElement overrides + already_AddRefed GetStyleSheetURL(bool* aIsInline); + + void GetStyleSheetInfo(nsAString& aTitle, + nsAString& aType, + nsAString& aMedia, + bool* aIsAlternate); + virtual CORSMode GetCORSMode() const; + + /** + * Common method to call from the various mutation observer methods. + * aContent is a content node that's either the one that changed or its + * parent; we should only respond to the change if aContent is non-anonymous. + */ + void ContentChanged(nsIContent* aContent); +}; + + +NS_IMPL_NS_NEW_SVG_ELEMENT(Style) + + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase) + +DOMCI_NODE_DATA(SVGStyleElement, nsSVGStyleElement) + +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGStyleElement) + NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGStyleElement, + nsIDOMLinkStyle, nsIStyleSheetLinkingElement, + nsIMutationObserver) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase) + +NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGStyleElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGStyleElement, + nsSVGStyleElementBase) + tmp->nsStyleLinkElement::Traverse(cb); +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGStyleElement, + nsSVGStyleElementBase) + tmp->nsStyleLinkElement::Unlink(); +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + +//---------------------------------------------------------------------- +// Implementation + +nsSVGStyleElement::nsSVGStyleElement(already_AddRefed aNodeInfo) + : nsSVGStyleElementBase(aNodeInfo) +{ + AddMutationObserver(this); +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement) + + +//---------------------------------------------------------------------- +// nsIContent methods + +nsresult +nsSVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) +{ + nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal; + nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + + return rv; +} + +void +nsSVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) +{ + nsCOMPtr oldDoc = GetCurrentDoc(); + + nsSVGStyleElementBase::UnbindFromTree(aDeep, aNullParent); + UpdateStyleSheetInternal(oldDoc); +} + +nsresult +nsSVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify) +{ + nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, + aValue, aNotify); + if (NS_SUCCEEDED(rv)) { + UpdateStyleSheetInternal(nullptr, + aNameSpaceID == kNameSpaceID_None && + (aName == nsGkAtoms::title || + aName == nsGkAtoms::media || + aName == nsGkAtoms::type)); + } + + return rv; +} + +nsresult +nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, + bool aNotify) +{ + nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, + aNotify); + if (NS_SUCCEEDED(rv)) { + UpdateStyleSheetInternal(nullptr, + aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::title || + aAttribute == nsGkAtoms::media || + aAttribute == nsGkAtoms::type)); + } + + return rv; +} + +bool +nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) +{ + if (aNamespaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::crossorigin) { + ParseCORSValue(aValue, aResult); + return true; + } + + return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, + aResult); +} + +//---------------------------------------------------------------------- +// nsIMutationObserver methods + +void +nsSVGStyleElement::CharacterDataChanged(nsIDocument* aDocument, + nsIContent* aContent, + CharacterDataChangeInfo* aInfo) +{ + ContentChanged(aContent); +} + +void +nsSVGStyleElement::ContentAppended(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aFirstNewContent, + int32_t aNewIndexInContainer) +{ + ContentChanged(aContainer); +} + +void +nsSVGStyleElement::ContentInserted(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer) +{ + ContentChanged(aChild); +} + +void +nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer, + nsIContent* aPreviousSibling) +{ + ContentChanged(aChild); +} + +void +nsSVGStyleElement::ContentChanged(nsIContent* aContent) +{ + if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { + UpdateStyleSheetInternal(nullptr); + } +} + +//---------------------------------------------------------------------- +// nsIDOMSVGStyleElement methods + +/* attribute DOMString xmlspace; */ +NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace) +{ + GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace); + + return NS_OK; +} +NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace) +{ + return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); +} + +/* attribute DOMString type; */ +NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); + + return NS_OK; +} +NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); +} + +/* attribute DOMString media; */ +NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); + + return NS_OK; +} +NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); +} + +/* attribute DOMString title; */ +NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle); + + return NS_OK; +} +NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); +} + +//---------------------------------------------------------------------- +// nsStyleLinkElement methods + +already_AddRefed +nsSVGStyleElement::GetStyleSheetURL(bool* aIsInline) +{ + *aIsInline = true; + return nullptr; +} + +void +nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, + nsAString& aType, + nsAString& aMedia, + bool* aIsAlternate) +{ + *aIsAlternate = false; + + nsAutoString title; + GetAttr(kNameSpaceID_None, nsGkAtoms::title, title); + title.CompressWhitespace(); + aTitle.Assign(title); + + GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); + // The SVG spec is formulated in terms of the CSS2 spec, + // which specifies that media queries are case insensitive. + nsContentUtils::ASCIIToLower(aMedia); + + GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); + if (aType.IsEmpty()) { + aType.AssignLiteral("text/css"); + } + + return; +} + +CORSMode +nsSVGStyleElement::GetCORSMode() const +{ + return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); +} diff --git a/content/svg/content/src/nsSVGTitleElement.cpp b/content/svg/content/src/nsSVGTitleElement.cpp new file mode 100644 index 000000000000..e6a19bb299cf --- /dev/null +++ b/content/svg/content/src/nsSVGTitleElement.cpp @@ -0,0 +1,173 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsSVGElement.h" +#include "nsIDOMSVGTitleElement.h" +#include "nsStubMutationObserver.h" + +typedef nsSVGElement nsSVGTitleElementBase; + +class nsSVGTitleElement : public nsSVGTitleElementBase, + public nsIDOMSVGTitleElement, + public nsStubMutationObserver +{ +protected: + friend nsresult NS_NewSVGTitleElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + nsSVGTitleElement(already_AddRefed aNodeInfo); + nsresult Init(); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGTITLEELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::) + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, + nsIContent *aBindingParent, + bool aCompileEventHandlers); + + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true); + + virtual void DoneAddingChildren(bool aHaveNotified); + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +private: + void SendTitleChangeEvent(bool aBound); +}; + +NS_IMPL_NS_NEW_SVG_ELEMENT(Title) + + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase) +NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase) + +DOMCI_NODE_DATA(SVGTitleElement, nsSVGTitleElement) + +NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement) + NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGTitleElement, + nsIMutationObserver) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement) +NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase) + + +//---------------------------------------------------------------------- +// Implementation + +nsSVGTitleElement::nsSVGTitleElement(already_AddRefed aNodeInfo) + : nsSVGTitleElementBase(aNodeInfo) +{ + AddMutationObserver(this); +} + +nsresult +nsSVGTitleElement::Init() +{ + return nsSVGTitleElementBase::Init(); +} + +void +nsSVGTitleElement::CharacterDataChanged(nsIDocument *aDocument, + nsIContent *aContent, + CharacterDataChangeInfo *aInfo) +{ + SendTitleChangeEvent(false); +} + +void +nsSVGTitleElement::ContentAppended(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aFirstNewContent, + int32_t aNewIndexInContainer) +{ + SendTitleChangeEvent(false); +} + +void +nsSVGTitleElement::ContentInserted(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aChild, + int32_t aIndexInContainer) +{ + SendTitleChangeEvent(false); +} + +void +nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aChild, + int32_t aIndexInContainer, + nsIContent *aPreviousSibling) +{ + SendTitleChangeEvent(false); +} + +nsresult +nsSVGTitleElement::BindToTree(nsIDocument *aDocument, + nsIContent *aParent, + nsIContent *aBindingParent, + bool aCompileEventHandlers) +{ + // Let this fall through. + nsresult rv = nsSVGTitleElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + SendTitleChangeEvent(true); + + return NS_OK; +} + +void +nsSVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent) +{ + SendTitleChangeEvent(false); + + // Let this fall through. + nsSVGTitleElementBase::UnbindFromTree(aDeep, aNullParent); +} + +void +nsSVGTitleElement::DoneAddingChildren(bool aHaveNotified) +{ + if (!aHaveNotified) { + SendTitleChangeEvent(false); + } +} + +void +nsSVGTitleElement::SendTitleChangeEvent(bool aBound) +{ + nsIDocument* doc = GetCurrentDoc(); + if (doc) { + doc->NotifyPossibleTitleChange(aBound); + } +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 0e564339cd97..ecfc1c3feb4d 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -716,10 +716,6 @@ DOMInterfaces = { 'headerFile': 'SVGPreserveAspectRatio.h' }, -'SVGTitleElement': { - 'hasInstanceInterface': 'nsIDOMSVGTitleElement', -}, - 'SVGTransform': { 'nativeType': 'mozilla::DOMSVGTransform', 'headerFile': 'DOMSVGTransform.h' @@ -1122,7 +1118,6 @@ addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction addExternalIface('Range', nativeType='nsRange') addExternalIface('Selection', nativeType='nsISelection') addExternalIface('StyleSheetList') -addExternalIface('SVGAnimatedNumber') addExternalIface('SVGAnimatedString') addExternalIface('SVGLength') addExternalIface('SVGNumber') diff --git a/dom/webidl/SVGDescElement.webidl b/dom/webidl/SVGDescElement.webidl deleted file mode 100644 index 1841ff54585d..000000000000 --- a/dom/webidl/SVGDescElement.webidl +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGDescElement : SVGElement { -}; - diff --git a/dom/webidl/SVGMPathElement.webidl b/dom/webidl/SVGMPathElement.webidl deleted file mode 100644 index 7165b6cf7459..000000000000 --- a/dom/webidl/SVGMPathElement.webidl +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGMPathElement : SVGElement { -}; - -SVGMPathElement implements SVGURIReference; - diff --git a/dom/webidl/SVGMetadataElement.webidl b/dom/webidl/SVGMetadataElement.webidl deleted file mode 100644 index 1c404f91f2d0..000000000000 --- a/dom/webidl/SVGMetadataElement.webidl +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGMetadataElement : SVGElement { -}; - diff --git a/dom/webidl/SVGStopElement.webidl b/dom/webidl/SVGStopElement.webidl deleted file mode 100644 index 85e19bda33ac..000000000000 --- a/dom/webidl/SVGStopElement.webidl +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGAnimatedNumber; - -interface SVGStopElement : SVGElement { - readonly attribute SVGAnimatedNumber offset; -}; - diff --git a/dom/webidl/SVGStyleElement.webidl b/dom/webidl/SVGStyleElement.webidl deleted file mode 100644 index 07f6f3c5a691..000000000000 --- a/dom/webidl/SVGStyleElement.webidl +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGStyleElement : SVGElement { - [SetterThrows] - attribute DOMString xmlspace; // Spec claims this should be on SVGElement - [SetterThrows] - attribute DOMString type; - [SetterThrows] - attribute DOMString media; - [SetterThrows] - attribute DOMString title; -}; - diff --git a/dom/webidl/SVGTitleElement.webidl b/dom/webidl/SVGTitleElement.webidl deleted file mode 100644 index d40c63373ea7..000000000000 --- a/dom/webidl/SVGTitleElement.webidl +++ /dev/null @@ -1,15 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGTitleElement : SVGElement { -}; - diff --git a/dom/webidl/SVGURIReference.webidl b/dom/webidl/SVGURIReference.webidl deleted file mode 100644 index 29426b3acb96..000000000000 --- a/dom/webidl/SVGURIReference.webidl +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - * - * The origin of this IDL file is - * http://www.w3.org/TR/SVG2/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. - */ - -interface SVGAnimatedString; - -[NoInterfaceObject] -interface SVGURIReference { - readonly attribute SVGAnimatedString href; -}; - diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 6148d120130b..05ef83eee284 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -96,24 +96,17 @@ webidl_files = \ SVGAnimatedNumberList.webidl \ SVGAnimatedPreserveAspectRatio.webidl \ SVGAnimatedTransformList.webidl \ - SVGDescElement.webidl \ SVGElement.webidl \ SVGLengthList.webidl \ SVGMatrix.webidl \ - SVGMetadataElement.webidl \ - SVGMPathElement.webidl \ SVGNumberList.webidl \ SVGPathSeg.webidl \ SVGPathSegList.webidl \ SVGPoint.webidl \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ - SVGStopElement.webidl \ - SVGStyleElement.webidl \ - SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ - SVGURIReference.webidl \ Text.webidl \ TextDecoder.webidl \ TextEncoder.webidl \ From 4345e1355991a87b69cdbc5c607e69a103671c91 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Thu, 3 Jan 2013 09:57:41 -0800 Subject: [PATCH 107/180] Bug 825599 - Specialize type of switch's conditions. r=h4writer --- js/src/ion/IonBuilder.cpp | 2 ++ js/src/ion/IonSpewer.cpp | 2 +- js/src/jit-test/tests/ion/bug825599.js | 27 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 js/src/jit-test/tests/ion/bug825599.js diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index 69de552e16fd..297fb23b96a1 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -2376,6 +2376,8 @@ IonBuilder::processCondSwitchCase(CFGState &state) MDefinition *caseOperand = current->pop(); MDefinition *switchOperand = current->peek(-1); MCompare *cmpResult = MCompare::New(switchOperand, caseOperand, JSOP_STRICTEQ); + TypeOracle::BinaryTypes b = oracle->binaryTypes(script(), pc); + cmpResult->infer(b, cx); JS_ASSERT(!cmpResult->isEffectful()); current->add(cmpResult); current->end(MTest::New(cmpResult, bodyBlock, caseBlock)); diff --git a/js/src/ion/IonSpewer.cpp b/js/src/ion/IonSpewer.cpp index 40a3c61d131b..9ea843b914ed 100644 --- a/js/src/ion/IonSpewer.cpp +++ b/js/src/ion/IonSpewer.cpp @@ -133,7 +133,7 @@ IonSpewer::beginFunction(MIRGraph *graph, HandleScript function) return; if (!FilterContainsLocation(function->filename, function->lineno)) { - JS_ASSERT(!this->function); + JS_ASSERT(!this->graph); // filter out logs during the compilation. filteredOutCompilations++; return; diff --git a/js/src/jit-test/tests/ion/bug825599.js b/js/src/jit-test/tests/ion/bug825599.js new file mode 100644 index 000000000000..3f39fa56e471 --- /dev/null +++ b/js/src/jit-test/tests/ion/bug825599.js @@ -0,0 +1,27 @@ +var typedSwitch0 = function (a) { + switch (a) { + case null: + return 0; + case 1.1: + return 1; + case "2": + return 2; + case 3: + return 3; + } + return 4; +}; + +// reuse the same function for testing with different inputs & type. +var typedSwitch1 = eval(typedSwitch0.toSource()); +var typedSwitch2 = eval(typedSwitch0.toSource()); +var typedSwitch3 = eval(typedSwitch0.toSource()); +var typedSwitch4 = eval(typedSwitch0.toSource()); + +for (var i = 0; i < 100; i++) { + assertEq(typedSwitch0(null), 0); + assertEq(typedSwitch1(1.1), 1); + assertEq(typedSwitch2("2"), 2); + assertEq(typedSwitch3(3), 3); + assertEq(typedSwitch4(undefined), 4); +} From 571c5d4a960854f9ed30a117854564e385250abc Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:20 -0500 Subject: [PATCH 108/180] Bug 824327: Add a namespaced version of NS_NewSVGXXXElement r=bz --- content/svg/content/src/nsSVGElement.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h index 19b210ed230b..6f802305753d 100644 --- a/content/svg/content/src/nsSVGElement.h +++ b/content/svg/content/src/nsSVGElement.h @@ -640,6 +640,25 @@ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ return rv; \ } +#define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(_elementName) \ +nsresult \ +NS_NewSVG##_elementName##Element(nsIContent **aResult, \ + already_AddRefed aNodeInfo) \ +{ \ + nsRefPtr it = \ + new mozilla::dom::SVG##_elementName##Element(aNodeInfo); \ + \ + nsresult rv = it->Init(); \ + \ + if (NS_FAILED(rv)) { \ + return rv; \ + } \ + \ + it.forget(aResult); \ + \ + return rv; \ +} + #define NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(_elementName) \ nsresult \ NS_NewSVG##_elementName##Element(nsIContent **aResult, \ From 518068fcfab1e2086e72737182d455c295e0c292 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:21 -0500 Subject: [PATCH 109/180] Bug 824327: Convert SVGDescElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGDescElement.cpp => content/svg/content/src/SVGDescElement.cpp rename : content/svg/content/src/nsSVGDescElement.cpp => content/svg/content/src/SVGDescElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGDescElement.cpp | 50 +++++++++++++ content/svg/content/src/SVGDescElement.h | 52 ++++++++++++++ content/svg/content/src/nsSVGDescElement.cpp | 76 -------------------- dom/webidl/SVGDescElement.webidl | 15 ++++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 content/svg/content/src/SVGDescElement.cpp create mode 100644 content/svg/content/src/SVGDescElement.h delete mode 100644 content/svg/content/src/nsSVGDescElement.cpp create mode 100644 dom/webidl/SVGDescElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index d108e94c186c..b7fa04ced7ae 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -45,7 +45,6 @@ CPPSRCS = \ nsSVGClipPathElement.cpp \ nsSVGDataParser.cpp \ nsSVGDefsElement.cpp \ - nsSVGDescElement.cpp \ nsSVGElement.cpp \ nsSVGElementFactory.cpp \ nsSVGEllipseElement.cpp \ @@ -122,6 +121,7 @@ CPPSRCS = \ nsSVGSetElement.cpp \ SVGAttrValueWrapper.cpp \ SVGContentUtils.cpp \ + SVGDescElement.cpp \ SVGIntegerPairSMILType.cpp \ SVGLengthListSMILType.cpp \ SVGMotionSMILType.cpp \ @@ -154,6 +154,7 @@ EXPORTS_mozilla/dom = \ SVGAngle.h \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ + SVGDescElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/src/SVGDescElement.cpp b/content/svg/content/src/SVGDescElement.cpp new file mode 100644 index 000000000000..cf1bba764011 --- /dev/null +++ b/content/svg/content/src/SVGDescElement.cpp @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGDescElement.h" +#include "mozilla/dom/SVGDescElementBinding.h" + +DOMCI_NODE_DATA(SVGDescElement, mozilla::dom::SVGDescElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Desc) + +namespace mozilla { +namespace dom { + +JSObject* +SVGDescElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGDescElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGDescElement, SVGDescElementBase) +NS_IMPL_RELEASE_INHERITED(SVGDescElement, SVGDescElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGDescElement) + NS_NODE_INTERFACE_TABLE4(SVGDescElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGDescElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement) +NS_INTERFACE_MAP_END_INHERITING(SVGDescElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGDescElement::SVGDescElement(already_AddRefed aNodeInfo) + : SVGDescElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDescElement) + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGDescElement.h b/content/svg/content/src/SVGDescElement.h new file mode 100644 index 000000000000..f259b8922934 --- /dev/null +++ b/content/svg/content/src/SVGDescElement.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGDescElement_h +#define mozilla_dom_SVGDescElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGDescElement.h" + +nsresult NS_NewSVGDescElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGDescElementBase; + +namespace mozilla { +namespace dom { + +class SVGDescElement MOZ_FINAL : public SVGDescElementBase, + public nsIDOMSVGDescElement +{ +protected: + friend nsresult (::NS_NewSVGDescElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGDescElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGDESCELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGDescElementBase::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGDescElement_h + diff --git a/content/svg/content/src/nsSVGDescElement.cpp b/content/svg/content/src/nsSVGDescElement.cpp deleted file mode 100644 index 81c158ec49cf..000000000000 --- a/content/svg/content/src/nsSVGDescElement.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsIDOMSVGDescElement.h" - -typedef nsSVGElement nsSVGDescElementBase; - -class nsSVGDescElement : public nsSVGDescElementBase, - public nsIDOMSVGDescElement -{ -protected: - friend nsresult NS_NewSVGDescElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGDescElement(already_AddRefed aNodeInfo); - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGDESCELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGDescElementBase::) - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Desc) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGDescElement, nsSVGDescElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGDescElement, nsSVGDescElementBase) - -DOMCI_NODE_DATA(SVGDescElement, nsSVGDescElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGDescElement) - NS_NODE_INTERFACE_TABLE4(nsSVGDescElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGDescElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGDescElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGDescElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -nsSVGDescElement::nsSVGDescElement(already_AddRefed aNodeInfo) - : nsSVGDescElementBase(aNodeInfo) -{ -} - - -nsresult -nsSVGDescElement::Init() -{ - return nsSVGDescElementBase::Init(); -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGDescElement) - diff --git a/dom/webidl/SVGDescElement.webidl b/dom/webidl/SVGDescElement.webidl new file mode 100644 index 000000000000..1841ff54585d --- /dev/null +++ b/dom/webidl/SVGDescElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGDescElement : SVGElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 05ef83eee284..2df530c21b23 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -96,6 +96,7 @@ webidl_files = \ SVGAnimatedNumberList.webidl \ SVGAnimatedPreserveAspectRatio.webidl \ SVGAnimatedTransformList.webidl \ + SVGDescElement.webidl \ SVGElement.webidl \ SVGLengthList.webidl \ SVGMatrix.webidl \ From aeefdf5e7cc56937032c392e340a4a4648c05a1a Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:21 -0500 Subject: [PATCH 110/180] Bug 824327: Convert SVGTitleElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGTitleElement.cpp => content/svg/content/src/SVGTitleElement.cpp rename : content/svg/content/src/nsSVGTitleElement.cpp => content/svg/content/src/SVGTitleElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGTitleElement.cpp | 131 +++++++++++++ content/svg/content/src/SVGTitleElement.h | 69 +++++++ content/svg/content/src/nsSVGTitleElement.cpp | 173 ------------------ dom/bindings/Bindings.conf | 4 + dom/webidl/SVGTitleElement.webidl | 15 ++ dom/webidl/WebIDL.mk | 1 + 7 files changed, 222 insertions(+), 174 deletions(-) create mode 100644 content/svg/content/src/SVGTitleElement.cpp create mode 100644 content/svg/content/src/SVGTitleElement.h delete mode 100644 content/svg/content/src/nsSVGTitleElement.cpp create mode 100644 dom/webidl/SVGTitleElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index b7fa04ced7ae..52acd6df50cd 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -87,7 +87,6 @@ CPPSRCS = \ nsSVGTextElement.cpp \ nsSVGTextPathElement.cpp \ nsSVGTextPositioningElement.cpp \ - nsSVGTitleElement.cpp \ nsSVGUnknownElement.cpp \ nsSVGUseElement.cpp \ nsSVGViewBox.cpp \ @@ -110,6 +109,7 @@ CPPSRCS = \ SVGPointList.cpp \ SVGPreserveAspectRatio.cpp \ SVGStringList.cpp \ + SVGTitleElement.cpp \ SVGTransform.cpp \ SVGTransformList.cpp \ SVGTransformListParser.cpp \ @@ -155,6 +155,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ SVGDescElement.h \ + SVGTitleElement.h \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/content/svg/content/src/SVGTitleElement.cpp b/content/svg/content/src/SVGTitleElement.cpp new file mode 100644 index 000000000000..488158e1e15c --- /dev/null +++ b/content/svg/content/src/SVGTitleElement.cpp @@ -0,0 +1,131 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGTitleElement.h" +#include "mozilla/dom/SVGTitleElementBinding.h" + +DOMCI_NODE_DATA(SVGTitleElement, mozilla::dom::SVGTitleElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Title) + +namespace mozilla { +namespace dom { + +JSObject* +SVGTitleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGTitleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGTitleElement, SVGTitleElementBase) +NS_IMPL_RELEASE_INHERITED(SVGTitleElement, SVGTitleElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGTitleElement) + NS_NODE_INTERFACE_TABLE5(SVGTitleElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGTitleElement, + nsIMutationObserver) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement) +NS_INTERFACE_MAP_END_INHERITING(SVGTitleElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGTitleElement::SVGTitleElement(already_AddRefed aNodeInfo) + : SVGTitleElementBase(aNodeInfo) +{ + SetIsDOMBinding(); + AddMutationObserver(this); +} + +void +SVGTitleElement::CharacterDataChanged(nsIDocument *aDocument, + nsIContent *aContent, + CharacterDataChangeInfo *aInfo) +{ + SendTitleChangeEvent(false); +} + +void +SVGTitleElement::ContentAppended(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aFirstNewContent, + int32_t aNewIndexInContainer) +{ + SendTitleChangeEvent(false); +} + +void +SVGTitleElement::ContentInserted(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aChild, + int32_t aIndexInContainer) +{ + SendTitleChangeEvent(false); +} + +void +SVGTitleElement::ContentRemoved(nsIDocument *aDocument, + nsIContent *aContainer, + nsIContent *aChild, + int32_t aIndexInContainer, + nsIContent *aPreviousSibling) +{ + SendTitleChangeEvent(false); +} + +nsresult +SVGTitleElement::BindToTree(nsIDocument *aDocument, + nsIContent *aParent, + nsIContent *aBindingParent, + bool aCompileEventHandlers) +{ + // Let this fall through. + nsresult rv = SVGTitleElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + SendTitleChangeEvent(true); + + return NS_OK; +} + +void +SVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent) +{ + SendTitleChangeEvent(false); + + // Let this fall through. + SVGTitleElementBase::UnbindFromTree(aDeep, aNullParent); +} + +void +SVGTitleElement::DoneAddingChildren(bool aHaveNotified) +{ + if (!aHaveNotified) { + SendTitleChangeEvent(false); + } +} + +void +SVGTitleElement::SendTitleChangeEvent(bool aBound) +{ + nsIDocument* doc = GetCurrentDoc(); + if (doc) { + doc->NotifyPossibleTitleChange(aBound); + } +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGTitleElement) + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGTitleElement.h b/content/svg/content/src/SVGTitleElement.h new file mode 100644 index 000000000000..dc51df00c139 --- /dev/null +++ b/content/svg/content/src/SVGTitleElement.h @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGTitleElement_h +#define mozilla_dom_SVGTitleElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGTitleElement.h" +#include "nsStubMutationObserver.h" + +typedef nsSVGElement SVGTitleElementBase; + +nsresult NS_NewSVGTitleElement(nsIContent **aResult, + already_AddRefed aNodeInfo); +namespace mozilla { +namespace dom { + +class SVGTitleElement MOZ_FINAL : public SVGTitleElementBase, + public nsStubMutationObserver, + public nsIDOMSVGTitleElement +{ +protected: + friend nsresult (::NS_NewSVGTitleElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGTitleElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGTitleElementBase::) + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, + nsIContent *aBindingParent, + bool aCompileEventHandlers); + + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true); + + virtual void DoneAddingChildren(bool aHaveNotified); + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +private: + void SendTitleChangeEvent(bool aBound); +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGTitleElement_h + diff --git a/content/svg/content/src/nsSVGTitleElement.cpp b/content/svg/content/src/nsSVGTitleElement.cpp deleted file mode 100644 index e6a19bb299cf..000000000000 --- a/content/svg/content/src/nsSVGTitleElement.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsIDOMSVGTitleElement.h" -#include "nsStubMutationObserver.h" - -typedef nsSVGElement nsSVGTitleElementBase; - -class nsSVGTitleElement : public nsSVGTitleElementBase, - public nsIDOMSVGTitleElement, - public nsStubMutationObserver -{ -protected: - friend nsresult NS_NewSVGTitleElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGTitleElement(already_AddRefed aNodeInfo); - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGTITLEELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGTitleElementBase::) - - // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent, - nsIContent *aBindingParent, - bool aCompileEventHandlers); - - virtual void UnbindFromTree(bool aDeep = true, - bool aNullParent = true); - - virtual void DoneAddingChildren(bool aHaveNotified); - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -private: - void SendTitleChangeEvent(bool aBound); -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Title) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase) - -DOMCI_NODE_DATA(SVGTitleElement, nsSVGTitleElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement) - NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGTitleElement, - nsIMutationObserver) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGTitleElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -nsSVGTitleElement::nsSVGTitleElement(already_AddRefed aNodeInfo) - : nsSVGTitleElementBase(aNodeInfo) -{ - AddMutationObserver(this); -} - -nsresult -nsSVGTitleElement::Init() -{ - return nsSVGTitleElementBase::Init(); -} - -void -nsSVGTitleElement::CharacterDataChanged(nsIDocument *aDocument, - nsIContent *aContent, - CharacterDataChangeInfo *aInfo) -{ - SendTitleChangeEvent(false); -} - -void -nsSVGTitleElement::ContentAppended(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aFirstNewContent, - int32_t aNewIndexInContainer) -{ - SendTitleChangeEvent(false); -} - -void -nsSVGTitleElement::ContentInserted(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - int32_t aIndexInContainer) -{ - SendTitleChangeEvent(false); -} - -void -nsSVGTitleElement::ContentRemoved(nsIDocument *aDocument, - nsIContent *aContainer, - nsIContent *aChild, - int32_t aIndexInContainer, - nsIContent *aPreviousSibling) -{ - SendTitleChangeEvent(false); -} - -nsresult -nsSVGTitleElement::BindToTree(nsIDocument *aDocument, - nsIContent *aParent, - nsIContent *aBindingParent, - bool aCompileEventHandlers) -{ - // Let this fall through. - nsresult rv = nsSVGTitleElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); - NS_ENSURE_SUCCESS(rv, rv); - - SendTitleChangeEvent(true); - - return NS_OK; -} - -void -nsSVGTitleElement::UnbindFromTree(bool aDeep, bool aNullParent) -{ - SendTitleChangeEvent(false); - - // Let this fall through. - nsSVGTitleElementBase::UnbindFromTree(aDeep, aNullParent); -} - -void -nsSVGTitleElement::DoneAddingChildren(bool aHaveNotified) -{ - if (!aHaveNotified) { - SendTitleChangeEvent(false); - } -} - -void -nsSVGTitleElement::SendTitleChangeEvent(bool aBound) -{ - nsIDocument* doc = GetCurrentDoc(); - if (doc) { - doc->NotifyPossibleTitleChange(aBound); - } -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGTitleElement) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index ecfc1c3feb4d..59c9ce6d4fb9 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -716,6 +716,10 @@ DOMInterfaces = { 'headerFile': 'SVGPreserveAspectRatio.h' }, +'SVGTitleElement': { + 'hasInstanceInterface': 'nsIDOMSVGTitleElement', +}, + 'SVGTransform': { 'nativeType': 'mozilla::DOMSVGTransform', 'headerFile': 'DOMSVGTransform.h' diff --git a/dom/webidl/SVGTitleElement.webidl b/dom/webidl/SVGTitleElement.webidl new file mode 100644 index 000000000000..d40c63373ea7 --- /dev/null +++ b/dom/webidl/SVGTitleElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGTitleElement : SVGElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 2df530c21b23..abfb2486e1b2 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -106,6 +106,7 @@ webidl_files = \ SVGPoint.webidl \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ + SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ Text.webidl \ From fc40e9830d40b07d39d002f8b9848eab59eafa4c Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:21 -0500 Subject: [PATCH 111/180] Bug 824327: Convert SVGStopElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGStopElement.cpp => content/svg/content/src/SVGStopElement.cpp rename : content/svg/content/src/nsSVGStopElement.cpp => content/svg/content/src/SVGStopElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGStopElement.cpp | 93 +++++++++++++++ content/svg/content/src/SVGStopElement.h | 65 ++++++++++ content/svg/content/src/nsSVGStopElement.cpp | 118 ------------------- dom/bindings/Bindings.conf | 1 + dom/webidl/SVGStopElement.webidl | 18 +++ dom/webidl/WebIDL.mk | 1 + 7 files changed, 180 insertions(+), 119 deletions(-) create mode 100644 content/svg/content/src/SVGStopElement.cpp create mode 100644 content/svg/content/src/SVGStopElement.h delete mode 100644 content/svg/content/src/nsSVGStopElement.cpp create mode 100644 dom/webidl/SVGStopElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 52acd6df50cd..54a2a416ce2e 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -78,7 +78,6 @@ CPPSRCS = \ nsSVGRect.cpp \ nsSVGRectElement.cpp \ nsSVGSVGElement.cpp \ - nsSVGStopElement.cpp \ nsSVGStyleElement.cpp \ nsSVGSwitchElement.cpp \ nsSVGSymbolElement.cpp \ @@ -133,6 +132,7 @@ CPPSRCS = \ SVGOrientSMILType.cpp \ SVGPathSegListSMILType.cpp \ SVGPointListSMILType.cpp \ + SVGStopElement.cpp \ SVGTransformListSMILType.cpp \ SVGViewBoxSMILType.cpp \ $(NULL) @@ -155,6 +155,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ SVGDescElement.h \ + SVGStopElement.h \ SVGTitleElement.h \ $(NULL) diff --git a/content/svg/content/src/SVGStopElement.cpp b/content/svg/content/src/SVGStopElement.cpp new file mode 100644 index 000000000000..0f0327d45f1d --- /dev/null +++ b/content/svg/content/src/SVGStopElement.cpp @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGStopElement.h" +#include "mozilla/dom/SVGStopElementBinding.h" + +DOMCI_NODE_DATA(SVGStopElement, mozilla::dom::SVGStopElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Stop) + +namespace mozilla { +namespace dom { + +JSObject* +SVGStopElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGStopElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +nsSVGElement::NumberInfo SVGStopElement::sNumberInfo = +{ &nsGkAtoms::offset, 0, true }; + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGStopElement, SVGStopElementBase) +NS_IMPL_RELEASE_INHERITED(SVGStopElement, SVGStopElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGStopElement) + NS_NODE_INTERFACE_TABLE4(SVGStopElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGStopElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement) +NS_INTERFACE_MAP_END_INHERITING(SVGStopElementBase) + +//---------------------------------------------------------------------- +// Implementation + +SVGStopElement::SVGStopElement(already_AddRefed aNodeInfo) + : SVGStopElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement) + +//---------------------------------------------------------------------- +// nsIDOMSVGStopElement methods + +/* readonly attribute nsIDOMSVGAnimatedNumber offset; */ +NS_IMETHODIMP SVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset) +{ + return mOffset.ToDOMAnimatedNumber(aOffset,this); +} + +already_AddRefed +SVGStopElement::Offset() +{ + nsCOMPtr offset; + mOffset.ToDOMAnimatedNumber(getter_AddRefs(offset), this); + return offset.forget(); +} + +//---------------------------------------------------------------------- +// sSVGElement methods + +nsSVGElement::NumberAttributesInfo +SVGStopElement::GetNumberInfo() +{ + return NumberAttributesInfo(&mOffset, &sNumberInfo, 1); +} + +//---------------------------------------------------------------------- +// nsIContent methods + +NS_IMETHODIMP_(bool) +SVGStopElement::IsAttributeMapped(const nsIAtom* name) const +{ + static const MappedAttributeEntry* const map[] = { + sGradientStopMap + }; + + return FindAttributeDependence(name, map) || + SVGStopElementBase::IsAttributeMapped(name); +} + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGStopElement.h b/content/svg/content/src/SVGStopElement.h new file mode 100644 index 000000000000..02968e54338c --- /dev/null +++ b/content/svg/content/src/SVGStopElement.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGStopElement_h +#define mozilla_dom_SVGStopElement_h + +#include "nsSVGElement.h" +#include "nsSVGNumber2.h" +#include "nsIDOMSVGStopElement.h" + +nsresult NS_NewSVGStopElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGStopElementBase; + +namespace mozilla { +namespace dom { + +class SVGStopElement MOZ_FINAL : public SVGStopElementBase, + public nsIDOMSVGStopElement +{ +protected: + friend nsresult (::NS_NewSVGStopElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGStopElement(already_AddRefed aNodeInfo); + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSTOPELEMENT + + // xxx If xpcom allowed virtual inheritance we wouldn't need to + // forward here :-( + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGStopElementBase::) + + // nsIContent interface + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + already_AddRefed Offset(); + +protected: + + virtual NumberAttributesInfo GetNumberInfo(); + // nsIDOMSVGStopElement properties: + nsSVGNumber2 mOffset; + static NumberInfo sNumberInfo; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGStopElement_h diff --git a/content/svg/content/src/nsSVGStopElement.cpp b/content/svg/content/src/nsSVGStopElement.cpp deleted file mode 100644 index 3c133cb81556..000000000000 --- a/content/svg/content/src/nsSVGStopElement.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Util.h" - -#include "nsSVGElement.h" -#include "nsIDOMSVGStopElement.h" -#include "nsSVGNumber2.h" -#include "nsGenericHTMLElement.h" - -using namespace mozilla; - -typedef nsSVGElement nsSVGStopElementBase; - -class nsSVGStopElement : public nsSVGStopElementBase, - public nsIDOMSVGStopElement -{ -protected: - friend nsresult NS_NewSVGStopElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGStopElement(already_AddRefed aNodeInfo); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSTOPELEMENT - - // xxx If xpcom allowed virtual inheritance we wouldn't need to - // forward here :-( - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStopElementBase::) - - // nsIContent interface - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - - virtual NumberAttributesInfo GetNumberInfo(); - // nsIDOMSVGStopElement properties: - nsSVGNumber2 mOffset; - static NumberInfo sNumberInfo; -}; - -nsSVGElement::NumberInfo nsSVGStopElement::sNumberInfo = -{ &nsGkAtoms::offset, 0, true }; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Stop) - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase) - -DOMCI_NODE_DATA(SVGStopElement, nsSVGStopElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGStopElement) - NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGStopElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStopElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase) - -//---------------------------------------------------------------------- -// Implementation - -nsSVGStopElement::nsSVGStopElement(already_AddRefed aNodeInfo) - : nsSVGStopElementBase(aNodeInfo) -{ - -} - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStopElement) - -//---------------------------------------------------------------------- -// nsIDOMSVGStopElement methods - -/* readonly attribute nsIDOMSVGAnimatedNumber offset; */ -NS_IMETHODIMP nsSVGStopElement::GetOffset(nsIDOMSVGAnimatedNumber * *aOffset) -{ - return mOffset.ToDOMAnimatedNumber(aOffset,this); -} - -//---------------------------------------------------------------------- -// nsSVGElement methods - -nsSVGElement::NumberAttributesInfo -nsSVGStopElement::GetNumberInfo() -{ - return NumberAttributesInfo(&mOffset, &sNumberInfo, 1); -} - -//---------------------------------------------------------------------- -// nsIContent methods - -NS_IMETHODIMP_(bool) -nsSVGStopElement::IsAttributeMapped(const nsIAtom* name) const -{ - static const MappedAttributeEntry* const map[] = { - sGradientStopMap - }; - - return FindAttributeDependence(name, map) || - nsSVGStopElementBase::IsAttributeMapped(name); -} - - diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 59c9ce6d4fb9..0e564339cd97 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1122,6 +1122,7 @@ addExternalIface('ProcessingInstruction', nativeType='nsXMLProcessingInstruction addExternalIface('Range', nativeType='nsRange') addExternalIface('Selection', nativeType='nsISelection') addExternalIface('StyleSheetList') +addExternalIface('SVGAnimatedNumber') addExternalIface('SVGAnimatedString') addExternalIface('SVGLength') addExternalIface('SVGNumber') diff --git a/dom/webidl/SVGStopElement.webidl b/dom/webidl/SVGStopElement.webidl new file mode 100644 index 000000000000..85e19bda33ac --- /dev/null +++ b/dom/webidl/SVGStopElement.webidl @@ -0,0 +1,18 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGAnimatedNumber; + +interface SVGStopElement : SVGElement { + readonly attribute SVGAnimatedNumber offset; +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index abfb2486e1b2..cd81eac1adfa 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -106,6 +106,7 @@ webidl_files = \ SVGPoint.webidl \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ + SVGStopElement.webidl \ SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ From fc0e876c377aea5445d207305dffd87e2d8cc021 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:21 -0500 Subject: [PATCH 112/180] Bug 824327: Convert SVGStyleElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGStyleElement.cpp => content/svg/content/src/SVGStyleElement.cpp rename : content/svg/content/src/nsSVGStyleElement.cpp => content/svg/content/src/SVGStyleElement.h --- content/svg/content/src/Makefile.in | 3 +- content/svg/content/src/SVGStyleElement.cpp | 307 +++++++++++++++ content/svg/content/src/SVGStyleElement.h | 114 ++++++ content/svg/content/src/nsSVGStyleElement.cpp | 363 ------------------ dom/webidl/SVGStyleElement.webidl | 23 ++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 447 insertions(+), 364 deletions(-) create mode 100644 content/svg/content/src/SVGStyleElement.cpp create mode 100644 content/svg/content/src/SVGStyleElement.h delete mode 100644 content/svg/content/src/nsSVGStyleElement.cpp create mode 100644 dom/webidl/SVGStyleElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 54a2a416ce2e..cababe8b1d02 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -78,7 +78,6 @@ CPPSRCS = \ nsSVGRect.cpp \ nsSVGRectElement.cpp \ nsSVGSVGElement.cpp \ - nsSVGStyleElement.cpp \ nsSVGSwitchElement.cpp \ nsSVGSymbolElement.cpp \ nsSVGTSpanElement.cpp \ @@ -133,6 +132,7 @@ CPPSRCS = \ SVGPathSegListSMILType.cpp \ SVGPointListSMILType.cpp \ SVGStopElement.cpp \ + SVGStyleElement.cpp \ SVGTransformListSMILType.cpp \ SVGViewBoxSMILType.cpp \ $(NULL) @@ -156,6 +156,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedBoolean.h \ SVGDescElement.h \ SVGStopElement.h \ + SVGStyleElement.h \ SVGTitleElement.h \ $(NULL) diff --git a/content/svg/content/src/SVGStyleElement.cpp b/content/svg/content/src/SVGStyleElement.cpp new file mode 100644 index 000000000000..bef78f677b1b --- /dev/null +++ b/content/svg/content/src/SVGStyleElement.cpp @@ -0,0 +1,307 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGStyleElement.h" +#include "nsContentUtils.h" +#include "nsStubMutationObserver.h" +#include "mozilla/dom/SVGStyleElementBinding.h" + +DOMCI_NODE_DATA(SVGStyleElement, mozilla::dom::SVGStyleElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Style) + +namespace mozilla { +namespace dom { + +JSObject* +SVGStyleElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGStyleElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGStyleElement, SVGStyleElementBase) +NS_IMPL_RELEASE_INHERITED(SVGStyleElement, SVGStyleElementBase) + +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGStyleElement) + NS_NODE_INTERFACE_TABLE7(SVGStyleElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGStyleElement, + nsIDOMLinkStyle, nsIStyleSheetLinkingElement, + nsIMutationObserver) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement) +NS_INTERFACE_MAP_END_INHERITING(SVGStyleElementBase) + +NS_IMPL_CYCLE_COLLECTION_CLASS(SVGStyleElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGStyleElement, + SVGStyleElementBase) + tmp->nsStyleLinkElement::Traverse(cb); +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement, + SVGStyleElementBase) + tmp->nsStyleLinkElement::Unlink(); +NS_IMPL_CYCLE_COLLECTION_UNLINK_END + +//---------------------------------------------------------------------- +// Implementation + +SVGStyleElement::SVGStyleElement(already_AddRefed aNodeInfo) + : SVGStyleElementBase(aNodeInfo) +{ + SetIsDOMBinding(); + AddMutationObserver(this); +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStyleElement) + + +//---------------------------------------------------------------------- +// nsIContent methods + +nsresult +SVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) +{ + nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); + NS_ENSURE_SUCCESS(rv, rv); + + void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal; + nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + + return rv; +} + +void +SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) +{ + nsCOMPtr oldDoc = GetCurrentDoc(); + + SVGStyleElementBase::UnbindFromTree(aDeep, aNullParent); + UpdateStyleSheetInternal(oldDoc); +} + +nsresult +SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify) +{ + nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, + aValue, aNotify); + if (NS_SUCCEEDED(rv)) { + UpdateStyleSheetInternal(nullptr, + aNameSpaceID == kNameSpaceID_None && + (aName == nsGkAtoms::title || + aName == nsGkAtoms::media || + aName == nsGkAtoms::type)); + } + + return rv; +} + +nsresult +SVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, + bool aNotify) +{ + nsresult rv = SVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, + aNotify); + if (NS_SUCCEEDED(rv)) { + UpdateStyleSheetInternal(nullptr, + aNameSpaceID == kNameSpaceID_None && + (aAttribute == nsGkAtoms::title || + aAttribute == nsGkAtoms::media || + aAttribute == nsGkAtoms::type)); + } + + return rv; +} + +bool +SVGStyleElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) +{ + if (aNamespaceID == kNameSpaceID_None && + aAttribute == nsGkAtoms::crossorigin) { + ParseCORSValue(aValue, aResult); + return true; + } + + return SVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, + aResult); +} + +//---------------------------------------------------------------------- +// nsIMutationObserver methods + +void +SVGStyleElement::CharacterDataChanged(nsIDocument* aDocument, + nsIContent* aContent, + CharacterDataChangeInfo* aInfo) +{ + ContentChanged(aContent); +} + +void +SVGStyleElement::ContentAppended(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aFirstNewContent, + int32_t aNewIndexInContainer) +{ + ContentChanged(aContainer); +} + +void +SVGStyleElement::ContentInserted(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer) +{ + ContentChanged(aChild); +} + +void +SVGStyleElement::ContentRemoved(nsIDocument* aDocument, + nsIContent* aContainer, + nsIContent* aChild, + int32_t aIndexInContainer, + nsIContent* aPreviousSibling) +{ + ContentChanged(aChild); +} + +void +SVGStyleElement::ContentChanged(nsIContent* aContent) +{ + if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { + UpdateStyleSheetInternal(nullptr); + } +} + +//---------------------------------------------------------------------- +// nsIDOMSVGStyleElement methods + +/* attribute DOMString xmlspace; */ +NS_IMETHODIMP SVGStyleElement::GetXmlspace(nsAString & aXmlspace) +{ + GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetXmlspace(const nsAString & aXmlspace) +{ + return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); +} +void +SVGStyleElement::SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); +} + +/* attribute DOMString type; */ +NS_IMETHODIMP SVGStyleElement::GetType(nsAString & aType) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetType(const nsAString & aType) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); +} +void +SVGStyleElement::SetType(const nsAString & aType, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); +} + +/* attribute DOMString media; */ +NS_IMETHODIMP SVGStyleElement::GetMedia(nsAString & aMedia) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetMedia(const nsAString & aMedia) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); +} +void +SVGStyleElement::SetMedia(const nsAString & aMedia, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); +} + +/* attribute DOMString title; */ +NS_IMETHODIMP SVGStyleElement::GetTitle(nsAString & aTitle) +{ + GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle); + + return NS_OK; +} +NS_IMETHODIMP SVGStyleElement::SetTitle(const nsAString & aTitle) +{ + return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); +} +void +SVGStyleElement::SetTitle(const nsAString & aTitle, ErrorResult& rv) +{ + rv = SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); +} + +//---------------------------------------------------------------------- +// nsStyleLinkElement methods + +already_AddRefed +SVGStyleElement::GetStyleSheetURL(bool* aIsInline) +{ + *aIsInline = true; + return nullptr; +} + +void +SVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, + nsAString& aType, + nsAString& aMedia, + bool* aIsAlternate) +{ + *aIsAlternate = false; + + nsAutoString title; + GetAttr(kNameSpaceID_None, nsGkAtoms::title, title); + title.CompressWhitespace(); + aTitle.Assign(title); + + GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); + // The SVG spec is formulated in terms of the CSS2 spec, + // which specifies that media queries are case insensitive. + nsContentUtils::ASCIIToLower(aMedia); + + GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); + if (aType.IsEmpty()) { + aType.AssignLiteral("text/css"); + } + + return; +} + +CORSMode +SVGStyleElement::GetCORSMode() const +{ + return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); +} + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGStyleElement.h b/content/svg/content/src/SVGStyleElement.h new file mode 100644 index 000000000000..c2a3d3f4b67a --- /dev/null +++ b/content/svg/content/src/SVGStyleElement.h @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGStyleElement_h +#define mozilla_dom_SVGStyleElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGStyleElement.h" +#include "nsStyleLinkElement.h" +#include "nsStubMutationObserver.h" + +nsresult NS_NewSVGStyleElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGStyleElementBase; + +namespace mozilla { +namespace dom { + +class SVGStyleElement MOZ_FINAL : public SVGStyleElementBase, + public nsIDOMSVGStyleElement, + public nsStyleLinkElement, + public nsStubMutationObserver +{ +protected: + friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGStyleElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + +public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGSTYLEELEMENT + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement, + SVGStyleElementBase) + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(SVGStyleElementBase::) + + // nsIContent + virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers); + virtual void UnbindFromTree(bool aDeep = true, + bool aNullParent = true); + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAString& aValue, bool aNotify) + { + return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); + } + virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, + nsIAtom* aPrefix, const nsAString& aValue, + bool aNotify); + virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, + bool aNotify); + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + // nsIMutationObserver + NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED + NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + void SetXmlspace(const nsAString & aXmlspace, ErrorResult& rv); + void SetType(const nsAString & aType, ErrorResult& rv); + void SetMedia(const nsAString & aMedia, ErrorResult& rv); + void SetTitle(const nsAString & aTitle, ErrorResult& rv); + +protected: + // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and + // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be + // completely optimized away. + inline nsresult Init() + { + return NS_OK; + } + + // nsStyleLinkElement overrides + already_AddRefed GetStyleSheetURL(bool* aIsInline); + + void GetStyleSheetInfo(nsAString& aTitle, + nsAString& aType, + nsAString& aMedia, + bool* aIsAlternate); + virtual CORSMode GetCORSMode() const; + + /** + * Common method to call from the various mutation observer methods. + * aContent is a content node that's either the one that changed or its + * parent; we should only respond to the change if aContent is non-anonymous. + */ + void ContentChanged(nsIContent* aContent); +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGStyleElement_h diff --git a/content/svg/content/src/nsSVGStyleElement.cpp b/content/svg/content/src/nsSVGStyleElement.cpp deleted file mode 100644 index 7d43a7519a53..000000000000 --- a/content/svg/content/src/nsSVGStyleElement.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsGkAtoms.h" -#include "nsIDOMSVGStyleElement.h" -#include "nsUnicharUtils.h" -#include "nsIDocument.h" -#include "nsStyleLinkElement.h" -#include "nsContentUtils.h" -#include "nsStubMutationObserver.h" - -using namespace mozilla; - -typedef nsSVGElement nsSVGStyleElementBase; - -class nsSVGStyleElement : public nsSVGStyleElementBase, - public nsIDOMSVGStyleElement, - public nsStyleLinkElement, - public nsStubMutationObserver -{ -protected: - friend nsresult NS_NewSVGStyleElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGStyleElement(already_AddRefed aNodeInfo); - -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGSTYLEELEMENT - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGStyleElement, - nsSVGStyleElementBase) - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGStyleElementBase::) - - // nsIContent - virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers); - virtual void UnbindFromTree(bool aDeep = true, - bool aNullParent = true); - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } - virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify); - virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify); - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - // nsIMutationObserver - NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED - NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and - // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be - // completely optimized away. - inline nsresult Init() - { - return NS_OK; - } - - // nsStyleLinkElement overrides - already_AddRefed GetStyleSheetURL(bool* aIsInline); - - void GetStyleSheetInfo(nsAString& aTitle, - nsAString& aType, - nsAString& aMedia, - bool* aIsAlternate); - virtual CORSMode GetCORSMode() const; - - /** - * Common method to call from the various mutation observer methods. - * aContent is a content node that's either the one that changed or its - * parent; we should only respond to the change if aContent is non-anonymous. - */ - void ContentChanged(nsIContent* aContent); -}; - - -NS_IMPL_NS_NEW_SVG_ELEMENT(Style) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase) - -DOMCI_NODE_DATA(SVGStyleElement, nsSVGStyleElement) - -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGStyleElement) - NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGStyleElement, - nsIDOMLinkStyle, nsIStyleSheetLinkingElement, - nsIMutationObserver) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGStyleElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase) - -NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGStyleElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGStyleElement, - nsSVGStyleElementBase) - tmp->nsStyleLinkElement::Traverse(cb); -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGStyleElement, - nsSVGStyleElementBase) - tmp->nsStyleLinkElement::Unlink(); -NS_IMPL_CYCLE_COLLECTION_UNLINK_END - -//---------------------------------------------------------------------- -// Implementation - -nsSVGStyleElement::nsSVGStyleElement(already_AddRefed aNodeInfo) - : nsSVGStyleElementBase(aNodeInfo) -{ - AddMutationObserver(this); -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGStyleElement) - - -//---------------------------------------------------------------------- -// nsIContent methods - -nsresult -nsSVGStyleElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) -{ - nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); - NS_ENSURE_SUCCESS(rv, rv); - - void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); - - return rv; -} - -void -nsSVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) -{ - nsCOMPtr oldDoc = GetCurrentDoc(); - - nsSVGStyleElementBase::UnbindFromTree(aDeep, aNullParent); - UpdateStyleSheetInternal(oldDoc); -} - -nsresult -nsSVGStyleElement::SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - bool aNotify) -{ - nsresult rv = nsSVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, - aValue, aNotify); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheetInternal(nullptr, - aNameSpaceID == kNameSpaceID_None && - (aName == nsGkAtoms::title || - aName == nsGkAtoms::media || - aName == nsGkAtoms::type)); - } - - return rv; -} - -nsresult -nsSVGStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, - bool aNotify) -{ - nsresult rv = nsSVGStyleElementBase::UnsetAttr(aNameSpaceID, aAttribute, - aNotify); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheetInternal(nullptr, - aNameSpaceID == kNameSpaceID_None && - (aAttribute == nsGkAtoms::title || - aAttribute == nsGkAtoms::media || - aAttribute == nsGkAtoms::type)); - } - - return rv; -} - -bool -nsSVGStyleElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aNamespaceID == kNameSpaceID_None && - aAttribute == nsGkAtoms::crossorigin) { - ParseCORSValue(aValue, aResult); - return true; - } - - return nsSVGStyleElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, - aResult); -} - -//---------------------------------------------------------------------- -// nsIMutationObserver methods - -void -nsSVGStyleElement::CharacterDataChanged(nsIDocument* aDocument, - nsIContent* aContent, - CharacterDataChangeInfo* aInfo) -{ - ContentChanged(aContent); -} - -void -nsSVGStyleElement::ContentAppended(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aFirstNewContent, - int32_t aNewIndexInContainer) -{ - ContentChanged(aContainer); -} - -void -nsSVGStyleElement::ContentInserted(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer) -{ - ContentChanged(aChild); -} - -void -nsSVGStyleElement::ContentRemoved(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aChild, - int32_t aIndexInContainer, - nsIContent* aPreviousSibling) -{ - ContentChanged(aChild); -} - -void -nsSVGStyleElement::ContentChanged(nsIContent* aContent) -{ - if (nsContentUtils::IsInSameAnonymousTree(this, aContent)) { - UpdateStyleSheetInternal(nullptr); - } -} - -//---------------------------------------------------------------------- -// nsIDOMSVGStyleElement methods - -/* attribute DOMString xmlspace; */ -NS_IMETHODIMP nsSVGStyleElement::GetXmlspace(nsAString & aXmlspace) -{ - GetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetXmlspace(const nsAString & aXmlspace) -{ - return SetAttr(kNameSpaceID_XML, nsGkAtoms::space, aXmlspace, true); -} - -/* attribute DOMString type; */ -NS_IMETHODIMP nsSVGStyleElement::GetType(nsAString & aType) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetType(const nsAString & aType) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::type, aType, true); -} - -/* attribute DOMString media; */ -NS_IMETHODIMP nsSVGStyleElement::GetMedia(nsAString & aMedia) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetMedia(const nsAString & aMedia) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia, true); -} - -/* attribute DOMString title; */ -NS_IMETHODIMP nsSVGStyleElement::GetTitle(nsAString & aTitle) -{ - GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle); - - return NS_OK; -} -NS_IMETHODIMP nsSVGStyleElement::SetTitle(const nsAString & aTitle) -{ - return SetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle, true); -} - -//---------------------------------------------------------------------- -// nsStyleLinkElement methods - -already_AddRefed -nsSVGStyleElement::GetStyleSheetURL(bool* aIsInline) -{ - *aIsInline = true; - return nullptr; -} - -void -nsSVGStyleElement::GetStyleSheetInfo(nsAString& aTitle, - nsAString& aType, - nsAString& aMedia, - bool* aIsAlternate) -{ - *aIsAlternate = false; - - nsAutoString title; - GetAttr(kNameSpaceID_None, nsGkAtoms::title, title); - title.CompressWhitespace(); - aTitle.Assign(title); - - GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia); - // The SVG spec is formulated in terms of the CSS2 spec, - // which specifies that media queries are case insensitive. - nsContentUtils::ASCIIToLower(aMedia); - - GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType); - if (aType.IsEmpty()) { - aType.AssignLiteral("text/css"); - } - - return; -} - -CORSMode -nsSVGStyleElement::GetCORSMode() const -{ - return AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)); -} diff --git a/dom/webidl/SVGStyleElement.webidl b/dom/webidl/SVGStyleElement.webidl new file mode 100644 index 000000000000..07f6f3c5a691 --- /dev/null +++ b/dom/webidl/SVGStyleElement.webidl @@ -0,0 +1,23 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGStyleElement : SVGElement { + [SetterThrows] + attribute DOMString xmlspace; // Spec claims this should be on SVGElement + [SetterThrows] + attribute DOMString type; + [SetterThrows] + attribute DOMString media; + [SetterThrows] + attribute DOMString title; +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index cd81eac1adfa..97aa4aea4265 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -107,6 +107,7 @@ webidl_files = \ SVGPointList.webidl \ SVGPreserveAspectRatio.webidl \ SVGStopElement.webidl \ + SVGStyleElement.webidl \ SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ From 1098e5532f0f2aaa3606fc366ff39f03b698d532 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:21 -0500 Subject: [PATCH 113/180] Bug 824327: Convert SVGMetadataElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGMetadataElement.cpp => content/svg/content/src/SVGMetadataElement.cpp rename : content/svg/content/src/nsSVGMetadataElement.cpp => content/svg/content/src/SVGMetadataElement.h --- content/svg/content/src/Makefile.in | 3 +- .../svg/content/src/SVGMetadataElement.cpp | 59 +++++++++++++++ content/svg/content/src/SVGMetadataElement.h | 52 +++++++++++++ .../svg/content/src/nsSVGMetadataElement.cpp | 75 ------------------- dom/webidl/SVGMetadataElement.webidl | 15 ++++ dom/webidl/WebIDL.mk | 1 + 6 files changed, 129 insertions(+), 76 deletions(-) create mode 100644 content/svg/content/src/SVGMetadataElement.cpp create mode 100644 content/svg/content/src/SVGMetadataElement.h delete mode 100644 content/svg/content/src/nsSVGMetadataElement.cpp create mode 100644 dom/webidl/SVGMetadataElement.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index cababe8b1d02..7740ba24f97e 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -63,7 +63,6 @@ CPPSRCS = \ nsSVGLineElement.cpp \ nsSVGMarkerElement.cpp \ nsSVGMaskElement.cpp \ - nsSVGMetadataElement.cpp \ nsSVGNumber2.cpp \ nsSVGNumberPair.cpp \ nsSVGPathDataParser.cpp \ @@ -122,6 +121,7 @@ CPPSRCS = \ SVGDescElement.cpp \ SVGIntegerPairSMILType.cpp \ SVGLengthListSMILType.cpp \ + SVGMetadataElement.cpp \ SVGMotionSMILType.cpp \ SVGMotionSMILAttr.cpp \ SVGMotionSMILAnimationFunction.cpp \ @@ -155,6 +155,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedAngle.h \ SVGAnimatedBoolean.h \ SVGDescElement.h \ + SVGMetadataElement.h \ SVGStopElement.h \ SVGStyleElement.h \ SVGTitleElement.h \ diff --git a/content/svg/content/src/SVGMetadataElement.cpp b/content/svg/content/src/SVGMetadataElement.cpp new file mode 100644 index 000000000000..036113b0468c --- /dev/null +++ b/content/svg/content/src/SVGMetadataElement.cpp @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/SVGMetadataElement.h" +#include "mozilla/dom/SVGMetadataElementBinding.h" + +DOMCI_NODE_DATA(SVGMetadataElement, mozilla::dom::SVGMetadataElement) + +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Metadata) + +namespace mozilla { +namespace dom { + +JSObject* +SVGMetadataElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGMetadataElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +//---------------------------------------------------------------------- +// nsISupports methods + +NS_IMPL_ADDREF_INHERITED(SVGMetadataElement, SVGMetadataElementBase) +NS_IMPL_RELEASE_INHERITED(SVGMetadataElement, SVGMetadataElementBase) + +NS_INTERFACE_TABLE_HEAD(SVGMetadataElement) + NS_NODE_INTERFACE_TABLE4(SVGMetadataElement, nsIDOMNode, nsIDOMElement, + nsIDOMSVGElement, nsIDOMSVGMetadataElement) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement) +NS_INTERFACE_MAP_END_INHERITING(SVGMetadataElementBase) + + +//---------------------------------------------------------------------- +// Implementation + +SVGMetadataElement::SVGMetadataElement(already_AddRefed aNodeInfo) + : SVGMetadataElementBase(aNodeInfo) +{ + SetIsDOMBinding(); +} + + +nsresult +SVGMetadataElement::Init() +{ + return NS_OK; +} + + +//---------------------------------------------------------------------- +// nsIDOMNode methods + +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMetadataElement) + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/SVGMetadataElement.h b/content/svg/content/src/SVGMetadataElement.h new file mode 100644 index 000000000000..7a6d1baf5451 --- /dev/null +++ b/content/svg/content/src/SVGMetadataElement.h @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_SVGMetadataElement_h +#define mozilla_dom_SVGMetadataElement_h + +#include "nsSVGElement.h" +#include "nsIDOMSVGMetadataElement.h" + +nsresult NS_NewSVGMetadataElement(nsIContent **aResult, + already_AddRefed aNodeInfo); + +typedef nsSVGElement SVGMetadataElementBase; + +namespace mozilla { +namespace dom { + +class SVGMetadataElement MOZ_FINAL : public SVGMetadataElementBase, + public nsIDOMSVGMetadataElement +{ +protected: + friend nsresult (::NS_NewSVGMetadataElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGMetadataElement(already_AddRefed aNodeInfo); + + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; + nsresult Init(); + +public: + // interfaces: + + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIDOMSVGMETADATAELEMENT + + // xxx I wish we could use virtual inheritance + NS_FORWARD_NSIDOMNODE_TO_NSINODE + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGMetadataElement_h diff --git a/content/svg/content/src/nsSVGMetadataElement.cpp b/content/svg/content/src/nsSVGMetadataElement.cpp deleted file mode 100644 index af52ffae835c..000000000000 --- a/content/svg/content/src/nsSVGMetadataElement.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsSVGElement.h" -#include "nsIDOMSVGMetadataElement.h" - -typedef nsSVGElement nsSVGMetadataElementBase; - -class nsSVGMetadataElement : public nsSVGMetadataElementBase, - public nsIDOMSVGMetadataElement -{ -protected: - friend nsresult NS_NewSVGMetadataElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGMetadataElement(already_AddRefed aNodeInfo); - nsresult Init(); - -public: - // interfaces: - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMSVGMETADATAELEMENT - - // xxx I wish we could use virtual inheritance - NS_FORWARD_NSIDOMNODE_TO_NSINODE - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGElement::) - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - -NS_IMPL_NS_NEW_SVG_ELEMENT(Metadata) - - -//---------------------------------------------------------------------- -// nsISupports methods - -NS_IMPL_ADDREF_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase) - -DOMCI_NODE_DATA(SVGMetadataElement, nsSVGMetadataElement) - -NS_INTERFACE_TABLE_HEAD(nsSVGMetadataElement) - NS_NODE_INTERFACE_TABLE4(nsSVGMetadataElement, nsIDOMNode, nsIDOMElement, - nsIDOMSVGElement, nsIDOMSVGMetadataElement) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMetadataElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGMetadataElementBase) - - -//---------------------------------------------------------------------- -// Implementation - -nsSVGMetadataElement::nsSVGMetadataElement(already_AddRefed aNodeInfo) - : nsSVGMetadataElementBase(aNodeInfo) -{ -} - - -nsresult -nsSVGMetadataElement::Init() -{ - return NS_OK; -} - - -//---------------------------------------------------------------------- -// nsIDOMNode methods - -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMetadataElement) diff --git a/dom/webidl/SVGMetadataElement.webidl b/dom/webidl/SVGMetadataElement.webidl new file mode 100644 index 000000000000..1c404f91f2d0 --- /dev/null +++ b/dom/webidl/SVGMetadataElement.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGMetadataElement : SVGElement { +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 97aa4aea4265..a21f2f079a46 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -100,6 +100,7 @@ webidl_files = \ SVGElement.webidl \ SVGLengthList.webidl \ SVGMatrix.webidl \ + SVGMetadataElement.webidl \ SVGNumberList.webidl \ SVGPathSeg.webidl \ SVGPathSegList.webidl \ From 924ce821501f6bdd9981ad40b085d9ca1265e0bb Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Fri, 4 Jan 2013 20:50:22 -0500 Subject: [PATCH 114/180] Bug 824327: Convert SVGMPathElement to WebIDL r=bz --HG-- rename : content/svg/content/src/nsSVGMpathElement.cpp => content/svg/content/src/SVGMPathElement.cpp rename : content/svg/content/src/nsSVGMpathElement.h => content/svg/content/src/SVGMPathElement.h --- content/svg/content/src/Makefile.in | 3 +- ...VGMpathElement.cpp => SVGMPathElement.cpp} | 129 ++++++++++-------- ...{nsSVGMpathElement.h => SVGMPathElement.h} | 47 ++++--- .../src/SVGMotionSMILAnimationFunction.cpp | 12 +- .../src/SVGMotionSMILAnimationFunction.h | 7 +- .../svg/content/src/nsSVGElementFactory.cpp | 4 +- dom/webidl/SVGMPathElement.webidl | 17 +++ dom/webidl/SVGURIReference.webidl | 19 +++ dom/webidl/WebIDL.mk | 2 + 9 files changed, 159 insertions(+), 81 deletions(-) rename content/svg/content/src/{nsSVGMpathElement.cpp => SVGMPathElement.cpp} (62%) rename content/svg/content/src/{nsSVGMpathElement.h => SVGMPathElement.h} (70%) create mode 100644 dom/webidl/SVGMPathElement.webidl create mode 100644 dom/webidl/SVGURIReference.webidl diff --git a/content/svg/content/src/Makefile.in b/content/svg/content/src/Makefile.in index 7740ba24f97e..d34d99282636 100644 --- a/content/svg/content/src/Makefile.in +++ b/content/svg/content/src/Makefile.in @@ -114,7 +114,6 @@ CPPSRCS = \ nsSVGAnimateTransformElement.cpp \ nsSVGAnimateMotionElement.cpp \ nsSVGAnimationElement.cpp \ - nsSVGMpathElement.cpp \ nsSVGSetElement.cpp \ SVGAttrValueWrapper.cpp \ SVGContentUtils.cpp \ @@ -126,6 +125,7 @@ CPPSRCS = \ SVGMotionSMILAttr.cpp \ SVGMotionSMILAnimationFunction.cpp \ SVGMotionSMILPathUtils.cpp \ + SVGMPathElement.cpp \ SVGNumberListSMILType.cpp \ SVGNumberPairSMILType.cpp \ SVGOrientSMILType.cpp \ @@ -156,6 +156,7 @@ EXPORTS_mozilla/dom = \ SVGAnimatedBoolean.h \ SVGDescElement.h \ SVGMetadataElement.h \ + SVGMPathElement.h \ SVGStopElement.h \ SVGStyleElement.h \ SVGTitleElement.h \ diff --git a/content/svg/content/src/nsSVGMpathElement.cpp b/content/svg/content/src/SVGMPathElement.cpp similarity index 62% rename from content/svg/content/src/nsSVGMpathElement.cpp rename to content/svg/content/src/SVGMPathElement.cpp index ea5bb5f8e584..927cdcbff1c4 100644 --- a/content/svg/content/src/nsSVGMpathElement.cpp +++ b/content/svg/content/src/SVGMPathElement.cpp @@ -5,49 +5,56 @@ #include "mozilla/Util.h" -#include "nsSVGMpathElement.h" +#include "mozilla/dom/SVGMPathElement.h" #include "nsAutoPtr.h" #include "nsDebug.h" #include "nsSVGPathElement.h" #include "nsSVGAnimateMotionElement.h" #include "nsContentUtils.h" +#include "mozilla/dom/SVGMPathElementBinding.h" -using namespace mozilla; -using namespace mozilla::dom; +DOMCI_NODE_DATA(SVGMpathElement, mozilla::dom::SVGMPathElement) -nsSVGElement::StringInfo nsSVGMpathElement::sStringInfo[1] = +NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(MPath) + +namespace mozilla { +namespace dom { + +JSObject* +SVGMPathElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return SVGMPathElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + +nsSVGElement::StringInfo SVGMPathElement::sStringInfo[1] = { { &nsGkAtoms::href, kNameSpaceID_XLink, false } }; -NS_IMPL_NS_NEW_SVG_ELEMENT(Mpath) - // Cycle collection magic -- based on nsSVGUseElement -NS_IMPL_CYCLE_COLLECTION_CLASS(nsSVGMpathElement) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSVGMpathElement, - nsSVGMpathElementBase) +NS_IMPL_CYCLE_COLLECTION_CLASS(SVGMPathElement) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGMPathElement, + SVGMPathElementBase) tmp->UnlinkHrefTarget(false); NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSVGMpathElement, - nsSVGMpathElementBase) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(SVGMPathElement, + SVGMPathElementBase) tmp->mHrefTarget.Traverse(&cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END //---------------------------------------------------------------------- // nsISupports methods -NS_IMPL_ADDREF_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase) -NS_IMPL_RELEASE_INHERITED(nsSVGMpathElement,nsSVGMpathElementBase) +NS_IMPL_ADDREF_INHERITED(SVGMPathElement,SVGMPathElementBase) +NS_IMPL_RELEASE_INHERITED(SVGMPathElement,SVGMPathElementBase) -DOMCI_NODE_DATA(SVGMpathElement, nsSVGMpathElement) - -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsSVGMpathElement) - NS_NODE_INTERFACE_TABLE6(nsSVGMpathElement, nsIDOMNode, nsIDOMElement, +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(SVGMPathElement) + NS_NODE_INTERFACE_TABLE6(SVGMPathElement, nsIDOMNode, nsIDOMElement, nsIDOMSVGElement, nsIDOMSVGURIReference, nsIDOMSVGMpathElement, nsIMutationObserver) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(SVGMpathElement) -NS_INTERFACE_MAP_END_INHERITING(nsSVGMpathElementBase) +NS_INTERFACE_MAP_END_INHERITING(SVGMPathElementBase) // Constructor #ifdef _MSC_VER @@ -57,16 +64,17 @@ NS_INTERFACE_MAP_END_INHERITING(nsSVGMpathElementBase) #pragma warning(push) #pragma warning(disable:4355) #endif -nsSVGMpathElement::nsSVGMpathElement(already_AddRefed aNodeInfo) - : nsSVGMpathElementBase(aNodeInfo), +SVGMPathElement::SVGMPathElement(already_AddRefed aNodeInfo) + : SVGMPathElementBase(aNodeInfo), mHrefTarget(this) #ifdef _MSC_VER #pragma warning(pop) #endif { + SetIsDOMBinding(); } -nsSVGMpathElement::~nsSVGMpathElement() +SVGMPathElement::~SVGMPathElement() { UnlinkHrefTarget(false); } @@ -74,33 +82,42 @@ nsSVGMpathElement::~nsSVGMpathElement() //---------------------------------------------------------------------- // nsIDOMNode methods -NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMpathElement) +NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMPathElement) //---------------------------------------------------------------------- // nsIDOMSVGURIReference methods /* readonly attribute nsIDOMSVGAnimatedString href; */ -NS_IMETHODIMP -nsSVGMpathElement::GetHref(nsIDOMSVGAnimatedString** aHref) +already_AddRefed +SVGMPathElement::Href() { - return mStringAttributes[HREF].ToDOMAnimatedString(aHref, this); + nsCOMPtr href; + mStringAttributes[HREF].ToDOMAnimatedString(getter_AddRefs(href), this); + return href.forget(); +} + +NS_IMETHODIMP +SVGMPathElement::GetHref(nsIDOMSVGAnimatedString** aHref) +{ + *aHref = Href().get(); + return NS_OK; } //---------------------------------------------------------------------- // nsIContent methods nsresult -nsSVGMpathElement::BindToTree(nsIDocument* aDocument, - nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) +SVGMPathElement::BindToTree(nsIDocument* aDocument, + nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) { NS_ABORT_IF_FALSE(!mHrefTarget.get(), "Shouldn't have href-target yet " "(or it should've been cleared)"); - nsresult rv = nsSVGMpathElementBase::BindToTree(aDocument, aParent, - aBindingParent, - aCompileEventHandlers); + nsresult rv = SVGMPathElementBase::BindToTree(aDocument, aParent, + aBindingParent, + aCompileEventHandlers); NS_ENSURE_SUCCESS(rv,rv); if (aDocument) { @@ -115,20 +132,20 @@ nsSVGMpathElement::BindToTree(nsIDocument* aDocument, } void -nsSVGMpathElement::UnbindFromTree(bool aDeep, bool aNullParent) +SVGMPathElement::UnbindFromTree(bool aDeep, bool aNullParent) { UnlinkHrefTarget(true); - nsSVGMpathElementBase::UnbindFromTree(aDeep, aNullParent); + SVGMPathElementBase::UnbindFromTree(aDeep, aNullParent); } bool -nsSVGMpathElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +SVGMPathElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { bool returnVal = - nsSVGMpathElementBase::ParseAttribute(aNamespaceID, aAttribute, + SVGMPathElementBase::ParseAttribute(aNamespaceID, aAttribute, aValue, aResult); if (aNamespaceID == kNameSpaceID_XLink && aAttribute == nsGkAtoms::href && @@ -141,11 +158,11 @@ nsSVGMpathElement::ParseAttribute(int32_t aNamespaceID, } nsresult -nsSVGMpathElement::UnsetAttr(int32_t aNamespaceID, - nsIAtom* aAttribute, bool aNotify) +SVGMPathElement::UnsetAttr(int32_t aNamespaceID, + nsIAtom* aAttribute, bool aNotify) { - nsresult rv = nsSVGMpathElementBase::UnsetAttr(aNamespaceID, aAttribute, - aNotify); + nsresult rv = SVGMPathElementBase::UnsetAttr(aNamespaceID, aAttribute, + aNotify); NS_ENSURE_SUCCESS(rv, rv); if (aNamespaceID == kNameSpaceID_XLink && @@ -160,7 +177,7 @@ nsSVGMpathElement::UnsetAttr(int32_t aNamespaceID, // nsSVGElement methods nsSVGElement::StringAttributesInfo -nsSVGMpathElement::GetStringInfo() +SVGMPathElement::GetStringInfo() { return StringAttributesInfo(mStringAttributes, sStringInfo, ArrayLength(sStringInfo)); @@ -170,11 +187,11 @@ nsSVGMpathElement::GetStringInfo() // nsIMutationObserver methods void -nsSVGMpathElement::AttributeChanged(nsIDocument* aDocument, - Element* aElement, - int32_t aNameSpaceID, - nsIAtom* aAttribute, - int32_t aModType) +SVGMPathElement::AttributeChanged(nsIDocument* aDocument, + Element* aElement, + int32_t aNameSpaceID, + nsIAtom* aAttribute, + int32_t aModType) { if (aNameSpaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::d) { @@ -187,7 +204,7 @@ nsSVGMpathElement::AttributeChanged(nsIDocument* aDocument, // Public helper methods nsSVGPathElement* -nsSVGMpathElement::GetReferencedPath() +SVGMPathElement::GetReferencedPath() { if (!HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) { NS_ABORT_IF_FALSE(!mHrefTarget.get(), @@ -207,8 +224,8 @@ nsSVGMpathElement::GetReferencedPath() // Protected helper methods void -nsSVGMpathElement::UpdateHrefTarget(nsIContent* aParent, - const nsAString& aHrefStr) +SVGMPathElement::UpdateHrefTarget(nsIContent* aParent, + const nsAString& aHrefStr) { nsCOMPtr targetURI; nsCOMPtr baseURI = GetBaseURI(); @@ -240,7 +257,7 @@ nsSVGMpathElement::UpdateHrefTarget(nsIContent* aParent, } void -nsSVGMpathElement::UnlinkHrefTarget(bool aNotifyParent) +SVGMPathElement::UnlinkHrefTarget(bool aNotifyParent) { // Stop observing old target (if any) if (mHrefTarget.get()) { @@ -254,7 +271,7 @@ nsSVGMpathElement::UnlinkHrefTarget(bool aNotifyParent) } void -nsSVGMpathElement::NotifyParentOfMpathChange(nsIContent* aParent) +SVGMPathElement::NotifyParentOfMpathChange(nsIContent* aParent) { if (aParent && aParent->IsSVG(nsGkAtoms::animateMotion)) { @@ -265,3 +282,7 @@ nsSVGMpathElement::NotifyParentOfMpathChange(nsIContent* aParent) AnimationNeedsResample(); } } + +} // namespace dom +} // namespace mozilla + diff --git a/content/svg/content/src/nsSVGMpathElement.h b/content/svg/content/src/SVGMPathElement.h similarity index 70% rename from content/svg/content/src/nsSVGMpathElement.h rename to content/svg/content/src/SVGMPathElement.h index 736ebea2d705..b6b00c736ed9 100644 --- a/content/svg/content/src/nsSVGMpathElement.h +++ b/content/svg/content/src/SVGMPathElement.h @@ -3,8 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef NS_SVGMPATHELEMENT_H_ -#define NS_SVGMPATHELEMENT_H_ +#ifndef mozilla_dom_SVGMPathElement_h +#define mozilla_dom_SVGMPathElement_h #include "nsIDOMSVGMpathElement.h" #include "nsIDOMSVGURIReference.h" @@ -14,20 +14,26 @@ #include "nsSVGString.h" #include "nsReferencedElement.h" +nsresult NS_NewSVGMPathElement(nsIContent **aResult, + already_AddRefed aNodeInfo); -typedef nsSVGElement nsSVGMpathElementBase; +typedef nsSVGElement SVGMPathElementBase; -class nsSVGMpathElement : public nsSVGMpathElementBase, - public nsIDOMSVGMpathElement, - public nsIDOMSVGURIReference, - public nsStubMutationObserver +namespace mozilla { +namespace dom { + +class SVGMPathElement MOZ_FINAL : public SVGMPathElementBase, + public nsIDOMSVGMpathElement, + public nsIDOMSVGURIReference, + public nsStubMutationObserver { protected: - friend nsresult NS_NewSVGMpathElement(nsIContent **aResult, - already_AddRefed aNodeInfo); - nsSVGMpathElement(already_AddRefed aNodeInfo); - ~nsSVGMpathElement(); + friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult, + already_AddRefed aNodeInfo)); + SVGMPathElement(already_AddRefed aNodeInfo); + ~SVGMPathElement(); + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) MOZ_OVERRIDE; public: // interfaces: @@ -35,15 +41,15 @@ public: NS_DECL_NSIDOMSVGMPATHELEMENT NS_DECL_NSIDOMSVGURIREFERENCE - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSVGMpathElement, - nsSVGMpathElementBase) + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGMPathElement, + SVGMPathElementBase) NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED // Forward interface implementations to base class NS_FORWARD_NSIDOMNODE_TO_NSINODE NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - NS_FORWARD_NSIDOMSVGELEMENT(nsSVGMpathElementBase::) + NS_FORWARD_NSIDOMSVGELEMENT(SVGMPathElementBase::) // nsIContent interface virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; @@ -68,10 +74,14 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + + // WebIDL + already_AddRefed Href(); + protected: class PathReference : public nsReferencedElement { public: - PathReference(nsSVGMpathElement* aMpathElement) : + PathReference(SVGMPathElement* aMpathElement) : mMpathElement(aMpathElement) {} protected: // We need to be notified when target changes, in order to request a sample @@ -92,7 +102,7 @@ protected: // first time the target changes) virtual bool IsPersistent() { return true; } private: - nsSVGMpathElement* const mMpathElement; + SVGMPathElement* const mMpathElement; }; virtual StringAttributesInfo GetStringInfo(); @@ -107,4 +117,7 @@ protected: PathReference mHrefTarget; }; -#endif // NS_SVGMPATHELEMENT_H_ +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_SVGMPathElement_h diff --git a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp index 560e06a33c79..b7bdbd4c0996 100644 --- a/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp +++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.cpp @@ -11,11 +11,13 @@ #include "SVGMotionSMILPathUtils.h" #include "nsSVGPathDataParser.h" #include "nsSVGPathElement.h" // for nsSVGPathList -#include "nsSVGMpathElement.h" +#include "SVGMPathElement.h" #include "nsAttrValueInlines.h" namespace mozilla { +using namespace dom; + SVGMotionSMILAnimationFunction::SVGMotionSMILAnimationFunction() : mRotateType(eRotateType_Explicit), mRotateAngle(0.0f), @@ -124,14 +126,14 @@ SVGMotionSMILAnimationFunction::GetCalcMode() const * Returns the first child of the given element */ -static nsSVGMpathElement* +static SVGMPathElement* GetFirstMpathChild(nsIContent* aElem) { for (nsIContent* child = aElem->GetFirstChild(); child; child = child->GetNextSibling()) { if (child->IsSVG(nsGkAtoms::mpath)) { - return static_cast(child); + return static_cast(child); } } @@ -210,7 +212,7 @@ SVGMotionSMILAnimationFunction:: void SVGMotionSMILAnimationFunction:: - RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem) + RebuildPathAndVerticesFromMpathElem(SVGMPathElement* aMpathElem) { mPathSourceType = ePathSourceType_Mpath; @@ -270,7 +272,7 @@ SVGMotionSMILAnimationFunction:: // Do we have a mpath child? if so, it trumps everything. Otherwise, we look // through our list of path-defining attributes, in order of priority. - nsSVGMpathElement* firstMpathChild = + SVGMPathElement* firstMpathChild = GetFirstMpathChild(&mAnimationElement->AsElement()); if (firstMpathChild) { diff --git a/content/svg/content/src/SVGMotionSMILAnimationFunction.h b/content/svg/content/src/SVGMotionSMILAnimationFunction.h index ebfdbef0d0dd..82f24c5b0ffd 100644 --- a/content/svg/content/src/SVGMotionSMILAnimationFunction.h +++ b/content/svg/content/src/SVGMotionSMILAnimationFunction.h @@ -17,10 +17,13 @@ class nsIAtom; class nsIContent; class nsISMILAttr; class nsSMILValue; -class nsSVGMpathElement; namespace mozilla { +namespace dom { +class SVGMPathElement; +} + //---------------------------------------------------------------------- // SVGMotionSMILAnimationFunction // @@ -72,7 +75,7 @@ protected: // Helpers for GetValues void MarkStaleIfAttributeAffectsPath(nsIAtom* aAttribute); void RebuildPathAndVertices(const nsIContent* aContextElem); - void RebuildPathAndVerticesFromMpathElem(nsSVGMpathElement* aMpathElem); + void RebuildPathAndVerticesFromMpathElem(dom::SVGMPathElement* aMpathElem); void RebuildPathAndVerticesFromPathAttr(); void RebuildPathAndVerticesFromBasicAttrs(const nsIContent* aContextElem); bool GenerateValuesForPathAndPoints(gfxFlattenedPath* aPath, diff --git a/content/svg/content/src/nsSVGElementFactory.cpp b/content/svg/content/src/nsSVGElementFactory.cpp index 473729d15472..98d1072808b7 100644 --- a/content/svg/content/src/nsSVGElementFactory.cpp +++ b/content/svg/content/src/nsSVGElementFactory.cpp @@ -201,7 +201,7 @@ nsresult NS_NewSVGAnimateMotionElement(nsIContent **aResult, already_AddRefed aNodeInfo); nsresult -NS_NewSVGMpathElement(nsIContent **aResult, +NS_NewSVGMPathElement(nsIContent **aResult, already_AddRefed aNodeInfo); nsresult NS_NewSVGSetElement(nsIContent **aResult, @@ -348,7 +348,7 @@ NS_NewSVGElement(nsIContent** aResult, already_AddRefed aNodeInfo, if (name == nsGkAtoms::animateMotion) return NS_NewSVGAnimateMotionElement(aResult, aNodeInfo); if (name == nsGkAtoms::mpath) - return NS_NewSVGMpathElement(aResult, aNodeInfo); + return NS_NewSVGMPathElement(aResult, aNodeInfo); if (name == nsGkAtoms::set) return NS_NewSVGSetElement(aResult, aNodeInfo); } diff --git a/dom/webidl/SVGMPathElement.webidl b/dom/webidl/SVGMPathElement.webidl new file mode 100644 index 000000000000..7165b6cf7459 --- /dev/null +++ b/dom/webidl/SVGMPathElement.webidl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGMPathElement : SVGElement { +}; + +SVGMPathElement implements SVGURIReference; + diff --git a/dom/webidl/SVGURIReference.webidl b/dom/webidl/SVGURIReference.webidl new file mode 100644 index 000000000000..29426b3acb96 --- /dev/null +++ b/dom/webidl/SVGURIReference.webidl @@ -0,0 +1,19 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/SVG2/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +interface SVGAnimatedString; + +[NoInterfaceObject] +interface SVGURIReference { + readonly attribute SVGAnimatedString href; +}; + diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index a21f2f079a46..6148d120130b 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -101,6 +101,7 @@ webidl_files = \ SVGLengthList.webidl \ SVGMatrix.webidl \ SVGMetadataElement.webidl \ + SVGMPathElement.webidl \ SVGNumberList.webidl \ SVGPathSeg.webidl \ SVGPathSegList.webidl \ @@ -112,6 +113,7 @@ webidl_files = \ SVGTitleElement.webidl \ SVGTransform.webidl \ SVGTransformList.webidl \ + SVGURIReference.webidl \ Text.webidl \ TextDecoder.webidl \ TextEncoder.webidl \ From 0136604f200fbc7d0d04c23959497377a02b98d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kan-Ru=20Chen=20=28=E9=99=B3=E4=BE=83=E5=A6=82=29?= Date: Sat, 5 Jan 2013 11:20:50 +0800 Subject: [PATCH 115/180] Bug 826628 - Release the texture after unbind it. r=jgilbert --- gfx/layers/opengl/ImageLayerOGL.cpp | 37 ++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/gfx/layers/opengl/ImageLayerOGL.cpp b/gfx/layers/opengl/ImageLayerOGL.cpp index b1eb80ae24fe..2acf4e5fff27 100644 --- a/gfx/layers/opengl/ImageLayerOGL.cpp +++ b/gfx/layers/opengl/ImageLayerOGL.cpp @@ -971,8 +971,8 @@ ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer, ImageContainerParent::SetCompositorIDForImage(mImageContainerID, mOGLManager->GetCompositorID()); uint32_t imgVersion = ImageContainerParent::GetSharedImageVersion(mImageContainerID); + SharedImage* img = ImageContainerParent::GetSharedImage(mImageContainerID); if (imgVersion != mImageVersion) { - SharedImage* img = ImageContainerParent::GetSharedImage(mImageContainerID); if (img && (img->type() == SharedImage::TYUVImage)) { UploadSharedYUVToTexture(img->get_YUVImage()); @@ -988,23 +988,24 @@ ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer, img->get_RGBImage().picture(), img->get_RGBImage().rgbFormat()); mImageVersion = imgVersion; -#ifdef MOZ_WIDGET_GONK - } else if (img - && (img->type() == SharedImage::TSurfaceDescriptor) - && (img->get_SurfaceDescriptor().type() == SurfaceDescriptor::TSurfaceDescriptorGralloc)) { - const SurfaceDescriptorGralloc& desc = img->get_SurfaceDescriptor().get_SurfaceDescriptorGralloc(); - sp graphicBuffer = GrallocBufferActor::GetFrom(desc); - mSize = gfxIntSize(graphicBuffer->getWidth(), graphicBuffer->getHeight()); - if (!mExternalBufferTexture.IsAllocated()) { - mExternalBufferTexture.Allocate(gl()); - } - gl()->MakeCurrent(); - gl()->fActiveTexture(LOCAL_GL_TEXTURE0); - gl()->BindExternalBuffer(mExternalBufferTexture.GetTextureID(), graphicBuffer->getNativeBuffer()); - mImageVersion = imgVersion; -#endif } } +#ifdef MOZ_WIDGET_GONK + if (img + && (img->type() == SharedImage::TSurfaceDescriptor) + && (img->get_SurfaceDescriptor().type() == SurfaceDescriptor::TSurfaceDescriptorGralloc)) { + const SurfaceDescriptorGralloc& desc = img->get_SurfaceDescriptor().get_SurfaceDescriptorGralloc(); + sp graphicBuffer = GrallocBufferActor::GetFrom(desc); + mSize = gfxIntSize(graphicBuffer->getWidth(), graphicBuffer->getHeight()); + if (!mExternalBufferTexture.IsAllocated()) { + mExternalBufferTexture.Allocate(gl()); + } + gl()->MakeCurrent(); + gl()->fActiveTexture(LOCAL_GL_TEXTURE0); + gl()->BindExternalBuffer(mExternalBufferTexture.GetTextureID(), graphicBuffer->getNativeBuffer()); + mImageVersion = imgVersion; + } +#endif } @@ -1069,7 +1070,11 @@ ShadowImageLayerOGL::RenderLayer(int aPreviousFrameBuffer, program->LoadMask(GetMaskLayer()); mOGLManager->BindAndDrawQuad(program); + + // Make sure that we release the underlying external image + gl()->fActiveTexture(LOCAL_GL_TEXTURE0); gl()->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, 0); + mExternalBufferTexture.Release(); #endif } else if (mSharedHandle) { GLContext::SharedHandleDetails handleDetails; From abea18c939b8d72d076c968469861e25d02fcd9a Mon Sep 17 00:00:00 2001 From: Oleg Romashin Date: Fri, 4 Jan 2013 19:24:15 -0800 Subject: [PATCH 116/180] Bug 825556 - RequestContentRepaint frequency should be possible to limit with some timeout. r=drs --- gfx/layers/ipc/AsyncPanZoomController.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 80551630499c..42b8e7ad17ed 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -92,6 +92,7 @@ AsyncPanZoomController::AsyncPanZoomController(GeckoContentController* aGeckoCon mMonitor("AsyncPanZoomController"), mLastSampleTime(TimeStamp::Now()), mState(NOTHING), + mPreviousPaintStartTime(TimeStamp::Now()), mLastAsyncScrollTime(TimeStamp::Now()), mLastAsyncScrollOffset(0, 0), mCurrentAsyncScrollOffset(0, 0), @@ -674,7 +675,10 @@ void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) { ScrollBy(gfx::Point(xDisplacement, yDisplacement)); ScheduleComposite(); - RequestContentRepaint(); + TimeDuration timePaintDelta = TimeStamp::Now() - mPreviousPaintStartTime; + if (timePaintDelta.ToMilliseconds() > PAN_REPAINT_INTERVAL) { + RequestContentRepaint(); + } } } @@ -708,7 +712,10 @@ bool AsyncPanZoomController::DoFling(const TimeDuration& aDelta) { mX.GetDisplacementForDuration(inverseResolution, aDelta), mY.GetDisplacementForDuration(inverseResolution, aDelta) )); - RequestContentRepaint(); + TimeDuration timePaintDelta = TimeStamp::Now() - mPreviousPaintStartTime; + if (timePaintDelta.ToMilliseconds() > FLING_REPAINT_INTERVAL) { + RequestContentRepaint(); + } return true; } From 0bda13504b26eea590b79fd6a3eb0350d26a2132 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:24 +1300 Subject: [PATCH 117/180] Bug 826632. Part 1: Merge nsIViewManager into nsViewManager. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : 85587555e1f202809cd39fe899570644e6ca4eb3 --- accessible/src/generic/DocAccessible.cpp | 4 +- accessible/src/mac/RootAccessibleWrap.mm | 2 +- accessible/src/msaa/AccessibleWrap.cpp | 4 +- accessible/src/msaa/DocAccessibleWrap.cpp | 2 +- content/base/public/nsIDocument.h | 4 +- content/base/src/Element.cpp | 2 +- content/base/src/FragmentOrElement.cpp | 2 +- content/base/src/nsContentSink.cpp | 6 +- content/base/src/nsContentSink.h | 2 +- content/base/src/nsContentUtils.cpp | 6 +- content/base/src/nsDocument.cpp | 4 +- content/base/src/nsDocument.h | 4 +- content/base/src/nsINode.cpp | 2 +- content/events/src/nsEventListenerManager.cpp | 2 +- content/events/src/nsIMEStateManager.cpp | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 2 +- content/html/document/src/MediaDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.h | 2 +- content/xml/document/src/nsXMLContentSink.h | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- .../xul/content/src/nsXULPopupListener.cpp | 2 +- content/xul/document/src/nsXULContentSink.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 2 +- docshell/base/nsDocShell.cpp | 14 +- dom/base/nsDOMWindowUtils.cpp | 4 +- dom/base/nsFocusManager.cpp | 12 +- dom/base/nsGlobalWindow.cpp | 4 +- dom/ipc/TabParent.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +- .../webBrowser/nsDocShellTreeOwner.cpp | 4 +- extensions/widgetutils/src/nsWidgetUtils.cpp | 4 +- layout/base/nsCSSFrameConstructor.cpp | 4 +- layout/base/nsCSSRendering.cpp | 2 +- layout/base/nsCSSRenderingBorders.cpp | 2 +- layout/base/nsDisplayList.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 16 +- layout/base/nsIDocumentViewerPrint.h | 6 +- layout/base/nsIPresShell.h | 8 +- layout/base/nsPresContext.cpp | 4 +- layout/base/nsPresShell.cpp | 16 +- layout/base/nsPresShell.h | 2 +- layout/base/nsRefreshDriver.cpp | 4 +- layout/forms/nsComboboxControlFrame.cpp | 6 +- layout/forms/nsListControlFrame.cpp | 2 +- layout/forms/nsTextControlFrame.cpp | 2 +- layout/generic/nsContainerFrame.cpp | 16 +- layout/generic/nsFrame.cpp | 4 +- layout/generic/nsFrameSetFrame.cpp | 2 +- layout/generic/nsGfxScrollFrame.cpp | 2 +- layout/generic/nsObjectFrame.cpp | 10 +- layout/generic/nsSubDocumentFrame.cpp | 8 +- layout/printing/nsPrintEngine.cpp | 4 +- layout/printing/nsPrintObject.h | 4 +- .../src/nsLayoutDebuggingTools.cpp | 8 +- .../layout-debug/src/nsRegressionTester.cpp | 2 +- layout/xul/base/src/nsBoxFrame.cpp | 2 +- layout/xul/base/src/nsDeckFrame.cpp | 2 +- layout/xul/base/src/nsLeafBoxFrame.cpp | 2 +- layout/xul/base/src/nsListBoxBodyFrame.cpp | 2 +- layout/xul/base/src/nsMenuPopupFrame.cpp | 10 +- layout/xul/base/src/nsMenuPopupFrame.h | 2 +- layout/xul/base/src/nsXULPopupManager.cpp | 6 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 2 +- view/public/Makefile.in | 2 +- view/public/nsView.h | 15 +- .../{nsIViewManager.h => nsViewManager.h} | 218 +++++++++++++++--- view/src/nsView.cpp | 2 +- view/src/nsViewManager.cpp | 14 +- view/src/nsViewManager.h | 214 ----------------- widget/android/nsWindow.cpp | 2 +- widget/cocoa/nsChildView.mm | 2 +- widget/gtk2/nsDragService.cpp | 4 +- widget/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/tests/TestWinTSF.cpp | 4 +- widget/xpwidgets/nsBaseDragService.cpp | 2 +- 76 files changed, 345 insertions(+), 418 deletions(-) rename view/public/{nsIViewManager.h => nsViewManager.h} (60%) delete mode 100644 view/src/nsViewManager.h diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 4163a9ed83fa..b579a96d2c02 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -35,7 +35,7 @@ #include "nsINameSpaceManager.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsUnicharUtils.h" #include "nsIURI.h" @@ -1253,7 +1253,7 @@ DocAccessible::GetNativeWindow() const if (!mPresShell) return nullptr; - nsIViewManager* vm = mPresShell->GetViewManager(); + nsViewManager* vm = mPresShell->GetViewManager(); if (!vm) return nullptr; diff --git a/accessible/src/mac/RootAccessibleWrap.mm b/accessible/src/mac/RootAccessibleWrap.mm index 6e332c935850..729087d03468 100644 --- a/accessible/src/mac/RootAccessibleWrap.mm +++ b/accessible/src/mac/RootAccessibleWrap.mm @@ -10,7 +10,7 @@ #include "nsCOMPtr.h" #include "nsObjCExceptions.h" #include "nsIWidget.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" using namespace mozilla::a11y; diff --git a/accessible/src/msaa/AccessibleWrap.cpp b/accessible/src/msaa/AccessibleWrap.cpp index 4f0704b5ff62..ec20bad885d4 100644 --- a/accessible/src/msaa/AccessibleWrap.cpp +++ b/accessible/src/msaa/AccessibleWrap.cpp @@ -34,7 +34,7 @@ #include "nsIServiceManager.h" #include "nsTextFormatter.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventMap.h" #include "nsArrayUtils.h" #include "mozilla/Preferences.h" @@ -1653,7 +1653,7 @@ AccessibleWrap::GetHWNDFor(Accessible* aAccessible) nsIWidget* widget = frame->GetNearestWidget(); if (widget && widget->IsVisible()) { nsIPresShell* shell = document->PresShell(); - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (vm) { nsCOMPtr rootWidget; vm->GetRootWidget(getter_AddRefs(rootWidget)); diff --git a/accessible/src/msaa/DocAccessibleWrap.cpp b/accessible/src/msaa/DocAccessibleWrap.cpp index 8fd23d488887..876958f24dff 100644 --- a/accessible/src/msaa/DocAccessibleWrap.cpp +++ b/accessible/src/msaa/DocAccessibleWrap.cpp @@ -21,7 +21,7 @@ #include "nsISelectionController.h" #include "nsIServiceManager.h" #include "nsIURI.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWebNavigation.h" using namespace mozilla; diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 12544516354b..a8c45d36846e 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -65,7 +65,7 @@ class nsIStyleRule; class nsIStyleSheet; class nsIURI; class nsIVariant; -class nsIViewManager; +class nsViewManager; class nsPresContext; class nsRange; class nsScriptLoader; @@ -478,7 +478,7 @@ public: * presshell if the presshell should observe document mutations. */ virtual nsresult CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) = 0; virtual void DeleteShell() = 0; diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index bc5538b3a1fb..0f6a7a1e4f9e 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -94,7 +94,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsXBLInsertionPoint.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index e43cd5301611..fb51d78dde75 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -93,7 +93,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsXBLInsertionPoint.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index a2bdec6a9cac..81bec6f4af40 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -25,7 +25,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsPresContext.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIAtom.h" #include "nsGkAtoms.h" #include "nsIDOMWindow.h" @@ -1371,7 +1371,7 @@ nsContentSink::DidProcessATokenImpl() // Check if there's a pending event if (sPendingEventMode != 0 && !mHasPendingEvent && (mDeflectedCount % sEventProbeRate) == 0) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1518,7 +1518,7 @@ nsContentSink::WillParseImpl(void) uint32_t currentTime = PR_IntervalToMicroseconds(PR_IntervalNow()); if (sEnablePerfMode == 0) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); uint32_t lastEventTime; vm->GetLastUserEventTime(lastEventTime); diff --git a/content/base/src/nsContentSink.h b/content/base/src/nsContentSink.h index 4cb8bbce8480..9537c801ab7c 100644 --- a/content/base/src/nsContentSink.h +++ b/content/base/src/nsContentSink.h @@ -34,7 +34,7 @@ class nsIParser; class nsIAtom; class nsIChannel; class nsIContent; -class nsIViewManager; +class nsViewManager; class nsNodeInfoManager; class nsScriptLoader; class nsIApplicationCache; diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index d2b910cea9e1..dd70005135a9 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -115,7 +115,7 @@ #include "nsTextEditorState.h" #include "nsIPluginHost.h" #include "nsICategoryManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventStateManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsParserConstants.h" @@ -6435,11 +6435,11 @@ nsContentUtils::WidgetForDocument(nsIDocument* aDoc) { nsIPresShell* shell = FindPresShellForDocument(aDoc); if (shell) { - nsIViewManager* VM = shell->GetViewManager(); + nsViewManager* VM = shell->GetViewManager(); if (VM) { nsView* rootView = VM->GetRootView(); if (rootView) { - nsView* displayRoot = nsIViewManager::GetDisplayRootFor(rootView); + nsView* displayRoot = nsViewManager::GetDisplayRootFor(rootView); if (displayRoot) { return displayRoot->GetNearestWidget(nullptr); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index fb018d1a03da..3cf1e8bd782f 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3119,7 +3119,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel, } nsresult -nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager, +nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { @@ -3132,7 +3132,7 @@ nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager, nsresult nsDocument::doCreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, nsStyleSet* aStyleSet, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult) { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index adbd2a66bd11..9da0d22572f2 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -568,7 +568,7 @@ public: * shared among multiple presentation shell's). */ virtual nsresult CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); virtual void DeleteShell(); @@ -1076,7 +1076,7 @@ public: protected: nsresult doCreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, nsStyleSet* aStyleSet, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult); diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 90eb565a7e4d..6ae96a8cfaed 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -74,7 +74,7 @@ #include "nsIServiceManager.h" #include "nsIURL.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWebNavigation.h" #include "nsIWidget.h" #include "nsLayoutStatics.h" diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 23c0174a27f8..e235fe40626d 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -27,7 +27,7 @@ #include "mozilla/dom/Element.h" #include "nsIFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsCOMPtr.h" #include "nsIServiceManager.h" #include "nsIScriptSecurityManager.h" diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 75aa6b148fd0..216d1dea558e 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -6,7 +6,7 @@ #include "nsIMEStateManager.h" #include "nsCOMPtr.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIPresShell.h" #include "nsISupports.h" #include "nsPIDOMWindow.h" diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 559d8aea071a..d52947b19d9d 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -38,7 +38,7 @@ #include "nsIFrame.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsRange.h" #include "nsIPresShell.h" diff --git a/content/html/document/src/MediaDocument.cpp b/content/html/document/src/MediaDocument.cpp index 0f86c50208f7..7576db42357b 100644 --- a/content/html/document/src/MediaDocument.cpp +++ b/content/html/document/src/MediaDocument.cpp @@ -9,7 +9,7 @@ #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsIScrollable.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsITextToSubURI.h" #include "nsIURL.h" #include "nsIContentViewer.h" diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index a15ddf6b8c01..7f2b5bdaa3ca 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -305,7 +305,7 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, nsresult nsHTMLDocument::CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 2ceecf8c5c95..a7124471a44e 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -55,7 +55,7 @@ public: nsIPrincipal* aPrincipal); virtual nsresult CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index a7c31295dbcb..140fb66be030 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -22,7 +22,7 @@ class nsIURI; class nsIContent; class nsINodeInfo; class nsIParser; -class nsIViewManager; +class nsViewManager; typedef enum { eXMLContentSinkState_InProlog, diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 0afe23e0538f..c87be6820afd 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -54,7 +54,7 @@ #include "mozilla/css/StyleRule.h" #include "nsIStyleSheet.h" #include "nsIURL.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsIXULDocument.h" #include "nsIXULTemplateBuilder.h" diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 26577548f2cd..4382be6ddae7 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -40,7 +40,7 @@ #include "nsIPresShell.h" #include "nsFocusManager.h" #include "nsPIDOMWindow.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsError.h" #include "nsMenuFrame.h" diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index 3068587e3970..54eb53f8a48f 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -30,7 +30,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIXULDocument.h" #include "nsIScriptSecurityManager.h" #include "nsLayoutCID.h" diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index ddebfd771566..583b8adebabe 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -30,7 +30,7 @@ #include "nsIBoxObject.h" #include "nsIChromeRegistry.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIContentViewer.h" #include "nsGUIEvent.h" #include "nsIDOMXULElement.h" diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c5a5b46bbad0..acde564214c6 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -66,7 +66,7 @@ #include "nsDOMJSUtils.h" #include "nsIInterfaceRequestorUtils.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScriptChannel.h" #include "nsIOfflineCacheUpdate.h" #include "nsITimedChannel.h" @@ -3249,7 +3249,7 @@ PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel) nsCOMPtr domwin(doc->GetWindow()); nsCOMPtr widget; - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { vm->GetWidget(getter_AddRefs(widget)); } @@ -5048,7 +5048,7 @@ nsDocShell::Repaint(bool aForce) nsCOMPtr presShell =GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsIViewManager* viewManager = presShell->GetViewManager(); + nsViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE); @@ -5115,7 +5115,7 @@ nsDocShell::GetVisibility(bool * aVisibility) return NS_OK; // get the view manager - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); // get the root view @@ -7388,7 +7388,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr oldPresShell = GetPresShell(); if (oldPresShell) { - nsIViewManager *vm = oldPresShell->GetViewManager(); + nsViewManager *vm = oldPresShell->GetViewManager(); if (vm) { nsView *oldRootView = vm->GetRootView(); @@ -7609,7 +7609,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr shell = GetPresShell(); - nsIViewManager *newVM = shell ? shell->GetViewManager() : nullptr; + nsViewManager *newVM = shell ? shell->GetViewManager() : nullptr; nsView *newRootView = newVM ? newVM->GetRootView() : nullptr; // Insert the new root view at the correct location in the view tree. @@ -7625,7 +7625,7 @@ nsDocShell::RestoreFromHistory() rootViewSibling = nullptr; } if (rootViewParent && newRootView && newRootView->GetParent() != rootViewParent) { - nsIViewManager *parentVM = rootViewParent->GetViewManager(); + nsViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { // InsertChild(parent, child, sib, true) inserts the child after // sib in content order, which is before sib in view order. BUT diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 77a94372207b..17501cdc436d 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -33,7 +33,7 @@ #include "nsJSEnvironment.h" #include "nsJSUtils.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMHTMLCanvasElement.h" #include "gfxContext.h" @@ -661,7 +661,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, nsCOMPtr presShell = presContext->PresShell(); if (!presShell) return NS_ERROR_FAILURE; - nsIViewManager* viewManager = presShell->GetViewManager(); + nsViewManager* viewManager = presShell->GetViewManager(); if (!viewManager) return NS_ERROR_FAILURE; nsView* view = viewManager->GetRootView(); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index f382d73e67fa..54bca81fa689 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -39,7 +39,7 @@ #include "nsIWebNavigation.h" #include "nsCaret.h" #include "nsIBaseWindow.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsFrameSelection.h" #include "mozilla/Selection.h" #include "nsXULPopupManager.h" @@ -1055,7 +1055,7 @@ nsFocusManager::EnsureCurrentWidgetFocused() if (docShell) { nsCOMPtr presShell = docShell->GetPresShell(); if (presShell) { - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1552,7 +1552,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, if (aAdjustWidgets && objectFrame && !sTestMode) { // note that the presshell's widget is being retrieved here, not the one // for the object frame. - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1726,7 +1726,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, objectFrameWidget = objectFrame->GetWidget(); } if (aAdjustWidgets && !objectFrameWidget && !sTestMode) { - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1812,7 +1812,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, if (aAdjustWidgets && objectFrameWidget && mFocusedWindow == aWindow && mFocusedContent == nullptr && !sTestMode) { - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1974,7 +1974,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow) if (!presShell) return; - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 48f071dad082..011c79740d45 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -118,7 +118,7 @@ #include "nsIScriptSecurityManager.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsISelectionController.h" #include "nsISelection.h" #include "nsIPrompt.h" @@ -11024,7 +11024,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor) nsCOMPtr presShell = mDocShell->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsView* rootView = vm->GetRootView(); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 70a607aa7081..a64e07c96362 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -41,7 +41,7 @@ #include "nsIURI.h" #include "nsIMozBrowserFrame.h" #include "nsIScriptSecurityManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsIWindowWatcher.h" #include "nsNetUtil.h" @@ -883,7 +883,7 @@ TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue) if (content) { nsIPresShell* shell = content->OwnerDoc()->GetShell(); if (shell) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index ac7ad95dbe2a..1f85478b3b57 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -45,7 +45,7 @@ using mozilla::DefaultXDisplay; #include "nsIWebBrowserChrome.h" #include "nsLayoutUtils.h" #include "nsIPluginWidget.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDocShellTreeOwner.h" #include "nsIDOMHTMLObjectElement.h" #include "nsIAppShell.h" @@ -693,7 +693,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #if defined(XP_WIN) || defined(XP_OS2) void** pvalue = (void**)value; - nsIViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager(); + nsViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager(); if (!vm) return NS_ERROR_FAILURE; #if defined(XP_WIN) diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 68985c3cb8d3..b11429c539a6 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -61,7 +61,7 @@ #include "imgIContainer.h" #include "nsContextMenuInfo.h" #include "nsPresContext.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsEventListenerManager.h" #include "nsIDOMDragEvent.h" @@ -1443,7 +1443,7 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, nsIWidget* widget = nullptr; if (shell) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (vm) { nsView* view = vm->GetRootView(); if (view) { diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index 9810e14b0a81..1c17043fa445 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -36,7 +36,7 @@ #include "nsIDOMWheelEvent.h" #include "nsView.h" #include "nsGUIEvent.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIContentPolicy.h" #include "nsIDocShellTreeItem.h" #include "nsIContent.h" @@ -89,7 +89,7 @@ private: static void StopPanningCallback(nsITimer *timer, void *closure); nsCOMPtr mWidget; - nsCOMPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mTimer; }; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 9357e37fd7c7..49cd2832186e 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -36,7 +36,7 @@ #include "nsIPresShell.h" #include "nsUnicharUtils.h" #include "nsStyleSet.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventStates.h" #include "nsStyleConsts.h" #include "nsTableOuterFrame.h" @@ -12015,7 +12015,7 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) return; // Make sure that the viewmanager will outlive the presshell - nsCOMPtr vm = mPresShell->GetViewManager(); + nsCOMPtr vm = mPresShell->GetViewManager(); // Processing the style changes could cause a flush that propagates to // the parent frame and thus destroys the pres shell. diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 98d67dd741d4..f8162d78d477 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -19,7 +19,7 @@ #include "nsIFrame.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIPresShell.h" #include "nsFrameManager.h" #include "nsStyleContext.h" diff --git a/layout/base/nsCSSRenderingBorders.cpp b/layout/base/nsCSSRenderingBorders.cpp index a28b2a7dc2b1..07fe86babf11 100644 --- a/layout/base/nsCSSRenderingBorders.cpp +++ b/layout/base/nsCSSRenderingBorders.cpp @@ -7,7 +7,7 @@ #include "nsStyleConsts.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsFrameManager.h" #include "nsStyleContext.h" #include "nsGkAtoms.h" diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index d17034b2bd08..8111f8c6a57a 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -46,7 +46,7 @@ #include "sampler.h" #include "nsAnimationManager.h" #include "nsTransitionManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "ImageLayers.h" #include "ImageContainer.h" #include "nsCanvasFrame.h" diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 870cfc3fd1ee..8d434d5bfc74 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -42,7 +42,7 @@ #include "nsViewsCID.h" #include "nsIDeviceContextSpec.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsIPageSequenceFrame.h" @@ -379,7 +379,7 @@ protected: // These return the current shell/prescontext etc. nsIPresShell* GetPresShell(); nsPresContext* GetPresContext(); - nsIViewManager* GetViewManager(); + nsViewManager* GetViewManager(); void DetachFromTopLevelWidget(); @@ -397,7 +397,7 @@ protected: // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsCOMPtr mViewManager; + nsCOMPtr mViewManager; nsRefPtr mPresContext; nsCOMPtr mPresShell; @@ -1399,7 +1399,7 @@ nsDocumentViewer::Open(nsISupports *aState, nsISHEntry *aSHEntry) // If the old view is already attached to our parent, detach DetachFromTopLevelWidget(); - nsIViewManager *vm = GetViewManager(); + nsViewManager *vm = GetViewManager(); NS_ABORT_IF_FALSE(vm, "no view manager"); nsView* v = vm->GetRootView(); NS_ABORT_IF_FALSE(v, "no root view"); @@ -1546,7 +1546,7 @@ nsDocumentViewer::Destroy() // Remove our root view from the view hierarchy. if (mPresShell) { - nsIViewManager *vm = mPresShell->GetViewManager(); + nsViewManager *vm = mPresShell->GetViewManager(); if (vm) { nsView *rootView = vm->GetRootView(); @@ -1559,7 +1559,7 @@ nsDocumentViewer::Destroy() nsView *rootViewParent = rootView->GetParent(); if (rootViewParent) { - nsIViewManager *parentVM = rootViewParent->GetViewManager(); + nsViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { parentVM->RemoveChild(rootView); } @@ -1806,7 +1806,7 @@ nsDocumentViewer::GetPresContext() return mPresContext; } -nsIViewManager* +nsViewManager* nsDocumentViewer::GetViewManager() { return mViewManager; @@ -4388,7 +4388,7 @@ nsDocumentViewer::InitializeForPrintPreview() } void -nsDocumentViewer::SetPrintPreviewPresentation(nsIViewManager* aViewManager, +nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) { diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index 083afc1219a1..e99d39198339 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -12,7 +12,7 @@ class nsStyleSet; class nsIPresShell; class nsPresContext; class nsIWidget; -class nsIViewManager; +class nsViewManager; // {c6f255cf-cadd-4382-b57f-cd2a9874169b} #define NS_IDOCUMENT_VIEWER_PRINT_IID \ @@ -58,7 +58,7 @@ public: /** * Replaces the current presentation with print preview presentation. */ - virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, + virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) = 0; }; @@ -78,7 +78,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, virtual void OnDonePrinting(); \ virtual bool IsInitializedForPrintPreview(); \ virtual void InitializeForPrintPreview(); \ - virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, \ + virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, \ nsPresContext* aPresContext, \ nsIPresShell* aPresShell); diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 39aa465b9b91..afc91f51df71 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -44,7 +44,7 @@ class nsIDocument; class nsIFrame; class nsPresContext; class nsStyleSet; -class nsIViewManager; +class nsViewManager; class nsView; class nsRenderingContext; class nsIPageSequenceFrame; @@ -176,7 +176,7 @@ protected: public: virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) = 0; @@ -272,7 +272,7 @@ public: nsPresContext* GetPresContext() const { return mPresContext; } - nsIViewManager* GetViewManager() const { return mViewManager; } + nsViewManager* GetViewManager() const { return mViewManager; } #ifdef ACCESSIBILITY /** @@ -1381,7 +1381,7 @@ protected: nsPresContext* mPresContext; // [STRONG] nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] - nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to + nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to nsPresArena mFrameArena; nsFrameSelection* mSelection; // Pointer into mFrameConstructor - this is purely so that FrameManager() and diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 00c6e59fa601..10350a5bf5f2 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -43,7 +43,7 @@ #include "nsThreadUtils.h" #include "nsFrameManager.h" #include "nsLayoutUtils.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsCSSFrameConstructor.h" #include "nsCSSRuleProcessor.h" #include "nsStyleChangeList.h" @@ -826,7 +826,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) // Re-fetch the view manager's window dimensions in case there's a deferred // resize which hasn't affected our mVisibleArea yet nscoord oldWidthAppUnits, oldHeightAppUnits; - nsIViewManager* vm = mShell->GetViewManager(); + nsViewManager* vm = mShell->GetViewManager(); vm->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits); float oldWidthDevPixels = oldWidthAppUnits/oldAppUnitsPerDevPixel; float oldHeightDevPixels = oldHeightAppUnits/oldAppUnitsPerDevPixel; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 0e19a038b38e..fd3ab466f9f4 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -788,7 +788,7 @@ PresShell::~PresShell() nsresult PresShell::Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) { @@ -1857,7 +1857,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_ERROR_NOT_AVAILABLE; } - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first nsCOMPtr kungFuDeathGrip(this); @@ -1897,7 +1897,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) // Kick off a top-down reflow AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager); + nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); mDirtyRoots.RemoveElement(rootFrame); DoReflow(rootFrame, true); @@ -3735,7 +3735,7 @@ PresShell::IsSafeToFlush() const if (isSafeToFlush) { // Not safe if we are painting - nsIViewManager* viewManager = GetViewManager(); + nsViewManager* viewManager = GetViewManager(); if (viewManager) { bool isPainting = false; viewManager->IsPainting(isPainting); @@ -3808,7 +3808,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; if (isSafeToFlush && mViewManager) { // Processing pending notifications can kill us, and some callers only // hold weak refs when calling FlushPendingNotifications(). :( @@ -5186,7 +5186,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) // We always dispatch the event to the pres shell that contains the view that // the mouse is over. pointVM is the VM of that pres shell. - nsIViewManager *pointVM = nullptr; + nsViewManager *pointVM = nullptr; // This could be a bit slow (traverses entire view hierarchy) // but it's OK to do it once per synthetic mouse event @@ -7652,7 +7652,7 @@ PresShell::ProcessReflowCommands(bool aInterruptible) nsAutoScriptBlocker scriptBlocker; WillDoReflow(); AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager); + nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); do { // Send an incremental reflow notification to the target frame. @@ -8270,7 +8270,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsCOMPtr vm = do_CreateInstance(kViewManagerCID); + nsCOMPtr vm = do_CreateInstance(kViewManagerCID); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index 89ae708e5a2f..bde4b2f3e9a8 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -70,7 +70,7 @@ public: // nsIPresShell virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode); virtual NS_HIDDEN_(void) Destroy(); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 2b3993a3a752..00af04528c54 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -39,7 +39,7 @@ #include "jsapi.h" #include "nsContentUtils.h" #include "mozilla/Preferences.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "sampler.h" #include "nsNPAPIPluginInstance.h" @@ -951,7 +951,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); + nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef DEBUG_INVALIDATIONS printf("Ending ProcessPendingUpdates\n"); diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 7231f4d72633..bae444b06e8c 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -24,7 +24,7 @@ #include "nsIPresShell.h" #include "nsContentList.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventDispatcher.h" #include "nsEventListenerManager.h" #include "nsIDOMNode.h" @@ -356,7 +356,7 @@ void nsComboboxControlFrame::ShowPopup(bool aShowPopup) { nsView* view = mDropdownFrame->GetView(); - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); if (aShowPopup) { nsRect rect = mDropdownFrame->GetRect(); @@ -510,7 +510,7 @@ nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext, // ensure we start off hidden if (GetStateBits() & NS_FRAME_FIRST_REFLOW) { nsView* view = mDropdownFrame->GetView(); - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); viewManager->SetViewVisibility(view, nsViewVisibility_kHide); nsRect emptyRect(0, 0, 0, 0); viewManager->ResizeView(view, emptyRect); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 7574138c8c1b..120ac259c914 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -17,7 +17,7 @@ #include "nsIDOMHTMLSelectElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsComboboxControlFrame.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsWidgetsCID.h" #include "nsIPresShell.h" diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 8a9497a06f8f..94ccfc181392 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -39,7 +39,7 @@ #include "nsLayoutUtils.h" #include "nsIComponentManager.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLElement.h" diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index b6e27140d8ef..623de06d899e 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -22,7 +22,7 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" #include "nsCSSAnonBoxes.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" @@ -373,7 +373,7 @@ nsContainerFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset, static nsresult ReparentFrameViewTo(nsIFrame* aFrame, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsView* aNewParentView, nsView* aOldParentView) { @@ -432,7 +432,7 @@ nsContainerFrame::CreateViewForFrame(nsIFrame* aFrame, nsView* parentView = aFrame->GetParent()->GetClosestView(); NS_ASSERTION(parentView, "no parent with view"); - nsIViewManager* viewManager = parentView->GetViewManager(); + nsViewManager* viewManager = parentView->GetViewManager(); NS_ASSERTION(viewManager, "null view manager"); // Create a view @@ -480,7 +480,7 @@ nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame) return; nsView* view = aKidFrame->GetView(); - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); nsPoint pt; nsView* ancestorView = parentFrame->GetClosestView(&pt); @@ -607,7 +607,7 @@ nsContainerFrame::ReparentFrameViewList(nsPresContext* aPresContext, // same view sub-hierarchy. If they are then we don't have to do // anything if (oldParentView != newParentView) { - nsIViewManager* viewManager = oldParentView->GetViewManager(); + nsViewManager* viewManager = oldParentView->GetViewManager(); // They're not so we need to reparent any child views for (nsFrameList::Enumerator e(aChildFrameList); !e.AtEnd(); e.Next()) { @@ -656,7 +656,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, if (!windowWidget || !IsTopLevelWidget(windowWidget)) return; - nsIViewManager* vm = aView->GetViewManager(); + nsViewManager* vm = aView->GetViewManager(); nsView* rootView = vm->GetRootView(); if (aView != rootView) @@ -748,7 +748,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext, } if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { - nsIViewManager* vm = aView->GetViewManager(); + nsViewManager* vm = aView->GetViewManager(); vm->ResizeView(aView, aVisualOverflowArea, true); } @@ -768,7 +768,7 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, return; } - nsIViewManager* vm = aView->GetViewManager(); + nsViewManager* vm = aView->GetViewManager(); if (nullptr == aStyleContext) { aStyleContext = aFrame->GetStyleContext(); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index fbd308f54891..be9082de186b 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -22,7 +22,7 @@ #include "nsStyleContext.h" #include "nsTableOuterFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsPresContext.h" #include "nsCRT.h" @@ -5289,7 +5289,7 @@ nsFrame::UpdateOverflow() if ((flags & NS_FRAME_NO_SIZE_VIEW) == 0) { // Make sure the frame's view is properly sized. - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); vm->ResizeView(view, overflowAreas.VisualOverflow(), true); } } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 843ef0ca5b55..7ea3d8e737ba 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -22,7 +22,7 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsWidgetsCID.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 541abd69edc9..e0510aa491b9 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -11,7 +11,7 @@ #include "nsIServiceManager.h" #include "nsView.h" #include "nsIScrollable.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsContainerFrame.h" #include "nsGfxScrollFrame.h" #include "nsGkAtoms.h" diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index c7b9fed522e9..7f1b46428bc8 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -14,7 +14,7 @@ #include "nsIPresShell.h" #include "nsWidgetsCID.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMEventListener.h" #include "nsIDOMDragEvent.h" #include "nsPluginHost.h" @@ -329,7 +329,7 @@ nsObjectFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) { if (HasView()) { nsView* view = GetView(); - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); if (vm) { nsViewVisibility visibility = IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow; @@ -365,7 +365,7 @@ nsObjectFrame::PrepForDrawing(nsIWidget *aWidget) return NS_ERROR_FAILURE; } - nsIViewManager* viewMan = view->GetViewManager(); + nsViewManager* viewMan = view->GetViewManager(); // mark the view as hidden since we don't know the (x,y) until Paint // XXX is the above comment correct? viewMan->SetViewVisibility(view, nsViewVisibility_kHide); @@ -593,7 +593,7 @@ nsObjectFrame::Reflow(nsPresContext* aPresContext, r.Deflate(aReflowState.mComputedBorderPadding); if (mInnerView) { - nsIViewManager* vm = mInnerView->GetViewManager(); + nsViewManager* vm = mInnerView->GetViewManager(); vm->MoveViewTo(mInnerView, r.x, r.y); vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), r.Size()), true); } @@ -884,7 +884,7 @@ nsObjectFrame::DidReflow(nsPresContext* aPresContext, if (HasView()) { nsView* view = GetView(); - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); if (vm) vm->SetViewVisibility(view, IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow); } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 4a5bf79aa73e..9ead05a2f475 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -30,7 +30,7 @@ #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" #include "nsStyleContext.h" @@ -674,7 +674,7 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, } if (mInnerView) { - nsIViewManager* vm = mInnerView->GetViewManager(); + nsViewManager* vm = mInnerView->GetViewManager(); vm->MoveViewTo(mInnerView, offset.x, offset.y); vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), innerSize), true); } @@ -958,7 +958,7 @@ InsertViewsInReverseOrder(nsView* aSibling, nsView* aParent) NS_PRECONDITION(aParent, ""); NS_PRECONDITION(!aParent->GetFirstChild(), "inserting into non-empty list"); - nsIViewManager* vm = aParent->GetViewManager(); + nsViewManager* vm = aParent->GetViewManager(); while (aSibling) { nsView* next = aSibling->GetNextSibling(); aSibling->SetNextSibling(nullptr); @@ -1092,7 +1092,7 @@ nsSubDocumentFrame::EnsureInnerView() NS_ASSERTION(outerView, "Must have an outer view already"); nsRect viewBounds(0, 0, 0, 0); // size will be fixed during reflow - nsIViewManager* viewMan = outerView->GetViewManager(); + nsViewManager* viewMan = outerView->GetViewManager(); nsView* innerView = viewMan->CreateView(viewBounds, outerView); if (!innerView) { NS_ERROR("Could not create inner view"); diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 41042894f8e6..225ed61290b5 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -90,7 +90,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsViewsCID.h" #include "nsWidgetsCID.h" #include "nsIDeviceContextSpec.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsRenderingContext.h" @@ -3793,7 +3793,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out) fprintf(out, "docshell=%p \n", aDocShell); nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell); if (shell) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (vm) { nsView* root = vm->GetRootView(); if (root) { diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 672d05d56c90..5f3e4cdfeafc 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -12,7 +12,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsStyleSet.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDocShell.h" #include "nsIDocument.h" #include "nsIDocShellTreeOwner.h" @@ -46,7 +46,7 @@ public: nsRefPtr mPresContext; nsCOMPtr mPresShell; - nsCOMPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 2e86a23f7c77..dc94218e3810 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -21,7 +21,7 @@ #include "nsIDOMDocument.h" #include "nsIPresShell.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIFrame.h" #include "nsILayoutDebugger.h" @@ -55,7 +55,7 @@ pres_shell(nsIDocShell *aDocShell) return result.forget(); } -static nsIViewManager* +static nsViewManager* view_manager(nsIDocShell *aDocShell) { nsCOMPtr shell(pres_shell(aDocShell)); @@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsCOMPtr vm(view_manager(aDocShell)); + nsCOMPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsCOMPtr vm(view_manager(mDocShell)); + nsCOMPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/tools/layout-debug/src/nsRegressionTester.cpp b/layout/tools/layout-debug/src/nsRegressionTester.cpp index a23195f613db..af942203e6da 100644 --- a/layout/tools/layout-debug/src/nsRegressionTester.cpp +++ b/layout/tools/layout-debug/src/nsRegressionTester.cpp @@ -25,7 +25,7 @@ #include "nsLayoutCID.h" #include "nsNetUtil.h" #include "nsIFile.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index e7c44eb816ed..011b9ea9d354 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -41,7 +41,7 @@ #include "nsGkAtoms.h" #include "nsIContent.h" #include "nsHTMLParts.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 50f4611bf7f6..34932e816285 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -20,7 +20,7 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsBoxLayoutState.h" #include "nsStackLayout.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsLeafBoxFrame.cpp b/layout/xul/base/src/nsLeafBoxFrame.cpp index 163ed3ce0a30..1ce3541532b1 100644 --- a/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -20,7 +20,7 @@ #include "nsINameSpaceManager.h" #include "nsBoxLayoutState.h" #include "nsWidgetsCID.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsContainerFrame.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index b5496a07cc1b..72eaf2c9f3ad 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -22,7 +22,7 @@ #include "nsIScrollableFrame.h" #include "nsScrollbarFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsStyleContext.h" #include "nsFontMetrics.h" #include "nsITimer.h" diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index eb20199c67c8..c463591f28d0 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -12,7 +12,7 @@ #include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsWidgetsCID.h" #include "nsMenuFrame.h" #include "nsMenuBarFrame.h" @@ -125,7 +125,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent, // so we use the nsView::SetFloating() to tell the view manager // about that constraint. nsView* ourView = GetView(); - nsIViewManager* viewManager = ourView->GetViewManager(); + nsViewManager* viewManager = ourView->GetViewManager(); viewManager->SetViewFloating(ourView, true); mPopupType = ePopupTypePanel; @@ -459,7 +459,7 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, b } if (isOpen) { - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); nsRect rect = GetRect(); rect.x = rect.y = 0; viewManager->ResizeView(view, rect); @@ -794,7 +794,7 @@ nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState) mHFlip = mVFlip = false; nsView* view = GetView(); - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); viewManager->SetViewVisibility(view, nsViewVisibility_kHide); FireDOMEvent(NS_LITERAL_STRING("DOMMenuInactive"), mContent); @@ -1919,7 +1919,7 @@ nsMenuPopupFrame::CreatePopupView() return NS_OK; } - nsIViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); + nsViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); NS_ASSERTION(nullptr != viewManager, "null view manager"); // Create a view diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index bcf09d20e979..10b977609aa9 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -90,7 +90,7 @@ enum FlipStyle { nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); -class nsIViewManager; +class nsViewManager; class nsView; class nsMenuPopupFrame; diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index cf6befa60196..32b2b0e50e0c 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -20,7 +20,7 @@ #include "nsEventStateManager.h" #include "nsCSSFrameConstructor.h" #include "nsLayoutUtils.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIComponentManager.h" #include "nsITimer.h" #include "nsFocusManager.h" @@ -2262,7 +2262,7 @@ nsXULMenuCommandEvent::Run() if (!pm) return NS_OK; - // The order of the nsIViewManager and nsIPresShell COM pointers is + // The order of the nsViewManager and nsIPresShell COM pointers is // important below. We want the pres shell to get released before the // associated view manager on exit from this function. // See bug 54233. @@ -2295,7 +2295,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); + nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index f889eba2383d..e0f6f69aa3f8 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -39,7 +39,7 @@ #include "nsXPIDLString.h" #include "nsContainerFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsWidgetsCID.h" #include "nsBoxFrame.h" #include "nsBoxObject.h" diff --git a/view/public/Makefile.in b/view/public/Makefile.in index f4c2731040a9..15a90772c1f2 100644 --- a/view/public/Makefile.in +++ b/view/public/Makefile.in @@ -14,7 +14,7 @@ MODULE = view EXPORTS = \ nsView.h \ - nsIViewManager.h \ + nsViewManager.h \ nsViewsCID.h \ nsIScrollPositionListener.h \ $(NULL) diff --git a/view/public/nsView.h b/view/public/nsView.h index a9bade64954b..686a97abc3d6 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -20,7 +20,6 @@ #include "nsIWidgetListener.h" #include -class nsIViewManager; class nsViewManager; class nsIWidget; class nsIFrame; @@ -59,7 +58,7 @@ enum nsViewVisibility { * view manager that owns the views. * * Most of the methods here are read-only. To set the corresponding properties - * of a view, go through nsIViewManager. + * of a view, go through nsViewManager. */ class nsView MOZ_FINAL : public nsIWidgetListener @@ -75,8 +74,8 @@ public: * view manager from somewhere else, do that instead. * @result the view manager */ - nsIViewManager* GetViewManager() const - { return reinterpret_cast(mViewManager); } + nsViewManager* GetViewManager() const + { return reinterpret_cast(mViewManager); } nsViewManager* GetViewManagerInternal() const { return mViewManager; } /** @@ -460,13 +459,13 @@ private: // released if it points to any view in this view hierarchy. void InvalidateHierarchy(nsViewManager *aViewManagerParent); - nsViewManager *mViewManager; + nsViewManager *mViewManager; nsView *mParent; - nsIWidget *mWindow; + nsIWidget *mWindow; nsView *mNextSibling; nsView *mFirstChild; - nsIFrame *mFrame; - nsRegion *mDirtyRegion; + nsIFrame *mFrame; + nsRegion *mDirtyRegion; int32_t mZIndex; nsViewVisibility mVis; // position relative our parent view origin but in our appunits diff --git a/view/public/nsIViewManager.h b/view/public/nsViewManager.h similarity index 60% rename from view/public/nsIViewManager.h rename to view/public/nsViewManager.h index b8ca74541cbd..685e59c4bda2 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsViewManager.h @@ -3,35 +3,54 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsIViewManager_h___ -#define nsIViewManager_h___ +#ifndef nsViewManager_h___ +#define nsViewManager_h___ #include "nscore.h" #include "nsView.h" #include "nsEvent.h" +#include "nsCOMPtr.h" +#include "nsCRT.h" +#include "nsITimer.h" +#include "prtime.h" +#include "prinrval.h" +#include "nsVoidArray.h" +#include "nsThreadUtils.h" +#include "nsIPresShell.h" +#include "nsDeviceContext.h" class nsIWidget; struct nsRect; class nsRegion; class nsDeviceContext; class nsIPresShell; +class nsView; #define NS_IVIEWMANAGER_IID \ { 0x540610a6, 0x4fdd, 0x4ae3, \ { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } } -class nsIViewManager : public nsISupports +class nsViewManager : public nsISupports { public: + friend class nsView; NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID) + + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW + + NS_DECL_ISUPPORTS + + nsViewManager(); + virtual ~nsViewManager(); + /** * Initialize the ViewManager * Note: this instance does not hold a reference to the presshell * because it holds a reference to this instance. * @result The result of the initialization, NS_OK if no errors */ - NS_IMETHOD Init(nsDeviceContext* aContext) = 0; + NS_IMETHOD Init(nsDeviceContext* aContext); /** * Create an ordinary view @@ -47,13 +66,13 @@ public: */ NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0; + nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); /** * Get the root of the view tree. * @result the root view */ - NS_IMETHOD_(nsView*) GetRootView() = 0; + NS_IMETHOD_(nsView*) GetRootView() { return mRootView; } /** * Set the root of the view tree. Does not destroy the current root view. @@ -61,7 +80,7 @@ public: * aView may have a widget (anything but printing) or may not (printing). * @param aView view to set as root */ - NS_IMETHOD SetRootView(nsView *aView) = 0; + NS_IMETHOD SetRootView(nsView *aView); /** * Get the dimensions of the root window. The dimensions are in @@ -69,7 +88,7 @@ public: * @param aWidth out parameter for width of window in twips * @param aHeight out parameter for height of window in twips */ - NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0; + NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); /** * Set the dimensions of the root window. @@ -78,19 +97,19 @@ public: * @param aWidth of window in twips * @param aHeight of window in twips */ - NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0; + NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight); /** * Do any resizes that are pending. */ - NS_IMETHOD FlushDelayedResize(bool aDoReflow) = 0; + NS_IMETHOD FlushDelayedResize(bool aDoReflow); /** * Called to inform the view manager that the entire area of a view * is dirty and needs to be redrawn. * @param aView view to paint. should be root view */ - NS_IMETHOD InvalidateView(nsView *aView) = 0; + NS_IMETHOD InvalidateView(nsView *aView); /** * Called to inform the view manager that some portion of a view is dirty and @@ -99,12 +118,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect) = 0; + NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); /** * Called to inform the view manager that it should invalidate all views. */ - NS_IMETHOD InvalidateAllViews() = 0; + NS_IMETHOD InvalidateAllViews(); /** * Called to dispatch an event to the appropriate view. Often called @@ -115,7 +134,7 @@ public: * @param aStatus event handling status */ NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, - nsView* aViewTarget, nsEventStatus* aStatus) = 0; + nsView* aViewTarget, nsEventStatus* aStatus); /** * Given a parent view, insert another view as its child. @@ -133,7 +152,9 @@ public: * @param aAfter after or before in the document order */ NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter) = 0; + bool aAfter); + + NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); /** * Remove a specific child view from its parent. This will NOT remove its placeholder @@ -142,7 +163,7 @@ public: * @param aParent parent view * @param aChild child view */ - NS_IMETHOD RemoveChild(nsView *aChild) = 0; + NS_IMETHOD RemoveChild(nsView *aChild); /** * Move a view to the specified position, provided in parent coordinates. @@ -153,7 +174,7 @@ public: * @param aX x value for new view position * @param aY y value for new view position */ - NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY) = 0; + NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); /** * Resize a view. In addition to setting the width and height, you can @@ -168,7 +189,7 @@ public: * if false Repaint the union of the old and new rectangles. */ NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, - bool aRepaintExposedAreaOnly = false) = 0; + bool aRepaintExposedAreaOnly = false); /** * Set the visibility of a view. Hidden views have the effect of hiding @@ -181,7 +202,7 @@ public: * @param aView view to change visibility state of * @param visible new visibility state */ - NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible) = 0; + NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); /** * Set the z-index of a view. Positive z-indices mean that a view @@ -199,7 +220,7 @@ public: * true if the view should be topmost when compared with * other z-index:auto views. */ - NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false) = 0; + NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); /** * Set whether the view "floats" above all other views, @@ -208,24 +229,24 @@ public: * this view. This is a hack, but it fixes some problems with * views that need to be drawn in front of all other views. */ - NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView) = 0; + NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView); /** * Set the presshell associated with this manager * @param aPresShell - new presshell */ - virtual void SetPresShell(nsIPresShell *aPresShell) = 0; + virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } /** * Get the pres shell associated with this manager */ - virtual nsIPresShell* GetPresShell() = 0; + virtual nsIPresShell* GetPresShell() { return mPresShell; } /** * Get the device context associated with this manager * @result device context */ - NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext) = 0; + NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); /** * A stack class for disallowing changes that would enter painting. For @@ -241,7 +262,7 @@ public: */ class NS_STACK_CLASS AutoDisableRefresh { public: - AutoDisableRefresh(nsIViewManager* aVM) { + AutoDisableRefresh(nsViewManager* aVM) { if (aVM) { mRootVM = aVM->IncrementDisableRefreshCount(); } @@ -255,21 +276,21 @@ public: AutoDisableRefresh(const AutoDisableRefresh& aOther); const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - nsCOMPtr mRootVM; + nsCOMPtr mRootVM; }; private: friend class AutoDisableRefresh; - virtual nsIViewManager* IncrementDisableRefreshCount() = 0; - virtual void DecrementDisableRefreshCount() = 0; + virtual nsViewManager* IncrementDisableRefreshCount(); + virtual void DecrementDisableRefreshCount(); public: /** * Retrieve the widget at the root of the nearest enclosing * view manager whose root view has a widget. */ - NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0; + NS_IMETHOD GetRootWidget(nsIWidget **aWidget); /** * Indicate whether the viewmanager is currently painting @@ -277,7 +298,7 @@ public: * @param aPainting true if the viewmanager is painting * false otherwise */ - NS_IMETHOD IsPainting(bool& aIsPainting)=0; + NS_IMETHOD IsPainting(bool& aIsPainting); /** * Retrieve the time of the last user event. User events @@ -286,7 +307,7 @@ public: * * @param aTime Last user event time in microseconds */ - NS_IMETHOD GetLastUserEventTime(uint32_t& aTime)=0; + NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); /** * Find the nearest display root view for the view aView. This is the view for @@ -298,14 +319,141 @@ public: * Flush the accumulated dirty region to the widget and update widget * geometry. */ - virtual void ProcessPendingUpdates()=0; + virtual void ProcessPendingUpdates(); /** * Just update widget geometry without flushing the dirty region */ - virtual void UpdateWidgetGeometry() = 0; + virtual void UpdateWidgetGeometry(); + + uint32_t AppUnitsPerDevPixel() const + { + return mContext->AppUnitsPerDevPixel(); + } + nsView* GetRootViewImpl() const { return mRootView; } + +private: + static uint32_t gLastUserEventTime; + + /* Update the cached RootViewManager pointer on this view manager. */ + void InvalidateHierarchy(); + void FlushPendingInvalidates(); + + void ProcessPendingUpdatesForView(nsView *aView, + bool aFlushDirtyRegion = true); + void FlushDirtyRegionToWidget(nsView* aView); + /** + * Call WillPaint() on all view observers under this vm root. + */ + void CallWillPaintOnObservers(bool aWillSendDidPaint); + void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget); + void ReparentWidgets(nsView* aView, nsView *aParent); + void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); + + void InvalidateViews(nsView *aView); + + // aView is the view for aWidget and aRegion is relative to aWidget. + void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint); + + void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); + void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, + nscoord aY1, nscoord aY2, bool aInCutOut); + + // Utilities + + bool IsViewInserted(nsView *aView); + + /** + * Intersects aRect with aView's bounds and then transforms it from aView's + * coordinate system to the coordinate system of the widget attached to + * aView. + */ + nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const; + + void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight); + + bool IsPainting() const { + return RootViewManager()->mPainting; + } + + void SetPainting(bool aPainting) { + RootViewManager()->mPainting = aPainting; + } + + nsresult InvalidateView(nsView *aView, const nsRect &aRect); + + nsViewManager* RootViewManager() const { return mRootViewManager; } + bool IsRootVM() const { return this == RootViewManager(); } + + // Whether synchronous painting is allowed at the moment. For example, + // widget geometry changes can cause synchronous painting, so they need to + // be deferred while refresh is disabled. + bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; } + + void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint); + bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, + uint32_t aFlags); + void DidPaintWindow(); + + // Call this when you need to let the viewmanager know that it now has + // pending updates. + void PostPendingUpdate(); + + nsRefPtr mContext; + nsIPresShell *mPresShell; + + // The size for a resize that we delayed until the root view becomes + // visible again. + nsSize mDelayedResize; + + nsView *mRootView; + // mRootViewManager is a strong ref unless it equals |this|. It's + // never null (if we have no ancestors, it will be |this|). + nsViewManager *mRootViewManager; + + // The following members should not be accessed directly except by + // the root view manager. Some have accessor functions to enforce + // this, as noted. + + int32_t mRefreshDisableCount; + // Use IsPainting() and SetPainting() to access mPainting. + bool mPainting; + bool mRecursiveRefreshPending; + bool mHasPendingWidgetGeometryChanges; + bool mInScroll; + + //from here to public should be static and locked... MMP + static int32_t mVMCount; //number of viewmanagers + + //list of view managers + static nsVoidArray *gViewManagers; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIViewManager, NS_IVIEWMANAGER_IID) +NS_DEFINE_STATIC_IID_ACCESSOR(nsViewManager, NS_IVIEWMANAGER_IID) -#endif // nsIViewManager_h___ + +/** + Invalidation model: + + 1) Callers call into the view manager and ask it to invalidate a view. + + 2) The view manager finds the "right" widget for the view, henceforth called + the root widget. + + 3) The view manager traverses descendants of the root widget and for each + one that needs invalidation stores the rect to invalidate on the widget's + view (batching). + + 4) The dirty region is flushed to the right widget when + ProcessPendingUpdates is called from the RefreshDriver. + + It's important to note that widgets associated to views outside this view + manager can end up being invalidated during step 3. Therefore, the end of a + view update batch really needs to traverse the entire view tree, to ensure + that those invalidates happen. + + To cope with this, invalidation processing and should only happen on the + root viewmanager. +*/ + +#endif // nsViewManager_h___ diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 31deaad1aecf..64949a9cce17 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) } if (view) { - nsCOMPtr vm = view->GetViewManager(); + nsCOMPtr vm = view->GetViewManager(); vm->DispatchEvent(aEvent, view, &result); } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 442b7056e849..414fc77dedee 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -122,7 +122,7 @@ nsViewManager::~nsViewManager() mPresShell = nullptr; } -NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager) +NS_IMPL_ISUPPORTS1(nsViewManager, nsViewManager) // We don't hold a reference to the presentation context because it // holds a reference to us. @@ -156,12 +156,6 @@ nsViewManager::CreateView(const nsRect& aBounds, return v; } -NS_IMETHODIMP_(nsView*) -nsViewManager::GetRootView() -{ - return mRootView; -} - NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) { NS_PRECONDITION(!aView || aView->GetViewManager() == this, @@ -278,7 +272,7 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn, return out; } -nsView* nsIViewManager::GetDisplayRootFor(nsView* aView) +nsView* nsViewManager::GetDisplayRootFor(nsView* aView) { nsView *displayRoot = aView; for (;;) { @@ -571,7 +565,7 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) if (!shell || shell->ShouldIgnoreInvalidation()) { return true; } - nsView* view = aVM->GetRootViewImpl()->GetParent(); + nsView* view = aVM->GetRootView()->GetParent(); aVM = view ? view->GetViewManagerInternal() : nullptr; } return false; @@ -1107,7 +1101,7 @@ NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) return NS_OK; } -nsIViewManager* +nsViewManager* nsViewManager::IncrementDisableRefreshCount() { if (!IsRootVM()) { diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h deleted file mode 100644 index 7315a3bd6683..000000000000 --- a/view/src/nsViewManager.h +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsViewManager_h___ -#define nsViewManager_h___ -#include "nsCOMPtr.h" -#include "nsIViewManager.h" -#include "nsCRT.h" -#include "nsITimer.h" -#include "prtime.h" -#include "prinrval.h" -#include "nsVoidArray.h" -#include "nsThreadUtils.h" -#include "nsIPresShell.h" -#include "nsDeviceContext.h" - - -/** - Invalidation model: - - 1) Callers call into the view manager and ask it to invalidate a view. - - 2) The view manager finds the "right" widget for the view, henceforth called - the root widget. - - 3) The view manager traverses descendants of the root widget and for each - one that needs invalidation stores the rect to invalidate on the widget's - view (batching). - - 4) The dirty region is flushed to the right widget when - ProcessPendingUpdates is called from the RefreshDriver. - - It's important to note that widgets associated to views outside this view - manager can end up being invalidated during step 3. Therefore, the end of a - view update batch really needs to traverse the entire view tree, to ensure - that those invalidates happen. - - To cope with this, invalidation processing and should only happen on the - root viewmanager. -*/ - -class nsViewManager : public nsIViewManager { -public: - nsViewManager(); - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_DECL_ISUPPORTS - - NS_IMETHOD Init(nsDeviceContext* aContext); - - NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, - const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); - - NS_IMETHOD_(nsView*) GetRootView(); - NS_IMETHOD SetRootView(nsView *aView); - - NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height); - NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); - NS_IMETHOD FlushDelayedResize(bool aDoReflow); - - NS_IMETHOD InvalidateView(nsView *aView); - NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); - NS_IMETHOD InvalidateAllViews(); - - NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, - nsView* aTargetView, nsEventStatus* aStatus); - - NS_IMETHOD InsertChild(nsView *parent, nsView *child, nsView *sibling, - bool above); - - NS_IMETHOD InsertChild(nsView *parent, nsView *child, - int32_t zindex); - - NS_IMETHOD RemoveChild(nsView *parent); - - NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); - - NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly = false); - - NS_IMETHOD SetViewFloating(nsView *aView, bool aFloating); - - NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); - - NS_IMETHOD SetViewZIndex(nsView *aView, bool aAuto, int32_t aZIndex, bool aTopMost=false); - - virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } - virtual nsIPresShell* GetPresShell() { return mPresShell; } - - NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); - - virtual nsIViewManager* IncrementDisableRefreshCount(); - virtual void DecrementDisableRefreshCount(); - - NS_IMETHOD GetRootWidget(nsIWidget **aWidget); - - NS_IMETHOD IsPainting(bool& aIsPainting); - NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); - static uint32_t gLastUserEventTime; - - /* Update the cached RootViewManager pointer on this view manager. */ - void InvalidateHierarchy(); - - virtual void ProcessPendingUpdates(); - virtual void UpdateWidgetGeometry(); - -protected: - virtual ~nsViewManager(); - -private: - - void FlushPendingInvalidates(); - void ProcessPendingUpdatesForView(nsView *aView, - bool aFlushDirtyRegion = true); - void FlushDirtyRegionToWidget(nsView* aView); - /** - * Call WillPaint() on all view observers under this vm root. - */ - void CallWillPaintOnObservers(bool aWillSendDidPaint); - void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget); - void ReparentWidgets(nsView* aView, nsView *aParent); - void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); - - void InvalidateViews(nsView *aView); - - // aView is the view for aWidget and aRegion is relative to aWidget. - void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint); - - void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); - void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, - nscoord aY1, nscoord aY2, bool aInCutOut); - - // Utilities - - bool IsViewInserted(nsView *aView); - - /** - * Intersects aRect with aView's bounds and then transforms it from aView's - * coordinate system to the coordinate system of the widget attached to - * aView. - */ - nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const; - - void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight); - - bool IsPainting() const { - return RootViewManager()->mPainting; - } - - void SetPainting(bool aPainting) { - RootViewManager()->mPainting = aPainting; - } - - nsresult InvalidateView(nsView *aView, const nsRect &aRect); - -public: // NOT in nsIViewManager, so private to the view module - nsView* GetRootViewImpl() const { return mRootView; } - nsViewManager* RootViewManager() const { return mRootViewManager; } - bool IsRootVM() const { return this == RootViewManager(); } - - // Whether synchronous painting is allowed at the moment. For example, - // widget geometry changes can cause synchronous painting, so they need to - // be deferred while refresh is disabled. - bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; } - - void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint); - bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, - uint32_t aFlags); - void DidPaintWindow(); - - // Call this when you need to let the viewmanager know that it now has - // pending updates. - void PostPendingUpdate(); - - uint32_t AppUnitsPerDevPixel() const - { - return mContext->AppUnitsPerDevPixel(); - } - -private: - nsRefPtr mContext; - nsIPresShell *mPresShell; - - // The size for a resize that we delayed until the root view becomes - // visible again. - nsSize mDelayedResize; - - nsView *mRootView; - // mRootViewManager is a strong ref unless it equals |this|. It's - // never null (if we have no ancestors, it will be |this|). - nsViewManager *mRootViewManager; - - // The following members should not be accessed directly except by - // the root view manager. Some have accessor functions to enforce - // this, as noted. - - int32_t mRefreshDisableCount; - // Use IsPainting() and SetPainting() to access mPainting. - bool mPainting; - bool mRecursiveRefreshPending; - bool mHasPendingWidgetGeometryChanges; - bool mInScroll; - - //from here to public should be static and locked... MMP - static int32_t mVMCount; //number of viewmanagers - - //list of view managers - static nsVoidArray *gViewManagers; -}; - -#endif /* nsViewManager_h___ */ diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 6c86c30ccdab..7d42ad969b03 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -23,7 +23,7 @@ using mozilla::unused; #include "nsIObserverService.h" #include "nsFocusManager.h" #include "nsIWidgetListener.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsRenderingContext.h" #include "nsIDOMSimpleGestureEvent.h" diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 0f84ca234fec..71ea4e226fa8 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -23,7 +23,7 @@ #include "nsFontMetrics.h" #include "nsIRollupListener.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIInterfaceRequestor.h" #include "nsIFile.h" #include "nsILocalFileMac.h" diff --git a/widget/gtk2/nsDragService.cpp b/widget/gtk2/nsDragService.cpp index 2f98d290ca39..82b403b4dc74 100644 --- a/widget/gtk2/nsDragService.cpp +++ b/widget/gtk2/nsDragService.cpp @@ -31,7 +31,7 @@ #include "nsPresContext.h" #include "nsIDocument.h" #include "nsISelection.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIFrame.h" // This sets how opaque the drag image is @@ -269,7 +269,7 @@ GetGtkWindow(nsIDOMDocument *aDocument) if (!presShell) return NULL; - nsCOMPtr vm = presShell->GetViewManager(); + nsCOMPtr vm = presShell->GetViewManager(); if (!vm) return NULL; diff --git a/widget/gtk2/nsNativeThemeGTK.cpp b/widget/gtk2/nsNativeThemeGTK.cpp index 59132735dada..35b786aec4c5 100644 --- a/widget/gtk2/nsNativeThemeGTK.cpp +++ b/widget/gtk2/nsNativeThemeGTK.cpp @@ -12,7 +12,7 @@ #include "nsIFrame.h" #include "nsIPresShell.h" #include "nsIContent.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsINameSpaceManager.h" #include "nsGfxCIID.h" #include "nsTransform2D.h" @@ -75,7 +75,7 @@ nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame) if (!shell) return; - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (!vm) return; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index 150c72c075a6..6a1aa6d79660 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -65,7 +65,7 @@ template class nsReadingIterator; #include "nsIDOMHTMLTextAreaElement.h" #include "nsIDOMElement.h" #include "nsISelectionController.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsTArray.h" #include "nsGUIEvent.h" @@ -3144,7 +3144,7 @@ TestApp::GetWidget(nsIWidget** aWidget) return false; } - nsCOMPtr viewManager = presShell->GetViewManager(); + nsCOMPtr viewManager = presShell->GetViewManager(); if (!viewManager) { return false; } diff --git a/widget/xpwidgets/nsBaseDragService.cpp b/widget/xpwidgets/nsBaseDragService.cpp index df2bb433365b..60c677fb00e3 100644 --- a/widget/xpwidgets/nsBaseDragService.cpp +++ b/widget/xpwidgets/nsBaseDragService.cpp @@ -18,7 +18,7 @@ #include "nsIDocument.h" #include "nsIContent.h" #include "nsIPresShell.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMNode.h" #include "nsIDOMDragEvent.h" #include "nsISelection.h" From 4464dc950d46e4dc48a727ca3cf53517eeecf751 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:42 +1300 Subject: [PATCH 118/180] Bug 826632. Part 2: Use nsRefPtr instead of nsCOMPtr. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : c9eabd54bb43d711a8c24222620abfdde674a1f7 --- extensions/widgetutils/src/nsWidgetUtils.cpp | 2 +- layout/base/nsCSSFrameConstructor.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 2 +- layout/base/nsPresShell.cpp | 6 +++--- layout/base/nsRefreshDriver.cpp | 2 +- layout/printing/nsPrintObject.h | 2 +- layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp | 4 ++-- layout/xul/base/src/nsXULPopupManager.cpp | 2 +- view/public/nsViewManager.h | 2 +- view/src/nsView.cpp | 8 ++++---- widget/gtk2/nsDragService.cpp | 2 +- widget/tests/TestWinTSF.cpp | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index 1c17043fa445..ec6ccbf78717 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -89,7 +89,7 @@ private: static void StopPanningCallback(nsITimer *timer, void *closure); nsCOMPtr mWidget; - nsCOMPtr mViewManager; + nsRefPtr mViewManager; nsCOMPtr mTimer; }; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 49cd2832186e..0b8905a9c6d3 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -12015,7 +12015,7 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) return; // Make sure that the viewmanager will outlive the presshell - nsCOMPtr vm = mPresShell->GetViewManager(); + nsRefPtr vm = mPresShell->GetViewManager(); // Processing the style changes could cause a flush that propagates to // the parent frame and thus destroys the pres shell. diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 8d434d5bfc74..d1a91c4702fa 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -397,7 +397,7 @@ protected: // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsCOMPtr mViewManager; + nsRefPtr mViewManager; nsRefPtr mPresContext; nsCOMPtr mPresShell; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index fd3ab466f9f4..0d50d8092c05 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1857,7 +1857,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_ERROR_NOT_AVAILABLE; } - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsRefPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first nsCOMPtr kungFuDeathGrip(this); @@ -3808,7 +3808,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsRefPtr viewManagerDeathGrip = mViewManager; if (isSafeToFlush && mViewManager) { // Processing pending notifications can kill us, and some callers only // hold weak refs when calling FlushPendingNotifications(). :( @@ -8270,7 +8270,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsCOMPtr vm = do_CreateInstance(kViewManagerCID); + nsRefPtr vm = do_CreateInstance(kViewManagerCID); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 00af04528c54..66cd63ae4f33 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -951,7 +951,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); + nsRefPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef DEBUG_INVALIDATIONS printf("Ending ProcessPendingUpdates\n"); diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 5f3e4cdfeafc..2ea10001b046 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -46,7 +46,7 @@ public: nsRefPtr mPresContext; nsCOMPtr mPresShell; - nsCOMPtr mViewManager; + nsRefPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index dc94218e3810..072b2f216d7d 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsCOMPtr vm(view_manager(aDocShell)); + nsRefPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsCOMPtr vm(view_manager(mDocShell)); + nsRefPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 32b2b0e50e0c..340fe7ec364a 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -2295,7 +2295,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); + nsRefPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index 685e59c4bda2..c959b7d1f56b 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -276,7 +276,7 @@ public: AutoDisableRefresh(const AutoDisableRefresh& aOther); const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - nsCOMPtr mRootVM; + nsRefPtr mRootVM; }; private: diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 64949a9cce17..64b9ff50072c 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -953,7 +953,7 @@ nsView::RequestWindowClose(nsIWidget* aWidget) void nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - nsCOMPtr vm = mViewManager; + nsRefPtr vm = mViewManager; vm->WillPaintWindow(aWidget, aWillSendDidPaint); } @@ -963,7 +963,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?"); mInAlternatePaint = aFlags & PAINT_IS_ALTERNATE; - nsCOMPtr vm = mViewManager; + nsRefPtr vm = mViewManager; bool result = vm->PaintWindow(aWidget, aRegion, aFlags); // PaintWindow can destroy this via WillPaintWindow notification, so we have // to re-get the view from the widget. @@ -977,7 +977,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) void nsView::DidPaintWindow() { - nsCOMPtr vm = mViewManager; + nsRefPtr vm = mViewManager; vm->DidPaintWindow(); } @@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) } if (view) { - nsCOMPtr vm = view->GetViewManager(); + nsRefPtr vm = view->GetViewManager(); vm->DispatchEvent(aEvent, view, &result); } diff --git a/widget/gtk2/nsDragService.cpp b/widget/gtk2/nsDragService.cpp index 82b403b4dc74..73900e74ffed 100644 --- a/widget/gtk2/nsDragService.cpp +++ b/widget/gtk2/nsDragService.cpp @@ -269,7 +269,7 @@ GetGtkWindow(nsIDOMDocument *aDocument) if (!presShell) return NULL; - nsCOMPtr vm = presShell->GetViewManager(); + nsRefPtr vm = presShell->GetViewManager(); if (!vm) return NULL; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index 6a1aa6d79660..e9f4cc049911 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -3144,7 +3144,7 @@ TestApp::GetWidget(nsIWidget** aWidget) return false; } - nsCOMPtr viewManager = presShell->GetViewManager(); + nsRefPtr viewManager = presShell->GetViewManager(); if (!viewManager) { return false; } From e25c1519f1d196497569520541655882263ac993 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:49 +1300 Subject: [PATCH 119/180] Bug 826632. Part 3: Create nsViewManagers directly instead of using XPCOM. r=tnikkel --HG-- extra : rebase_source : f85da22ada991035fbb7116a993898dd0801663d --- layout/base/nsDocumentViewer.cpp | 10 ++-------- layout/base/nsPresShell.cpp | 5 +---- layout/build/nsLayoutModule.cpp | 7 ------- layout/printing/nsPrintEngine.cpp | 7 +------ view/public/Makefile.in | 1 - view/public/nsViewsCID.h | 17 ----------------- 6 files changed, 4 insertions(+), 43 deletions(-) delete mode 100644 view/public/nsViewsCID.h diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index d1a91c4702fa..a8f3cfc43811 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -40,7 +40,6 @@ #include "nsLayoutStylesheetCache.h" #include "mozilla/Preferences.h" -#include "nsViewsCID.h" #include "nsIDeviceContextSpec.h" #include "nsViewManager.h" #include "nsView.h" @@ -497,8 +496,6 @@ private: //------------------------------------------------------------------ // nsDocumentViewer //------------------------------------------------------------------ -// Class IDs -static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); //------------------------------------------------------------------ nsresult @@ -2272,14 +2269,11 @@ nsDocumentViewer::MakeWindow(const nsSize& aSize, nsView* aContainerView) DetachFromTopLevelWidget(); } - nsresult rv; - mViewManager = do_CreateInstance(kViewManagerCID, &rv); - if (NS_FAILED(rv)) - return rv; + mViewManager = new nsViewManager(); nsDeviceContext *dx = mPresContext->DeviceContext(); - rv = mViewManager->Init(dx); + nsresult rv = mViewManager->Init(dx); if (NS_FAILED(rv)) return rv; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 0d50d8092c05..427aecd9deb3 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -72,7 +72,6 @@ #include "nsCaret.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMXMLDocument.h" -#include "nsViewsCID.h" #include "nsFrameManager.h" #include "nsEventStateManager.h" #include "nsIMEStateManager.h" @@ -7926,8 +7925,6 @@ nsIPresShell::RemoveRefreshObserverExternal(nsARefreshObserver* aObserver, #include "nsIURL.h" #include "nsILinkHandler.h" -static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); - static void LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg) { @@ -8270,7 +8267,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsRefPtr vm = do_CreateInstance(kViewManagerCID); + nsRefPtr vm = new nsViewManager(); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index ad41b6b499d4..0589851d6361 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -66,8 +66,6 @@ #include "nsChannelPolicy.h" // view stuff -#include "nsViewsCID.h" -#include "nsViewManager.h" #include "nsContentCreatorFunctions.h" // DOM includes @@ -594,8 +592,6 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ return rv; \ } \ -NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager) - static nsresult CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult) { @@ -755,7 +751,6 @@ NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID); NS_DEFINE_NAMED_CID(NS_JSURI_CID); NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID); NS_DEFINE_NAMED_CID(NS_WINDOWCONTROLLER_CID); -NS_DEFINE_NAMED_CID(NS_VIEW_MANAGER_CID); NS_DEFINE_NAMED_CID(NS_PLUGINDOCLOADERFACTORY_CID); NS_DEFINE_NAMED_CID(NS_PLUGINDOCUMENT_CID); #ifdef MOZ_MEDIA @@ -1039,7 +1034,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &kNS_JSURI_CID, false, NULL, nsJSURIConstructor }, { &kNS_WINDOWCOMMANDTABLE_CID, false, NULL, CreateWindowCommandTableConstructor }, { &kNS_WINDOWCONTROLLER_CID, false, NULL, CreateWindowControllerWithSingletonCommandTable }, - { &kNS_VIEW_MANAGER_CID, false, NULL, nsViewManagerConstructor }, { &kNS_PLUGINDOCLOADERFACTORY_CID, false, NULL, CreateContentDLF }, { &kNS_PLUGINDOCUMENT_CID, false, NULL, CreatePluginDocument }, #ifdef MOZ_MEDIA @@ -1189,7 +1183,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID }, { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID }, { NS_WINDOWCONTROLLER_CONTRACTID, &kNS_WINDOWCONTROLLER_CID }, - { "@mozilla.org/view-manager;1", &kNS_VIEW_MANAGER_CID }, { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID }, { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID }, { TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID, &kTRANSFORMIIX_XSLT_PROCESSOR_CID }, diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 225ed61290b5..2224765fddce 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -87,7 +87,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsLayoutUtils.h" #include "mozilla/Preferences.h" -#include "nsViewsCID.h" #include "nsWidgetsCID.h" #include "nsIDeviceContextSpec.h" #include "nsViewManager.h" @@ -216,9 +215,6 @@ protected: bool mSuppressed; }; -// Class IDs -static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); - NS_IMPL_ISUPPORTS3(nsPrintEngine, nsIWebProgressListener, nsISupportsWeakReference, nsIObserver) @@ -2197,8 +2193,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO) nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDC); NS_ENSURE_SUCCESS(rv, rv); - aPO->mViewManager = do_CreateInstance(kViewManagerCID, &rv); - NS_ENSURE_SUCCESS(rv,rv); + aPO->mViewManager = new nsViewManager(); rv = aPO->mViewManager->Init(mPrt->mPrintDC); NS_ENSURE_SUCCESS(rv,rv); diff --git a/view/public/Makefile.in b/view/public/Makefile.in index 15a90772c1f2..49effdfb71a2 100644 --- a/view/public/Makefile.in +++ b/view/public/Makefile.in @@ -15,7 +15,6 @@ MODULE = view EXPORTS = \ nsView.h \ nsViewManager.h \ - nsViewsCID.h \ nsIScrollPositionListener.h \ $(NULL) diff --git a/view/public/nsViewsCID.h b/view/public/nsViewsCID.h deleted file mode 100644 index 5c06871a4235..000000000000 --- a/view/public/nsViewsCID.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsViewsCID_h__ -#define nsViewsCID_h__ - -#include "nsISupports.h" -#include "nsIFactory.h" -#include "nsIComponentManager.h" - -#define NS_VIEW_MANAGER_CID \ -{ 0xc95f1831, 0xc376, 0x11d1, \ - {0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}} - -#endif // nsViewsCID_h__ From b7774f093b4ddde6d761cc38589891482b86eace Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:57 +1300 Subject: [PATCH 120/180] Bug 826632. Part 4: nsViewManager does not need to implement nsISupports anymore. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : 868b6971a2ae0d45023fb11f31b3874159a793b0 --- view/public/nsViewManager.h | 13 ++----------- view/src/nsViewManager.cpp | 2 -- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index c959b7d1f56b..2daab6467684 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -26,20 +26,14 @@ class nsDeviceContext; class nsIPresShell; class nsView; -#define NS_IVIEWMANAGER_IID \ -{ 0x540610a6, 0x4fdd, 0x4ae3, \ - { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } } - -class nsViewManager : public nsISupports +class nsViewManager { public: friend class nsView; - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID) - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - NS_DECL_ISUPPORTS + NS_INLINE_DECL_REFCOUNTING(nsViewManager) nsViewManager(); virtual ~nsViewManager(); @@ -429,9 +423,6 @@ private: static nsVoidArray *gViewManagers; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsViewManager, NS_IVIEWMANAGER_IID) - - /** Invalidation model: diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 414fc77dedee..d40d44a0a88c 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -122,8 +122,6 @@ nsViewManager::~nsViewManager() mPresShell = nullptr; } -NS_IMPL_ISUPPORTS1(nsViewManager, nsViewManager) - // We don't hold a reference to the presentation context because it // holds a reference to us. NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) From 136a5fbaac35d38f68eb2a21e8f63367289f7f90 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:13:05 +1300 Subject: [PATCH 121/180] Bug 826632. Part 5: nsViewManager methods do not need to be virtual and most of the ones that return nsresult don't need to. r=tnikkel Also, just use GetRootView instead of GetRootViewImpl. --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : 8dadf01e7cab20f6e0b9b3e95e767687445260c2 --- docshell/base/nsDocShell.cpp | 2 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +- view/public/nsViewManager.h | 74 ++++++------ view/src/nsView.cpp | 14 +-- view/src/nsViewManager.cpp | 124 ++++++++++----------- 5 files changed, 105 insertions(+), 113 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index acde564214c6..f4f10dabb371 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5051,7 +5051,7 @@ nsDocShell::Repaint(bool aForce) nsViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE); + viewManager->InvalidateAllViews(); return NS_OK; } diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 1f85478b3b57..0b46a8ce1105 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -743,14 +743,14 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #endif // simply return the topmost document window nsCOMPtr widget; - nsresult rv = vm->GetRootWidget(getter_AddRefs(widget)); + vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { *pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW); } else { NS_ASSERTION(widget, "couldn't get doc's widget in getting doc's window handle"); } - return rv; + return NS_OK; #elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11) // X11 window managers want the toplevel window for WM_TRANSIENT_FOR. nsIWidget* win = mObjectFrame->GetNearestWidget(); diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index 2daab6467684..bfc729758f2e 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -24,9 +24,8 @@ struct nsRect; class nsRegion; class nsDeviceContext; class nsIPresShell; -class nsView; -class nsViewManager +class nsViewManager MOZ_FINAL { public: friend class nsView; @@ -36,7 +35,7 @@ public: NS_INLINE_DECL_REFCOUNTING(nsViewManager) nsViewManager(); - virtual ~nsViewManager(); + ~nsViewManager(); /** * Initialize the ViewManager @@ -44,7 +43,7 @@ public: * because it holds a reference to this instance. * @result The result of the initialization, NS_OK if no errors */ - NS_IMETHOD Init(nsDeviceContext* aContext); + nsresult Init(nsDeviceContext* aContext); /** * Create an ordinary view @@ -58,15 +57,15 @@ public: * XXX We should eliminate this parameter; you can set it after CreateView * @result The new view */ - NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, - const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); + nsView* CreateView(const nsRect& aBounds, + const nsView* aParent, + nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); /** * Get the root of the view tree. * @result the root view */ - NS_IMETHOD_(nsView*) GetRootView() { return mRootView; } + nsView* GetRootView() { return mRootView; } /** * Set the root of the view tree. Does not destroy the current root view. @@ -74,7 +73,7 @@ public: * aView may have a widget (anything but printing) or may not (printing). * @param aView view to set as root */ - NS_IMETHOD SetRootView(nsView *aView); + void SetRootView(nsView *aView); /** * Get the dimensions of the root window. The dimensions are in @@ -82,7 +81,7 @@ public: * @param aWidth out parameter for width of window in twips * @param aHeight out parameter for height of window in twips */ - NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); + void GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); /** * Set the dimensions of the root window. @@ -91,19 +90,19 @@ public: * @param aWidth of window in twips * @param aHeight of window in twips */ - NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight); + void SetWindowDimensions(nscoord aWidth, nscoord aHeight); /** * Do any resizes that are pending. */ - NS_IMETHOD FlushDelayedResize(bool aDoReflow); + void FlushDelayedResize(bool aDoReflow); /** * Called to inform the view manager that the entire area of a view * is dirty and needs to be redrawn. * @param aView view to paint. should be root view */ - NS_IMETHOD InvalidateView(nsView *aView); + void InvalidateView(nsView *aView); /** * Called to inform the view manager that some portion of a view is dirty and @@ -112,12 +111,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); + void InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); /** * Called to inform the view manager that it should invalidate all views. */ - NS_IMETHOD InvalidateAllViews(); + void InvalidateAllViews(); /** * Called to dispatch an event to the appropriate view. Often called @@ -127,7 +126,7 @@ public: * @param aViewTarget dispatch the event to this view * @param aStatus event handling status */ - NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, + void DispatchEvent(nsGUIEvent *aEvent, nsView* aViewTarget, nsEventStatus* aStatus); /** @@ -145,10 +144,10 @@ public: * @param aSibling sibling view * @param aAfter after or before in the document order */ - NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter); + void InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, + bool aAfter); - NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); + void InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); /** * Remove a specific child view from its parent. This will NOT remove its placeholder @@ -157,7 +156,7 @@ public: * @param aParent parent view * @param aChild child view */ - NS_IMETHOD RemoveChild(nsView *aChild); + void RemoveChild(nsView *aChild); /** * Move a view to the specified position, provided in parent coordinates. @@ -168,7 +167,7 @@ public: * @param aX x value for new view position * @param aY y value for new view position */ - NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); + void MoveViewTo(nsView *aView, nscoord aX, nscoord aY); /** * Resize a view. In addition to setting the width and height, you can @@ -182,8 +181,8 @@ public: * if true Repaint only the expanded or contracted region, * if false Repaint the union of the old and new rectangles. */ - NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, - bool aRepaintExposedAreaOnly = false); + void ResizeView(nsView *aView, const nsRect &aRect, + bool aRepaintExposedAreaOnly = false); /** * Set the visibility of a view. Hidden views have the effect of hiding @@ -196,7 +195,7 @@ public: * @param aView view to change visibility state of * @param visible new visibility state */ - NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); + void SetViewVisibility(nsView *aView, nsViewVisibility aVisible); /** * Set the z-index of a view. Positive z-indices mean that a view @@ -214,7 +213,7 @@ public: * true if the view should be topmost when compared with * other z-index:auto views. */ - NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); + void SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); /** * Set whether the view "floats" above all other views, @@ -223,24 +222,24 @@ public: * this view. This is a hack, but it fixes some problems with * views that need to be drawn in front of all other views. */ - NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView); + void SetViewFloating(nsView *aView, bool aFloatingView); /** * Set the presshell associated with this manager * @param aPresShell - new presshell */ - virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } + void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } /** * Get the pres shell associated with this manager */ - virtual nsIPresShell* GetPresShell() { return mPresShell; } + nsIPresShell* GetPresShell() { return mPresShell; } /** * Get the device context associated with this manager * @result device context */ - NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); + void GetDeviceContext(nsDeviceContext *&aContext); /** * A stack class for disallowing changes that would enter painting. For @@ -276,15 +275,15 @@ public: private: friend class AutoDisableRefresh; - virtual nsViewManager* IncrementDisableRefreshCount(); - virtual void DecrementDisableRefreshCount(); + nsViewManager* IncrementDisableRefreshCount(); + void DecrementDisableRefreshCount(); public: /** * Retrieve the widget at the root of the nearest enclosing * view manager whose root view has a widget. */ - NS_IMETHOD GetRootWidget(nsIWidget **aWidget); + void GetRootWidget(nsIWidget **aWidget); /** * Indicate whether the viewmanager is currently painting @@ -292,7 +291,7 @@ public: * @param aPainting true if the viewmanager is painting * false otherwise */ - NS_IMETHOD IsPainting(bool& aIsPainting); + void IsPainting(bool& aIsPainting); /** * Retrieve the time of the last user event. User events @@ -301,7 +300,7 @@ public: * * @param aTime Last user event time in microseconds */ - NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); + void GetLastUserEventTime(uint32_t& aTime); /** * Find the nearest display root view for the view aView. This is the view for @@ -313,18 +312,17 @@ public: * Flush the accumulated dirty region to the widget and update widget * geometry. */ - virtual void ProcessPendingUpdates(); + void ProcessPendingUpdates(); /** * Just update widget geometry without flushing the dirty region */ - virtual void UpdateWidgetGeometry(); + void UpdateWidgetGeometry(); uint32_t AppUnitsPerDevPixel() const { return mContext->AppUnitsPerDevPixel(); } - nsView* GetRootViewImpl() const { return mRootView; } private: static uint32_t gLastUserEventTime; @@ -374,7 +372,7 @@ private: RootViewManager()->mPainting = aPainting; } - nsresult InvalidateView(nsView *aView, const nsRect &aRect); + void InvalidateView(nsView *aView, const nsRect &aRect); nsViewManager* RootViewManager() const { return mRootViewManager; } bool IsRootVM() const { return this == RootViewManager(); } diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 64b9ff50072c..fc54bee54f03 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -63,7 +63,7 @@ nsView::~nsView() { DropMouseGrabbing(); - nsView *rootView = mViewManager->GetRootViewImpl(); + nsView *rootView = mViewManager->GetRootView(); if (rootView) { @@ -225,7 +225,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize) { // The geometry of a root view's widget is controlled externally, // NOT by sizing or positioning the view - if (mViewManager->GetRootViewImpl() == this) { + if (mViewManager->GetRootView() == this) { return; } @@ -347,7 +347,7 @@ void nsView::SetFloating(bool aFloatingView) void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent) { - if (mViewManager->GetRootViewImpl() == this) + if (mViewManager->GetRootView() == this) mViewManager->InvalidateHierarchy(); for (nsView *child = mFirstChild; child; child = child->GetNextSibling()) @@ -380,7 +380,7 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // on all view managers in the new subtree. nsViewManager *vm = aChild->GetViewManagerInternal(); - if (vm->GetRootViewImpl() == aChild) + if (vm->GetRootView() == aChild) { aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs } @@ -416,7 +416,7 @@ void nsView::RemoveChild(nsView *child) // on all view managers in the removed subtree. nsViewManager *vm = child->GetViewManagerInternal(); - if (vm->GetRootViewImpl() == child) + if (vm->GetRootView() == child) { child->InvalidateHierarchy(GetViewManagerInternal()); } @@ -856,7 +856,7 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const bool nsView::IsRoot() const { NS_ASSERTION(mViewManager != nullptr," View manager is null in nsView::IsRoot()"); - return mViewManager->GetRootViewImpl() == this; + return mViewManager->GetRootView() == this; } nsRect @@ -864,7 +864,7 @@ nsView::GetBoundsInParentUnits() const { nsView* parent = GetParent(); nsViewManager* VM = GetViewManagerInternal(); - if (this != VM->GetRootViewImpl() || !parent) { + if (this != VM->GetRootView() || !parent) { return mDimBounds; } int32_t ourAPD = VM->AppUnitsPerDevPixel(); diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index d40d44a0a88c..9c39b195f032 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -124,7 +124,8 @@ nsViewManager::~nsViewManager() // We don't hold a reference to the presentation context because it // holds a reference to us. -NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) +nsresult +nsViewManager::Init(nsDeviceContext* aContext) { NS_PRECONDITION(nullptr != aContext, "null ptr"); @@ -139,7 +140,7 @@ NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) return NS_OK; } -NS_IMETHODIMP_(nsView *) +nsView* nsViewManager::CreateView(const nsRect& aBounds, const nsView* aParent, nsViewVisibility aVisibilityFlag) @@ -154,7 +155,8 @@ nsViewManager::CreateView(const nsRect& aBounds, return v; } -NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) +void +nsViewManager::SetRootView(nsView *aView) { NS_PRECONDITION(!aView || aView->GetViewManager() == this, "Unexpected viewmanager on root view"); @@ -176,11 +178,10 @@ NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) mRootView->SetZIndex(false, 0, false); } // Else don't touch mRootViewManager - - return NS_OK; } -NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) +void +nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) { if (nullptr != mRootView) { if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) { @@ -197,7 +198,6 @@ NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeig *aWidth = 0; *aHeight = 0; } - return NS_OK; } void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) @@ -213,7 +213,8 @@ void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) } } -NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) +void +nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) { if (mRootView) { if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { @@ -236,11 +237,10 @@ NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight } } } - - return NS_OK; } -NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow) +void +nsViewManager::FlushDelayedResize(bool aDoReflow) { if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) { if (aDoReflow) { @@ -253,7 +253,6 @@ NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow) } } } - return NS_OK; } // Convert aIn from being relative to and in appunits of aFromView, to being @@ -447,10 +446,11 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) dirtyRegion->SetEmpty(); } -NS_IMETHODIMP nsViewManager::InvalidateView(nsView *aView) +void +nsViewManager::InvalidateView(nsView *aView) { // Mark the entire view as damaged - return InvalidateView(aView, aView->GetDimensions()); + InvalidateView(aView, aView->GetDimensions()); } static void @@ -569,19 +569,21 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) return false; } -nsresult nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect) +void +nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect) { // If painting is suppressed in the presshell or an ancestor drop all // invalidates, it will invalidate everything when it unsuppresses. if (ShouldIgnoreInvalidation(this)) { - return NS_OK; + return; } - return InvalidateViewNoSuppression(aView, aRect); + InvalidateViewNoSuppression(aView, aRect); } -NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, - const nsRect &aRect) +void +nsViewManager::InvalidateViewNoSuppression(nsView *aView, + const nsRect &aRect) { NS_PRECONDITION(nullptr != aView, "null view"); @@ -590,7 +592,7 @@ NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, nsRect damagedRect(aRect); if (damagedRect.IsEmpty()) { - return NS_OK; + return; } nsView* displayRoot = GetDisplayRootFor(aView); @@ -606,18 +608,16 @@ NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, // accumulate this rectangle in the view's dirty region, so we can // process it later. AddDirtyRegion(displayRoot, nsRegion(damagedRect)); - - return NS_OK; } -NS_IMETHODIMP nsViewManager::InvalidateAllViews() +void +nsViewManager::InvalidateAllViews() { if (RootViewManager() != this) { return RootViewManager()->InvalidateAllViews(); } InvalidateViews(mRootView); - return NS_OK; } void nsViewManager::InvalidateViews(nsView *aView) @@ -708,7 +708,8 @@ void nsViewManager::DidPaintWindow() } } -nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) +void +nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) { SAMPLE_LABEL("event", "nsViewManager::DispatchEvent"); @@ -759,13 +760,11 @@ nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEvent // want to cause its destruction in, say, some JavaScript event handler. nsCOMPtr shell = view->GetViewManager()->GetPresShell(); if (shell) { - return shell->HandleEvent(frame, aEvent, false, aStatus); + shell->HandleEvent(frame, aEvent, false, aStatus); } } *aStatus = nsEventStatus_eIgnore; - - return NS_OK; } // Recursively reparent widgets if necessary @@ -829,8 +828,9 @@ void nsViewManager::ReparentWidgets(nsView* aView, nsView *aParent) } } -NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter) +void +nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, + bool aAfter) { NS_PRECONDITION(nullptr != aParent, "null ptr"); NS_PRECONDITION(nullptr != aChild, "null ptr"); @@ -891,20 +891,21 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView if (nsViewVisibility_kHide != aChild->GetVisibility()) aChild->GetViewManagerInternal()->InvalidateView(aChild); } - return NS_OK; } -NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex) +void +nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex) { // no-one really calls this with anything other than aZIndex == 0 on a fresh view // XXX this method should simply be eliminated and its callers redirected to the real method SetViewZIndex(aChild, false, aZIndex, false); - return InsertChild(aParent, aChild, nullptr, true); + InsertChild(aParent, aChild, nullptr, true); } -NS_IMETHODIMP nsViewManager::RemoveChild(nsView *aChild) +void +nsViewManager::RemoveChild(nsView *aChild) { - NS_ENSURE_ARG_POINTER(aChild); + NS_ASSERTION(aChild, "aChild must not be null"); nsView* parent = aChild->GetParent(); @@ -914,11 +915,10 @@ NS_IMETHODIMP nsViewManager::RemoveChild(nsView *aChild) aChild->GetViewManagerInternal()->InvalidateView(aChild); parent->RemoveChild(aChild); } - - return NS_OK; } -NS_IMETHODIMP nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) +void +nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); nsPoint oldPt = aView->GetPosition(); @@ -937,7 +937,6 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) } } } - return NS_OK; } void nsViewManager::InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, @@ -971,7 +970,8 @@ void nsViewManager::InvalidateRectDifference(nsView *aView, const nsRect& aRect, } } -NS_IMETHODIMP nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly) +void +nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -1006,20 +1006,18 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool // in the case where mClipRect has been optimized away to just be a null // pointer, and this resize is implicitly changing the clip rect, it's OK // because layout will change it back again if necessary. - - return NS_OK; } -NS_IMETHODIMP nsViewManager::SetViewFloating(nsView *aView, bool aFloating) +void +nsViewManager::SetViewFloating(nsView *aView, bool aFloating) { NS_ASSERTION(!(nullptr == aView), "no view"); aView->SetFloating(aFloating); - - return NS_OK; } -NS_IMETHODIMP nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) +void +nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -1041,7 +1039,6 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility a } } } - return NS_OK; } bool nsViewManager::IsViewInserted(nsView *aView) @@ -1062,16 +1059,15 @@ bool nsViewManager::IsViewInserted(nsView *aView) } } -NS_IMETHODIMP nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost) +void +nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost) { - nsresult rv = NS_OK; - NS_ASSERTION((aView != nullptr), "no view"); // don't allow the root view's z-index to be changed. It should always be zero. // This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences if (aView == mRootView) { - return rv; + return; } bool oldTopMost = aView->IsTopMost(); @@ -1088,15 +1084,13 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int3 oldIsAuto != aAutoZIndex) { InvalidateView(aView); } - - return rv; } -NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) +void +nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) { aContext = mContext; NS_IF_ADDREF(aContext); - return NS_OK; } nsViewManager* @@ -1119,21 +1113,23 @@ nsViewManager::DecrementDisableRefreshCount() NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!"); } -NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget) +void +nsViewManager::GetRootWidget(nsIWidget **aWidget) { if (!mRootView) { *aWidget = nullptr; - return NS_OK; + return; } if (mRootView->HasWidget()) { *aWidget = mRootView->GetWidget(); NS_ADDREF(*aWidget); - return NS_OK; + return; + } + if (mRootView->GetParent()) { + mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); + return; } - if (mRootView->GetParent()) - return mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); *aWidget = nullptr; - return NS_OK; } nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const @@ -1147,11 +1143,10 @@ nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const return rect.ToOutsidePixels(AppUnitsPerDevPixel()); } -NS_IMETHODIMP +void nsViewManager::IsPainting(bool& aIsPainting) { aIsPainting = IsPainting(); - return NS_OK; } void @@ -1214,11 +1209,10 @@ nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint) } } -NS_IMETHODIMP +void nsViewManager::GetLastUserEventTime(uint32_t& aTime) { aTime = gLastUserEventTime; - return NS_OK; } void From 263a950638647d94effe33de6db6a22edf4ec713 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:13:13 +1300 Subject: [PATCH 122/180] Bug 826632. Part 6: Remove some unnecessary #includes from nsView.h and nsViewManager.h. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : 10a50ae18eeff3a26862bad50549f7556593a0a6 --- view/public/nsView.h | 6 ------ view/public/nsViewManager.h | 5 ----- 2 files changed, 11 deletions(-) diff --git a/view/public/nsView.h b/view/public/nsView.h index 686a97abc3d6..42ae807d3526 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -6,19 +6,13 @@ #ifndef nsView_h__ #define nsView_h__ -#include "nsISupports.h" #include "nsCoord.h" #include "nsRect.h" #include "nsPoint.h" -#include "nsNativeWidget.h" -#include "nsIWidget.h" -#include "nsWidgetInitData.h" #include "nsRegion.h" #include "nsCRT.h" -#include "nsIFactory.h" #include "nsEvent.h" #include "nsIWidgetListener.h" -#include class nsViewManager; class nsIWidget; diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index bfc729758f2e..f5ba8823e065 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -11,12 +11,7 @@ #include "nsEvent.h" #include "nsCOMPtr.h" #include "nsCRT.h" -#include "nsITimer.h" -#include "prtime.h" -#include "prinrval.h" #include "nsVoidArray.h" -#include "nsThreadUtils.h" -#include "nsIPresShell.h" #include "nsDeviceContext.h" class nsIWidget; From 616220b0c8f0ac0eaee5eb2dcc71a805fd507129 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:13:23 +1300 Subject: [PATCH 123/180] Bug 826632. Part 7: nsView::GetViewManagerInternal is no longer relevant, so remove it. r=tnikkel --HG-- extra : rebase_source : ee90c4205d54efc1a7fa248a60d82fa51a07f19a --- view/public/nsView.h | 4 +--- view/src/nsView.cpp | 30 +++++++++++++++--------------- view/src/nsViewManager.cpp | 30 +++++++++++++++--------------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/view/public/nsView.h b/view/public/nsView.h index 42ae807d3526..9e2d9f02c728 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -68,9 +68,7 @@ public: * view manager from somewhere else, do that instead. * @result the view manager */ - nsViewManager* GetViewManager() const - { return reinterpret_cast(mViewManager); } - nsViewManager* GetViewManagerInternal() const { return mViewManager; } + nsViewManager* GetViewManager() const { return mViewManager; } /** * Find the view for the given widget, if there is one. diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index fc54bee54f03..a2dc372a6fdb 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -379,7 +379,7 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // If we just inserted a root view, then update the RootViewManager // on all view managers in the new subtree. - nsViewManager *vm = aChild->GetViewManagerInternal(); + nsViewManager *vm = aChild->GetViewManager(); if (vm->GetRootView() == aChild) { aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs @@ -415,10 +415,10 @@ void nsView::RemoveChild(nsView *child) // If we just removed a root view, then update the RootViewManager // on all view managers in the removed subtree. - nsViewManager *vm = child->GetViewManagerInternal(); + nsViewManager *vm = child->GetViewManager(); if (vm->GetRootView() == child) { - child->InvalidateHierarchy(GetViewManagerInternal()); + child->InvalidateHierarchy(GetViewManager()); } } } @@ -736,7 +736,7 @@ void nsView::List(FILE* out, int32_t aIndent) const nsPoint nsView::GetOffsetTo(const nsView* aOther) const { - return GetOffsetTo(aOther, GetViewManagerInternal()->AppUnitsPerDevPixel()); + return GetOffsetTo(aOther, GetViewManager()->AppUnitsPerDevPixel()); } nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const @@ -749,11 +749,11 @@ nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const // The offset currently accumulated at the current APD nsPoint docOffset(0, 0); const nsView* v = this; - nsViewManager* currVM = v->GetViewManagerInternal(); + nsViewManager* currVM = v->GetViewManager(); int32_t currAPD = currVM->AppUnitsPerDevPixel(); const nsView* root = nullptr; for ( ; v != aOther && v; root = v, v = v->GetParent()) { - nsViewManager* newVM = v->GetViewManagerInternal(); + nsViewManager* newVM = v->GetViewManager(); if (newVM != currVM) { int32_t newAPD = newVM->AppUnitsPerDevPixel(); if (newAPD != currAPD) { @@ -799,15 +799,15 @@ nsPoint nsView::GetOffsetToWidget(nsIWidget* aWidget) const pt += widgetView->ViewToWidgetOffset(); // Convert to our appunits. - int32_t widgetAPD = widgetView->GetViewManagerInternal()->AppUnitsPerDevPixel(); - int32_t ourAPD = GetViewManagerInternal()->AppUnitsPerDevPixel(); + int32_t widgetAPD = widgetView->GetViewManager()->AppUnitsPerDevPixel(); + int32_t ourAPD = GetViewManager()->AppUnitsPerDevPixel(); pt = pt.ConvertAppUnits(widgetAPD, ourAPD); return pt; } nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset) const { - return GetNearestWidget(aOffset, GetViewManagerInternal()->AppUnitsPerDevPixel()); + return GetNearestWidget(aOffset, GetViewManager()->AppUnitsPerDevPixel()); } nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const @@ -820,10 +820,10 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const // The offset currently accumulated at the current APD nsPoint docPt(0,0); const nsView* v = this; - nsViewManager* currVM = v->GetViewManagerInternal(); + nsViewManager* currVM = v->GetViewManager(); int32_t currAPD = currVM->AppUnitsPerDevPixel(); for ( ; v && !v->HasWidget(); v = v->GetParent()) { - nsViewManager* newVM = v->GetViewManagerInternal(); + nsViewManager* newVM = v->GetViewManager(); if (newVM != currVM) { int32_t newAPD = newVM->AppUnitsPerDevPixel(); if (newAPD != currAPD) { @@ -863,12 +863,12 @@ nsRect nsView::GetBoundsInParentUnits() const { nsView* parent = GetParent(); - nsViewManager* VM = GetViewManagerInternal(); + nsViewManager* VM = GetViewManager(); if (this != VM->GetRootView() || !parent) { return mDimBounds; } int32_t ourAPD = VM->AppUnitsPerDevPixel(); - int32_t parentAPD = parent->GetViewManagerInternal()->AppUnitsPerDevPixel(); + int32_t parentAPD = parent->GetViewManager()->AppUnitsPerDevPixel(); return mDimBounds.ConvertAppUnitsRoundOut(ourAPD, parentAPD); } @@ -877,8 +877,8 @@ nsView::ConvertFromParentCoords(nsPoint aPt) const { const nsView* parent = GetParent(); if (parent) { - aPt = aPt.ConvertAppUnits(parent->GetViewManagerInternal()->AppUnitsPerDevPixel(), - GetViewManagerInternal()->AppUnitsPerDevPixel()); + aPt = aPt.ConvertAppUnits(parent->GetViewManager()->AppUnitsPerDevPixel(), + GetViewManager()->AppUnitsPerDevPixel()); } aPt -= GetPosition(); return aPt; diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 9c39b195f032..f743de0f77b7 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -264,8 +264,8 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn, nsRegion out = aIn; out.MoveBy(aFromView->GetOffsetTo(aToView)); out = out.ConvertAppUnitsRoundOut( - aFromView->GetViewManagerInternal()->AppUnitsPerDevPixel(), - aToView->GetViewManagerInternal()->AppUnitsPerDevPixel()); + aFromView->GetViewManager()->AppUnitsPerDevPixel(), + aToView->GetViewManager()->AppUnitsPerDevPixel()); return out; } @@ -396,7 +396,7 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // have a delayed resize to handle. for (nsViewManager *vm = this; vm; vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManagerInternal() + ? vm->mRootView->GetParent()->GetViewManager() : nullptr) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && vm->mRootView->IsEffectivelyVisible() && @@ -441,7 +441,7 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) } nsRegion r = ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget); - nsViewManager* widgetVM = nearestViewWithWidget->GetViewManagerInternal(); + nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager(); widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r); dirtyRegion->SetEmpty(); } @@ -564,7 +564,7 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) return true; } nsView* view = aVM->GetRootView()->GetParent(); - aVM = view ? view->GetViewManagerInternal() : nullptr; + aVM = view ? view->GetViewManager() : nullptr; } return false; } @@ -596,7 +596,7 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView, } nsView* displayRoot = GetDisplayRootFor(aView); - nsViewManager* displayRootVM = displayRoot->GetViewManagerInternal(); + nsViewManager* displayRootVM = displayRoot->GetViewManager(); // Propagate the update to the displayRoot, since iframes, for example, // can overlap each other and be translucent. So we have to possibly // invalidate our rect in each of the widgets we have lying about. @@ -628,7 +628,7 @@ void nsViewManager::InvalidateViews(nsView *aView) // Invalidate all children as well. nsView* childView = aView->GetFirstChild(); while (nullptr != childView) { - childView->GetViewManagerInternal()->InvalidateViews(childView); + childView->GetViewManager()->InvalidateViews(childView); childView = childView->GetNextSibling(); } } @@ -640,7 +640,7 @@ void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) // have a delayed resize to handle. for (nsViewManager *vm = this; vm; vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManagerInternal() + ? vm->mRootView->GetParent()->GetViewManager() : nullptr) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && vm->mRootView->IsEffectivelyVisible() && @@ -889,7 +889,7 @@ nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, //and mark this area as dirty if the view is visible... if (nsViewVisibility_kHide != aChild->GetVisibility()) - aChild->GetViewManagerInternal()->InvalidateView(aChild); + aChild->GetViewManager()->InvalidateView(aChild); } } @@ -912,7 +912,7 @@ nsViewManager::RemoveChild(nsView *aChild) if (nullptr != parent) { NS_ASSERTION(aChild->GetViewManager() == this || parent->GetViewManager() == this, "wrong view manager"); - aChild->GetViewManagerInternal()->InvalidateView(aChild); + aChild->GetViewManager()->InvalidateView(aChild); parent->RemoveChild(aChild); } } @@ -931,7 +931,7 @@ nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) if (aView->GetVisibility() != nsViewVisibility_kHide) { nsView* parentView = aView->GetParent(); if (parentView) { - nsViewManager* parentVM = parentView->GetViewManagerInternal(); + nsViewManager* parentVM = parentView->GetViewManager(); parentVM->InvalidateView(parentView, oldBounds); parentVM->InvalidateView(parentView, aView->GetBoundsInParentUnits()); } @@ -988,7 +988,7 @@ nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExpos } nsRect oldBounds = aView->GetBoundsInParentUnits(); aView->SetDimensions(aRect, true); - nsViewManager* parentVM = parentView->GetViewManagerInternal(); + nsViewManager* parentVM = parentView->GetViewManager(); if (!aRepaintExposedAreaOnly) { // Invalidate the union of the old and new size InvalidateView(aView, aRect); @@ -1029,7 +1029,7 @@ nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) if (nsViewVisibility_kHide == aVisible) { nsView* parentView = aView->GetParent(); if (parentView) { - parentView->GetViewManagerInternal()-> + parentView->GetViewManager()-> InvalidateView(parentView, aView->GetBoundsInParentUnits()); } } @@ -1126,7 +1126,7 @@ nsViewManager::GetRootWidget(nsIWidget **aWidget) return; } if (mRootView->GetParent()) { - mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); + mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget); return; } *aWidget = nullptr; @@ -1224,7 +1224,7 @@ nsViewManager::InvalidateHierarchy() } nsView *parent = mRootView->GetParent(); if (parent) { - mRootViewManager = parent->GetViewManagerInternal()->RootViewManager(); + mRootViewManager = parent->GetViewManager()->RootViewManager(); NS_ADDREF(mRootViewManager); NS_ASSERTION(mRootViewManager != this, "Root view had a parent, but it has the same view manager"); From 2d87545673884764a961d60e5062585438988d1b Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:14:17 +1300 Subject: [PATCH 124/180] Bug 826635. Refresh-driver painting is always enabled now, so remove the alternative code path. r=mattwoodrow --HG-- extra : rebase_source : 3fcd1e59af66d195af62e46a3a9dacc0e074550c --- view/src/nsViewManager.cpp | 133 +++++++++++-------------------------- 1 file changed, 39 insertions(+), 94 deletions(-) diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index f743de0f77b7..b51d1fd34953 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -46,22 +46,6 @@ #undef DEBUG_MOUSE_LOCATION -static bool -IsRefreshDriverPaintingEnabled() -{ - static bool sRefreshDriverPaintingEnabled; - static bool sRefreshDriverPaintingPrefCached = false; - - if (!sRefreshDriverPaintingPrefCached) { - sRefreshDriverPaintingPrefCached = true; - mozilla::Preferences::AddBoolVarCache(&sRefreshDriverPaintingEnabled, - "viewmanager.refresh-driver-painting.enabled", - true); - } - - return sRefreshDriverPaintingEnabled; -} - int32_t nsViewManager::mVMCount = 0; // Weakly held references to all of the view managers @@ -348,7 +332,6 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion, printf("--COMPOSITE-- %p\n", mPresShell); #endif mPresShell->Paint(aView, damageRegion, - (IsRefreshDriverPaintingEnabled() ? 0 : nsIPresShell::PAINT_LAYERS) | nsIPresShell::PAINT_COMPOSITE | (aWillSendDidPaint ? nsIPresShell::PAINT_WILL_SEND_DID_PAINT : 0)); #ifdef DEBUG_INVALIDATIONS @@ -389,40 +372,38 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // Push out updates after we've processed the children; ensures that // damage is applied based on the final widget geometry if (aFlushDirtyRegion) { - if (IsRefreshDriverPaintingEnabled()) { - nsIWidget *widget = aView->GetWidget(); - if (widget && widget->NeedsPaint()) { - // If an ancestor widget was hidden and then shown, we could - // have a delayed resize to handle. - for (nsViewManager *vm = this; vm; - vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManager() - : nullptr) { - if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && - vm->mRootView->IsEffectivelyVisible() && - mPresShell && mPresShell->IsVisible()) { - vm->FlushDelayedResize(true); - vm->InvalidateView(vm->mRootView); - } + nsIWidget *widget = aView->GetWidget(); + if (widget && widget->NeedsPaint()) { + // If an ancestor widget was hidden and then shown, we could + // have a delayed resize to handle. + for (nsViewManager *vm = this; vm; + vm = vm->mRootView->GetParent() + ? vm->mRootView->GetParent()->GetViewManager() + : nullptr) { + if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && + vm->mRootView->IsEffectivelyVisible() && + mPresShell && mPresShell->IsVisible()) { + vm->FlushDelayedResize(true); + vm->InvalidateView(vm->mRootView); } - - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - - SetPainting(true); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); -#endif - nsAutoScriptBlocker scriptBlocker; - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - mPresShell->Paint(aView, nsRegion(), - nsIPresShell::PAINT_LAYERS | - nsIPresShell::PAINT_WILL_SEND_DID_PAINT); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT END ----\n"); -#endif - aView->SetForcedRepaint(false); - SetPainting(false); } + + NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); + + SetPainting(true); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); +#endif + nsAutoScriptBlocker scriptBlocker; + NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); + mPresShell->Paint(aView, nsRegion(), + nsIPresShell::PAINT_LAYERS | + nsIPresShell::PAINT_WILL_SEND_DID_PAINT); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT END ----\n"); +#endif + aView->SetForcedRepaint(false); + SetPainting(false); } FlushDirtyRegionToWidget(aView); } @@ -635,30 +616,7 @@ void nsViewManager::InvalidateViews(nsView *aView) void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - if (!IsRefreshDriverPaintingEnabled() && aWidget && mContext) { - // If an ancestor widget was hidden and then shown, we could - // have a delayed resize to handle. - for (nsViewManager *vm = this; vm; - vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManager() - : nullptr) { - if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && - vm->mRootView->IsEffectivelyVisible() && - mPresShell && mPresShell->IsVisible()) { - vm->FlushDelayedResize(true); - vm->InvalidateView(vm->mRootView); - } - } - - // Flush things like reflows by calling WillPaint on observer presShells. - nsRefPtr rootVM = RootViewManager(); - rootVM->CallWillPaintOnObservers(aWillSendDidPaint); - - // Flush view widget geometry updates and invalidations. - rootVM->ProcessPendingUpdates(); - } - - if (aWidget && IsRefreshDriverPaintingEnabled()) { + if (aWidget) { nsView* view = nsView::GetViewFor(aWidget); if (view && view->ForcedRepaint()) { ProcessPendingUpdates(); @@ -686,10 +644,6 @@ bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, NS_ASSERTION(IsPaintingAllowed(), "shouldn't be receiving paint events while painting is disallowed!"); - if (!(aFlags & nsIWidgetListener::SENT_WILL_PAINT) && !IsRefreshDriverPaintingEnabled()) { - WillPaintWindow(aWidget, (aFlags & nsIWidgetListener::WILL_SEND_DID_PAINT)); - } - // Get the view pointer here since NS_WILL_PAINT might have // destroyed it during CallWillPaintOnObservers (bug 378273). nsView* view = nsView::GetViewFor(aWidget); @@ -1052,7 +1006,7 @@ bool nsViewManager::IsViewInserted(nsView *aView) while (view != nullptr) { if (view == aView) { return true; - } + } view = view->GetNextSibling(); } return false; @@ -1157,17 +1111,13 @@ nsViewManager::ProcessPendingUpdates() return; } - if (IsRefreshDriverPaintingEnabled()) { - mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush(); - - // Flush things like reflows by calling WillPaint on observer presShells. - if (mPresShell) { - CallWillPaintOnObservers(true); - } - ProcessPendingUpdatesForView(mRootView, true); - } else { - ProcessPendingUpdatesForView(mRootView, true); + mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush(); + + // Flush things like reflows by calling WillPaint on observer presShells. + if (mPresShell) { + CallWillPaintOnObservers(true); } + ProcessPendingUpdatesForView(mRootView, true); } void @@ -1179,13 +1129,8 @@ nsViewManager::UpdateWidgetGeometry() } if (mHasPendingWidgetGeometryChanges) { - if (IsRefreshDriverPaintingEnabled()) { - mHasPendingWidgetGeometryChanges = false; - } + mHasPendingWidgetGeometryChanges = false; ProcessPendingUpdatesForView(mRootView, false); - if (!IsRefreshDriverPaintingEnabled()) { - mHasPendingWidgetGeometryChanges = false; - } } } From a8274df1f4d1b2bd2c4b6c113fbf4548730789b6 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 5 Jan 2013 12:55:22 +0900 Subject: [PATCH 125/180] Bug 795433 - Use #define for nsresult values in C code. r=ehsan,glandium; feedback=njn --- xpcom/base/Makefile.in | 15 +++++++++++---- xpcom/base/nsError.h | 21 ++++++++++++++------- xpcom/typelib/xpt/src/Makefile.in | 2 ++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/xpcom/base/Makefile.in b/xpcom/base/Makefile.in index 56730585c290..51de8df87581 100644 --- a/xpcom/base/Makefile.in +++ b/xpcom/base/Makefile.in @@ -109,7 +109,8 @@ SDK_HEADERS = \ nsAutoPtr.h \ nsError.h \ ErrorList.h \ - ErrorListDefines.h \ + ErrorListCxxDefines.h \ + ErrorListCDefines.h \ nsISupportsBase.h \ nscore.h \ nsAtomicRefcnt.h \ @@ -163,10 +164,16 @@ LOCAL_INCLUDES += \ -I$(topsrcdir)/xpcom/ds \ $(NULL) -# We generate ErrorListDefines.h from ErrorList.h using regex. The -n option +# We generate ErrorListCxxDefines.h from ErrorList.h using regex. The -n option # suppresses printing the pattern space, and the p at the end prints it anyway, # so we don't print lines that don't match the pattern to start with. -ErrorListDefines.h: ErrorList.h +ErrorListCxxDefines.h: ErrorList.h Makefile sed -n 's/.*ERROR(\([A-Z_0-9]*\).*/#define \1 nsresult::\1/p' < $< > $@ -GARBAGE += ErrorListDefines.h +ErrorListCDefines.h: ErrorList.h Makefile + sed 's/.*ERROR(\([A-Z_0-9]*\),\( *\)\(.*\))[^)]*/#define \1 \2((nsresult)(\3))/' < $< > $@ + +GARBAGE += \ + ErrorListCxxDefines.h \ + ErrorListCDefines.h \ + $(NULL) diff --git a/xpcom/base/nsError.h b/xpcom/base/nsError.h index 819d436604ad..20e5bb72b837 100644 --- a/xpcom/base/nsError.h +++ b/xpcom/base/nsError.h @@ -117,16 +117,16 @@ * return foo ? F() : NS_ERROR_FAILURE; * to fail, because nsresult and nsresult::Enum are two distinct types and * either can be converted to the other, so it's ambiguous. So we have to fall - * back to a regular enum. Fortunately, we need to support that anyway for the - * sake of C, so it's not a big deal. + * back to a regular enum. */ -#if defined(__cplusplus) && defined(MOZ_HAVE_CXX11_STRONG_ENUMS) +#if defined(__cplusplus) +#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) typedef enum class tag_nsresult : uint32_t -#elif defined(__cplusplus) && defined(MOZ_HAVE_CXX11_ENUM_TYPE) +#elif defined(MOZ_HAVE_CXX11_ENUM_TYPE) /* Need underlying type for workaround of Microsoft compiler (Bug 794734) */ typedef enum tag_nsresult : uint32_t #else - /* C, or no strong enums */ + /* no strong enums */ typedef enum tag_nsresult #endif { @@ -136,11 +136,18 @@ #undef ERROR } nsresult; -#if defined(__cplusplus) && defined(MOZ_HAVE_CXX11_STRONG_ENUMS) +#if defined(MOZ_HAVE_CXX11_STRONG_ENUMS) /* We're using enum classes, so we need #define's to put the constants in * global scope for compatibility with old code. */ - #include "ErrorListDefines.h" + #include "ErrorListCxxDefines.h" #endif +#else /* defined(__cplusplus) */ + /* C enum can't have a value outside the range of 'int'. + * C const can't initialize with an expression involving other variables + * even if it is const. So we have to fall back to bad old #defines. */ + typedef uint32_t nsresult; + #include "ErrorListCDefines.h" +#endif /* defined(__cplusplus) */ #undef SUCCESS_OR_FAILURE #undef SUCCESS diff --git a/xpcom/typelib/xpt/src/Makefile.in b/xpcom/typelib/xpt/src/Makefile.in index 582ebaacc052..cf3390130474 100644 --- a/xpcom/typelib/xpt/src/Makefile.in +++ b/xpcom/typelib/xpt/src/Makefile.in @@ -32,6 +32,7 @@ DEFINES += -DEXPORT_XPT_API # Build libxpt early so that it'll be available to xpidl, which also # must be built early. export:: + @$(MAKE) -C ../../../base ErrorListCDefines.h @$(MAKE) libs # XXX, bug 417045, make -jN combines badly with -save-temps in @@ -46,5 +47,6 @@ endif LOCAL_INCLUDES += \ -I../../../ \ + -I../../../base \ -I$(topsrcdir)/xpcom/base \ $(NULL) From a8668b36065f2f660fd860c2447fd10ec47718de Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sat, 5 Jan 2013 12:55:23 +0900 Subject: [PATCH 126/180] Bug 826613 - Enable FAIL_ON_WARNINGS on MSVC in image/. r=joe --- .../svg/content/src/SVGPreserveAspectRatio.h | 4 ++-- image/build/Makefile.in | 2 -- image/src/BMPFileHeaders.h | 4 +++- image/src/ImageFactory.h | 3 ++- image/src/Makefile.in | 2 -- image/src/RasterImage.cpp | 18 +++++++++++++++--- image/src/imgRequest.cpp | 3 ++- image/src/imgStatusTracker.cpp | 5 +++-- media/libjpeg/jmorecfg.h | 3 +++ 9 files changed, 30 insertions(+), 14 deletions(-) diff --git a/content/svg/content/src/SVGPreserveAspectRatio.h b/content/svg/content/src/SVGPreserveAspectRatio.h index ad1ff411428b..9cb0a21b7d5b 100644 --- a/content/svg/content/src/SVGPreserveAspectRatio.h +++ b/content/svg/content/src/SVGPreserveAspectRatio.h @@ -38,8 +38,8 @@ class SVGPreserveAspectRatio friend class SVGAnimatedPreserveAspectRatio; public: SVGPreserveAspectRatio(uint16_t aAlign, uint16_t aMeetOrSlice, bool aDefer = false) - : mAlign(aAlign) - , mMeetOrSlice(aMeetOrSlice) + : mAlign(static_cast(aAlign)) + , mMeetOrSlice(static_cast(aMeetOrSlice)) , mDefer(aDefer) {} diff --git a/image/build/Makefile.in b/image/build/Makefile.in index 79db5466c1be..e73b80807aa5 100644 --- a/image/build/Makefile.in +++ b/image/build/Makefile.in @@ -17,9 +17,7 @@ IS_COMPONENT = 1 MODULE_NAME = nsImageLib2Module GRE_MODULE = 1 LIBXUL_LIBRARY = 1 -ifndef _MSC_VER FAIL_ON_WARNINGS = 1 -endif # !_MSC_VER CPPSRCS = \ nsImageModule.cpp \ diff --git a/image/src/BMPFileHeaders.h b/image/src/BMPFileHeaders.h index 3964e1982874..1ebd78b49ba4 100644 --- a/image/src/BMPFileHeaders.h +++ b/image/src/BMPFileHeaders.h @@ -35,8 +35,10 @@ namespace mozilla { #define WIN_V3_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V3_INTERNAL_BIH_LENGTH) #define WIN_V5_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V5_INTERNAL_BIH_LENGTH) +#ifndef LCS_sRGB #define LCS_sRGB 0x73524742 - +#endif + struct xyz { int32_t x, y, z; }; diff --git a/image/src/ImageFactory.h b/image/src/ImageFactory.h index a285a3e52773..e1f6d4560992 100644 --- a/image/src/ImageFactory.h +++ b/image/src/ImageFactory.h @@ -17,8 +17,9 @@ namespace image { extern const char* SVG_MIMETYPE; -struct ImageFactory +class ImageFactory { +public: /** * Creates a new image with the given properties. * diff --git a/image/src/Makefile.in b/image/src/Makefile.in index eb160cee1538..ddb7f443ed4e 100644 --- a/image/src/Makefile.in +++ b/image/src/Makefile.in @@ -16,9 +16,7 @@ FORCE_STATIC_LIB = 1 MODULE_NAME = nsImageLib2Module GRE_MODULE = 1 LIBXUL_LIBRARY = 1 -ifndef _MSC_VER FAIL_ON_WARNINGS = 1 -endif # !_MSC_VER EXPORTS = imgLoader.h \ diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 7981e008f65a..225fced32a20 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -150,8 +150,9 @@ DiscardingEnabled() return enabled; } -struct ScaleRequest +class ScaleRequest { +public: ScaleRequest(RasterImage* aImage, const gfxSize& aScale, imgFrame* aSrcFrame) : scale(aScale) , dstLocked(false) @@ -364,7 +365,16 @@ RasterImage::RasterImage(imgStatusTracker* aStatusTracker, mLoopCount(-1), mLockCount(0), mDecoder(nullptr), +// We know DecodeRequest won't touch members of RasterImage +// until this constructor completes +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4355) +#endif mDecodeRequest(this), +#ifdef _MSC_VER +#pragma warning(pop) +#endif mBytesDecoded(0), mDecodeCount(0), #ifdef DEBUG @@ -842,10 +852,12 @@ RasterImage::GetCurrentImgFrameEndTime() const // doesn't work correctly if we have a negative timeout value. The reason // this positive infinity was chosen was because it works with the loop in // RequestRefresh() above. - return TimeStamp() + TimeDuration::FromMilliseconds(UINT64_MAX); + return TimeStamp() + + TimeDuration::FromMilliseconds(static_cast(UINT64_MAX)); } - TimeDuration durationOfTimeout = TimeDuration::FromMilliseconds(timeout); + TimeDuration durationOfTimeout = + TimeDuration::FromMilliseconds(static_cast(timeout)); TimeStamp currentFrameEndTime = currentFrameTime + durationOfTimeout; return currentFrameEndTime; diff --git a/image/src/imgRequest.cpp b/image/src/imgRequest.cpp index dda406eb9e9b..dae7c80dbddf 100644 --- a/image/src/imgRequest.cpp +++ b/image/src/imgRequest.cpp @@ -767,7 +767,8 @@ imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, // Now we can create a new image to hold the data. If we don't have a decoder // for this mimetype we'll find out about it here. mImage = ImageFactory::CreateImage(aRequest, mStatusTracker, mContentType, - mURI, mIsMultiPartChannel, mInnerWindowId); + mURI, mIsMultiPartChannel, + static_cast(mInnerWindowId)); // Release our copy of the status tracker since the image owns it now. mStatusTracker = nullptr; diff --git a/image/src/imgStatusTracker.cpp b/image/src/imgStatusTracker.cpp index 972b0b3f7101..42eae6a8629f 100644 --- a/image/src/imgStatusTracker.cpp +++ b/image/src/imgStatusTracker.cpp @@ -186,13 +186,14 @@ private: imgStatusTracker::imgStatusTracker(Image* aImage) : mImage(aImage), - mTrackerObserver(new imgStatusTrackerObserver(this)), mState(0), mImageStatus(imgIRequest::STATUS_NONE), mIsMultipart(false), mHadLastPart(false), mBlockingOnload(false) -{} +{ + mTrackerObserver = new imgStatusTrackerObserver(this); +} imgStatusTracker::imgStatusTracker(const imgStatusTracker& aOther) : mImage(aOther.mImage), diff --git a/media/libjpeg/jmorecfg.h b/media/libjpeg/jmorecfg.h index 62dbd78fdc2e..e5e94e181fdf 100644 --- a/media/libjpeg/jmorecfg.h +++ b/media/libjpeg/jmorecfg.h @@ -196,8 +196,11 @@ typedef unsigned int JDIMENSION; */ #ifdef NEED_FAR_POINTERS +#ifndef FAR #define FAR far +#endif #else +#undef FAR #define FAR #endif From b17ad863b09d302716a61d9392aa7f42c50225f4 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Fri, 4 Jan 2013 20:05:44 -0800 Subject: [PATCH 127/180] Bug 824862: Don't skip over generated-content children of a flex container, even if they look like whitespace. r=bz --- layout/base/nsCSSFrameConstructor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 0b8905a9c6d3..271102f07fcd 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -9532,7 +9532,15 @@ nsCSSFrameConstructor::CreateNeededAnonFlexItems( // there's anything wrappable immediately after it. If not, we just drop // the whitespace and move on. (We're not supposed to create any anonymous // flex items that _only_ contain whitespace). - if (iter.item().IsWhitespace(aState)) { + // (BUT if this is generated content, then we don't give whitespace nodes + // any special treatment, because they're probably not really whitespace -- + // they're just temporarily empty, waiting for their generated text.) + // XXXdholbert If this node's generated text will *actually end up being + // entirely whitespace*, then we technically should still skip over it, per + // the flexbox spec. I'm not bothering with that at this point, since it's + // a pretty extreme edge case. + if (!aParentFrame->IsGeneratedContentFrame() && + iter.item().IsWhitespace(aState)) { FCItemIterator afterWhitespaceIter(iter); bool hitEnd = afterWhitespaceIter.SkipWhitespace(aState); bool nextChildNeedsAnonFlexItem = From 2ad944e28e318e3432cc194ed704d665e69ad22d Mon Sep 17 00:00:00 2001 From: Gina Yeh Date: Sat, 5 Jan 2013 12:34:19 +0800 Subject: [PATCH 128/180] Bug 826463 - Patch 1(v1): After disconnect BT headset while in-call, audio rerouting takes too long, r=echou --- dom/bluetooth/BluetoothHfpManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/bluetooth/BluetoothHfpManager.cpp b/dom/bluetooth/BluetoothHfpManager.cpp index 272d3c22d52e..a94723fd673c 100644 --- a/dom/bluetooth/BluetoothHfpManager.cpp +++ b/dom/bluetooth/BluetoothHfpManager.cpp @@ -604,7 +604,7 @@ BluetoothHfpManager::ReceiveSocketData(UnixSocketRawData* aMessage) // For more information, please refer to 4.34.1 "Bluetooth Defined AT // Capabilities" in Bluetooth hands-free profile 1.6 if (msg.Find("AT+BRSF=") != -1) { - SendCommand("+BRSF: ", 23); + SendCommand("+BRSF: ", 33); } else if (msg.Find("AT+CIND=?") != -1) { // Asking for CIND range SendCommand("+CIND: ", 0); @@ -831,6 +831,7 @@ BluetoothHfpManager::Disconnect() return; } + CloseScoSocket(); CloseSocket(); } From f34bb3f29c0b6ed2632b475f85cda4b0230f07c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kan-Ru=20Chen=20=28=E9=99=B3=E4=BE=83=E5=A6=82=29?= Date: Sat, 5 Jan 2013 13:03:51 +0800 Subject: [PATCH 129/180] Bug 793105 - Add a "backgroundPerceivable" class for audio-channel-content. r=jlebar,roc --- b2g/app/b2g.js | 2 ++ dom/audiochannel/AudioChannelService.cpp | 6 ++++ dom/audiochannel/AudioChannelService.h | 6 ++++ dom/audiochannel/AudioChannelServiceChild.cpp | 16 ++++++--- dom/ipc/ProcessPriorityManager.cpp | 35 ++++++++++++++++--- hal/HalTypes.h | 1 + hal/gonk/GonkHal.cpp | 12 +++++-- 7 files changed, 67 insertions(+), 11 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index f5cc8833bdd8..a5f757b15289 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -544,6 +544,8 @@ pref("hal.processPriorityManager.gonk.masterOomScoreAdjust", 0); pref("hal.processPriorityManager.gonk.masterKillUnderMB", 1); pref("hal.processPriorityManager.gonk.foregroundOomScoreAdjust", 67); pref("hal.processPriorityManager.gonk.foregroundKillUnderMB", 4); +pref("hal.processPriorityManager.gonk.backgroundPerceivableOomScoreAdjust", 134); +pref("hal.processPriorityManager.gonk.backgroundPerceivebleKillUnderMB", 5); pref("hal.processPriorityManager.gonk.backgroundHomescreenOomScoreAdjust", 200); pref("hal.processPriorityManager.gonk.backgroundHomescreenKillUnderMB", 5); pref("hal.processPriorityManager.gonk.backgroundOomScoreAdjust", 400); diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 059bcb4b2be5..342dc0a00eb5 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -239,6 +239,12 @@ AudioChannelService::GetMuted(AudioChannelType aType, bool aElementHidden) return muted; } +bool +AudioChannelService::ContentChannelIsActive() +{ + return mChannelCounters[AUDIO_CHANNEL_CONTENT].Length() > 0; +} + static PLDHashOperator NotifyEnumerator(AudioChannelAgent* aAgent, AudioChannelType aType, void* aData) diff --git a/dom/audiochannel/AudioChannelService.h b/dom/audiochannel/AudioChannelService.h index 702e7dde5338..096fcb36b2cc 100644 --- a/dom/audiochannel/AudioChannelService.h +++ b/dom/audiochannel/AudioChannelService.h @@ -53,6 +53,12 @@ public: */ virtual bool GetMuted(AudioChannelType aType, bool aElementHidden); + /** + * Return true if there is a content channel active in this process + * or one of its subprocesses. + */ + virtual bool ContentChannelIsActive(); + protected: void Notify(); diff --git a/dom/audiochannel/AudioChannelServiceChild.cpp b/dom/audiochannel/AudioChannelServiceChild.cpp index a8f6547c5e1a..c5ec949d66f8 100644 --- a/dom/audiochannel/AudioChannelServiceChild.cpp +++ b/dom/audiochannel/AudioChannelServiceChild.cpp @@ -12,11 +12,8 @@ #include "mozilla/StaticPtr.h" #include "mozilla/unused.h" #include "mozilla/Util.h" - #include "mozilla/dom/ContentChild.h" - -#include "base/basictypes.h" - +#include "nsIObserverService.h" #include "nsThreadUtils.h" using namespace mozilla; @@ -82,6 +79,11 @@ AudioChannelServiceChild::RegisterAudioChannelAgent(AudioChannelAgent* aAgent, if (cc) { cc->SendAudioChannelRegisterType(aType); } + + nsCOMPtr obs = mozilla::services::GetObserverService(); + if (obs) { + obs->NotifyObservers(nullptr, "audio-channel-agent-changed", nullptr); + } } void @@ -98,5 +100,9 @@ AudioChannelServiceChild::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent) if (cc) { cc->SendAudioChannelUnregisterType(type); } -} + nsCOMPtr obs = mozilla::services::GetObserverService(); + if (obs) { + obs->NotifyObservers(nullptr, "audio-channel-agent-changed", nullptr); + } +} diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index 98947d2c97e8..f4e8bb266f85 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -13,6 +13,7 @@ #include "mozilla/Services.h" #include "mozilla/HalTypes.h" #include "mozilla/TimeStamp.h" +#include "AudioChannelService.h" #include "prlog.h" #include "nsWeakPtr.h" #include "nsXULAppAPI.h" @@ -80,6 +81,11 @@ GetPPMLog() ProcessPriority GetBackgroundPriority() { + AudioChannelService* service = AudioChannelService::GetAudioChannelService(); + if (service->ContentChannelIsActive()) { + return PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE; + } + bool isHomescreen = false; ContentChild* contentChild = ContentChild::GetSingleton(); @@ -101,6 +107,17 @@ GetBackgroundPriority() PROCESS_PRIORITY_BACKGROUND; } +/** + * Determine if the priority is a backround priority. + */ +bool +IsBackgroundPriority(ProcessPriority aPriority) +{ + return (aPriority == PROCESS_PRIORITY_BACKGROUND || + aPriority == PROCESS_PRIORITY_BACKGROUND_HOMESCREEN || + aPriority == PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE); +} + /** * This class listens to window creation and visibilitychange events and * informs the hal back-end when this process transitions between having no @@ -135,6 +152,7 @@ public: private: void SetPriority(ProcessPriority aPriority); + void OnAudioChannelAgentChanged(); void OnContentDocumentGlobalCreated(nsISupports* aOuterWindow); void OnInnerWindowDestroyed(); void OnGracePeriodTimerFired(); @@ -170,6 +188,7 @@ ProcessPriorityManager::Init() nsCOMPtr os = services::GetObserverService(); os->AddObserver(this, "content-document-global-created", /* ownsWeak = */ false); os->AddObserver(this, "inner-window-destroyed", /* ownsWeak = */ false); + os->AddObserver(this, "audio-channel-agent-changed", /* ownsWeak = */ false); SetPriority(PROCESS_PRIORITY_FOREGROUND); } @@ -186,6 +205,8 @@ ProcessPriorityManager::Observe( OnInnerWindowDestroyed(); } else if (!strcmp(aTopic, "timer-callback")) { OnGracePeriodTimerFired(); + } else if (!strcmp(aTopic, "audio-channel-agent-changed")) { + OnAudioChannelAgentChanged(); } else { MOZ_ASSERT(false); } @@ -201,6 +222,14 @@ ProcessPriorityManager::HandleEvent( return NS_OK; } +void +ProcessPriorityManager::OnAudioChannelAgentChanged() +{ + if (IsBackgroundPriority(mProcessPriority)) { + SetPriority(GetBackgroundPriority()); + } +} + void ProcessPriorityManager::OnContentDocumentGlobalCreated( nsISupports* aOuterWindow) @@ -297,8 +326,7 @@ ProcessPriorityManager::SetPriority(ProcessPriority aPriority) return; } - if (aPriority == PROCESS_PRIORITY_BACKGROUND || - aPriority == PROCESS_PRIORITY_BACKGROUND_HOMESCREEN) { + if (IsBackgroundPriority(aPriority)) { // If this is a foreground --> background transition, give ourselves a // grace period before informing hal. uint32_t gracePeriodMS = Preferences::GetUint("dom.ipc.processPriorityManager.gracePeriodMS", 1000); @@ -345,8 +373,7 @@ ProcessPriorityManager::OnGracePeriodTimerFired() // mProcessPriority should already be one of the BACKGROUND values: We set it // in SetPriority(BACKGROUND), and we canceled this timer if there was an // intervening SetPriority(FOREGROUND) call. - MOZ_ASSERT(mProcessPriority == PROCESS_PRIORITY_BACKGROUND || - mProcessPriority == PROCESS_PRIORITY_BACKGROUND_HOMESCREEN); + MOZ_ASSERT(IsBackgroundPriority(mProcessPriority)); mGracePeriodTimer = nullptr; hal::SetProcessPriority(getpid(), mProcessPriority); diff --git a/hal/HalTypes.h b/hal/HalTypes.h index ce85622ded14..749691115f27 100644 --- a/hal/HalTypes.h +++ b/hal/HalTypes.h @@ -70,6 +70,7 @@ typedef Observer SwitchObserver; enum ProcessPriority { PROCESS_PRIORITY_BACKGROUND, PROCESS_PRIORITY_BACKGROUND_HOMESCREEN, + PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE, // Any priority greater than or equal to FOREGROUND is considered // "foreground" for the purposes of priority testing, for example // CurrentProcessIsForeground(). diff --git a/hal/gonk/GonkHal.cpp b/hal/gonk/GonkHal.cpp index c04d7f88accb..7dfb07bc5589 100644 --- a/hal/gonk/GonkHal.cpp +++ b/hal/gonk/GonkHal.cpp @@ -1046,8 +1046,13 @@ EnsureKernelLowMemKillerParamsSet() nsAutoCString adjParams; nsAutoCString minfreeParams; - const char* priorityClasses[] = - {"master", "foreground", "background", "backgroundHomescreen"}; + const char* priorityClasses[] = { + "master", + "foreground", + "background", + "backgroundHomescreen", + "backgroundPerceivable" + }; for (size_t i = 0; i < NS_ARRAY_LENGTH(priorityClasses); i++) { int32_t oomScoreAdj; if (!NS_SUCCEEDED(Preferences::GetInt(nsPrintfCString( @@ -1112,6 +1117,9 @@ SetProcessPriority(int aPid, ProcessPriority aPriority) case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN: priorityStr = "backgroundHomescreen"; break; + case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE: + priorityStr = "backgroundPerceivable"; + break; case PROCESS_PRIORITY_FOREGROUND: priorityStr = "foreground"; break; From d44dff50964522e8d91c9b9d64b05009a6b117ee Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Fri, 4 Jan 2013 21:30:14 -0800 Subject: [PATCH 130/180] Back out 5e76dfb1d426 (bug 826635) and 0df74b1a4543:20df426b6111 (bug 826632) for bustage CLOSED TREE --- accessible/src/generic/DocAccessible.cpp | 4 +- accessible/src/mac/RootAccessibleWrap.mm | 2 +- accessible/src/msaa/AccessibleWrap.cpp | 4 +- accessible/src/msaa/DocAccessibleWrap.cpp | 2 +- content/base/public/nsIDocument.h | 4 +- content/base/src/Element.cpp | 2 +- content/base/src/FragmentOrElement.cpp | 2 +- content/base/src/nsContentSink.cpp | 6 +- content/base/src/nsContentSink.h | 2 +- content/base/src/nsContentUtils.cpp | 6 +- content/base/src/nsDocument.cpp | 4 +- content/base/src/nsDocument.h | 4 +- content/base/src/nsINode.cpp | 2 +- content/events/src/nsEventListenerManager.cpp | 2 +- content/events/src/nsIMEStateManager.cpp | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 2 +- content/html/document/src/MediaDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.h | 2 +- content/xml/document/src/nsXMLContentSink.h | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- .../xul/content/src/nsXULPopupListener.cpp | 2 +- content/xul/document/src/nsXULContentSink.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 2 +- docshell/base/nsDocShell.cpp | 16 +- dom/base/nsDOMWindowUtils.cpp | 4 +- dom/base/nsFocusManager.cpp | 12 +- dom/base/nsGlobalWindow.cpp | 4 +- dom/ipc/TabParent.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 8 +- .../webBrowser/nsDocShellTreeOwner.cpp | 4 +- extensions/widgetutils/src/nsWidgetUtils.cpp | 4 +- layout/base/nsCSSFrameConstructor.cpp | 4 +- layout/base/nsCSSRendering.cpp | 2 +- layout/base/nsCSSRenderingBorders.cpp | 2 +- layout/base/nsDisplayList.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 26 +- layout/base/nsIDocumentViewerPrint.h | 6 +- layout/base/nsIPresShell.h | 8 +- layout/base/nsPresContext.cpp | 4 +- layout/base/nsPresShell.cpp | 19 +- layout/base/nsPresShell.h | 2 +- layout/base/nsRefreshDriver.cpp | 4 +- layout/build/nsLayoutModule.cpp | 7 + layout/forms/nsComboboxControlFrame.cpp | 6 +- layout/forms/nsListControlFrame.cpp | 2 +- layout/forms/nsTextControlFrame.cpp | 2 +- layout/generic/nsContainerFrame.cpp | 16 +- layout/generic/nsFrame.cpp | 4 +- layout/generic/nsFrameSetFrame.cpp | 2 +- layout/generic/nsGfxScrollFrame.cpp | 2 +- layout/generic/nsObjectFrame.cpp | 10 +- layout/generic/nsSubDocumentFrame.cpp | 8 +- layout/printing/nsPrintEngine.cpp | 11 +- layout/printing/nsPrintObject.h | 4 +- .../src/nsLayoutDebuggingTools.cpp | 8 +- .../layout-debug/src/nsRegressionTester.cpp | 2 +- layout/xul/base/src/nsBoxFrame.cpp | 2 +- layout/xul/base/src/nsDeckFrame.cpp | 2 +- layout/xul/base/src/nsLeafBoxFrame.cpp | 2 +- layout/xul/base/src/nsListBoxBodyFrame.cpp | 2 +- layout/xul/base/src/nsMenuPopupFrame.cpp | 10 +- layout/xul/base/src/nsMenuPopupFrame.h | 2 +- layout/xul/base/src/nsXULPopupManager.cpp | 6 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 2 +- view/public/Makefile.in | 3 +- .../{nsViewManager.h => nsIViewManager.h} | 222 +++---------- view/public/nsView.h | 21 +- view/public/nsViewsCID.h | 17 + view/src/nsView.cpp | 52 +-- view/src/nsViewManager.cpp | 295 +++++++++++------- view/src/nsViewManager.h | 214 +++++++++++++ widget/android/nsWindow.cpp | 2 +- widget/cocoa/nsChildView.mm | 2 +- widget/gtk2/nsDragService.cpp | 4 +- widget/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/tests/TestWinTSF.cpp | 4 +- widget/xpwidgets/nsBaseDragService.cpp | 2 +- 78 files changed, 677 insertions(+), 478 deletions(-) rename view/public/{nsViewManager.h => nsIViewManager.h} (57%) create mode 100644 view/public/nsViewsCID.h create mode 100644 view/src/nsViewManager.h diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index b579a96d2c02..4163a9ed83fa 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -35,7 +35,7 @@ #include "nsINameSpaceManager.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScrollableFrame.h" #include "nsUnicharUtils.h" #include "nsIURI.h" @@ -1253,7 +1253,7 @@ DocAccessible::GetNativeWindow() const if (!mPresShell) return nullptr; - nsViewManager* vm = mPresShell->GetViewManager(); + nsIViewManager* vm = mPresShell->GetViewManager(); if (!vm) return nullptr; diff --git a/accessible/src/mac/RootAccessibleWrap.mm b/accessible/src/mac/RootAccessibleWrap.mm index 729087d03468..6e332c935850 100644 --- a/accessible/src/mac/RootAccessibleWrap.mm +++ b/accessible/src/mac/RootAccessibleWrap.mm @@ -10,7 +10,7 @@ #include "nsCOMPtr.h" #include "nsObjCExceptions.h" #include "nsIWidget.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" using namespace mozilla::a11y; diff --git a/accessible/src/msaa/AccessibleWrap.cpp b/accessible/src/msaa/AccessibleWrap.cpp index ec20bad885d4..4f0704b5ff62 100644 --- a/accessible/src/msaa/AccessibleWrap.cpp +++ b/accessible/src/msaa/AccessibleWrap.cpp @@ -34,7 +34,7 @@ #include "nsIServiceManager.h" #include "nsTextFormatter.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventMap.h" #include "nsArrayUtils.h" #include "mozilla/Preferences.h" @@ -1653,7 +1653,7 @@ AccessibleWrap::GetHWNDFor(Accessible* aAccessible) nsIWidget* widget = frame->GetNearestWidget(); if (widget && widget->IsVisible()) { nsIPresShell* shell = document->PresShell(); - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (vm) { nsCOMPtr rootWidget; vm->GetRootWidget(getter_AddRefs(rootWidget)); diff --git a/accessible/src/msaa/DocAccessibleWrap.cpp b/accessible/src/msaa/DocAccessibleWrap.cpp index 876958f24dff..8fd23d488887 100644 --- a/accessible/src/msaa/DocAccessibleWrap.cpp +++ b/accessible/src/msaa/DocAccessibleWrap.cpp @@ -21,7 +21,7 @@ #include "nsISelectionController.h" #include "nsIServiceManager.h" #include "nsIURI.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWebNavigation.h" using namespace mozilla; diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index a8c45d36846e..12544516354b 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -65,7 +65,7 @@ class nsIStyleRule; class nsIStyleSheet; class nsIURI; class nsIVariant; -class nsViewManager; +class nsIViewManager; class nsPresContext; class nsRange; class nsScriptLoader; @@ -478,7 +478,7 @@ public: * presshell if the presshell should observe document mutations. */ virtual nsresult CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) = 0; virtual void DeleteShell() = 0; diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index 0f6a7a1e4f9e..bc5538b3a1fb 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -94,7 +94,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScrollableFrame.h" #include "nsXBLInsertionPoint.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index fb51d78dde75..e43cd5301611 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -93,7 +93,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScrollableFrame.h" #include "nsXBLInsertionPoint.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 81bec6f4af40..a2bdec6a9cac 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -25,7 +25,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsPresContext.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIAtom.h" #include "nsGkAtoms.h" #include "nsIDOMWindow.h" @@ -1371,7 +1371,7 @@ nsContentSink::DidProcessATokenImpl() // Check if there's a pending event if (sPendingEventMode != 0 && !mHasPendingEvent && (mDeflectedCount % sEventProbeRate) == 0) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1518,7 +1518,7 @@ nsContentSink::WillParseImpl(void) uint32_t currentTime = PR_IntervalToMicroseconds(PR_IntervalNow()); if (sEnablePerfMode == 0) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); uint32_t lastEventTime; vm->GetLastUserEventTime(lastEventTime); diff --git a/content/base/src/nsContentSink.h b/content/base/src/nsContentSink.h index 9537c801ab7c..4cb8bbce8480 100644 --- a/content/base/src/nsContentSink.h +++ b/content/base/src/nsContentSink.h @@ -34,7 +34,7 @@ class nsIParser; class nsIAtom; class nsIChannel; class nsIContent; -class nsViewManager; +class nsIViewManager; class nsNodeInfoManager; class nsScriptLoader; class nsIApplicationCache; diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index dd70005135a9..d2b910cea9e1 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -115,7 +115,7 @@ #include "nsTextEditorState.h" #include "nsIPluginHost.h" #include "nsICategoryManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventStateManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsParserConstants.h" @@ -6435,11 +6435,11 @@ nsContentUtils::WidgetForDocument(nsIDocument* aDoc) { nsIPresShell* shell = FindPresShellForDocument(aDoc); if (shell) { - nsViewManager* VM = shell->GetViewManager(); + nsIViewManager* VM = shell->GetViewManager(); if (VM) { nsView* rootView = VM->GetRootView(); if (rootView) { - nsView* displayRoot = nsViewManager::GetDisplayRootFor(rootView); + nsView* displayRoot = nsIViewManager::GetDisplayRootFor(rootView); if (displayRoot) { return displayRoot->GetNearestWidget(nullptr); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 3cf1e8bd782f..fb018d1a03da 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3119,7 +3119,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel, } nsresult -nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, +nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { @@ -3132,7 +3132,7 @@ nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, nsresult nsDocument::doCreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, nsStyleSet* aStyleSet, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult) { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 9da0d22572f2..adbd2a66bd11 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -568,7 +568,7 @@ public: * shared among multiple presentation shell's). */ virtual nsresult CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); virtual void DeleteShell(); @@ -1076,7 +1076,7 @@ public: protected: nsresult doCreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, nsStyleSet* aStyleSet, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult); diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 6ae96a8cfaed..90eb565a7e4d 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -74,7 +74,7 @@ #include "nsIServiceManager.h" #include "nsIURL.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWebNavigation.h" #include "nsIWidget.h" #include "nsLayoutStatics.h" diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index e235fe40626d..23c0174a27f8 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -27,7 +27,7 @@ #include "mozilla/dom/Element.h" #include "nsIFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsCOMPtr.h" #include "nsIServiceManager.h" #include "nsIScriptSecurityManager.h" diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 216d1dea558e..75aa6b148fd0 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -6,7 +6,7 @@ #include "nsIMEStateManager.h" #include "nsCOMPtr.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIPresShell.h" #include "nsISupports.h" #include "nsPIDOMWindow.h" diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d52947b19d9d..559d8aea071a 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -38,7 +38,7 @@ #include "nsIFrame.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsRange.h" #include "nsIPresShell.h" diff --git a/content/html/document/src/MediaDocument.cpp b/content/html/document/src/MediaDocument.cpp index 7576db42357b..0f86c50208f7 100644 --- a/content/html/document/src/MediaDocument.cpp +++ b/content/html/document/src/MediaDocument.cpp @@ -9,7 +9,7 @@ #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsIScrollable.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsITextToSubURI.h" #include "nsIURL.h" #include "nsIContentViewer.h" diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 7f2b5bdaa3ca..a15ddf6b8c01 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -305,7 +305,7 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, nsresult nsHTMLDocument::CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index a7124471a44e..2ceecf8c5c95 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -55,7 +55,7 @@ public: nsIPrincipal* aPrincipal); virtual nsresult CreateShell(nsPresContext* aContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index 140fb66be030..a7c31295dbcb 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -22,7 +22,7 @@ class nsIURI; class nsIContent; class nsINodeInfo; class nsIParser; -class nsViewManager; +class nsIViewManager; typedef enum { eXMLContentSinkState_InProlog, diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index c87be6820afd..0afe23e0538f 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -54,7 +54,7 @@ #include "mozilla/css/StyleRule.h" #include "nsIStyleSheet.h" #include "nsIURL.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsIXULDocument.h" #include "nsIXULTemplateBuilder.h" diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 4382be6ddae7..26577548f2cd 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -40,7 +40,7 @@ #include "nsIPresShell.h" #include "nsFocusManager.h" #include "nsPIDOMWindow.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsError.h" #include "nsMenuFrame.h" diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index 54eb53f8a48f..3068587e3970 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -30,7 +30,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIXULDocument.h" #include "nsIScriptSecurityManager.h" #include "nsLayoutCID.h" diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 583b8adebabe..ddebfd771566 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -30,7 +30,7 @@ #include "nsIBoxObject.h" #include "nsIChromeRegistry.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIContentViewer.h" #include "nsGUIEvent.h" #include "nsIDOMXULElement.h" diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index f4f10dabb371..c5a5b46bbad0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -66,7 +66,7 @@ #include "nsDOMJSUtils.h" #include "nsIInterfaceRequestorUtils.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScriptChannel.h" #include "nsIOfflineCacheUpdate.h" #include "nsITimedChannel.h" @@ -3249,7 +3249,7 @@ PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel) nsCOMPtr domwin(doc->GetWindow()); nsCOMPtr widget; - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { vm->GetWidget(getter_AddRefs(widget)); } @@ -5048,10 +5048,10 @@ nsDocShell::Repaint(bool aForce) nsCOMPtr presShell =GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsViewManager* viewManager = presShell->GetViewManager(); + nsIViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); - viewManager->InvalidateAllViews(); + NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE); return NS_OK; } @@ -5115,7 +5115,7 @@ nsDocShell::GetVisibility(bool * aVisibility) return NS_OK; // get the view manager - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); // get the root view @@ -7388,7 +7388,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr oldPresShell = GetPresShell(); if (oldPresShell) { - nsViewManager *vm = oldPresShell->GetViewManager(); + nsIViewManager *vm = oldPresShell->GetViewManager(); if (vm) { nsView *oldRootView = vm->GetRootView(); @@ -7609,7 +7609,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr shell = GetPresShell(); - nsViewManager *newVM = shell ? shell->GetViewManager() : nullptr; + nsIViewManager *newVM = shell ? shell->GetViewManager() : nullptr; nsView *newRootView = newVM ? newVM->GetRootView() : nullptr; // Insert the new root view at the correct location in the view tree. @@ -7625,7 +7625,7 @@ nsDocShell::RestoreFromHistory() rootViewSibling = nullptr; } if (rootViewParent && newRootView && newRootView->GetParent() != rootViewParent) { - nsViewManager *parentVM = rootViewParent->GetViewManager(); + nsIViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { // InsertChild(parent, child, sib, true) inserts the child after // sib in content order, which is before sib in view order. BUT diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 17501cdc436d..77a94372207b 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -33,7 +33,7 @@ #include "nsJSEnvironment.h" #include "nsJSUtils.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMHTMLCanvasElement.h" #include "gfxContext.h" @@ -661,7 +661,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, nsCOMPtr presShell = presContext->PresShell(); if (!presShell) return NS_ERROR_FAILURE; - nsViewManager* viewManager = presShell->GetViewManager(); + nsIViewManager* viewManager = presShell->GetViewManager(); if (!viewManager) return NS_ERROR_FAILURE; nsView* view = viewManager->GetRootView(); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 54bca81fa689..f382d73e67fa 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -39,7 +39,7 @@ #include "nsIWebNavigation.h" #include "nsCaret.h" #include "nsIBaseWindow.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsFrameSelection.h" #include "mozilla/Selection.h" #include "nsXULPopupManager.h" @@ -1055,7 +1055,7 @@ nsFocusManager::EnsureCurrentWidgetFocused() if (docShell) { nsCOMPtr presShell = docShell->GetPresShell(); if (presShell) { - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1552,7 +1552,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, if (aAdjustWidgets && objectFrame && !sTestMode) { // note that the presshell's widget is being retrieved here, not the one // for the object frame. - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1726,7 +1726,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, objectFrameWidget = objectFrame->GetWidget(); } if (aAdjustWidgets && !objectFrameWidget && !sTestMode) { - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1812,7 +1812,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, if (aAdjustWidgets && objectFrameWidget && mFocusedWindow == aWindow && mFocusedContent == nullptr && !sTestMode) { - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1974,7 +1974,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow) if (!presShell) return; - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 011c79740d45..48f071dad082 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -118,7 +118,7 @@ #include "nsIScriptSecurityManager.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsISelectionController.h" #include "nsISelection.h" #include "nsIPrompt.h" @@ -11024,7 +11024,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor) nsCOMPtr presShell = mDocShell->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsViewManager* vm = presShell->GetViewManager(); + nsIViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsView* rootView = vm->GetRootView(); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index a64e07c96362..70a607aa7081 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -41,7 +41,7 @@ #include "nsIURI.h" #include "nsIMozBrowserFrame.h" #include "nsIScriptSecurityManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsIWindowWatcher.h" #include "nsNetUtil.h" @@ -883,7 +883,7 @@ TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue) if (content) { nsIPresShell* shell = content->OwnerDoc()->GetShell(); if (shell) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 0b46a8ce1105..ac7ad95dbe2a 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -45,7 +45,7 @@ using mozilla::DefaultXDisplay; #include "nsIWebBrowserChrome.h" #include "nsLayoutUtils.h" #include "nsIPluginWidget.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDocShellTreeOwner.h" #include "nsIDOMHTMLObjectElement.h" #include "nsIAppShell.h" @@ -693,7 +693,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #if defined(XP_WIN) || defined(XP_OS2) void** pvalue = (void**)value; - nsViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager(); + nsIViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager(); if (!vm) return NS_ERROR_FAILURE; #if defined(XP_WIN) @@ -743,14 +743,14 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #endif // simply return the topmost document window nsCOMPtr widget; - vm->GetRootWidget(getter_AddRefs(widget)); + nsresult rv = vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { *pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW); } else { NS_ASSERTION(widget, "couldn't get doc's widget in getting doc's window handle"); } - return NS_OK; + return rv; #elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11) // X11 window managers want the toplevel window for WM_TRANSIENT_FOR. nsIWidget* win = mObjectFrame->GetNearestWidget(); diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index b11429c539a6..68985c3cb8d3 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -61,7 +61,7 @@ #include "imgIContainer.h" #include "nsContextMenuInfo.h" #include "nsPresContext.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" #include "nsEventListenerManager.h" #include "nsIDOMDragEvent.h" @@ -1443,7 +1443,7 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, nsIWidget* widget = nullptr; if (shell) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (vm) { nsView* view = vm->GetRootView(); if (view) { diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index ec6ccbf78717..9810e14b0a81 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -36,7 +36,7 @@ #include "nsIDOMWheelEvent.h" #include "nsView.h" #include "nsGUIEvent.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIContentPolicy.h" #include "nsIDocShellTreeItem.h" #include "nsIContent.h" @@ -89,7 +89,7 @@ private: static void StopPanningCallback(nsITimer *timer, void *closure); nsCOMPtr mWidget; - nsRefPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mTimer; }; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 271102f07fcd..f5d4dd66c202 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -36,7 +36,7 @@ #include "nsIPresShell.h" #include "nsUnicharUtils.h" #include "nsStyleSet.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventStates.h" #include "nsStyleConsts.h" #include "nsTableOuterFrame.h" @@ -12023,7 +12023,7 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) return; // Make sure that the viewmanager will outlive the presshell - nsRefPtr vm = mPresShell->GetViewManager(); + nsCOMPtr vm = mPresShell->GetViewManager(); // Processing the style changes could cause a flush that propagates to // the parent frame and thus destroys the pres shell. diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index f8162d78d477..98d67dd741d4 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -19,7 +19,7 @@ #include "nsIFrame.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIPresShell.h" #include "nsFrameManager.h" #include "nsStyleContext.h" diff --git a/layout/base/nsCSSRenderingBorders.cpp b/layout/base/nsCSSRenderingBorders.cpp index 07fe86babf11..a28b2a7dc2b1 100644 --- a/layout/base/nsCSSRenderingBorders.cpp +++ b/layout/base/nsCSSRenderingBorders.cpp @@ -7,7 +7,7 @@ #include "nsStyleConsts.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsFrameManager.h" #include "nsStyleContext.h" #include "nsGkAtoms.h" diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 8111f8c6a57a..d17034b2bd08 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -46,7 +46,7 @@ #include "sampler.h" #include "nsAnimationManager.h" #include "nsTransitionManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "ImageLayers.h" #include "ImageContainer.h" #include "nsCanvasFrame.h" diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index a8f3cfc43811..870cfc3fd1ee 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -40,8 +40,9 @@ #include "nsLayoutStylesheetCache.h" #include "mozilla/Preferences.h" +#include "nsViewsCID.h" #include "nsIDeviceContextSpec.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" #include "nsIPageSequenceFrame.h" @@ -378,7 +379,7 @@ protected: // These return the current shell/prescontext etc. nsIPresShell* GetPresShell(); nsPresContext* GetPresContext(); - nsViewManager* GetViewManager(); + nsIViewManager* GetViewManager(); void DetachFromTopLevelWidget(); @@ -396,7 +397,7 @@ protected: // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsRefPtr mViewManager; + nsCOMPtr mViewManager; nsRefPtr mPresContext; nsCOMPtr mPresShell; @@ -496,6 +497,8 @@ private: //------------------------------------------------------------------ // nsDocumentViewer //------------------------------------------------------------------ +// Class IDs +static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); //------------------------------------------------------------------ nsresult @@ -1396,7 +1399,7 @@ nsDocumentViewer::Open(nsISupports *aState, nsISHEntry *aSHEntry) // If the old view is already attached to our parent, detach DetachFromTopLevelWidget(); - nsViewManager *vm = GetViewManager(); + nsIViewManager *vm = GetViewManager(); NS_ABORT_IF_FALSE(vm, "no view manager"); nsView* v = vm->GetRootView(); NS_ABORT_IF_FALSE(v, "no root view"); @@ -1543,7 +1546,7 @@ nsDocumentViewer::Destroy() // Remove our root view from the view hierarchy. if (mPresShell) { - nsViewManager *vm = mPresShell->GetViewManager(); + nsIViewManager *vm = mPresShell->GetViewManager(); if (vm) { nsView *rootView = vm->GetRootView(); @@ -1556,7 +1559,7 @@ nsDocumentViewer::Destroy() nsView *rootViewParent = rootView->GetParent(); if (rootViewParent) { - nsViewManager *parentVM = rootViewParent->GetViewManager(); + nsIViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { parentVM->RemoveChild(rootView); } @@ -1803,7 +1806,7 @@ nsDocumentViewer::GetPresContext() return mPresContext; } -nsViewManager* +nsIViewManager* nsDocumentViewer::GetViewManager() { return mViewManager; @@ -2269,11 +2272,14 @@ nsDocumentViewer::MakeWindow(const nsSize& aSize, nsView* aContainerView) DetachFromTopLevelWidget(); } - mViewManager = new nsViewManager(); + nsresult rv; + mViewManager = do_CreateInstance(kViewManagerCID, &rv); + if (NS_FAILED(rv)) + return rv; nsDeviceContext *dx = mPresContext->DeviceContext(); - nsresult rv = mViewManager->Init(dx); + rv = mViewManager->Init(dx); if (NS_FAILED(rv)) return rv; @@ -4382,7 +4388,7 @@ nsDocumentViewer::InitializeForPrintPreview() } void -nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager, +nsDocumentViewer::SetPrintPreviewPresentation(nsIViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) { diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index e99d39198339..083afc1219a1 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -12,7 +12,7 @@ class nsStyleSet; class nsIPresShell; class nsPresContext; class nsIWidget; -class nsViewManager; +class nsIViewManager; // {c6f255cf-cadd-4382-b57f-cd2a9874169b} #define NS_IDOCUMENT_VIEWER_PRINT_IID \ @@ -58,7 +58,7 @@ public: /** * Replaces the current presentation with print preview presentation. */ - virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, + virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) = 0; }; @@ -78,7 +78,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, virtual void OnDonePrinting(); \ virtual bool IsInitializedForPrintPreview(); \ virtual void InitializeForPrintPreview(); \ - virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, \ + virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, \ nsPresContext* aPresContext, \ nsIPresShell* aPresShell); diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index afc91f51df71..39aa465b9b91 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -44,7 +44,7 @@ class nsIDocument; class nsIFrame; class nsPresContext; class nsStyleSet; -class nsViewManager; +class nsIViewManager; class nsView; class nsRenderingContext; class nsIPageSequenceFrame; @@ -176,7 +176,7 @@ protected: public: virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) = 0; @@ -272,7 +272,7 @@ public: nsPresContext* GetPresContext() const { return mPresContext; } - nsViewManager* GetViewManager() const { return mViewManager; } + nsIViewManager* GetViewManager() const { return mViewManager; } #ifdef ACCESSIBILITY /** @@ -1381,7 +1381,7 @@ protected: nsPresContext* mPresContext; // [STRONG] nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] - nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to + nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to nsPresArena mFrameArena; nsFrameSelection* mSelection; // Pointer into mFrameConstructor - this is purely so that FrameManager() and diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 10350a5bf5f2..00c6e59fa601 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -43,7 +43,7 @@ #include "nsThreadUtils.h" #include "nsFrameManager.h" #include "nsLayoutUtils.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsCSSFrameConstructor.h" #include "nsCSSRuleProcessor.h" #include "nsStyleChangeList.h" @@ -826,7 +826,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) // Re-fetch the view manager's window dimensions in case there's a deferred // resize which hasn't affected our mVisibleArea yet nscoord oldWidthAppUnits, oldHeightAppUnits; - nsViewManager* vm = mShell->GetViewManager(); + nsIViewManager* vm = mShell->GetViewManager(); vm->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits); float oldWidthDevPixels = oldWidthAppUnits/oldAppUnitsPerDevPixel; float oldHeightDevPixels = oldHeightAppUnits/oldAppUnitsPerDevPixel; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 427aecd9deb3..0e19a038b38e 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -72,6 +72,7 @@ #include "nsCaret.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMXMLDocument.h" +#include "nsViewsCID.h" #include "nsFrameManager.h" #include "nsEventStateManager.h" #include "nsIMEStateManager.h" @@ -787,7 +788,7 @@ PresShell::~PresShell() nsresult PresShell::Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) { @@ -1856,7 +1857,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_ERROR_NOT_AVAILABLE; } - nsRefPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first nsCOMPtr kungFuDeathGrip(this); @@ -1896,7 +1897,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) // Kick off a top-down reflow AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); + nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager); mDirtyRoots.RemoveElement(rootFrame); DoReflow(rootFrame, true); @@ -3734,7 +3735,7 @@ PresShell::IsSafeToFlush() const if (isSafeToFlush) { // Not safe if we are painting - nsViewManager* viewManager = GetViewManager(); + nsIViewManager* viewManager = GetViewManager(); if (viewManager) { bool isPainting = false; viewManager->IsPainting(isPainting); @@ -3807,7 +3808,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsRefPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; if (isSafeToFlush && mViewManager) { // Processing pending notifications can kill us, and some callers only // hold weak refs when calling FlushPendingNotifications(). :( @@ -5185,7 +5186,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) // We always dispatch the event to the pres shell that contains the view that // the mouse is over. pointVM is the VM of that pres shell. - nsViewManager *pointVM = nullptr; + nsIViewManager *pointVM = nullptr; // This could be a bit slow (traverses entire view hierarchy) // but it's OK to do it once per synthetic mouse event @@ -7651,7 +7652,7 @@ PresShell::ProcessReflowCommands(bool aInterruptible) nsAutoScriptBlocker scriptBlocker; WillDoReflow(); AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); + nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager); do { // Send an incremental reflow notification to the target frame. @@ -7925,6 +7926,8 @@ nsIPresShell::RemoveRefreshObserverExternal(nsARefreshObserver* aObserver, #include "nsIURL.h" #include "nsILinkHandler.h" +static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); + static void LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg) { @@ -8267,7 +8270,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsRefPtr vm = new nsViewManager(); + nsCOMPtr vm = do_CreateInstance(kViewManagerCID); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index bde4b2f3e9a8..89ae708e5a2f 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -70,7 +70,7 @@ public: // nsIPresShell virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode); virtual NS_HIDDEN_(void) Destroy(); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 66cd63ae4f33..2b3993a3a752 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -39,7 +39,7 @@ #include "jsapi.h" #include "nsContentUtils.h" #include "mozilla/Preferences.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "sampler.h" #include "nsNPAPIPluginInstance.h" @@ -951,7 +951,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsRefPtr vm = mPresContext->GetPresShell()->GetViewManager(); + nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef DEBUG_INVALIDATIONS printf("Ending ProcessPendingUpdates\n"); diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 0589851d6361..ad41b6b499d4 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -66,6 +66,8 @@ #include "nsChannelPolicy.h" // view stuff +#include "nsViewsCID.h" +#include "nsViewManager.h" #include "nsContentCreatorFunctions.h" // DOM includes @@ -592,6 +594,8 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ return rv; \ } \ +NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager) + static nsresult CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult) { @@ -751,6 +755,7 @@ NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID); NS_DEFINE_NAMED_CID(NS_JSURI_CID); NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID); NS_DEFINE_NAMED_CID(NS_WINDOWCONTROLLER_CID); +NS_DEFINE_NAMED_CID(NS_VIEW_MANAGER_CID); NS_DEFINE_NAMED_CID(NS_PLUGINDOCLOADERFACTORY_CID); NS_DEFINE_NAMED_CID(NS_PLUGINDOCUMENT_CID); #ifdef MOZ_MEDIA @@ -1034,6 +1039,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &kNS_JSURI_CID, false, NULL, nsJSURIConstructor }, { &kNS_WINDOWCOMMANDTABLE_CID, false, NULL, CreateWindowCommandTableConstructor }, { &kNS_WINDOWCONTROLLER_CID, false, NULL, CreateWindowControllerWithSingletonCommandTable }, + { &kNS_VIEW_MANAGER_CID, false, NULL, nsViewManagerConstructor }, { &kNS_PLUGINDOCLOADERFACTORY_CID, false, NULL, CreateContentDLF }, { &kNS_PLUGINDOCUMENT_CID, false, NULL, CreatePluginDocument }, #ifdef MOZ_MEDIA @@ -1183,6 +1189,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID }, { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID }, { NS_WINDOWCONTROLLER_CONTRACTID, &kNS_WINDOWCONTROLLER_CID }, + { "@mozilla.org/view-manager;1", &kNS_VIEW_MANAGER_CID }, { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID }, { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID }, { TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID, &kTRANSFORMIIX_XSLT_PROCESSOR_CID }, diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index bae444b06e8c..7231f4d72633 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -24,7 +24,7 @@ #include "nsIPresShell.h" #include "nsContentList.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsEventDispatcher.h" #include "nsEventListenerManager.h" #include "nsIDOMNode.h" @@ -356,7 +356,7 @@ void nsComboboxControlFrame::ShowPopup(bool aShowPopup) { nsView* view = mDropdownFrame->GetView(); - nsViewManager* viewManager = view->GetViewManager(); + nsIViewManager* viewManager = view->GetViewManager(); if (aShowPopup) { nsRect rect = mDropdownFrame->GetRect(); @@ -510,7 +510,7 @@ nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext, // ensure we start off hidden if (GetStateBits() & NS_FRAME_FIRST_REFLOW) { nsView* view = mDropdownFrame->GetView(); - nsViewManager* viewManager = view->GetViewManager(); + nsIViewManager* viewManager = view->GetViewManager(); viewManager->SetViewVisibility(view, nsViewVisibility_kHide); nsRect emptyRect(0, 0, 0, 0); viewManager->ResizeView(view, emptyRect); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 120ac259c914..7574138c8c1b 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -17,7 +17,7 @@ #include "nsIDOMHTMLSelectElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsComboboxControlFrame.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsWidgetsCID.h" #include "nsIPresShell.h" diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 94ccfc181392..8a9497a06f8f 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -39,7 +39,7 @@ #include "nsLayoutUtils.h" #include "nsIComponentManager.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLElement.h" diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 623de06d899e..b6e27140d8ef 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -22,7 +22,7 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" #include "nsCSSAnonBoxes.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIWidget.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" @@ -373,7 +373,7 @@ nsContainerFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset, static nsresult ReparentFrameViewTo(nsIFrame* aFrame, - nsViewManager* aViewManager, + nsIViewManager* aViewManager, nsView* aNewParentView, nsView* aOldParentView) { @@ -432,7 +432,7 @@ nsContainerFrame::CreateViewForFrame(nsIFrame* aFrame, nsView* parentView = aFrame->GetParent()->GetClosestView(); NS_ASSERTION(parentView, "no parent with view"); - nsViewManager* viewManager = parentView->GetViewManager(); + nsIViewManager* viewManager = parentView->GetViewManager(); NS_ASSERTION(viewManager, "null view manager"); // Create a view @@ -480,7 +480,7 @@ nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame) return; nsView* view = aKidFrame->GetView(); - nsViewManager* vm = view->GetViewManager(); + nsIViewManager* vm = view->GetViewManager(); nsPoint pt; nsView* ancestorView = parentFrame->GetClosestView(&pt); @@ -607,7 +607,7 @@ nsContainerFrame::ReparentFrameViewList(nsPresContext* aPresContext, // same view sub-hierarchy. If they are then we don't have to do // anything if (oldParentView != newParentView) { - nsViewManager* viewManager = oldParentView->GetViewManager(); + nsIViewManager* viewManager = oldParentView->GetViewManager(); // They're not so we need to reparent any child views for (nsFrameList::Enumerator e(aChildFrameList); !e.AtEnd(); e.Next()) { @@ -656,7 +656,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, if (!windowWidget || !IsTopLevelWidget(windowWidget)) return; - nsViewManager* vm = aView->GetViewManager(); + nsIViewManager* vm = aView->GetViewManager(); nsView* rootView = vm->GetRootView(); if (aView != rootView) @@ -748,7 +748,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext, } if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { - nsViewManager* vm = aView->GetViewManager(); + nsIViewManager* vm = aView->GetViewManager(); vm->ResizeView(aView, aVisualOverflowArea, true); } @@ -768,7 +768,7 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, return; } - nsViewManager* vm = aView->GetViewManager(); + nsIViewManager* vm = aView->GetViewManager(); if (nullptr == aStyleContext) { aStyleContext = aFrame->GetStyleContext(); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index be9082de186b..fbd308f54891 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -22,7 +22,7 @@ #include "nsStyleContext.h" #include "nsTableOuterFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIScrollableFrame.h" #include "nsPresContext.h" #include "nsCRT.h" @@ -5289,7 +5289,7 @@ nsFrame::UpdateOverflow() if ((flags & NS_FRAME_NO_SIZE_VIEW) == 0) { // Make sure the frame's view is properly sized. - nsViewManager* vm = view->GetViewManager(); + nsIViewManager* vm = view->GetViewManager(); vm->ResizeView(view, overflowAreas.VisualOverflow(), true); } } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 7ea3d8e737ba..843ef0ca5b55 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -22,7 +22,7 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index e0510aa491b9..541abd69edc9 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -11,7 +11,7 @@ #include "nsIServiceManager.h" #include "nsView.h" #include "nsIScrollable.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsContainerFrame.h" #include "nsGfxScrollFrame.h" #include "nsGkAtoms.h" diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 7f1b46428bc8..c7b9fed522e9 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -14,7 +14,7 @@ #include "nsIPresShell.h" #include "nsWidgetsCID.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMEventListener.h" #include "nsIDOMDragEvent.h" #include "nsPluginHost.h" @@ -329,7 +329,7 @@ nsObjectFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) { if (HasView()) { nsView* view = GetView(); - nsViewManager* vm = view->GetViewManager(); + nsIViewManager* vm = view->GetViewManager(); if (vm) { nsViewVisibility visibility = IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow; @@ -365,7 +365,7 @@ nsObjectFrame::PrepForDrawing(nsIWidget *aWidget) return NS_ERROR_FAILURE; } - nsViewManager* viewMan = view->GetViewManager(); + nsIViewManager* viewMan = view->GetViewManager(); // mark the view as hidden since we don't know the (x,y) until Paint // XXX is the above comment correct? viewMan->SetViewVisibility(view, nsViewVisibility_kHide); @@ -593,7 +593,7 @@ nsObjectFrame::Reflow(nsPresContext* aPresContext, r.Deflate(aReflowState.mComputedBorderPadding); if (mInnerView) { - nsViewManager* vm = mInnerView->GetViewManager(); + nsIViewManager* vm = mInnerView->GetViewManager(); vm->MoveViewTo(mInnerView, r.x, r.y); vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), r.Size()), true); } @@ -884,7 +884,7 @@ nsObjectFrame::DidReflow(nsPresContext* aPresContext, if (HasView()) { nsView* view = GetView(); - nsViewManager* vm = view->GetViewManager(); + nsIViewManager* vm = view->GetViewManager(); if (vm) vm->SetViewVisibility(view, IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow); } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 9ead05a2f475..4a5bf79aa73e 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -30,7 +30,7 @@ #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" #include "nsStyleContext.h" @@ -674,7 +674,7 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, } if (mInnerView) { - nsViewManager* vm = mInnerView->GetViewManager(); + nsIViewManager* vm = mInnerView->GetViewManager(); vm->MoveViewTo(mInnerView, offset.x, offset.y); vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), innerSize), true); } @@ -958,7 +958,7 @@ InsertViewsInReverseOrder(nsView* aSibling, nsView* aParent) NS_PRECONDITION(aParent, ""); NS_PRECONDITION(!aParent->GetFirstChild(), "inserting into non-empty list"); - nsViewManager* vm = aParent->GetViewManager(); + nsIViewManager* vm = aParent->GetViewManager(); while (aSibling) { nsView* next = aSibling->GetNextSibling(); aSibling->SetNextSibling(nullptr); @@ -1092,7 +1092,7 @@ nsSubDocumentFrame::EnsureInnerView() NS_ASSERTION(outerView, "Must have an outer view already"); nsRect viewBounds(0, 0, 0, 0); // size will be fixed during reflow - nsViewManager* viewMan = outerView->GetViewManager(); + nsIViewManager* viewMan = outerView->GetViewManager(); nsView* innerView = viewMan->CreateView(viewBounds, outerView); if (!innerView) { NS_ERROR("Could not create inner view"); diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 2224765fddce..41042894f8e6 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -87,9 +87,10 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsLayoutUtils.h" #include "mozilla/Preferences.h" +#include "nsViewsCID.h" #include "nsWidgetsCID.h" #include "nsIDeviceContextSpec.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" #include "nsRenderingContext.h" @@ -215,6 +216,9 @@ protected: bool mSuppressed; }; +// Class IDs +static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); + NS_IMPL_ISUPPORTS3(nsPrintEngine, nsIWebProgressListener, nsISupportsWeakReference, nsIObserver) @@ -2193,7 +2197,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO) nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDC); NS_ENSURE_SUCCESS(rv, rv); - aPO->mViewManager = new nsViewManager(); + aPO->mViewManager = do_CreateInstance(kViewManagerCID, &rv); + NS_ENSURE_SUCCESS(rv,rv); rv = aPO->mViewManager->Init(mPrt->mPrintDC); NS_ENSURE_SUCCESS(rv,rv); @@ -3788,7 +3793,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out) fprintf(out, "docshell=%p \n", aDocShell); nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell); if (shell) { - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (vm) { nsView* root = vm->GetRootView(); if (root) { diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 2ea10001b046..672d05d56c90 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -12,7 +12,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsStyleSet.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDocShell.h" #include "nsIDocument.h" #include "nsIDocShellTreeOwner.h" @@ -46,7 +46,7 @@ public: nsRefPtr mPresContext; nsCOMPtr mPresShell; - nsRefPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 072b2f216d7d..2e86a23f7c77 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -21,7 +21,7 @@ #include "nsIDOMDocument.h" #include "nsIPresShell.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIFrame.h" #include "nsILayoutDebugger.h" @@ -55,7 +55,7 @@ pres_shell(nsIDocShell *aDocShell) return result.forget(); } -static nsViewManager* +static nsIViewManager* view_manager(nsIDocShell *aDocShell) { nsCOMPtr shell(pres_shell(aDocShell)); @@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsRefPtr vm(view_manager(aDocShell)); + nsCOMPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsRefPtr vm(view_manager(mDocShell)); + nsCOMPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/tools/layout-debug/src/nsRegressionTester.cpp b/layout/tools/layout-debug/src/nsRegressionTester.cpp index af942203e6da..a23195f613db 100644 --- a/layout/tools/layout-debug/src/nsRegressionTester.cpp +++ b/layout/tools/layout-debug/src/nsRegressionTester.cpp @@ -25,7 +25,7 @@ #include "nsLayoutCID.h" #include "nsNetUtil.h" #include "nsIFile.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index 011b9ea9d354..e7c44eb816ed 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -41,7 +41,7 @@ #include "nsGkAtoms.h" #include "nsIContent.h" #include "nsHTMLParts.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsView.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 34932e816285..50f4611bf7f6 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -20,7 +20,7 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsBoxLayoutState.h" #include "nsStackLayout.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsLeafBoxFrame.cpp b/layout/xul/base/src/nsLeafBoxFrame.cpp index 1ce3541532b1..163ed3ce0a30 100644 --- a/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -20,7 +20,7 @@ #include "nsINameSpaceManager.h" #include "nsBoxLayoutState.h" #include "nsWidgetsCID.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsContainerFrame.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index 72eaf2c9f3ad..b5496a07cc1b 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -22,7 +22,7 @@ #include "nsIScrollableFrame.h" #include "nsScrollbarFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsStyleContext.h" #include "nsFontMetrics.h" #include "nsITimer.h" diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index c463591f28d0..eb20199c67c8 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -12,7 +12,7 @@ #include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsMenuFrame.h" #include "nsMenuBarFrame.h" @@ -125,7 +125,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent, // so we use the nsView::SetFloating() to tell the view manager // about that constraint. nsView* ourView = GetView(); - nsViewManager* viewManager = ourView->GetViewManager(); + nsIViewManager* viewManager = ourView->GetViewManager(); viewManager->SetViewFloating(ourView, true); mPopupType = ePopupTypePanel; @@ -459,7 +459,7 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, b } if (isOpen) { - nsViewManager* viewManager = view->GetViewManager(); + nsIViewManager* viewManager = view->GetViewManager(); nsRect rect = GetRect(); rect.x = rect.y = 0; viewManager->ResizeView(view, rect); @@ -794,7 +794,7 @@ nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState) mHFlip = mVFlip = false; nsView* view = GetView(); - nsViewManager* viewManager = view->GetViewManager(); + nsIViewManager* viewManager = view->GetViewManager(); viewManager->SetViewVisibility(view, nsViewVisibility_kHide); FireDOMEvent(NS_LITERAL_STRING("DOMMenuInactive"), mContent); @@ -1919,7 +1919,7 @@ nsMenuPopupFrame::CreatePopupView() return NS_OK; } - nsViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); + nsIViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); NS_ASSERTION(nullptr != viewManager, "null view manager"); // Create a view diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index 10b977609aa9..bcf09d20e979 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -90,7 +90,7 @@ enum FlipStyle { nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); -class nsViewManager; +class nsIViewManager; class nsView; class nsMenuPopupFrame; diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 340fe7ec364a..cf6befa60196 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -20,7 +20,7 @@ #include "nsEventStateManager.h" #include "nsCSSFrameConstructor.h" #include "nsLayoutUtils.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIComponentManager.h" #include "nsITimer.h" #include "nsFocusManager.h" @@ -2262,7 +2262,7 @@ nsXULMenuCommandEvent::Run() if (!pm) return NS_OK; - // The order of the nsViewManager and nsIPresShell COM pointers is + // The order of the nsIViewManager and nsIPresShell COM pointers is // important below. We want the pres shell to get released before the // associated view manager on exit from this function. // See bug 54233. @@ -2295,7 +2295,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsRefPtr kungFuDeathGrip = shell->GetViewManager(); + nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index e0f6f69aa3f8..f889eba2383d 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -39,7 +39,7 @@ #include "nsXPIDLString.h" #include "nsContainerFrame.h" #include "nsView.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsBoxFrame.h" #include "nsBoxObject.h" diff --git a/view/public/Makefile.in b/view/public/Makefile.in index 49effdfb71a2..f4c2731040a9 100644 --- a/view/public/Makefile.in +++ b/view/public/Makefile.in @@ -14,7 +14,8 @@ MODULE = view EXPORTS = \ nsView.h \ - nsViewManager.h \ + nsIViewManager.h \ + nsViewsCID.h \ nsIScrollPositionListener.h \ $(NULL) diff --git a/view/public/nsViewManager.h b/view/public/nsIViewManager.h similarity index 57% rename from view/public/nsViewManager.h rename to view/public/nsIViewManager.h index f5ba8823e065..b8ca74541cbd 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsIViewManager.h @@ -3,16 +3,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsViewManager_h___ -#define nsViewManager_h___ +#ifndef nsIViewManager_h___ +#define nsIViewManager_h___ #include "nscore.h" #include "nsView.h" #include "nsEvent.h" -#include "nsCOMPtr.h" -#include "nsCRT.h" -#include "nsVoidArray.h" -#include "nsDeviceContext.h" class nsIWidget; struct nsRect; @@ -20,25 +16,22 @@ class nsRegion; class nsDeviceContext; class nsIPresShell; -class nsViewManager MOZ_FINAL +#define NS_IVIEWMANAGER_IID \ +{ 0x540610a6, 0x4fdd, 0x4ae3, \ + { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } } + +class nsIViewManager : public nsISupports { public: - friend class nsView; - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_INLINE_DECL_REFCOUNTING(nsViewManager) - - nsViewManager(); - ~nsViewManager(); + NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID) /** * Initialize the ViewManager * Note: this instance does not hold a reference to the presshell * because it holds a reference to this instance. * @result The result of the initialization, NS_OK if no errors */ - nsresult Init(nsDeviceContext* aContext); + NS_IMETHOD Init(nsDeviceContext* aContext) = 0; /** * Create an ordinary view @@ -52,15 +45,15 @@ public: * XXX We should eliminate this parameter; you can set it after CreateView * @result The new view */ - nsView* CreateView(const nsRect& aBounds, - const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); + NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, + const nsView* aParent, + nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0; /** * Get the root of the view tree. * @result the root view */ - nsView* GetRootView() { return mRootView; } + NS_IMETHOD_(nsView*) GetRootView() = 0; /** * Set the root of the view tree. Does not destroy the current root view. @@ -68,7 +61,7 @@ public: * aView may have a widget (anything but printing) or may not (printing). * @param aView view to set as root */ - void SetRootView(nsView *aView); + NS_IMETHOD SetRootView(nsView *aView) = 0; /** * Get the dimensions of the root window. The dimensions are in @@ -76,7 +69,7 @@ public: * @param aWidth out parameter for width of window in twips * @param aHeight out parameter for height of window in twips */ - void GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); + NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0; /** * Set the dimensions of the root window. @@ -85,19 +78,19 @@ public: * @param aWidth of window in twips * @param aHeight of window in twips */ - void SetWindowDimensions(nscoord aWidth, nscoord aHeight); + NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0; /** * Do any resizes that are pending. */ - void FlushDelayedResize(bool aDoReflow); + NS_IMETHOD FlushDelayedResize(bool aDoReflow) = 0; /** * Called to inform the view manager that the entire area of a view * is dirty and needs to be redrawn. * @param aView view to paint. should be root view */ - void InvalidateView(nsView *aView); + NS_IMETHOD InvalidateView(nsView *aView) = 0; /** * Called to inform the view manager that some portion of a view is dirty and @@ -106,12 +99,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - void InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); + NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect) = 0; /** * Called to inform the view manager that it should invalidate all views. */ - void InvalidateAllViews(); + NS_IMETHOD InvalidateAllViews() = 0; /** * Called to dispatch an event to the appropriate view. Often called @@ -121,8 +114,8 @@ public: * @param aViewTarget dispatch the event to this view * @param aStatus event handling status */ - void DispatchEvent(nsGUIEvent *aEvent, - nsView* aViewTarget, nsEventStatus* aStatus); + NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, + nsView* aViewTarget, nsEventStatus* aStatus) = 0; /** * Given a parent view, insert another view as its child. @@ -139,10 +132,8 @@ public: * @param aSibling sibling view * @param aAfter after or before in the document order */ - void InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter); - - void InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); + NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, + bool aAfter) = 0; /** * Remove a specific child view from its parent. This will NOT remove its placeholder @@ -151,7 +142,7 @@ public: * @param aParent parent view * @param aChild child view */ - void RemoveChild(nsView *aChild); + NS_IMETHOD RemoveChild(nsView *aChild) = 0; /** * Move a view to the specified position, provided in parent coordinates. @@ -162,7 +153,7 @@ public: * @param aX x value for new view position * @param aY y value for new view position */ - void MoveViewTo(nsView *aView, nscoord aX, nscoord aY); + NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY) = 0; /** * Resize a view. In addition to setting the width and height, you can @@ -176,8 +167,8 @@ public: * if true Repaint only the expanded or contracted region, * if false Repaint the union of the old and new rectangles. */ - void ResizeView(nsView *aView, const nsRect &aRect, - bool aRepaintExposedAreaOnly = false); + NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, + bool aRepaintExposedAreaOnly = false) = 0; /** * Set the visibility of a view. Hidden views have the effect of hiding @@ -190,7 +181,7 @@ public: * @param aView view to change visibility state of * @param visible new visibility state */ - void SetViewVisibility(nsView *aView, nsViewVisibility aVisible); + NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible) = 0; /** * Set the z-index of a view. Positive z-indices mean that a view @@ -208,7 +199,7 @@ public: * true if the view should be topmost when compared with * other z-index:auto views. */ - void SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); + NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false) = 0; /** * Set whether the view "floats" above all other views, @@ -217,24 +208,24 @@ public: * this view. This is a hack, but it fixes some problems with * views that need to be drawn in front of all other views. */ - void SetViewFloating(nsView *aView, bool aFloatingView); + NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView) = 0; /** * Set the presshell associated with this manager * @param aPresShell - new presshell */ - void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } + virtual void SetPresShell(nsIPresShell *aPresShell) = 0; /** * Get the pres shell associated with this manager */ - nsIPresShell* GetPresShell() { return mPresShell; } + virtual nsIPresShell* GetPresShell() = 0; /** * Get the device context associated with this manager * @result device context */ - void GetDeviceContext(nsDeviceContext *&aContext); + NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext) = 0; /** * A stack class for disallowing changes that would enter painting. For @@ -250,7 +241,7 @@ public: */ class NS_STACK_CLASS AutoDisableRefresh { public: - AutoDisableRefresh(nsViewManager* aVM) { + AutoDisableRefresh(nsIViewManager* aVM) { if (aVM) { mRootVM = aVM->IncrementDisableRefreshCount(); } @@ -264,21 +255,21 @@ public: AutoDisableRefresh(const AutoDisableRefresh& aOther); const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - nsRefPtr mRootVM; + nsCOMPtr mRootVM; }; private: friend class AutoDisableRefresh; - nsViewManager* IncrementDisableRefreshCount(); - void DecrementDisableRefreshCount(); + virtual nsIViewManager* IncrementDisableRefreshCount() = 0; + virtual void DecrementDisableRefreshCount() = 0; public: /** * Retrieve the widget at the root of the nearest enclosing * view manager whose root view has a widget. */ - void GetRootWidget(nsIWidget **aWidget); + NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0; /** * Indicate whether the viewmanager is currently painting @@ -286,7 +277,7 @@ public: * @param aPainting true if the viewmanager is painting * false otherwise */ - void IsPainting(bool& aIsPainting); + NS_IMETHOD IsPainting(bool& aIsPainting)=0; /** * Retrieve the time of the last user event. User events @@ -295,7 +286,7 @@ public: * * @param aTime Last user event time in microseconds */ - void GetLastUserEventTime(uint32_t& aTime); + NS_IMETHOD GetLastUserEventTime(uint32_t& aTime)=0; /** * Find the nearest display root view for the view aView. This is the view for @@ -307,137 +298,14 @@ public: * Flush the accumulated dirty region to the widget and update widget * geometry. */ - void ProcessPendingUpdates(); + virtual void ProcessPendingUpdates()=0; /** * Just update widget geometry without flushing the dirty region */ - void UpdateWidgetGeometry(); - - uint32_t AppUnitsPerDevPixel() const - { - return mContext->AppUnitsPerDevPixel(); - } - -private: - static uint32_t gLastUserEventTime; - - /* Update the cached RootViewManager pointer on this view manager. */ - void InvalidateHierarchy(); - void FlushPendingInvalidates(); - - void ProcessPendingUpdatesForView(nsView *aView, - bool aFlushDirtyRegion = true); - void FlushDirtyRegionToWidget(nsView* aView); - /** - * Call WillPaint() on all view observers under this vm root. - */ - void CallWillPaintOnObservers(bool aWillSendDidPaint); - void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget); - void ReparentWidgets(nsView* aView, nsView *aParent); - void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); - - void InvalidateViews(nsView *aView); - - // aView is the view for aWidget and aRegion is relative to aWidget. - void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint); - - void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); - void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, - nscoord aY1, nscoord aY2, bool aInCutOut); - - // Utilities - - bool IsViewInserted(nsView *aView); - - /** - * Intersects aRect with aView's bounds and then transforms it from aView's - * coordinate system to the coordinate system of the widget attached to - * aView. - */ - nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const; - - void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight); - - bool IsPainting() const { - return RootViewManager()->mPainting; - } - - void SetPainting(bool aPainting) { - RootViewManager()->mPainting = aPainting; - } - - void InvalidateView(nsView *aView, const nsRect &aRect); - - nsViewManager* RootViewManager() const { return mRootViewManager; } - bool IsRootVM() const { return this == RootViewManager(); } - - // Whether synchronous painting is allowed at the moment. For example, - // widget geometry changes can cause synchronous painting, so they need to - // be deferred while refresh is disabled. - bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; } - - void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint); - bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, - uint32_t aFlags); - void DidPaintWindow(); - - // Call this when you need to let the viewmanager know that it now has - // pending updates. - void PostPendingUpdate(); - - nsRefPtr mContext; - nsIPresShell *mPresShell; - - // The size for a resize that we delayed until the root view becomes - // visible again. - nsSize mDelayedResize; - - nsView *mRootView; - // mRootViewManager is a strong ref unless it equals |this|. It's - // never null (if we have no ancestors, it will be |this|). - nsViewManager *mRootViewManager; - - // The following members should not be accessed directly except by - // the root view manager. Some have accessor functions to enforce - // this, as noted. - - int32_t mRefreshDisableCount; - // Use IsPainting() and SetPainting() to access mPainting. - bool mPainting; - bool mRecursiveRefreshPending; - bool mHasPendingWidgetGeometryChanges; - bool mInScroll; - - //from here to public should be static and locked... MMP - static int32_t mVMCount; //number of viewmanagers - - //list of view managers - static nsVoidArray *gViewManagers; + virtual void UpdateWidgetGeometry() = 0; }; -/** - Invalidation model: +NS_DEFINE_STATIC_IID_ACCESSOR(nsIViewManager, NS_IVIEWMANAGER_IID) - 1) Callers call into the view manager and ask it to invalidate a view. - - 2) The view manager finds the "right" widget for the view, henceforth called - the root widget. - - 3) The view manager traverses descendants of the root widget and for each - one that needs invalidation stores the rect to invalidate on the widget's - view (batching). - - 4) The dirty region is flushed to the right widget when - ProcessPendingUpdates is called from the RefreshDriver. - - It's important to note that widgets associated to views outside this view - manager can end up being invalidated during step 3. Therefore, the end of a - view update batch really needs to traverse the entire view tree, to ensure - that those invalidates happen. - - To cope with this, invalidation processing and should only happen on the - root viewmanager. -*/ - -#endif // nsViewManager_h___ +#endif // nsIViewManager_h___ diff --git a/view/public/nsView.h b/view/public/nsView.h index 9e2d9f02c728..a9bade64954b 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -6,14 +6,21 @@ #ifndef nsView_h__ #define nsView_h__ +#include "nsISupports.h" #include "nsCoord.h" #include "nsRect.h" #include "nsPoint.h" +#include "nsNativeWidget.h" +#include "nsIWidget.h" +#include "nsWidgetInitData.h" #include "nsRegion.h" #include "nsCRT.h" +#include "nsIFactory.h" #include "nsEvent.h" #include "nsIWidgetListener.h" +#include +class nsIViewManager; class nsViewManager; class nsIWidget; class nsIFrame; @@ -52,7 +59,7 @@ enum nsViewVisibility { * view manager that owns the views. * * Most of the methods here are read-only. To set the corresponding properties - * of a view, go through nsViewManager. + * of a view, go through nsIViewManager. */ class nsView MOZ_FINAL : public nsIWidgetListener @@ -68,7 +75,9 @@ public: * view manager from somewhere else, do that instead. * @result the view manager */ - nsViewManager* GetViewManager() const { return mViewManager; } + nsIViewManager* GetViewManager() const + { return reinterpret_cast(mViewManager); } + nsViewManager* GetViewManagerInternal() const { return mViewManager; } /** * Find the view for the given widget, if there is one. @@ -451,13 +460,13 @@ private: // released if it points to any view in this view hierarchy. void InvalidateHierarchy(nsViewManager *aViewManagerParent); - nsViewManager *mViewManager; + nsViewManager *mViewManager; nsView *mParent; - nsIWidget *mWindow; + nsIWidget *mWindow; nsView *mNextSibling; nsView *mFirstChild; - nsIFrame *mFrame; - nsRegion *mDirtyRegion; + nsIFrame *mFrame; + nsRegion *mDirtyRegion; int32_t mZIndex; nsViewVisibility mVis; // position relative our parent view origin but in our appunits diff --git a/view/public/nsViewsCID.h b/view/public/nsViewsCID.h new file mode 100644 index 000000000000..5c06871a4235 --- /dev/null +++ b/view/public/nsViewsCID.h @@ -0,0 +1,17 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsViewsCID_h__ +#define nsViewsCID_h__ + +#include "nsISupports.h" +#include "nsIFactory.h" +#include "nsIComponentManager.h" + +#define NS_VIEW_MANAGER_CID \ +{ 0xc95f1831, 0xc376, 0x11d1, \ + {0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}} + +#endif // nsViewsCID_h__ diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index a2dc372a6fdb..31deaad1aecf 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -63,7 +63,7 @@ nsView::~nsView() { DropMouseGrabbing(); - nsView *rootView = mViewManager->GetRootView(); + nsView *rootView = mViewManager->GetRootViewImpl(); if (rootView) { @@ -225,7 +225,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize) { // The geometry of a root view's widget is controlled externally, // NOT by sizing or positioning the view - if (mViewManager->GetRootView() == this) { + if (mViewManager->GetRootViewImpl() == this) { return; } @@ -347,7 +347,7 @@ void nsView::SetFloating(bool aFloatingView) void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent) { - if (mViewManager->GetRootView() == this) + if (mViewManager->GetRootViewImpl() == this) mViewManager->InvalidateHierarchy(); for (nsView *child = mFirstChild; child; child = child->GetNextSibling()) @@ -379,8 +379,8 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // If we just inserted a root view, then update the RootViewManager // on all view managers in the new subtree. - nsViewManager *vm = aChild->GetViewManager(); - if (vm->GetRootView() == aChild) + nsViewManager *vm = aChild->GetViewManagerInternal(); + if (vm->GetRootViewImpl() == aChild) { aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs } @@ -415,10 +415,10 @@ void nsView::RemoveChild(nsView *child) // If we just removed a root view, then update the RootViewManager // on all view managers in the removed subtree. - nsViewManager *vm = child->GetViewManager(); - if (vm->GetRootView() == child) + nsViewManager *vm = child->GetViewManagerInternal(); + if (vm->GetRootViewImpl() == child) { - child->InvalidateHierarchy(GetViewManager()); + child->InvalidateHierarchy(GetViewManagerInternal()); } } } @@ -736,7 +736,7 @@ void nsView::List(FILE* out, int32_t aIndent) const nsPoint nsView::GetOffsetTo(const nsView* aOther) const { - return GetOffsetTo(aOther, GetViewManager()->AppUnitsPerDevPixel()); + return GetOffsetTo(aOther, GetViewManagerInternal()->AppUnitsPerDevPixel()); } nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const @@ -749,11 +749,11 @@ nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const // The offset currently accumulated at the current APD nsPoint docOffset(0, 0); const nsView* v = this; - nsViewManager* currVM = v->GetViewManager(); + nsViewManager* currVM = v->GetViewManagerInternal(); int32_t currAPD = currVM->AppUnitsPerDevPixel(); const nsView* root = nullptr; for ( ; v != aOther && v; root = v, v = v->GetParent()) { - nsViewManager* newVM = v->GetViewManager(); + nsViewManager* newVM = v->GetViewManagerInternal(); if (newVM != currVM) { int32_t newAPD = newVM->AppUnitsPerDevPixel(); if (newAPD != currAPD) { @@ -799,15 +799,15 @@ nsPoint nsView::GetOffsetToWidget(nsIWidget* aWidget) const pt += widgetView->ViewToWidgetOffset(); // Convert to our appunits. - int32_t widgetAPD = widgetView->GetViewManager()->AppUnitsPerDevPixel(); - int32_t ourAPD = GetViewManager()->AppUnitsPerDevPixel(); + int32_t widgetAPD = widgetView->GetViewManagerInternal()->AppUnitsPerDevPixel(); + int32_t ourAPD = GetViewManagerInternal()->AppUnitsPerDevPixel(); pt = pt.ConvertAppUnits(widgetAPD, ourAPD); return pt; } nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset) const { - return GetNearestWidget(aOffset, GetViewManager()->AppUnitsPerDevPixel()); + return GetNearestWidget(aOffset, GetViewManagerInternal()->AppUnitsPerDevPixel()); } nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const @@ -820,10 +820,10 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const // The offset currently accumulated at the current APD nsPoint docPt(0,0); const nsView* v = this; - nsViewManager* currVM = v->GetViewManager(); + nsViewManager* currVM = v->GetViewManagerInternal(); int32_t currAPD = currVM->AppUnitsPerDevPixel(); for ( ; v && !v->HasWidget(); v = v->GetParent()) { - nsViewManager* newVM = v->GetViewManager(); + nsViewManager* newVM = v->GetViewManagerInternal(); if (newVM != currVM) { int32_t newAPD = newVM->AppUnitsPerDevPixel(); if (newAPD != currAPD) { @@ -856,19 +856,19 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const bool nsView::IsRoot() const { NS_ASSERTION(mViewManager != nullptr," View manager is null in nsView::IsRoot()"); - return mViewManager->GetRootView() == this; + return mViewManager->GetRootViewImpl() == this; } nsRect nsView::GetBoundsInParentUnits() const { nsView* parent = GetParent(); - nsViewManager* VM = GetViewManager(); - if (this != VM->GetRootView() || !parent) { + nsViewManager* VM = GetViewManagerInternal(); + if (this != VM->GetRootViewImpl() || !parent) { return mDimBounds; } int32_t ourAPD = VM->AppUnitsPerDevPixel(); - int32_t parentAPD = parent->GetViewManager()->AppUnitsPerDevPixel(); + int32_t parentAPD = parent->GetViewManagerInternal()->AppUnitsPerDevPixel(); return mDimBounds.ConvertAppUnitsRoundOut(ourAPD, parentAPD); } @@ -877,8 +877,8 @@ nsView::ConvertFromParentCoords(nsPoint aPt) const { const nsView* parent = GetParent(); if (parent) { - aPt = aPt.ConvertAppUnits(parent->GetViewManager()->AppUnitsPerDevPixel(), - GetViewManager()->AppUnitsPerDevPixel()); + aPt = aPt.ConvertAppUnits(parent->GetViewManagerInternal()->AppUnitsPerDevPixel(), + GetViewManagerInternal()->AppUnitsPerDevPixel()); } aPt -= GetPosition(); return aPt; @@ -953,7 +953,7 @@ nsView::RequestWindowClose(nsIWidget* aWidget) void nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - nsRefPtr vm = mViewManager; + nsCOMPtr vm = mViewManager; vm->WillPaintWindow(aWidget, aWillSendDidPaint); } @@ -963,7 +963,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?"); mInAlternatePaint = aFlags & PAINT_IS_ALTERNATE; - nsRefPtr vm = mViewManager; + nsCOMPtr vm = mViewManager; bool result = vm->PaintWindow(aWidget, aRegion, aFlags); // PaintWindow can destroy this via WillPaintWindow notification, so we have // to re-get the view from the widget. @@ -977,7 +977,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) void nsView::DidPaintWindow() { - nsRefPtr vm = mViewManager; + nsCOMPtr vm = mViewManager; vm->DidPaintWindow(); } @@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) } if (view) { - nsRefPtr vm = view->GetViewManager(); + nsCOMPtr vm = view->GetViewManager(); vm->DispatchEvent(aEvent, view, &result); } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index b51d1fd34953..442b7056e849 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -46,6 +46,22 @@ #undef DEBUG_MOUSE_LOCATION +static bool +IsRefreshDriverPaintingEnabled() +{ + static bool sRefreshDriverPaintingEnabled; + static bool sRefreshDriverPaintingPrefCached = false; + + if (!sRefreshDriverPaintingPrefCached) { + sRefreshDriverPaintingPrefCached = true; + mozilla::Preferences::AddBoolVarCache(&sRefreshDriverPaintingEnabled, + "viewmanager.refresh-driver-painting.enabled", + true); + } + + return sRefreshDriverPaintingEnabled; +} + int32_t nsViewManager::mVMCount = 0; // Weakly held references to all of the view managers @@ -106,10 +122,11 @@ nsViewManager::~nsViewManager() mPresShell = nullptr; } +NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager) + // We don't hold a reference to the presentation context because it // holds a reference to us. -nsresult -nsViewManager::Init(nsDeviceContext* aContext) +NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) { NS_PRECONDITION(nullptr != aContext, "null ptr"); @@ -124,7 +141,7 @@ nsViewManager::Init(nsDeviceContext* aContext) return NS_OK; } -nsView* +NS_IMETHODIMP_(nsView *) nsViewManager::CreateView(const nsRect& aBounds, const nsView* aParent, nsViewVisibility aVisibilityFlag) @@ -139,8 +156,13 @@ nsViewManager::CreateView(const nsRect& aBounds, return v; } -void -nsViewManager::SetRootView(nsView *aView) +NS_IMETHODIMP_(nsView*) +nsViewManager::GetRootView() +{ + return mRootView; +} + +NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) { NS_PRECONDITION(!aView || aView->GetViewManager() == this, "Unexpected viewmanager on root view"); @@ -162,10 +184,11 @@ nsViewManager::SetRootView(nsView *aView) mRootView->SetZIndex(false, 0, false); } // Else don't touch mRootViewManager + + return NS_OK; } -void -nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) +NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) { if (nullptr != mRootView) { if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) { @@ -182,6 +205,7 @@ nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) *aWidth = 0; *aHeight = 0; } + return NS_OK; } void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) @@ -197,8 +221,7 @@ void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) } } -void -nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) +NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) { if (mRootView) { if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { @@ -221,10 +244,11 @@ nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) } } } + + return NS_OK; } -void -nsViewManager::FlushDelayedResize(bool aDoReflow) +NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow) { if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) { if (aDoReflow) { @@ -237,6 +261,7 @@ nsViewManager::FlushDelayedResize(bool aDoReflow) } } } + return NS_OK; } // Convert aIn from being relative to and in appunits of aFromView, to being @@ -248,12 +273,12 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn, nsRegion out = aIn; out.MoveBy(aFromView->GetOffsetTo(aToView)); out = out.ConvertAppUnitsRoundOut( - aFromView->GetViewManager()->AppUnitsPerDevPixel(), - aToView->GetViewManager()->AppUnitsPerDevPixel()); + aFromView->GetViewManagerInternal()->AppUnitsPerDevPixel(), + aToView->GetViewManagerInternal()->AppUnitsPerDevPixel()); return out; } -nsView* nsViewManager::GetDisplayRootFor(nsView* aView) +nsView* nsIViewManager::GetDisplayRootFor(nsView* aView) { nsView *displayRoot = aView; for (;;) { @@ -332,6 +357,7 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion, printf("--COMPOSITE-- %p\n", mPresShell); #endif mPresShell->Paint(aView, damageRegion, + (IsRefreshDriverPaintingEnabled() ? 0 : nsIPresShell::PAINT_LAYERS) | nsIPresShell::PAINT_COMPOSITE | (aWillSendDidPaint ? nsIPresShell::PAINT_WILL_SEND_DID_PAINT : 0)); #ifdef DEBUG_INVALIDATIONS @@ -372,38 +398,40 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // Push out updates after we've processed the children; ensures that // damage is applied based on the final widget geometry if (aFlushDirtyRegion) { - nsIWidget *widget = aView->GetWidget(); - if (widget && widget->NeedsPaint()) { - // If an ancestor widget was hidden and then shown, we could - // have a delayed resize to handle. - for (nsViewManager *vm = this; vm; - vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManager() - : nullptr) { - if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && - vm->mRootView->IsEffectivelyVisible() && - mPresShell && mPresShell->IsVisible()) { - vm->FlushDelayedResize(true); - vm->InvalidateView(vm->mRootView); + if (IsRefreshDriverPaintingEnabled()) { + nsIWidget *widget = aView->GetWidget(); + if (widget && widget->NeedsPaint()) { + // If an ancestor widget was hidden and then shown, we could + // have a delayed resize to handle. + for (nsViewManager *vm = this; vm; + vm = vm->mRootView->GetParent() + ? vm->mRootView->GetParent()->GetViewManagerInternal() + : nullptr) { + if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && + vm->mRootView->IsEffectivelyVisible() && + mPresShell && mPresShell->IsVisible()) { + vm->FlushDelayedResize(true); + vm->InvalidateView(vm->mRootView); + } } + + NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); + + SetPainting(true); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); +#endif + nsAutoScriptBlocker scriptBlocker; + NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); + mPresShell->Paint(aView, nsRegion(), + nsIPresShell::PAINT_LAYERS | + nsIPresShell::PAINT_WILL_SEND_DID_PAINT); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT END ----\n"); +#endif + aView->SetForcedRepaint(false); + SetPainting(false); } - - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - - SetPainting(true); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); -#endif - nsAutoScriptBlocker scriptBlocker; - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - mPresShell->Paint(aView, nsRegion(), - nsIPresShell::PAINT_LAYERS | - nsIPresShell::PAINT_WILL_SEND_DID_PAINT); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT END ----\n"); -#endif - aView->SetForcedRepaint(false); - SetPainting(false); } FlushDirtyRegionToWidget(aView); } @@ -422,16 +450,15 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) } nsRegion r = ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget); - nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager(); + nsViewManager* widgetVM = nearestViewWithWidget->GetViewManagerInternal(); widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r); dirtyRegion->SetEmpty(); } -void -nsViewManager::InvalidateView(nsView *aView) +NS_IMETHODIMP nsViewManager::InvalidateView(nsView *aView) { // Mark the entire view as damaged - InvalidateView(aView, aView->GetDimensions()); + return InvalidateView(aView, aView->GetDimensions()); } static void @@ -544,27 +571,25 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) if (!shell || shell->ShouldIgnoreInvalidation()) { return true; } - nsView* view = aVM->GetRootView()->GetParent(); - aVM = view ? view->GetViewManager() : nullptr; + nsView* view = aVM->GetRootViewImpl()->GetParent(); + aVM = view ? view->GetViewManagerInternal() : nullptr; } return false; } -void -nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect) +nsresult nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect) { // If painting is suppressed in the presshell or an ancestor drop all // invalidates, it will invalidate everything when it unsuppresses. if (ShouldIgnoreInvalidation(this)) { - return; + return NS_OK; } - InvalidateViewNoSuppression(aView, aRect); + return InvalidateViewNoSuppression(aView, aRect); } -void -nsViewManager::InvalidateViewNoSuppression(nsView *aView, - const nsRect &aRect) +NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, + const nsRect &aRect) { NS_PRECONDITION(nullptr != aView, "null view"); @@ -573,11 +598,11 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView, nsRect damagedRect(aRect); if (damagedRect.IsEmpty()) { - return; + return NS_OK; } nsView* displayRoot = GetDisplayRootFor(aView); - nsViewManager* displayRootVM = displayRoot->GetViewManager(); + nsViewManager* displayRootVM = displayRoot->GetViewManagerInternal(); // Propagate the update to the displayRoot, since iframes, for example, // can overlap each other and be translucent. So we have to possibly // invalidate our rect in each of the widgets we have lying about. @@ -589,16 +614,18 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView, // accumulate this rectangle in the view's dirty region, so we can // process it later. AddDirtyRegion(displayRoot, nsRegion(damagedRect)); + + return NS_OK; } -void -nsViewManager::InvalidateAllViews() +NS_IMETHODIMP nsViewManager::InvalidateAllViews() { if (RootViewManager() != this) { return RootViewManager()->InvalidateAllViews(); } InvalidateViews(mRootView); + return NS_OK; } void nsViewManager::InvalidateViews(nsView *aView) @@ -609,14 +636,37 @@ void nsViewManager::InvalidateViews(nsView *aView) // Invalidate all children as well. nsView* childView = aView->GetFirstChild(); while (nullptr != childView) { - childView->GetViewManager()->InvalidateViews(childView); + childView->GetViewManagerInternal()->InvalidateViews(childView); childView = childView->GetNextSibling(); } } void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - if (aWidget) { + if (!IsRefreshDriverPaintingEnabled() && aWidget && mContext) { + // If an ancestor widget was hidden and then shown, we could + // have a delayed resize to handle. + for (nsViewManager *vm = this; vm; + vm = vm->mRootView->GetParent() + ? vm->mRootView->GetParent()->GetViewManagerInternal() + : nullptr) { + if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && + vm->mRootView->IsEffectivelyVisible() && + mPresShell && mPresShell->IsVisible()) { + vm->FlushDelayedResize(true); + vm->InvalidateView(vm->mRootView); + } + } + + // Flush things like reflows by calling WillPaint on observer presShells. + nsRefPtr rootVM = RootViewManager(); + rootVM->CallWillPaintOnObservers(aWillSendDidPaint); + + // Flush view widget geometry updates and invalidations. + rootVM->ProcessPendingUpdates(); + } + + if (aWidget && IsRefreshDriverPaintingEnabled()) { nsView* view = nsView::GetViewFor(aWidget); if (view && view->ForcedRepaint()) { ProcessPendingUpdates(); @@ -644,6 +694,10 @@ bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, NS_ASSERTION(IsPaintingAllowed(), "shouldn't be receiving paint events while painting is disallowed!"); + if (!(aFlags & nsIWidgetListener::SENT_WILL_PAINT) && !IsRefreshDriverPaintingEnabled()) { + WillPaintWindow(aWidget, (aFlags & nsIWidgetListener::WILL_SEND_DID_PAINT)); + } + // Get the view pointer here since NS_WILL_PAINT might have // destroyed it during CallWillPaintOnObservers (bug 378273). nsView* view = nsView::GetViewFor(aWidget); @@ -662,8 +716,7 @@ void nsViewManager::DidPaintWindow() } } -void -nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) +nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) { SAMPLE_LABEL("event", "nsViewManager::DispatchEvent"); @@ -714,11 +767,13 @@ nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* a // want to cause its destruction in, say, some JavaScript event handler. nsCOMPtr shell = view->GetViewManager()->GetPresShell(); if (shell) { - shell->HandleEvent(frame, aEvent, false, aStatus); + return shell->HandleEvent(frame, aEvent, false, aStatus); } } *aStatus = nsEventStatus_eIgnore; + + return NS_OK; } // Recursively reparent widgets if necessary @@ -782,9 +837,8 @@ void nsViewManager::ReparentWidgets(nsView* aView, nsView *aParent) } } -void -nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter) +NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, + bool aAfter) { NS_PRECONDITION(nullptr != aParent, "null ptr"); NS_PRECONDITION(nullptr != aChild, "null ptr"); @@ -843,36 +897,36 @@ nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, //and mark this area as dirty if the view is visible... if (nsViewVisibility_kHide != aChild->GetVisibility()) - aChild->GetViewManager()->InvalidateView(aChild); + aChild->GetViewManagerInternal()->InvalidateView(aChild); } + return NS_OK; } -void -nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex) +NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex) { // no-one really calls this with anything other than aZIndex == 0 on a fresh view // XXX this method should simply be eliminated and its callers redirected to the real method SetViewZIndex(aChild, false, aZIndex, false); - InsertChild(aParent, aChild, nullptr, true); + return InsertChild(aParent, aChild, nullptr, true); } -void -nsViewManager::RemoveChild(nsView *aChild) +NS_IMETHODIMP nsViewManager::RemoveChild(nsView *aChild) { - NS_ASSERTION(aChild, "aChild must not be null"); + NS_ENSURE_ARG_POINTER(aChild); nsView* parent = aChild->GetParent(); if (nullptr != parent) { NS_ASSERTION(aChild->GetViewManager() == this || parent->GetViewManager() == this, "wrong view manager"); - aChild->GetViewManager()->InvalidateView(aChild); + aChild->GetViewManagerInternal()->InvalidateView(aChild); parent->RemoveChild(aChild); } + + return NS_OK; } -void -nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) +NS_IMETHODIMP nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); nsPoint oldPt = aView->GetPosition(); @@ -885,12 +939,13 @@ nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) if (aView->GetVisibility() != nsViewVisibility_kHide) { nsView* parentView = aView->GetParent(); if (parentView) { - nsViewManager* parentVM = parentView->GetViewManager(); + nsViewManager* parentVM = parentView->GetViewManagerInternal(); parentVM->InvalidateView(parentView, oldBounds); parentVM->InvalidateView(parentView, aView->GetBoundsInParentUnits()); } } } + return NS_OK; } void nsViewManager::InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, @@ -924,8 +979,7 @@ void nsViewManager::InvalidateRectDifference(nsView *aView, const nsRect& aRect, } } -void -nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly) +NS_IMETHODIMP nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -942,7 +996,7 @@ nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExpos } nsRect oldBounds = aView->GetBoundsInParentUnits(); aView->SetDimensions(aRect, true); - nsViewManager* parentVM = parentView->GetViewManager(); + nsViewManager* parentVM = parentView->GetViewManagerInternal(); if (!aRepaintExposedAreaOnly) { // Invalidate the union of the old and new size InvalidateView(aView, aRect); @@ -960,18 +1014,20 @@ nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExpos // in the case where mClipRect has been optimized away to just be a null // pointer, and this resize is implicitly changing the clip rect, it's OK // because layout will change it back again if necessary. + + return NS_OK; } -void -nsViewManager::SetViewFloating(nsView *aView, bool aFloating) +NS_IMETHODIMP nsViewManager::SetViewFloating(nsView *aView, bool aFloating) { NS_ASSERTION(!(nullptr == aView), "no view"); aView->SetFloating(aFloating); + + return NS_OK; } -void -nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) +NS_IMETHODIMP nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -983,7 +1039,7 @@ nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) if (nsViewVisibility_kHide == aVisible) { nsView* parentView = aView->GetParent(); if (parentView) { - parentView->GetViewManager()-> + parentView->GetViewManagerInternal()-> InvalidateView(parentView, aView->GetBoundsInParentUnits()); } } @@ -993,6 +1049,7 @@ nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) } } } + return NS_OK; } bool nsViewManager::IsViewInserted(nsView *aView) @@ -1006,22 +1063,23 @@ bool nsViewManager::IsViewInserted(nsView *aView) while (view != nullptr) { if (view == aView) { return true; - } + } view = view->GetNextSibling(); } return false; } } -void -nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost) +NS_IMETHODIMP nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost) { + nsresult rv = NS_OK; + NS_ASSERTION((aView != nullptr), "no view"); // don't allow the root view's z-index to be changed. It should always be zero. // This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences if (aView == mRootView) { - return; + return rv; } bool oldTopMost = aView->IsTopMost(); @@ -1038,16 +1096,18 @@ nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, b oldIsAuto != aAutoZIndex) { InvalidateView(aView); } + + return rv; } -void -nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) +NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) { aContext = mContext; NS_IF_ADDREF(aContext); + return NS_OK; } -nsViewManager* +nsIViewManager* nsViewManager::IncrementDisableRefreshCount() { if (!IsRootVM()) { @@ -1067,23 +1127,21 @@ nsViewManager::DecrementDisableRefreshCount() NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!"); } -void -nsViewManager::GetRootWidget(nsIWidget **aWidget) +NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget) { if (!mRootView) { *aWidget = nullptr; - return; + return NS_OK; } if (mRootView->HasWidget()) { *aWidget = mRootView->GetWidget(); NS_ADDREF(*aWidget); - return; - } - if (mRootView->GetParent()) { - mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget); - return; + return NS_OK; } + if (mRootView->GetParent()) + return mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); *aWidget = nullptr; + return NS_OK; } nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const @@ -1097,10 +1155,11 @@ nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const return rect.ToOutsidePixels(AppUnitsPerDevPixel()); } -void +NS_IMETHODIMP nsViewManager::IsPainting(bool& aIsPainting) { aIsPainting = IsPainting(); + return NS_OK; } void @@ -1111,13 +1170,17 @@ nsViewManager::ProcessPendingUpdates() return; } - mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush(); - - // Flush things like reflows by calling WillPaint on observer presShells. - if (mPresShell) { - CallWillPaintOnObservers(true); + if (IsRefreshDriverPaintingEnabled()) { + mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush(); + + // Flush things like reflows by calling WillPaint on observer presShells. + if (mPresShell) { + CallWillPaintOnObservers(true); + } + ProcessPendingUpdatesForView(mRootView, true); + } else { + ProcessPendingUpdatesForView(mRootView, true); } - ProcessPendingUpdatesForView(mRootView, true); } void @@ -1129,8 +1192,13 @@ nsViewManager::UpdateWidgetGeometry() } if (mHasPendingWidgetGeometryChanges) { - mHasPendingWidgetGeometryChanges = false; + if (IsRefreshDriverPaintingEnabled()) { + mHasPendingWidgetGeometryChanges = false; + } ProcessPendingUpdatesForView(mRootView, false); + if (!IsRefreshDriverPaintingEnabled()) { + mHasPendingWidgetGeometryChanges = false; + } } } @@ -1154,10 +1222,11 @@ nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint) } } -void +NS_IMETHODIMP nsViewManager::GetLastUserEventTime(uint32_t& aTime) { aTime = gLastUserEventTime; + return NS_OK; } void @@ -1169,7 +1238,7 @@ nsViewManager::InvalidateHierarchy() } nsView *parent = mRootView->GetParent(); if (parent) { - mRootViewManager = parent->GetViewManager()->RootViewManager(); + mRootViewManager = parent->GetViewManagerInternal()->RootViewManager(); NS_ADDREF(mRootViewManager); NS_ASSERTION(mRootViewManager != this, "Root view had a parent, but it has the same view manager"); diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h new file mode 100644 index 000000000000..7315a3bd6683 --- /dev/null +++ b/view/src/nsViewManager.h @@ -0,0 +1,214 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsViewManager_h___ +#define nsViewManager_h___ +#include "nsCOMPtr.h" +#include "nsIViewManager.h" +#include "nsCRT.h" +#include "nsITimer.h" +#include "prtime.h" +#include "prinrval.h" +#include "nsVoidArray.h" +#include "nsThreadUtils.h" +#include "nsIPresShell.h" +#include "nsDeviceContext.h" + + +/** + Invalidation model: + + 1) Callers call into the view manager and ask it to invalidate a view. + + 2) The view manager finds the "right" widget for the view, henceforth called + the root widget. + + 3) The view manager traverses descendants of the root widget and for each + one that needs invalidation stores the rect to invalidate on the widget's + view (batching). + + 4) The dirty region is flushed to the right widget when + ProcessPendingUpdates is called from the RefreshDriver. + + It's important to note that widgets associated to views outside this view + manager can end up being invalidated during step 3. Therefore, the end of a + view update batch really needs to traverse the entire view tree, to ensure + that those invalidates happen. + + To cope with this, invalidation processing and should only happen on the + root viewmanager. +*/ + +class nsViewManager : public nsIViewManager { +public: + nsViewManager(); + + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init(nsDeviceContext* aContext); + + NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, + const nsView* aParent, + nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); + + NS_IMETHOD_(nsView*) GetRootView(); + NS_IMETHOD SetRootView(nsView *aView); + + NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height); + NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); + NS_IMETHOD FlushDelayedResize(bool aDoReflow); + + NS_IMETHOD InvalidateView(nsView *aView); + NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); + NS_IMETHOD InvalidateAllViews(); + + NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, + nsView* aTargetView, nsEventStatus* aStatus); + + NS_IMETHOD InsertChild(nsView *parent, nsView *child, nsView *sibling, + bool above); + + NS_IMETHOD InsertChild(nsView *parent, nsView *child, + int32_t zindex); + + NS_IMETHOD RemoveChild(nsView *parent); + + NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); + + NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly = false); + + NS_IMETHOD SetViewFloating(nsView *aView, bool aFloating); + + NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); + + NS_IMETHOD SetViewZIndex(nsView *aView, bool aAuto, int32_t aZIndex, bool aTopMost=false); + + virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } + virtual nsIPresShell* GetPresShell() { return mPresShell; } + + NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); + + virtual nsIViewManager* IncrementDisableRefreshCount(); + virtual void DecrementDisableRefreshCount(); + + NS_IMETHOD GetRootWidget(nsIWidget **aWidget); + + NS_IMETHOD IsPainting(bool& aIsPainting); + NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); + static uint32_t gLastUserEventTime; + + /* Update the cached RootViewManager pointer on this view manager. */ + void InvalidateHierarchy(); + + virtual void ProcessPendingUpdates(); + virtual void UpdateWidgetGeometry(); + +protected: + virtual ~nsViewManager(); + +private: + + void FlushPendingInvalidates(); + void ProcessPendingUpdatesForView(nsView *aView, + bool aFlushDirtyRegion = true); + void FlushDirtyRegionToWidget(nsView* aView); + /** + * Call WillPaint() on all view observers under this vm root. + */ + void CallWillPaintOnObservers(bool aWillSendDidPaint); + void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget); + void ReparentWidgets(nsView* aView, nsView *aParent); + void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); + + void InvalidateViews(nsView *aView); + + // aView is the view for aWidget and aRegion is relative to aWidget. + void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint); + + void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); + void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, + nscoord aY1, nscoord aY2, bool aInCutOut); + + // Utilities + + bool IsViewInserted(nsView *aView); + + /** + * Intersects aRect with aView's bounds and then transforms it from aView's + * coordinate system to the coordinate system of the widget attached to + * aView. + */ + nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const; + + void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight); + + bool IsPainting() const { + return RootViewManager()->mPainting; + } + + void SetPainting(bool aPainting) { + RootViewManager()->mPainting = aPainting; + } + + nsresult InvalidateView(nsView *aView, const nsRect &aRect); + +public: // NOT in nsIViewManager, so private to the view module + nsView* GetRootViewImpl() const { return mRootView; } + nsViewManager* RootViewManager() const { return mRootViewManager; } + bool IsRootVM() const { return this == RootViewManager(); } + + // Whether synchronous painting is allowed at the moment. For example, + // widget geometry changes can cause synchronous painting, so they need to + // be deferred while refresh is disabled. + bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; } + + void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint); + bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, + uint32_t aFlags); + void DidPaintWindow(); + + // Call this when you need to let the viewmanager know that it now has + // pending updates. + void PostPendingUpdate(); + + uint32_t AppUnitsPerDevPixel() const + { + return mContext->AppUnitsPerDevPixel(); + } + +private: + nsRefPtr mContext; + nsIPresShell *mPresShell; + + // The size for a resize that we delayed until the root view becomes + // visible again. + nsSize mDelayedResize; + + nsView *mRootView; + // mRootViewManager is a strong ref unless it equals |this|. It's + // never null (if we have no ancestors, it will be |this|). + nsViewManager *mRootViewManager; + + // The following members should not be accessed directly except by + // the root view manager. Some have accessor functions to enforce + // this, as noted. + + int32_t mRefreshDisableCount; + // Use IsPainting() and SetPainting() to access mPainting. + bool mPainting; + bool mRecursiveRefreshPending; + bool mHasPendingWidgetGeometryChanges; + bool mInScroll; + + //from here to public should be static and locked... MMP + static int32_t mVMCount; //number of viewmanagers + + //list of view managers + static nsVoidArray *gViewManagers; +}; + +#endif /* nsViewManager_h___ */ diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 7d42ad969b03..6c86c30ccdab 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -23,7 +23,7 @@ using mozilla::unused; #include "nsIObserverService.h" #include "nsFocusManager.h" #include "nsIWidgetListener.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsRenderingContext.h" #include "nsIDOMSimpleGestureEvent.h" diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 71ea4e226fa8..0f84ca234fec 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -23,7 +23,7 @@ #include "nsFontMetrics.h" #include "nsIRollupListener.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIInterfaceRequestor.h" #include "nsIFile.h" #include "nsILocalFileMac.h" diff --git a/widget/gtk2/nsDragService.cpp b/widget/gtk2/nsDragService.cpp index 73900e74ffed..2f98d290ca39 100644 --- a/widget/gtk2/nsDragService.cpp +++ b/widget/gtk2/nsDragService.cpp @@ -31,7 +31,7 @@ #include "nsPresContext.h" #include "nsIDocument.h" #include "nsISelection.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIFrame.h" // This sets how opaque the drag image is @@ -269,7 +269,7 @@ GetGtkWindow(nsIDOMDocument *aDocument) if (!presShell) return NULL; - nsRefPtr vm = presShell->GetViewManager(); + nsCOMPtr vm = presShell->GetViewManager(); if (!vm) return NULL; diff --git a/widget/gtk2/nsNativeThemeGTK.cpp b/widget/gtk2/nsNativeThemeGTK.cpp index 35b786aec4c5..59132735dada 100644 --- a/widget/gtk2/nsNativeThemeGTK.cpp +++ b/widget/gtk2/nsNativeThemeGTK.cpp @@ -12,7 +12,7 @@ #include "nsIFrame.h" #include "nsIPresShell.h" #include "nsIContent.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsINameSpaceManager.h" #include "nsGfxCIID.h" #include "nsTransform2D.h" @@ -75,7 +75,7 @@ nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame) if (!shell) return; - nsViewManager* vm = shell->GetViewManager(); + nsIViewManager* vm = shell->GetViewManager(); if (!vm) return; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index e9f4cc049911..150c72c075a6 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -65,7 +65,7 @@ template class nsReadingIterator; #include "nsIDOMHTMLTextAreaElement.h" #include "nsIDOMElement.h" #include "nsISelectionController.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsTArray.h" #include "nsGUIEvent.h" @@ -3144,7 +3144,7 @@ TestApp::GetWidget(nsIWidget** aWidget) return false; } - nsRefPtr viewManager = presShell->GetViewManager(); + nsCOMPtr viewManager = presShell->GetViewManager(); if (!viewManager) { return false; } diff --git a/widget/xpwidgets/nsBaseDragService.cpp b/widget/xpwidgets/nsBaseDragService.cpp index 60c677fb00e3..df2bb433365b 100644 --- a/widget/xpwidgets/nsBaseDragService.cpp +++ b/widget/xpwidgets/nsBaseDragService.cpp @@ -18,7 +18,7 @@ #include "nsIDocument.h" #include "nsIContent.h" #include "nsIPresShell.h" -#include "nsViewManager.h" +#include "nsIViewManager.h" #include "nsIDOMNode.h" #include "nsIDOMDragEvent.h" #include "nsISelection.h" From 537115a7259e83e066116506f29d04bf383b0131 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 4 Jan 2013 22:23:50 -0800 Subject: [PATCH 131/180] Bug 806494 - Fix resource header copying on internal redirect. r=gps --- services/sync/modules/resource.js | 11 ++- .../sync/tests/unit/test_resource_header.js | 69 +++++++++++++++++++ services/sync/tests/unit/xpcshell.ini | 1 + 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 services/sync/tests/unit/test_resource_header.js diff --git a/services/sync/modules/resource.js b/services/sync/modules/resource.js index 9a5ee4beed67..bb5b8b53c78f 100644 --- a/services/sync/modules/resource.js +++ b/services/sync/modules/resource.js @@ -631,12 +631,21 @@ ChannelNotificationListener.prototype = { if ((flags & Ci.nsIChannelEventSink.REDIRECT_INTERNAL) && newChannel.URI.equals(oldChannel.URI)) { this._log.debug("Copying headers for safe internal redirect."); + + // QI the channel so we can set headers on it. + try { + newChannel.QueryInterface(Ci.nsIHttpChannel); + } catch (ex) { + this._log.error("Unexpected error: channel is not a nsIHttpChannel!"); + throw ex; + } + for (let header of this._headersToCopy) { let value = oldChannel.getRequestHeader(header); if (value) { let printed = (header == "authorization") ? "****" : value; this._log.debug("Header: " + header + " = " + printed); - newChannel.setRequestHeader(header, value); + newChannel.setRequestHeader(header, value, false); } else { this._log.warn("No value for header " + header); } diff --git a/services/sync/tests/unit/test_resource_header.js b/services/sync/tests/unit/test_resource_header.js new file mode 100644 index 000000000000..0c65f3c52ebc --- /dev/null +++ b/services/sync/tests/unit/test_resource_header.js @@ -0,0 +1,69 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +Cu.import("resource://testing-common/httpd.js"); +Cu.import("resource://services-sync/resource.js"); + +function run_test() { + initTestLogging("Trace"); + run_next_test(); +} + +const TEST_URL = "http://localhost:4444/content"; +const HTTP_PORT = 4444; +const BODY = "response body"; + +// Keep headers for later inspection. +let auth = null; +let foo = null; +function contentHandler(metadata, response) { + _("Handling request."); + auth = metadata.getHeader("Authorization"); + foo = metadata.getHeader("X-Foo"); + + _("Extracted headers. " + auth + ", " + foo); + + response.setHeader("Content-Type", "text/plain"); + response.bodyOutputStream.write(BODY, BODY.length); +} + +function makeServer() { + let httpServer = new HttpServer(); + httpServer.registerPathHandler("/content", contentHandler); + httpServer.start(4444); + return httpServer; +} + +// Set a proxy function to cause an internal redirect. +function triggerRedirect() { + const PROXY_FUNCTION = "function FindProxyForURL(url, host) {" + + " return 'PROXY a_non_existent_domain_x7x6c572v:80; " + + "PROXY localhost:4444';" + + "}"; + + let prefsService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService); + let prefs = prefsService.getBranch("network.proxy."); + prefs.setIntPref("type", 2); + prefs.setCharPref("autoconfig_url", "data:text/plain," + PROXY_FUNCTION); +} + +add_test(function test_headers_copied() { + let server = makeServer(); + triggerRedirect(); + + _("Issuing request."); + let resource = new Resource(TEST_URL); + resource.setHeader("Authorization", "Basic foobar"); + resource.setHeader("X-Foo", "foofoo"); + + let result = resource.get(TEST_URL); + _("Result: " + result); + + do_check_eq(result, BODY); + do_check_eq(auth, "Basic foobar"); + do_check_eq(foo, "foofoo"); + + server.stop(run_next_test); +}); diff --git a/services/sync/tests/unit/xpcshell.ini b/services/sync/tests/unit/xpcshell.ini index bbe127d17eeb..1d62447326ad 100644 --- a/services/sync/tests/unit/xpcshell.ini +++ b/services/sync/tests/unit/xpcshell.ini @@ -34,6 +34,7 @@ skip-if = os == "win" || os == "android" # HTTP layers. [test_resource.js] [test_resource_async.js] +[test_resource_header.js] [test_resource_ua.js] [test_syncstoragerequest.js] From 23ba3ed604e2fa0d5991f2c71945d6eb8bc4dbee Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Sat, 5 Jan 2013 10:21:04 +0100 Subject: [PATCH 132/180] Bug 825849 - Add a RemoveAllDownloads API to nsIDownloadHistory. r=Mano sr=gavin --- .../content/allDownloadsViewOverlay.js | 23 +- .../content/allDownloadsViewOverlay.xul | 8 + .../chrome/browser/downloads/downloads.dtd | 2 + docshell/base/nsDownloadHistory.cpp | 6 + docshell/base/nsIDownloadHistory.idl | 19 +- .../downloads/nsDownloadManager.cpp | 2 +- toolkit/components/places/History.cpp | 421 +++++++++++++++++- toolkit/components/places/History.h | 8 + .../places/nsINavHistoryService.idl | 8 +- toolkit/components/places/nsNavBookmarks.cpp | 2 +- toolkit/components/places/nsNavHistory.cpp | 7 +- .../components/places/nsNavHistoryResult.cpp | 18 +- .../components/places/nsNavHistoryResult.h | 3 +- .../nsPIPlacesHistoryListenersNotifier.idl | 8 +- .../components/places/nsPlacesExpiration.js | 2 +- .../components/places/tests/head_common.js | 2 +- .../tests/unit/test_download_history.js | 129 ++++-- 17 files changed, 608 insertions(+), 60 deletions(-) diff --git a/browser/components/downloads/content/allDownloadsViewOverlay.js b/browser/components/downloads/content/allDownloadsViewOverlay.js index 63cfdd7f9d87..144106a7d32c 100644 --- a/browser/components/downloads/content/allDownloadsViewOverlay.js +++ b/browser/components/downloads/content/allDownloadsViewOverlay.js @@ -12,12 +12,16 @@ let Cu = Components.utils; let Ci = Components.interfaces; let Cc = Components.classes; +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/DownloadUtils.jsm"); Cu.import("resource:///modules/DownloadsCommon.jsm"); Cu.import("resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", + "resource://gre/modules/PrivateBrowsingUtils.jsm"); + const nsIDM = Ci.nsIDownloadManager; const DESTINATION_FILE_URI_ANNO = "downloads/destinationFileURI"; @@ -28,7 +32,7 @@ const DOWNLOAD_VIEW_SUPPORTED_COMMANDS = ["cmd_delete", "cmd_copy", "cmd_paste", "cmd_selectAll", "downloadsCmd_pauseResume", "downloadsCmd_cancel", "downloadsCmd_open", "downloadsCmd_show", "downloadsCmd_retry", - "downloadsCmd_openReferrer"]; + "downloadsCmd_openReferrer", "downloadsCmd_clearDownloads"]; const NOT_AVAILABLE = Number.MAX_VALUE; @@ -826,7 +830,7 @@ DownloadsPlacesView.prototype = { } else { let before = this._lastSessionDownloadElement ? - this._lastSessionDownloadElement.nextSibling : this._richlistbox.firstchild; + this._lastSessionDownloadElement.nextSibling : this._richlistbox.firstChild; this._richlistbox.insertBefore(shell.element, before); } } @@ -965,6 +969,7 @@ DownloadsPlacesView.prototype = { sortingChanged: function() {}, nodeMoved: function() {}, nodeURIChanged: function() {}, + batching: function() {}, get controller() this._richlistbox.controller, @@ -1012,6 +1017,8 @@ DownloadsPlacesView.prototype = { return true; case "cmd_paste": return this._canDownloadClipboardURL(); + case "downloadsCmd_clearDownloads": + return !!this._richlistbox.firstChild; default: return Array.every(selectedElements, function(element) { return element._shell.isCommandEnabled(aCommand); @@ -1073,6 +1080,18 @@ DownloadsPlacesView.prototype = { case "cmd_paste": this._downloadURLFromClipboard(); break; + case "downloadsCmd_clearDownloads": + if (PrivateBrowsingUtils.isWindowPrivate(window)) { + Services.downloads.cleanUpPrivate(); + } else { + Services.downloads.cleanUp(); + } + if (this.result) { + Cc["@mozilla.org/browser/download-history;1"] + .getService(Ci.nsIDownloadHistory) + .removeAllDownloads(); + } + break; default: { let selectedElements = this._richlistbox.selectedItems; for (let element of selectedElements) { diff --git a/browser/components/downloads/content/allDownloadsViewOverlay.xul b/browser/components/downloads/content/allDownloadsViewOverlay.xul index 6fc702e6c3a4..3b30aa173107 100644 --- a/browser/components/downloads/content/allDownloadsViewOverlay.xul +++ b/browser/components/downloads/content/allDownloadsViewOverlay.xul @@ -64,6 +64,8 @@ oncommand="goDoCommand('downloadsCmd_retry')"/> + @@ -102,5 +104,11 @@ + + + + diff --git a/browser/locales/en-US/chrome/browser/downloads/downloads.dtd b/browser/locales/en-US/chrome/browser/downloads/downloads.dtd index 86b3f0af2729..506d799d9275 100644 --- a/browser/locales/en-US/chrome/browser/downloads/downloads.dtd +++ b/browser/locales/en-US/chrome/browser/downloads/downloads.dtd @@ -64,6 +64,8 @@ + + + + + From 6830dc7b3a6fb5aabb16e6fe5924f128ceaf3c0c Mon Sep 17 00:00:00 2001 From: Asaf Romano Date: Sat, 5 Jan 2013 16:49:58 +0200 Subject: [PATCH 145/180] Bug 826425 - double-click on finished downloads in Library view doesn't open them. r=mak. --- .../downloads/content/allDownloadsViewOverlay.js | 13 +++++++++++++ .../downloads/content/allDownloadsViewOverlay.xul | 1 + 2 files changed, 14 insertions(+) diff --git a/browser/components/downloads/content/allDownloadsViewOverlay.js b/browser/components/downloads/content/allDownloadsViewOverlay.js index ca4f3fd2d969..21a54362c9a7 100644 --- a/browser/components/downloads/content/allDownloadsViewOverlay.js +++ b/browser/components/downloads/content/allDownloadsViewOverlay.js @@ -1185,6 +1185,19 @@ DownloadsPlacesView.prototype = { element._shell.doCommand("downloadsCmd_pauseResume"); } } + }, + + onDoubleClick: function DPV_onDoubleClick(aEvent) { + if (aEvent.button != 0) + return; + + let selectedElements = this._richlistbox.selectedItems; + if (!selectedElements || selectedElements.length != 1) + return; + + let element = selectedElements[0]; + if (element._shell) + element._shell.doDefaultCommand(); } }; diff --git a/browser/components/downloads/content/allDownloadsViewOverlay.xul b/browser/components/downloads/content/allDownloadsViewOverlay.xul index 3b30aa173107..a4221cf4e01e 100644 --- a/browser/components/downloads/content/allDownloadsViewOverlay.xul +++ b/browser/components/downloads/content/allDownloadsViewOverlay.xul @@ -43,6 +43,7 @@ seltype="multiple" id="downloadsRichListBox" context="downloadsContextMenu" onkeypress="return this._placesView.onKeyPress(event);" + ondblclick="return this._placesView.onDoubleClick(event);" oncontextmenu="return this._placesView.onContextMenu(event);" onfocus="goUpdateDownloadCommands();" onselect="goUpdateDownloadCommands();" From 2d5f17e9d1bdf5c951a8482280afed8f2cff0473 Mon Sep 17 00:00:00 2001 From: Soumya Deb Date: Sat, 5 Jan 2013 16:00:32 +0100 Subject: [PATCH 146/180] Bug 821969 - Un-prefix CSS gradients. r=dao --- browser/themes/gnomestripe/browser.css | 61 ++++--- browser/themes/pinstripe/browser.css | 66 ++++---- browser/themes/winstripe/browser-aero.css | 22 +-- browser/themes/winstripe/browser.css | 187 +++++++++++----------- 4 files changed, 167 insertions(+), 169 deletions(-) diff --git a/browser/themes/gnomestripe/browser.css b/browser/themes/gnomestripe/browser.css index 51843571600a..2b0b80ba1d69 100644 --- a/browser/themes/gnomestripe/browser.css +++ b/browser/themes/gnomestripe/browser.css @@ -55,7 +55,7 @@ #nav-bar[tabsontop=true], #nav-bar[tabsontop=true][collapsed=true]:not([customizing]) + toolbar, #nav-bar[tabsontop=true][collapsed=true]:not([customizing]) + #customToolbars + #PersonalToolbar { - background-image: -moz-linear-gradient(@toolbarHighlight@, rgba(255,255,255,0)); + background-image: linear-gradient(@toolbarHighlight@, rgba(255,255,255,0)); } #personal-bookmarks { @@ -1057,10 +1057,10 @@ toolbar[iconsize="small"] #feed-button { background-color: #fff; color: hsl(92,100%,30%); -moz-margin-end: 4px; - background-image: -moz-linear-gradient(hsla(92,81%,16%,0), - hsla(92,81%,16%,.2) 25%, - hsla(92,81%,16%,.2) 75%, - hsla(92,81%,16%,0)); + background-image: linear-gradient(hsla(92,81%,16%,0), + hsla(92,81%,16%,.2) 25%, + hsla(92,81%,16%,.2) 75%, + hsla(92,81%,16%,0)); background-position: right; background-size: 1px; background-repeat: no-repeat; @@ -1481,7 +1481,7 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- margin: 8px -10px -10px -10px; padding: 8px 10px; border-top: 1px solid ThreeDShadow; - background-image: -moz-linear-gradient(hsla(0,0%,0%,.15), hsla(0,0%,0%,.08) 6px); + background-image: linear-gradient(hsla(0,0%,0%,.15), hsla(0,0%,0%,.08) 6px); } .panel-promo-icon { @@ -1540,15 +1540,14 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- } #TabsToolbar[tabsontop=false] { - background-image: - -moz-linear-gradient(bottom, rgba(0,0,0,.3) 1px, rgba(0,0,0,.05) 1px, transparent 50%); + background-image: linear-gradient(to top, rgba(0,0,0,.3) 1px, rgba(0,0,0,.05) 1px, transparent 50%); } .tabbrowser-tab, .tabs-newtab-button { position: static; -moz-appearance: none; - background: -moz-linear-gradient(hsla(0,0%,100%,.2), hsla(0,0%,45%,.2) 2px, hsla(0,0%,32%,.2) 80%); + background: linear-gradient(hsla(0,0%,100%,.2), hsla(0,0%,45%,.2) 2px, hsla(0,0%,32%,.2) 80%); background-origin: border-box; background-position: 1px 2px; background-size: 100% calc(100% - 2px); @@ -1565,52 +1564,52 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- .tabbrowser-tab:hover, .tabs-newtab-button:hover { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.2) 4px, hsla(0,0%,75%,.2) 80%); + background-image: linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.2) 4px, hsla(0,0%,75%,.2) 80%); } .tabbrowser-tab[selected="true"] { - background-image: -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%), - -moz-linear-gradient(-moz-dialog, -moz-dialog); + background-image: linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%), + linear-gradient(-moz-dialog, -moz-dialog); color: -moz-dialogtext; } #main-window[tabsontop=false]:not([disablechrome]) .tabbrowser-tab[selected=true]:not(:-moz-lwtheme) { - background-image: -moz-linear-gradient(bottom, rgba(0,0,0,.3) 1px, transparent 1px), - -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%), - -moz-linear-gradient(-moz-dialog, -moz-dialog); + background-image: linear-gradient(to top, rgba(0,0,0,.3) 1px, transparent 1px), + linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%), + linear-gradient(-moz-dialog, -moz-dialog); } .tabbrowser-tab[selected="true"]:-moz-lwtheme { - background-image: -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%); + background-image: linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 32%); color: inherit; } .tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]), .tabs-newtab-button:-moz-lwtheme-brighttext { - background-image: -moz-linear-gradient(hsla(0,0%,60%,.6), hsla(0,0%,40%,.6) 4px, hsla(0,0%,30%,.6) 80%); + background-image: linear-gradient(hsla(0,0%,60%,.6), hsla(0,0%,40%,.6) 4px, hsla(0,0%,30%,.6) 80%); } .tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]):hover, .tabs-newtab-button:-moz-lwtheme-brighttext:hover { - background-image: -moz-linear-gradient(hsla(0,0%,80%,.6), hsla(0,0%,60%,.6) 4px, hsla(0,0%,45%,.6) 80%); + background-image: linear-gradient(hsla(0,0%,80%,.6), hsla(0,0%,60%,.6) 4px, hsla(0,0%,45%,.6) 80%); } .tabbrowser-tab:-moz-lwtheme-darktext:not([selected="true"]), .tabs-newtab-button:-moz-lwtheme-darktext { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.5), hsla(0,0%,60%,.5) 4px, hsla(0,0%,45%,.5) 80%); + background-image: linear-gradient(hsla(0,0%,100%,.5), hsla(0,0%,60%,.5) 4px, hsla(0,0%,45%,.5) 80%); } .tabbrowser-tab:-moz-lwtheme-darktext:not([selected="true"]):hover, .tabs-newtab-button:-moz-lwtheme-darktext:hover { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.5), hsla(0,0%,80%,.5) 4px, hsla(0,0%,60%,.5) 80%); + background-image: linear-gradient(hsla(0,0%,100%,.5), hsla(0,0%,80%,.5) 4px, hsla(0,0%,60%,.5) 80%); } .tabbrowser-tab[pinned][titlechanged]:not([selected="true"]) { - background-image: -moz-radial-gradient(center 3px, circle cover, rgba(233,242,252,1) 3%, rgba(172,206,255,.75) 40%, rgba(87,151,201,.5) 80%, rgba(87,151,201,0)); + background-image: radial-gradient(circle farthest-corner at 50% 3px, rgba(233,242,252,1) 3%, rgba(172,206,255,.75) 40%, rgba(87,151,201,.5) 80%, rgba(87,151,201,0)); } .tabbrowser-tab[pinned][titlechanged]:not([selected="true"]):hover { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.8), hsla(0,0%,100%,.6) 2px, hsla(0,0%,75%,.2) 80%), - -moz-radial-gradient(center 3px, circle cover, rgba(233,242,252,1) 3%, rgba(172,206,255,.75) 40%, rgba(87,151,201,.5) 80%, rgba(87,151,201,0)); + background-image: linear-gradient(hsla(0,0%,100%,.8), hsla(0,0%,100%,.6) 2px, hsla(0,0%,75%,.2) 80%), + radial-gradient(circle farthest-corner at 50% 3px, rgba(233,242,252,1) 3%, rgba(172,206,255,.75) 40%, rgba(87,151,201,.5) 80%, rgba(87,151,201,0)); } #tabbrowser-tabs[positionpinnedtabs] > .tabbrowser-tab > .tab-stack > .tab-content[pinned] { @@ -1939,9 +1938,9 @@ toolbar[mode="text"] toolbarbutton.chevron > .toolbarbutton-icon { #addon-bar[customizing] > #status-bar { opacity: .5; - background-image: -moz-repeating-linear-gradient(-45deg, - rgba(255,255,255,.3), rgba(255,255,255,.3) 5px, - rgba(0,0,0,.3) 5px, rgba(0,0,0,.3) 10px); + background-image: repeating-linear-gradient(135deg, + rgba(255,255,255,.3), rgba(255,255,255,.3) 5px, + rgba(0,0,0,.3) 5px, rgba(0,0,0,.3) 10px); } #status-bar > statusbarpanel { @@ -1963,7 +1962,7 @@ toolbar[mode="text"] toolbarbutton.chevron > .toolbarbutton-icon { .statuspanel-label { margin: 0; padding: 2px 4px; - background: -moz-linear-gradient(white, #ddd); + background: linear-gradient(#fff, #ddd); border: 1px none #ccc; border-top-style: solid; color: #333; @@ -2009,7 +2008,7 @@ toolbar[mode="text"] toolbarbutton.chevron > .toolbarbutton-icon { color: hsl(200, 100%, 65%); border: 1px solid hsla(210, 19%, 63%, .5); border-radius: 3px; - background: -moz-linear-gradient(hsl(209, 18%, 30%), hsl(210, 24%, 16%)) no-repeat padding-box; + background: linear-gradient(hsl(209, 18%, 30%), hsl(210, 24%, 16%)) no-repeat padding-box; } /* Highlighter - Node Infobar - text */ @@ -2093,7 +2092,7 @@ html|*.highlighter-nodeinfobar-pseudo-classes { margin-top: 8px; border-right-color: hsla(210, 19%, 63%, .5); border-top-color: hsla(210, 19%, 63%, .5); - background-image: -moz-linear-gradient(bottom left, transparent 50%, hsl(209, 18%, 30%) 50%); + background-image: linear-gradient(to top right, transparent 50%, hsl(209, 18%, 30%) 50%); } .highlighter-nodeinfobar-arrow-bottom { @@ -2101,7 +2100,7 @@ html|*.highlighter-nodeinfobar-pseudo-classes { margin-bottom: 8px; border-left-color: hsla(210, 19%, 63%, .5); border-bottom-color: hsla(210, 19%, 63%, .5); - background-image: -moz-linear-gradient(top right, transparent 50%, hsl(210, 24%, 16%) 50%); + background-image: linear-gradient(to bottom left, transparent 50%, hsl(210, 24%, 16%) 50%); } .highlighter-nodeinfobar-container[position="top"] > .highlighter-nodeinfobar, @@ -2332,7 +2331,7 @@ html|*#gcli-output-frame { color: #FDF3DE; min-width: 16px; text-shadow: none; - background-image: -moz-linear-gradient(top, #B4211B, #8A1915); + background-image: linear-gradient(#B4211B, #8A1915); border-radius: 1px; -moz-margin-end: 2px; } diff --git a/browser/themes/pinstripe/browser.css b/browser/themes/pinstripe/browser.css index e034eff39d18..7f95fd3f4b94 100644 --- a/browser/themes/pinstripe/browser.css +++ b/browser/themes/pinstripe/browser.css @@ -77,7 +77,7 @@ toolbar[mode="full"] toolbarseparator { padding-top: 4px !important; border-bottom: 1px solid rgba(0, 0, 0, 0.57); background-color: -moz-mac-chrome-active; - background-image: -moz-linear-gradient(rgba(255,255,255,.43), rgba(255,255,255,0)) !important; /* override lwtheme style */ + background-image: linear-gradient(rgba(255,255,255,.43), rgba(255,255,255,0)) !important; /* override lwtheme style */ background-origin: border-box !important; } @@ -371,7 +371,7 @@ toolbarbutton.bookmark-item > menupopup { padding: 0 3px; border: 1px solid rgba(0, 0, 0, 0.4); border-radius: @toolbarbuttonCornerRadius@; - background: -moz-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.2)) repeat-x; + background: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.2) 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.2)) repeat-x; background-origin: border-box; box-shadow: inset 0 1px rgba(255,255,255,0.3), 0 1px rgba(255,255,255,0.2); } @@ -380,7 +380,7 @@ toolbarbutton.bookmark-item > menupopup { .toolbarbutton-1 > .toolbarbutton-menubutton-button:-moz-lwtheme-darktext, .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker:-moz-lwtheme-darktext, #restore-button:-moz-lwtheme-darktext { - background-image: -moz-linear-gradient(rgba(255,255,255,0.3), rgba(50,50,50,0.2) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.13)); + background-image: linear-gradient(rgba(255,255,255,0.3), rgba(50,50,50,0.2) 50%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.13)); } .toolbarbutton-1[type="menu-button"] { @@ -650,7 +650,7 @@ toolbar[mode="icons"] #forward-button { @conditionalForwardWithUrlbar@ > #forward-button:not(:-moz-lwtheme) { -moz-appearance: none; -moz-padding-start: 2px; - background: -moz-linear-gradient(hsl(0,0%,99%), hsl(0,0%,67%)) padding-box; + background: linear-gradient(hsl(0,0%,99%), hsl(0,0%,67%)) padding-box; border: 1px solid; border-color: hsl(0,0%,31%) hsla(0,0%,29%,.6) hsl(0,0%,27%); box-shadow: inset 0 1px 0 hsla(0,0%,100%,.35), @@ -672,7 +672,7 @@ toolbar[mode="icons"] #forward-button { } @conditionalForwardWithUrlbar@ > #forward-button:hover:active:not(:-moz-lwtheme) { - background-image: -moz-linear-gradient(hsl(0,0%,74%), hsl(0,0%,61%)); + background-image: linear-gradient(hsl(0,0%,74%), hsl(0,0%,61%)); box-shadow: inset rgba(0,0,0,.3) 0 -6px 10px, inset #000 0 1px 3px, inset rgba(0,0,0,.2) 0 1px 3px, @@ -681,7 +681,7 @@ toolbar[mode="icons"] #forward-button { @conditionalForwardWithUrlbar@ > #forward-button:-moz-window-inactive:not(:-moz-lwtheme) { border-color: hsl(0,0%,64%) hsl(0,0%,65%) hsl(0,0%,66%); - background-image: -moz-linear-gradient(hsl(0,0%,99%), hsl(0,0%,82%)); + background-image: linear-gradient(hsl(0,0%,99%), hsl(0,0%,82%)); box-shadow: inset 0 1px 0 hsla(0,0%,100%,.35); } @@ -691,7 +691,7 @@ toolbar[mode="icons"] #forward-button { @media (-moz-mac-lion-theme) { @conditionalForwardWithUrlbar@ > #forward-button:not(:-moz-lwtheme) { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.73), hsla(0,0%,100%,.05) 85%); + background-image: linear-gradient(hsla(0,0%,100%,.73), hsla(0,0%,100%,.05) 85%); border-color: hsla(0,0%,0%,.35) hsla(0,0%,0%,.25) hsla(0,0%,0%,.2); box-shadow: inset 0 1px 0 hsla(0,0%,100%,.2), inset 0 0 1px hsla(0,0%,100%,.1), @@ -699,7 +699,7 @@ toolbar[mode="icons"] #forward-button { } @conditionalForwardWithUrlbar@ > #forward-button:hover:active:not(:-moz-lwtheme) { - background-image: -moz-linear-gradient(hsla(0,0%,60%,.37), hsla(0,0%,100%,.35) 95%); + background-image: linear-gradient(hsla(0,0%,60%,.37), hsla(0,0%,100%,.35) 95%); border-color: hsla(0,0%,0%,.43) hsla(0,0%,0%,.25) hsla(0,0%,0%,.37); box-shadow: inset 0 1px 0 hsla(0,0%,0%,.02), inset 0 1px 2px hsla(0,0%,0%,.2), @@ -1126,7 +1126,7 @@ toolbar[mode="icons"] #zoom-in-button { @media (-moz-mac-lion-theme) { #urlbar, .searchbar-textbox { - background-image: -moz-linear-gradient(hsl(0,0%,97%), hsl(0,0%,100%)); + background-image: linear-gradient(hsl(0,0%,97%), hsl(0,0%,100%)); border-color: hsla(0,0%,0%,.35) hsla(0,0%,0%,.25) hsla(0,0%,0%,.15); box-shadow: 0 1px 0 hsla(0,0%,100%,.2), inset 0 0 1px hsla(0,0%,0%,.05), @@ -1257,10 +1257,10 @@ toolbar[mode="icons"] #zoom-in-button { #urlbar[pageproxystate="valid"] > #identity-box.verifiedIdentity { color: hsl(92,100%,30%); -moz-padding-end: 4px; - background-image: -moz-linear-gradient(hsla(92,81%,16%,0), - hsla(92,81%,16%,.2) 25%, - hsla(92,81%,16%,.2) 75%, - hsla(92,81%,16%,0)); + background-image: linear-gradient(hsla(92,81%,16%,0), + hsla(92,81%,16%,.2) 25%, + hsla(92,81%,16%,.2) 75%, + hsla(92,81%,16%,0)); background-position: right; background-size: 1px; background-repeat: no-repeat; @@ -1296,7 +1296,7 @@ toolbar[mode="icons"] #zoom-in-button { .urlbar-history-dropmarker[open="true"], .urlbar-history-dropmarker:hover:active { -moz-image-region: rect(0px, 22px, 14px, 11px); - background-image: -moz-radial-gradient(center, circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); } @media (min-resolution: 2dppx) { @@ -1325,7 +1325,7 @@ toolbar[mode="icons"] #zoom-in-button { .urlbar-icon[open="true"], .urlbar-icon:hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); } #urlbar-search-splitter { @@ -1531,7 +1531,7 @@ window[tabsontop="false"] richlistitem[type~="action"][actiontype="switchtab"][s } #urlbar > toolbarbutton:not([disabled]):hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); } #go-button { @@ -2271,27 +2271,27 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { .tab-background-start[pinned][titlechanged]:not([selected="true"]), .tab-background-end[pinned][titlechanged]:not([selected="true"]) { - background-image: -moz-linear-gradient(rgba(148,205,253,.2), rgba(148,205,253,.2)) !important; + background-image: linear-gradient(rgba(148,205,253,.2), rgba(148,205,253,.2)) !important; } @TABSONBOTTOM_TAB_STACK@ > .tab-background > .tab-background-middle[pinned][titlechanged]:not([selected="true"]) { - background-image: -moz-radial-gradient(center 99%, circle cover, rgba(254,254,255,1) 3%, rgba(210,235,255,.9) 12%, rgba(148,205,253,.6) 30%, rgba(148,205,253,.2) 70%); + background-image: radial-gradient(circle farthest-corner at 50% 99%, rgba(254,254,255,1) 3%, rgba(210,235,255,.9) 12%, rgba(148,205,253,.6) 30%, rgba(148,205,253,.2) 70%); } @TABSONTOP_TAB_STACK@ > .tab-background > .tab-background-middle[pinned][titlechanged]:not([selected="true"]) { - background-image: -moz-radial-gradient(center 2px, circle cover, rgba(254,254,255,1) 3%, rgba(210,235,255,.9) 12%, rgba(148,205,253,.6) 30%, rgba(148,205,253,.2) 70%); + background-image: radial-gradient(circle farthest-corner at 50% 2px, rgba(254,254,255,1) 3%, rgba(210,235,255,.9) 12%, rgba(148,205,253,.6) 30%, rgba(148,205,253,.2) 70%); } .tabbrowser-tab > .tab-stack > .tab-background > .tab-background-start:-moz-lwtheme-brighttext:not([selected="true"]), .tabbrowser-tab > .tab-stack > .tab-background > .tab-background-middle:-moz-lwtheme-brighttext:not([selected="true"]), .tabbrowser-tab > .tab-stack > .tab-background > .tab-background-end:-moz-lwtheme-brighttext:not([selected="true"]) { - background-image: -moz-linear-gradient(hsla(0,0%,40%,.6), hsla(0,0%,30%,.6) 50%); + background-image: linear-gradient(hsla(0,0%,40%,.6), hsla(0,0%,30%,.6) 50%); } .tabbrowser-tab > .tab-stack > .tab-background > .tab-background-start:-moz-lwtheme-darktext:not([selected="true"]), .tabbrowser-tab > .tab-stack > .tab-background > .tab-background-middle:-moz-lwtheme-darktext:not([selected="true"]), .tabbrowser-tab > .tab-stack > .tab-background > .tab-background-end:-moz-lwtheme-darktext:not([selected="true"]) { - background-image: -moz-linear-gradient(hsla(0,0%,60%,.5), hsla(0,0%,45%,.5) 50%); + background-image: linear-gradient(hsla(0,0%,60%,.5), hsla(0,0%,45%,.5) 50%); } @TABSONTOP_TAB_STACK@ > .tab-content, @@ -2423,12 +2423,12 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { #TabsToolbar[tabsontop="true"]:not(:-moz-lwtheme) { padding-bottom: 2px; background: url(chrome://browser/skin/tabbrowser/tabbar-top-bg-active.png), - -moz-linear-gradient(bottom, -moz-mac-chrome-active 2px, transparent 2px); + linear-gradient(to top, -moz-mac-chrome-active 2px, transparent 2px); } #TabsToolbar[tabsontop="true"]:not(:-moz-lwtheme):-moz-window-inactive { background: url(chrome://browser/skin/tabbrowser/tabbar-top-bg-inactive.png), - -moz-linear-gradient(bottom, -moz-mac-chrome-inactive 2px, transparent 2px); + linear-gradient(to top, -moz-mac-chrome-inactive 2px, transparent 2px); } /* In tabs-on-bottom mode, fill the whole toolbar with the chrome @@ -2668,7 +2668,7 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1:not([type="menu-button"]):not([disabled]):not([open]):hover, :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled]):hover, :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1:not([disabled]):not([buttonover]):hover > .toolbarbutton-menubutton-dropmarker { - background-image: -moz-linear-gradient(transparent, rgba(0,0,0,.15)) !important; + background-image: linear-gradient(transparent, rgba(0,0,0,.15)) !important; } .tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled]):hover:active, @@ -2677,7 +2677,7 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1[type="menu"][open], :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled]):hover:active, :-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1[open]:not([disabled]):hover > .toolbarbutton-menubutton-dropmarker { - background-image: -moz-linear-gradient(transparent, rgba(0,0,0,.3)) !important; + background-image: linear-gradient(transparent, rgba(0,0,0,.3)) !important; } .tabs-newtab-button, @@ -3347,9 +3347,9 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { #addon-bar[customizing] > #status-bar { opacity: .5; - background-image: -moz-repeating-linear-gradient(-45deg, - rgba(255,255,255,.3), rgba(255,255,255,.3) 5px, - rgba(0,0,0,.3) 5px, rgba(0,0,0,.3) 10px); + background-image: repeating-linear-gradient(135deg, + rgba(255,255,255,.3), rgba(255,255,255,.3) 5px, + rgba(0,0,0,.3) 5px, rgba(0,0,0,.3) 10px); } #status-bar > statusbarpanel { @@ -3397,7 +3397,7 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { .statuspanel-label { margin: 0; padding: 2px 4px; - background: -moz-linear-gradient(white, #ddd); + background: linear-gradient(#fff, #ddd); border: 1px none #ccc; border-top-style: solid; color: #333; @@ -3470,7 +3470,7 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker { color: hsl(200, 100%, 65%); border: 1px solid hsla(210, 19%, 63%, .5); border-radius: 3px; - background: -moz-linear-gradient(hsl(209, 18%, 30%), hsl(210, 24%, 16%)) no-repeat padding-box; + background: linear-gradient(hsl(209, 18%, 30%), hsl(210, 24%, 16%)) no-repeat padding-box; } /* Highlighter - Node Infobar - text */ @@ -3555,7 +3555,7 @@ html|*.highlighter-nodeinfobar-pseudo-classes { margin-top: 8px; border-right-color: hsla(210, 19%, 63%, .5); border-top-color: hsla(210, 19%, 63%, .5); - background-image: -moz-linear-gradient(bottom left, transparent 50%, hsl(209, 18%, 30%) 50%); + background-image: linear-gradient(to top right, transparent 50%, hsl(209, 18%, 30%) 50%); } .highlighter-nodeinfobar-arrow-bottom { @@ -3563,7 +3563,7 @@ html|*.highlighter-nodeinfobar-pseudo-classes { margin-bottom: 8px; border-left-color: hsla(210, 19%, 63%, .5); border-bottom-color: hsla(210, 19%, 63%, .5); - background-image: -moz-linear-gradient(top right, transparent 50%, hsl(210, 24%, 16%) 50%); + background-image: linear-gradient(to bottom left, transparent 50%, hsl(210, 24%, 16%) 50%); } .highlighter-nodeinfobar-container[position="top"] > .highlighter-nodeinfobar, @@ -3789,7 +3789,7 @@ html|*#gcli-output-frame { color: #FDF3DE; min-width: 16px; text-shadow: none; - background-image: -moz-linear-gradient(top, #B4211B, #8A1915); + background-image: linear-gradient(#B4211B, #8A1915); border-radius: 1px; } diff --git a/browser/themes/winstripe/browser-aero.css b/browser/themes/winstripe/browser-aero.css index 0901ece52251..dc77a53f3fe0 100644 --- a/browser/themes/winstripe/browser-aero.css +++ b/browser/themes/winstripe/browser-aero.css @@ -50,24 +50,24 @@ .tabbrowser-tab:not(:-moz-lwtheme), .tabs-newtab-button:not(:-moz-lwtheme) { background-image: @toolbarShadowOnTab@, @bgTabTexture@, - -moz-linear-gradient(@customToolbarColor@, @customToolbarColor@); + linear-gradient(@customToolbarColor@, @customToolbarColor@); } .tabbrowser-tab:not(:-moz-lwtheme):hover, .tabs-newtab-button:not(:-moz-lwtheme):hover { background-image: @toolbarShadowOnTab@, @bgTabTextureHover@, - -moz-linear-gradient(@customToolbarColor@, @customToolbarColor@); + linear-gradient(@customToolbarColor@, @customToolbarColor@); } .tabbrowser-tab[selected="true"]:not(:-moz-lwtheme) { - background-image: -moz-linear-gradient(white, @toolbarHighlight@ 50%), - -moz-linear-gradient(@customToolbarColor@, @customToolbarColor@); + background-image: linear-gradient(#fff, @toolbarHighlight@ 50%), + linear-gradient(@customToolbarColor@, @customToolbarColor@); } #main-window[tabsontop=false]:not([disablechrome]) .tabbrowser-tab[selected=true]:not(:-moz-lwtheme) { background-image: @toolbarShadowOnTab@, - -moz-linear-gradient(white, @toolbarHighlight@ 50%), - -moz-linear-gradient(@customToolbarColor@, @customToolbarColor@); + linear-gradient(#fff, @toolbarHighlight@ 50%), + linear-gradient(@customToolbarColor@, @customToolbarColor@); } #navigator-toolbox:not(:-moz-lwtheme)::after { @@ -246,7 +246,7 @@ #navigator-toolbox[tabsontop=false] > #PersonalToolbar:not(:-moz-lwtheme) { margin-top: 2px; border-top: 1px solid @toolbarShadowColor@; - background-image: -moz-linear-gradient(@toolbarHighlight@, rgba(255,255,255,0)); + background-image: linear-gradient(@toolbarHighlight@, rgba(255,255,255,0)); } #main-window[sizemode=normal] #TabsToolbar[tabsontop=true] { @@ -263,7 +263,7 @@ #main-window[sizemode=normal][disablechrome] #navigator-toolbox[tabsontop=true]:not(:-moz-lwtheme)::after { visibility: visible; background-color: @customToolbarColor@; - background-image: -moz-linear-gradient(@toolbarHighlight@, @toolbarHighlight@); + background-image: linear-gradient(@toolbarHighlight@, @toolbarHighlight@); height: 4px; } @@ -331,7 +331,7 @@ #tab-view:-moz-lwtheme { background-image: url("chrome://browser/skin/tabview/grain.png"), - -moz-linear-gradient(rgba(255,255,255,0), #CCD9EA 200px, #C7D5E7); + linear-gradient(rgba(255,255,255,0), #CCD9EA 200px, #C7D5E7); background-attachment: fixed; } } @@ -444,13 +444,13 @@ .splitmenu-menuitem[_moz-menuactive], .splitmenu-menu[_moz-menuactive] { background-color: transparent; - background-image: -moz-linear-gradient(#fafbfd, #ebf3fd); + background-image: linear-gradient(#fafbfd, #ebf3fd); border-color: #aeccf1; } .splitmenu-menuitem[disabled][_moz-menuactive], .splitmenu-menu[disabled][_moz-menuactive] { - background-image: -moz-linear-gradient(#f8f9f9, #eaeaea); + background-image: linear-gradient(#f8f9f9, #eaeaea); border-color: #d8d7d7; } diff --git a/browser/themes/winstripe/browser.css b/browser/themes/winstripe/browser.css index 15cabf3de37d..ff9b32cc7e8e 100644 --- a/browser/themes/winstripe/browser.css +++ b/browser/themes/winstripe/browser.css @@ -12,9 +12,9 @@ %define toolbarHighlight rgba(255,255,255,.5) %define selectedTabHighlight rgba(255,255,255,.7) %define toolbarShadowColor rgba(10%,10%,10%,.4) -%define toolbarShadowOnTab -moz-linear-gradient(bottom, rgba(10%,10%,10%,.4) 1px, transparent 1px) -%define bgTabTexture -moz-linear-gradient(transparent, hsla(0,0%,45%,.1) 1px, hsla(0,0%,32%,.2) 80%, hsla(0,0%,0%,.2)) -%define bgTabTextureHover -moz-linear-gradient(hsla(0,0%,100%,.3) 1px, hsla(0,0%,75%,.2) 80%, hsla(0,0%,60%,.2)) +%define toolbarShadowOnTab linear-gradient(to top, rgba(10%,10%,10%,.4) 1px, transparent 1px) +%define bgTabTexture linear-gradient(transparent, hsla(0,0%,45%,.1) 1px, hsla(0,0%,32%,.2) 80%, hsla(0,0%,0%,.2)) +%define bgTabTextureHover linear-gradient(hsla(0,0%,100%,.3) 1px, hsla(0,0%,75%,.2) 80%, hsla(0,0%,60%,.2)) %define navbarTextboxCustomBorder border-color: rgba(0,0,0,.32); %define navbarLargeIcons #navigator-toolbox[iconsize=large][mode=icons] > #nav-bar %define forwardTransitionLength 150ms @@ -67,13 +67,13 @@ @media not all and (-moz-windows-compositor) { %endif #main-window[tabsintitlebar]:not([inFullscreen]) #toolbar-menubar[inactive] ~ #TabsToolbar:not(:-moz-lwtheme) { - background: -moz-linear-gradient(bottom, @toolbarShadowColor@ 1px, transparent 1px), - -moz-linear-gradient(rgba(50%,50%,50%,0), ActiveCaption 85%); + background: linear-gradient(to top, @toolbarShadowColor@ 1px, transparent 1px), + linear-gradient(rgba(50%,50%,50%,0), ActiveCaption 85%); color: CaptionText; } #main-window[tabsintitlebar]:not([inFullscreen]) #toolbar-menubar[inactive] ~ #TabsToolbar:not(:-moz-lwtheme):-moz-window-inactive { - background: -moz-linear-gradient(bottom, @toolbarShadowColor@ 1px, transparent 1px), - -moz-linear-gradient(rgba(50%,50%,50%,0), InactiveCaption 85%); + background: linear-gradient(to top, @toolbarShadowColor@ 1px, transparent 1px), + linear-gradient(rgba(50%,50%,50%,0), InactiveCaption 85%); color: InactiveCaptionText; } @@ -91,7 +91,7 @@ #nav-bar[tabsontop=true], #nav-bar[tabsontop=true][collapsed=true]:not([customizing]) + toolbar, #nav-bar[tabsontop=true][collapsed=true]:not([customizing]) + #customToolbars + #PersonalToolbar { - background-image: -moz-linear-gradient(@toolbarHighlight@, rgba(255,255,255,0)); + background-image: linear-gradient(@toolbarHighlight@, rgba(255,255,255,0)); } #personal-bookmarks { @@ -143,15 +143,15 @@ %ifdef MOZ_OFFICIAL_BRANDING #appmenu-button { - background-image: -moz-linear-gradient(rgb(247,182,82), rgb(215,98,10) 95%); + background-image: linear-gradient(rgb(247,182,82), rgb(215,98,10) 95%); border-color: rgba(83,42,6,.9); box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 0 0 1px rgba(255,255,255,.25) inset; } #appmenu-button:hover:not(:active):not([open]) { - background-image: -moz-radial-gradient(center bottom, farthest-side, rgba(252,240,89,.5) 10%, rgba(252,240,89,0) 70%), - -moz-radial-gradient(center bottom, farthest-side, rgb(236,133,0), rgba(255,229,172,0)), - -moz-linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%); + background-image: radial-gradient(farthest-side at bottom, rgba(252,240,89,.5) 10%, rgba(252,240,89,0) 70%), + radial-gradient(farthest-side at bottom, rgb(236,133,0), rgba(255,229,172,0)), + linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%); border-color: rgba(83,42,6,.9); box-shadow: 0 1px 0 rgba(255,255,255,.1) inset, 0 0 2px 1px rgba(250,234,169,.7) inset, @@ -159,22 +159,22 @@ } #appmenu-button:hover:active, #appmenu-button[open] { - background-image: -moz-linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%); + background-image: linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%); box-shadow: 0 2px 3px rgba(0,0,0,.4) inset, 0 1px 1px rgba(0,0,0,.2) inset; } %else %if MOZ_UPDATE_CHANNEL == aurora #appmenu-button { - background-image: -moz-linear-gradient(hsl(208,99%,37%), hsl(214,90%,23%) 95%); + background-image: linear-gradient(hsl(208,99%,37%), hsl(214,90%,23%) 95%); border-color: hsla(214,89%,21%,.9); box-shadow: 0 1px 0 hsla(205,100%,72%,.2) inset, 0 0 2px 1px hsla(205,100%,72%,.25) inset; } #appmenu-button:hover:not(:active):not([open]) { - background-image: -moz-radial-gradient(center bottom, farthest-side, hsla(202,100%,85%,.5) 10%, hsla(202,100%,85%,0) 70%), - -moz-radial-gradient(center bottom, farthest-side, hsla(205,100%,72%,.7), hsla(205,100%,72%,0)), - -moz-linear-gradient(hsl(208,98%,34%), hsl(213,87%,20%) 95%); + background-image: radial-gradient(farthest-side at bottom, hsla(202,100%,85%,.5) 10%, hsla(202,100%,85%,0) 70%), + radial-gradient(farthest-side at bottom, hsla(205,100%,72%,.7), hsla(205,100%,72%,0)), + linear-gradient(hsl(208,98%,34%), hsl(213,87%,20%) 95%); border-color: hsla(214,89%,21%,.9); box-shadow: 0 1px 0 hsla(205,100%,72%,.15) inset, 0 0 2px 1px hsla(205,100%,72%,.5) inset, @@ -182,21 +182,21 @@ } #appmenu-button:hover:active, #appmenu-button[open] { - background-image: -moz-linear-gradient(hsl(208,95%,30%), hsl(214,85%,17%) 95%); + background-image: linear-gradient(hsl(208,95%,30%), hsl(214,85%,17%) 95%); box-shadow: 0 2px 3px rgba(0,0,0,.4) inset, 0 1px 1px rgba(0,0,0,.2) inset; } %else #appmenu-button { - background-image: -moz-linear-gradient(hsl(211,33%,32%), hsl(209,53%,10%) 95%); + background-image: linear-gradient(hsl(211,33%,32%), hsl(209,53%,10%) 95%); border-color: hsla(210,59%,13%,.9); box-shadow: 0 1px 0 hsla(210,48%,90%,.15) inset, 0 0 2px 1px hsla(211,65%,85%,.15) inset; } #appmenu-button:hover:not(:active):not([open]) { - background-image: -moz-radial-gradient(center bottom, farthest-side, hsla(210,48%,90%,.5) 10%, hsla(210,48%,90%,0) 70%), - -moz-radial-gradient(center bottom, farthest-side, hsla(211,70%,83%,.5), hsla(211,70%,83%,0)), - -moz-linear-gradient(hsl(211,33%,32%), hsl(209,53%,10%) 95%); + background-image: radial-gradient(farthest-side at bottom, hsla(210,48%,90%,.5) 10%, hsla(210,48%,90%,0) 70%), + radial-gradient(farthest-side at bottom, hsla(211,70%,83%,.5), hsla(211,70%,83%,0)), + linear-gradient(hsl(211,33%,32%), hsl(209,53%,10%) 95%); border-color: hsla(210,59%,13%,.9); box-shadow: 0 1px 0 hsla(210,48%,90%,.15) inset, 0 0 2px 1px hsla(210,48%,90%,.4) inset, @@ -204,7 +204,7 @@ } #appmenu-button:hover:active, #appmenu-button[open] { - background-image: -moz-linear-gradient(hsl(211,33%,26%), hsl(209,53%,6%) 95%); + background-image: linear-gradient(hsl(211,33%,26%), hsl(209,53%,6%) 95%); box-shadow: 0 2px 3px rgba(0,0,0,.4) inset, 0 1px 1px rgba(0,0,0,.2) inset; } @@ -212,14 +212,14 @@ %endif #main-window[privatebrowsingmode=temporary] #appmenu-button { - background-image: -moz-linear-gradient(rgb(153,38,211), rgb(105,19,163) 95%); + background-image: linear-gradient(rgb(153,38,211), rgb(105,19,163) 95%); border-color: rgba(43,8,65,.9); } #main-window[privatebrowsingmode=temporary] #appmenu-button:hover:not(:active):not([open]) { - background-image: -moz-radial-gradient(center bottom, farthest-side, rgba(240,193,255,.5) 10%, rgba(240,193,255,0) 70%), - -moz-radial-gradient(center bottom, farthest-side, rgb(192,81,247), rgba(236,172,255,0)), - -moz-linear-gradient(rgb(144,20,207), rgb(95,0,158) 95%); + background-image: radial-gradient(farthest-side at bottom, rgba(240,193,255,.5) 10%, rgba(240,193,255,0) 70%), + radial-gradient(farthest-side at bottom, rgb(192,81,247), rgba(236,172,255,0)), + linear-gradient(rgb(144,20,207), rgb(95,0,158) 95%); border-color: rgba(43,8,65,.9); box-shadow: 0 1px 0 rgba(255,255,255,.1) inset, 0 0 2px 1px rgba(240,193,255,.7) inset, @@ -228,7 +228,7 @@ #main-window[privatebrowsingmode=temporary] #appmenu-button:hover:active, #main-window[privatebrowsingmode=temporary] #appmenu-button[open] { - background-image: -moz-linear-gradient(rgb(144,20,207), rgb(95,0,158) 95%); + background-image: linear-gradient(rgb(144,20,207), rgb(95,0,158) 95%); } #appmenu-button > .button-box { @@ -299,9 +299,9 @@ %ifdef WINSTRIPE_AERO #appmenuPrimaryPane menupopup { -moz-appearance: none; - background-image: -moz-linear-gradient(left, white 26px, ThreeDLightShadow 26px, - ThreeDLightShadow 27px, ThreeDHighlight 27px, - ThreeDHighlight 28px, white 28px); + background-image: linear-gradient(to right, white 26px, ThreeDLightShadow 26px, + ThreeDLightShadow 27px, ThreeDHighlight 27px, + ThreeDHighlight 28px, white 28px); border: 3px solid; -moz-border-top-colors: ThreeDShadow white; -moz-border-bottom-colors: ThreeDShadow white; @@ -313,9 +313,9 @@ #appmenuSecondaryPane menupopup { -moz-appearance: none; %ifdef WINSTRIPE_AERO - background-image: -moz-linear-gradient(left, #f1f5fb 26px, ThreeDLightShadow 26px, - ThreeDLightShadow 27px, ThreeDHighlight 27px, - ThreeDHighlight 28px, #f1f5fb 28px); + background-image: linear-gradient(to right, #f1f5fb 26px, ThreeDLightShadow 26px, + ThreeDLightShadow 27px, ThreeDHighlight 27px, + ThreeDHighlight 28px, #f1f5fb 28px); border: 3px solid; -moz-border-top-colors: ThreeDShadow #f1f5fb; -moz-border-bottom-colors: ThreeDShadow #f1f5fb; @@ -330,14 +330,14 @@ %ifdef WINSTRIPE_AERO #appmenuPrimaryPane menupopup:-moz-locale-dir(rtl) { - background-image: -moz-linear-gradient(right, white 26px, ThreeDLightShadow 26px, - ThreeDLightShadow 27px, ThreeDHighlight 27px, - ThreeDHighlight 28px, white 28px); + background-image: linear-gradient(to left, white 26px, ThreeDLightShadow 26px, + ThreeDLightShadow 27px, ThreeDHighlight 27px, + ThreeDHighlight 28px, white 28px); } #appmenuSecondaryPane menupopup:-moz-locale-dir(rtl) { - background-image: -moz-linear-gradient(right, #f1f5fb 26px, ThreeDLightShadow 26px, - ThreeDLightShadow 27px, ThreeDHighlight 27px, - ThreeDHighlight 28px, #f1f5fb 28px); + background-image: linear-gradient(to left, #f1f5fb 26px, ThreeDLightShadow 26px, + ThreeDLightShadow 27px, ThreeDHighlight 27px, + ThreeDHighlight 28px, #f1f5fb 28px); } %endif @@ -358,7 +358,7 @@ .appmenu-edit-button:not([disabled]):hover { border: 1px solid #b8d6fb; box-shadow: inset 0 0 1px white; - background: -moz-linear-gradient(#fafbfd, #ebf3fd); + background: linear-gradient(#fafbfd, #ebf3fd); transition: .2s ease-in; } } @@ -757,7 +757,7 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button { @navbarLargeIcons@ .toolbarbutton-1:not([disabled]):hover > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon, @navbarLargeIcons@ .toolbarbutton-1:not([disabled]):not([checked]):not([open]):not(:active):hover > .toolbarbutton-icon, @conditionalForwardWithUrlbar@ > .toolbarbutton-1:-moz-any([disabled],:not([open]):not([disabled]):not(:active)) > .toolbarbutton-icon { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1)); + background-image: linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1)); border-color: hsla(210,54%,20%,.15) hsla(210,54%,20%,.2) hsla(210,54%,20%,.25); box-shadow: 0 1px hsla(0,0%,100%,.3) inset, 0 1px hsla(210,54%,20%,.03), @@ -776,7 +776,7 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button { @navbarLargeIcons@ .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled]):hover:active > .toolbarbutton-icon, @navbarLargeIcons@ .toolbarbutton-1[open] > .toolbarbutton-menubutton-dropmarker:not([disabled]) > .dropmarker-icon, @navbarLargeIcons@ .toolbarbutton-1:not([disabled]):-moz-any([open],[checked],:hover:active) > .toolbarbutton-icon { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1)); + background-image: linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1)); background-color: hsla(210,54%,20%,.15); border-color: hsla(210,54%,20%,.3) hsla(210,54%,20%,.35) hsla(210,54%,20%,.4); box-shadow: 0 1px 1px hsla(210,54%,20%,.1) inset, @@ -811,9 +811,9 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button { #TabsToolbar .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled]):hover, .tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled]):hover, .tabbrowser-arrowscrollbox > .scrollbutton-down:not([disabled]):hover { - background-image: -moz-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.5)), - -moz-linear-gradient(transparent, rgba(0,0,0,.25) 30%), - -moz-linear-gradient(transparent, rgba(0,0,0,.25) 30%); + background-image: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.5)), + linear-gradient(transparent, rgba(0,0,0,.25) 30%), + linear-gradient(transparent, rgba(0,0,0,.25) 30%); background-position: 1px -1px, 0 -1px, 100% -1px; background-size: calc(100% - 2px) 100%, 1px 100%, 1px 100%; background-repeat: no-repeat; @@ -822,9 +822,9 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button { #addon-bar .toolbarbutton-1:not([disabled]):hover, #addon-bar .toolbarbutton-1[open], #addon-bar .toolbarbutton-1 > .toolbarbutton-menubutton-button:not([disabled]):hover { - background-image: -moz-linear-gradient(bottom, transparent, rgba(0,0,0,.15)), - -moz-linear-gradient(bottom, transparent, rgba(0,0,0,.15) 30%), - -moz-linear-gradient(bottom, transparent, rgba(0,0,0,.15) 30%); + background-image: linear-gradient(to top, transparent, rgba(0,0,0,.15)), + linear-gradient(to top, transparent, rgba(0,0,0,.15) 30%), + linear-gradient(to top, transparent, rgba(0,0,0,.15) 30%); background-position: left, left, right; background-size: auto, 1px 100%, 1px 100%; background-repeat: no-repeat; @@ -899,7 +899,7 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button { border-radius: 10000px; padding: 5px; border: none; - background-image: -moz-linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1)); + background-image: linear-gradient(hsla(0,0%,100%,.6), hsla(0,0%,100%,.1)); box-shadow: 0 1px 0 hsla(0,0%,100%,.3) inset, 0 0 0 1px hsla(0,0%,100%,.3) inset, 0 0 0 1px hsla(210,54%,20%,.25), @@ -1289,12 +1289,12 @@ html|*.urlbar-input:-moz-lwtheme::-moz-placeholder, } .urlbar-icon:hover { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(200,100%,70%,.3), hsla(200,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(200,100%,70%,.3), hsla(200,100%,70%,0)); } .urlbar-icon[open="true"], .urlbar-icon:hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(200,100%,70%,.1), hsla(200,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(200,100%,70%,.1), hsla(200,100%,70%,0)); } #urlbar-search-splitter { @@ -1375,10 +1375,10 @@ html|*.urlbar-input:-moz-lwtheme::-moz-placeholder, #urlbar[pageproxystate="valid"] > #identity-box.verifiedIdentity { color: hsl(92,100%,30%); -moz-margin-end: 4px; - background-image: -moz-linear-gradient(hsla(92,81%,16%,0), - hsla(92,81%,16%,.2) 25%, - hsla(92,81%,16%,.2) 75%, - hsla(92,81%,16%,0)); + background-image: linear-gradient(hsla(92,81%,16%,0), + hsla(92,81%,16%,.2) 25%, + hsla(92,81%,16%,.2) 75%, + hsla(92,81%,16%,0)); background-position: right; background-size: 1px; background-repeat: no-repeat; @@ -1419,13 +1419,13 @@ html|*.urlbar-input:-moz-lwtheme::-moz-placeholder, } .urlbar-history-dropmarker:hover { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(205,100%,70%,.3), hsla(205,100%,70%,0)); -moz-image-region: rect(0px, 22px, 14px, 11px); } .urlbar-history-dropmarker:hover:active, .urlbar-history-dropmarker[open="true"] { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(205,100%,70%,.1), hsla(205,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(205,100%,70%,.1), hsla(205,100%,70%,0)); -moz-image-region: rect(0px, 33px, 14px, 22px); } @@ -1576,12 +1576,12 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- } #urlbar-reload-button:not([disabled]):hover { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(200,100%,70%,.2), hsla(200,100%,70%,0)); + background-image: radial-gradient(circle closest-side, hsla(200,100%,70%,.2), hsla(200,100%,70%,0)); -moz-image-region: rect(14px, 14px, 28px, 0); } #urlbar-reload-button:not([disabled]):hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(200,100%,60%,.1), hsla(200,100%,60%,0)); + background-image: radial-gradient(circle closest-side, hsla(200,100%,60%,.1), hsla(200,100%,60%,0)); -moz-image-region: rect(28px, 14px, 42px, 0); } @@ -1596,13 +1596,13 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- #go-button:hover, #urlbar-go-button:hover { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(110,70%,50%,.2), hsla(110,70%,50%,0)); + background-image: radial-gradient(circle closest-side, hsla(110,70%,50%,.2), hsla(110,70%,50%,0)); -moz-image-region: rect(14px, 42px, 28px, 28px); } #go-button:hover:active, #urlbar-go-button:hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(110,70%,50%,.1), hsla(110,70%,50%,0)); + background-image: radial-gradient(circle closest-side, hsla(110,70%,50%,.1), hsla(110,70%,50%,0)); -moz-image-region: rect(28px, 42px, 42px, 28px); } @@ -1616,12 +1616,12 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- } #urlbar-stop-button:not([disabled]):hover { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(5,100%,75%,.3), hsla(5,100%,75%,0)); + background-image: radial-gradient(circle closest-side, hsla(5,100%,75%,.3), hsla(5,100%,75%,0)); -moz-image-region: rect(14px, 28px, 28px, 14px); } #urlbar-stop-button:hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(5,100%,75%,.1), hsla(5,100%,75%,0)); + background-image: radial-gradient(circle closest-side, hsla(5,100%,75%,.1), hsla(5,100%,75%,0)); -moz-image-region: rect(28px, 28px, 42px, 14px); } @@ -1694,12 +1694,12 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- } #star-button:hover { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(45,100%,73%,.3), hsla(45,100%,73%,0)); + background-image: radial-gradient(circle closest-side, hsla(45,100%,73%,.3), hsla(45,100%,73%,0)); -moz-image-region: rect(0px 32px 16px 16px); } #star-button:hover:active { - background-image: -moz-radial-gradient(center, circle closest-side, hsla(45,100%,73%,.1), hsla(45,100%,73%,0)); + background-image: radial-gradient(circle closest-side, hsla(45,100%,73%,.1), hsla(45,100%,73%,0)); -moz-image-region: rect(0px 48px 16px 32px); } @@ -1736,7 +1736,7 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- margin: 10px -10px -10px; padding: 8px 10px; border-top: 1px solid ThreeDShadow; - background-image: -moz-linear-gradient(hsla(0,0%,0%,.15), hsla(0,0%,0%,.08) 6px); + background-image: linear-gradient(hsla(0,0%,0%,.15), hsla(0,0%,0%,.08) 6px); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; } @@ -1814,8 +1814,7 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- #TabsToolbar:not(:-moz-lwtheme), #TabsToolbar[tabsontop=false] { - background-image: - -moz-linear-gradient(bottom, @toolbarShadowColor@ 1px, rgba(0,0,0,.05) 1px, transparent 50%); + background-image: linear-gradient(to top, @toolbarShadowColor@ 1px, rgba(0,0,0,.05) 1px, transparent 50%); } %ifndef WINSTRIPE_AERO @@ -1831,7 +1830,7 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- .tabs-newtab-button { -moz-appearance: none; background: @toolbarShadowOnTab@, @bgTabTexture@, - -moz-linear-gradient(-moz-dialog, -moz-dialog); + linear-gradient(-moz-dialog, -moz-dialog); background-origin: border-box; background-position: 1px 2px; background-size: calc(100% - 2px) calc(100% - 2px); @@ -1847,7 +1846,7 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- .tabbrowser-tab:hover, .tabs-newtab-button:hover { background-image: @toolbarShadowOnTab@, @bgTabTextureHover@, - -moz-linear-gradient(-moz-dialog, -moz-dialog); + linear-gradient(-moz-dialog, -moz-dialog); } %ifndef WINSTRIPE_AERO @@ -1855,26 +1854,26 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- .tabbrowser-tab, .tabs-newtab-button { background-image: @toolbarShadowOnTab@, - -moz-linear-gradient(hsla(51,34%,89%,.9), hsla(51,15%,79%,.9) 1px, hsla(51,9%,68%,.9)); + linear-gradient(hsla(51,34%,89%,.9), hsla(51,15%,79%,.9) 1px, hsla(51,9%,68%,.9)); } .tabbrowser-tab:hover, .tabs-newtab-button:hover { background-image: @toolbarShadowOnTab@, - -moz-linear-gradient(hsla(51,34%,100%,.9), hsla(51,15%,94%,.9) 1px, hsla(51,9%,83%,.9)); + linear-gradient(hsla(51,34%,100%,.9), hsla(51,15%,94%,.9) 1px, hsla(51,9%,83%,.9)); } } %endif .tabbrowser-tab[selected="true"] { - background-image: -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 50%), - -moz-linear-gradient(-moz-dialog, -moz-dialog); + background-image: linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 50%), + linear-gradient(-moz-dialog, -moz-dialog); } #main-window[tabsontop=false]:not([disablechrome]) .tabbrowser-tab[selected=true]:not(:-moz-lwtheme) { background-image: @toolbarShadowOnTab@, - -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 50%), - -moz-linear-gradient(-moz-dialog, -moz-dialog); + linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 50%), + linear-gradient(-moz-dialog, -moz-dialog); } .tabbrowser-tab:-moz-lwtheme { @@ -1882,35 +1881,35 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action- } .tabbrowser-tab[selected="true"]:-moz-lwtheme { - background-image: -moz-linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 50%); + background-image: linear-gradient(@selectedTabHighlight@, @toolbarHighlight@ 50%); } .tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]), .tabs-newtab-button:-moz-lwtheme-brighttext { - background-image: -moz-linear-gradient(hsla(0,0%,40%,.6), hsla(0,0%,30%,.6) 80%); + background-image: linear-gradient(hsla(0,0%,40%,.6), hsla(0,0%,30%,.6) 80%); } .tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]):hover, .tabs-newtab-button:-moz-lwtheme-brighttext:hover { - background-image: -moz-linear-gradient(hsla(0,0%,60%,.6), hsla(0,0%,45%,.6) 80%); + background-image: linear-gradient(hsla(0,0%,60%,.6), hsla(0,0%,45%,.6) 80%); } .tabbrowser-tab:-moz-lwtheme-darktext:not([selected="true"]), .tabs-newtab-button:-moz-lwtheme-darktext { - background-image: -moz-linear-gradient(hsla(0,0%,60%,.5), hsla(0,0%,45%,.5) 80%); + background-image: linear-gradient(hsla(0,0%,60%,.5), hsla(0,0%,45%,.5) 80%); } .tabbrowser-tab:-moz-lwtheme-darktext:not([selected="true"]):hover, .tabs-newtab-button:-moz-lwtheme-darktext:hover { - background-image: -moz-linear-gradient(hsla(0,0%,80%,.5), hsla(0,0%,60%,.5) 80%); + background-image: linear-gradient(hsla(0,0%,80%,.5), hsla(0,0%,60%,.5) 80%); } .tabbrowser-tab[pinned][titlechanged]:not([selected="true"]) { - background-image: -moz-radial-gradient(center 3px, circle cover, rgba(255,255,255,1) 3%, rgba(186,221,251,.75) 40%, rgba(127,179,255,.5) 80%, rgba(127,179,255,.25)); + background-image: radial-gradient(circle farthest-corner at 50% 3px, rgba(255,255,255,1) 3%, rgba(186,221,251,.75) 40%, rgba(127,179,255,.5) 80%, rgba(127,179,255,.25)); } .tabbrowser-tab[pinned][titlechanged]:not([selected="true"]):hover { - background-image: -moz-linear-gradient(hsla(0,0%,100%,.4), hsla(0,0%,75%,.4) 80%), - -moz-radial-gradient(center 3px, circle cover, rgba(255,255,255,1) 3%, rgba(186,221,251,.75) 40%, rgba(127,179,255,.5) 80%, rgba(127,179,255,.25)); + background-image: linear-gradient(hsla(0,0%,100%,.4), hsla(0,0%,75%,.4) 80%), + radial-gradient(circle farthest-corner at 50% 3px, rgba(255,255,255,1) 3%, rgba(186,221,251,.75) 40%, rgba(127,179,255,.5) 80%, rgba(127,179,255,.25)); } .tab-throbber, @@ -2596,7 +2595,7 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] { border-top-style: none; border-bottom-style: none; padding-top: 1px; - background-image: -moz-linear-gradient(rgba(0,0,0,.15) 1px, rgba(255,255,255,.15) 1px); + background-image: linear-gradient(rgba(0,0,0,.15) 1px, rgba(255,255,255,.15) 1px); background-size: 100% 2px; background-repeat: no-repeat; } @@ -2610,9 +2609,9 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] { #addon-bar[customizing] > #status-bar { opacity: .5; - background-image: -moz-repeating-linear-gradient(-45deg, - rgba(255,255,255,.3), rgba(255,255,255,.3) 5px, - rgba(0,0,0,.3) 5px, rgba(0,0,0,.3) 10px); + background-image: repeating-linear-gradient(135deg, + rgba(255,255,255,.3), rgba(255,255,255,.3) 5px, + rgba(0,0,0,.3) 5px, rgba(0,0,0,.3) 10px); } #status-bar > statusbarpanel { @@ -2641,7 +2640,7 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] { .statuspanel-label { margin: 0; padding: 2px 4px; - background: -moz-linear-gradient(white, #ddd); + background: linear-gradient(#fff, #ddd); border: 1px none #ccc; border-top-style: solid; color: #333; @@ -2691,7 +2690,7 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] { color: hsl(200, 100%, 65%); border: 1px solid hsla(210, 19%, 63%, .5); border-radius: 3px; - background: -moz-linear-gradient(hsl(209, 18%, 30%), hsl(210, 24%, 16%)) no-repeat padding-box; + background: linear-gradient(hsl(209, 18%, 30%), hsl(210, 24%, 16%)) no-repeat padding-box; } /* Highlighter - Node Infobar - text */ @@ -2776,7 +2775,7 @@ html|*.highlighter-nodeinfobar-pseudo-classes { margin-top: 8px; border-right-color: hsla(210, 19%, 63%, .5); border-top-color: hsla(210, 19%, 63%, .5); - background-image: -moz-linear-gradient(bottom left, transparent 50%, hsl(209, 18%, 30%) 50%); + background-image: linear-gradient(to top right, transparent 50%, hsl(209, 18%, 30%) 50%); } .highlighter-nodeinfobar-arrow-bottom { @@ -2784,7 +2783,7 @@ html|*.highlighter-nodeinfobar-pseudo-classes { margin-bottom: 8px; border-left-color: hsla(210, 19%, 63%, .5); border-bottom-color: hsla(210, 19%, 63%, .5); - background-image: -moz-linear-gradient(top right, transparent 50%, hsl(210, 24%, 16%) 50%); + background-image: linear-gradient(to bottom left, transparent 50%, hsl(210, 24%, 16%) 50%); } .highlighter-nodeinfobar-container[position="top"] > .highlighter-nodeinfobar, @@ -3015,7 +3014,7 @@ html|*#gcli-output-frame { color: #FDF3DE; min-width: 16px; text-shadow: none; - background-image: -moz-linear-gradient(top, #B4211B, #8A1915); + background-image: linear-gradient(#B4211B, #8A1915); border-radius: 1px; -moz-margin-end: 5px; } From d9f2a41f28cd5ba54a45086107f0813267e94244 Mon Sep 17 00:00:00 2001 From: EKR Date: Sat, 5 Jan 2013 09:02:36 -0800 Subject: [PATCH 147/180] Bug 825611 - Have MediaPipeline deliver as much media as requested. r=jesup --- .../src/mediapipeline/MediaPipeline.cpp | 24 ++++--------------- .../src/mediapipeline/MediaPipeline.h | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 9934bb8e22b6..aab80796a741 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -822,31 +822,15 @@ nsresult MediaPipelineReceiveAudio::Init() { } void MediaPipelineReceiveAudio::PipelineListener:: -NotifyPull(MediaStreamGraph* graph, StreamTime total) { +NotifyPull(MediaStreamGraph* graph, StreamTime desired_time) { MOZ_ASSERT(source_); if (!source_) { MOZ_MTLOG(PR_LOG_ERROR, "NotifyPull() called from a non-SourceMediaStream"); return; } - // "total" is absolute stream time. - // StreamTime desired = total - played_; - played_ = total; - //double time_s = MediaTimeToSeconds(desired); - - // Number of 10 ms samples we need - //int num_samples = ceil(time_s / .01f); - - // Doesn't matter what was asked for, always give 160 samples per 10 ms. - int num_samples = 1; - - MOZ_MTLOG(PR_LOG_DEBUG, "Asking for " << num_samples << "sample from Audio Conduit"); - - if (num_samples <= 0) { - return; - } - - while (num_samples--) { + // This comparison is done in total time to avoid accumulated roundoff errors. + while (MillisecondsToMediaTime(played_) < desired_time) { // TODO(ekr@rtfm.com): Is there a way to avoid mallocating here? nsRefPtr samples = SharedBuffer::Create(1000); int samples_length; @@ -870,6 +854,8 @@ NotifyPull(MediaStreamGraph* graph, StreamTime total) { source_->AppendToTrack(1, // TODO(ekr@rtfm.com): Track ID &segment); + + played_ += 10; } } diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h index 1cf472f9be15..9570bb6394a6 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h @@ -371,7 +371,7 @@ class MediaPipelineReceiveAudio : public MediaPipelineReceive { private: SourceMediaStream *source_; RefPtr conduit_; - StreamTime played_; + uint64_t played_; // Amount of media played in milliseconds. }; RefPtr listener_; From 562567aa746dc09df733c20b7b81043d4bd1e4f1 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Sun, 6 Jan 2013 02:28:00 +0900 Subject: [PATCH 148/180] Bug 826961 - Revise SVGPreserveAspectRatio so that the silly cast is not needed. r=longsonr --- .../src/SVGAnimatedPreserveAspectRatio.h | 8 ++- content/svg/content/src/SVGContentUtils.cpp | 4 +- .../svg/content/src/SVGPreserveAspectRatio.h | 59 +++++++++++-------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h index 4ca60b11cf76..e9ddae79d0b9 100644 --- a/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h +++ b/content/svg/content/src/SVGAnimatedPreserveAspectRatio.h @@ -19,7 +19,7 @@ class nsSMILValue; namespace mozilla { -class SVGAnimatedPreserveAspectRatio +class SVGAnimatedPreserveAspectRatio MOZ_FINAL { public: void Init() { @@ -44,7 +44,8 @@ public: return NS_ERROR_FAILURE; } SetBaseValue(SVGPreserveAspectRatio( - aAlign, mBaseVal.GetMeetOrSlice(), mBaseVal.GetDefer()), + static_cast(aAlign), mBaseVal.GetMeetOrSlice(), + mBaseVal.GetDefer()), aSVGElement); return NS_OK; } @@ -54,7 +55,8 @@ public: return NS_ERROR_FAILURE; } SetBaseValue(SVGPreserveAspectRatio( - mBaseVal.GetAlign(), aMeetOrSlice, mBaseVal.GetDefer()), + mBaseVal.GetAlign(), static_cast(aMeetOrSlice), + mBaseVal.GetDefer()), aSVGElement); return NS_OK; } diff --git a/content/svg/content/src/SVGContentUtils.cpp b/content/svg/content/src/SVGContentUtils.cpp index ae60d3294616..1592c18cbd13 100644 --- a/content/svg/content/src/SVGContentUtils.cpp +++ b/content/svg/content/src/SVGContentUtils.cpp @@ -303,8 +303,8 @@ SVGContentUtils::GetViewBoxTransform(const nsSVGElement* aElement, NS_ASSERTION(aViewboxWidth > 0, "viewBox width must be greater than zero!"); NS_ASSERTION(aViewboxHeight > 0, "viewBox height must be greater than zero!"); - uint16_t align = aPreserveAspectRatio.GetAlign(); - uint16_t meetOrSlice = aPreserveAspectRatio.GetMeetOrSlice(); + SVGAlign align = aPreserveAspectRatio.GetAlign(); + SVGMeetOrSlice meetOrSlice = aPreserveAspectRatio.GetMeetOrSlice(); // default to the defaults if (align == SVG_PRESERVEASPECTRATIO_UNKNOWN) diff --git a/content/svg/content/src/SVGPreserveAspectRatio.h b/content/svg/content/src/SVGPreserveAspectRatio.h index 9cb0a21b7d5b..066ad52a6a60 100644 --- a/content/svg/content/src/SVGPreserveAspectRatio.h +++ b/content/svg/content/src/SVGPreserveAspectRatio.h @@ -12,42 +12,47 @@ class nsSVGElement; +namespace mozilla { // Alignment Types -static const unsigned short SVG_PRESERVEASPECTRATIO_UNKNOWN = 0; -static const unsigned short SVG_PRESERVEASPECTRATIO_NONE = 1; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMIN = 2; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMID = 5; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMID = 6; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMID = 7; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMINYMAX = 8; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9; -static const unsigned short SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10; +enum SVGAlign MOZ_ENUM_TYPE(uint8_t) { + SVG_PRESERVEASPECTRATIO_UNKNOWN = 0, + SVG_PRESERVEASPECTRATIO_NONE = 1, + SVG_PRESERVEASPECTRATIO_XMINYMIN = 2, + SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3, + SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4, + SVG_PRESERVEASPECTRATIO_XMINYMID = 5, + SVG_PRESERVEASPECTRATIO_XMIDYMID = 6, + SVG_PRESERVEASPECTRATIO_XMAXYMID = 7, + SVG_PRESERVEASPECTRATIO_XMINYMAX = 8, + SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9, + SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10 +}; // Meet-or-slice Types -static const unsigned short SVG_MEETORSLICE_UNKNOWN = 0; -static const unsigned short SVG_MEETORSLICE_MEET = 1; -static const unsigned short SVG_MEETORSLICE_SLICE = 2; +enum SVGMeetOrSlice MOZ_ENUM_TYPE(uint8_t) { + SVG_MEETORSLICE_UNKNOWN = 0, + SVG_MEETORSLICE_MEET = 1, + SVG_MEETORSLICE_SLICE = 2 +}; -namespace mozilla { class SVGAnimatedPreserveAspectRatio; -class SVGPreserveAspectRatio +class SVGPreserveAspectRatio MOZ_FINAL { friend class SVGAnimatedPreserveAspectRatio; public: - SVGPreserveAspectRatio(uint16_t aAlign, uint16_t aMeetOrSlice, bool aDefer = false) - : mAlign(static_cast(aAlign)) - , mMeetOrSlice(static_cast(aMeetOrSlice)) + SVGPreserveAspectRatio(SVGAlign aAlign, SVGMeetOrSlice aMeetOrSlice, + bool aDefer = false) + : mAlign(aAlign) + , mMeetOrSlice(aMeetOrSlice) , mDefer(aDefer) {} bool operator==(const SVGPreserveAspectRatio& aOther) const; explicit SVGPreserveAspectRatio() - : mAlign(0) - , mMeetOrSlice(0) + : mAlign(SVG_PRESERVEASPECTRATIO_UNKNOWN) + , mMeetOrSlice(SVG_MEETORSLICE_UNKNOWN) , mDefer(false) {} @@ -59,8 +64,8 @@ public: return NS_OK; } - uint16_t GetAlign() const { - return mAlign; + SVGAlign GetAlign() const { + return static_cast(mAlign); } nsresult SetMeetOrSlice(uint16_t aMeetOrSlice) { @@ -71,8 +76,8 @@ public: return NS_OK; } - uint16_t GetMeetOrSlice() const { - return mMeetOrSlice; + SVGMeetOrSlice GetMeetOrSlice() const { + return static_cast(mMeetOrSlice); } void SetDefer(bool aDefer) { @@ -84,11 +89,15 @@ public: } private: + // We can't use enum types here because some compilers fail to pack them. uint8_t mAlign; uint8_t mMeetOrSlice; bool mDefer; }; +MOZ_STATIC_ASSERT(sizeof(SVGPreserveAspectRatio) <= 4, + "The compiler didn't pack SVGPreserveAspectRatio well"); + namespace dom { class DOMSVGPreserveAspectRatio MOZ_FINAL : public nsISupports, From 90d63d11c37231a57fdb630b6d06031289e0a706 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Fri, 28 Dec 2012 03:45:57 +0100 Subject: [PATCH 149/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - rename classes. r=bz. --HG-- rename : content/html/content/src/nsHTMLTableCaptionElement.cpp => content/html/content/src/HTMLTableCaptionElement.cpp rename : content/html/content/src/nsHTMLTableCaptionElement.cpp => content/html/content/src/HTMLTableCaptionElement.h rename : content/html/content/src/nsHTMLTableCellElement.cpp => content/html/content/src/HTMLTableCellElement.cpp rename : content/html/content/src/nsHTMLTableCellElement.cpp => content/html/content/src/HTMLTableCellElement.h rename : content/html/content/src/nsHTMLTableColElement.cpp => content/html/content/src/HTMLTableColElement.cpp rename : content/html/content/src/nsHTMLTableColElement.cpp => content/html/content/src/HTMLTableColElement.h rename : content/html/content/src/nsHTMLTableElement.cpp => content/html/content/src/HTMLTableElement.cpp rename : content/html/content/src/nsHTMLTableElement.h => content/html/content/src/HTMLTableElement.h rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.cpp rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.h rename : content/html/content/src/nsHTMLTableSectionElement.cpp => content/html/content/src/HTMLTableSectionElement.cpp rename : content/html/content/src/nsHTMLTableSectionElement.cpp => content/html/content/src/HTMLTableSectionElement.h extra : rebase_source : ebb7a81fd1091f5c5905431e79390fd271328a67 --- .../content/src/HTMLTableCaptionElement.cpp | 100 ++++++++++++ .../content/src/HTMLTableCaptionElement.h | 56 +++++++ ...llElement.cpp => HTMLTableCellElement.cpp} | 139 ++++++---------- .../html/content/src/HTMLTableCellElement.h | 65 ++++++++ ...ColElement.cpp => HTMLTableColElement.cpp} | 103 ++++-------- .../html/content/src/HTMLTableColElement.h | 56 +++++++ ...LTableElement.cpp => HTMLTableElement.cpp} | 143 +++++++++-------- ...sHTMLTableElement.h => HTMLTableElement.h} | 23 ++- ...RowElement.cpp => HTMLTableRowElement.cpp} | 117 ++++---------- .../html/content/src/HTMLTableRowElement.h | 63 ++++++++ ...lement.cpp => HTMLTableSectionElement.cpp} | 109 ++++--------- .../content/src/HTMLTableSectionElement.h | 57 +++++++ content/html/content/src/Makefile.in | 18 ++- .../content/src/nsHTMLTableCaptionElement.cpp | 150 ------------------ 14 files changed, 638 insertions(+), 561 deletions(-) create mode 100644 content/html/content/src/HTMLTableCaptionElement.cpp create mode 100644 content/html/content/src/HTMLTableCaptionElement.h rename content/html/content/src/{nsHTMLTableCellElement.cpp => HTMLTableCellElement.cpp} (70%) create mode 100644 content/html/content/src/HTMLTableCellElement.h rename content/html/content/src/{nsHTMLTableColElement.cpp => HTMLTableColElement.cpp} (62%) create mode 100644 content/html/content/src/HTMLTableColElement.h rename content/html/content/src/{nsHTMLTableElement.cpp => HTMLTableElement.cpp} (90%) rename content/html/content/src/{nsHTMLTableElement.h => HTMLTableElement.h} (86%) rename content/html/content/src/{nsHTMLTableRowElement.cpp => HTMLTableRowElement.cpp} (72%) create mode 100644 content/html/content/src/HTMLTableRowElement.h rename content/html/content/src/{nsHTMLTableSectionElement.cpp => HTMLTableSectionElement.cpp} (66%) create mode 100644 content/html/content/src/HTMLTableSectionElement.h delete mode 100644 content/html/content/src/nsHTMLTableCaptionElement.cpp diff --git a/content/html/content/src/HTMLTableCaptionElement.cpp b/content/html/content/src/HTMLTableCaptionElement.cpp new file mode 100644 index 000000000000..a7828dfba399 --- /dev/null +++ b/content/html/content/src/HTMLTableCaptionElement.cpp @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Util.h" + +#include "mozilla/dom/HTMLTableCaptionElement.h" +#include "nsAttrValueInlines.h" +#include "nsGkAtoms.h" +#include "nsStyleConsts.h" +#include "nsMappedAttributes.h" +#include "nsRuleData.h" + +NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption) +DOMCI_NODE_DATA(HTMLTableCaptionElement, mozilla::dom::HTMLTableCaptionElement) + +namespace mozilla { +namespace dom { + +HTMLTableCaptionElement::~HTMLTableCaptionElement() +{ +} + +NS_IMPL_ADDREF_INHERITED(HTMLTableCaptionElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLTableCaptionElement, Element) + +// QueryInterface implementation for HTMLTableCaptionElement +NS_INTERFACE_TABLE_HEAD(HTMLTableCaptionElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableCaptionElement, + nsIDOMHTMLTableCaptionElement) + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableCaptionElement, + nsGenericHTMLElement) +NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableCaptionElement) + +NS_IMPL_ELEMENT_CLONE(HTMLTableCaptionElement) + +NS_IMPL_STRING_ATTR(HTMLTableCaptionElement, Align, align) + +static const nsAttrValue::EnumTable kCaptionAlignTable[] = { + { "left", NS_STYLE_CAPTION_SIDE_LEFT }, + { "right", NS_STYLE_CAPTION_SIDE_RIGHT }, + { "top", NS_STYLE_CAPTION_SIDE_TOP }, + { "bottom", NS_STYLE_CAPTION_SIDE_BOTTOM }, + { 0 } +}; + +bool +HTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) +{ + if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) { + return aResult.ParseEnumValue(aValue, kCaptionAlignTable, false); + } + + return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, + aResult); +} + +static +void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) +{ + if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) { + nsCSSValue* captionSide = aData->ValueForCaptionSide(); + if (captionSide->GetUnit() == eCSSUnit_Null) { + const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align); + if (value && value->Type() == nsAttrValue::eEnum) + captionSide->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated); + } + } + + nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData); +} + +NS_IMETHODIMP_(bool) +HTMLTableCaptionElement::IsAttributeMapped(const nsIAtom* aAttribute) const +{ + static const MappedAttributeEntry attributes[] = { + { &nsGkAtoms::align }, + { nullptr } + }; + + static const MappedAttributeEntry* const map[] = { + attributes, + sCommonAttributeMap, + }; + + return FindAttributeDependence(aAttribute, map); +} + +nsMapRuleToAttributesFunc +HTMLTableCaptionElement::GetAttributeMappingFunction() const +{ + return &MapAttributesIntoRule; +} + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLTableCaptionElement.h b/content/html/content/src/HTMLTableCaptionElement.h new file mode 100644 index 000000000000..a024023d59d7 --- /dev/null +++ b/content/html/content/src/HTMLTableCaptionElement.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozilla_dom_HTMLTableCaptionElement_h +#define mozilla_dom_HTMLTableCaptionElement_h + +#include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLTableCaptionElem.h" + +namespace mozilla { +namespace dom { + +class HTMLTableCaptionElement : public nsGenericHTMLElement, + public nsIDOMHTMLTableCaptionElement +{ +public: + HTMLTableCaptionElement(already_AddRefed aNodeInfo) + : nsGenericHTMLElement(aNodeInfo) + { + } + virtual ~HTMLTableCaptionElement(); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMElement + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + + // nsIDOMHTMLElement + NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC + + // nsIDOMHTMLTableCaptionElement + NS_DECL_NSIDOMHTMLTABLECAPTIONELEMENT + + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLTableCaptionElement_h */ diff --git a/content/html/content/src/nsHTMLTableCellElement.cpp b/content/html/content/src/HTMLTableCellElement.cpp similarity index 70% rename from content/html/content/src/nsHTMLTableCellElement.cpp rename to content/html/content/src/HTMLTableCellElement.cpp index ccbfedb2c313..739f5abe5524 100644 --- a/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/content/html/content/src/HTMLTableCellElement.cpp @@ -5,13 +5,12 @@ #include "mozilla/Util.h" +#include "mozilla/dom/HTMLTableCellElement.h" +#include "mozilla/dom/HTMLTableElement.h" #include "nsIDOMHTMLTableCellElement.h" #include "nsIDOMHTMLTableRowElement.h" -#include "nsHTMLTableElement.h" #include "nsIDOMHTMLCollection.h" -#include "nsIDOMEventTarget.h" #include "nsMappedAttributes.h" -#include "nsGenericHTMLElement.h" #include "nsAttrValueInlines.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" @@ -20,93 +19,42 @@ #include "nsRuleWalker.h" #include "celldata.h" -using namespace mozilla; -using namespace mozilla::dom; - -class nsHTMLTableCellElement : public nsGenericHTMLElement, - public nsIDOMHTMLTableCellElement -{ -public: - nsHTMLTableCellElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLTableCellElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC - - // nsIDOMHTMLTableCellElement - NS_DECL_NSIDOMHTMLTABLECELLELEMENT - - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - nsHTMLTableElement* GetTable() const; - - already_AddRefed GetRow() const; -}; - - NS_IMPL_NS_NEW_HTML_ELEMENT(TableCell) +DOMCI_NODE_DATA(HTMLTableCellElement, mozilla::dom::HTMLTableCellElement) +namespace mozilla { +namespace dom { -nsHTMLTableCellElement::nsHTMLTableCellElement(already_AddRefed aNodeInfo) - : nsGenericHTMLElement(aNodeInfo) +HTMLTableCellElement::~HTMLTableCellElement() { } -nsHTMLTableCellElement::~nsHTMLTableCellElement() -{ -} +NS_IMPL_ADDREF_INHERITED(HTMLTableCellElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLTableCellElement, Element) - -NS_IMPL_ADDREF_INHERITED(nsHTMLTableCellElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLTableCellElement, Element) - - -DOMCI_NODE_DATA(HTMLTableCellElement, nsHTMLTableCellElement) - -// QueryInterface implementation for nsHTMLTableCellElement -NS_INTERFACE_TABLE_HEAD(nsHTMLTableCellElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableCellElement, +// QueryInterface implementation for HTMLTableCellElement +NS_INTERFACE_TABLE_HEAD(HTMLTableCellElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableCellElement, nsIDOMHTMLTableCellElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableCellElement, + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableCellElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableCellElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLTableCellElement) +NS_IMPL_ELEMENT_CLONE(HTMLTableCellElement) // protected method already_AddRefed -nsHTMLTableCellElement::GetRow() const +HTMLTableCellElement::GetRow() const { nsCOMPtr row = do_QueryInterface(GetParent()); return row.forget(); } // protected method -nsHTMLTableElement* -nsHTMLTableCellElement::GetTable() const +HTMLTableElement* +HTMLTableCellElement::GetTable() const { nsIContent *parent = GetParent(); if (!parent) { @@ -121,20 +69,20 @@ nsHTMLTableCellElement::GetTable() const if (section->IsHTML(nsGkAtoms::table)) { // XHTML, without a row group. - return static_cast(section); + return static_cast(section); } // We have a row group. nsIContent* result = section->GetParent(); if (result && result->IsHTML(nsGkAtoms::table)) { - return static_cast(result); + return static_cast(result); } return nullptr; } NS_IMETHODIMP -nsHTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) +HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) { *aCellIndex = -1; @@ -169,12 +117,12 @@ nsHTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) NS_IMETHODIMP -nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) +HTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) { nsresult rv = nsGenericHTMLElement::WalkContentStyleRules(aRuleWalker); NS_ENSURE_SUCCESS(rv, rv); - if (nsHTMLTableElement* table = GetTable()) { + if (HTMLTableElement* table = GetTable()) { nsMappedAttributes* tableInheritedAttributes = table->GetAttributesMappedForCell(); if (tableInheritedAttributes) { @@ -185,23 +133,23 @@ nsHTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) } -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Abbr, abbr) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Axis, axis) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, BgColor, bgcolor) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Ch, _char) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, ChOff, charoff) -NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, ColSpan, colspan, 1) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Headers, headers) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Height, height) -NS_IMPL_BOOL_ATTR(nsHTMLTableCellElement, NoWrap, nowrap) -NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTableCellElement, RowSpan, rowspan, 1) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Scope, scope) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, VAlign, valign) -NS_IMPL_STRING_ATTR(nsHTMLTableCellElement, Width, width) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Abbr, abbr) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Axis, axis) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, BgColor, bgcolor) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Ch, _char) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, ChOff, charoff) +NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableCellElement, ColSpan, colspan, 1) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Headers, headers) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Height, height) +NS_IMPL_BOOL_ATTR(HTMLTableCellElement, NoWrap, nowrap) +NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableCellElement, RowSpan, rowspan, 1) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Scope, scope) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, VAlign, valign) +NS_IMPL_STRING_ATTR(HTMLTableCellElement, Width, width) NS_IMETHODIMP -nsHTMLTableCellElement::GetAlign(nsAString& aValue) +HTMLTableCellElement::GetAlign(nsAString& aValue) { if (!GetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue)) { // There's no align attribute, ask the row for the alignment. @@ -215,7 +163,7 @@ nsHTMLTableCellElement::GetAlign(nsAString& aValue) } NS_IMETHODIMP -nsHTMLTableCellElement::SetAlign(const nsAString& aValue) +HTMLTableCellElement::SetAlign(const nsAString& aValue) { return SetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue, true); } @@ -230,10 +178,10 @@ static const nsAttrValue::EnumTable kCellScopeTable[] = { }; bool -nsHTMLTableCellElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLTableCellElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { if (aNamespaceID == kNameSpaceID_None) { /* ignore these attributes, stored simply as strings @@ -370,7 +318,7 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, } NS_IMETHODIMP_(bool) -nsHTMLTableCellElement::IsAttributeMapped(const nsIAtom* aAttribute) const +HTMLTableCellElement::IsAttributeMapped(const nsIAtom* aAttribute) const { static const MappedAttributeEntry attributes[] = { { &nsGkAtoms::align }, @@ -399,7 +347,10 @@ nsHTMLTableCellElement::IsAttributeMapped(const nsIAtom* aAttribute) const } nsMapRuleToAttributesFunc -nsHTMLTableCellElement::GetAttributeMappingFunction() const +HTMLTableCellElement::GetAttributeMappingFunction() const { return &MapAttributesIntoRule; } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLTableCellElement.h b/content/html/content/src/HTMLTableCellElement.h new file mode 100644 index 000000000000..1e1a555b0bd6 --- /dev/null +++ b/content/html/content/src/HTMLTableCellElement.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozilla_dom_HTMLTableCellElement_h +#define mozilla_dom_HTMLTableCellElement_h + +#include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLTableCellElement.h" + +class nsIDOMHTMLTableRowElement; + +namespace mozilla { +namespace dom { + +class HTMLTableElement; + +class HTMLTableCellElement : public nsGenericHTMLElement, + public nsIDOMHTMLTableCellElement +{ +public: + HTMLTableCellElement(already_AddRefed aNodeInfo) + : nsGenericHTMLElement(aNodeInfo) + { + } + virtual ~HTMLTableCellElement(); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMElement + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + + // nsIDOMHTMLElement + NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC + + // nsIDOMHTMLTableCellElement + NS_DECL_NSIDOMHTMLTABLECELLELEMENT + + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + NS_IMETHOD WalkContentStyleRules(nsRuleWalker* aRuleWalker); + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +protected: + HTMLTableElement* GetTable() const; + + already_AddRefed GetRow() const; +}; + +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLTableCellElement_h */ diff --git a/content/html/content/src/nsHTMLTableColElement.cpp b/content/html/content/src/HTMLTableColElement.cpp similarity index 62% rename from content/html/content/src/nsHTMLTableColElement.cpp rename to content/html/content/src/HTMLTableColElement.cpp index c1055b9b320b..e8d20d17a3fd 100644 --- a/content/html/content/src/nsHTMLTableColElement.cpp +++ b/content/html/content/src/HTMLTableColElement.cpp @@ -5,102 +5,54 @@ #include "mozilla/Util.h" -#include "nsIDOMHTMLTableColElement.h" -#include "nsIDOMEventTarget.h" +#include "mozilla/dom/HTMLTableColElement.h" #include "nsMappedAttributes.h" -#include "nsGenericHTMLElement.h" #include "nsAttrValueInlines.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" #include "nsRuleData.h" -using namespace mozilla; -using namespace mozilla::dom; +NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol) +DOMCI_NODE_DATA(HTMLTableColElement, mozilla::dom::HTMLTableColElement) + +namespace mozilla { +namespace dom { // use the same protection as ancient code did // http://lxr.mozilla.org/classic/source/lib/layout/laytable.c#46 #define MAX_COLSPAN 1000 -class nsHTMLTableColElement : public nsGenericHTMLElement, - public nsIDOMHTMLTableColElement -{ -public: - nsHTMLTableColElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLTableColElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC - - // nsIDOMHTMLTableColElement - NS_DECL_NSIDOMHTMLTABLECOLELEMENT - - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - - -NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol) - - -nsHTMLTableColElement::nsHTMLTableColElement(already_AddRefed aNodeInfo) - : nsGenericHTMLElement(aNodeInfo) +HTMLTableColElement::~HTMLTableColElement() { } -nsHTMLTableColElement::~nsHTMLTableColElement() -{ -} +NS_IMPL_ADDREF_INHERITED(HTMLTableColElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLTableColElement, Element) - -NS_IMPL_ADDREF_INHERITED(nsHTMLTableColElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLTableColElement, Element) - - -DOMCI_NODE_DATA(HTMLTableColElement, nsHTMLTableColElement) - -// QueryInterface implementation for nsHTMLTableColElement -NS_INTERFACE_TABLE_HEAD(nsHTMLTableColElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableColElement, +// QueryInterface implementation for HTMLTableColElement +NS_INTERFACE_TABLE_HEAD(HTMLTableColElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableColElement, nsIDOMHTMLTableColElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableColElement, + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableColElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableColElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLTableColElement) +NS_IMPL_ELEMENT_CLONE(HTMLTableColElement) -NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Align, align) -NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Ch, _char) -NS_IMPL_STRING_ATTR(nsHTMLTableColElement, ChOff, charoff) -NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Span, span, 1) -NS_IMPL_STRING_ATTR(nsHTMLTableColElement, VAlign, valign) -NS_IMPL_STRING_ATTR(nsHTMLTableColElement, Width, width) +NS_IMPL_STRING_ATTR(HTMLTableColElement, Align, align) +NS_IMPL_STRING_ATTR(HTMLTableColElement, Ch, _char) +NS_IMPL_STRING_ATTR(HTMLTableColElement, ChOff, charoff) +NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableColElement, Span, span, 1) +NS_IMPL_STRING_ATTR(HTMLTableColElement, VAlign, valign) +NS_IMPL_STRING_ATTR(HTMLTableColElement, Width, width) bool -nsHTMLTableColElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLTableColElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { if (aNamespaceID == kNameSpaceID_None) { /* ignore these attributes, stored simply as strings ch */ @@ -189,7 +141,7 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD } NS_IMETHODIMP_(bool) -nsHTMLTableColElement::IsAttributeMapped(const nsIAtom* aAttribute) const +HTMLTableColElement::IsAttributeMapped(const nsIAtom* aAttribute) const { static const MappedAttributeEntry attributes[] = { { &nsGkAtoms::width }, @@ -209,7 +161,10 @@ nsHTMLTableColElement::IsAttributeMapped(const nsIAtom* aAttribute) const nsMapRuleToAttributesFunc -nsHTMLTableColElement::GetAttributeMappingFunction() const +HTMLTableColElement::GetAttributeMappingFunction() const { return &MapAttributesIntoRule; } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLTableColElement.h b/content/html/content/src/HTMLTableColElement.h new file mode 100644 index 000000000000..2ef0e25ac645 --- /dev/null +++ b/content/html/content/src/HTMLTableColElement.h @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozilla_dom_HTMLTableColElement_h +#define mozilla_dom_HTMLTableColElement_h + +#include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLTableColElement.h" + +namespace mozilla { +namespace dom { + +class HTMLTableColElement : public nsGenericHTMLElement, + public nsIDOMHTMLTableColElement +{ +public: + HTMLTableColElement(already_AddRefed aNodeInfo) + : nsGenericHTMLElement(aNodeInfo) + { + } + virtual ~HTMLTableColElement(); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMElement + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + + // nsIDOMHTMLElement + NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC + + // nsIDOMHTMLTableColElement + NS_DECL_NSIDOMHTMLTABLECOLELEMENT + + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +}; + +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLTableColElement_h */ diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/HTMLTableElement.cpp similarity index 90% rename from content/html/content/src/nsHTMLTableElement.cpp rename to content/html/content/src/HTMLTableElement.cpp index f8188992cc05..3070aa84c7d9 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/HTMLTableElement.cpp @@ -5,7 +5,7 @@ #include "mozilla/Util.h" -#include "nsHTMLTableElement.h" +#include "mozilla/dom/HTMLTableElement.h" #include "nsIDOMHTMLTableCaptionElem.h" #include "nsIDOMHTMLTableSectionElem.h" #include "nsCOMPtr.h" @@ -28,8 +28,11 @@ #include "mozilla/dom/HTMLCollectionBinding.h" #include "mozilla/dom/BindingUtils.h" -using namespace mozilla; -using namespace mozilla::dom; +NS_IMPL_NS_NEW_HTML_ELEMENT(Table) +DOMCI_NODE_DATA(HTMLTableElement, mozilla::dom::HTMLTableElement) + +namespace mozilla { +namespace dom { /* ------------------------------ TableRowsCollection -------------------------------- */ /** @@ -40,7 +43,7 @@ class TableRowsCollection : public nsIHTMLCollection, public nsWrapperCache { public: - TableRowsCollection(nsHTMLTableElement *aParent); + TableRowsCollection(HTMLTableElement *aParent); virtual ~TableRowsCollection(); NS_DECL_CYCLE_COLLECTING_ISUPPORTS @@ -70,12 +73,12 @@ public: protected: // Those rows that are not in table sections - nsHTMLTableElement* mParent; + HTMLTableElement* mParent; nsRefPtr mOrphanRows; }; -TableRowsCollection::TableRowsCollection(nsHTMLTableElement *aParent) +TableRowsCollection::TableRowsCollection(HTMLTableElement *aParent) : mParent(aParent) , mOrphanRows(new nsContentList(mParent, kNameSpaceID_XHTML, @@ -320,20 +323,15 @@ TableRowsCollection::ParentDestroyed() return NS_OK; } -/* -------------------------- nsHTMLTableElement --------------------------- */ -// the class declaration is at the top of this file +/* --------------------------- HTMLTableElement ---------------------------- */ - -NS_IMPL_NS_NEW_HTML_ELEMENT(Table) - - -nsHTMLTableElement::nsHTMLTableElement(already_AddRefed aNodeInfo) +HTMLTableElement::HTMLTableElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mTableInheritedAttributes(TABLE_ATTRS_DIRTY) { } -nsHTMLTableElement::~nsHTMLTableElement() +HTMLTableElement::~HTMLTableElement() { if (mRows) { mRows->ParentDestroyed(); @@ -342,54 +340,52 @@ nsHTMLTableElement::~nsHTMLTableElement() } -NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLTableElement) -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLTableElement, nsGenericHTMLElement) +NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableElement) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLTableElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_UNLINK(mTBodies) if (tmp->mRows) { tmp->mRows->ParentDestroyed(); } NS_IMPL_CYCLE_COLLECTION_UNLINK(mRows) NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLTableElement, +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTableElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTBodies) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRows) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_ADDREF_INHERITED(nsHTMLTableElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLTableElement, Element) +NS_IMPL_ADDREF_INHERITED(HTMLTableElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLTableElement, Element) -DOMCI_NODE_DATA(HTMLTableElement, nsHTMLTableElement) - -// QueryInterface implementation for nsHTMLTableElement -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTableElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableElement, nsIDOMHTMLTableElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableElement, +// QueryInterface implementation for HTMLTableElement +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLTableElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableElement, nsIDOMHTMLTableElement) + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLTableElement) +NS_IMPL_ELEMENT_CLONE(HTMLTableElement) // the DOM spec says border, cellpadding, cellSpacing are all "wstring" // in fact, they are integers or they are meaningless. so we store them // here as ints. -NS_IMPL_STRING_ATTR(nsHTMLTableElement, Align, align) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, BgColor, bgcolor) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, Border, border) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, CellPadding, cellpadding) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, CellSpacing, cellspacing) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, Frame, frame) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, Rules, rules) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, Summary, summary) -NS_IMPL_STRING_ATTR(nsHTMLTableElement, Width, width) +NS_IMPL_STRING_ATTR(HTMLTableElement, Align, align) +NS_IMPL_STRING_ATTR(HTMLTableElement, BgColor, bgcolor) +NS_IMPL_STRING_ATTR(HTMLTableElement, Border, border) +NS_IMPL_STRING_ATTR(HTMLTableElement, CellPadding, cellpadding) +NS_IMPL_STRING_ATTR(HTMLTableElement, CellSpacing, cellspacing) +NS_IMPL_STRING_ATTR(HTMLTableElement, Frame, frame) +NS_IMPL_STRING_ATTR(HTMLTableElement, Rules, rules) +NS_IMPL_STRING_ATTR(HTMLTableElement, Summary, summary) +NS_IMPL_STRING_ATTR(HTMLTableElement, Width, width) already_AddRefed -nsHTMLTableElement::GetCaption() +HTMLTableElement::GetCaption() { for (nsIContent* cur = nsINode::GetFirstChild(); cur; cur = cur->GetNextSibling()) { nsCOMPtr caption = do_QueryInterface(cur); @@ -401,7 +397,7 @@ nsHTMLTableElement::GetCaption() } NS_IMETHODIMP -nsHTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) +HTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) { nsCOMPtr caption = GetCaption(); caption.forget(aValue); @@ -409,7 +405,7 @@ nsHTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) +HTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) { nsresult rv = DeleteCaption(); @@ -424,7 +420,7 @@ nsHTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) } already_AddRefed -nsHTMLTableElement::GetSection(nsIAtom *aTag) +HTMLTableElement::GetSection(nsIAtom *aTag) { for (nsIContent* child = nsINode::GetFirstChild(); child; @@ -438,7 +434,7 @@ nsHTMLTableElement::GetSection(nsIAtom *aTag) } NS_IMETHODIMP -nsHTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) +HTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) { *aValue = GetTHead().get(); @@ -446,7 +442,7 @@ nsHTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) +HTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) { nsCOMPtr content(do_QueryInterface(aValue)); NS_ENSURE_TRUE(content, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); @@ -475,7 +471,7 @@ nsHTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) } NS_IMETHODIMP -nsHTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) +HTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) { *aValue = GetTFoot().get(); @@ -483,7 +479,7 @@ nsHTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) +HTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) { nsCOMPtr content(do_QueryInterface(aValue)); NS_ENSURE_TRUE(content, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); @@ -504,7 +500,7 @@ nsHTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) } NS_IMETHODIMP -nsHTMLTableElement::GetRows(nsIDOMHTMLCollection** aValue) +HTMLTableElement::GetRows(nsIDOMHTMLCollection** aValue) { if (!mRows) { mRows = new TableRowsCollection(this); @@ -517,14 +513,14 @@ nsHTMLTableElement::GetRows(nsIDOMHTMLCollection** aValue) } NS_IMETHODIMP -nsHTMLTableElement::GetTBodies(nsIDOMHTMLCollection** aValue) +HTMLTableElement::GetTBodies(nsIDOMHTMLCollection** aValue) { NS_ADDREF(*aValue = TBodies()); return NS_OK; } nsContentList* -nsHTMLTableElement::TBodies() +HTMLTableElement::TBodies() { if (!mTBodies) { // Not using NS_GetContentList because this should not be cached @@ -539,7 +535,7 @@ nsHTMLTableElement::TBodies() } NS_IMETHODIMP -nsHTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) +HTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) { *aValue = nullptr; @@ -574,7 +570,7 @@ nsHTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::DeleteTHead() +HTMLTableElement::DeleteTHead() { nsCOMPtr childToDelete; nsresult rv = GetTHead(getter_AddRefs(childToDelete)); @@ -589,7 +585,7 @@ nsHTMLTableElement::DeleteTHead() } NS_IMETHODIMP -nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) +HTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) { *aValue = nullptr; @@ -616,7 +612,7 @@ nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::DeleteTFoot() +HTMLTableElement::DeleteTFoot() { nsCOMPtr childToDelete; nsresult rv = GetTFoot(getter_AddRefs(childToDelete)); @@ -631,7 +627,7 @@ nsHTMLTableElement::DeleteTFoot() } NS_IMETHODIMP -nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) +HTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) { *aValue = nullptr; @@ -660,7 +656,7 @@ nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::DeleteCaption() +HTMLTableElement::DeleteCaption() { nsCOMPtr childToDelete; nsresult rv = GetCaption(getter_AddRefs(childToDelete)); @@ -674,7 +670,7 @@ nsHTMLTableElement::DeleteCaption() } NS_IMETHODIMP -nsHTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) +HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) { /* get the ref row at aIndex if there is one, @@ -818,7 +814,7 @@ nsHTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) } NS_IMETHODIMP -nsHTMLTableElement::DeleteRow(int32_t aValue) +HTMLTableElement::DeleteRow(int32_t aValue) { if (aValue < -1) { return NS_ERROR_DOM_INDEX_SIZE_ERR; @@ -889,10 +885,10 @@ static const nsAttrValue::EnumTable kLayoutTable[] = { bool -nsHTMLTableElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLTableElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { /* ignore summary, just a string */ if (aNamespaceID == kNameSpaceID_None) { @@ -1110,7 +1106,7 @@ MapAttributesIntoRule(const nsMappedAttributes* aAttributes, } NS_IMETHODIMP_(bool) -nsHTMLTableElement::IsAttributeMapped(const nsIAtom* aAttribute) const +HTMLTableElement::IsAttributeMapped(const nsIAtom* aAttribute) const { static const MappedAttributeEntry attributes[] = { { &nsGkAtoms::layout }, @@ -1139,7 +1135,7 @@ nsHTMLTableElement::IsAttributeMapped(const nsIAtom* aAttribute) const } nsMapRuleToAttributesFunc -nsHTMLTableElement::GetAttributeMappingFunction() const +HTMLTableElement::GetAttributeMappingFunction() const { return &MapAttributesIntoRule; } @@ -1179,7 +1175,7 @@ MapInheritedTableAttributesIntoRule(const nsMappedAttributes* aAttributes, } nsMappedAttributes* -nsHTMLTableElement::GetAttributesMappedForCell() +HTMLTableElement::GetAttributesMappedForCell() { if (mTableInheritedAttributes) { if (mTableInheritedAttributes == TABLE_ATTRS_DIRTY) @@ -1191,7 +1187,7 @@ nsHTMLTableElement::GetAttributesMappedForCell() } void -nsHTMLTableElement::BuildInheritedAttributes() +HTMLTableElement::BuildInheritedAttributes() { NS_ASSERTION(mTableInheritedAttributes == TABLE_ATTRS_DIRTY, "potential leak, plus waste of work"); @@ -1227,9 +1223,9 @@ nsHTMLTableElement::BuildInheritedAttributes() } nsresult -nsHTMLTableElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - bool aCompileEventHandlers) +HTMLTableElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, + nsIContent* aBindingParent, + bool aCompileEventHandlers) { ReleaseInheritedAttributes(); return nsGenericHTMLElement::BindToTree(aDocument, aParent, @@ -1238,16 +1234,16 @@ nsHTMLTableElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, } void -nsHTMLTableElement::UnbindFromTree(bool aDeep, bool aNullParent) +HTMLTableElement::UnbindFromTree(bool aDeep, bool aNullParent) { ReleaseInheritedAttributes(); nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent); } nsresult -nsHTMLTableElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAttrValueOrString* aValue, - bool aNotify) +HTMLTableElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAttrValueOrString* aValue, + bool aNotify) { if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) { ReleaseInheritedAttributes(); @@ -1257,9 +1253,9 @@ nsHTMLTableElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } nsresult -nsHTMLTableElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAttrValue* aValue, - bool aNotify) +HTMLTableElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, + const nsAttrValue* aValue, + bool aNotify) { if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) { BuildInheritedAttributes(); @@ -1267,3 +1263,6 @@ nsHTMLTableElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, aNotify); } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/nsHTMLTableElement.h b/content/html/content/src/HTMLTableElement.h similarity index 86% rename from content/html/content/src/nsHTMLTableElement.h rename to content/html/content/src/HTMLTableElement.h index 807f71ffe4ed..8e07046c2f28 100644 --- a/content/html/content/src/nsHTMLTableElement.h +++ b/content/html/content/src/HTMLTableElement.h @@ -2,21 +2,26 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsIDOMHTMLTableElement.h" +#ifndef mozilla_dom_HTMLTableElement_h +#define mozilla_dom_HTMLTableElement_h + #include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLTableElement.h" #include "nsMappedAttributes.h" +namespace mozilla { +namespace dom { + #define TABLE_ATTRS_DIRTY ((nsMappedAttributes*)0x1) - class TableRowsCollection; -class nsHTMLTableElement : public nsGenericHTMLElement, - public nsIDOMHTMLTableElement +class HTMLTableElement : public nsGenericHTMLElement, + public nsIDOMHTMLTableElement { public: - nsHTMLTableElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLTableElement(); + HTMLTableElement(already_AddRefed aNodeInfo); + virtual ~HTMLTableElement(); // nsISupports NS_DECL_ISUPPORTS_INHERITED @@ -61,7 +66,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, bool aNotify); - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLTableElement, + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTableElement, nsGenericHTMLElement) nsMappedAttributes* GetAttributesMappedForCell(); already_AddRefed GetTHead() { @@ -89,3 +94,7 @@ protected: } }; +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLTableElement_h */ diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/HTMLTableRowElement.cpp similarity index 72% rename from content/html/content/src/nsHTMLTableRowElement.cpp rename to content/html/content/src/HTMLTableRowElement.cpp index f6703b3c4116..1f2a72df5ad9 100644 --- a/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/content/html/content/src/HTMLTableRowElement.cpp @@ -5,14 +5,11 @@ #include "mozilla/Util.h" -#include "nsIDOMHTMLTableRowElement.h" +#include "mozilla/dom/HTMLTableRowElement.h" #include "nsIDOMHTMLTableElement.h" #include "nsIDOMHTMLTableSectionElem.h" #include "nsIDOMHTMLTableCellElement.h" -#include "nsIDOMEventTarget.h" -#include "nsError.h" #include "nsMappedAttributes.h" -#include "nsGenericHTMLElement.h" #include "nsAttrValueInlines.h" #include "nsContentList.h" #include "nsGkAtoms.h" @@ -21,88 +18,41 @@ #include "nsRuleData.h" #include "nsContentUtils.h" -using namespace mozilla; -using namespace mozilla::dom; - -class nsHTMLTableRowElement : public nsGenericHTMLElement, - public nsIDOMHTMLTableRowElement -{ -public: - nsHTMLTableRowElement(already_AddRefed aNodeInfo); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC - - // nsIDOMHTMLTableRowElement - NS_DECL_NSIDOMHTMLTABLEROWELEMENT - - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLTableRowElement, - nsGenericHTMLElement) - -protected: - already_AddRefed GetSection() const; - already_AddRefed GetTable() const; - nsRefPtr mCells; -}; - - NS_IMPL_NS_NEW_HTML_ELEMENT(TableRow) +DOMCI_NODE_DATA(HTMLTableRowElement, mozilla::dom::HTMLTableRowElement) +namespace mozilla { +namespace dom { -nsHTMLTableRowElement::nsHTMLTableRowElement(already_AddRefed aNodeInfo) +HTMLTableRowElement::HTMLTableRowElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { } -NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLTableRowElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLTableRowElement, +NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableRowElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTableRowElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCells) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_ADDREF_INHERITED(nsHTMLTableRowElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLTableRowElement, Element) +NS_IMPL_ADDREF_INHERITED(HTMLTableRowElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLTableRowElement, Element) - -DOMCI_NODE_DATA(HTMLTableRowElement, nsHTMLTableRowElement) - -// QueryInterface implementation for nsHTMLTableRowElement -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTableRowElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableRowElement, +// QueryInterface implementation for HTMLTableRowElement +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLTableRowElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableRowElement, nsIDOMHTMLTableRowElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableRowElement, + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableRowElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableRowElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLTableRowElement) +NS_IMPL_ELEMENT_CLONE(HTMLTableRowElement) // protected method already_AddRefed -nsHTMLTableRowElement::GetSection() const +HTMLTableRowElement::GetSection() const { nsCOMPtr section = do_QueryInterface(GetParent()); @@ -111,7 +61,7 @@ nsHTMLTableRowElement::GetSection() const // protected method already_AddRefed -nsHTMLTableRowElement::GetTable() const +HTMLTableRowElement::GetTable() const { nsIContent* parent = GetParent(); if (!parent) { @@ -133,7 +83,7 @@ nsHTMLTableRowElement::GetTable() const } NS_IMETHODIMP -nsHTMLTableRowElement::GetRowIndex(int32_t* aValue) +HTMLTableRowElement::GetRowIndex(int32_t* aValue) { *aValue = -1; nsCOMPtr table = GetTable(); @@ -157,7 +107,7 @@ nsHTMLTableRowElement::GetRowIndex(int32_t* aValue) } NS_IMETHODIMP -nsHTMLTableRowElement::GetSectionRowIndex(int32_t* aValue) +HTMLTableRowElement::GetSectionRowIndex(int32_t* aValue) { *aValue = -1; nsCOMPtr section = GetSection(); @@ -191,7 +141,7 @@ IsCell(nsIContent *aContent, int32_t aNamespaceID, } NS_IMETHODIMP -nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) +HTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) { if (!mCells) { mCells = new nsContentList(this, @@ -209,7 +159,7 @@ nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) } NS_IMETHODIMP -nsHTMLTableRowElement::InsertCell(int32_t aIndex, nsIDOMHTMLElement** aValue) +HTMLTableRowElement::InsertCell(int32_t aIndex, nsIDOMHTMLElement** aValue) { *aValue = nullptr; @@ -267,7 +217,7 @@ nsHTMLTableRowElement::InsertCell(int32_t aIndex, nsIDOMHTMLElement** aValue) NS_IMETHODIMP -nsHTMLTableRowElement::DeleteCell(int32_t aValue) +HTMLTableRowElement::DeleteCell(int32_t aValue) { if (aValue < -1) { return NS_ERROR_DOM_INDEX_SIZE_ERR; @@ -304,18 +254,18 @@ nsHTMLTableRowElement::DeleteCell(int32_t aValue) return RemoveChild(cell, getter_AddRefs(retChild)); } -NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Align, align) -NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, BgColor, bgcolor) -NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, Ch, _char) -NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, ChOff, charoff) -NS_IMPL_STRING_ATTR(nsHTMLTableRowElement, VAlign, valign) +NS_IMPL_STRING_ATTR(HTMLTableRowElement, Align, align) +NS_IMPL_STRING_ATTR(HTMLTableRowElement, BgColor, bgcolor) +NS_IMPL_STRING_ATTR(HTMLTableRowElement, Ch, _char) +NS_IMPL_STRING_ATTR(HTMLTableRowElement, ChOff, charoff) +NS_IMPL_STRING_ATTR(HTMLTableRowElement, VAlign, valign) bool -nsHTMLTableRowElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLTableRowElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { /* * ignore these attributes, stored simply as strings @@ -389,7 +339,7 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD } NS_IMETHODIMP_(bool) -nsHTMLTableRowElement::IsAttributeMapped(const nsIAtom* aAttribute) const +HTMLTableRowElement::IsAttributeMapped(const nsIAtom* aAttribute) const { static const MappedAttributeEntry attributes[] = { { &nsGkAtoms::align }, @@ -408,7 +358,10 @@ nsHTMLTableRowElement::IsAttributeMapped(const nsIAtom* aAttribute) const } nsMapRuleToAttributesFunc -nsHTMLTableRowElement::GetAttributeMappingFunction() const +HTMLTableRowElement::GetAttributeMappingFunction() const { return &MapAttributesIntoRule; } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLTableRowElement.h b/content/html/content/src/HTMLTableRowElement.h new file mode 100644 index 000000000000..74ba6b306cd6 --- /dev/null +++ b/content/html/content/src/HTMLTableRowElement.h @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozilla_dom_HTMLTableRowElement_h +#define mozilla_dom_HTMLTableRowElement_h + +#include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLTableRowElement.h" + +class nsIDOMHTMLTableElement; +class nsIDOMHTMLTableSectionElement; + +namespace mozilla { +namespace dom { + +class HTMLTableRowElement : public nsGenericHTMLElement, + public nsIDOMHTMLTableRowElement +{ +public: + HTMLTableRowElement(already_AddRefed aNodeInfo); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMElement + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + + // nsIDOMHTMLElement + NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC + + // nsIDOMHTMLTableRowElement + NS_DECL_NSIDOMHTMLTABLEROWELEMENT + + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLTableRowElement, + nsGenericHTMLElement) + +protected: + already_AddRefed GetSection() const; + already_AddRefed GetTable() const; + nsRefPtr mCells; +}; + +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLTableRowElement_h */ diff --git a/content/html/content/src/nsHTMLTableSectionElement.cpp b/content/html/content/src/HTMLTableSectionElement.cpp similarity index 66% rename from content/html/content/src/nsHTMLTableSectionElement.cpp rename to content/html/content/src/HTMLTableSectionElement.cpp index 52b049f9551f..f1e330c24483 100644 --- a/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/content/html/content/src/HTMLTableSectionElement.cpp @@ -5,10 +5,8 @@ #include "mozilla/Util.h" -#include "nsIDOMHTMLTableSectionElem.h" -#include "nsIDOMEventTarget.h" +#include "mozilla/dom/HTMLTableSectionElement.h" #include "nsMappedAttributes.h" -#include "nsGenericHTMLElement.h" #include "nsAttrValueInlines.h" #include "nsGkAtoms.h" #include "nsHTMLParts.h" @@ -18,92 +16,48 @@ #include "nsError.h" #include "nsContentUtils.h" -using namespace mozilla; -using namespace mozilla::dom; +NS_IMPL_NS_NEW_HTML_ELEMENT(TableSection) +DOMCI_NODE_DATA(HTMLTableSectionElement, mozilla::dom::HTMLTableSectionElement) + +namespace mozilla { +namespace dom { // you will see the phrases "rowgroup" and "section" used interchangably -class nsHTMLTableSectionElement : public nsGenericHTMLElement, - public nsIDOMHTMLTableSectionElement -{ -public: - nsHTMLTableSectionElement(already_AddRefed aNodeInfo); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC - - // nsIDOMHTMLTableSectionElement - NS_DECL_NSIDOMHTMLTABLESECTIONELEMENT - - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLTableSectionElement, - nsGenericHTMLElement) - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -protected: - nsRefPtr mRows; -}; - - -NS_IMPL_NS_NEW_HTML_ELEMENT(TableSection) - - -nsHTMLTableSectionElement::nsHTMLTableSectionElement(already_AddRefed aNodeInfo) +HTMLTableSectionElement::HTMLTableSectionElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { } -NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLTableSectionElement) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLTableSectionElement, +NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableSectionElement) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLTableSectionElement, nsGenericHTMLElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRows) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_ADDREF_INHERITED(nsHTMLTableSectionElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLTableSectionElement, Element) +NS_IMPL_ADDREF_INHERITED(HTMLTableSectionElement, Element) +NS_IMPL_RELEASE_INHERITED(HTMLTableSectionElement, Element) - -DOMCI_NODE_DATA(HTMLTableSectionElement, nsHTMLTableSectionElement) - -// QueryInterface implementation for nsHTMLTableSectionElement -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTableSectionElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableSectionElement, +// QueryInterface implementation for HTMLTableSectionElement +NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLTableSectionElement) + NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableSectionElement, nsIDOMHTMLTableSectionElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableSectionElement, + NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableSectionElement, nsGenericHTMLElement) NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableSectionElement) -NS_IMPL_ELEMENT_CLONE(nsHTMLTableSectionElement) +NS_IMPL_ELEMENT_CLONE(HTMLTableSectionElement) -NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, Align, align) -NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, VAlign, valign) -NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, Ch, _char) -NS_IMPL_STRING_ATTR(nsHTMLTableSectionElement, ChOff, charoff) +NS_IMPL_STRING_ATTR(HTMLTableSectionElement, Align, align) +NS_IMPL_STRING_ATTR(HTMLTableSectionElement, VAlign, valign) +NS_IMPL_STRING_ATTR(HTMLTableSectionElement, Ch, _char) +NS_IMPL_STRING_ATTR(HTMLTableSectionElement, ChOff, charoff) NS_IMETHODIMP -nsHTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) +HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) { if (!mRows) { mRows = new nsContentList(this, @@ -119,8 +73,8 @@ nsHTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) NS_IMETHODIMP -nsHTMLTableSectionElement::InsertRow(int32_t aIndex, - nsIDOMHTMLElement** aValue) +HTMLTableSectionElement::InsertRow(int32_t aIndex, + nsIDOMHTMLElement** aValue) { *aValue = nullptr; @@ -175,7 +129,7 @@ nsHTMLTableSectionElement::InsertRow(int32_t aIndex, } NS_IMETHODIMP -nsHTMLTableSectionElement::DeleteRow(int32_t aValue) +HTMLTableSectionElement::DeleteRow(int32_t aValue) { if (aValue < -1) { return NS_ERROR_DOM_INDEX_SIZE_ERR; @@ -213,10 +167,10 @@ nsHTMLTableSectionElement::DeleteRow(int32_t aValue) } bool -nsHTMLTableSectionElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) +HTMLTableSectionElement::ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult) { if (aNamespaceID == kNameSpaceID_None) { /* ignore these attributes, stored simply as strings @@ -282,7 +236,7 @@ void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aD } NS_IMETHODIMP_(bool) -nsHTMLTableSectionElement::IsAttributeMapped(const nsIAtom* aAttribute) const +HTMLTableSectionElement::IsAttributeMapped(const nsIAtom* aAttribute) const { static const MappedAttributeEntry attributes[] = { { &nsGkAtoms::align }, @@ -302,7 +256,10 @@ nsHTMLTableSectionElement::IsAttributeMapped(const nsIAtom* aAttribute) const nsMapRuleToAttributesFunc -nsHTMLTableSectionElement::GetAttributeMappingFunction() const +HTMLTableSectionElement::GetAttributeMappingFunction() const { return &MapAttributesIntoRule; } + +} // namespace dom +} // namespace mozilla diff --git a/content/html/content/src/HTMLTableSectionElement.h b/content/html/content/src/HTMLTableSectionElement.h new file mode 100644 index 000000000000..3f95a7a8068f --- /dev/null +++ b/content/html/content/src/HTMLTableSectionElement.h @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozilla_dom_HTMLTableSectionElement_h +#define mozilla_dom_HTMLTableSectionElement_h + +#include "nsGenericHTMLElement.h" +#include "nsIDOMHTMLTableSectionElem.h" + +namespace mozilla { +namespace dom { + +class HTMLTableSectionElement : public nsGenericHTMLElement, + public nsIDOMHTMLTableSectionElement +{ +public: + HTMLTableSectionElement(already_AddRefed aNodeInfo); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMElement + NS_FORWARD_NSIDOMELEMENT_TO_GENERIC + + // nsIDOMHTMLElement + NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC + + // nsIDOMHTMLTableSectionElement + NS_DECL_NSIDOMHTMLTABLESECTIONELEMENT + + virtual bool ParseAttribute(int32_t aNamespaceID, + nsIAtom* aAttribute, + const nsAString& aValue, + nsAttrValue& aResult); + virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; + NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; + + virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLTableSectionElement, + nsGenericHTMLElement) + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +protected: + nsRefPtr mRows; +}; + +} // namespace dom +} // namespace mozilla + +#endif /* mozilla_dom_HTMLTableSectionElement_h */ diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 8e2e4be4867d..7e847b7cda91 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -45,6 +45,12 @@ EXPORTS_mozilla/dom = \ HTMLScriptElement.h \ HTMLSharedListElement.h \ HTMLSpanElement.h \ + HTMLTableCaptionElement.h \ + HTMLTableCellElement.h \ + HTMLTableColElement.h \ + HTMLTableElement.h \ + HTMLTableRowElement.h \ + HTMLTableSectionElement.h \ HTMLTitleElement.h \ HTMLUnknownElement.h \ UndoManager.h \ @@ -101,12 +107,12 @@ CPPSRCS = \ HTMLSpanElement.cpp \ HTMLSharedListElement.cpp \ nsHTMLStyleElement.cpp \ - nsHTMLTableElement.cpp \ - nsHTMLTableCaptionElement.cpp \ - nsHTMLTableCellElement.cpp \ - nsHTMLTableColElement.cpp \ - nsHTMLTableRowElement.cpp \ - nsHTMLTableSectionElement.cpp \ + HTMLTableElement.cpp \ + HTMLTableCaptionElement.cpp \ + HTMLTableCellElement.cpp \ + HTMLTableColElement.cpp \ + HTMLTableRowElement.cpp \ + HTMLTableSectionElement.cpp \ nsHTMLTextAreaElement.cpp \ HTMLTitleElement.cpp \ HTMLUnknownElement.cpp \ diff --git a/content/html/content/src/nsHTMLTableCaptionElement.cpp b/content/html/content/src/nsHTMLTableCaptionElement.cpp deleted file mode 100644 index eb2e40cd26bf..000000000000 --- a/content/html/content/src/nsHTMLTableCaptionElement.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Util.h" - -#include "nsIDOMHTMLTableCaptionElem.h" -#include "nsIDOMEventTarget.h" -#include "nsGenericHTMLElement.h" -#include "nsAttrValueInlines.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" -#include "nsMappedAttributes.h" -#include "nsRuleData.h" - -using namespace mozilla; -using namespace mozilla::dom; - -class nsHTMLTableCaptionElement : public nsGenericHTMLElement, - public nsIDOMHTMLTableCaptionElement -{ -public: - nsHTMLTableCaptionElement(already_AddRefed aNodeInfo); - virtual ~nsHTMLTableCaptionElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT_TO_GENERIC - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC - - // nsIDOMHTMLTableCaptionElement - NS_DECL_NSIDOMHTMLTABLECAPTIONELEMENT - - virtual bool ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -}; - - -NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption) - - -nsHTMLTableCaptionElement::nsHTMLTableCaptionElement(already_AddRefed aNodeInfo) - : nsGenericHTMLElement(aNodeInfo) -{ -} - -nsHTMLTableCaptionElement::~nsHTMLTableCaptionElement() -{ -} - - -NS_IMPL_ADDREF_INHERITED(nsHTMLTableCaptionElement, Element) -NS_IMPL_RELEASE_INHERITED(nsHTMLTableCaptionElement, Element) - - -DOMCI_NODE_DATA(HTMLTableCaptionElement, nsHTMLTableCaptionElement) - -// QueryInterface implementation for nsHTMLTableCaptionElement -NS_INTERFACE_TABLE_HEAD(nsHTMLTableCaptionElement) - NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableCaptionElement, - nsIDOMHTMLTableCaptionElement) - NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableCaptionElement, - nsGenericHTMLElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableCaptionElement) - - -NS_IMPL_ELEMENT_CLONE(nsHTMLTableCaptionElement) - - -NS_IMPL_STRING_ATTR(nsHTMLTableCaptionElement, Align, align) - - -static const nsAttrValue::EnumTable kCaptionAlignTable[] = { - { "left", NS_STYLE_CAPTION_SIDE_LEFT }, - { "right", NS_STYLE_CAPTION_SIDE_RIGHT }, - { "top", NS_STYLE_CAPTION_SIDE_TOP }, - { "bottom", NS_STYLE_CAPTION_SIDE_BOTTOM }, - { 0 } -}; - -bool -nsHTMLTableCaptionElement::ParseAttribute(int32_t aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult) -{ - if (aAttribute == nsGkAtoms::align && aNamespaceID == kNameSpaceID_None) { - return aResult.ParseEnumValue(aValue, kCaptionAlignTable, false); - } - - return nsGenericHTMLElement::ParseAttribute(aNamespaceID, aAttribute, aValue, - aResult); -} - -static -void MapAttributesIntoRule(const nsMappedAttributes* aAttributes, nsRuleData* aData) -{ - if (aData->mSIDs & NS_STYLE_INHERIT_BIT(TableBorder)) { - nsCSSValue* captionSide = aData->ValueForCaptionSide(); - if (captionSide->GetUnit() == eCSSUnit_Null) { - const nsAttrValue* value = aAttributes->GetAttr(nsGkAtoms::align); - if (value && value->Type() == nsAttrValue::eEnum) - captionSide->SetIntValue(value->GetEnumValue(), eCSSUnit_Enumerated); - } - } - - nsGenericHTMLElement::MapCommonAttributesInto(aAttributes, aData); -} - -NS_IMETHODIMP_(bool) -nsHTMLTableCaptionElement::IsAttributeMapped(const nsIAtom* aAttribute) const -{ - static const MappedAttributeEntry attributes[] = { - { &nsGkAtoms::align }, - { nullptr } - }; - - static const MappedAttributeEntry* const map[] = { - attributes, - sCommonAttributeMap, - }; - - return FindAttributeDependence(aAttribute, map); -} - - - -nsMapRuleToAttributesFunc -nsHTMLTableCaptionElement::GetAttributeMappingFunction() const -{ - return &MapAttributesIntoRule; -} From b1c2b889daed60e911e22acc5a8d229017b805de Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 29 Dec 2012 09:08:15 +0100 Subject: [PATCH 150/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableElement to WebIDL. r=bz. --HG-- rename : content/html/content/src/nsHTMLTableElement.cpp => content/html/content/src/HTMLTableElement.cpp rename : content/html/content/src/nsHTMLTableElement.h => content/html/content/src/HTMLTableElement.h extra : rebase_source : 36ef4c094fdf54103ad3c41e299eb86d20956915 --- content/html/content/src/HTMLTableElement.cpp | 660 +++++++++--------- content/html/content/src/HTMLTableElement.h | 161 ++++- content/html/content/test/reflect.js | 1 - dom/bindings/Bindings.conf | 11 + dom/webidl/HTMLTableElement.webidl | 59 ++ dom/webidl/WebIDL.mk | 1 + js/xpconnect/src/dom_quickstubs.qsconf | 4 - 7 files changed, 565 insertions(+), 332 deletions(-) create mode 100644 dom/webidl/HTMLTableElement.webidl diff --git a/content/html/content/src/HTMLTableElement.cpp b/content/html/content/src/HTMLTableElement.cpp index 3070aa84c7d9..b5cc400eb331 100644 --- a/content/html/content/src/HTMLTableElement.cpp +++ b/content/html/content/src/HTMLTableElement.cpp @@ -6,27 +6,13 @@ #include "mozilla/Util.h" #include "mozilla/dom/HTMLTableElement.h" -#include "nsIDOMHTMLTableCaptionElem.h" #include "nsIDOMHTMLTableSectionElem.h" -#include "nsCOMPtr.h" -#include "nsIDOMEventTarget.h" -#include "nsError.h" -#include "nsContentList.h" -#include "nsGenericHTMLElement.h" #include "nsAttrValueInlines.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" -#include "nsPresContext.h" -#include "nsHTMLParts.h" #include "nsRuleData.h" -#include "nsStyleContext.h" -#include "nsIDocument.h" -#include "nsContentUtils.h" -#include "nsIDOMElement.h" -#include "nsIHTMLCollection.h" #include "nsHTMLStyleSheet.h" -#include "mozilla/dom/HTMLCollectionBinding.h" #include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/HTMLCollectionBinding.h" +#include "mozilla/dom/HTMLTableElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(Table) DOMCI_NODE_DATA(HTMLTableElement, mozilla::dom::HTMLTableElement) @@ -130,8 +116,7 @@ NS_INTERFACE_MAP_END do { \ if (mParent) { \ /* THead */ \ - nsCOMPtr rowGroup; \ - rowGroup = mParent->GetTHead(); \ + HTMLTableSectionElement* rowGroup = mParent->GetTHead(); \ nsCOMPtr rows; \ if (rowGroup) { \ rowGroup->GetRows(getter_AddRefs(rows)); \ @@ -140,19 +125,15 @@ NS_INTERFACE_MAP_END } while (0); \ } \ /* TBodies */ \ - nsContentList *_tbodies = mParent->TBodies(); \ - nsINode * _node; \ - uint32_t _tbodyIndex = 0; \ - _node = _tbodies->Item(_tbodyIndex); \ - while (_node) { \ - rowGroup = do_QueryInterface(_node); \ - if (rowGroup) { \ + for (nsIContent* _node = mParent->nsINode::GetFirstChild(); \ + _node; _node = _node->GetNextSibling()) { \ + if (_node->IsHTML(nsGkAtoms::tbody)) { \ + rowGroup = static_cast(_node); \ rowGroup->GetRows(getter_AddRefs(rows)); \ do { /* gives scoping */ \ _code \ } while (0); \ } \ - _node = _tbodies->Item(++_tbodyIndex); \ } \ /* orphan rows */ \ rows = mOrphanRows; \ @@ -329,6 +310,7 @@ HTMLTableElement::HTMLTableElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mTableInheritedAttributes(TABLE_ATTRS_DIRTY) { + SetIsDOMBinding(); } HTMLTableElement::~HTMLTableElement() @@ -339,6 +321,11 @@ HTMLTableElement::~HTMLTableElement() ReleaseInheritedAttributes(); } +JSObject* +HTMLTableElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap) +{ + return HTMLTableElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableElement) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLTableElement, nsGenericHTMLElement) @@ -357,7 +344,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_ADDREF_INHERITED(HTMLTableElement, Element) NS_IMPL_RELEASE_INHERITED(HTMLTableElement, Element) - // QueryInterface implementation for HTMLTableElement NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(HTMLTableElement) NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableElement, nsIDOMHTMLTableElement) @@ -373,27 +359,157 @@ NS_IMPL_ELEMENT_CLONE(HTMLTableElement) // in fact, they are integers or they are meaningless. so we store them // here as ints. -NS_IMPL_STRING_ATTR(HTMLTableElement, Align, align) -NS_IMPL_STRING_ATTR(HTMLTableElement, BgColor, bgcolor) -NS_IMPL_STRING_ATTR(HTMLTableElement, Border, border) -NS_IMPL_STRING_ATTR(HTMLTableElement, CellPadding, cellpadding) -NS_IMPL_STRING_ATTR(HTMLTableElement, CellSpacing, cellspacing) -NS_IMPL_STRING_ATTR(HTMLTableElement, Frame, frame) -NS_IMPL_STRING_ATTR(HTMLTableElement, Rules, rules) -NS_IMPL_STRING_ATTR(HTMLTableElement, Summary, summary) -NS_IMPL_STRING_ATTR(HTMLTableElement, Width, width) - - -already_AddRefed -HTMLTableElement::GetCaption() +NS_IMETHODIMP +HTMLTableElement::SetAlign(const nsAString& aAlign) { - for (nsIContent* cur = nsINode::GetFirstChild(); cur; cur = cur->GetNextSibling()) { - nsCOMPtr caption = do_QueryInterface(cur); - if (caption) { - return caption.forget(); - } - } - return nullptr; + ErrorResult rv; + SetAlign(aAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetAlign(nsAString& aAlign) +{ + nsString align; + GetAlign(align); + aAlign = align; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetBgColor(const nsAString& aBgColor) +{ + ErrorResult rv; + SetBgColor(aBgColor, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetBgColor(nsAString& aBgColor) +{ + nsString bgColor; + GetBgColor(bgColor); + aBgColor = bgColor; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetBorder(const nsAString& aBorder) +{ + ErrorResult rv; + SetBorder(aBorder, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetBorder(nsAString& aBorder) +{ + nsString border; + GetBorder(border); + aBorder = border; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetCellPadding(const nsAString& aCellPadding) +{ + ErrorResult rv; + SetCellPadding(aCellPadding, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetCellPadding(nsAString& aCellPadding) +{ + nsString cellPadding; + GetCellPadding(cellPadding); + aCellPadding = cellPadding; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetCellSpacing(const nsAString& aCellSpacing) +{ + ErrorResult rv; + SetCellSpacing(aCellSpacing, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetCellSpacing(nsAString& aCellSpacing) +{ + nsString cellSpacing; + GetCellSpacing(cellSpacing); + aCellSpacing = cellSpacing; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetFrame(const nsAString& aFrame) +{ + ErrorResult rv; + SetFrame(aFrame, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetFrame(nsAString& aFrame) +{ + nsString frame; + GetFrame(frame); + aFrame = frame; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetRules(const nsAString& aRules) +{ + ErrorResult rv; + SetRules(aRules, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetRules(nsAString& aRules) +{ + nsString rules; + GetRules(rules); + aRules = rules; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetSummary(const nsAString& aSummary) +{ + ErrorResult rv; + SetSummary(aSummary, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetSummary(nsAString& aSummary) +{ + nsString summary; + GetSummary(summary); + aSummary = summary; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableElement::SetWidth(const nsAString& aWidth) +{ + ErrorResult rv; + SetWidth(aWidth, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableElement::GetWidth(nsAString& aWidth) +{ + nsString width; + GetWidth(width); + aWidth = width; + return NS_OK; } NS_IMETHODIMP @@ -407,36 +523,16 @@ HTMLTableElement::GetCaption(nsIDOMHTMLTableCaptionElement** aValue) NS_IMETHODIMP HTMLTableElement::SetCaption(nsIDOMHTMLTableCaptionElement* aValue) { - nsresult rv = DeleteCaption(); - - if (NS_SUCCEEDED(rv)) { - if (aValue) { - nsCOMPtr resultingChild; - AppendChild(aValue, getter_AddRefs(resultingChild)); - } - } - - return rv; -} - -already_AddRefed -HTMLTableElement::GetSection(nsIAtom *aTag) -{ - for (nsIContent* child = nsINode::GetFirstChild(); - child; - child = child->GetNextSibling()) { - nsCOMPtr section = do_QueryInterface(child); - if (section && child->NodeInfo()->Equals(aTag)) { - return section.forget(); - } - } - return nullptr; + HTMLTableCaptionElement* caption = + static_cast(aValue); + SetCaption(caption); + return NS_OK; } NS_IMETHODIMP HTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) { - *aValue = GetTHead().get(); + NS_IF_ADDREF(*aValue = GetTHead()); return NS_OK; } @@ -444,36 +540,15 @@ HTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) NS_IMETHODIMP HTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) { - nsCOMPtr content(do_QueryInterface(aValue)); - NS_ENSURE_TRUE(content, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); - - if (!content->NodeInfo()->Equals(nsGkAtoms::thead)) { - return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; - } - - nsresult rv = DeleteTHead(); - if (NS_FAILED(rv)) { - return rv; - } - - if (aValue) { - nsCOMPtr child; - rv = GetFirstChild(getter_AddRefs(child)); - if (NS_FAILED(rv)) { - return rv; - } - - nsCOMPtr resultChild; - rv = InsertBefore(aValue, child, getter_AddRefs(resultChild)); - } - - return rv; + ErrorResult rv; + SetTHead(aValue, rv); + return rv.ErrorCode(); } NS_IMETHODIMP HTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) { - *aValue = GetTFoot().get(); + NS_IF_ADDREF(*aValue = GetTFoot()); return NS_OK; } @@ -481,35 +556,26 @@ HTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) NS_IMETHODIMP HTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) { - nsCOMPtr content(do_QueryInterface(aValue)); - NS_ENSURE_TRUE(content, NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); - - if (!content->NodeInfo()->Equals(nsGkAtoms::tfoot)) { - return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; - } - - nsresult rv = DeleteTFoot(); - if (NS_SUCCEEDED(rv)) { - if (aValue) { - nsCOMPtr resultingChild; - AppendChild(aValue, getter_AddRefs(resultingChild)); - } - } - - return rv; + ErrorResult rv; + SetTFoot(aValue, rv); + return rv.ErrorCode(); } NS_IMETHODIMP HTMLTableElement::GetRows(nsIDOMHTMLCollection** aValue) +{ + NS_ADDREF(*aValue = Rows()); + return NS_OK; +} + +nsIHTMLCollection* +HTMLTableElement::Rows() { if (!mRows) { mRows = new TableRowsCollection(this); } - *aValue = mRows; - NS_ADDREF(*aValue); - - return NS_OK; + return mRows; } NS_IMETHODIMP @@ -519,7 +585,7 @@ HTMLTableElement::GetTBodies(nsIDOMHTMLCollection** aValue) return NS_OK; } -nsContentList* +nsIHTMLCollection* HTMLTableElement::TBodies() { if (!mTBodies) { @@ -534,143 +600,129 @@ HTMLTableElement::TBodies() return mTBodies; } +already_AddRefed +HTMLTableElement::CreateTHead() +{ + nsRefPtr head = GetTHead(); + if (!head) { + // Create a new head rowgroup. + nsCOMPtr nodeInfo; + nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::thead, + getter_AddRefs(nodeInfo)); + + head = NS_NewHTMLTableSectionElement(nodeInfo.forget()); + if (!head) { + return nullptr; + } + + ErrorResult rv; + nsINode::InsertBefore(*head, nsINode::GetFirstChild(), rv); + } + return head.forget(); +} + NS_IMETHODIMP HTMLTableElement::CreateTHead(nsIDOMHTMLElement** aValue) { - *aValue = nullptr; - - nsRefPtr head = GetTHead(); - if (head) { - // return the existing thead - head.forget(aValue); - return NS_OK; - } - - nsCOMPtr nodeInfo; - nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::thead, - getter_AddRefs(nodeInfo)); - - nsCOMPtr newHead = - NS_NewHTMLTableSectionElement(nodeInfo.forget()); - - if (!newHead) { - return NS_OK; - } - - nsCOMPtr child; - nsresult rv = GetFirstChild(getter_AddRefs(child)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr newHeadAsDOMElement = do_QueryInterface(newHead); - - nsCOMPtr resultChild; - InsertBefore(newHeadAsDOMElement, child, getter_AddRefs(resultChild)); - newHeadAsDOMElement.forget(aValue); - return NS_OK; + nsRefPtr thead = CreateTHead(); + return thead ? CallQueryInterface(thead, aValue) : NS_OK; } NS_IMETHODIMP HTMLTableElement::DeleteTHead() { - nsCOMPtr childToDelete; - nsresult rv = GetTHead(getter_AddRefs(childToDelete)); - - if ((NS_SUCCEEDED(rv)) && childToDelete) { - nsCOMPtr resultingChild; - // mInner does the notification - RemoveChild(childToDelete, getter_AddRefs(resultingChild)); + HTMLTableSectionElement* tHead = GetTHead(); + if (tHead) { + mozilla::ErrorResult rv; + nsINode::RemoveChild(*tHead, rv); + MOZ_ASSERT(!rv.Failed()); } return NS_OK; } +already_AddRefed +HTMLTableElement::CreateTFoot() +{ + nsRefPtr foot = GetTFoot(); + if (!foot) { + // create a new foot rowgroup + nsCOMPtr nodeInfo; + nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tfoot, + getter_AddRefs(nodeInfo)); + + foot = NS_NewHTMLTableSectionElement(nodeInfo.forget()); + if (!foot) { + return nullptr; + } + AppendChildTo(foot, true); + } + + return foot.forget(); +} + NS_IMETHODIMP HTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) { - *aValue = nullptr; - - nsRefPtr foot = GetTFoot(); - if (foot) { - // return the existing tfoot - foot.forget(aValue); - return NS_OK; - } - // create a new foot rowgroup - nsCOMPtr nodeInfo; - nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tfoot, - getter_AddRefs(nodeInfo)); - - nsCOMPtr newFoot = NS_NewHTMLTableSectionElement(nodeInfo.forget()); - - if (!newFoot) { - return NS_OK; - } - AppendChildTo(newFoot, true); - nsCOMPtr newFootAsDOMElement = do_QueryInterface(newFoot); - newFootAsDOMElement.forget(aValue); - return NS_OK; + nsRefPtr tfoot = CreateTFoot(); + return tfoot ? CallQueryInterface(tfoot, aValue) : NS_OK; } NS_IMETHODIMP HTMLTableElement::DeleteTFoot() { - nsCOMPtr childToDelete; - nsresult rv = GetTFoot(getter_AddRefs(childToDelete)); - - if ((NS_SUCCEEDED(rv)) && childToDelete) { - nsCOMPtr resultingChild; - // mInner does the notification - RemoveChild(childToDelete, getter_AddRefs(resultingChild)); + HTMLTableSectionElement* tFoot = GetTFoot(); + if (tFoot) { + mozilla::ErrorResult rv; + nsINode::RemoveChild(*tFoot, rv); + MOZ_ASSERT(!rv.Failed()); } return NS_OK; } +already_AddRefed +HTMLTableElement::CreateCaption() +{ + nsRefPtr caption = GetCaption(); + if (!caption) { + // Create a new caption. + nsCOMPtr nodeInfo; + nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::caption, + getter_AddRefs(nodeInfo)); + + caption = NS_NewHTMLTableCaptionElement(nodeInfo.forget()); + if (!caption) { + return nullptr; + } + + AppendChildTo(caption, true); + } + return caption.forget(); +} + NS_IMETHODIMP HTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) { - *aValue = nullptr; - - if (nsRefPtr caption = GetCaption()) { - // return the existing caption - caption.forget(aValue); - return NS_OK; - } - - // create a new head rowgroup - nsCOMPtr nodeInfo; - nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::caption, - getter_AddRefs(nodeInfo)); - - nsCOMPtr newCaption = NS_NewHTMLTableCaptionElement(nodeInfo.forget()); - - if (!newCaption) { - return NS_OK; - } - - AppendChildTo(newCaption, true); - nsCOMPtr captionAsDOMElement = - do_QueryInterface(newCaption); - captionAsDOMElement.forget(aValue); - return NS_OK; + nsRefPtr caption = CreateCaption(); + return caption ? CallQueryInterface(caption, aValue) : NS_OK; } NS_IMETHODIMP HTMLTableElement::DeleteCaption() { - nsCOMPtr childToDelete; - nsresult rv = GetCaption(getter_AddRefs(childToDelete)); - - if ((NS_SUCCEEDED(rv)) && childToDelete) { - nsCOMPtr resultingChild; - RemoveChild(childToDelete, getter_AddRefs(resultingChild)); + HTMLTableCaptionElement* caption = GetCaption(); + if (caption) { + mozilla::ErrorResult rv; + nsINode::RemoveChild(*caption, rv); + MOZ_ASSERT(!rv.Failed()); } return NS_OK; } -NS_IMETHODIMP -HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) +already_AddRefed +HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError) { /* get the ref row at aIndex if there is one, @@ -680,26 +732,22 @@ HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) get the first row group insert the new row as its first child */ - *aValue = nullptr; - if (aIndex < -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; } - nsCOMPtr rows; - GetRows(getter_AddRefs(rows)); - - uint32_t rowCount; - rows->GetLength(&rowCount); - + nsIHTMLCollection* rows = Rows(); + uint32_t rowCount = rows->Length(); if ((uint32_t)aIndex > rowCount && aIndex != -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; } // use local variable refIndex so we can remember original aIndex uint32_t refIndex = (uint32_t)aIndex; - nsresult rv; + nsRefPtr newRow; if (rowCount > 0) { if (refIndex == rowCount || aIndex == -1) { // we set refIndex to the last row so we can get the last row's @@ -708,46 +756,34 @@ HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) refIndex = rowCount - 1; } - nsCOMPtr refRow; - rows->Item(refIndex, getter_AddRefs(refRow)); + Element* refRow = rows->Item(refIndex); + nsINode* parent = refRow->GetParentNode(); - nsCOMPtr parent; - - refRow->GetParentNode(getter_AddRefs(parent)); // create the row nsCOMPtr nodeInfo; nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tr, getter_AddRefs(nodeInfo)); - nsCOMPtr newRow = NS_NewHTMLTableRowElement(nodeInfo.forget()); + newRow = NS_NewHTMLTableRowElement(nodeInfo.forget()); if (newRow) { - nsCOMPtr newRowNode(do_QueryInterface(newRow)); - nsCOMPtr retChild; - - // If index is -1 or equal to the number of rows, the new row + // If aIndex is -1 or equal to the number of rows, the new row // is appended. if (aIndex == -1 || uint32_t(aIndex) == rowCount) { - rv = parent->AppendChild(newRowNode, getter_AddRefs(retChild)); - NS_ENSURE_SUCCESS(rv, rv); - } - else - { + parent->AppendChild(*newRow, aError); + } else { // insert the new row before the reference row we found above - rv = parent->InsertBefore(newRowNode, refRow, - getter_AddRefs(retChild)); - NS_ENSURE_SUCCESS(rv, rv); + parent->InsertBefore(*newRow, refRow, aError); } - if (retChild) { - CallQueryInterface(retChild, aValue); + if (aError.Failed()) { + return nullptr; } } } else { // the row count was 0, so // find the first row group and insert there as first child - nsCOMPtr rowGroup; - + nsCOMPtr rowGroup; for (nsIContent* child = nsINode::GetFirstChild(); child; child = child->GetNextSibling()) { @@ -757,8 +793,7 @@ HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) (localName == nsGkAtoms::thead || localName == nsGkAtoms::tbody || localName == nsGkAtoms::tfoot)) { - rowGroup = do_QueryInterface(child); - NS_ASSERTION(rowGroup, "HTML node did not QI to nsIDOMNode"); + rowGroup = child; break; } } @@ -768,14 +803,12 @@ HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tbody, getter_AddRefs(nodeInfo)); - nsCOMPtr newRowGroup = - NS_NewHTMLTableSectionElement(nodeInfo.forget()); - - if (newRowGroup) { - rv = AppendChildTo(newRowGroup, true); - NS_ENSURE_SUCCESS(rv, rv); - - rowGroup = do_QueryInterface(newRowGroup); + rowGroup = NS_NewHTMLTableSectionElement(nodeInfo.forget()); + if (rowGroup) { + aError = AppendChildTo(rowGroup, true); + if (aError.Failed()) { + return nullptr; + } } } @@ -784,75 +817,66 @@ HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tr, getter_AddRefs(nodeInfo)); - nsCOMPtr newRow = NS_NewHTMLTableRowElement(nodeInfo.forget()); + newRow = NS_NewHTMLTableRowElement(nodeInfo.forget()); if (newRow) { - nsCOMPtr firstRow; - - nsCOMPtr section = - do_QueryInterface(rowGroup); - - if (section) { - nsCOMPtr rows; - section->GetRows(getter_AddRefs(rows)); - if (rows) { - rows->Item(0, getter_AddRefs(firstRow)); - } - } - - nsCOMPtr retNode, newRowNode(do_QueryInterface(newRow)); - - rowGroup->InsertBefore(newRowNode, firstRow, getter_AddRefs(retNode)); - - if (retNode) { - CallQueryInterface(retNode, aValue); - } + HTMLTableSectionElement* section = + static_cast(rowGroup.get()); + nsCOMPtr rows; + section->GetRows(getter_AddRefs(rows)); + rowGroup->InsertBefore(*newRow, + static_cast(rows.get())->Item(0), + aError); } } } - return NS_OK; + return newRow.forget(); +} + +NS_IMETHODIMP +HTMLTableElement::InsertRow(int32_t aIndex, nsIDOMHTMLElement** aValue) +{ + ErrorResult rv; + nsRefPtr newRow = InsertRow(aIndex, rv); + return rv.Failed() ? rv.ErrorCode() : CallQueryInterface(newRow, aValue); +} + +void +HTMLTableElement::DeleteRow(int32_t aIndex, ErrorResult& aError) +{ + if (aIndex < -1) { + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; + } + + nsIHTMLCollection* rows = Rows(); + uint32_t refIndex; + if (aIndex == -1) { + refIndex = rows->Length(); + if (refIndex == 0) { + return; + } + + --refIndex; + } else { + refIndex = (uint32_t)aIndex; + } + + nsCOMPtr row = rows->Item(refIndex); + if (!row) { + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; + } + + row->RemoveFromParent(); } NS_IMETHODIMP HTMLTableElement::DeleteRow(int32_t aValue) { - if (aValue < -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; - } - - nsCOMPtr rows; - GetRows(getter_AddRefs(rows)); - - nsresult rv; - uint32_t refIndex; - if (aValue == -1) { - rv = rows->GetLength(&refIndex); - NS_ENSURE_SUCCESS(rv, rv); - - if (refIndex == 0) { - return NS_OK; - } - - --refIndex; - } - else { - refIndex = (uint32_t)aValue; - } - - nsCOMPtr row; - rv = rows->Item(refIndex, getter_AddRefs(row)); - NS_ENSURE_SUCCESS(rv, rv); - - if (!row) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; - } - - nsCOMPtr parent; - row->GetParentNode(getter_AddRefs(parent)); - NS_ENSURE_TRUE(parent, NS_ERROR_UNEXPECTED); - - nsCOMPtr deleted_row; - return parent->RemoveChild(row, getter_AddRefs(deleted_row)); + ErrorResult rv; + DeleteRow(aValue, rv); + return rv.ErrorCode(); } static const nsAttrValue::EnumTable kFrameTable[] = { diff --git a/content/html/content/src/HTMLTableElement.h b/content/html/content/src/HTMLTableElement.h index 8e07046c2f28..5382e9b454c7 100644 --- a/content/html/content/src/HTMLTableElement.h +++ b/content/html/content/src/HTMLTableElement.h @@ -7,6 +7,8 @@ #include "nsGenericHTMLElement.h" #include "nsIDOMHTMLTableElement.h" +#include "mozilla/dom/HTMLTableCaptionElement.h" +#include "mozilla/dom/HTMLTableSectionElement.h" #include "nsMappedAttributes.h" namespace mozilla { @@ -38,6 +40,142 @@ public: // nsIDOMHTMLTableElement NS_DECL_NSIDOMHTMLTABLEELEMENT + HTMLTableCaptionElement* GetCaption() const + { + return static_cast(GetChild(nsGkAtoms::caption)); + } + void SetCaption(HTMLTableCaptionElement* aCaption) + { + DeleteCaption(); + if (aCaption) { + mozilla::ErrorResult rv; + nsINode::AppendChild(*aCaption, rv); + } + } + already_AddRefed CreateCaption(); + + HTMLTableSectionElement* GetTHead() const + { + return static_cast(GetChild(nsGkAtoms::thead)); + } + void SetTHead(nsIDOMHTMLTableSectionElement* aTHead, ErrorResult& aError) + { + nsCOMPtr content = do_QueryInterface(aTHead); + if (!content || !content->IsHTML(nsGkAtoms::thead)) { + aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); + return; + } + HTMLTableSectionElement* thead = + static_cast(aTHead); + + DeleteTHead(); + if (thead) { + nsINode::InsertBefore(*thead, nsINode::GetFirstChild(), aError); + } + } + already_AddRefed CreateTHead(); + + HTMLTableSectionElement* GetTFoot() const + { + return static_cast(GetChild(nsGkAtoms::tfoot)); + } + void SetTFoot(nsIDOMHTMLTableSectionElement* aTFoot, ErrorResult& aError) + { + nsCOMPtr content = do_QueryInterface(aTFoot); + if (!content || !content->IsHTML(nsGkAtoms::tfoot)) { + aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); + return; + } + HTMLTableSectionElement* tfoot = + static_cast(aTFoot); + + DeleteTFoot(); + if (tfoot) { + nsINode::AppendChild(*tfoot, aError); + } + } + already_AddRefed CreateTFoot(); + + nsIHTMLCollection* TBodies(); + nsIHTMLCollection* Rows(); + + already_AddRefed InsertRow(int32_t aIndex, + ErrorResult& aError); + void DeleteRow(int32_t aIndex, ErrorResult& aError); + + void GetAlign(nsString& aAlign) + { + GetHTMLAttr(nsGkAtoms::align, aAlign); + } + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + void GetBorder(nsString& aBorder) + { + GetHTMLAttr(nsGkAtoms::border, aBorder); + } + void SetBorder(const nsAString& aBorder, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::border, aBorder, aError); + } + void GetFrame(nsString& aFrame) + { + GetHTMLAttr(nsGkAtoms::frame, aFrame); + } + void SetFrame(const nsAString& aFrame, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::frame, aFrame, aError); + } + void GetRules(nsString& aRules) + { + GetHTMLAttr(nsGkAtoms::rules, aRules); + } + void SetRules(const nsAString& aRules, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::rules, aRules, aError); + } + void GetSummary(nsString& aSummary) + { + GetHTMLAttr(nsGkAtoms::summary, aSummary); + } + void SetSummary(const nsAString& aSummary, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::summary, aSummary, aError); + } + void GetWidth(nsString& aWidth) + { + GetHTMLAttr(nsGkAtoms::width, aWidth); + } + void SetWidth(const nsAString& aWidth, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::width, aWidth, aError); + } + void GetBgColor(nsString& aBgColor) + { + GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor); + } + void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError); + } + void GetCellPadding(nsString& aCellPadding) + { + GetHTMLAttr(nsGkAtoms::cellpadding, aCellPadding); + } + void SetCellPadding(const nsAString& aCellPadding, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::cellpadding, aCellPadding, aError); + } + void GetCellSpacing(nsString& aCellSpacing) + { + GetHTMLAttr(nsGkAtoms::cellspacing, aCellSpacing); + } + void SetCellSpacing(const nsAString& aCellSpacing, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::cellspacing, aCellSpacing, aError); + } + virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -69,16 +207,21 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTableElement, nsGenericHTMLElement) nsMappedAttributes* GetAttributesMappedForCell(); - already_AddRefed GetTHead() { - return GetSection(nsGkAtoms::thead); - } - already_AddRefed GetTFoot() { - return GetSection(nsGkAtoms::tfoot); - } - already_AddRefed GetCaption(); - nsContentList* TBodies(); + protected: - already_AddRefed GetSection(nsIAtom *aTag); + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) MOZ_OVERRIDE; + + nsIContent* GetChild(nsIAtom *aTag) const + { + for (nsIContent* cur = nsINode::GetFirstChild(); cur; + cur = cur->GetNextSibling()) { + if (cur->IsHTML(aTag)) { + return cur; + } + } + return nullptr; + } nsRefPtr mTBodies; nsRefPtr mRows; diff --git a/content/html/content/test/reflect.js b/content/html/content/test/reflect.js index e141fb3a0bc3..2d3306d5915e 100644 --- a/content/html/content/test/reflect.js +++ b/content/html/content/test/reflect.js @@ -64,7 +64,6 @@ function reflectString(aParameters) input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ], link: [ "crossOrigin" ], source: [ "media" ], - table: [ "border", "width" ], tbody: [ "align", "vAlign", "ch" ], td: [ "align", "vAlign", "ch" ], textarea: [ "name", "placeholder" ], diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 7ad13231e92e..d293f60af1b1 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -422,6 +422,13 @@ DOMInterfaces = { 'hasInstanceInterface': 'nsIDOMHTMLScriptElement', }, +'HTMLTableElement': { + 'hasInstanceInterface': 'nsIDOMHTMLTableElement', + 'resultNotAddRefed': [ + 'caption', 'tHead', 'tFoot', 'tBodies', 'rows' + ] +}, + 'HTMLUListElement': { 'headerFile' : 'mozilla/dom/HTMLSharedListElement.h' }, @@ -1110,6 +1117,10 @@ addExternalIface('File') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('HTMLHeadElement', nativeType='mozilla::dom::Element') addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement') +addExternalIface('HTMLTableCaptionElement', + headerFile="nsIDOMHTMLTableCaptionElem.h") +addExternalIface('HTMLTableSectionElement', + headerFile="nsIDOMHTMLTableSectionElem.h") addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LockedFile') diff --git a/dom/webidl/HTMLTableElement.webidl b/dom/webidl/HTMLTableElement.webidl new file mode 100644 index 000000000000..85439d6ec9b9 --- /dev/null +++ b/dom/webidl/HTMLTableElement.webidl @@ -0,0 +1,59 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/ + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLTableCaptionElement; +interface HTMLTableSectionElement; + +interface HTMLTableElement : HTMLElement { + attribute HTMLTableCaptionElement? caption; + HTMLElement createCaption(); + void deleteCaption(); + [SetterThrows] + attribute HTMLTableSectionElement? tHead; + HTMLElement createTHead(); + void deleteTHead(); + [SetterThrows] + attribute HTMLTableSectionElement? tFoot; + HTMLElement createTFoot(); + void deleteTFoot(); + readonly attribute HTMLCollection tBodies; + //HTMLElement createTBody(); + readonly attribute HTMLCollection rows; + [Throws] + HTMLElement insertRow(optional long index = -1); + [Throws] + void deleteRow(long index); + // attribute boolean sortable; + //void stopSorting(); +/* +}; + +partial interface HTMLTableElement { +*/ + [SetterThrows] + attribute DOMString align; + [SetterThrows] + attribute DOMString border; + [SetterThrows] + attribute DOMString frame; + [SetterThrows] + attribute DOMString rules; + [SetterThrows] + attribute DOMString summary; + [SetterThrows] + attribute DOMString width; + + [TreatNullAs=EmptyString, SetterThrows] attribute DOMString bgColor; + [TreatNullAs=EmptyString, SetterThrows] attribute DOMString cellPadding; + [TreatNullAs=EmptyString, SetterThrows] attribute DOMString cellSpacing; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index e816cc91af52..7462364f4d60 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -73,6 +73,7 @@ webidl_files = \ HTMLPropertiesCollection.webidl \ HTMLScriptElement.webidl \ HTMLSpanElement.webidl \ + HTMLTableElement.webidl \ HTMLTitleElement.webidl \ HTMLUListElement.webidl \ ImageData.webidl \ diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 2996fa16e573..d8d7b31e6f4e 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -190,10 +190,6 @@ members = [ 'nsIDOMHTMLTableCellElement.width', 'nsIDOMHTMLTableColElement.span', 'nsIDOMHTMLTableColElement.width', - 'nsIDOMHTMLTableElement.rows', - 'nsIDOMHTMLTableElement.deleteRow', - 'nsIDOMHTMLTableElement.summary', - 'nsIDOMHTMLTableElement.insertRow', 'nsIDOMHTMLTableRowElement.sectionRowIndex', 'nsIDOMHTMLTableRowElement.rowIndex', 'nsIDOMHTMLTableRowElement.cells', From 2b53d84e31b1bff6b098074449fb28117433bff1 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 29 Dec 2012 15:07:46 +0100 Subject: [PATCH 151/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableCaptionElement to WebIDL. r=bz. --HG-- rename : content/html/content/src/nsHTMLTableCaptionElement.cpp => content/html/content/src/HTMLTableCaptionElement.cpp rename : content/html/content/src/nsHTMLTableCaptionElement.cpp => content/html/content/src/HTMLTableCaptionElement.h extra : rebase_source : ccf765d029b74fc22b45d9162e9b4a9ac6977344 --- .../browser_dbg_propertyview-filter-05.js | 4 ++-- .../content/src/HTMLTableCaptionElement.cpp | 10 ++++++++-- .../content/src/HTMLTableCaptionElement.h | 14 +++++++++++++ dom/bindings/Bindings.conf | 2 -- dom/webidl/HTMLTableCaptionElement.webidl | 20 +++++++++++++++++++ dom/webidl/HTMLTableElement.webidl | 1 - dom/webidl/WebIDL.mk | 1 + 7 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 dom/webidl/HTMLTableCaptionElement.webidl diff --git a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js b/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js index 49f6b0f0613a..b01717a20ca0 100644 --- a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js +++ b/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js @@ -45,8 +45,8 @@ function testVariablesFiltering() "There should be 0 variables displayed in the test scope"); is(loadScope.querySelectorAll(".variable:not([non-match])").length, 1, "There should be 1 variable displayed in the load scope"); - is(globalScope.querySelectorAll(".variable:not([non-match])").length, 3, - "There should be 3 variables displayed in the global scope"); + is(globalScope.querySelectorAll(".variable:not([non-match])").length, 4, + "There should be 4 variables displayed in the global scope"); is(innerScope.querySelectorAll(".property:not([non-match])").length, 0, "There should be 0 properties displayed in the inner scope"); diff --git a/content/html/content/src/HTMLTableCaptionElement.cpp b/content/html/content/src/HTMLTableCaptionElement.cpp index a7828dfba399..82b4037661cd 100644 --- a/content/html/content/src/HTMLTableCaptionElement.cpp +++ b/content/html/content/src/HTMLTableCaptionElement.cpp @@ -7,10 +7,9 @@ #include "mozilla/dom/HTMLTableCaptionElement.h" #include "nsAttrValueInlines.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" #include "nsMappedAttributes.h" #include "nsRuleData.h" +#include "mozilla/dom/HTMLTableCaptionElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(TableCaption) DOMCI_NODE_DATA(HTMLTableCaptionElement, mozilla::dom::HTMLTableCaptionElement) @@ -22,6 +21,13 @@ HTMLTableCaptionElement::~HTMLTableCaptionElement() { } +JSObject* +HTMLTableCaptionElement::WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) +{ + return HTMLTableCaptionElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + NS_IMPL_ADDREF_INHERITED(HTMLTableCaptionElement, Element) NS_IMPL_RELEASE_INHERITED(HTMLTableCaptionElement, Element) diff --git a/content/html/content/src/HTMLTableCaptionElement.h b/content/html/content/src/HTMLTableCaptionElement.h index a024023d59d7..675665775435 100644 --- a/content/html/content/src/HTMLTableCaptionElement.h +++ b/content/html/content/src/HTMLTableCaptionElement.h @@ -18,6 +18,7 @@ public: HTMLTableCaptionElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { + SetIsDOMBinding(); } virtual ~HTMLTableCaptionElement(); @@ -36,6 +37,15 @@ public: // nsIDOMHTMLTableCaptionElement NS_DECL_NSIDOMHTMLTABLECAPTIONELEMENT + void GetAlign(nsString& aAlign) + { + GetHTMLAttr(nsGkAtoms::align, aAlign); + } + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -48,6 +58,10 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + +protected: + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) MOZ_OVERRIDE; }; } // namespace dom diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index d293f60af1b1..6ebeaa595517 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1117,8 +1117,6 @@ addExternalIface('File') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('HTMLHeadElement', nativeType='mozilla::dom::Element') addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement') -addExternalIface('HTMLTableCaptionElement', - headerFile="nsIDOMHTMLTableCaptionElem.h") addExternalIface('HTMLTableSectionElement', headerFile="nsIDOMHTMLTableSectionElem.h") addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') diff --git a/dom/webidl/HTMLTableCaptionElement.webidl b/dom/webidl/HTMLTableCaptionElement.webidl new file mode 100644 index 000000000000..26bbf7605641 --- /dev/null +++ b/dom/webidl/HTMLTableCaptionElement.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/ + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLTableCaptionElement : HTMLElement {/*}; + +partial interface HTMLTableCaptionElement { +*/ + [SetterThrows] + attribute DOMString align; +}; diff --git a/dom/webidl/HTMLTableElement.webidl b/dom/webidl/HTMLTableElement.webidl index 85439d6ec9b9..207e9a6068e6 100644 --- a/dom/webidl/HTMLTableElement.webidl +++ b/dom/webidl/HTMLTableElement.webidl @@ -11,7 +11,6 @@ * and create derivative works of this document. */ -interface HTMLTableCaptionElement; interface HTMLTableSectionElement; interface HTMLTableElement : HTMLElement { diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 7462364f4d60..ca59e9577c7c 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -73,6 +73,7 @@ webidl_files = \ HTMLPropertiesCollection.webidl \ HTMLScriptElement.webidl \ HTMLSpanElement.webidl \ + HTMLTableCaptionElement.webidl \ HTMLTableElement.webidl \ HTMLTitleElement.webidl \ HTMLUListElement.webidl \ From 77ad96a30391a5b58ec80f014bc0d7c7224c293c Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 29 Dec 2012 15:07:48 +0100 Subject: [PATCH 152/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableSectionElement to WebIDL. r=bz. --HG-- rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.cpp rename : content/html/content/src/nsHTMLTableSectionElement.cpp => content/html/content/src/HTMLTableSectionElement.cpp rename : content/html/content/src/nsHTMLTableSectionElement.cpp => content/html/content/src/HTMLTableSectionElement.h rename : dom/interfaces/html/nsIDOMHTMLTableSectionElem.idl => dom/interfaces/html/nsIDOMHTMLTableSectionElement.idl extra : rebase_source : b9c1d7dea38653452b44b2033cf2c0140f7b39b1 --- accessible/src/html/HTMLTableAccessible.cpp | 2 +- .../browser_dbg_propertyview-filter-05.js | 4 +- content/html/content/src/HTMLTableElement.cpp | 27 +-- content/html/content/src/HTMLTableElement.h | 22 +- .../html/content/src/HTMLTableRowElement.cpp | 2 +- .../content/src/HTMLTableSectionElement.cpp | 189 ++++++++++++------ .../content/src/HTMLTableSectionElement.h | 48 ++++- content/html/content/test/reflect.js | 3 - dom/base/nsDOMClassInfo.cpp | 2 +- dom/bindings/Bindings.conf | 9 +- dom/interfaces/html/Makefile.in | 2 +- ....idl => nsIDOMHTMLTableSectionElement.idl} | 0 dom/webidl/HTMLTableElement.webidl | 2 - dom/webidl/HTMLTableSectionElement.webidl | 33 +++ dom/webidl/WebIDL.mk | 1 + js/xpconnect/src/dom_quickstubs.qsconf | 6 - 16 files changed, 238 insertions(+), 114 deletions(-) rename dom/interfaces/html/{nsIDOMHTMLTableSectionElem.idl => nsIDOMHTMLTableSectionElement.idl} (100%) create mode 100644 dom/webidl/HTMLTableSectionElement.webidl diff --git a/accessible/src/html/HTMLTableAccessible.cpp b/accessible/src/html/HTMLTableAccessible.cpp index 4d6a2b1de1cb..bd1607c14603 100644 --- a/accessible/src/html/HTMLTableAccessible.cpp +++ b/accessible/src/html/HTMLTableAccessible.cpp @@ -28,7 +28,7 @@ #include "nsIDOMHTMLTableCellElement.h" #include "nsIDOMHTMLTableElement.h" #include "nsIDOMHTMLTableRowElement.h" -#include "nsIDOMHTMLTableSectionElem.h" +#include "nsIDOMHTMLTableSectionElement.h" #include "nsIDocument.h" #include "nsIMutableArray.h" #include "nsIPresShell.h" diff --git a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js b/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js index b01717a20ca0..99f8655063c4 100644 --- a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js +++ b/browser/devtools/debugger/test/browser_dbg_propertyview-filter-05.js @@ -45,8 +45,8 @@ function testVariablesFiltering() "There should be 0 variables displayed in the test scope"); is(loadScope.querySelectorAll(".variable:not([non-match])").length, 1, "There should be 1 variable displayed in the load scope"); - is(globalScope.querySelectorAll(".variable:not([non-match])").length, 4, - "There should be 4 variables displayed in the global scope"); + is(globalScope.querySelectorAll(".variable:not([non-match])").length, 5, + "There should be 5 variables displayed in the global scope"); is(innerScope.querySelectorAll(".property:not([non-match])").length, 0, "There should be 0 properties displayed in the inner scope"); diff --git a/content/html/content/src/HTMLTableElement.cpp b/content/html/content/src/HTMLTableElement.cpp index b5cc400eb331..810a54ed4fa6 100644 --- a/content/html/content/src/HTMLTableElement.cpp +++ b/content/html/content/src/HTMLTableElement.cpp @@ -6,7 +6,7 @@ #include "mozilla/Util.h" #include "mozilla/dom/HTMLTableElement.h" -#include "nsIDOMHTMLTableSectionElem.h" +#include "nsIDOMHTMLTableSectionElement.h" #include "nsAttrValueInlines.h" #include "nsRuleData.h" #include "nsHTMLStyleSheet.h" @@ -117,9 +117,9 @@ NS_INTERFACE_MAP_END if (mParent) { \ /* THead */ \ HTMLTableSectionElement* rowGroup = mParent->GetTHead(); \ - nsCOMPtr rows; \ + nsIHTMLCollection* rows; \ if (rowGroup) { \ - rowGroup->GetRows(getter_AddRefs(rows)); \ + rows = rowGroup->Rows(); \ do { /* gives scoping */ \ _code \ } while (0); \ @@ -129,7 +129,7 @@ NS_INTERFACE_MAP_END _node; _node = _node->GetNextSibling()) { \ if (_node->IsHTML(nsGkAtoms::tbody)) { \ rowGroup = static_cast(_node); \ - rowGroup->GetRows(getter_AddRefs(rows)); \ + rows = rowGroup->Rows(); \ do { /* gives scoping */ \ _code \ } while (0); \ @@ -142,9 +142,9 @@ NS_INTERFACE_MAP_END } while (0); \ /* TFoot */ \ rowGroup = mParent->GetTFoot(); \ - rows = nullptr; \ + rows = nullptr; \ if (rowGroup) { \ - rowGroup->GetRows(getter_AddRefs(rows)); \ + rows = rowGroup->Rows(); \ do { /* gives scoping */ \ _code \ } while (0); \ @@ -540,8 +540,10 @@ HTMLTableElement::GetTHead(nsIDOMHTMLTableSectionElement** aValue) NS_IMETHODIMP HTMLTableElement::SetTHead(nsIDOMHTMLTableSectionElement* aValue) { + HTMLTableSectionElement* section = + static_cast(aValue); ErrorResult rv; - SetTHead(aValue, rv); + SetTHead(section, rv); return rv.ErrorCode(); } @@ -556,8 +558,10 @@ HTMLTableElement::GetTFoot(nsIDOMHTMLTableSectionElement** aValue) NS_IMETHODIMP HTMLTableElement::SetTFoot(nsIDOMHTMLTableSectionElement* aValue) { + HTMLTableSectionElement* section = + static_cast(aValue); ErrorResult rv; - SetTFoot(aValue, rv); + SetTFoot(section, rv); return rv.ErrorCode(); } @@ -821,11 +825,8 @@ HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError) if (newRow) { HTMLTableSectionElement* section = static_cast(rowGroup.get()); - nsCOMPtr rows; - section->GetRows(getter_AddRefs(rows)); - rowGroup->InsertBefore(*newRow, - static_cast(rows.get())->Item(0), - aError); + nsIHTMLCollection* rows = section->Rows(); + rowGroup->InsertBefore(*newRow, rows->Item(0), aError); } } } diff --git a/content/html/content/src/HTMLTableElement.h b/content/html/content/src/HTMLTableElement.h index 5382e9b454c7..15087a6769c5 100644 --- a/content/html/content/src/HTMLTableElement.h +++ b/content/html/content/src/HTMLTableElement.h @@ -58,19 +58,16 @@ public: { return static_cast(GetChild(nsGkAtoms::thead)); } - void SetTHead(nsIDOMHTMLTableSectionElement* aTHead, ErrorResult& aError) + void SetTHead(HTMLTableSectionElement* aTHead, ErrorResult& aError) { - nsCOMPtr content = do_QueryInterface(aTHead); - if (!content || !content->IsHTML(nsGkAtoms::thead)) { + if (!aTHead->IsHTML(nsGkAtoms::thead)) { aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); return; } - HTMLTableSectionElement* thead = - static_cast(aTHead); DeleteTHead(); - if (thead) { - nsINode::InsertBefore(*thead, nsINode::GetFirstChild(), aError); + if (aTHead) { + nsINode::InsertBefore(*aTHead, nsINode::GetFirstChild(), aError); } } already_AddRefed CreateTHead(); @@ -79,19 +76,16 @@ public: { return static_cast(GetChild(nsGkAtoms::tfoot)); } - void SetTFoot(nsIDOMHTMLTableSectionElement* aTFoot, ErrorResult& aError) + void SetTFoot(HTMLTableSectionElement* aTFoot, ErrorResult& aError) { - nsCOMPtr content = do_QueryInterface(aTFoot); - if (!content || !content->IsHTML(nsGkAtoms::tfoot)) { + if (!aTFoot->IsHTML(nsGkAtoms::tfoot)) { aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); return; } - HTMLTableSectionElement* tfoot = - static_cast(aTFoot); DeleteTFoot(); - if (tfoot) { - nsINode::AppendChild(*tfoot, aError); + if (aTFoot) { + nsINode::AppendChild(*aTFoot, aError); } } already_AddRefed CreateTFoot(); diff --git a/content/html/content/src/HTMLTableRowElement.cpp b/content/html/content/src/HTMLTableRowElement.cpp index 1f2a72df5ad9..d441834ba9e2 100644 --- a/content/html/content/src/HTMLTableRowElement.cpp +++ b/content/html/content/src/HTMLTableRowElement.cpp @@ -7,7 +7,7 @@ #include "mozilla/dom/HTMLTableRowElement.h" #include "nsIDOMHTMLTableElement.h" -#include "nsIDOMHTMLTableSectionElem.h" +#include "nsIDOMHTMLTableSectionElement.h" #include "nsIDOMHTMLTableCellElement.h" #include "nsMappedAttributes.h" #include "nsAttrValueInlines.h" diff --git a/content/html/content/src/HTMLTableSectionElement.cpp b/content/html/content/src/HTMLTableSectionElement.cpp index f1e330c24483..d7e717a7a42b 100644 --- a/content/html/content/src/HTMLTableSectionElement.cpp +++ b/content/html/content/src/HTMLTableSectionElement.cpp @@ -8,13 +8,9 @@ #include "mozilla/dom/HTMLTableSectionElement.h" #include "nsMappedAttributes.h" #include "nsAttrValueInlines.h" -#include "nsGkAtoms.h" -#include "nsHTMLParts.h" -#include "nsStyleConsts.h" -#include "nsContentList.h" #include "nsRuleData.h" -#include "nsError.h" -#include "nsContentUtils.h" +#include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/HTMLTableSectionElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(TableSection) DOMCI_NODE_DATA(HTMLTableSectionElement, mozilla::dom::HTMLTableSectionElement) @@ -24,9 +20,11 @@ namespace dom { // you will see the phrases "rowgroup" and "section" used interchangably -HTMLTableSectionElement::HTMLTableSectionElement(already_AddRefed aNodeInfo) - : nsGenericHTMLElement(aNodeInfo) +JSObject* +HTMLTableSectionElement::WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) { + return HTMLTableSectionElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); } NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableSectionElement) @@ -49,15 +47,76 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableSectionElement) NS_IMPL_ELEMENT_CLONE(HTMLTableSectionElement) - -NS_IMPL_STRING_ATTR(HTMLTableSectionElement, Align, align) -NS_IMPL_STRING_ATTR(HTMLTableSectionElement, VAlign, valign) -NS_IMPL_STRING_ATTR(HTMLTableSectionElement, Ch, _char) -NS_IMPL_STRING_ATTR(HTMLTableSectionElement, ChOff, charoff) - +NS_IMETHODIMP +HTMLTableSectionElement::SetAlign(const nsAString& aAlign) +{ + ErrorResult rv; + SetAlign(aAlign, rv); + return rv.ErrorCode(); +} NS_IMETHODIMP -HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) +HTMLTableSectionElement::GetAlign(nsAString& aAlign) +{ + nsString align; + GetAlign(align); + aAlign = align; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableSectionElement::SetVAlign(const nsAString& aVAlign) +{ + ErrorResult rv; + SetVAlign(aVAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableSectionElement::GetVAlign(nsAString& aVAlign) +{ + nsString vAlign; + GetVAlign(vAlign); + aVAlign = vAlign; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableSectionElement::SetCh(const nsAString& aCh) +{ + ErrorResult rv; + SetCh(aCh, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableSectionElement::GetCh(nsAString& aCh) +{ + nsString ch; + GetCh(ch); + aCh = ch; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableSectionElement::SetChOff(const nsAString& aChOff) +{ + ErrorResult rv; + SetChOff(aChOff, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableSectionElement::GetChOff(nsAString& aChOff) +{ + nsString chOff; + GetChOff(chOff); + aChOff = chOff; + return NS_OK; +} + +nsIHTMLCollection* +HTMLTableSectionElement::Rows() { if (!mRows) { mRows = new nsContentList(this, @@ -67,29 +126,30 @@ HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) false); } - NS_ADDREF(*aValue = mRows); + return mRows; +} + +NS_IMETHODIMP +HTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) +{ + NS_ADDREF(*aValue = Rows()); return NS_OK; } - -NS_IMETHODIMP -HTMLTableSectionElement::InsertRow(int32_t aIndex, - nsIDOMHTMLElement** aValue) +already_AddRefed +HTMLTableSectionElement::InsertRow(int32_t aIndex, ErrorResult& aError) { - *aValue = nullptr; - if (aIndex < -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; } - nsCOMPtr rows; - GetRows(getter_AddRefs(rows)); - - uint32_t rowCount; - rows->GetLength(&rowCount); + nsIHTMLCollection* rows = Rows(); + uint32_t rowCount = rows->Length(); if (aIndex > (int32_t)rowCount) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; } bool doInsert = (aIndex < int32_t(rowCount)) && (aIndex != -1); @@ -99,53 +159,45 @@ HTMLTableSectionElement::InsertRow(int32_t aIndex, nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tr, getter_AddRefs(nodeInfo)); - nsCOMPtr rowContent = NS_NewHTMLTableRowElement(nodeInfo.forget()); + nsRefPtr rowContent = + NS_NewHTMLTableRowElement(nodeInfo.forget()); if (!rowContent) { - return NS_ERROR_OUT_OF_MEMORY; + aError.Throw(NS_ERROR_OUT_OF_MEMORY); + return nullptr; } - nsCOMPtr rowNode(do_QueryInterface(rowContent)); - NS_ASSERTION(rowNode, "Should implement nsIDOMNode!"); - - nsCOMPtr retChild; - - nsresult rv; if (doInsert) { - nsCOMPtr refRow; - rows->Item(aIndex, getter_AddRefs(refRow)); - - rv = InsertBefore(rowNode, refRow, getter_AddRefs(retChild)); - NS_ENSURE_SUCCESS(rv, rv); + nsINode::InsertBefore(*rowContent, rows->Item(aIndex), aError); } else { - rv = AppendChild(rowNode, getter_AddRefs(retChild)); - NS_ENSURE_SUCCESS(rv, rv); + nsINode::AppendChild(*rowContent, aError); } - - if (retChild) { - CallQueryInterface(retChild, aValue); - } - - return NS_OK; + return rowContent.forget(); } NS_IMETHODIMP -HTMLTableSectionElement::DeleteRow(int32_t aValue) +HTMLTableSectionElement::InsertRow(int32_t aIndex, + nsIDOMHTMLElement** aValue) +{ + ErrorResult rv; + nsRefPtr row = InsertRow(aIndex, rv); + return rv.Failed() ? rv.ErrorCode() : CallQueryInterface(row, aValue); +} + +void +HTMLTableSectionElement::DeleteRow(int32_t aValue, ErrorResult& aError) { if (aValue < -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; } - nsCOMPtr rows; - GetRows(getter_AddRefs(rows)); + nsIHTMLCollection* rows = Rows(); - nsresult rv; uint32_t refIndex; if (aValue == -1) { - rv = rows->GetLength(&refIndex); - NS_ENSURE_SUCCESS(rv, rv); - + refIndex = rows->Length(); if (refIndex == 0) { - return NS_OK; + return; } --refIndex; @@ -154,16 +206,21 @@ HTMLTableSectionElement::DeleteRow(int32_t aValue) refIndex = (uint32_t)aValue; } - nsCOMPtr row; - rv = rows->Item(refIndex, getter_AddRefs(row)); - NS_ENSURE_SUCCESS(rv, rv); - + nsINode* row = rows->Item(refIndex); if (!row) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; } - nsCOMPtr retChild; - return RemoveChild(row, getter_AddRefs(retChild)); + nsINode::RemoveChild(*row, aError); +} + +NS_IMETHODIMP +HTMLTableSectionElement::DeleteRow(int32_t aValue) +{ + ErrorResult rv; + DeleteRow(aValue, rv); + return rv.ErrorCode(); } bool diff --git a/content/html/content/src/HTMLTableSectionElement.h b/content/html/content/src/HTMLTableSectionElement.h index 3f95a7a8068f..1f8760de8c84 100644 --- a/content/html/content/src/HTMLTableSectionElement.h +++ b/content/html/content/src/HTMLTableSectionElement.h @@ -6,7 +6,7 @@ #define mozilla_dom_HTMLTableSectionElement_h #include "nsGenericHTMLElement.h" -#include "nsIDOMHTMLTableSectionElem.h" +#include "nsIDOMHTMLTableSectionElement.h" namespace mozilla { namespace dom { @@ -15,7 +15,11 @@ class HTMLTableSectionElement : public nsGenericHTMLElement, public nsIDOMHTMLTableSectionElement { public: - HTMLTableSectionElement(already_AddRefed aNodeInfo); + HTMLTableSectionElement(already_AddRefed aNodeInfo) + : nsGenericHTMLElement(aNodeInfo) + { + SetIsDOMBinding(); + } // nsISupports NS_DECL_ISUPPORTS_INHERITED @@ -32,6 +36,44 @@ public: // nsIDOMHTMLTableSectionElement NS_DECL_NSIDOMHTMLTABLESECTIONELEMENT + nsIHTMLCollection* Rows(); + already_AddRefed + InsertRow(int32_t aIndex, ErrorResult& aError); + void DeleteRow(int32_t aValue, ErrorResult& aError); + + void GetAlign(nsString& aAlign) + { + GetHTMLAttr(nsGkAtoms::align, aAlign); + } + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + void GetCh(nsString& aCh) + { + GetHTMLAttr(nsGkAtoms::_char, aCh); + } + void SetCh(const nsAString& aCh, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::_char, aCh, aError); + } + void GetChOff(nsString& aChOff) + { + GetHTMLAttr(nsGkAtoms::charoff, aChOff); + } + void SetChOff(const nsAString& aChOff, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError); + } + void GetVAlign(nsString& aVAlign) + { + GetHTMLAttr(nsGkAtoms::valign, aVAlign); + } + void SetVAlign(const nsAString& aVAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError); + } + virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -48,6 +90,8 @@ public: virtual nsIDOMNode* AsDOMNode() { return this; } protected: + JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap); + nsRefPtr mRows; }; diff --git a/content/html/content/test/reflect.js b/content/html/content/test/reflect.js index 2d3306d5915e..02c667aa0324 100644 --- a/content/html/content/test/reflect.js +++ b/content/html/content/test/reflect.js @@ -64,12 +64,9 @@ function reflectString(aParameters) input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ], link: [ "crossOrigin" ], source: [ "media" ], - tbody: [ "align", "vAlign", "ch" ], td: [ "align", "vAlign", "ch" ], textarea: [ "name", "placeholder" ], - tfoot: [ "align", "vAlign", "ch" ], th: [ "align", "vAlign", "ch" ], - thead: [ "align", "vAlign", "ch" ], tr: [ "align", "vAlign", "ch" ], }; if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) { diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 85bf2eb8c2ae..c7704e2a4969 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -256,7 +256,7 @@ #include "nsIDOMHTMLTableColElement.h" #include "nsIDOMHTMLTableElement.h" #include "nsIDOMHTMLTableRowElement.h" -#include "nsIDOMHTMLTableSectionElem.h" +#include "nsIDOMHTMLTableSectionElement.h" #include "nsIDOMHTMLTextAreaElement.h" #include "nsIDOMHTMLTitleElement.h" #include "nsIDOMHTMLUListElement.h" diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 6ebeaa595517..1baaafe302c7 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -429,6 +429,13 @@ DOMInterfaces = { ] }, +'HTMLTableSectionElement': { + 'hasInstanceInterface': 'nsIDOMHTMLTableSectionElement', + 'resultNotAddRefed': [ + 'rows' + ] +}, + 'HTMLUListElement': { 'headerFile' : 'mozilla/dom/HTMLSharedListElement.h' }, @@ -1117,8 +1124,6 @@ addExternalIface('File') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('HTMLHeadElement', nativeType='mozilla::dom::Element') addExternalIface('HTMLCanvasElement', nativeType='mozilla::dom::HTMLCanvasElement') -addExternalIface('HTMLTableSectionElement', - headerFile="nsIDOMHTMLTableSectionElem.h") addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LockedFile') diff --git a/dom/interfaces/html/Makefile.in b/dom/interfaces/html/Makefile.in index 3cbf57e42c69..b8de12d04843 100644 --- a/dom/interfaces/html/Makefile.in +++ b/dom/interfaces/html/Makefile.in @@ -72,7 +72,7 @@ SDK_XPIDLSRCS = \ nsIDOMHTMLTableColElement.idl \ nsIDOMHTMLTableElement.idl \ nsIDOMHTMLTableRowElement.idl \ - nsIDOMHTMLTableSectionElem.idl \ + nsIDOMHTMLTableSectionElement.idl \ nsIDOMHTMLTextAreaElement.idl \ nsIDOMHTMLTitleElement.idl \ nsIDOMHTMLUListElement.idl \ diff --git a/dom/interfaces/html/nsIDOMHTMLTableSectionElem.idl b/dom/interfaces/html/nsIDOMHTMLTableSectionElement.idl similarity index 100% rename from dom/interfaces/html/nsIDOMHTMLTableSectionElem.idl rename to dom/interfaces/html/nsIDOMHTMLTableSectionElement.idl diff --git a/dom/webidl/HTMLTableElement.webidl b/dom/webidl/HTMLTableElement.webidl index 207e9a6068e6..66f31939646b 100644 --- a/dom/webidl/HTMLTableElement.webidl +++ b/dom/webidl/HTMLTableElement.webidl @@ -11,8 +11,6 @@ * and create derivative works of this document. */ -interface HTMLTableSectionElement; - interface HTMLTableElement : HTMLElement { attribute HTMLTableCaptionElement? caption; HTMLElement createCaption(); diff --git a/dom/webidl/HTMLTableSectionElement.webidl b/dom/webidl/HTMLTableSectionElement.webidl new file mode 100644 index 000000000000..82428c635748 --- /dev/null +++ b/dom/webidl/HTMLTableSectionElement.webidl @@ -0,0 +1,33 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/ + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLTableSectionElement : HTMLElement { + readonly attribute HTMLCollection rows; + [Throws] + HTMLElement insertRow(optional long index = -1); + [Throws] + void deleteRow(long index); +/* +}; + +partial interface HTMLTableSectionElement { +*/ + [SetterThrows] + attribute DOMString align; + [SetterThrows] + attribute DOMString ch; + [SetterThrows] + attribute DOMString chOff; + [SetterThrows] + attribute DOMString vAlign; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index ca59e9577c7c..518c75e18228 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -75,6 +75,7 @@ webidl_files = \ HTMLSpanElement.webidl \ HTMLTableCaptionElement.webidl \ HTMLTableElement.webidl \ + HTMLTableSectionElement.webidl \ HTMLTitleElement.webidl \ HTMLUListElement.webidl \ ImageData.webidl \ diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index d8d7b31e6f4e..95dd348a7f93 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -195,9 +195,6 @@ members = [ 'nsIDOMHTMLTableRowElement.cells', 'nsIDOMHTMLTableRowElement.deleteCell', 'nsIDOMHTMLTableRowElement.insertCell', - 'nsIDOMHTMLTableSectionElement.rows', - 'nsIDOMHTMLTableSectionElement.insertRow', - 'nsIDOMHTMLTableSectionElement.deleteRow', 'nsIDOMHTMLTextAreaElement.rows', 'nsIDOMHTMLTextAreaElement.name', 'nsIDOMHTMLTextAreaElement.form', @@ -316,9 +313,6 @@ members = [ # a little help. # irregularFilenames = { - # abbreviations - 'nsIDOMHTMLTableSectionElement': 'nsIDOMHTMLTableSectionElem', - # stowaways 'nsIDOMTextMetrics': 'nsIDOMCanvasRenderingContext2D', 'nsIDOMCanvasGradient': 'nsIDOMCanvasRenderingContext2D', From 05464fedb3ad6f9ce8b71c0a5732118e45fd5618 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 29 Dec 2012 15:07:56 +0100 Subject: [PATCH 153/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableCellElement to WebIDL. r=bz. --HG-- rename : content/html/content/src/nsHTMLTableCellElement.cpp => content/html/content/src/HTMLTableCellElement.cpp rename : content/html/content/src/nsHTMLTableCellElement.cpp => content/html/content/src/HTMLTableCellElement.h rename : content/html/content/src/nsHTMLTableElement.cpp => content/html/content/src/HTMLTableElement.cpp rename : content/html/content/src/nsHTMLTableElement.h => content/html/content/src/HTMLTableElement.h rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.h extra : rebase_source : fcf088e7ac91a216ae7ad1cb16d509a17cd7a2a7 --- .../html/content/src/HTMLTableCellElement.cpp | 304 +++++++++++++++--- .../html/content/src/HTMLTableCellElement.h | 119 ++++++- .../html/content/src/HTMLTableRowElement.h | 2 + content/html/content/test/reflect.js | 2 - dom/bindings/Bindings.conf | 4 + dom/webidl/HTMLTableCellElement.webidl | 53 +++ dom/webidl/WebIDL.mk | 1 + js/xpconnect/src/dom_quickstubs.qsconf | 8 - 8 files changed, 436 insertions(+), 57 deletions(-) create mode 100644 dom/webidl/HTMLTableCellElement.webidl diff --git a/content/html/content/src/HTMLTableCellElement.cpp b/content/html/content/src/HTMLTableCellElement.cpp index 739f5abe5524..185e78ccc6d0 100644 --- a/content/html/content/src/HTMLTableCellElement.cpp +++ b/content/html/content/src/HTMLTableCellElement.cpp @@ -7,17 +7,13 @@ #include "mozilla/dom/HTMLTableCellElement.h" #include "mozilla/dom/HTMLTableElement.h" -#include "nsIDOMHTMLTableCellElement.h" -#include "nsIDOMHTMLTableRowElement.h" -#include "nsIDOMHTMLCollection.h" +#include "mozilla/dom/HTMLTableRowElement.h" #include "nsMappedAttributes.h" #include "nsAttrValueInlines.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" -#include "nsPresContext.h" #include "nsRuleData.h" #include "nsRuleWalker.h" #include "celldata.h" +#include "mozilla/dom/HTMLTableCellElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(TableCell) DOMCI_NODE_DATA(HTMLTableCellElement, mozilla::dom::HTMLTableCellElement) @@ -29,6 +25,13 @@ HTMLTableCellElement::~HTMLTableCellElement() { } +JSObject* +HTMLTableCellElement::WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) +{ + return HTMLTableCellElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + NS_IMPL_ADDREF_INHERITED(HTMLTableCellElement, Element) NS_IMPL_RELEASE_INHERITED(HTMLTableCellElement, Element) @@ -45,11 +48,10 @@ NS_IMPL_ELEMENT_CLONE(HTMLTableCellElement) // protected method -already_AddRefed +HTMLTableRowElement* HTMLTableCellElement::GetRow() const { - nsCOMPtr row = do_QueryInterface(GetParent()); - return row.forget(); + return HTMLTableRowElement::FromContentOrNull(GetParent()); } // protected method @@ -81,14 +83,12 @@ HTMLTableCellElement::GetTable() const return nullptr; } -NS_IMETHODIMP -HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) +int32_t +HTMLTableCellElement::CellIndex() const { - *aCellIndex = -1; - - nsCOMPtr row = GetRow(); + HTMLTableRowElement* row = GetRow(); if (!row) { - return NS_OK; + return -1; } nsCOMPtr cells; @@ -96,7 +96,7 @@ HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) row->GetCells(getter_AddRefs(cells)); if (!cells) { - return NS_OK; + return -1; } uint32_t numCells; @@ -106,15 +106,20 @@ HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) nsCOMPtr node; cells->Item(i, getter_AddRefs(node)); - if (node.get() == static_cast(this)) { - *aCellIndex = i; - break; + if (node.get() == static_cast(this)) { + return i; } } - return NS_OK; + return -1; } +NS_IMETHODIMP +HTMLTableCellElement::GetCellIndex(int32_t* aCellIndex) +{ + *aCellIndex = CellIndex(); + return NS_OK; +} NS_IMETHODIMP HTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) @@ -132,42 +137,249 @@ HTMLTableCellElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker) return NS_OK; } - -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Abbr, abbr) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Axis, axis) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, BgColor, bgcolor) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Ch, _char) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, ChOff, charoff) -NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableCellElement, ColSpan, colspan, 1) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Headers, headers) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Height, height) -NS_IMPL_BOOL_ATTR(HTMLTableCellElement, NoWrap, nowrap) -NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableCellElement, RowSpan, rowspan, 1) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Scope, scope) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, VAlign, valign) -NS_IMPL_STRING_ATTR(HTMLTableCellElement, Width, width) - +NS_IMETHODIMP +HTMLTableCellElement::SetAbbr(const nsAString& aAbbr) +{ + ErrorResult rv; + SetAbbr(aAbbr, rv); + return rv.ErrorCode(); +} NS_IMETHODIMP -HTMLTableCellElement::GetAlign(nsAString& aValue) +HTMLTableCellElement::GetAbbr(nsAString& aAbbr) { - if (!GetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue)) { - // There's no align attribute, ask the row for the alignment. - nsCOMPtr row = GetRow(); - if (row) { - return row->GetAlign(aValue); - } - } - + nsString abbr; + GetAbbr(abbr); + aAbbr = abbr; return NS_OK; } NS_IMETHODIMP -HTMLTableCellElement::SetAlign(const nsAString& aValue) +HTMLTableCellElement::SetAxis(const nsAString& aAxis) { - return SetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue, true); + ErrorResult rv; + SetAxis(aAxis, rv); + return rv.ErrorCode(); } +NS_IMETHODIMP +HTMLTableCellElement::GetAxis(nsAString& aAxis) +{ + nsString axis; + GetAxis(axis); + aAxis = axis; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetAlign(const nsAString& aAlign) +{ + ErrorResult rv; + SetAlign(aAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetAlign(nsAString& aAlign) +{ + nsString align; + GetAlign(align); + aAlign = align; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetVAlign(const nsAString& aVAlign) +{ + ErrorResult rv; + SetVAlign(aVAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetVAlign(nsAString& aVAlign) +{ + nsString vAlign; + GetVAlign(vAlign); + aVAlign = vAlign; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetCh(const nsAString& aCh) +{ + ErrorResult rv; + SetCh(aCh, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetCh(nsAString& aCh) +{ + nsString ch; + GetCh(ch); + aCh = ch; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetChOff(const nsAString& aChOff) +{ + ErrorResult rv; + SetChOff(aChOff, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetChOff(nsAString& aChOff) +{ + nsString chOff; + GetChOff(chOff); + aChOff = chOff; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetBgColor(const nsAString& aBgColor) +{ + ErrorResult rv; + SetBgColor(aBgColor, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetBgColor(nsAString& aBgColor) +{ + nsString bgColor; + GetBgColor(bgColor); + aBgColor = bgColor; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetHeight(const nsAString& aHeight) +{ + ErrorResult rv; + SetHeight(aHeight, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetHeight(nsAString& aHeight) +{ + nsString height; + GetHeight(height); + aHeight = height; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetWidth(const nsAString& aWidth) +{ + ErrorResult rv; + SetWidth(aWidth, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetWidth(nsAString& aWidth) +{ + nsString width; + GetWidth(width); + aWidth = width; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetNoWrap(bool aNoWrap) +{ + ErrorResult rv; + SetNoWrap(aNoWrap, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetNoWrap(bool* aNoWrap) +{ + *aNoWrap = NoWrap(); + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetScope(const nsAString& aScope) +{ + ErrorResult rv; + SetScope(aScope, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetScope(nsAString& aScope) +{ + nsString scope; + GetScope(scope); + aScope = scope; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetHeaders(const nsAString& aHeaders) +{ + ErrorResult rv; + SetHeaders(aHeaders, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetHeaders(nsAString& aHeaders) +{ + nsString headers; + GetHeaders(headers); + aHeaders = headers; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetColSpan(int32_t aColSpan) +{ + ErrorResult rv; + SetColSpan(aColSpan, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetColSpan(int32_t* aColSpan) +{ + *aColSpan = ColSpan(); + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableCellElement::SetRowSpan(int32_t aRowSpan) +{ + ErrorResult rv; + SetRowSpan(aRowSpan, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableCellElement::GetRowSpan(int32_t* aRowSpan) +{ + *aRowSpan = RowSpan(); + return NS_OK; +} + +void +HTMLTableCellElement::GetAlign(nsString& aValue) +{ + if (!GetAttr(kNameSpaceID_None, nsGkAtoms::align, aValue)) { + // There's no align attribute, ask the row for the alignment. + HTMLTableRowElement* row = GetRow(); + if (row) { + row->GetAlign(aValue); + } + } +} static const nsAttrValue::EnumTable kCellScopeTable[] = { { "row", NS_STYLE_CELL_SCOPE_ROW }, diff --git a/content/html/content/src/HTMLTableCellElement.h b/content/html/content/src/HTMLTableCellElement.h index 1e1a555b0bd6..a8c4a25442e0 100644 --- a/content/html/content/src/HTMLTableCellElement.h +++ b/content/html/content/src/HTMLTableCellElement.h @@ -22,6 +22,7 @@ public: HTMLTableCellElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { + SetIsDOMBinding(); } virtual ~HTMLTableCellElement(); @@ -40,6 +41,119 @@ public: // nsIDOMHTMLTableCellElement NS_DECL_NSIDOMHTMLTABLECELLELEMENT + uint32_t ColSpan() const + { + return GetIntAttr(nsGkAtoms::colspan, 1); + } + void SetColSpan(uint32_t aColSpan, ErrorResult& aError) + { + SetHTMLIntAttr(nsGkAtoms::colspan, aColSpan, aError); + } + uint32_t RowSpan() const + { + return GetIntAttr(nsGkAtoms::rowspan, 1); + } + void SetRowSpan(uint32_t aRowSpan, ErrorResult& aError) + { + SetHTMLIntAttr(nsGkAtoms::rowspan, aRowSpan, aError); + } + //already_AddRefed Headers() const; + void GetHeaders(nsString& aHeaders) + { + GetHTMLAttr(nsGkAtoms::headers, aHeaders); + } + void SetHeaders(const nsAString& aHeaders, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::headers, aHeaders, aError); + } + int32_t CellIndex() const; + + void GetAbbr(nsString& aAbbr) + { + GetHTMLAttr(nsGkAtoms::abbr, aAbbr); + } + void SetAbbr(const nsAString& aAbbr, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::abbr, aAbbr, aError); + } + void GetScope(nsString& aScope) + { + GetHTMLAttr(nsGkAtoms::scope, aScope); + } + void SetScope(const nsAString& aScope, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::scope, aScope, aError); + } + void GetAlign(nsString& aAlign); + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + void GetAxis(nsString& aAxis) + { + GetHTMLAttr(nsGkAtoms::axis, aAxis); + } + void SetAxis(const nsAString& aAxis, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::axis, aAxis, aError); + } + void GetHeight(nsString& aHeight) + { + GetHTMLAttr(nsGkAtoms::height, aHeight); + } + void SetHeight(const nsAString& aHeight, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::height, aHeight, aError); + } + void GetWidth(nsString& aWidth) + { + GetHTMLAttr(nsGkAtoms::width, aWidth); + } + void SetWidth(const nsAString& aWidth, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::width, aWidth, aError); + } + void GetCh(nsString& aCh) + { + GetHTMLAttr(nsGkAtoms::_char, aCh); + } + void SetCh(const nsAString& aCh, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::_char, aCh, aError); + } + void GetChOff(nsString& aChOff) + { + GetHTMLAttr(nsGkAtoms::charoff, aChOff); + } + void SetChOff(const nsAString& aChOff, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError); + } + bool NoWrap() + { + return GetBoolAttr(nsGkAtoms::nowrap); + } + void SetNoWrap(bool aNoWrap, ErrorResult& aError) + { + SetHTMLBoolAttr(nsGkAtoms::nowrap, aNoWrap, aError); + } + void GetVAlign(nsString& aVAlign) + { + GetHTMLAttr(nsGkAtoms::valign, aVAlign); + } + void SetVAlign(const nsAString& aVAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError); + } + void GetBgColor(nsString& aBgColor) + { + GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor); + } + void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError); + } + virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -54,9 +168,12 @@ public: virtual nsIDOMNode* AsDOMNode() { return this; } protected: + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) MOZ_OVERRIDE; + HTMLTableElement* GetTable() const; - already_AddRefed GetRow() const; + HTMLTableRowElement* GetRow() const; }; } // namespace dom diff --git a/content/html/content/src/HTMLTableRowElement.h b/content/html/content/src/HTMLTableRowElement.h index 74ba6b306cd6..cd22097e13c8 100644 --- a/content/html/content/src/HTMLTableRowElement.h +++ b/content/html/content/src/HTMLTableRowElement.h @@ -20,6 +20,8 @@ class HTMLTableRowElement : public nsGenericHTMLElement, public: HTMLTableRowElement(already_AddRefed aNodeInfo); + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableRowElement, nsGkAtoms::tr) + // nsISupports NS_DECL_ISUPPORTS_INHERITED diff --git a/content/html/content/test/reflect.js b/content/html/content/test/reflect.js index 02c667aa0324..b3dc6267fe89 100644 --- a/content/html/content/test/reflect.js +++ b/content/html/content/test/reflect.js @@ -64,9 +64,7 @@ function reflectString(aParameters) input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ], link: [ "crossOrigin" ], source: [ "media" ], - td: [ "align", "vAlign", "ch" ], textarea: [ "name", "placeholder" ], - th: [ "align", "vAlign", "ch" ], tr: [ "align", "vAlign", "ch" ], }; if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) { diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 1baaafe302c7..439f5d2bfc51 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -422,6 +422,10 @@ DOMInterfaces = { 'hasInstanceInterface': 'nsIDOMHTMLScriptElement', }, +'HTMLTableCellElement': { + 'hasInstanceInterface': 'nsIDOMHTMLTableCellElement' +}, + 'HTMLTableElement': { 'hasInstanceInterface': 'nsIDOMHTMLTableElement', 'resultNotAddRefed': [ diff --git a/dom/webidl/HTMLTableCellElement.webidl b/dom/webidl/HTMLTableCellElement.webidl new file mode 100644 index 000000000000..968f6ec289cf --- /dev/null +++ b/dom/webidl/HTMLTableCellElement.webidl @@ -0,0 +1,53 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/ + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLTableCellElement : HTMLElement { + [SetterThrows] + attribute unsigned long colSpan; + [SetterThrows] + attribute unsigned long rowSpan; + //[PutForwards=value] readonly attribute DOMSettableTokenList headers; + [SetterThrows] + attribute DOMString headers; + readonly attribute long cellIndex; + + // Mozilla-specific extensions + [SetterThrows] + attribute DOMString abbr; + [SetterThrows] + attribute DOMString scope; +/* +}; + +partial interface HTMLTableCellElement { +*/ + [SetterThrows] + attribute DOMString align; + [SetterThrows] + attribute DOMString axis; + [SetterThrows] + attribute DOMString height; + [SetterThrows] + attribute DOMString width; + + [SetterThrows] + attribute DOMString ch; + [SetterThrows] + attribute DOMString chOff; + [SetterThrows] + attribute boolean noWrap; + [SetterThrows] + attribute DOMString vAlign; + + [TreatNullAs=EmptyString, SetterThrows] attribute DOMString bgColor; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 518c75e18228..67629bcc45bf 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -74,6 +74,7 @@ webidl_files = \ HTMLScriptElement.webidl \ HTMLSpanElement.webidl \ HTMLTableCaptionElement.webidl \ + HTMLTableCellElement.webidl \ HTMLTableElement.webidl \ HTMLTableSectionElement.webidl \ HTMLTitleElement.webidl \ diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 95dd348a7f93..abbcae27a651 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -180,14 +180,6 @@ members = [ 'nsIDOMHTMLSelectElement.options', 'nsIDOMHTMLSelectElement.size', 'nsIDOMHTMLStyleElement.disabled', - 'nsIDOMHTMLTableCellElement.colSpan', - 'nsIDOMHTMLTableCellElement.headers', - 'nsIDOMHTMLTableCellElement.cellIndex', - 'nsIDOMHTMLTableCellElement.rowSpan', - 'nsIDOMHTMLTableCellElement.abbr', - 'nsIDOMHTMLTableCellElement.scope', - 'nsIDOMHTMLTableCellElement.noWrap', - 'nsIDOMHTMLTableCellElement.width', 'nsIDOMHTMLTableColElement.span', 'nsIDOMHTMLTableColElement.width', 'nsIDOMHTMLTableRowElement.sectionRowIndex', From b355be85c1ad78fd5e214ddddf68297c765f82b5 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 29 Dec 2012 15:07:57 +0100 Subject: [PATCH 154/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableRowElement to WebIDL. r=bz. --HG-- extra : rebase_source : d2febac66f508caf3c2b89816e811ed8e2c88856 --- .../html/content/src/HTMLTableCellElement.cpp | 14 +- content/html/content/src/HTMLTableElement.h | 2 + .../html/content/src/HTMLTableRowElement.cpp | 272 ++++++++++++------ .../html/content/src/HTMLTableRowElement.h | 58 +++- content/html/content/test/reflect.js | 1 - dom/bindings/Bindings.conf | 7 + dom/webidl/HTMLTableRowElement.webidl | 37 +++ dom/webidl/WebIDL.mk | 1 + js/xpconnect/src/dom_quickstubs.qsconf | 5 - 9 files changed, 284 insertions(+), 113 deletions(-) create mode 100644 dom/webidl/HTMLTableRowElement.webidl diff --git a/content/html/content/src/HTMLTableCellElement.cpp b/content/html/content/src/HTMLTableCellElement.cpp index 185e78ccc6d0..01100600da77 100644 --- a/content/html/content/src/HTMLTableCellElement.cpp +++ b/content/html/content/src/HTMLTableCellElement.cpp @@ -91,22 +91,14 @@ HTMLTableCellElement::CellIndex() const return -1; } - nsCOMPtr cells; - - row->GetCells(getter_AddRefs(cells)); - + nsIHTMLCollection* cells = row->Cells(); if (!cells) { return -1; } - uint32_t numCells; - cells->GetLength(&numCells); - + uint32_t numCells = cells->Length(); for (uint32_t i = 0; i < numCells; i++) { - nsCOMPtr node; - cells->Item(i, getter_AddRefs(node)); - - if (node.get() == static_cast(this)) { + if (cells->Item(i) == this) { return i; } } diff --git a/content/html/content/src/HTMLTableElement.h b/content/html/content/src/HTMLTableElement.h index 15087a6769c5..092a908e51d3 100644 --- a/content/html/content/src/HTMLTableElement.h +++ b/content/html/content/src/HTMLTableElement.h @@ -25,6 +25,8 @@ public: HTMLTableElement(already_AddRefed aNodeInfo); virtual ~HTMLTableElement(); + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableElement, nsGkAtoms::table) + // nsISupports NS_DECL_ISUPPORTS_INHERITED diff --git a/content/html/content/src/HTMLTableRowElement.cpp b/content/html/content/src/HTMLTableRowElement.cpp index d441834ba9e2..86a6845d5001 100644 --- a/content/html/content/src/HTMLTableRowElement.cpp +++ b/content/html/content/src/HTMLTableRowElement.cpp @@ -6,17 +6,12 @@ #include "mozilla/Util.h" #include "mozilla/dom/HTMLTableRowElement.h" -#include "nsIDOMHTMLTableElement.h" -#include "nsIDOMHTMLTableSectionElement.h" -#include "nsIDOMHTMLTableCellElement.h" +#include "mozilla/dom/HTMLTableElement.h" #include "nsMappedAttributes.h" #include "nsAttrValueInlines.h" -#include "nsContentList.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" -#include "nsHTMLParts.h" #include "nsRuleData.h" -#include "nsContentUtils.h" +#include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/HTMLTableRowElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(TableRow) DOMCI_NODE_DATA(HTMLTableRowElement, mozilla::dom::HTMLTableRowElement) @@ -24,9 +19,11 @@ DOMCI_NODE_DATA(HTMLTableRowElement, mozilla::dom::HTMLTableRowElement) namespace mozilla { namespace dom { -HTMLTableRowElement::HTMLTableRowElement(already_AddRefed aNodeInfo) - : nsGenericHTMLElement(aNodeInfo) +JSObject* +HTMLTableRowElement::WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) { + return HTMLTableRowElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); } NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLTableRowElement) @@ -60,7 +57,7 @@ HTMLTableRowElement::GetSection() const } // protected method -already_AddRefed +HTMLTableElement* HTMLTableRowElement::GetTable() const { nsIContent* parent = GetParent(); @@ -69,50 +66,48 @@ HTMLTableRowElement::GetTable() const } // We may not be in a section - nsCOMPtr table = do_QueryInterface(parent); + HTMLTableElement* table = HTMLTableElement::FromContent(parent); if (table) { - return table.forget(); + return table; } - parent = parent->GetParent(); - if (!parent) { - return nullptr; + return HTMLTableElement::FromContentOrNull(parent->GetParent()); +} + +int32_t +HTMLTableRowElement::RowIndex() const +{ + HTMLTableElement* table = GetTable(); + if (!table) { + return -1; } - table = do_QueryInterface(parent); - return table.forget(); + + nsIHTMLCollection* rows = table->Rows(); + + uint32_t numRows = rows->Length(); + + for (uint32_t i = 0; i < numRows; i++) { + if (rows->GetElementAt(i) == this) { + return i; + } + } + + return -1; } NS_IMETHODIMP HTMLTableRowElement::GetRowIndex(int32_t* aValue) { - *aValue = -1; - nsCOMPtr table = GetTable(); - if (!table) { - return NS_OK; - } - - nsCOMPtr rows; - table->GetRows(getter_AddRefs(rows)); - - nsCOMPtr coll = do_QueryInterface(rows); - uint32_t numRows = coll->Length(); - - for (uint32_t i = 0; i < numRows; i++) { - if (coll->GetElementAt(i) == this) { - *aValue = i; - break; - } - } + *aValue = RowIndex(); return NS_OK; } -NS_IMETHODIMP -HTMLTableRowElement::GetSectionRowIndex(int32_t* aValue) +int32_t +HTMLTableRowElement::SectionRowIndex() const { - *aValue = -1; nsCOMPtr section = GetSection(); if (!section) { - return NS_OK; + return -1; } nsCOMPtr rows; @@ -122,11 +117,17 @@ HTMLTableRowElement::GetSectionRowIndex(int32_t* aValue) uint32_t numRows = coll->Length(); for (uint32_t i = 0; i < numRows; i++) { if (coll->GetElementAt(i) == this) { - *aValue = i; - break; + return i; } } + return -1; +} + +NS_IMETHODIMP +HTMLTableRowElement::GetSectionRowIndex(int32_t* aValue) +{ + *aValue = SectionRowIndex(); return NS_OK; } @@ -140,8 +141,8 @@ IsCell(nsIContent *aContent, int32_t aNamespaceID, aContent->IsHTML()); } -NS_IMETHODIMP -HTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) +nsIHTMLCollection* +HTMLTableRowElement::Cells() { if (!mCells) { mCells = new nsContentList(this, @@ -154,40 +155,42 @@ HTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) false); } - NS_ADDREF(*aValue = mCells); - return NS_OK; + return mCells; } NS_IMETHODIMP -HTMLTableRowElement::InsertCell(int32_t aIndex, nsIDOMHTMLElement** aValue) +HTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) { - *aValue = nullptr; + NS_ADDREF(*aValue = Cells()); + return NS_OK; +} +already_AddRefed +HTMLTableRowElement::InsertCell(int32_t aIndex, + ErrorResult& aError) +{ if (aIndex < -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; } // Make sure mCells is initialized. - nsCOMPtr cells; - nsresult rv = GetCells(getter_AddRefs(cells)); - if (NS_FAILED(rv)) { - return rv; - } + nsIHTMLCollection* cells = Cells(); NS_ASSERTION(mCells, "How did that happen?"); - nsCOMPtr nextSibling; + nsCOMPtr nextSibling; // -1 means append, so should use null nextSibling if (aIndex != -1) { - cells->Item(aIndex, getter_AddRefs(nextSibling)); + nextSibling = cells->Item(aIndex); // Check whether we're inserting past end of list. We want to avoid doing // this unless we really have to, since this has to walk all our kids. If // we have a nextSibling, we're clearly not past end of list. if (!nextSibling) { - uint32_t cellCount; - cells->GetLength(&cellCount); + uint32_t cellCount = cells->Length(); if (aIndex > int32_t(cellCount)) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return nullptr; } } } @@ -197,43 +200,41 @@ HTMLTableRowElement::InsertCell(int32_t aIndex, nsIDOMHTMLElement** aValue) nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::td, getter_AddRefs(nodeInfo)); - nsCOMPtr cellContent = NS_NewHTMLTableCellElement(nodeInfo.forget()); - if (!cellContent) { - return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr cell = + NS_NewHTMLTableCellElement(nodeInfo.forget()); + if (!cell) { + aError.Throw(NS_ERROR_OUT_OF_MEMORY); + return nullptr; } - nsCOMPtr cellNode(do_QueryInterface(cellContent)); - NS_ASSERTION(cellNode, "Should implement nsIDOMNode!"); + nsINode::InsertBefore(*cell, nextSibling, aError); - nsCOMPtr retChild; - InsertBefore(cellNode, nextSibling, getter_AddRefs(retChild)); - - if (retChild) { - CallQueryInterface(retChild, aValue); - } - - return NS_OK; + return cell.forget(); } - NS_IMETHODIMP -HTMLTableRowElement::DeleteCell(int32_t aValue) +HTMLTableRowElement::InsertCell(int32_t aIndex, nsIDOMHTMLElement** aValue) +{ + ErrorResult rv; + nsRefPtr cell = InsertCell(aIndex, rv); + return rv.Failed() ? rv.ErrorCode() : CallQueryInterface(cell, aValue); +} + +void +HTMLTableRowElement::DeleteCell(int32_t aValue, ErrorResult& aError) { if (aValue < -1) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; } - nsCOMPtr cells; - GetCells(getter_AddRefs(cells)); + nsIHTMLCollection* cells = Cells(); - nsresult rv; uint32_t refIndex; if (aValue == -1) { - rv = cells->GetLength(&refIndex); - NS_ENSURE_SUCCESS(rv, rv); - + refIndex = cells->Length(); if (refIndex == 0) { - return NS_OK; + return; } --refIndex; @@ -242,24 +243,107 @@ HTMLTableRowElement::DeleteCell(int32_t aValue) refIndex = (uint32_t)aValue; } - nsCOMPtr cell; - rv = cells->Item(refIndex, getter_AddRefs(cell)); - NS_ENSURE_SUCCESS(rv, rv); - + nsCOMPtr cell = cells->Item(refIndex); if (!cell) { - return NS_ERROR_DOM_INDEX_SIZE_ERR; + aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); + return; } - nsCOMPtr retChild; - return RemoveChild(cell, getter_AddRefs(retChild)); + nsINode::RemoveChild(*cell, aError); } -NS_IMPL_STRING_ATTR(HTMLTableRowElement, Align, align) -NS_IMPL_STRING_ATTR(HTMLTableRowElement, BgColor, bgcolor) -NS_IMPL_STRING_ATTR(HTMLTableRowElement, Ch, _char) -NS_IMPL_STRING_ATTR(HTMLTableRowElement, ChOff, charoff) -NS_IMPL_STRING_ATTR(HTMLTableRowElement, VAlign, valign) +NS_IMETHODIMP +HTMLTableRowElement::DeleteCell(int32_t aValue) +{ + ErrorResult rv; + DeleteCell(aValue, rv); + return rv.ErrorCode(); +} +NS_IMETHODIMP +HTMLTableRowElement::SetAlign(const nsAString& aAlign) +{ + ErrorResult rv; + SetAlign(aAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableRowElement::GetAlign(nsAString& aAlign) +{ + nsString align; + GetAlign(align); + aAlign = align; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableRowElement::SetVAlign(const nsAString& aVAlign) +{ + ErrorResult rv; + SetVAlign(aVAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableRowElement::GetVAlign(nsAString& aVAlign) +{ + nsString vAlign; + GetVAlign(vAlign); + aVAlign = vAlign; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableRowElement::SetCh(const nsAString& aCh) +{ + ErrorResult rv; + SetCh(aCh, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableRowElement::GetCh(nsAString& aCh) +{ + nsString ch; + GetCh(ch); + aCh = ch; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableRowElement::SetChOff(const nsAString& aChOff) +{ + ErrorResult rv; + SetChOff(aChOff, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableRowElement::GetChOff(nsAString& aChOff) +{ + nsString chOff; + GetChOff(chOff); + aChOff = chOff; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableRowElement::SetBgColor(const nsAString& aBgColor) +{ + ErrorResult rv; + SetBgColor(aBgColor, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableRowElement::GetBgColor(nsAString& aBgColor) +{ + nsString bgColor; + GetBgColor(bgColor); + aBgColor = bgColor; + return NS_OK; +} bool HTMLTableRowElement::ParseAttribute(int32_t aNamespaceID, diff --git a/content/html/content/src/HTMLTableRowElement.h b/content/html/content/src/HTMLTableRowElement.h index cd22097e13c8..fd1fec1db920 100644 --- a/content/html/content/src/HTMLTableRowElement.h +++ b/content/html/content/src/HTMLTableRowElement.h @@ -18,7 +18,11 @@ class HTMLTableRowElement : public nsGenericHTMLElement, public nsIDOMHTMLTableRowElement { public: - HTMLTableRowElement(already_AddRefed aNodeInfo); + HTMLTableRowElement(already_AddRefed aNodeInfo) + : nsGenericHTMLElement(aNodeInfo) + { + SetIsDOMBinding(); + } NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableRowElement, nsGkAtoms::tr) @@ -37,6 +41,54 @@ public: // nsIDOMHTMLTableRowElement NS_DECL_NSIDOMHTMLTABLEROWELEMENT + int32_t RowIndex() const; + int32_t SectionRowIndex() const; + nsIHTMLCollection* Cells(); + already_AddRefed + InsertCell(int32_t aIndex, ErrorResult& aError); + void DeleteCell(int32_t aValue, ErrorResult& aError); + + void GetAlign(nsString& aAlign) + { + GetHTMLAttr(nsGkAtoms::align, aAlign); + } + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + void GetCh(nsString& aCh) + { + GetHTMLAttr(nsGkAtoms::_char, aCh); + } + void SetCh(const nsAString& aCh, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::_char, aCh, aError); + } + void GetChOff(nsString& aChOff) + { + GetHTMLAttr(nsGkAtoms::charoff, aChOff); + } + void SetChOff(const nsAString& aChOff, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError); + } + void GetVAlign(nsString& aVAlign) + { + GetHTMLAttr(nsGkAtoms::valign, aVAlign); + } + void SetVAlign(const nsAString& aVAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError); + } + void GetBgColor(nsString& aBgColor) + { + GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor); + } + void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError); + } + virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -54,8 +106,10 @@ public: nsGenericHTMLElement) protected: + JSObject* WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap); + already_AddRefed GetSection() const; - already_AddRefed GetTable() const; + HTMLTableElement* GetTable() const; nsRefPtr mCells; }; diff --git a/content/html/content/test/reflect.js b/content/html/content/test/reflect.js index b3dc6267fe89..b118cf9ae40b 100644 --- a/content/html/content/test/reflect.js +++ b/content/html/content/test/reflect.js @@ -65,7 +65,6 @@ function reflectString(aParameters) link: [ "crossOrigin" ], source: [ "media" ], textarea: [ "name", "placeholder" ], - tr: [ "align", "vAlign", "ch" ], }; if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) { is(element.getAttribute(contentAttr), "null", diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 439f5d2bfc51..ebd5899c5e30 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -433,6 +433,13 @@ DOMInterfaces = { ] }, +'HTMLTableRowElement': { + 'hasInstanceInterface': 'nsIDOMHTMLTableRowElement', + 'resultNotAddRefed': [ + 'cells' + ] +}, + 'HTMLTableSectionElement': { 'hasInstanceInterface': 'nsIDOMHTMLTableSectionElement', 'resultNotAddRefed': [ diff --git a/dom/webidl/HTMLTableRowElement.webidl b/dom/webidl/HTMLTableRowElement.webidl new file mode 100644 index 000000000000..8791179387c5 --- /dev/null +++ b/dom/webidl/HTMLTableRowElement.webidl @@ -0,0 +1,37 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/ + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLTableRowElement : HTMLElement { + readonly attribute long rowIndex; + readonly attribute long sectionRowIndex; + readonly attribute HTMLCollection cells; + [Throws] + HTMLElement insertCell(optional long index = -1); + [Throws] + void deleteCell(long index); +/* +}; + +partial interface HTMLTableRowElement { +*/ + [SetterThrows] + attribute DOMString align; + [SetterThrows] + attribute DOMString ch; + [SetterThrows] + attribute DOMString chOff; + [SetterThrows] + attribute DOMString vAlign; + + [TreatNullAs=EmptyString, SetterThrows] attribute DOMString bgColor; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 67629bcc45bf..7cbad7049908 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -76,6 +76,7 @@ webidl_files = \ HTMLTableCaptionElement.webidl \ HTMLTableCellElement.webidl \ HTMLTableElement.webidl \ + HTMLTableRowElement.webidl \ HTMLTableSectionElement.webidl \ HTMLTitleElement.webidl \ HTMLUListElement.webidl \ diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index abbcae27a651..a75857b35611 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -182,11 +182,6 @@ members = [ 'nsIDOMHTMLStyleElement.disabled', 'nsIDOMHTMLTableColElement.span', 'nsIDOMHTMLTableColElement.width', - 'nsIDOMHTMLTableRowElement.sectionRowIndex', - 'nsIDOMHTMLTableRowElement.rowIndex', - 'nsIDOMHTMLTableRowElement.cells', - 'nsIDOMHTMLTableRowElement.deleteCell', - 'nsIDOMHTMLTableRowElement.insertCell', 'nsIDOMHTMLTextAreaElement.rows', 'nsIDOMHTMLTextAreaElement.name', 'nsIDOMHTMLTextAreaElement.form', From 15549f5c0ed759da01d165b5b27f50a70a6a681c Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 29 Dec 2012 15:07:57 +0100 Subject: [PATCH 155/180] Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableColElement to WebIDL. r=bz. --HG-- rename : content/html/content/src/nsHTMLTableCellElement.cpp => content/html/content/src/HTMLTableCellElement.cpp rename : content/html/content/src/nsHTMLTableColElement.cpp => content/html/content/src/HTMLTableColElement.cpp rename : content/html/content/src/nsHTMLTableColElement.cpp => content/html/content/src/HTMLTableColElement.h rename : content/html/content/src/nsHTMLTableElement.h => content/html/content/src/HTMLTableElement.h rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.cpp rename : content/html/content/src/nsHTMLTableRowElement.cpp => content/html/content/src/HTMLTableRowElement.h extra : rebase_source : 4654bf54c41231eed6f73a35118d58be0c9af9a0 --- .../html/content/src/HTMLTableColElement.cpp | 113 ++++++++++++++++-- .../html/content/src/HTMLTableColElement.h | 55 +++++++++ content/html/content/test/reflect.js | 2 - dom/bindings/Bindings.conf | 4 + dom/webidl/HTMLTableColElement.webidl | 26 ++++ dom/webidl/WebIDL.mk | 1 + js/xpconnect/src/dom_quickstubs.qsconf | 2 - 7 files changed, 191 insertions(+), 12 deletions(-) create mode 100644 dom/webidl/HTMLTableColElement.webidl diff --git a/content/html/content/src/HTMLTableColElement.cpp b/content/html/content/src/HTMLTableColElement.cpp index e8d20d17a3fd..0e15f160d796 100644 --- a/content/html/content/src/HTMLTableColElement.cpp +++ b/content/html/content/src/HTMLTableColElement.cpp @@ -8,9 +8,8 @@ #include "mozilla/dom/HTMLTableColElement.h" #include "nsMappedAttributes.h" #include "nsAttrValueInlines.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" #include "nsRuleData.h" +#include "mozilla/dom/HTMLTableColElementBinding.h" NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol) DOMCI_NODE_DATA(HTMLTableColElement, mozilla::dom::HTMLTableColElement) @@ -26,6 +25,13 @@ HTMLTableColElement::~HTMLTableColElement() { } +JSObject* +HTMLTableColElement::WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) +{ + return HTMLTableColElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + NS_IMPL_ADDREF_INHERITED(HTMLTableColElement, Element) NS_IMPL_RELEASE_INHERITED(HTMLTableColElement, Element) @@ -39,14 +45,105 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableColElement) NS_IMPL_ELEMENT_CLONE(HTMLTableColElement) +NS_IMETHODIMP +HTMLTableColElement::SetSpan(int32_t aSpan) +{ + ErrorResult rv; + SetSpan(aSpan, rv); + return rv.ErrorCode(); +} -NS_IMPL_STRING_ATTR(HTMLTableColElement, Align, align) -NS_IMPL_STRING_ATTR(HTMLTableColElement, Ch, _char) -NS_IMPL_STRING_ATTR(HTMLTableColElement, ChOff, charoff) -NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableColElement, Span, span, 1) -NS_IMPL_STRING_ATTR(HTMLTableColElement, VAlign, valign) -NS_IMPL_STRING_ATTR(HTMLTableColElement, Width, width) +NS_IMETHODIMP +HTMLTableColElement::GetSpan(int32_t* aSpan) +{ + *aSpan = Span(); + return NS_OK; +} +NS_IMETHODIMP +HTMLTableColElement::SetAlign(const nsAString& aAlign) +{ + ErrorResult rv; + SetAlign(aAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableColElement::GetAlign(nsAString& aAlign) +{ + nsString align; + GetAlign(align); + aAlign = align; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableColElement::SetVAlign(const nsAString& aVAlign) +{ + ErrorResult rv; + SetVAlign(aVAlign, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableColElement::GetVAlign(nsAString& aVAlign) +{ + nsString vAlign; + GetVAlign(vAlign); + aVAlign = vAlign; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableColElement::SetCh(const nsAString& aCh) +{ + ErrorResult rv; + SetCh(aCh, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableColElement::GetCh(nsAString& aCh) +{ + nsString ch; + GetCh(ch); + aCh = ch; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableColElement::SetChOff(const nsAString& aChOff) +{ + ErrorResult rv; + SetChOff(aChOff, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableColElement::GetChOff(nsAString& aChOff) +{ + nsString chOff; + GetChOff(chOff); + aChOff = chOff; + return NS_OK; +} + +NS_IMETHODIMP +HTMLTableColElement::SetWidth(const nsAString& aWidth) +{ + ErrorResult rv; + SetWidth(aWidth, rv); + return rv.ErrorCode(); +} + +NS_IMETHODIMP +HTMLTableColElement::GetWidth(nsAString& aWidth) +{ + nsString width; + GetWidth(width); + aWidth = width; + return NS_OK; +} bool HTMLTableColElement::ParseAttribute(int32_t aNamespaceID, diff --git a/content/html/content/src/HTMLTableColElement.h b/content/html/content/src/HTMLTableColElement.h index 2ef0e25ac645..dc9a55551426 100644 --- a/content/html/content/src/HTMLTableColElement.h +++ b/content/html/content/src/HTMLTableColElement.h @@ -18,6 +18,7 @@ public: HTMLTableColElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { + SetIsDOMBinding(); } virtual ~HTMLTableColElement(); @@ -36,6 +37,56 @@ public: // nsIDOMHTMLTableColElement NS_DECL_NSIDOMHTMLTABLECOLELEMENT + uint32_t Span() const + { + return GetIntAttr(nsGkAtoms::span, 1); + } + void SetSpan(uint32_t aSpan, ErrorResult& aError) + { + SetHTMLIntAttr(nsGkAtoms::span, aSpan, aError); + } + + void GetAlign(nsString& aAlign) + { + GetHTMLAttr(nsGkAtoms::align, aAlign); + } + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + void GetCh(nsString& aCh) + { + GetHTMLAttr(nsGkAtoms::_char, aCh); + } + void SetCh(const nsAString& aCh, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::_char, aCh, aError); + } + void GetChOff(nsString& aChOff) + { + GetHTMLAttr(nsGkAtoms::charoff, aChOff); + } + void SetChOff(const nsAString& aChOff, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError); + } + void GetVAlign(nsString& aVAlign) + { + GetHTMLAttr(nsGkAtoms::valign, aVAlign); + } + void SetVAlign(const nsAString& aVAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError); + } + void GetWidth(nsString& aWidth) + { + GetHTMLAttr(nsGkAtoms::width, aWidth); + } + void SetWidth(const nsAString& aWidth, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::width, aWidth, aError); + } + virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, const nsAString& aValue, @@ -48,6 +99,10 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + +protected: + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) MOZ_OVERRIDE; }; } // namespace dom diff --git a/content/html/content/test/reflect.js b/content/html/content/test/reflect.js index b118cf9ae40b..cba1c922c468 100644 --- a/content/html/content/test/reflect.js +++ b/content/html/content/test/reflect.js @@ -57,8 +57,6 @@ function reflectString(aParameters) element[idlAttr] = null; // TODO: remove this ugly hack when null stringification will work as expected. var todoAttrs = { - col: [ "align", "vAlign", "ch" ], - colgroup: [ "align", "vAlign", "ch" ], form: [ "acceptCharset", "name", "target" ], img: [ "align" ], input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ], diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index ebd5899c5e30..d3e5c5181af1 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -426,6 +426,10 @@ DOMInterfaces = { 'hasInstanceInterface': 'nsIDOMHTMLTableCellElement' }, +'HTMLTableColElement': { + 'hasInstanceInterface': 'nsIDOMHTMLTableColElement' +}, + 'HTMLTableElement': { 'hasInstanceInterface': 'nsIDOMHTMLTableElement', 'resultNotAddRefed': [ diff --git a/dom/webidl/HTMLTableColElement.webidl b/dom/webidl/HTMLTableColElement.webidl new file mode 100644 index 000000000000..a806a2d6b004 --- /dev/null +++ b/dom/webidl/HTMLTableColElement.webidl @@ -0,0 +1,26 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/ + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +interface HTMLTableColElement : HTMLElement { + attribute unsigned long span; +/* +}; + +partial interface HTMLTableColElement { +*/ + attribute DOMString align; + attribute DOMString ch; + attribute DOMString chOff; + attribute DOMString vAlign; + attribute DOMString width; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 7cbad7049908..0c42991bee97 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -75,6 +75,7 @@ webidl_files = \ HTMLSpanElement.webidl \ HTMLTableCaptionElement.webidl \ HTMLTableCellElement.webidl \ + HTMLTableColElement.webidl \ HTMLTableElement.webidl \ HTMLTableRowElement.webidl \ HTMLTableSectionElement.webidl \ diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index a75857b35611..73451a53440e 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -180,8 +180,6 @@ members = [ 'nsIDOMHTMLSelectElement.options', 'nsIDOMHTMLSelectElement.size', 'nsIDOMHTMLStyleElement.disabled', - 'nsIDOMHTMLTableColElement.span', - 'nsIDOMHTMLTableColElement.width', 'nsIDOMHTMLTextAreaElement.rows', 'nsIDOMHTMLTextAreaElement.name', 'nsIDOMHTMLTextAreaElement.form', From 1af8bc9062816bca2890f3e30e6ea96775d1a7f0 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Fri, 4 Jan 2013 12:54:54 +0100 Subject: [PATCH 156/180] Bug 817543 - [toolbox] is slow to start. r=jwalker --- .../devtools/commandline/BuiltinCommands.jsm | 1994 +++++++++++++++++ browser/devtools/commandline/CmdAddon.jsm | 297 --- browser/devtools/commandline/CmdBreak.jsm | 184 -- browser/devtools/commandline/CmdCalllog.jsm | 107 - .../devtools/commandline/CmdCalllogChrome.jsm | 158 -- browser/devtools/commandline/CmdCmd.jsm | 129 -- browser/devtools/commandline/CmdConsole.jsm | 68 - browser/devtools/commandline/CmdCookie.jsm | 207 -- browser/devtools/commandline/CmdDbg.jsm | 176 -- browser/devtools/commandline/CmdEcho.jsm | 29 - browser/devtools/commandline/CmdExport.jsm | 32 - browser/devtools/commandline/CmdJsb.jsm | 138 -- browser/devtools/commandline/CmdPagemod.jsm | 264 --- browser/devtools/commandline/CmdRestart.jsm | 54 - .../devtools/commandline/CmdScreenshot.jsm | 238 -- browser/devtools/commandline/Commands.jsm | 14 +- browser/devtools/commandline/gcli.jsm | 169 +- .../commandline/test/browser_cmd_addon.js | 4 +- browser/devtools/framework/Toolbox.jsm | 15 +- browser/devtools/framework/ToolboxHosts.jsm | 14 +- .../framework/test/browser_toolbox_hosts.js | 11 +- .../test/browser_inspector_bug_665880.js | 6 +- ...inspector_bug_672902_keyboard_shortcuts.js | 2 +- browser/devtools/inspector/test/head.js | 2 +- .../devtools/styleinspector/CssHtmlTree.jsm | 12 +- .../styleinspector/StyleInspector.jsm | 4 +- browser/devtools/tilt/CmdTilt.jsm | 6 +- 27 files changed, 2158 insertions(+), 2176 deletions(-) create mode 100644 browser/devtools/commandline/BuiltinCommands.jsm delete mode 100644 browser/devtools/commandline/CmdAddon.jsm delete mode 100644 browser/devtools/commandline/CmdBreak.jsm delete mode 100644 browser/devtools/commandline/CmdCalllog.jsm delete mode 100644 browser/devtools/commandline/CmdCalllogChrome.jsm delete mode 100644 browser/devtools/commandline/CmdCmd.jsm delete mode 100644 browser/devtools/commandline/CmdConsole.jsm delete mode 100644 browser/devtools/commandline/CmdCookie.jsm delete mode 100644 browser/devtools/commandline/CmdDbg.jsm delete mode 100644 browser/devtools/commandline/CmdEcho.jsm delete mode 100644 browser/devtools/commandline/CmdExport.jsm delete mode 100644 browser/devtools/commandline/CmdJsb.jsm delete mode 100644 browser/devtools/commandline/CmdPagemod.jsm delete mode 100644 browser/devtools/commandline/CmdRestart.jsm delete mode 100644 browser/devtools/commandline/CmdScreenshot.jsm diff --git a/browser/devtools/commandline/BuiltinCommands.jsm b/browser/devtools/commandline/BuiltinCommands.jsm new file mode 100644 index 000000000000..d4d149ae682c --- /dev/null +++ b/browser/devtools/commandline/BuiltinCommands.jsm @@ -0,0 +1,1994 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const { classes: Cc, interfaces: Ci, utils: Cu } = Components; + +this.EXPORTED_SYMBOLS = [ "CmdAddonFlags" ]; + +Cu.import("resource:///modules/devtools/gcli.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.import("resource://gre/modules/Services.jsm"); + +XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", + "resource:///modules/devtools/gDevTools.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", + "resource:///modules/devtools/Target.jsm"); + +/* CmdAddon ---------------------------------------------------------------- */ + +(function(module) { + XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", + "resource://gre/modules/AddonManager.jsm"); + + // We need to use an object in which to store any flags because a primitive + // would remain undefined. + module.CmdAddonFlags = { + addonsLoaded: false + }; + + /** + * 'addon' command. + */ + gcli.addCommand({ + name: "addon", + description: gcli.lookup("addonDesc") + }); + + /** + * 'addon list' command. + */ + gcli.addCommand({ + name: "addon list", + description: gcli.lookup("addonListDesc"), + params: [{ + name: 'type', + type: { + name: 'selection', + data: ["dictionary", "extension", "locale", "plugin", "theme", "all"] + }, + defaultValue: 'all', + description: gcli.lookup("addonListTypeDesc"), + }], + exec: function(aArgs, context) { + function representEnabledAddon(aAddon) { + return "
  • "; + } + + function representDisabledAddon(aAddon) { + return "
  • " + + "
  • "; + } + + function getAddonStatus(aAddon) { + let operations = []; + + if (aAddon.pendingOperations & AddonManager.PENDING_ENABLE) { + operations.push("PENDING_ENABLE"); + } + + if (aAddon.pendingOperations & AddonManager.PENDING_DISABLE) { + operations.push("PENDING_DISABLE"); + } + + if (aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL) { + operations.push("PENDING_UNINSTALL"); + } + + if (aAddon.pendingOperations & AddonManager.PENDING_INSTALL) { + operations.push("PENDING_INSTALL"); + } + + if (aAddon.pendingOperations & AddonManager.PENDING_UPGRADE) { + operations.push("PENDING_UPGRADE"); + } + + if (operations.length) { + return " (" + operations.join(", ") + ")"; + } + return ""; + } + + /** + * Compares two addons by their name. Used in sorting. + */ + function compareAddonNames(aNameA, aNameB) { + return String.localeCompare(aNameA.name, aNameB.name); + } + + /** + * Resolves the promise which is the scope (this) of this function, filling + * it with an HTML representation of the passed add-ons. + */ + function list(aType, aAddons) { + if (!aAddons.length) { + this.resolve(gcli.lookup("addonNoneOfType")); + } + + // Separate the enabled add-ons from the disabled ones. + let enabledAddons = []; + let disabledAddons = []; + + aAddons.forEach(function(aAddon) { + if (aAddon.isActive) { + enabledAddons.push(aAddon); + } else { + disabledAddons.push(aAddon); + } + }); + + let header; + switch(aType) { + case "dictionary": + header = gcli.lookup("addonListDictionaryHeading"); + break; + case "extension": + header = gcli.lookup("addonListExtensionHeading"); + break; + case "locale": + header = gcli.lookup("addonListLocaleHeading"); + break; + case "plugin": + header = gcli.lookup("addonListPluginHeading"); + break; + case "theme": + header = gcli.lookup("addonListThemeHeading"); + case "all": + header = gcli.lookup("addonListAllHeading"); + break; + default: + header = gcli.lookup("addonListUnknownHeading"); + } + + // Map and sort the add-ons, and create an HTML list. + let message = header + + "
      " + + enabledAddons.sort(compareAddonNames).map(representEnabledAddon).join("") + + disabledAddons.sort(compareAddonNames).map(representDisabledAddon).join("") + + "
    "; + + this.resolve(context.createView({ html: message })); + } + + // Create the promise that will be resolved when the add-on listing has + // been finished. + let promise = context.createPromise(); + let types = aArgs.type == "all" ? null : [aArgs.type]; + AddonManager.getAddonsByTypes(types, list.bind(promise, aArgs.type)); + return promise; + } + }); + + // We need a list of addon names for the enable and disable commands. Because + // getting the name list is async we do not add the commands until we have the + // list. + AddonManager.getAllAddons(function addonAsync(aAddons) { + // We listen for installs to keep our addon list up to date. There is no need + // to listen for uninstalls because uninstalled addons are simply disabled + // until restart (to enable undo functionality). + AddonManager.addAddonListener({ + onInstalled: function(aAddon) { + addonNameCache.push({ + name: representAddon(aAddon).replace(/\s/g, "_"), + value: aAddon.name + }); + }, + onUninstalled: function(aAddon) { + let name = representAddon(aAddon).replace(/\s/g, "_"); + + for (let i = 0; i < addonNameCache.length; i++) { + if(addonNameCache[i].name == name) { + addonNameCache.splice(i, 1); + break; + } + } + }, + }); + + /** + * Returns a string that represents the passed add-on. + */ + function representAddon(aAddon) { + let name = aAddon.name + " " + aAddon.version; + return name.trim(); + } + + let addonNameCache = []; + + // The name parameter, used in "addon enable" and "addon disable." + let nameParameter = { + name: "name", + type: { + name: "selection", + lookup: addonNameCache + }, + description: gcli.lookup("addonNameDesc") + }; + + for (let addon of aAddons) { + addonNameCache.push({ + name: representAddon(addon).replace(/\s/g, "_"), + value: addon.name + }); + } + + /** + * 'addon enable' command. + */ + gcli.addCommand({ + name: "addon enable", + description: gcli.lookup("addonEnableDesc"), + params: [nameParameter], + exec: function(aArgs, context) { + /** + * Enables the addon in the passed list which has a name that matches + * according to the passed name comparer, and resolves the promise which + * is the scope (this) of this function to display the result of this + * enable attempt. + */ + function enable(aName, addons) { + // Find the add-on. + let addon = null; + addons.some(function(candidate) { + if (candidate.name == aName) { + addon = candidate; + return true; + } else { + return false; + } + }); + + let name = representAddon(addon); + let message = ""; + + if (!addon.userDisabled) { + message = gcli.lookupFormat("addonAlreadyEnabled", [name]); + } else { + addon.userDisabled = false; + message = gcli.lookupFormat("addonEnabled", [name]); + } + this.resolve(message); + } + + let promise = context.createPromise(); + // List the installed add-ons, enable one when done listing. + AddonManager.getAllAddons(enable.bind(promise, aArgs.name)); + return promise; + } + }); + + /** + * 'addon disable' command. + */ + gcli.addCommand({ + name: "addon disable", + description: gcli.lookup("addonDisableDesc"), + params: [nameParameter], + exec: function(aArgs, context) { + /** + * Like enable, but ... you know ... the exact opposite. + */ + function disable(aName, addons) { + // Find the add-on. + let addon = null; + addons.some(function(candidate) { + if (candidate.name == aName) { + addon = candidate; + return true; + } else { + return false; + } + }); + + let name = representAddon(addon); + let message = ""; + + if (addon.userDisabled) { + message = gcli.lookupFormat("addonAlreadyDisabled", [name]); + } else { + addon.userDisabled = true; + message = gcli.lookupFormat("addonDisabled", [name]); + } + this.resolve(message); + } + + let promise = context.createPromise(); + // List the installed add-ons, disable one when done listing. + AddonManager.getAllAddons(disable.bind(promise, aArgs.name)); + return promise; + } + }); + module.CmdAddonFlags.addonsLoaded = true; + Services.obs.notifyObservers(null, "gcli_addon_commands_ready", null); + }); +}(this)); + +/* CmdBreak ---------------------------------------------------------------- */ +(function(module) { + XPCOMUtils.defineLazyModuleGetter(this, "HUDService", + "resource:///modules/HUDService.jsm"); + + XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", + "resource:///modules/devtools/Target.jsm"); + + /** + * 'break' command + */ + gcli.addCommand({ + name: "break", + description: gcli.lookup("breakDesc"), + manual: gcli.lookup("breakManual") + }); + + /** + * 'break list' command + */ + gcli.addCommand({ + name: "break list", + description: gcli.lookup("breaklistDesc"), + returnType: "html", + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let breakpoints = dbg.getAllBreakpoints(); + + if (Object.keys(breakpoints).length === 0) { + return gcli.lookup("breaklistNone"); + } + + let reply = gcli.lookup("breaklistIntro"); + reply += "
      "; + for each (let breakpoint in breakpoints) { + let text = gcli.lookupFormat("breaklistLineEntry", + [breakpoint.location.url, + breakpoint.location.line]); + reply += "
    1. " + text + "
    2. "; + }; + reply += "
    "; + return reply; + } + }); + + /** + * 'break add' command + */ + gcli.addCommand({ + name: "break add", + description: gcli.lookup("breakaddDesc"), + manual: gcli.lookup("breakaddManual") + }); + + /** + * 'break add line' command + */ + gcli.addCommand({ + name: "break add line", + description: gcli.lookup("breakaddlineDesc"), + params: [ + { + name: "file", + type: { + name: "selection", + data: function(args, context) { + let files = []; + let dbg = getPanel(context, "jsdebugger"); + if (dbg) { + let sourcesView = dbg.panelWin.DebuggerView.Sources; + for (let item in sourcesView) { + files.push(item.value); + } + } + return files; + } + }, + description: gcli.lookup("breakaddlineFileDesc") + }, + { + name: "line", + type: { name: "number", min: 1, step: 10 }, + description: gcli.lookup("breakaddlineLineDesc") + } + ], + returnType: "html", + exec: function(args, context) { + args.type = "line"; + + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + var deferred = context.defer(); + let position = { url: args.file, line: args.line }; + dbg.addBreakpoint(position, function(aBreakpoint, aError) { + if (aError) { + deferred.resolve(gcli.lookupFormat("breakaddFailed", [aError])); + return; + } + deferred.resolve(gcli.lookup("breakaddAdded")); + }); + return deferred.promise; + } + }); + + + /** + * 'break del' command + */ + gcli.addCommand({ + name: "break del", + description: gcli.lookup("breakdelDesc"), + params: [ + { + name: "breakid", + type: { + name: "number", + min: 0, + max: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + return dbg == null ? + null : + Object.keys(dbg.getAllBreakpoints()).length - 1; + }, + }, + description: gcli.lookup("breakdelBreakidDesc") + } + ], + returnType: "html", + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let breakpoints = dbg.getAllBreakpoints(); + let id = Object.keys(breakpoints)[args.breakid]; + if (!id || !(id in breakpoints)) { + return gcli.lookup("breakNotFound"); + } + + let deferred = context.defer(); + try { + dbg.removeBreakpoint(breakpoints[id], function() { + deferred.resolve(gcli.lookup("breakdelRemoved")); + }); + } catch (ex) { + // If the debugger has been closed already, don't scare the user. + deferred.resolve(gcli.lookup("breakdelRemoved")); + } + return deferred.promise; + } + }); + + /** + * A helper to go from a command context to a debugger panel + */ + function getPanel(context, id) { + if (context == null) { + return undefined; + } + + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + let toolbox = gDevTools.getToolbox(target); + return toolbox == null ? undefined : toolbox.getPanel(id); + } +}(this)); + +/* CmdCalllog -------------------------------------------------------------- */ + +(function(module) { + XPCOMUtils.defineLazyGetter(this, "Debugger", function() { + let JsDebugger = {}; + Components.utils.import("resource://gre/modules/jsdebugger.jsm", JsDebugger); + + let global = Components.utils.getGlobalForObject({}); + JsDebugger.addDebuggerToGlobal(global); + + return global.Debugger; + }); + + XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", + "resource:///modules/devtools/Target.jsm"); + + let debuggers = []; + + /** + * 'calllog' command + */ + gcli.addCommand({ + name: "calllog", + description: gcli.lookup("calllogDesc") + }) + + /** + * 'calllog start' command + */ + gcli.addCommand({ + name: "calllog start", + description: gcli.lookup("calllogStartDesc"), + + exec: function(args, context) { + let contentWindow = context.environment.contentDocument.defaultView; + + let dbg = new Debugger(contentWindow); + dbg.onEnterFrame = function(frame) { + // BUG 773652 - Make the output from the GCLI calllog command nicer + contentWindow.console.log("Method call: " + this.callDescription(frame)); + }.bind(this); + + debuggers.push(dbg); + + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + gDevTools.showToolbox(target, "webconsole"); + + return gcli.lookup("calllogStartReply"); + }, + + callDescription: function(frame) { + let name = ""; + if (frame.callee.name) { + name = frame.callee.name; + } + else { + let desc = frame.callee.getOwnPropertyDescriptor("displayName"); + if (desc && desc.value && typeof desc.value == "string") { + name = desc.value; + } + } + + let args = frame.arguments.map(this.valueToString).join(", "); + return name + "(" + args + ")"; + }, + + valueToString: function(value) { + if (typeof value !== "object" || value === null) { + return uneval(value); + } + return "[object " + value.class + "]"; + } + }); + + /** + * 'calllog stop' command + */ + gcli.addCommand({ + name: "calllog stop", + description: gcli.lookup("calllogStopDesc"), + + exec: function(args, context) { + let numDebuggers = debuggers.length; + if (numDebuggers == 0) { + return gcli.lookup("calllogStopNoLogging"); + } + + for (let dbg of debuggers) { + dbg.onEnterFrame = undefined; + } + debuggers = []; + + return gcli.lookupFormat("calllogStopReply", [ numDebuggers ]); + } + }); +}(this)); + +/* CmdCalllogChrome -------------------------------------------------------- */ + +(function(module) { + XPCOMUtils.defineLazyGetter(this, "Debugger", function() { + let JsDebugger = {}; + Cu.import("resource://gre/modules/jsdebugger.jsm", JsDebugger); + + let global = Components.utils.getGlobalForObject({}); + JsDebugger.addDebuggerToGlobal(global); + + return global.Debugger; + }); + + let debuggers = []; + let sandboxes = []; + + /** + * 'calllog chromestart' command + */ + gcli.addCommand({ + name: "calllog chromestart", + description: gcli.lookup("calllogChromeStartDesc"), + get hidden() gcli.hiddenByChromePref(), + params: [ + { + name: "sourceType", + type: { + name: "selection", + data: ["content-variable", "chrome-variable", "jsm", "javascript"] + } + }, + { + name: "source", + type: "string", + description: gcli.lookup("calllogChromeSourceTypeDesc"), + manual: gcli.lookup("calllogChromeSourceTypeManual"), + } + ], + exec: function(args, context) { + let globalObj; + let contentWindow = context.environment.contentDocument.defaultView; + + if (args.sourceType == "jsm") { + try { + globalObj = Cu.import(args.source); + } + catch (e) { + return gcli.lookup("callLogChromeInvalidJSM"); + } + } else if (args.sourceType == "content-variable") { + if (args.source in contentWindow) { + globalObj = Cu.getGlobalForObject(contentWindow[args.source]); + } else { + throw new Error(gcli.lookup("callLogChromeVarNotFoundContent")); + } + } else if (args.sourceType == "chrome-variable") { + let chromeWin = context.environment.chromeDocument.defaultView; + if (args.source in chromeWin) { + globalObj = Cu.getGlobalForObject(chromeWin[args.source]); + } else { + return gcli.lookup("callLogChromeVarNotFoundChrome"); + } + } else { + let chromeWin = context.environment.chromeDocument.defaultView; + let sandbox = new Cu.Sandbox(chromeWin, + { + sandboxPrototype: chromeWin, + wantXrays: false, + sandboxName: "gcli-cmd-calllog-chrome" + }); + let returnVal; + try { + returnVal = Cu.evalInSandbox(args.source, sandbox, "ECMAv5"); + sandboxes.push(sandbox); + } catch(e) { + // We need to save the message before cleaning up else e contains a dead + // object. + let msg = gcli.lookup("callLogChromeEvalException") + ": " + e; + Cu.nukeSandbox(sandbox); + return msg; + } + + if (typeof returnVal == "undefined") { + return gcli.lookup("callLogChromeEvalNeedsObject"); + } + + globalObj = Cu.getGlobalForObject(returnVal); + } + + let dbg = new Debugger(globalObj); + debuggers.push(dbg); + + dbg.onEnterFrame = function(frame) { + // BUG 773652 - Make the output from the GCLI calllog command nicer + contentWindow.console.log(gcli.lookup("callLogChromeMethodCall") + + ": " + this.callDescription(frame)); + }.bind(this); + + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + gDevTools.showToolbox(target, "webconsole"); + + return gcli.lookup("calllogChromeStartReply"); + }, + + valueToString: function(value) { + if (typeof value !== "object" || value === null) + return uneval(value); + return "[object " + value.class + "]"; + }, + + callDescription: function(frame) { + let name = frame.callee.name || gcli.lookup("callLogChromeAnonFunction"); + let args = frame.arguments.map(this.valueToString).join(", "); + return name + "(" + args + ")"; + } + }); + + /** + * 'calllog chromestop' command + */ + gcli.addCommand({ + name: "calllog chromestop", + description: gcli.lookup("calllogChromeStopDesc"), + get hidden() gcli.hiddenByChromePref(), + exec: function(args, context) { + let numDebuggers = debuggers.length; + if (numDebuggers == 0) { + return gcli.lookup("calllogChromeStopNoLogging"); + } + + for (let dbg of debuggers) { + dbg.onEnterFrame = undefined; + dbg.enabled = false; + } + for (let sandbox of sandboxes) { + Cu.nukeSandbox(sandbox); + } + debuggers = []; + sandboxes = []; + + return gcli.lookupFormat("calllogChromeStopReply", [ numDebuggers ]); + } + }); +}(this)); + +/* CmdCmd ------------------------------------------------------------------ */ + +(function(module) { + let prefSvc = "@mozilla.org/preferences-service;1"; + XPCOMUtils.defineLazyGetter(this, "prefBranch", function() { + let prefService = Cc[prefSvc].getService(Ci.nsIPrefService); + return prefService.getBranch(null).QueryInterface(Ci.nsIPrefBranch2); + }); + + XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", + "resource://gre/modules/NetUtil.jsm"); + XPCOMUtils.defineLazyModuleGetter(this, "console", + "resource://gre/modules/devtools/Console.jsm"); + + const PREF_DIR = "devtools.commands.dir"; + + /** + * A place to store the names of the commands that we have added as a result of + * calling refreshAutoCommands(). Used by refreshAutoCommands to remove the + * added commands. + */ + let commands = []; + + /** + * Exported API + */ + this.CmdCommands = { + /** + * Called to look in a directory pointed at by the devtools.commands.dir pref + * for *.mozcmd files which are then loaded. + * @param nsIPrincipal aSandboxPrincipal Scope object for the Sandbox in which + * we eval the script from the .mozcmd file. This should be a chrome window. + */ + refreshAutoCommands: function GC_refreshAutoCommands(aSandboxPrincipal) { + // First get rid of the last set of commands + commands.forEach(function(name) { + gcli.removeCommand(name); + }); + + let dirName = prefBranch.getComplexValue(PREF_DIR, + Ci.nsISupportsString).data.trim(); + if (dirName == "") { + return; + } + + let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); + dir.initWithPath(dirName); + if (!dir.exists() || !dir.isDirectory()) { + throw new Error('\'' + dirName + '\' is not a directory.'); + } + + let en = dir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator); + + while (true) { + let file = en.nextFile; + if (!file) { + break; + } + if (file.leafName.match(/.*\.mozcmd$/) && file.isFile() && file.isReadable()) { + loadCommandFile(file, aSandboxPrincipal); + } + } + }, + }; + + /** + * Load the commands from a single file + * @param nsIFile aFile The file containing the commands that we should read + * @param nsIPrincipal aSandboxPrincipal Scope object for the Sandbox in which + * we eval the script from the .mozcmd file. This should be a chrome window. + */ + function loadCommandFile(aFile, aSandboxPrincipal) { + NetUtil.asyncFetch(aFile, function refresh_fetch(aStream, aStatus) { + if (!Components.isSuccessCode(aStatus)) { + console.error("NetUtil.asyncFetch(" + aFile.path + ",..) failed. Status=" + aStatus); + return; + } + + let source = NetUtil.readInputStreamToString(aStream, aStream.available()); + aStream.close(); + + let sandbox = new Cu.Sandbox(aSandboxPrincipal, { + sandboxPrototype: aSandboxPrincipal, + wantXrays: false, + sandboxName: aFile.path + }); + let data = Cu.evalInSandbox(source, sandbox, "1.8", aFile.leafName, 1); + + if (!Array.isArray(data)) { + console.error("Command file '" + aFile.leafName + "' does not have top level array."); + return; + } + + data.forEach(function(commandSpec) { + gcli.addCommand(commandSpec); + commands.push(commandSpec.name); + }); + }.bind(this)); + } + + /** + * 'cmd' command + */ + gcli.addCommand({ + name: "cmd", + get hidden() { return !prefBranch.prefHasUserValue(PREF_DIR); }, + description: gcli.lookup("cmdDesc") + }); + + /** + * 'cmd refresh' command + */ + gcli.addCommand({ + name: "cmd refresh", + description: gcli.lookup("cmdRefreshDesc"), + get hidden() { return !prefBranch.prefHasUserValue(PREF_DIR); }, + exec: function Command_cmdRefresh(args, context) { + let chromeWindow = context.environment.chromeDocument.defaultView; + CmdCommands.refreshAutoCommands(chromeWindow); + } + }); +}(this)); + +/* CmdConsole -------------------------------------------------------------- */ + +(function(module) { + XPCOMUtils.defineLazyModuleGetter(this, "HUDService", + "resource:///modules/HUDService.jsm"); + + /** + * 'console' command + */ + gcli.addCommand({ + name: "console", + description: gcli.lookup("consoleDesc"), + manual: gcli.lookup("consoleManual") + }); + + /** + * 'console clear' command + */ + gcli.addCommand({ + name: "console clear", + description: gcli.lookup("consoleclearDesc"), + exec: function Command_consoleClear(args, context) { + let window = context.environment.contentDocument.defaultView; + let hud = HUDService.getHudByWindow(window); + // hud will be null if the web console has not been opened for this window + if (hud) { + hud.jsterm.clearOutput(); + } + } + }); + + /** + * 'console close' command + */ + gcli.addCommand({ + name: "console close", + description: gcli.lookup("consolecloseDesc"), + exec: function Command_consoleClose(args, context) { + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + return gDevTools.closeToolbox(target); + } + }); + + /** + * 'console open' command + */ + gcli.addCommand({ + name: "console open", + description: gcli.lookup("consoleopenDesc"), + exec: function Command_consoleOpen(args, context) { + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + return gDevTools.showToolbox(target, "webconsole"); + } + }); +}(this)); + +/* CmdCookie --------------------------------------------------------------- */ + +(function(module) { + XPCOMUtils.defineLazyModuleGetter(this, "console", + "resource://gre/modules/devtools/Console.jsm"); + + // We should really be using nsICookieManager so we can read more than just the + // key/value of cookies. The difficulty is filtering the cookies that are + // relevant to the current page. See + // https://github.com/firebug/firebug/blob/master/extension/content/firebug/cookies/cookieObserver.js#L123 + // For details on how this is done with Firebug + + /** + * 'cookie' command + */ + gcli.addCommand({ + name: "cookie", + description: gcli.lookup("cookieDesc"), + manual: gcli.lookup("cookieManual") + }); + + /** + * The template for the 'cookie list' command. + */ + var cookieListHtml = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "
    " + gcli.lookup("cookieListOutKey") + "" + gcli.lookup("cookieListOutValue") + "" + gcli.lookup("cookieListOutActions") + "
    ${cookie.key}${cookie.value}" + + " " + gcli.lookup("cookieListOutEdit") + "" + + " " + gcli.lookup("cookieListOutRemove") + "" + + "
    " + + ""; + + /** + * 'cookie list' command + */ + gcli.addCommand({ + name: "cookie list", + description: gcli.lookup("cookieListDesc"), + manual: gcli.lookup("cookieListManual"), + returnType: "string", + exec: function Command_cookieList(args, context) { + // Parse out an array of { key:..., value:... } objects for each cookie + var doc = context.environment.contentDocument; + var cookies = doc.cookie.split("; ").map(function(cookieStr) { + var equalsPos = cookieStr.indexOf("="); + return { + key: cookieStr.substring(0, equalsPos), + value: cookieStr.substring(equalsPos + 1) + }; + }); + + return context.createView({ + html: cookieListHtml, + data: { + cookies: cookies, + onclick: createUpdateHandler(context), + ondblclick: createExecuteHandler(context), + } + }); + } + }); + + /** + * 'cookie remove' command + */ + gcli.addCommand({ + name: "cookie remove", + description: gcli.lookup("cookieRemoveDesc"), + manual: gcli.lookup("cookieRemoveManual"), + params: [ + { + name: "key", + type: "string", + description: gcli.lookup("cookieRemoveKeyDesc"), + } + ], + exec: function Command_cookieRemove(args, context) { + let document = context.environment.contentDocument; + let expDate = new Date(); + expDate.setDate(expDate.getDate() - 1); + document.cookie = escape(args.key) + "=; expires=" + expDate.toGMTString(); + } + }); + + /** + * 'cookie set' command + */ + gcli.addCommand({ + name: "cookie set", + description: gcli.lookup("cookieSetDesc"), + manual: gcli.lookup("cookieSetManual"), + params: [ + { + name: "key", + type: "string", + description: gcli.lookup("cookieSetKeyDesc") + }, + { + name: "value", + type: "string", + description: gcli.lookup("cookieSetValueDesc") + }, + { + group: gcli.lookup("cookieSetOptionsDesc"), + params: [ + { + name: "path", + type: "string", + defaultValue: "/", + description: gcli.lookup("cookieSetPathDesc") + }, + { + name: "domain", + type: "string", + defaultValue: null, + description: gcli.lookup("cookieSetDomainDesc") + }, + { + name: "secure", + type: "boolean", + description: gcli.lookup("cookieSetSecureDesc") + } + ] + } + ], + exec: function Command_cookieSet(args, context) { + let document = context.environment.contentDocument; + + document.cookie = escape(args.key) + "=" + escape(args.value) + + (args.domain ? "; domain=" + args.domain : "") + + (args.path ? "; path=" + args.path : "") + + (args.secure ? "; secure" : ""); + } + }); + + /** + * Helper to find the 'data-command' attribute and call some action on it. + * @see |updateCommand()| and |executeCommand()| + */ + function withCommand(element, action) { + var command = element.getAttribute("data-command"); + if (!command) { + command = element.querySelector("*[data-command]") + .getAttribute("data-command"); + } + + if (command) { + action(command); + } + else { + console.warn("Missing data-command for " + util.findCssSelector(element)); + } + } + + /** + * Create a handler to update the requisition to contain the text held in the + * first matching data-command attribute under the currentTarget of the event. + * @param context Either a Requisition or an ExecutionContext or another object + * that contains an |update()| function that follows a similar contract. + */ + function createUpdateHandler(context) { + return function(ev) { + withCommand(ev.currentTarget, function(command) { + context.update(command); + }); + } + } + + /** + * Create a handler to execute the text held in the data-command attribute + * under the currentTarget of the event. + * @param context Either a Requisition or an ExecutionContext or another object + * that contains an |update()| function that follows a similar contract. + */ + function createExecuteHandler(context) { + return function(ev) { + withCommand(ev.currentTarget, function(command) { + context.exec({ + visible: true, + typed: command + }); + }); + } + } +}(this)); + +/* CmdDbg ------------------------------------------------------------------ */ + +(function(module) { + /** + * 'dbg' command + */ + gcli.addCommand({ + name: "dbg", + description: gcli.lookup("dbgDesc"), + manual: gcli.lookup("dbgManual") + }); + + /** + * 'dbg open' command + */ + gcli.addCommand({ + name: "dbg open", + description: gcli.lookup("dbgOpen"), + params: [], + exec: function (args, context) { + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + return gDevTools.showToolbox(target, "jsdebugger"); + } + }); + + /** + * 'dbg close' command + */ + gcli.addCommand({ + name: "dbg close", + description: gcli.lookup("dbgClose"), + params: [], + exec: function (args, context) { + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + return gDevTools.closeToolbox(target); + } + }); + + /** + * 'dbg interrupt' command + */ + gcli.addCommand({ + name: "dbg interrupt", + description: gcli.lookup("dbgInterrupt"), + params: [], + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let controller = dbg._controller; + let thread = controller.activeThread; + if (!thread.paused) { + thread.interrupt(); + } + } + }); + + /** + * 'dbg continue' command + */ + gcli.addCommand({ + name: "dbg continue", + description: gcli.lookup("dbgContinue"), + params: [], + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let controller = dbg._controller; + let thread = controller.activeThread; + if (thread.paused) { + thread.resume(); + } + } + }); + + /** + * 'dbg step' command + */ + gcli.addCommand({ + name: "dbg step", + description: gcli.lookup("dbgStepDesc"), + manual: gcli.lookup("dbgStepManual") + }); + + /** + * 'dbg step over' command + */ + gcli.addCommand({ + name: "dbg step over", + description: gcli.lookup("dbgStepOverDesc"), + params: [], + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let controller = dbg._controller; + let thread = controller.activeThread; + if (thread.paused) { + thread.stepOver(); + } + } + }); + + /** + * 'dbg step in' command + */ + gcli.addCommand({ + name: 'dbg step in', + description: gcli.lookup("dbgStepInDesc"), + params: [], + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let controller = dbg._controller; + let thread = controller.activeThread; + if (thread.paused) { + thread.stepIn(); + } + } + }); + + /** + * 'dbg step over' command + */ + gcli.addCommand({ + name: 'dbg step out', + description: gcli.lookup("dbgStepOutDesc"), + params: [], + exec: function(args, context) { + let dbg = getPanel(context, "jsdebugger"); + if (!dbg) { + return gcli.lookup("debuggerStopped"); + } + + let controller = dbg._controller; + let thread = controller.activeThread; + if (thread.paused) { + thread.stepOut(); + } + } + }); + + /** + * A helper to go from a command context to a debugger panel + */ + function getPanel(context, id) { + let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; + let target = TargetFactory.forTab(gBrowser.selectedTab); + let toolbox = gDevTools.getToolbox(target); + return toolbox == null ? undefined : toolbox.getPanel(id); + } +}(this)); + +/* CmdEcho ----------------------------------------------------------------- */ + +(function(module) { + /** + * 'echo' command + */ + gcli.addCommand({ + name: "echo", + description: gcli.lookup("echoDesc"), + params: [ + { + name: "message", + type: "string", + description: gcli.lookup("echoMessageDesc") + } + ], + returnType: "string", + hidden: true, + exec: function Command_echo(args, context) { + return args.message; + } + }); +}(this)); + +/* CmdExport --------------------------------------------------------------- */ + +(function(module) { + /** + * 'export' command + */ + gcli.addCommand({ + name: "export", + description: gcli.lookup("exportDesc"), + }); + + /** + * The 'export html' command. This command allows the user to export the page to + * HTML after they do DOM changes. + */ + gcli.addCommand({ + name: "export html", + description: gcli.lookup("exportHtmlDesc"), + exec: function(args, context) { + let document = context.environment.contentDocument; + let window = document.defaultView; + let page = document.documentElement.outerHTML; + window.open('data:text/plain;charset=utf8,' + encodeURIComponent(page)); + } + }); +}(this)); + +/* CmdJsb ------------------------------------------------------------------ */ + +(function(module) { + const XMLHttpRequest = + Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1"); + + XPCOMUtils.defineLazyModuleGetter(this, "js_beautify", + "resource:///modules/devtools/Jsbeautify.jsm"); + + /** + * jsb command. + */ + gcli.addCommand({ + name: 'jsb', + description: gcli.lookup('jsbDesc'), + returnValue:'string', + params: [ + { + name: 'url', + type: 'string', + description: gcli.lookup('jsbUrlDesc') + }, + { + group: gcli.lookup("jsbOptionsDesc"), + params: [ + { + name: 'indentSize', + type: 'number', + description: gcli.lookup('jsbIndentSizeDesc'), + manual: gcli.lookup('jsbIndentSizeManual'), + defaultValue: 2 + }, + { + name: 'indentChar', + type: { + name: 'selection', + lookup: [ + { name: "space", value: " " }, + { name: "tab", value: "\t" } + ] + }, + description: gcli.lookup('jsbIndentCharDesc'), + manual: gcli.lookup('jsbIndentCharManual'), + defaultValue: ' ', + }, + { + name: 'doNotPreserveNewlines', + type: 'boolean', + description: gcli.lookup('jsbDoNotPreserveNewlinesDesc') + }, + { + name: 'preserveMaxNewlines', + type: 'number', + description: gcli.lookup('jsbPreserveMaxNewlinesDesc'), + manual: gcli.lookup('jsbPreserveMaxNewlinesManual'), + defaultValue: -1 + }, + { + name: 'jslintHappy', + type: 'boolean', + description: gcli.lookup('jsbJslintHappyDesc'), + manual: gcli.lookup('jsbJslintHappyManual') + }, + { + name: 'braceStyle', + type: { + name: 'selection', + data: ['collapse', 'expand', 'end-expand', 'expand-strict'] + }, + description: gcli.lookup('jsbBraceStyleDesc'), + manual: gcli.lookup('jsbBraceStyleManual'), + defaultValue: "collapse" + }, + { + name: 'noSpaceBeforeConditional', + type: 'boolean', + description: gcli.lookup('jsbNoSpaceBeforeConditionalDesc') + }, + { + name: 'unescapeStrings', + type: 'boolean', + description: gcli.lookup('jsbUnescapeStringsDesc'), + manual: gcli.lookup('jsbUnescapeStringsManual') + } + ] + } + ], + exec: function(args, context) { + let opts = { + indent_size: args.indentSize, + indent_char: args.indentChar, + preserve_newlines: !args.doNotPreserveNewlines, + max_preserve_newlines: args.preserveMaxNewlines == -1 ? + undefined : args.preserveMaxNewlines, + jslint_happy: args.jslintHappy, + brace_style: args.braceStyle, + space_before_conditional: !args.noSpaceBeforeConditional, + unescape_strings: args.unescapeStrings + }; + + let xhr = new XMLHttpRequest(); + + try { + xhr.open("GET", args.url, true); + } catch(e) { + return gcli.lookup('jsbInvalidURL'); + } + + let promise = context.createPromise(); + + xhr.onreadystatechange = function(aEvt) { + if (xhr.readyState == 4) { + if (xhr.status == 200 || xhr.status == 0) { + let browserDoc = context.environment.chromeDocument; + let browserWindow = browserDoc.defaultView; + let gBrowser = browserWindow.gBrowser; + let result = js_beautify(xhr.responseText, opts); + + browserWindow.Scratchpad.ScratchpadManager.openScratchpad({text: result}); + + promise.resolve(); + } else { + promise.resolve("Unable to load page to beautify: " + args.url + " " + + xhr.status + " " + xhr.statusText); + } + }; + } + xhr.send(null); + return promise; + } + }); +}(this)); + +/* CmdPagemod -------------------------------------------------------------- */ + +(function(module) { + /** + * 'pagemod' command + */ + gcli.addCommand({ + name: "pagemod", + description: gcli.lookup("pagemodDesc"), + }); + + /** + * The 'pagemod replace' command. This command allows the user to search and + * replace within text nodes and attributes. + */ + gcli.addCommand({ + name: "pagemod replace", + description: gcli.lookup("pagemodReplaceDesc"), + params: [ + { + name: "search", + type: "string", + description: gcli.lookup("pagemodReplaceSearchDesc"), + }, + { + name: "replace", + type: "string", + description: gcli.lookup("pagemodReplaceReplaceDesc"), + }, + { + name: "ignoreCase", + type: "boolean", + description: gcli.lookup("pagemodReplaceIgnoreCaseDesc"), + }, + { + name: "selector", + type: "string", + description: gcli.lookup("pagemodReplaceSelectorDesc"), + defaultValue: "*:not(script):not(style):not(embed):not(object):not(frame):not(iframe):not(frameset)", + }, + { + name: "root", + type: "node", + description: gcli.lookup("pagemodReplaceRootDesc"), + defaultValue: null, + }, + { + name: "attrOnly", + type: "boolean", + description: gcli.lookup("pagemodReplaceAttrOnlyDesc"), + }, + { + name: "contentOnly", + type: "boolean", + description: gcli.lookup("pagemodReplaceContentOnlyDesc"), + }, + { + name: "attributes", + type: "string", + description: gcli.lookup("pagemodReplaceAttributesDesc"), + defaultValue: null, + }, + ], + exec: function(args, context) { + let document = context.environment.contentDocument; + let searchTextNodes = !args.attrOnly; + let searchAttributes = !args.contentOnly; + let regexOptions = args.ignoreCase ? 'ig' : 'g'; + let search = new RegExp(escapeRegex(args.search), regexOptions); + let attributeRegex = null; + if (args.attributes) { + attributeRegex = new RegExp(args.attributes, regexOptions); + } + + let root = args.root || document; + let elements = root.querySelectorAll(args.selector); + elements = Array.prototype.slice.call(elements); + + let replacedTextNodes = 0; + let replacedAttributes = 0; + + function replaceAttribute() { + replacedAttributes++; + return args.replace; + } + function replaceTextNode() { + replacedTextNodes++; + return args.replace; + } + + for (let i = 0; i < elements.length; i++) { + let element = elements[i]; + if (searchTextNodes) { + for (let y = 0; y < element.childNodes.length; y++) { + let node = element.childNodes[y]; + if (node.nodeType == node.TEXT_NODE) { + node.textContent = node.textContent.replace(search, replaceTextNode); + } + } + } + + if (searchAttributes) { + if (!element.attributes) { + continue; + } + for (let y = 0; y < element.attributes.length; y++) { + let attr = element.attributes[y]; + if (!attributeRegex || attributeRegex.test(attr.name)) { + attr.value = attr.value.replace(search, replaceAttribute); + } + } + } + } + + return gcli.lookupFormat("pagemodReplaceResult", + [elements.length, replacedTextNodes, + replacedAttributes]); + } + }); + + /** + * 'pagemod remove' command + */ + gcli.addCommand({ + name: "pagemod remove", + description: gcli.lookup("pagemodRemoveDesc"), + }); + + + /** + * The 'pagemod remove element' command. + */ + gcli.addCommand({ + name: "pagemod remove element", + description: gcli.lookup("pagemodRemoveElementDesc"), + params: [ + { + name: "search", + type: "string", + description: gcli.lookup("pagemodRemoveElementSearchDesc"), + }, + { + name: "root", + type: "node", + description: gcli.lookup("pagemodRemoveElementRootDesc"), + defaultValue: null, + }, + { + name: 'stripOnly', + type: 'boolean', + description: gcli.lookup("pagemodRemoveElementStripOnlyDesc"), + }, + { + name: 'ifEmptyOnly', + type: 'boolean', + description: gcli.lookup("pagemodRemoveElementIfEmptyOnlyDesc"), + }, + ], + exec: function(args, context) { + let document = context.environment.contentDocument; + let root = args.root || document; + let elements = Array.prototype.slice.call(root.querySelectorAll(args.search)); + + let removed = 0; + for (let i = 0; i < elements.length; i++) { + let element = elements[i]; + let parentNode = element.parentNode; + if (!parentNode || !element.removeChild) { + continue; + } + if (args.stripOnly) { + while (element.hasChildNodes()) { + parentNode.insertBefore(element.childNodes[0], element); + } + } + if (!args.ifEmptyOnly || !element.hasChildNodes()) { + element.parentNode.removeChild(element); + removed++; + } + } + + return gcli.lookupFormat("pagemodRemoveElementResultMatchedAndRemovedElements", + [elements.length, removed]); + } + }); + + /** + * The 'pagemod remove attribute' command. + */ + gcli.addCommand({ + name: "pagemod remove attribute", + description: gcli.lookup("pagemodRemoveAttributeDesc"), + params: [ + { + name: "searchAttributes", + type: "string", + description: gcli.lookup("pagemodRemoveAttributeSearchAttributesDesc"), + }, + { + name: "searchElements", + type: "string", + description: gcli.lookup("pagemodRemoveAttributeSearchElementsDesc"), + }, + { + name: "root", + type: "node", + description: gcli.lookup("pagemodRemoveAttributeRootDesc"), + defaultValue: null, + }, + { + name: "ignoreCase", + type: "boolean", + description: gcli.lookup("pagemodRemoveAttributeIgnoreCaseDesc"), + }, + ], + exec: function(args, context) { + let document = context.environment.contentDocument; + + let root = args.root || document; + let regexOptions = args.ignoreCase ? 'ig' : 'g'; + let attributeRegex = new RegExp(args.searchAttributes, regexOptions); + let elements = root.querySelectorAll(args.searchElements); + elements = Array.prototype.slice.call(elements); + + let removed = 0; + for (let i = 0; i < elements.length; i++) { + let element = elements[i]; + if (!element.attributes) { + continue; + } + + var attrs = Array.prototype.slice.call(element.attributes); + for (let y = 0; y < attrs.length; y++) { + let attr = attrs[y]; + if (attributeRegex.test(attr.name)) { + element.removeAttribute(attr.name); + removed++; + } + } + } + + return gcli.lookupFormat("pagemodRemoveAttributeResult", + [elements.length, removed]); + } + }); + + /** + * Make a given string safe to use in a regular expression. + * + * @param string aString + * The string you want to use in a regex. + * @return string + * The equivalent of |aString| but safe to use in a regex. + */ + function escapeRegex(aString) { + return aString.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + } +}(this)); + +/* CmdRestart -------------------------------------------------------------- */ + +(function(module) { + /** + * Restart command + * + * @param boolean nocache + * Disables loading content from cache upon restart. + * + * Examples : + * >> restart + * - restarts browser immediately + * >> restart --nocache + * - restarts immediately and starts Firefox without using cache + */ + gcli.addCommand({ + name: "restart", + description: gcli.lookup("restartFirefoxDesc"), + params: [ + { + name: "nocache", + type: "boolean", + description: gcli.lookup("restartFirefoxNocacheDesc") + } + ], + returnType: "string", + exec: function Restart(args, context) { + let canceled = Cc["@mozilla.org/supports-PRBool;1"] + .createInstance(Ci.nsISupportsPRBool); + Services.obs.notifyObservers(canceled, "quit-application-requested", "restart"); + if (canceled.data) { + return gcli.lookup("restartFirefoxRequestCancelled"); + } + + // disable loading content from cache. + if (args.nocache) { + Services.appinfo.invalidateCachesOnRestart(); + } + + // restart + Cc['@mozilla.org/toolkit/app-startup;1'] + .getService(Ci.nsIAppStartup) + .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); + return gcli.lookup("restartFirefoxRestarting"); + } + }); +}(this)); + +/* CmdScreenshot ----------------------------------------------------------- */ + +(function(module) { + XPCOMUtils.defineLazyModuleGetter(this, "LayoutHelpers", + "resource:///modules/devtools/LayoutHelpers.jsm"); + + // String used as an indication to generate default file name in the following + // format: "Screen Shot yyyy-mm-dd at HH.MM.SS.png" + const FILENAME_DEFAULT_VALUE = " "; + + /** + * 'screenshot' command + */ + gcli.addCommand({ + name: "screenshot", + description: gcli.lookup("screenshotDesc"), + manual: gcli.lookup("screenshotManual"), + returnType: "html", + params: [ + { + name: "filename", + type: "string", + defaultValue: FILENAME_DEFAULT_VALUE, + description: gcli.lookup("screenshotFilenameDesc"), + manual: gcli.lookup("screenshotFilenameManual") + }, + { + group: gcli.lookup("screenshotGroupOptions"), + params: [ + { + name: "clipboard", + type: "boolean", + description: gcli.lookup("screenshotClipboardDesc"), + manual: gcli.lookup("screenshotClipboardManual") + }, + { + name: "chrome", + type: "boolean", + description: gcli.lookup("screenshotChromeDesc"), + manual: gcli.lookup("screenshotChromeManual") + }, + { + name: "delay", + type: { name: "number", min: 0 }, + defaultValue: 0, + description: gcli.lookup("screenshotDelayDesc"), + manual: gcli.lookup("screenshotDelayManual") + }, + { + name: "fullpage", + type: "boolean", + description: gcli.lookup("screenshotFullPageDesc"), + manual: gcli.lookup("screenshotFullPageManual") + }, + { + name: "selector", + type: "node", + defaultValue: null, + description: gcli.lookup("inspectNodeDesc"), + manual: gcli.lookup("inspectNodeManual") + } + ] + } + ], + exec: function Command_screenshot(args, context) { + if (args.chrome && args.selector) { + // Node screenshot with chrome option does not work as inteded + // Refer https://bugzilla.mozilla.org/show_bug.cgi?id=659268#c7 + // throwing for now. + throw new Error(gcli.lookup("screenshotSelectorChromeConflict")); + } + var document = args.chrome? context.environment.chromeDocument + : context.environment.contentDocument; + if (args.delay > 0) { + var promise = context.createPromise(); + document.defaultView.setTimeout(function Command_screenshotDelay() { + let reply = this.grabScreen(document, args.filename, args.clipboard, + args.fullpage); + promise.resolve(reply); + }.bind(this), args.delay * 1000); + return promise; + } + else { + return this.grabScreen(document, args.filename, args.clipboard, + args.fullpage, args.selector); + } + }, + grabScreen: + function Command_screenshotGrabScreen(document, filename, clipboard, + fullpage, node) { + let window = document.defaultView; + let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); + let left = 0; + let top = 0; + let width; + let height; + let div = document.createElementNS("http://www.w3.org/1999/xhtml", "div"); + + if (!fullpage) { + if (!node) { + left = window.scrollX; + top = window.scrollY; + width = window.innerWidth; + height = window.innerHeight; + } else { + let rect = LayoutHelpers.getRect(node, window); + top = rect.top; + left = rect.left; + width = rect.width; + height = rect.height; + } + } else { + width = window.innerWidth + window.scrollMaxX; + height = window.innerHeight + window.scrollMaxY; + } + canvas.width = width; + canvas.height = height; + + let ctx = canvas.getContext("2d"); + ctx.drawWindow(window, left, top, width, height, "#fff"); + let data = canvas.toDataURL("image/png", ""); + + let loadContext = document.defaultView + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsILoadContext); + + try { + if (clipboard) { + let io = Cc["@mozilla.org/network/io-service;1"] + .getService(Ci.nsIIOService); + let channel = io.newChannel(data, null, null); + let input = channel.open(); + let imgTools = Cc["@mozilla.org/image/tools;1"] + .getService(Ci.imgITools); + + let container = {}; + imgTools.decodeImageData(input, channel.contentType, container); + + let wrapped = Cc["@mozilla.org/supports-interface-pointer;1"] + .createInstance(Ci.nsISupportsInterfacePointer); + wrapped.data = container.value; + + let trans = Cc["@mozilla.org/widget/transferable;1"] + .createInstance(Ci.nsITransferable); + trans.init(loadContext); + trans.addDataFlavor(channel.contentType); + trans.setTransferData(channel.contentType, wrapped, -1); + + let clipid = Ci.nsIClipboard; + let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid); + clip.setData(trans, null, clipid.kGlobalClipboard); + div.textContent = gcli.lookup("screenshotCopied"); + return div; + } + } + catch (ex) { + div.textContent = gcli.lookup("screenshotErrorCopying"); + return div; + } + + let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); + + // Create a name for the file if not present + if (filename == FILENAME_DEFAULT_VALUE) { + let date = new Date(); + let dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + + "-" + date.getDate(); + dateString = dateString.split("-").map(function(part) { + if (part.length == 1) { + part = "0" + part; + } + return part; + }).join("-"); + let timeString = date.toTimeString().replace(/:/g, ".").split(" ")[0]; + filename = gcli.lookupFormat("screenshotGeneratedFilename", + [dateString, timeString]) + ".png"; + } + // Check there is a .png extension to filename + else if (!filename.match(/.png$/i)) { + filename += ".png"; + } + + // If the filename is relative, tack it onto the download directory + if (!filename.match(/[\\\/]/)) { + let downloadMgr = Cc["@mozilla.org/download-manager;1"] + .getService(Ci.nsIDownloadManager); + let tempfile = downloadMgr.userDownloadsDirectory; + tempfile.append(filename); + filename = tempfile.path; + } + + try { + file.initWithPath(filename); + } catch (ex) { + div.textContent = gcli.lookup("screenshotErrorSavingToFile") + " " + filename; + return div; + } + + let ioService = Cc["@mozilla.org/network/io-service;1"] + .getService(Ci.nsIIOService); + + let Persist = Ci.nsIWebBrowserPersist; + let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] + .createInstance(Persist); + persist.persistFlags = Persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES | + Persist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION; + + let source = ioService.newURI(data, "UTF8", null); + persist.saveURI(source, null, null, null, null, file, loadContext); + + div.textContent = gcli.lookup("screenshotSavedToFile") + " \"" + filename + + "\""; + div.addEventListener("click", function openFile() { + div.removeEventListener("click", openFile); + file.reveal(); + }); + div.style.cursor = "pointer"; + let image = document.createElement("div"); + let previewHeight = parseInt(256*height/width); + image.setAttribute("style", + "width:256px; height:" + previewHeight + "px;" + + "max-height: 256px;" + + "background-image: url('" + data + "');" + + "background-size: 256px " + previewHeight + "px;" + + "margin: 4px; display: block"); + div.appendChild(image); + return div; + } + }); +}(this)); diff --git a/browser/devtools/commandline/CmdAddon.jsm b/browser/devtools/commandline/CmdAddon.jsm deleted file mode 100644 index bc1eb2dd28ba..000000000000 --- a/browser/devtools/commandline/CmdAddon.jsm +++ /dev/null @@ -1,297 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ "Flags" ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", - "resource://gre/modules/AddonManager.jsm"); - -// We need to use an object in which to store any flags because a primitive -// would remain undefined. -this.Flags = { - addonsLoaded: false -}; - -/** - * 'addon' command. - */ -gcli.addCommand({ - name: "addon", - description: gcli.lookup("addonDesc") -}); - -/** - * 'addon list' command. - */ -gcli.addCommand({ - name: "addon list", - description: gcli.lookup("addonListDesc"), - params: [{ - name: 'type', - type: { - name: 'selection', - data: ["dictionary", "extension", "locale", "plugin", "theme", "all"] - }, - defaultValue: 'all', - description: gcli.lookup("addonListTypeDesc"), - }], - exec: function(aArgs, context) { - function representEnabledAddon(aAddon) { - return "
  • "; - } - - function representDisabledAddon(aAddon) { - return "
  • " + - "
  • "; - } - - function getAddonStatus(aAddon) { - let operations = []; - - if (aAddon.pendingOperations & AddonManager.PENDING_ENABLE) { - operations.push("PENDING_ENABLE"); - } - - if (aAddon.pendingOperations & AddonManager.PENDING_DISABLE) { - operations.push("PENDING_DISABLE"); - } - - if (aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL) { - operations.push("PENDING_UNINSTALL"); - } - - if (aAddon.pendingOperations & AddonManager.PENDING_INSTALL) { - operations.push("PENDING_INSTALL"); - } - - if (aAddon.pendingOperations & AddonManager.PENDING_UPGRADE) { - operations.push("PENDING_UPGRADE"); - } - - if (operations.length) { - return " (" + operations.join(", ") + ")"; - } - return ""; - } - - /** - * Compares two addons by their name. Used in sorting. - */ - function compareAddonNames(aNameA, aNameB) { - return String.localeCompare(aNameA.name, aNameB.name); - } - - /** - * Resolves the promise which is the scope (this) of this function, filling - * it with an HTML representation of the passed add-ons. - */ - function list(aType, aAddons) { - if (!aAddons.length) { - this.resolve(gcli.lookup("addonNoneOfType")); - } - - // Separate the enabled add-ons from the disabled ones. - let enabledAddons = []; - let disabledAddons = []; - - aAddons.forEach(function(aAddon) { - if (aAddon.isActive) { - enabledAddons.push(aAddon); - } else { - disabledAddons.push(aAddon); - } - }); - - let header; - switch(aType) { - case "dictionary": - header = gcli.lookup("addonListDictionaryHeading"); - break; - case "extension": - header = gcli.lookup("addonListExtensionHeading"); - break; - case "locale": - header = gcli.lookup("addonListLocaleHeading"); - break; - case "plugin": - header = gcli.lookup("addonListPluginHeading"); - break; - case "theme": - header = gcli.lookup("addonListThemeHeading"); - case "all": - header = gcli.lookup("addonListAllHeading"); - break; - default: - header = gcli.lookup("addonListUnknownHeading"); - } - - // Map and sort the add-ons, and create an HTML list. - let message = header + - "
      " + - enabledAddons.sort(compareAddonNames).map(representEnabledAddon).join("") + - disabledAddons.sort(compareAddonNames).map(representDisabledAddon).join("") + - "
    "; - - this.resolve(context.createView({ html: message })); - } - - // Create the promise that will be resolved when the add-on listing has - // been finished. - let promise = context.createPromise(); - let types = aArgs.type == "all" ? null : [aArgs.type]; - AddonManager.getAddonsByTypes(types, list.bind(promise, aArgs.type)); - return promise; - } -}); - -// We need a list of addon names for the enable and disable commands. Because -// getting the name list is async we do not add the commands until we have the -// list. -AddonManager.getAllAddons(function addonAsync(aAddons) { - // We listen for installs to keep our addon list up to date. There is no need - // to listen for uninstalls because uninstalled addons are simply disabled - // until restart (to enable undo functionality). - AddonManager.addAddonListener({ - onInstalled: function(aAddon) { - addonNameCache.push({ - name: representAddon(aAddon).replace(/\s/g, "_"), - value: aAddon.name - }); - }, - onUninstalled: function(aAddon) { - let name = representAddon(aAddon).replace(/\s/g, "_"); - - for (let i = 0; i < addonNameCache.length; i++) { - if(addonNameCache[i].name == name) { - addonNameCache.splice(i, 1); - break; - } - } - }, - }); - - /** - * Returns a string that represents the passed add-on. - */ - function representAddon(aAddon) { - let name = aAddon.name + " " + aAddon.version; - return name.trim(); - } - - let addonNameCache = []; - - // The name parameter, used in "addon enable" and "addon disable." - let nameParameter = { - name: "name", - type: { - name: "selection", - lookup: addonNameCache - }, - description: gcli.lookup("addonNameDesc") - }; - - for (let addon of aAddons) { - addonNameCache.push({ - name: representAddon(addon).replace(/\s/g, "_"), - value: addon.name - }); - } - - /** - * 'addon enable' command. - */ - gcli.addCommand({ - name: "addon enable", - description: gcli.lookup("addonEnableDesc"), - params: [nameParameter], - exec: function(aArgs, context) { - /** - * Enables the addon in the passed list which has a name that matches - * according to the passed name comparer, and resolves the promise which - * is the scope (this) of this function to display the result of this - * enable attempt. - */ - function enable(aName, addons) { - // Find the add-on. - let addon = null; - addons.some(function(candidate) { - if (candidate.name == aName) { - addon = candidate; - return true; - } else { - return false; - } - }); - - let name = representAddon(addon); - let message = ""; - - if (!addon.userDisabled) { - message = gcli.lookupFormat("addonAlreadyEnabled", [name]); - } else { - addon.userDisabled = false; - message = gcli.lookupFormat("addonEnabled", [name]); - } - this.resolve(message); - } - - let promise = context.createPromise(); - // List the installed add-ons, enable one when done listing. - AddonManager.getAllAddons(enable.bind(promise, aArgs.name)); - return promise; - } - }); - - /** - * 'addon disable' command. - */ - gcli.addCommand({ - name: "addon disable", - description: gcli.lookup("addonDisableDesc"), - params: [nameParameter], - exec: function(aArgs, context) { - /** - * Like enable, but ... you know ... the exact opposite. - */ - function disable(aName, addons) { - // Find the add-on. - let addon = null; - addons.some(function(candidate) { - if (candidate.name == aName) { - addon = candidate; - return true; - } else { - return false; - } - }); - - let name = representAddon(addon); - let message = ""; - - if (addon.userDisabled) { - message = gcli.lookupFormat("addonAlreadyDisabled", [name]); - } else { - addon.userDisabled = true; - message = gcli.lookupFormat("addonDisabled", [name]); - } - this.resolve(message); - } - - let promise = context.createPromise(); - // List the installed add-ons, disable one when done listing. - AddonManager.getAllAddons(disable.bind(promise, aArgs.name)); - return promise; - } - }); - Flags.addonsLoaded = true; - Services.obs.notifyObservers(null, "gcli_addon_commands_ready", null); -}); diff --git a/browser/devtools/commandline/CmdBreak.jsm b/browser/devtools/commandline/CmdBreak.jsm deleted file mode 100644 index 6f3b6bffcf1d..000000000000 --- a/browser/devtools/commandline/CmdBreak.jsm +++ /dev/null @@ -1,184 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "HUDService", - "resource:///modules/HUDService.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", - "resource:///modules/devtools/Target.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", - "resource:///modules/devtools/gDevTools.jsm"); - -/** - * 'break' command - */ -gcli.addCommand({ - name: "break", - description: gcli.lookup("breakDesc"), - manual: gcli.lookup("breakManual") -}); - -/** - * 'break list' command - */ -gcli.addCommand({ - name: "break list", - description: gcli.lookup("breaklistDesc"), - returnType: "html", - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let breakpoints = dbg.getAllBreakpoints(); - - if (Object.keys(breakpoints).length === 0) { - return gcli.lookup("breaklistNone"); - } - - let reply = gcli.lookup("breaklistIntro"); - reply += "
      "; - for each (let breakpoint in breakpoints) { - let text = gcli.lookupFormat("breaklistLineEntry", - [breakpoint.location.url, - breakpoint.location.line]); - reply += "
    1. " + text + "
    2. "; - }; - reply += "
    "; - return reply; - } -}); - -/** - * 'break add' command - */ -gcli.addCommand({ - name: "break add", - description: gcli.lookup("breakaddDesc"), - manual: gcli.lookup("breakaddManual") -}); - -/** - * 'break add line' command - */ -gcli.addCommand({ - name: "break add line", - description: gcli.lookup("breakaddlineDesc"), - params: [ - { - name: "file", - type: { - name: "selection", - data: function(args, context) { - let files = []; - let dbg = getPanel(context, "jsdebugger"); - if (dbg) { - let sourcesView = dbg.panelWin.DebuggerView.Sources; - for (let item in sourcesView) { - files.push(item.value); - } - } - return files; - } - }, - description: gcli.lookup("breakaddlineFileDesc") - }, - { - name: "line", - type: { name: "number", min: 1, step: 10 }, - description: gcli.lookup("breakaddlineLineDesc") - } - ], - returnType: "html", - exec: function(args, context) { - args.type = "line"; - - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - var deferred = context.defer(); - let position = { url: args.file, line: args.line }; - dbg.addBreakpoint(position, function(aBreakpoint, aError) { - if (aError) { - deferred.resolve(gcli.lookupFormat("breakaddFailed", [aError])); - return; - } - deferred.resolve(gcli.lookup("breakaddAdded")); - }); - return deferred.promise; - } -}); - - -/** - * 'break del' command - */ -gcli.addCommand({ - name: "break del", - description: gcli.lookup("breakdelDesc"), - params: [ - { - name: "breakid", - type: { - name: "number", - min: 0, - max: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - return dbg == null ? - null : - Object.keys(dbg.getAllBreakpoints()).length - 1; - }, - }, - description: gcli.lookup("breakdelBreakidDesc") - } - ], - returnType: "html", - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let breakpoints = dbg.getAllBreakpoints(); - let id = Object.keys(breakpoints)[args.breakid]; - if (!id || !(id in breakpoints)) { - return gcli.lookup("breakNotFound"); - } - - let deferred = context.defer(); - try { - dbg.removeBreakpoint(breakpoints[id], function() { - deferred.resolve(gcli.lookup("breakdelRemoved")); - }); - } catch (ex) { - // If the debugger has been closed already, don't scare the user. - deferred.resolve(gcli.lookup("breakdelRemoved")); - } - return deferred.promise; - } -}); - -/** - * A helper to go from a command context to a debugger panel - */ -function getPanel(context, id) { - if (context == null) { - return undefined; - } - - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - let toolbox = gDevTools.getToolbox(target); - return toolbox == null ? undefined : toolbox.getPanel(id); -} diff --git a/browser/devtools/commandline/CmdCalllog.jsm b/browser/devtools/commandline/CmdCalllog.jsm deleted file mode 100644 index 7c8f83997b95..000000000000 --- a/browser/devtools/commandline/CmdCalllog.jsm +++ /dev/null @@ -1,107 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", - "resource:///modules/devtools/gDevTools.jsm"); - -XPCOMUtils.defineLazyGetter(this, "Debugger", function() { - let JsDebugger = {}; - Components.utils.import("resource://gre/modules/jsdebugger.jsm", JsDebugger); - - let global = Components.utils.getGlobalForObject({}); - JsDebugger.addDebuggerToGlobal(global); - - return global.Debugger; -}); - -XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", - "resource:///modules/devtools/Target.jsm"); - -let debuggers = []; - -/** - * 'calllog' command - */ -gcli.addCommand({ - name: "calllog", - description: gcli.lookup("calllogDesc") -}) - -/** - * 'calllog start' command - */ -gcli.addCommand({ - name: "calllog start", - description: gcli.lookup("calllogStartDesc"), - - exec: function(args, context) { - let contentWindow = context.environment.contentDocument.defaultView; - - let dbg = new Debugger(contentWindow); - dbg.onEnterFrame = function(frame) { - // BUG 773652 - Make the output from the GCLI calllog command nicer - contentWindow.console.log("Method call: " + this.callDescription(frame)); - }.bind(this); - - debuggers.push(dbg); - - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "webconsole"); - - return gcli.lookup("calllogStartReply"); - }, - - callDescription: function(frame) { - let name = ""; - if (frame.callee.name) { - name = frame.callee.name; - } - else { - let desc = frame.callee.getOwnPropertyDescriptor("displayName"); - if (desc && desc.value && typeof desc.value == "string") { - name = desc.value; - } - } - - let args = frame.arguments.map(this.valueToString).join(", "); - return name + "(" + args + ")"; - }, - - valueToString: function(value) { - if (typeof value !== "object" || value === null) { - return uneval(value); - } - return "[object " + value.class + "]"; - } -}); - -/** - * 'calllog stop' command - */ -gcli.addCommand({ - name: "calllog stop", - description: gcli.lookup("calllogStopDesc"), - - exec: function(args, context) { - let numDebuggers = debuggers.length; - if (numDebuggers == 0) { - return gcli.lookup("calllogStopNoLogging"); - } - - for (let dbg of debuggers) { - dbg.onEnterFrame = undefined; - } - debuggers = []; - - return gcli.lookupFormat("calllogStopReply", [ numDebuggers ]); - } -}); diff --git a/browser/devtools/commandline/CmdCalllogChrome.jsm b/browser/devtools/commandline/CmdCalllogChrome.jsm deleted file mode 100644 index 599e49133503..000000000000 --- a/browser/devtools/commandline/CmdCalllogChrome.jsm +++ /dev/null @@ -1,158 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - -this.EXPORTED_SYMBOLS = [ ]; - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", - "resource:///modules/devtools/gDevTools.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", - "resource:///modules/devtools/Target.jsm"); - -XPCOMUtils.defineLazyGetter(this, "Debugger", function() { - let JsDebugger = {}; - Cu.import("resource://gre/modules/jsdebugger.jsm", JsDebugger); - - let global = Components.utils.getGlobalForObject({}); - JsDebugger.addDebuggerToGlobal(global); - - return global.Debugger; -}); - -let debuggers = []; -let sandboxes = []; - -/** - * 'calllog chromestart' command - */ -gcli.addCommand({ - name: "calllog chromestart", - description: gcli.lookup("calllogChromeStartDesc"), - get hidden() gcli.hiddenByChromePref(), - params: [ - { - name: "sourceType", - type: { - name: "selection", - data: ["content-variable", "chrome-variable", "jsm", "javascript"] - } - }, - { - name: "source", - type: "string", - description: gcli.lookup("calllogChromeSourceTypeDesc"), - manual: gcli.lookup("calllogChromeSourceTypeManual"), - } - ], - exec: function(args, context) { - let globalObj; - let contentWindow = context.environment.contentDocument.defaultView; - - if (args.sourceType == "jsm") { - try { - globalObj = Cu.import(args.source); - } - catch (e) { - return gcli.lookup("callLogChromeInvalidJSM"); - } - } else if (args.sourceType == "content-variable") { - if (args.source in contentWindow) { - globalObj = Cu.getGlobalForObject(contentWindow[args.source]); - } else { - throw new Error(gcli.lookup("callLogChromeVarNotFoundContent")); - } - } else if (args.sourceType == "chrome-variable") { - let chromeWin = context.environment.chromeDocument.defaultView; - if (args.source in chromeWin) { - globalObj = Cu.getGlobalForObject(chromeWin[args.source]); - } else { - return gcli.lookup("callLogChromeVarNotFoundChrome"); - } - } else { - let chromeWin = context.environment.chromeDocument.defaultView; - let sandbox = new Cu.Sandbox(chromeWin, - { - sandboxPrototype: chromeWin, - wantXrays: false, - sandboxName: "gcli-cmd-calllog-chrome" - }); - let returnVal; - try { - returnVal = Cu.evalInSandbox(args.source, sandbox, "ECMAv5"); - sandboxes.push(sandbox); - } catch(e) { - // We need to save the message before cleaning up else e contains a dead - // object. - let msg = gcli.lookup("callLogChromeEvalException") + ": " + e; - Cu.nukeSandbox(sandbox); - return msg; - } - - if (typeof returnVal == "undefined") { - return gcli.lookup("callLogChromeEvalNeedsObject"); - } - - globalObj = Cu.getGlobalForObject(returnVal); - } - - let dbg = new Debugger(globalObj); - debuggers.push(dbg); - - dbg.onEnterFrame = function(frame) { - // BUG 773652 - Make the output from the GCLI calllog command nicer - contentWindow.console.log(gcli.lookup("callLogChromeMethodCall") + - ": " + this.callDescription(frame)); - }.bind(this); - - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.showToolbox(target, "webconsole"); - - return gcli.lookup("calllogChromeStartReply"); - }, - - valueToString: function(value) { - if (typeof value !== "object" || value === null) - return uneval(value); - return "[object " + value.class + "]"; - }, - - callDescription: function(frame) { - let name = frame.callee.name || gcli.lookup("callLogChromeAnonFunction"); - let args = frame.arguments.map(this.valueToString).join(", "); - return name + "(" + args + ")"; - } -}); - -/** - * 'calllog chromestop' command - */ -gcli.addCommand({ - name: "calllog chromestop", - description: gcli.lookup("calllogChromeStopDesc"), - get hidden() gcli.hiddenByChromePref(), - exec: function(args, context) { - let numDebuggers = debuggers.length; - if (numDebuggers == 0) { - return gcli.lookup("calllogChromeStopNoLogging"); - } - - for (let dbg of debuggers) { - dbg.onEnterFrame = undefined; - dbg.enabled = false; - } - for (let sandbox of sandboxes) { - Cu.nukeSandbox(sandbox); - } - debuggers = []; - sandboxes = []; - - return gcli.lookupFormat("calllogChromeStopReply", [ numDebuggers ]); - } -}); diff --git a/browser/devtools/commandline/CmdCmd.jsm b/browser/devtools/commandline/CmdCmd.jsm deleted file mode 100644 index 50f8a3aa0997..000000000000 --- a/browser/devtools/commandline/CmdCmd.jsm +++ /dev/null @@ -1,129 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -this.EXPORTED_SYMBOLS = [ "CmdCommands" ]; - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -let prefSvc = "@mozilla.org/preferences-service;1"; -XPCOMUtils.defineLazyGetter(this, "prefBranch", function() { - let prefService = Cc[prefSvc].getService(Ci.nsIPrefService); - return prefService.getBranch(null).QueryInterface(Ci.nsIPrefBranch2); -}); - -XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", - "resource://gre/modules/NetUtil.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "console", - "resource://gre/modules/devtools/Console.jsm"); - -const PREF_DIR = "devtools.commands.dir"; - -/** - * A place to store the names of the commands that we have added as a result of - * calling refreshAutoCommands(). Used by refreshAutoCommands to remove the - * added commands. - */ -let commands = []; - -/** - * Exported API - */ -this.CmdCommands = { - /** - * Called to look in a directory pointed at by the devtools.commands.dir pref - * for *.mozcmd files which are then loaded. - * @param nsIPrincipal aSandboxPrincipal Scope object for the Sandbox in which - * we eval the script from the .mozcmd file. This should be a chrome window. - */ - refreshAutoCommands: function GC_refreshAutoCommands(aSandboxPrincipal) { - // First get rid of the last set of commands - commands.forEach(function(name) { - gcli.removeCommand(name); - }); - - let dirName = prefBranch.getComplexValue(PREF_DIR, - Ci.nsISupportsString).data.trim(); - if (dirName == "") { - return; - } - - let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); - dir.initWithPath(dirName); - if (!dir.exists() || !dir.isDirectory()) { - throw new Error('\'' + dirName + '\' is not a directory.'); - } - - let en = dir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator); - - while (true) { - let file = en.nextFile; - if (!file) { - break; - } - if (file.leafName.match(/.*\.mozcmd$/) && file.isFile() && file.isReadable()) { - loadCommandFile(file, aSandboxPrincipal); - } - } - }, -}; - -/** - * Load the commands from a single file - * @param nsIFile aFile The file containing the commands that we should read - * @param nsIPrincipal aSandboxPrincipal Scope object for the Sandbox in which - * we eval the script from the .mozcmd file. This should be a chrome window. - */ -function loadCommandFile(aFile, aSandboxPrincipal) { - NetUtil.asyncFetch(aFile, function refresh_fetch(aStream, aStatus) { - if (!Components.isSuccessCode(aStatus)) { - console.error("NetUtil.asyncFetch(" + aFile.path + ",..) failed. Status=" + aStatus); - return; - } - - let source = NetUtil.readInputStreamToString(aStream, aStream.available()); - aStream.close(); - - let sandbox = new Cu.Sandbox(aSandboxPrincipal, { - sandboxPrototype: aSandboxPrincipal, - wantXrays: false, - sandboxName: aFile.path - }); - let data = Cu.evalInSandbox(source, sandbox, "1.8", aFile.leafName, 1); - - if (!Array.isArray(data)) { - console.error("Command file '" + aFile.leafName + "' does not have top level array."); - return; - } - - data.forEach(function(commandSpec) { - gcli.addCommand(commandSpec); - commands.push(commandSpec.name); - }); - }.bind(this)); -} - -/** - * 'cmd' command - */ -gcli.addCommand({ - name: "cmd", - get hidden() { return !prefBranch.prefHasUserValue(PREF_DIR); }, - description: gcli.lookup("cmdDesc") -}); - -/** - * 'cmd refresh' command - */ -gcli.addCommand({ - name: "cmd refresh", - description: gcli.lookup("cmdRefreshDesc"), - get hidden() { return !prefBranch.prefHasUserValue(PREF_DIR); }, - exec: function Command_cmdRefresh(args, context) { - let chromeWindow = context.environment.chromeDocument.defaultView; - CmdCommands.refreshAutoCommands(chromeWindow); - } -}); diff --git a/browser/devtools/commandline/CmdConsole.jsm b/browser/devtools/commandline/CmdConsole.jsm deleted file mode 100644 index bf76065080a8..000000000000 --- a/browser/devtools/commandline/CmdConsole.jsm +++ /dev/null @@ -1,68 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "HUDService", - "resource:///modules/HUDService.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", - "resource:///modules/devtools/gDevTools.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", - "resource:///modules/devtools/Target.jsm"); - -/** - * 'console' command - */ -gcli.addCommand({ - name: "console", - description: gcli.lookup("consoleDesc"), - manual: gcli.lookup("consoleManual") -}); - -/** - * 'console clear' command - */ -gcli.addCommand({ - name: "console clear", - description: gcli.lookup("consoleclearDesc"), - exec: function Command_consoleClear(args, context) { - let window = context.environment.contentDocument.defaultView; - let hud = HUDService.getHudByWindow(window); - // hud will be null if the web console has not been opened for this window - if (hud) { - hud.jsterm.clearOutput(); - } - } -}); - -/** - * 'console close' command - */ -gcli.addCommand({ - name: "console close", - description: gcli.lookup("consolecloseDesc"), - exec: function Command_consoleClose(args, context) { - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - return gDevTools.closeToolbox(target); - } -}); - -/** - * 'console open' command - */ -gcli.addCommand({ - name: "console open", - description: gcli.lookup("consoleopenDesc"), - exec: function Command_consoleOpen(args, context) { - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - return gDevTools.showToolbox(target, "webconsole"); - } -}); diff --git a/browser/devtools/commandline/CmdCookie.jsm b/browser/devtools/commandline/CmdCookie.jsm deleted file mode 100644 index 88bd1b92c4b5..000000000000 --- a/browser/devtools/commandline/CmdCookie.jsm +++ /dev/null @@ -1,207 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "console", - "resource://gre/modules/devtools/Console.jsm"); - -// We should really be using nsICookieManager so we can read more than just the -// key/value of cookies. The difficulty is filtering the cookies that are -// relevant to the current page. See -// https://github.com/firebug/firebug/blob/master/extension/content/firebug/cookies/cookieObserver.js#L123 -// For details on how this is done with Firebug - -/** - * 'cookie' command - */ -gcli.addCommand({ - name: "cookie", - description: gcli.lookup("cookieDesc"), - manual: gcli.lookup("cookieManual") -}); - -/** - * The template for the 'cookie list' command. - */ -var cookieListHtml = "" + - "" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - "
    " + gcli.lookup("cookieListOutKey") + "" + gcli.lookup("cookieListOutValue") + "" + gcli.lookup("cookieListOutActions") + "
    ${cookie.key}${cookie.value}" + - " " + gcli.lookup("cookieListOutEdit") + "" + - " " + gcli.lookup("cookieListOutRemove") + "" + - "
    " + - ""; - -/** - * 'cookie list' command - */ -gcli.addCommand({ - name: "cookie list", - description: gcli.lookup("cookieListDesc"), - manual: gcli.lookup("cookieListManual"), - returnType: "string", - exec: function Command_cookieList(args, context) { - // Parse out an array of { key:..., value:... } objects for each cookie - var doc = context.environment.contentDocument; - var cookies = doc.cookie.split("; ").map(function(cookieStr) { - var equalsPos = cookieStr.indexOf("="); - return { - key: cookieStr.substring(0, equalsPos), - value: cookieStr.substring(equalsPos + 1) - }; - }); - - return context.createView({ - html: cookieListHtml, - data: { - cookies: cookies, - onclick: createUpdateHandler(context), - ondblclick: createExecuteHandler(context), - } - }); - } -}); - -/** - * 'cookie remove' command - */ -gcli.addCommand({ - name: "cookie remove", - description: gcli.lookup("cookieRemoveDesc"), - manual: gcli.lookup("cookieRemoveManual"), - params: [ - { - name: "key", - type: "string", - description: gcli.lookup("cookieRemoveKeyDesc"), - } - ], - exec: function Command_cookieRemove(args, context) { - let document = context.environment.contentDocument; - let expDate = new Date(); - expDate.setDate(expDate.getDate() - 1); - document.cookie = escape(args.key) + "=; expires=" + expDate.toGMTString(); - } -}); - -/** - * 'cookie set' command - */ -gcli.addCommand({ - name: "cookie set", - description: gcli.lookup("cookieSetDesc"), - manual: gcli.lookup("cookieSetManual"), - params: [ - { - name: "key", - type: "string", - description: gcli.lookup("cookieSetKeyDesc") - }, - { - name: "value", - type: "string", - description: gcli.lookup("cookieSetValueDesc") - }, - { - group: gcli.lookup("cookieSetOptionsDesc"), - params: [ - { - name: "path", - type: "string", - defaultValue: "/", - description: gcli.lookup("cookieSetPathDesc") - }, - { - name: "domain", - type: "string", - defaultValue: null, - description: gcli.lookup("cookieSetDomainDesc") - }, - { - name: "secure", - type: "boolean", - description: gcli.lookup("cookieSetSecureDesc") - } - ] - } - ], - exec: function Command_cookieSet(args, context) { - let document = context.environment.contentDocument; - - document.cookie = escape(args.key) + "=" + escape(args.value) + - (args.domain ? "; domain=" + args.domain : "") + - (args.path ? "; path=" + args.path : "") + - (args.secure ? "; secure" : ""); - } -}); - -/** - * Helper to find the 'data-command' attribute and call some action on it. - * @see |updateCommand()| and |executeCommand()| - */ -function withCommand(element, action) { - var command = element.getAttribute("data-command"); - if (!command) { - command = element.querySelector("*[data-command]") - .getAttribute("data-command"); - } - - if (command) { - action(command); - } - else { - console.warn("Missing data-command for " + util.findCssSelector(element)); - } -} - -/** - * Create a handler to update the requisition to contain the text held in the - * first matching data-command attribute under the currentTarget of the event. - * @param context Either a Requisition or an ExecutionContext or another object - * that contains an |update()| function that follows a similar contract. - */ -function createUpdateHandler(context) { - return function(ev) { - withCommand(ev.currentTarget, function(command) { - context.update(command); - }); - } -} - -/** - * Create a handler to execute the text held in the data-command attribute - * under the currentTarget of the event. - * @param context Either a Requisition or an ExecutionContext or another object - * that contains an |update()| function that follows a similar contract. - */ -function createExecuteHandler(context) { - return function(ev) { - withCommand(ev.currentTarget, function(command) { - context.exec({ - visible: true, - typed: command - }); - }); - } -} diff --git a/browser/devtools/commandline/CmdDbg.jsm b/browser/devtools/commandline/CmdDbg.jsm deleted file mode 100644 index 2450ca1c1721..000000000000 --- a/browser/devtools/commandline/CmdDbg.jsm +++ /dev/null @@ -1,176 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "gDevTools", - "resource:///modules/devtools/gDevTools.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory", - "resource:///modules/devtools/Target.jsm"); - -/** - * 'dbg' command - */ -gcli.addCommand({ - name: "dbg", - description: gcli.lookup("dbgDesc"), - manual: gcli.lookup("dbgManual") -}); - -/** - * 'dbg open' command - */ -gcli.addCommand({ - name: "dbg open", - description: gcli.lookup("dbgOpen"), - params: [], - exec: function (args, context) { - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - return gDevTools.showToolbox(target, "jsdebugger"); - } -}); - -/** - * 'dbg close' command - */ -gcli.addCommand({ - name: "dbg close", - description: gcli.lookup("dbgClose"), - params: [], - exec: function (args, context) { - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - return gDevTools.closeToolbox(target); - } -}); - -/** - * 'dbg interrupt' command - */ -gcli.addCommand({ - name: "dbg interrupt", - description: gcli.lookup("dbgInterrupt"), - params: [], - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let controller = dbg._controller; - let thread = controller.activeThread; - if (!thread.paused) { - thread.interrupt(); - } - } -}); - -/** - * 'dbg continue' command - */ -gcli.addCommand({ - name: "dbg continue", - description: gcli.lookup("dbgContinue"), - params: [], - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let controller = dbg._controller; - let thread = controller.activeThread; - if (thread.paused) { - thread.resume(); - } - } -}); - -/** - * 'dbg step' command - */ -gcli.addCommand({ - name: "dbg step", - description: gcli.lookup("dbgStepDesc"), - manual: gcli.lookup("dbgStepManual") -}); - -/** - * 'dbg step over' command - */ -gcli.addCommand({ - name: "dbg step over", - description: gcli.lookup("dbgStepOverDesc"), - params: [], - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let controller = dbg._controller; - let thread = controller.activeThread; - if (thread.paused) { - thread.stepOver(); - } - } -}); - -/** - * 'dbg step in' command - */ -gcli.addCommand({ - name: 'dbg step in', - description: gcli.lookup("dbgStepInDesc"), - params: [], - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let controller = dbg._controller; - let thread = controller.activeThread; - if (thread.paused) { - thread.stepIn(); - } - } -}); - -/** - * 'dbg step over' command - */ -gcli.addCommand({ - name: 'dbg step out', - description: gcli.lookup("dbgStepOutDesc"), - params: [], - exec: function(args, context) { - let dbg = getPanel(context, "jsdebugger"); - if (!dbg) { - return gcli.lookup("debuggerStopped"); - } - - let controller = dbg._controller; - let thread = controller.activeThread; - if (thread.paused) { - thread.stepOut(); - } - } -}); - -/** - * A helper to go from a command context to a debugger panel - */ -function getPanel(context, id) { - let gBrowser = context.environment.chromeDocument.defaultView.gBrowser; - let target = TargetFactory.forTab(gBrowser.selectedTab); - let toolbox = gDevTools.getToolbox(target); - return toolbox == null ? undefined : toolbox.getPanel(id); -} diff --git a/browser/devtools/commandline/CmdEcho.jsm b/browser/devtools/commandline/CmdEcho.jsm deleted file mode 100644 index 607ee1d7b11e..000000000000 --- a/browser/devtools/commandline/CmdEcho.jsm +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); - -/** - * 'echo' command - */ -gcli.addCommand({ - name: "echo", - description: gcli.lookup("echoDesc"), - params: [ - { - name: "message", - type: "string", - description: gcli.lookup("echoMessageDesc") - } - ], - returnType: "string", - hidden: true, - exec: function Command_echo(args, context) { - return args.message; - } -}); diff --git a/browser/devtools/commandline/CmdExport.jsm b/browser/devtools/commandline/CmdExport.jsm deleted file mode 100644 index 175f294a8b29..000000000000 --- a/browser/devtools/commandline/CmdExport.jsm +++ /dev/null @@ -1,32 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); - -/** - * 'export' command - */ -gcli.addCommand({ - name: "export", - description: gcli.lookup("exportDesc"), -}); - -/** - * The 'export html' command. This command allows the user to export the page to - * HTML after they do DOM changes. - */ -gcli.addCommand({ - name: "export html", - description: gcli.lookup("exportHtmlDesc"), - exec: function(args, context) { - let document = context.environment.contentDocument; - let window = document.defaultView; - let page = document.documentElement.outerHTML; - window.open('data:text/plain;charset=utf8,' + encodeURIComponent(page)); - } -}); diff --git a/browser/devtools/commandline/CmdJsb.jsm b/browser/devtools/commandline/CmdJsb.jsm deleted file mode 100644 index 5a31f500fcb1..000000000000 --- a/browser/devtools/commandline/CmdJsb.jsm +++ /dev/null @@ -1,138 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; -const XMLHttpRequest = - Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1"); - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource:///modules/devtools/gcli.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "js_beautify", - "resource:///modules/devtools/Jsbeautify.jsm"); - -/** - * jsb command. - */ -gcli.addCommand({ - name: 'jsb', - description: gcli.lookup('jsbDesc'), - returnValue:'string', - params: [ - { - name: 'url', - type: 'string', - description: gcli.lookup('jsbUrlDesc') - }, - { - group: gcli.lookup("jsbOptionsDesc"), - params: [ - { - name: 'indentSize', - type: 'number', - description: gcli.lookup('jsbIndentSizeDesc'), - manual: gcli.lookup('jsbIndentSizeManual'), - defaultValue: 2 - }, - { - name: 'indentChar', - type: { - name: 'selection', - lookup: [ - { name: "space", value: " " }, - { name: "tab", value: "\t" } - ] - }, - description: gcli.lookup('jsbIndentCharDesc'), - manual: gcli.lookup('jsbIndentCharManual'), - defaultValue: ' ', - }, - { - name: 'doNotPreserveNewlines', - type: 'boolean', - description: gcli.lookup('jsbDoNotPreserveNewlinesDesc') - }, - { - name: 'preserveMaxNewlines', - type: 'number', - description: gcli.lookup('jsbPreserveMaxNewlinesDesc'), - manual: gcli.lookup('jsbPreserveMaxNewlinesManual'), - defaultValue: -1 - }, - { - name: 'jslintHappy', - type: 'boolean', - description: gcli.lookup('jsbJslintHappyDesc'), - manual: gcli.lookup('jsbJslintHappyManual') - }, - { - name: 'braceStyle', - type: { - name: 'selection', - data: ['collapse', 'expand', 'end-expand', 'expand-strict'] - }, - description: gcli.lookup('jsbBraceStyleDesc'), - manual: gcli.lookup('jsbBraceStyleManual'), - defaultValue: "collapse" - }, - { - name: 'noSpaceBeforeConditional', - type: 'boolean', - description: gcli.lookup('jsbNoSpaceBeforeConditionalDesc') - }, - { - name: 'unescapeStrings', - type: 'boolean', - description: gcli.lookup('jsbUnescapeStringsDesc'), - manual: gcli.lookup('jsbUnescapeStringsManual') - } - ] - } - ], - exec: function(args, context) { - let opts = { - indent_size: args.indentSize, - indent_char: args.indentChar, - preserve_newlines: !args.doNotPreserveNewlines, - max_preserve_newlines: args.preserveMaxNewlines == -1 ? - undefined : args.preserveMaxNewlines, - jslint_happy: args.jslintHappy, - brace_style: args.braceStyle, - space_before_conditional: !args.noSpaceBeforeConditional, - unescape_strings: args.unescapeStrings - }; - - let xhr = new XMLHttpRequest(); - - try { - xhr.open("GET", args.url, true); - } catch(e) { - return gcli.lookup('jsbInvalidURL'); - } - - let promise = context.createPromise(); - - xhr.onreadystatechange = function(aEvt) { - if (xhr.readyState == 4) { - if (xhr.status == 200 || xhr.status == 0) { - let browserDoc = context.environment.chromeDocument; - let browserWindow = browserDoc.defaultView; - let gBrowser = browserWindow.gBrowser; - let result = js_beautify(xhr.responseText, opts); - - browserWindow.Scratchpad.ScratchpadManager.openScratchpad({text: result}); - - promise.resolve(); - } else { - promise.resolve("Unable to load page to beautify: " + args.url + " " + - xhr.status + " " + xhr.statusText); - } - }; - } - xhr.send(null); - return promise; - } -}); diff --git a/browser/devtools/commandline/CmdPagemod.jsm b/browser/devtools/commandline/CmdPagemod.jsm deleted file mode 100644 index e65d2bcd75f4..000000000000 --- a/browser/devtools/commandline/CmdPagemod.jsm +++ /dev/null @@ -1,264 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); - -/** - * 'pagemod' command - */ -gcli.addCommand({ - name: "pagemod", - description: gcli.lookup("pagemodDesc"), -}); - -/** - * The 'pagemod replace' command. This command allows the user to search and - * replace within text nodes and attributes. - */ -gcli.addCommand({ - name: "pagemod replace", - description: gcli.lookup("pagemodReplaceDesc"), - params: [ - { - name: "search", - type: "string", - description: gcli.lookup("pagemodReplaceSearchDesc"), - }, - { - name: "replace", - type: "string", - description: gcli.lookup("pagemodReplaceReplaceDesc"), - }, - { - name: "ignoreCase", - type: "boolean", - description: gcli.lookup("pagemodReplaceIgnoreCaseDesc"), - }, - { - name: "selector", - type: "string", - description: gcli.lookup("pagemodReplaceSelectorDesc"), - defaultValue: "*:not(script):not(style):not(embed):not(object):not(frame):not(iframe):not(frameset)", - }, - { - name: "root", - type: "node", - description: gcli.lookup("pagemodReplaceRootDesc"), - defaultValue: null, - }, - { - name: "attrOnly", - type: "boolean", - description: gcli.lookup("pagemodReplaceAttrOnlyDesc"), - }, - { - name: "contentOnly", - type: "boolean", - description: gcli.lookup("pagemodReplaceContentOnlyDesc"), - }, - { - name: "attributes", - type: "string", - description: gcli.lookup("pagemodReplaceAttributesDesc"), - defaultValue: null, - }, - ], - exec: function(args, context) { - let document = context.environment.contentDocument; - let searchTextNodes = !args.attrOnly; - let searchAttributes = !args.contentOnly; - let regexOptions = args.ignoreCase ? 'ig' : 'g'; - let search = new RegExp(escapeRegex(args.search), regexOptions); - let attributeRegex = null; - if (args.attributes) { - attributeRegex = new RegExp(args.attributes, regexOptions); - } - - let root = args.root || document; - let elements = root.querySelectorAll(args.selector); - elements = Array.prototype.slice.call(elements); - - let replacedTextNodes = 0; - let replacedAttributes = 0; - - function replaceAttribute() { - replacedAttributes++; - return args.replace; - } - function replaceTextNode() { - replacedTextNodes++; - return args.replace; - } - - for (let i = 0; i < elements.length; i++) { - let element = elements[i]; - if (searchTextNodes) { - for (let y = 0; y < element.childNodes.length; y++) { - let node = element.childNodes[y]; - if (node.nodeType == node.TEXT_NODE) { - node.textContent = node.textContent.replace(search, replaceTextNode); - } - } - } - - if (searchAttributes) { - if (!element.attributes) { - continue; - } - for (let y = 0; y < element.attributes.length; y++) { - let attr = element.attributes[y]; - if (!attributeRegex || attributeRegex.test(attr.name)) { - attr.value = attr.value.replace(search, replaceAttribute); - } - } - } - } - - return gcli.lookupFormat("pagemodReplaceResult", - [elements.length, replacedTextNodes, - replacedAttributes]); - } -}); - -/** - * 'pagemod remove' command - */ -gcli.addCommand({ - name: "pagemod remove", - description: gcli.lookup("pagemodRemoveDesc"), -}); - - -/** - * The 'pagemod remove element' command. - */ -gcli.addCommand({ - name: "pagemod remove element", - description: gcli.lookup("pagemodRemoveElementDesc"), - params: [ - { - name: "search", - type: "string", - description: gcli.lookup("pagemodRemoveElementSearchDesc"), - }, - { - name: "root", - type: "node", - description: gcli.lookup("pagemodRemoveElementRootDesc"), - defaultValue: null, - }, - { - name: 'stripOnly', - type: 'boolean', - description: gcli.lookup("pagemodRemoveElementStripOnlyDesc"), - }, - { - name: 'ifEmptyOnly', - type: 'boolean', - description: gcli.lookup("pagemodRemoveElementIfEmptyOnlyDesc"), - }, - ], - exec: function(args, context) { - let document = context.environment.contentDocument; - let root = args.root || document; - let elements = Array.prototype.slice.call(root.querySelectorAll(args.search)); - - let removed = 0; - for (let i = 0; i < elements.length; i++) { - let element = elements[i]; - let parentNode = element.parentNode; - if (!parentNode || !element.removeChild) { - continue; - } - if (args.stripOnly) { - while (element.hasChildNodes()) { - parentNode.insertBefore(element.childNodes[0], element); - } - } - if (!args.ifEmptyOnly || !element.hasChildNodes()) { - element.parentNode.removeChild(element); - removed++; - } - } - - return gcli.lookupFormat("pagemodRemoveElementResultMatchedAndRemovedElements", - [elements.length, removed]); - } -}); - -/** - * The 'pagemod remove attribute' command. - */ -gcli.addCommand({ - name: "pagemod remove attribute", - description: gcli.lookup("pagemodRemoveAttributeDesc"), - params: [ - { - name: "searchAttributes", - type: "string", - description: gcli.lookup("pagemodRemoveAttributeSearchAttributesDesc"), - }, - { - name: "searchElements", - type: "string", - description: gcli.lookup("pagemodRemoveAttributeSearchElementsDesc"), - }, - { - name: "root", - type: "node", - description: gcli.lookup("pagemodRemoveAttributeRootDesc"), - defaultValue: null, - }, - { - name: "ignoreCase", - type: "boolean", - description: gcli.lookup("pagemodRemoveAttributeIgnoreCaseDesc"), - }, - ], - exec: function(args, context) { - let document = context.environment.contentDocument; - - let root = args.root || document; - let regexOptions = args.ignoreCase ? 'ig' : 'g'; - let attributeRegex = new RegExp(args.searchAttributes, regexOptions); - let elements = root.querySelectorAll(args.searchElements); - elements = Array.prototype.slice.call(elements); - - let removed = 0; - for (let i = 0; i < elements.length; i++) { - let element = elements[i]; - if (!element.attributes) { - continue; - } - - var attrs = Array.prototype.slice.call(element.attributes); - for (let y = 0; y < attrs.length; y++) { - let attr = attrs[y]; - if (attributeRegex.test(attr.name)) { - element.removeAttribute(attr.name); - removed++; - } - } - } - - return gcli.lookupFormat("pagemodRemoveAttributeResult", - [elements.length, removed]); - } -}); - -/** - * Make a given string safe to use in a regular expression. - * - * @param string aString - * The string you want to use in a regex. - * @return string - * The equivalent of |aString| but safe to use in a regex. - */ -function escapeRegex(aString) { - return aString.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); -} diff --git a/browser/devtools/commandline/CmdRestart.jsm b/browser/devtools/commandline/CmdRestart.jsm deleted file mode 100644 index d196fdbd3e5c..000000000000 --- a/browser/devtools/commandline/CmdRestart.jsm +++ /dev/null @@ -1,54 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -/** - * Restart command - * - * @param boolean nocache - * Disables loading content from cache upon restart. - * - * Examples : - * >> restart - * - restarts browser immediately - * >> restart --nocache - * - restarts immediately and starts Firefox without using cache - */ -gcli.addCommand({ - name: "restart", - description: gcli.lookup("restartFirefoxDesc"), - params: [ - { - name: "nocache", - type: "boolean", - description: gcli.lookup("restartFirefoxNocacheDesc") - } - ], - returnType: "string", - exec: function Restart(args, context) { - let canceled = Cc["@mozilla.org/supports-PRBool;1"] - .createInstance(Ci.nsISupportsPRBool); - Services.obs.notifyObservers(canceled, "quit-application-requested", "restart"); - if (canceled.data) { - return gcli.lookup("restartFirefoxRequestCancelled"); - } - - // disable loading content from cache. - if (args.nocache) { - Services.appinfo.invalidateCachesOnRestart(); - } - - // restart - Cc['@mozilla.org/toolkit/app-startup;1'] - .getService(Ci.nsIAppStartup) - .quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); - return gcli.lookup("restartFirefoxRestarting"); - } -}); diff --git a/browser/devtools/commandline/CmdScreenshot.jsm b/browser/devtools/commandline/CmdScreenshot.jsm deleted file mode 100644 index 1c164a51b55b..000000000000 --- a/browser/devtools/commandline/CmdScreenshot.jsm +++ /dev/null @@ -1,238 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -this.EXPORTED_SYMBOLS = [ ]; - -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "LayoutHelpers", - "resource:///modules/devtools/LayoutHelpers.jsm"); - -// String used as an indication to generate default file name in the following -// format: "Screen Shot yyyy-mm-dd at HH.MM.SS.png" -const FILENAME_DEFAULT_VALUE = " "; - -/** - * 'screenshot' command - */ -gcli.addCommand({ - name: "screenshot", - description: gcli.lookup("screenshotDesc"), - manual: gcli.lookup("screenshotManual"), - returnType: "html", - params: [ - { - name: "filename", - type: "string", - defaultValue: FILENAME_DEFAULT_VALUE, - description: gcli.lookup("screenshotFilenameDesc"), - manual: gcli.lookup("screenshotFilenameManual") - }, - { - group: gcli.lookup("screenshotGroupOptions"), - params: [ - { - name: "clipboard", - type: "boolean", - description: gcli.lookup("screenshotClipboardDesc"), - manual: gcli.lookup("screenshotClipboardManual") - }, - { - name: "chrome", - type: "boolean", - description: gcli.lookup("screenshotChromeDesc"), - manual: gcli.lookup("screenshotChromeManual") - }, - { - name: "delay", - type: { name: "number", min: 0 }, - defaultValue: 0, - description: gcli.lookup("screenshotDelayDesc"), - manual: gcli.lookup("screenshotDelayManual") - }, - { - name: "fullpage", - type: "boolean", - description: gcli.lookup("screenshotFullPageDesc"), - manual: gcli.lookup("screenshotFullPageManual") - }, - { - name: "selector", - type: "node", - defaultValue: null, - description: gcli.lookup("inspectNodeDesc"), - manual: gcli.lookup("inspectNodeManual") - } - ] - } - ], - exec: function Command_screenshot(args, context) { - if (args.chrome && args.selector) { - // Node screenshot with chrome option does not work as inteded - // Refer https://bugzilla.mozilla.org/show_bug.cgi?id=659268#c7 - // throwing for now. - throw new Error(gcli.lookup("screenshotSelectorChromeConflict")); - } - var document = args.chrome? context.environment.chromeDocument - : context.environment.contentDocument; - if (args.delay > 0) { - var promise = context.createPromise(); - document.defaultView.setTimeout(function Command_screenshotDelay() { - let reply = this.grabScreen(document, args.filename, args.clipboard, - args.fullpage); - promise.resolve(reply); - }.bind(this), args.delay * 1000); - return promise; - } - else { - return this.grabScreen(document, args.filename, args.clipboard, - args.fullpage, args.selector); - } - }, - grabScreen: - function Command_screenshotGrabScreen(document, filename, clipboard, - fullpage, node) { - let window = document.defaultView; - let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas"); - let left = 0; - let top = 0; - let width; - let height; - let div = document.createElementNS("http://www.w3.org/1999/xhtml", "div"); - - if (!fullpage) { - if (!node) { - left = window.scrollX; - top = window.scrollY; - width = window.innerWidth; - height = window.innerHeight; - } else { - let rect = LayoutHelpers.getRect(node, window); - top = rect.top; - left = rect.left; - width = rect.width; - height = rect.height; - } - } else { - width = window.innerWidth + window.scrollMaxX; - height = window.innerHeight + window.scrollMaxY; - } - canvas.width = width; - canvas.height = height; - - let ctx = canvas.getContext("2d"); - ctx.drawWindow(window, left, top, width, height, "#fff"); - let data = canvas.toDataURL("image/png", ""); - - let loadContext = document.defaultView - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); - - try { - if (clipboard) { - let io = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService); - let channel = io.newChannel(data, null, null); - let input = channel.open(); - let imgTools = Cc["@mozilla.org/image/tools;1"] - .getService(Ci.imgITools); - - let container = {}; - imgTools.decodeImageData(input, channel.contentType, container); - - let wrapped = Cc["@mozilla.org/supports-interface-pointer;1"] - .createInstance(Ci.nsISupportsInterfacePointer); - wrapped.data = container.value; - - let trans = Cc["@mozilla.org/widget/transferable;1"] - .createInstance(Ci.nsITransferable); - trans.init(loadContext); - trans.addDataFlavor(channel.contentType); - trans.setTransferData(channel.contentType, wrapped, -1); - - let clipid = Ci.nsIClipboard; - let clip = Cc["@mozilla.org/widget/clipboard;1"].getService(clipid); - clip.setData(trans, null, clipid.kGlobalClipboard); - div.textContent = gcli.lookup("screenshotCopied"); - return div; - } - } - catch (ex) { - div.textContent = gcli.lookup("screenshotErrorCopying"); - return div; - } - - let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); - - // Create a name for the file if not present - if (filename == FILENAME_DEFAULT_VALUE) { - let date = new Date(); - let dateString = date.getFullYear() + "-" + (date.getMonth() + 1) + - "-" + date.getDate(); - dateString = dateString.split("-").map(function(part) { - if (part.length == 1) { - part = "0" + part; - } - return part; - }).join("-"); - let timeString = date.toTimeString().replace(/:/g, ".").split(" ")[0]; - filename = gcli.lookupFormat("screenshotGeneratedFilename", - [dateString, timeString]) + ".png"; - } - // Check there is a .png extension to filename - else if (!filename.match(/.png$/i)) { - filename += ".png"; - } - - // If the filename is relative, tack it onto the download directory - if (!filename.match(/[\\\/]/)) { - let downloadMgr = Cc["@mozilla.org/download-manager;1"] - .getService(Ci.nsIDownloadManager); - let tempfile = downloadMgr.userDownloadsDirectory; - tempfile.append(filename); - filename = tempfile.path; - } - - try { - file.initWithPath(filename); - } catch (ex) { - div.textContent = gcli.lookup("screenshotErrorSavingToFile") + " " + filename; - return div; - } - - let ioService = Cc["@mozilla.org/network/io-service;1"] - .getService(Ci.nsIIOService); - - let Persist = Ci.nsIWebBrowserPersist; - let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] - .createInstance(Persist); - persist.persistFlags = Persist.PERSIST_FLAGS_REPLACE_EXISTING_FILES | - Persist.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION; - - let source = ioService.newURI(data, "UTF8", null); - persist.saveURI(source, null, null, null, null, file, loadContext); - - div.textContent = gcli.lookup("screenshotSavedToFile") + " \"" + filename + - "\""; - div.addEventListener("click", function openFile() { - div.removeEventListener("click", openFile); - file.reveal(); - }); - div.style.cursor = "pointer"; - let image = document.createElement("div"); - let previewHeight = parseInt(256*height/width); - image.setAttribute("style", - "width:256px; height:" + previewHeight + "px;" + - "max-height: 256px;" + - "background-image: url('" + data + "');" + - "background-size: 256px " + previewHeight + "px;" + - "margin: 4px; display: block"); - div.appendChild(image); - return div; - } -}); \ No newline at end of file diff --git a/browser/devtools/commandline/Commands.jsm b/browser/devtools/commandline/Commands.jsm index 452f27789124..53075d73edd2 100644 --- a/browser/devtools/commandline/Commands.jsm +++ b/browser/devtools/commandline/Commands.jsm @@ -7,21 +7,9 @@ this.EXPORTED_SYMBOLS = [ ]; const Cu = Components.utils; -Cu.import("resource:///modules/devtools/CmdAddon.jsm"); -Cu.import("resource:///modules/devtools/CmdBreak.jsm"); -Cu.import("resource:///modules/devtools/CmdCalllog.jsm"); -Cu.import("resource:///modules/devtools/CmdCalllogChrome.jsm"); -Cu.import("resource:///modules/devtools/CmdConsole.jsm"); -Cu.import("resource:///modules/devtools/CmdCookie.jsm"); -Cu.import("resource:///modules/devtools/CmdDbg.jsm"); -Cu.import("resource:///modules/devtools/CmdEcho.jsm"); +Cu.import("resource:///modules/devtools/BuiltinCommands.jsm"); Cu.import("resource:///modules/devtools/CmdEdit.jsm"); -Cu.import("resource:///modules/devtools/CmdExport.jsm"); Cu.import("resource:///modules/devtools/CmdInspect.jsm"); -Cu.import("resource:///modules/devtools/CmdJsb.jsm"); -Cu.import("resource:///modules/devtools/CmdPagemod.jsm"); Cu.import("resource:///modules/devtools/CmdResize.jsm"); -Cu.import("resource:///modules/devtools/CmdRestart.jsm"); -Cu.import("resource:///modules/devtools/CmdScreenshot.jsm"); Cu.import("resource:///modules/devtools/CmdTilt.jsm"); Cu.import("resource:///modules/devtools/CmdScratchpad.jsm"); diff --git a/browser/devtools/commandline/gcli.jsm b/browser/devtools/commandline/gcli.jsm index f23b374157c0..320b1ae4adcd 100644 --- a/browser/devtools/commandline/gcli.jsm +++ b/browser/devtools/commandline/gcli.jsm @@ -2436,7 +2436,6 @@ function Parameter(paramSpec, command, groupName) { this.name = this.paramSpec.name; this.type = this.paramSpec.type; this.groupName = groupName; - this.defaultValue = this.paramSpec.defaultValue; if (!this.name) { throw new Error('In ' + this.command.name + @@ -2453,22 +2452,20 @@ function Parameter(paramSpec, command, groupName) { // boolean parameters have an implicit defaultValue:false, which should // not be changed. See the docs. - if (this.type instanceof BooleanType) { - if (this.defaultValue !== undefined) { - throw new Error('In ' + this.command.name + '/' + this.name + - ': boolean parameters can not have a defaultValue.' + - ' Ignoring'); - } - this.defaultValue = false; + if (this.type instanceof BooleanType && + this.paramSpec.defaultValue !== undefined) { + throw new Error('In ' + this.command.name + '/' + this.name + + ': boolean parameters can not have a defaultValue.' + + ' Ignoring'); } // Check the defaultValue for validity. // Both undefined and null get a pass on this test. undefined is used when // there is no defaultValue, and null is used when the parameter is // optional, neither are required to parse and stringify. - if (this.defaultValue != null) { + if (this._defaultValue != null) { try { - var defaultText = this.type.stringify(this.defaultValue); + var defaultText = this.type.stringify(this.paramSpec.defaultValue); var defaultConversion = this.type.parseString(defaultText); if (defaultConversion.getStatus() !== Status.VALID) { throw new Error('In ' + this.command.name + '/' + this.name + @@ -2482,20 +2479,31 @@ function Parameter(paramSpec, command, groupName) { } } - // Some types (boolean, array) have a non 'undefined' blank value. Give the - // type a chance to override the default defaultValue of undefined - if (this.defaultValue === undefined) { - this.defaultValue = this.type.getBlank().value; - } - // All parameters that can only be set via a named parameter must have a // non-undefined default value - if (!this.isPositionalAllowed && this.defaultValue === undefined) { + if (!this.isPositionalAllowed && this.paramSpec.defaultValue === undefined && + this.type.getBlank == null && !(this.type instanceof BooleanType)) { throw new Error('In ' + this.command.name + '/' + this.name + ': Missing defaultValue for optional parameter.'); } } +/** + * type.getBlank can be expensive, so we delay execution where we can + */ +Object.defineProperty(Parameter.prototype, 'defaultValue', { + get: function() { + if (!('_defaultValue' in this)) { + this._defaultValue = (this.paramSpec.defaultValue !== undefined) ? + this.paramSpec.defaultValue : + this.type.getBlank().value; + } + + return this._defaultValue; + }, + enumerable : true +}); + /** * Does the given name uniquely identify this param (among the other params * in this command) @@ -4686,26 +4694,8 @@ imports.XPCOMUtils.defineLazyGetter(imports, 'supportsString', function() { var util = require('gcli/util'); var types = require('gcli/types'); -var allSettings = []; - /** - * Cache existing settings on startup - */ -exports.startup = function() { - imports.prefBranch.getChildList('').forEach(function(name) { - allSettings.push(new Setting(name)); - }.bind(this)); - allSettings.sort(function(s1, s2) { - return s1.name.localeCompare(s2.name); - }.bind(this)); -}; - -exports.shutdown = function() { - allSettings = []; -}; - -/** - * + * All local settings have this prefix when used in Firefox */ var DEVTOOLS_PREFIX = 'devtools.gcli.'; @@ -4824,14 +4814,76 @@ Setting.prototype.setDefault = function() { Services.prefs.savePrefFile(null); }; + /** - * 'static' function to get an array containing all known Settings + * Collection of preferences for sorted access + */ +var settingsAll = []; + +/** + * Collection of preferences for fast indexed access + */ +var settingsMap = new Map(); + +/** + * Flag so we know if we've read the system preferences + */ +var hasReadSystem = false; + +/** + * Clear out all preferences and return to initial state + */ +function reset() { + settingsMap = new Map(); + settingsAll = []; + hasReadSystem = false; +} + +/** + * Reset everything on startup and shutdown because we're doing lazy loading + */ +exports.startup = function() { + reset(); +}; + +exports.shutdown = function() { + reset(); +}; + +/** + * Load system prefs if they've not been loaded already + * @return true + */ +function readSystem() { + if (hasReadSystem) { + return; + } + + imports.prefBranch.getChildList('').forEach(function(name) { + var setting = new Setting(name); + settingsAll.push(setting); + settingsMap.set(name, setting); + }); + + settingsAll.sort(function(s1, s2) { + return s1.name.localeCompare(s2.name); + }); + + hasReadSystem = true; +} + +/** + * Get an array containing all known Settings filtered to match the given + * filter (string) at any point in the name of the setting */ exports.getAll = function(filter) { + readSystem(); + if (filter == null) { - return allSettings; + return settingsAll; } - return allSettings.filter(function(setting) { + + return settingsAll.filter(function(setting) { return setting.name.indexOf(filter) !== -1; }); }; @@ -4841,12 +4893,19 @@ exports.getAll = function(filter) { */ exports.addSetting = function(prefSpec) { var setting = new Setting(prefSpec); - for (var i = 0; i < allSettings.length; i++) { - if (allSettings[i].name === setting.name) { - allSettings[i] = setting; + + if (settingsMap.has(setting.name)) { + // Once exists already, we're going to need to replace it in the array + for (var i = 0; i < settingsAll.length; i++) { + if (settingsAll[i].name === setting.name) { + settingsAll[i] = setting; + } } } + + settingsMap.set(setting.name, setting); exports.onChange({ added: setting.name }); + return setting; }; @@ -4860,15 +4919,20 @@ exports.addSetting = function(prefSpec) { * @return The found Setting object, or undefined if the setting was not found */ exports.getSetting = function(name) { - var found = undefined; - allSettings.some(function(setting) { - if (setting.name === name) { - found = setting; - return true; - } - return false; - }); - return found; + // We might be able to give the answer without needing to read all system + // settings if this is an internal setting + var found = settingsMap.get(name); + if (found) { + return found; + } + + if (hasReadSystem) { + return undefined; + } + else { + readSystem(); + return settingsMap.get(name); + } }; /** @@ -4879,8 +4943,7 @@ exports.onChange = util.createEvent('Settings.onChange'); /** * Remove a setting. A no-op in this case */ -exports.removeSetting = function(nameOrSpec) { -}; +exports.removeSetting = function() { }; }); diff --git a/browser/devtools/commandline/test/browser_cmd_addon.js b/browser/devtools/commandline/test/browser_cmd_addon.js index b86c17433626..141d9282c36b 100644 --- a/browser/devtools/commandline/test/browser_cmd_addon.js +++ b/browser/devtools/commandline/test/browser_cmd_addon.js @@ -4,7 +4,7 @@ // Tests that the addon commands works as they should let imported = {}; -Components.utils.import("resource:///modules/devtools/CmdAddon.jsm", imported); +Components.utils.import("resource:///modules/devtools/BuiltinCommands.jsm", imported); function test() { DeveloperToolbarTest.test("about:blank", [ GAT_test ]); @@ -96,7 +96,7 @@ function GAT_test() { Services.obs.addObserver(GAT_ready, "gcli_addon_commands_ready", false); - if (imported.Flags.addonsLoaded) { + if (imported.CmdAddonFlags.addonsLoaded) { info("The getAllAddons command has already completed and we have missed "); info("the notification. Let's send the gcli_addon_commands_ready "); info("notification ourselves."); diff --git a/browser/devtools/framework/Toolbox.jsm b/browser/devtools/framework/Toolbox.jsm index 750228e63edd..4f6445110315 100644 --- a/browser/devtools/framework/Toolbox.jsm +++ b/browser/devtools/framework/Toolbox.jsm @@ -244,9 +244,14 @@ Toolbox.prototype = { open: function TBOX_open() { let deferred = Promise.defer(); - this._host.open().then(function(iframe) { - let onload = function() { - iframe.removeEventListener("DOMContentLoaded", onload, true); + this._host.create().then(function(iframe) { + let domReady = function() { + iframe.removeEventListener("DOMContentLoaded", domReady, true); + + let vbox = this.doc.getElementById("toolbox-panel-" + this._currentToolId); + if (vbox) { + this.doc.commandDispatcher.advanceFocusIntoSubtree(vbox); + } this.isReady = true; @@ -263,7 +268,7 @@ Toolbox.prototype = { }.bind(this)); }.bind(this); - iframe.addEventListener("DOMContentLoaded", onload, true); + iframe.addEventListener("DOMContentLoaded", domReady, true); iframe.setAttribute("src", this._URL); }.bind(this)); @@ -502,7 +507,7 @@ Toolbox.prototype = { } let newHost = this._createHost(hostType); - return newHost.open().then(function(iframe) { + return newHost.create().then(function(iframe) { // change toolbox document's parent to the new host iframe.QueryInterface(Ci.nsIFrameLoaderOwner); iframe.swapFrameLoaders(this.frame); diff --git a/browser/devtools/framework/ToolboxHosts.jsm b/browser/devtools/framework/ToolboxHosts.jsm index c19960807cf0..ccfd804899cf 100644 --- a/browser/devtools/framework/ToolboxHosts.jsm +++ b/browser/devtools/framework/ToolboxHosts.jsm @@ -17,7 +17,7 @@ this.EXPORTED_SYMBOLS = [ "Hosts" ]; * sidebar or a separate window). Any host object should implement the * following functions: * - * open() - create the UI and emit a 'ready' event when the UI is ready to use + * create() - create the UI and emit a 'ready' event when the UI is ready to use * destroy() - destroy the host's UI */ @@ -44,7 +44,7 @@ BottomHost.prototype = { /** * Create a box at the bottom of the host tab. */ - open: function BH_open() { + create: function BH_create() { let deferred = Promise.defer(); let gBrowser = this.hostTab.ownerDocument.defaultView.gBrowser; @@ -54,7 +54,7 @@ BottomHost.prototype = { this._splitter.setAttribute("class", "devtools-horizontal-splitter"); this.frame = ownerDocument.createElement("iframe"); - this.frame.id = "devtools-toolbox-bottom-iframe"; + this.frame.className = "devtools-toolbox-bottom-iframe"; this.frame.height = Services.prefs.getIntPref(this.heightPref); this._nbox = gBrowser.getNotificationBox(this.hostTab.linkedBrowser); @@ -112,7 +112,7 @@ SidebarHost.prototype = { /** * Create a box in the sidebar of the host tab. */ - open: function RH_open() { + create: function SH_create() { let deferred = Promise.defer(); let gBrowser = this.hostTab.ownerDocument.defaultView.gBrowser; @@ -122,7 +122,7 @@ SidebarHost.prototype = { this._splitter.setAttribute("class", "devtools-side-splitter"); this.frame = ownerDocument.createElement("iframe"); - this.frame.id = "devtools-toolbox-side-iframe"; + this.frame.className = "devtools-toolbox-side-iframe"; this.frame.width = Services.prefs.getIntPref(this.widthPref); this._sidebar = gBrowser.getSidebarContainer(this.hostTab.linkedBrowser); @@ -147,7 +147,7 @@ SidebarHost.prototype = { /** * Destroy the sidebar. */ - destroy: function RH_destroy() { + destroy: function SH_destroy() { if (!this._destroyed) { this._destroyed = true; @@ -177,7 +177,7 @@ WindowHost.prototype = { /** * Create a new xul window to contain the toolbox. */ - open: function WH_open() { + create: function WH_create() { let deferred = Promise.defer(); let flags = "chrome,centerscreen,resizable,dialog=no"; diff --git a/browser/devtools/framework/test/browser_toolbox_hosts.js b/browser/devtools/framework/test/browser_toolbox_hosts.js index f178b8790edb..b37ebd0458a2 100644 --- a/browser/devtools/framework/test/browser_toolbox_hosts.js +++ b/browser/devtools/framework/test/browser_toolbox_hosts.js @@ -38,7 +38,8 @@ function testBottomHost(aToolbox) checkHostType(Toolbox.HostType.BOTTOM); // test UI presence - let iframe = document.getElementById("devtools-toolbox-bottom-iframe"); + let nbox = gBrowser.getNotificationBox(); + let iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-bottom-iframe"); ok(iframe, "toolbox bottom iframe exists"); checkToolboxLoaded(iframe); @@ -51,10 +52,11 @@ function testSidebarHost() checkHostType(Toolbox.HostType.SIDE); // test UI presence - let bottom = document.getElementById("devtools-toolbox-bottom-iframe"); + let nbox = gBrowser.getNotificationBox(); + let bottom = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-bottom-iframe"); ok(!bottom, "toolbox bottom iframe doesn't exist"); - let iframe = document.getElementById("devtools-toolbox-side-iframe"); + let iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-side-iframe"); ok(iframe, "toolbox side iframe exists"); checkToolboxLoaded(iframe); @@ -66,7 +68,8 @@ function testWindowHost() { checkHostType(Toolbox.HostType.WINDOW); - let sidebar = document.getElementById("devtools-toolbox-side-iframe"); + let nbox = gBrowser.getNotificationBox(); + let sidebar = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-side-iframe"); ok(!sidebar, "toolbox sidebar iframe doesn't exist"); let win = Services.wm.getMostRecentWindow("devtools:toolbox"); diff --git a/browser/devtools/inspector/test/browser_inspector_bug_665880.js b/browser/devtools/inspector/test/browser_inspector_bug_665880.js index b80de1cc211c..6d990d5c8bbd 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_665880.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_665880.js @@ -36,8 +36,10 @@ function test() { is(getActiveInspector().selection.node, objectNode, "selection matches node"); let target = TargetFactory.forTab(gBrowser.selectedTab); - gDevTools.closeToolbox(target); - finishUp(); + executeSoon(function() { + gDevTools.closeToolbox(target); + finishUp(); + }); } diff --git a/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js b/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js index f44ad7ba9838..f61ab3805e22 100644 --- a/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js +++ b/browser/devtools/inspector/test/browser_inspector_bug_672902_keyboard_shortcuts.js @@ -30,7 +30,7 @@ function test() openInspector(findAndHighlightNode); } - function findAndHighlightNode(aInspector) + function findAndHighlightNode(aInspector, aToolbox) { inspector = aInspector; diff --git a/browser/devtools/inspector/test/head.js b/browser/devtools/inspector/test/head.js index 1e47e039ac29..38fc64372129 100644 --- a/browser/devtools/inspector/test/head.js +++ b/browser/devtools/inspector/test/head.js @@ -19,7 +19,7 @@ function openInspector(callback) { let target = TargetFactory.forTab(gBrowser.selectedTab); gDevTools.showToolbox(target, "inspector").then(function(toolbox) { - callback(toolbox.getCurrentPanel()); + callback(toolbox.getCurrentPanel(), toolbox); }).then(null, console.error); } diff --git a/browser/devtools/styleinspector/CssHtmlTree.jsm b/browser/devtools/styleinspector/CssHtmlTree.jsm index 6b16180141e0..f8f517bcb77d 100644 --- a/browser/devtools/styleinspector/CssHtmlTree.jsm +++ b/browser/devtools/styleinspector/CssHtmlTree.jsm @@ -62,7 +62,7 @@ UpdateProcess.prototype = { */ schedule: function UP_schedule() { - if (this.cancelled) { + if (this.canceled) { return; } this._timeout = this.win.setTimeout(this._timeoutHandler.bind(this), 0); @@ -100,7 +100,7 @@ UpdateProcess.prototype = { _runBatch: function Y_runBatch() { let time = Date.now(); - while(!this.cancelled) { + while(!this.canceled) { // Continue until iter.next() throws... let next = this.iter.next(); this.onItem(next[1]); @@ -147,7 +147,6 @@ this.CssHtmlTree = function CssHtmlTree(aStyleInspector) this.root = this.styleDocument.getElementById("root"); this.templateRoot = this.styleDocument.getElementById("templateRoot"); this.propertyContainer = this.styleDocument.getElementById("propertyContainer"); - this.panel = aStyleInspector.panel; // No results text. this.noResults = this.styleDocument.getElementById("noResults"); @@ -257,6 +256,13 @@ CssHtmlTree.prototype = { this._unmatchedProperties = null; this._matchedProperties = null; + if (!aElement) { + if (this._refreshProcess) { + this._refreshProcess.cancel(); + } + return; + } + if (this.htmlComplete) { this.refreshSourceFilter(); this.refreshPanel(); diff --git a/browser/devtools/styleinspector/StyleInspector.jsm b/browser/devtools/styleinspector/StyleInspector.jsm index e56502c9cff6..a25c614f0375 100644 --- a/browser/devtools/styleinspector/StyleInspector.jsm +++ b/browser/devtools/styleinspector/StyleInspector.jsm @@ -80,6 +80,7 @@ this.RuleViewTool = function RVT_RuleViewTool(aInspector, aWindow, aIFrame) this._cssLinkHandler); this._onSelect = this.onSelect.bind(this); + this.inspector.selection.on("detached", this._onSelect); this.inspector.selection.on("new-node", this._onSelect); this.refresh = this.refresh.bind(this); this.inspector.on("layout-change", this.refresh); @@ -159,6 +160,7 @@ this.ComputedViewTool = function CVT_ComputedViewTool(aInspector, aWindow, aIFra this.view = new CssHtmlTree(this); this._onSelect = this.onSelect.bind(this); + this.inspector.selection.on("detached", this._onSelect); this.inspector.selection.on("new-node", this._onSelect); if (this.inspector.highlighter) { this.inspector.highlighter.on("locked", this._onSelect); @@ -179,7 +181,7 @@ ComputedViewTool.prototype = { { if (!this.inspector.selection.isConnected() || !this.inspector.selection.isElementNode()) { - // FIXME: We should hide view's content + this.view.highlight(null); return; } diff --git a/browser/devtools/tilt/CmdTilt.jsm b/browser/devtools/tilt/CmdTilt.jsm index 1297e786a783..0b8e422d7424 100644 --- a/browser/devtools/tilt/CmdTilt.jsm +++ b/browser/devtools/tilt/CmdTilt.jsm @@ -5,11 +5,11 @@ this.EXPORTED_SYMBOLS = [ ]; +Components.utils.import('resource://gre/modules/XPCOMUtils.jsm'); Components.utils.import("resource:///modules/devtools/gcli.jsm"); -Components.utils.import("resource:///modules/HUDService.jsm"); -Components.utils.import("resource:///modules/devtools/Tilt.jsm"); - +XPCOMUtils.defineLazyModuleGetter(this, "TiltManager", + "resource:///modules/devtools/Tilt.jsm"); /** * 'tilt' command */ From 4f9fbed4b2d634cc2f8e5d581ec2e1b918dd7876 Mon Sep 17 00:00:00 2001 From: Anton Kovalyov Date: Fri, 4 Jan 2013 12:57:02 +0100 Subject: [PATCH 157/180] Bug 822110 - filter.png, noise.png and showall.png in browser/devtools/profiler/cleopatra/images are empty. r=robcee r=bgirard --- browser/devtools/jar.mn | 2 - .../profiler/cleopatra/cleopatra.html | 2 - .../devtools/profiler/cleopatra/css/tree.css | 9 --- .../devtools/profiler/cleopatra/css/ui.css | 67 +++++++++---------- .../profiler/cleopatra/images/filter.png | 0 .../profiler/cleopatra/images/showall.png | 0 6 files changed, 32 insertions(+), 48 deletions(-) delete mode 100755 browser/devtools/profiler/cleopatra/images/filter.png delete mode 100755 browser/devtools/profiler/cleopatra/images/showall.png diff --git a/browser/devtools/jar.mn b/browser/devtools/jar.mn index dbc4a18fcb42..f50bfaad6c99 100644 --- a/browser/devtools/jar.mn +++ b/browser/devtools/jar.mn @@ -40,9 +40,7 @@ browser.jar: content/browser/devtools/profiler/cleopatra/js/ProgressReporter.js (profiler/cleopatra/js/ProgressReporter.js) content/browser/devtools/profiler/cleopatra/js/devtools.js (profiler/cleopatra/js/devtools.js) content/browser/devtools/profiler/cleopatra/images/circlearrow.svg (profiler/cleopatra/images/circlearrow.svg) - content/browser/devtools/profiler/cleopatra/images/filter.png (profiler/cleopatra/images/filter.png) content/browser/devtools/profiler/cleopatra/images/noise.png (profiler/cleopatra/images/noise.png) - content/browser/devtools/profiler/cleopatra/images/showall.png (profiler/cleopatra/images/showall.png) content/browser/devtools/profiler/cleopatra/images/throbber.svg (profiler/cleopatra/images/throbber.svg) content/browser/devtools/profiler/cleopatra/images/treetwisty.svg (profiler/cleopatra/images/treetwisty.svg) content/browser/devtools/commandline.css (commandline/commandline.css) diff --git a/browser/devtools/profiler/cleopatra/cleopatra.html b/browser/devtools/profiler/cleopatra/cleopatra.html index 586b1bfcbcd4..e1330e00270c 100755 --- a/browser/devtools/profiler/cleopatra/cleopatra.html +++ b/browser/devtools/profiler/cleopatra/cleopatra.html @@ -17,8 +17,6 @@ - - diff --git a/browser/devtools/profiler/cleopatra/css/tree.css b/browser/devtools/profiler/cleopatra/css/tree.css index 5ffac9331b85..3b092a9767e2 100755 --- a/browser/devtools/profiler/cleopatra/css/tree.css +++ b/browser/devtools/profiler/cleopatra/css/tree.css @@ -4,7 +4,6 @@ .treeViewContainer { -moz-user-select: none; - -webkit-user-select: none; user-select: none; cursor: default; line-height: 16px; @@ -26,8 +25,6 @@ .treeColumnHeader { position: absolute; display: block; - background: -moz-linear-gradient(#FFF 45%, #EEE 60%); - background: -webkit-linear-gradient(#FFF 45%, #EEE 60%); background: linear-gradient(#FFF 45%, #EEE 60%); margin: 0; padding: 0; @@ -93,17 +90,11 @@ .treeViewVerticalScrollbox, .treeViewHorizontalScrollbox { - background: -moz-linear-gradient(white, white 50%, #F0F5FF 50%, #F0F5FF); - background: -webkit-linear-gradient(white, white 50%, #F0F5FF 50%, #F0F5FF); background: linear-gradient(white, white 50%, #F0F5FF 50%, #F0F5FF); background-size: 100px 32px; } .leftColumnBackground { - background: -moz-linear-gradient(left, transparent, transparent 98px, #CCC 98px, #CCC 99px, transparent 99px), - -moz-linear-gradient(white, white 50%, #F0F5FF 50%, #F0F5FF); - background: -webkit-linear-gradient(left, transparent, transparent 98px, #CCC 98px, #CCC 99px, transparent 99px), - -webkit-linear-gradient(white, white 50%, #F0F5FF 50%, #F0F5FF); background: linear-gradient(left, transparent, transparent 98px, #CCC 98px, #CCC 99px, transparent 99px), linear-gradient(white, white 50%, #F0F5FF 50%, #F0F5FF); background-size: auto, 100px 32px; diff --git a/browser/devtools/profiler/cleopatra/css/ui.css b/browser/devtools/profiler/cleopatra/css/ui.css index fea0dcb1a8c5..a0e5bb6be1cf 100755 --- a/browser/devtools/profiler/cleopatra/css/ui.css +++ b/browser/devtools/profiler/cleopatra/css/ui.css @@ -31,10 +31,6 @@ body { .profileProgressPane { padding: 20px; background-color: rgb(229,229,229); - background-image: url(../images/noise.png), - -moz-linear-gradient(rgba(255,255,255,.5),rgba(255,255,255,.2)); - background-image: url(../images/noise.png), - -webkit-linear-gradient(rgba(255,255,255,.5),rgba(255,255,255,.2)); background-image: url(../images/noise.png), linear-gradient(rgba(255,255,255,.5),rgba(255,255,255,.2)); text-shadow: rgba(255, 255, 255, 0.4) 0 1px; @@ -62,22 +58,39 @@ body { height: 16px; } .finishedProfilePaneBackgroundCover { - -webkit-animation: darken 300ms cubic-bezier(0, 0, 1, 0); - -moz-animation: darken 300ms cubic-bezier(0, 0, 1, 0); + animation: darken 300ms cubic-bezier(0, 0, 1, 0); background-color: rgba(0, 0, 0, 0.5); } + .finishedProfilePane { - -webkit-animation: appear 300ms ease-out; - -moz-animation: appear 300ms ease-out; + animation: appear 300ms ease-out; } +@keyframes darken { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes appear { + from { + transform: scale(0.3); + opacity: 0; + pointer-events: none; + } + to { + transform: scale(1); + opacity: 1; + pointer-events: auto; + } +} .breadcrumbTrail { top: 0; right: 0; height: 29px; left: 0; - background: -moz-linear-gradient(#FFF 50%, #F3F3F3 55%); - background: -webkit-linear-gradient(#FFF 50%, #F3F3F3 55%); background: linear-gradient(#FFF 50%, #F3F3F3 55%); border-bottom: 1px solid #CCC; margin: 0; @@ -85,8 +98,6 @@ body { overflow: hidden; } .breadcrumbTrailItem { - background: -moz-linear-gradient(#FFF 50%, #F3F3F3 55%); - background: -webkit-linear-gradient(#FFF 50%, #F3F3F3 55%); background: linear-gradient(#FFF 50%, #F3F3F3 55%); display: block; margin: 0; @@ -96,7 +107,6 @@ body { padding: 0 10px; font-size: 12px; -moz-user-select: none; - -webkit-user-select: none; user-select: none; cursor: default; border-right: 1px solid #CCC; @@ -106,7 +116,7 @@ body { white-space: nowrap; position: relative; } -@-webkit-keyframes slide-out { +@keyframes slide-out { from { margin-left: -270px; opacity: 0; @@ -116,7 +126,7 @@ body { opacity: 1; } } -@-moz-keyframes slide-out { +@keyframes slide-out { from { margin-left: -270px; opacity: 0; @@ -127,12 +137,9 @@ body { } } .breadcrumbTrailItem:not(:first-child) { - -moz-animation: slide-out; - -moz-animation-duration: 400ms; - -moz-animation-timing-function: ease-out; - -webkit-animation: slide-out; - -webkit-animation-duration: 400ms; - -webkit-animation-timing-function: ease-out; + animation: slide-out; + animation-duration: 400ms; + animation-timing-function: ease-out; } .breadcrumbTrailItem.selected { background: linear-gradient(#E5E5E5 50%, #DADADA 55%); @@ -141,10 +148,8 @@ body { background: linear-gradient(#F2F2F2 50%, #E6E6E6 55%); } .breadcrumbTrailItem.deleted { - -moz-transition: 400ms ease-out; - -moz-transition-property: opacity, margin-left; - -webkit-transition: 400ms ease-out; - -webkit-transition-property: opacity, margin-left; + transition: 400ms ease-out; + transition-property: opacity, margin-left; opacity: 0; margin-left: -270px; } @@ -199,7 +204,6 @@ body { } .sideBar { -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; box-sizing: border-box; position: absolute; left: 0; @@ -246,8 +250,6 @@ body { right: 0; left: 0; border-bottom: 1px solid #CCC; - background: -moz-linear-gradient(#EEE, #CCC); - background: -webkit-linear-gradient(#EEE, #CCC); background: linear-gradient(#EEE, #CCC); } .histogramHilite { @@ -287,8 +289,6 @@ body { text-indent: 8px; } .fileListItem.selected { - background: -moz-linear-gradient(#4B91D7 1px, #5FA9E4 1px, #5FA9E4 2px, #58A0DE 3px, #2B70C7 39px, #2763B4 39px); - background: -webkit-linear-gradient(#4B91D7 1px, #5FA9E4 1px, #5FA9E4 2px, #58A0DE 3px, #2B70C7 39px, #2763B4 39px); background: linear-gradient(#4B91D7 1px, #5FA9E4 1px, #5FA9E4 2px, #58A0DE 3px, #2B70C7 39px, #2763B4 39px); color: #FFF; text-shadow: 0 1px rgba(0, 0, 0, 0.3); @@ -313,10 +313,8 @@ body { opacity: 0; pointer-events: none; background: rgba(120, 120, 120, 0.2); - -moz-transition: 200ms ease-in-out; - -moz-transition-property: visibility, opacity; - -webkit-transition: 200ms ease-in-out; - -webkit-transition-property: visibility, opacity; + transition: 200ms ease-in-out; + transition-property: visibility, opacity; } .busyCover.busy { visibility: visible; @@ -330,7 +328,6 @@ body { margin: -12px; } label { - -webkit-user-select: none; -moz-user-select: none; } .videoPane { diff --git a/browser/devtools/profiler/cleopatra/images/filter.png b/browser/devtools/profiler/cleopatra/images/filter.png deleted file mode 100755 index e69de29bb2d1..000000000000 diff --git a/browser/devtools/profiler/cleopatra/images/showall.png b/browser/devtools/profiler/cleopatra/images/showall.png deleted file mode 100755 index e69de29bb2d1..000000000000 From 5d3b4f738b30d9f5a89faf0922623487c6630ab2 Mon Sep 17 00:00:00 2001 From: Joe Walker Date: Fri, 4 Jan 2013 20:31:38 +0000 Subject: [PATCH 158/180] Bug 822609 - developer tools should not use target.isChrome; r=paul --- browser/devtools/framework/ToolDefinitions.jsm | 8 ++------ browser/devtools/framework/Toolbox.jsm | 15 +-------------- browser/devtools/webconsole/WebConsolePanel.jsm | 4 ++-- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/browser/devtools/framework/ToolDefinitions.jsm b/browser/devtools/framework/ToolDefinitions.jsm index 2d217497c474..69688926bff9 100644 --- a/browser/devtools/framework/ToolDefinitions.jsm +++ b/browser/devtools/framework/ToolDefinitions.jsm @@ -135,7 +135,7 @@ let styleEditorDefinition = { tooltip: l10n("ToolboxStyleEditor.tooltip", styleEditorStrings), isTargetSupported: function(target) { - return !target.isRemote && !target.isChrome; + return target.isLocalTab; }, build: function(iframeWindow, toolbox) { @@ -152,11 +152,7 @@ let profilerDefinition = { tooltip: l10n("profiler.tooltip", profilerStrings), isTargetSupported: function (target) { - if (target.isRemote || target.isChrome) { - return false; - } - - return true; + return !target.isRemote; }, build: function (frame, target) { diff --git a/browser/devtools/framework/Toolbox.jsm b/browser/devtools/framework/Toolbox.jsm index 4f6445110315..21e216a55e17 100644 --- a/browser/devtools/framework/Toolbox.jsm +++ b/browser/devtools/framework/Toolbox.jsm @@ -478,11 +478,10 @@ Toolbox.prototype = { * The created host object */ _createHost: function TBOX_createHost(hostType) { - let hostTab = this._getHostTab(); if (!Hosts[hostType]) { throw new Error('Unknown hostType: '+ hostType); } - let newHost = new Hosts[hostType](hostTab); + let newHost = new Hosts[hostType](this.target.tab); // clean up the toolbox if its window is closed newHost.on("window-closed", this.destroy); @@ -525,18 +524,6 @@ Toolbox.prototype = { }.bind(this)); }, - /** - * Get the most appropriate host tab, either the target or the current tab - */ - _getHostTab: function TBOX_getHostTab() { - if (!this._target.isRemote && !this._target.isChrome) { - return this._target.tab; - } else { - let win = Services.wm.getMostRecentWindow("navigator:browser"); - return win.gBrowser.selectedTab; - } - }, - /** * Handler for the tool-registered event. * @param {string} event diff --git a/browser/devtools/webconsole/WebConsolePanel.jsm b/browser/devtools/webconsole/WebConsolePanel.jsm index a1f0064cb117..3b017db8a259 100644 --- a/browser/devtools/webconsole/WebConsolePanel.jsm +++ b/browser/devtools/webconsole/WebConsolePanel.jsm @@ -30,10 +30,10 @@ WebConsolePanel.prototype = { * open is effectively an asynchronous constructor */ open: function StyleEditor_open() { - let tab = this._toolbox._getHostTab(); let parentDoc = this._frameWindow.document.defaultView.parent.document; let iframe = parentDoc.getElementById("toolbox-panel-iframe-webconsole"); - this.hud = HUDService.activateHUDForContext(tab, iframe, this._toolbox.target); + this.hud = HUDService.activateHUDForContext(this.target.tab, iframe, + this._toolbox.target); let deferred = Promise.defer(); From 5c84bd2eb8993ca48a0d98142822abb9ab8b2a24 Mon Sep 17 00:00:00 2001 From: Joe Walker Date: Fri, 4 Jan 2013 20:31:38 +0000 Subject: [PATCH 159/180] Bug 795988 - Closing browser window with Developer Toolbar open leaks an everything; r=paul,ttaubert --- browser/base/content/browser.js | 5 + browser/devtools/commandline/gcli.jsm | 95 ++++++++++++------- .../commandline/test/browser_gcli_exec.js | 19 ++-- browser/devtools/framework/Toolbox.jsm | 13 ++- browser/devtools/shared/DeveloperToolbar.jsm | 7 ++ 5 files changed, 90 insertions(+), 49 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 71be56bda704..cdfd307b230a 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1516,6 +1516,11 @@ var gBrowserInit = { gDevToolsBrowser.forgetBrowserWindow(window); + let desc = Object.getOwnPropertyDescriptor(window, "DeveloperToolbar"); + if (desc && !desc.get) { + DeveloperToolbar.destroy(); + } + // First clean up services initialized in gBrowserInit.onLoad (or those whose // uninit methods don't depend on the services having been initialized). allTabs.uninit(); diff --git a/browser/devtools/commandline/gcli.jsm b/browser/devtools/commandline/gcli.jsm index 320b1ae4adcd..54719b53e736 100644 --- a/browser/devtools/commandline/gcli.jsm +++ b/browser/devtools/commandline/gcli.jsm @@ -2697,11 +2697,10 @@ canon.onCanonChange = util.createEvent('canon.onCanonChange'); * CommandOutputManager stores the output objects generated by executed * commands. * - * CommandOutputManager is exposed (via canon.commandOutputManager) to the the - * outside world and could (but shouldn't) be used before gcli.startup() has - * been called. This could should be defensive to that where possible, and we - * should certainly document if the use of it or similar will fail if used too - * soon. + * CommandOutputManager is exposed to the the outside world and could (but + * shouldn't) be used before gcli.startup() has been called. + * This could should be defensive to that where possible, and we should + * certainly document if the use of it or similar will fail if used too soon. */ function CommandOutputManager() { this.onOutput = util.createEvent('CommandOutputManager.onOutput'); @@ -2709,12 +2708,6 @@ function CommandOutputManager() { canon.CommandOutputManager = CommandOutputManager; -/** - * We maintain a global command output manager for the majority case where - * there is only one important set of outputs. - */ -canon.commandOutputManager = new CommandOutputManager(); - }); /* @@ -2744,6 +2737,18 @@ define('gcli/util', ['require', 'exports', 'module' ], function(require, exports var eventDebug = false; +/** + * Patch up broken console API from node + */ +if (eventDebug) { + if (console.group == null) { + console.group = function() { console.log(arguments); }; + } + if (console.groupEnd == null) { + console.groupEnd = function() { console.log(arguments); }; + } +} + /** * Useful way to create a name for a handler, used in createEvent() */ @@ -2825,6 +2830,10 @@ exports.createEvent = function(name) { * @param scope Optional 'this' object for the function call */ event.add = function(func, scope) { + if (eventDebug) { + console.log('Adding listener to ' + name); + } + handlers.push({ func: func, scope: scope }); }; @@ -2835,16 +2844,20 @@ exports.createEvent = function(name) { * @param scope Optional 'this' object for the function call */ event.remove = function(func, scope) { + if (eventDebug) { + console.log('Removing listener from ' + name); + } + var found = false; handlers = handlers.filter(function(test) { - var noMatch = (test.func !== func && test.scope !== scope); - if (!noMatch) { + var match = (test.func === func && test.scope === scope); + if (match) { found = true; } - return noMatch; + return !match; }); if (!found) { - console.warn('Failed to remove handler from ' + name); + console.warn('Handler not found. Attached to ' + name); } }; @@ -4065,6 +4078,7 @@ exports.setDocument = function(document) { */ exports.unsetDocument = function() { doc = undefined; + exports._empty = undefined; }; /** @@ -5172,6 +5186,7 @@ var l10n = require('gcli/l10n'); var canon = require('gcli/canon'); var Q = require('gcli/promise'); +var CommandOutputManager = require('gcli/canon').CommandOutputManager; var Status = require('gcli/types').Status; var Conversion = require('gcli/types').Conversion; @@ -5530,9 +5545,11 @@ UnassignedAssignment.prototype.getStatus = function(arg) { * @param doc A DOM Document passed to commands using the Execution Context in * order to allow creation of DOM nodes. If missing Requisition will use the * global 'document'. + * @param commandOutputManager A custom commandOutputManager to which output + * should be sent (optional) * @constructor */ -function Requisition(environment, doc) { +function Requisition(environment, doc, commandOutputManager) { this.environment = environment; this.document = doc; if (this.document == null) { @@ -5543,6 +5560,7 @@ function Requisition(environment, doc) { // Ignore } } + this.commandOutputManager = commandOutputManager || new CommandOutputManager(); // The command that we are about to execute. // @see setCommandConversion() @@ -5573,8 +5591,6 @@ function Requisition(environment, doc) { this.commandAssignment.onAssignmentChange.add(this._commandAssignmentChanged, this); this.commandAssignment.onAssignmentChange.add(this._assignmentChanged, this); - this.commandOutputManager = canon.commandOutputManager; - this.onAssignmentChange = util.createEvent('Requisition.onAssignmentChange'); this.onTextChange = util.createEvent('Requisition.onTextChange'); } @@ -7055,21 +7071,21 @@ exports.shutdown = function() { * @param options Object containing user customization properties, including: * - blurDelay (default=150ms) * - debug (default=false) - * - commandOutputManager (default=canon.commandOutputManager) * @param components Object that links to other UI components. GCLI provided: * - document + * - requisition */ function FocusManager(options, components) { options = options || {}; this._document = components.document || document; + this._requisition = components.requisition; + this._debug = options.debug || false; this._blurDelay = options.blurDelay || 150; this._window = this._document.defaultView; - this._commandOutputManager = options.commandOutputManager || - canon.commandOutputManager; - this._commandOutputManager.onOutput.add(this._outputted, this); + this._requisition.commandOutputManager.onOutput.add(this._outputted, this); this._blurDelayTimeout = null; // Result of setTimeout in delaying a blur this._monitoredElements = []; // See addMonitoredElement() @@ -7098,7 +7114,7 @@ FocusManager.prototype.destroy = function() { eagerHelper.onChange.remove(this._eagerHelperChanged, this); this._document.removeEventListener('focus', this._focused, true); - this._commandOutputManager.onOutput.remove(this._outputted, this); + this._requisition.commandOutputManager.onOutput.remove(this._outputted, this); for (var i = 0; i < this._monitoredElements.length; i++) { var monitor = this._monitoredElements[i]; @@ -7116,7 +7132,7 @@ FocusManager.prototype.destroy = function() { delete this._focused; delete this._document; delete this._window; - delete this._commandOutputManager; + delete this._requisition; }; /** @@ -9075,7 +9091,7 @@ var resource = require('gcli/types/resource'); var host = require('gcli/host'); var intro = require('gcli/ui/intro'); -var commandOutputManager = require('gcli/canon').commandOutputManager; +var CommandOutputManager = require('gcli/canon').CommandOutputManager; /** * Handy utility to inject the content document (i.e. for the viewed page, @@ -9111,6 +9127,7 @@ function setContentDocument(document) { * - environment * - scratchpad (optional) * - chromeWindow + * - commandOutputManager (optional) */ function FFDisplay(options) { if (options.eval) { @@ -9119,13 +9136,19 @@ function FFDisplay(options) { setContentDocument(options.contentDocument); host.chromeWindow = options.chromeWindow; - this.onOutput = commandOutputManager.onOutput; - this.requisition = new Requisition(options.environment, options.outputDocument); + this.commandOutputManager = options.commandOutputManager; + if (this.commandOutputManager == null) { + this.commandOutputManager = new CommandOutputManager(); + } + + this.onOutput = this.commandOutputManager.onOutput; + this.requisition = new Requisition(options.environment, + options.outputDocument, + this.commandOutputManager); - // Create a FocusManager for the various parts to register with this.focusManager = new FocusManager(options, { - // TODO: can we kill chromeDocument here? - document: options.chromeDocument + document: options.chromeDocument, + requisition: this.requisition, }); this.onVisibilityChange = this.focusManager.onVisibilityChange; @@ -9169,7 +9192,7 @@ function FFDisplay(options) { * separate method */ FFDisplay.prototype.maybeShowIntro = function() { - intro.maybeShowIntro(commandOutputManager); + intro.maybeShowIntro(this.commandOutputManager); }; /** @@ -9214,7 +9237,7 @@ FFDisplay.prototype.destroy = function() { // DOM node hunter script from looking in all the nooks and crannies, so it's // better if we can be leak-free without deleting them: // - consoleWrap, resizer, tooltip, completer, inputter, - // - focusManager, onVisibilityChange, requisition + // - focusManager, onVisibilityChange, requisition, commandOutputManager }; /** @@ -10008,7 +10031,8 @@ function Completer(options, components) { this.inputter.onAssignmentChange.add(this.update, this); this.inputter.onChoiceChange.add(this.update, this); - if (components.autoResize) { + this.autoResize = components.autoResize; + if (this.autoResize) { this.inputter.onResize.add(this.resized, this); var dimensions = this.inputter.getDimensions(); @@ -10031,7 +10055,10 @@ Completer.prototype.destroy = function() { this.inputter.onInputChange.remove(this.update, this); this.inputter.onAssignmentChange.remove(this.update, this); this.inputter.onChoiceChange.remove(this.update, this); - this.inputter.onResize.remove(this.resized, this); + + if (this.autoResize) { + this.inputter.onResize.remove(this.resized, this); + } delete this.document; delete this.element; diff --git a/browser/devtools/commandline/test/browser_gcli_exec.js b/browser/devtools/commandline/test/browser_gcli_exec.js index 01d35e5c875c..f6a2350de2aa 100644 --- a/browser/devtools/commandline/test/browser_gcli_exec.js +++ b/browser/devtools/commandline/test/browser_gcli_exec.js @@ -42,7 +42,7 @@ function test() { var Requisition = require('gcli/cli').Requisition; -var canon = require('gcli/canon'); +var CommandOutputManager = require('gcli/canon').CommandOutputManager; // var mockCommands = require('gclitest/mockCommands'); var nodetype = require('gcli/types/node'); @@ -53,16 +53,22 @@ var actualOutput; var hideExec = false; var skip = 'skip'; -exports.setup = function() { +var environment = { value: 'example environment data' }; +var commandOutputManager = new CommandOutputManager(); +var requisition = new Requisition(environment, null, commandOutputManager); + +exports.setup = function(options) { mockCommands.setup(); mockCommands.onCommandExec.add(commandExeced); - canon.commandOutputManager.onOutput.add(commandOutputed); + + commandOutputManager.onOutput.add(commandOutputed); }; -exports.shutdown = function() { +exports.shutdown = function(options) { mockCommands.shutdown(); mockCommands.onCommandExec.remove(commandExeced); - canon.commandOutputManager.onOutput.remove(commandOutputed); + + commandOutputManager.onOutput.remove(commandOutputed); }; function commandExeced(ev) { @@ -74,9 +80,6 @@ function commandOutputed(ev) { } function exec(command, expectedArgs) { - var environment = {}; - - var requisition = new Requisition(environment); var outputObject = requisition.exec({ typed: command, hidden: hideExec }); assert.is(command.indexOf(actualExec.command.name), 0, 'Command name: ' + command); diff --git a/browser/devtools/framework/Toolbox.jsm b/browser/devtools/framework/Toolbox.jsm index 21e216a55e17..3e1fd33a1f38 100644 --- a/browser/devtools/framework/Toolbox.jsm +++ b/browser/devtools/framework/Toolbox.jsm @@ -16,6 +16,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Hosts", "resource:///modules/devtools/ToolboxHosts.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "CommandUtils", "resource:///modules/devtools/DeveloperToolbar.jsm"); + XPCOMUtils.defineLazyGetter(this, "toolboxStrings", function() { let bundle = Services.strings.createBundle("chrome://browser/locale/devtools/toolbox.properties"); let l10n = function(name) { @@ -28,13 +29,12 @@ XPCOMUtils.defineLazyGetter(this, "toolboxStrings", function() { return l10n; }); -// DO NOT put Require.jsm or gcli.jsm into lazy getters as this breaks the -// requisition import a few lines down. -Cu.import("resource:///modules/devtools/gcli.jsm"); -Cu.import("resource://gre/modules/devtools/Require.jsm"); +XPCOMUtils.defineLazyGetter(this, "Requisition", function() { + Cu.import("resource://gre/modules/devtools/Require.jsm"); + Cu.import("resource:///modules/devtools/gcli.jsm"); -let Requisition = require('gcli/cli').Requisition; -let CommandOutputManager = require('gcli/canon').CommandOutputManager; + return require('gcli/cli').Requisition; +}); this.EXPORTED_SYMBOLS = [ "Toolbox" ]; @@ -334,7 +334,6 @@ Toolbox.prototype = { let toolbarSpec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec"); let environment = { chromeDocument: frame.ownerDocument }; let requisition = new Requisition(environment); - requisition.commandOutputManager = new CommandOutputManager(); let buttons = CommandUtils.createButtons(toolbarSpec, this._target, this.doc, requisition); diff --git a/browser/devtools/shared/DeveloperToolbar.jsm b/browser/devtools/shared/DeveloperToolbar.jsm index 311160a0608f..d76d782c4d96 100644 --- a/browser/devtools/shared/DeveloperToolbar.jsm +++ b/browser/devtools/shared/DeveloperToolbar.jsm @@ -456,7 +456,12 @@ DeveloperToolbar.prototype.hide = function DT_hide() */ DeveloperToolbar.prototype.destroy = function DT_destroy() { + if (this._lastState == NOTIFICATIONS.HIDE) { + return; + } + this._chromeWindow.getBrowser().tabContainer.removeEventListener("TabSelect", this, false); + this._chromeWindow.getBrowser().tabContainer.removeEventListener("TabClose", this, false); this._chromeWindow.getBrowser().removeEventListener("load", this, true); this._chromeWindow.getBrowser().removeEventListener("beforeunload", this, true); @@ -483,6 +488,8 @@ DeveloperToolbar.prototype.destroy = function DT_destroy() delete this.outputPanel; delete this.tooltipPanel; */ + + this._lastState = NOTIFICATIONS.HIDE; }; /** From d58782e82b748150a8b6a5d4353763544c846949 Mon Sep 17 00:00:00 2001 From: Joe Walker Date: Fri, 4 Jan 2013 20:31:38 +0000 Subject: [PATCH 160/180] Bug 820436 - Buttons are unresponsive after previously closing the Developer Tools Window; r=paul --- browser/devtools/framework/Toolbox.jsm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/browser/devtools/framework/Toolbox.jsm b/browser/devtools/framework/Toolbox.jsm index 3e1fd33a1f38..e28354c9bd64 100644 --- a/browser/devtools/framework/Toolbox.jsm +++ b/browser/devtools/framework/Toolbox.jsm @@ -260,7 +260,7 @@ Toolbox.prototype = { this._buildDockButtons(); this._buildTabs(); - this._buildButtons(this.frame); + this._buildButtons(); this.selectTool(this._defaultToolId).then(function(panel) { this.emit("ready"); @@ -322,17 +322,14 @@ Toolbox.prototype = { /** * Add buttons to the UI as specified in the devtools.window.toolbarSpec pref - * - * @param {iframe} frame - * The iframe to contain the buttons */ - _buildButtons: function TBOX_buildButtons(frame) { - if (this.target.isRemote) { + _buildButtons: function TBOX_buildButtons() { + if (!this.target.isLocalTab) { return; } let toolbarSpec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec"); - let environment = { chromeDocument: frame.ownerDocument }; + let environment = { chromeDocument: this.target.tab.ownerDocument }; let requisition = new Requisition(environment); let buttons = CommandUtils.createButtons(toolbarSpec, this._target, this.doc, requisition); From f07bc4f1320eba9e840747b4267063aa4938b166 Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Fri, 4 Jan 2013 21:34:43 +0200 Subject: [PATCH 161/180] Implement a new addAllGlobalsAsDebuggees method for faster chrome debugging (bug 821701); r=jimb Also GC only once when going through all compartments in both addAllGlobalsAsDebuggees and removeAllDebuggees, instead of once for every debuggee added or removed. --- browser/devtools/debugger/test/Makefile.in | 2 +- .../test/browser_dbg_chrome-debugging.js | 3 -- .../tests/debug/Debugger-debuggees-20.js | 28 +++++++++++ js/src/jscompartment.cpp | 21 ++++++++- js/src/jscompartment.h | 5 ++ js/src/vm/Debugger.cpp | 47 +++++++++++++++++-- js/src/vm/Debugger.h | 7 +++ .../debugger/server/dbg-script-actors.js | 6 +-- 8 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 js/src/jit-test/tests/debug/Debugger-debuggees-20.js diff --git a/browser/devtools/debugger/test/Makefile.in b/browser/devtools/debugger/test/Makefile.in index e641bef4d3cf..c71dba794f48 100644 --- a/browser/devtools/debugger/test/Makefile.in +++ b/browser/devtools/debugger/test/Makefile.in @@ -87,7 +87,7 @@ MOCHITEST_BROWSER_TESTS = \ browser_dbg_breakpoint-new-script.js \ browser_dbg_bug737803_editor_actual_location.js \ browser_dbg_progress-listener-bug.js \ - $(filter disabled-for-intermittent-crashes--bug-821701, browser_dbg_chrome-debugging.js) \ + browser_dbg_chrome-debugging.js \ $(filter disabled-for-intermittent-failures--bug-753225, browser_dbg_createRemote.js) \ head.js \ $(NULL) diff --git a/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js b/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js index 1342791aed43..faf3d351224b 100644 --- a/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js +++ b/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js @@ -16,9 +16,6 @@ const DEBUGGER_TAB_URL = EXAMPLE_URL + "browser_dbg_debuggerstatement.html"; function test() { - // Make sure there is enough time for findAllGlobals. - requestLongerTimeout(3); - let transport = DebuggerServer.connectPipe(); gClient = new DebuggerClient(transport); gClient.connect(function(aType, aTraits) { diff --git a/js/src/jit-test/tests/debug/Debugger-debuggees-20.js b/js/src/jit-test/tests/debug/Debugger-debuggees-20.js new file mode 100644 index 000000000000..16319f8a2ca9 --- /dev/null +++ b/js/src/jit-test/tests/debug/Debugger-debuggees-20.js @@ -0,0 +1,28 @@ +// addAllGlobalsAsDebuggees adds all the globals as debuggees. + +var g1 = newGlobal(); // Created before the Debugger; debuggee. +var g2 = newGlobal(); // Created before the Debugger; not debuggee. + +var dbg = new Debugger; + +var g3 = newGlobal(); // Created after the Debugger; debuggee. +var g4 = newGlobal(); // Created after the Debugger; not debuggee. + +var g1w = dbg.addDebuggee(g1); +assertEq(dbg.addAllGlobalsAsDebuggees(), undefined); + +// Get Debugger.Objects viewing the globals from their own compartments; +// this is the sort that findAllGlobals and addDebuggee return. +var g1w = g1w.makeDebuggeeValue(g1).unwrap(); +var g2w = g1w.makeDebuggeeValue(g2).unwrap(); +var g3w = g1w.makeDebuggeeValue(g3).unwrap(); +var g4w = g1w.makeDebuggeeValue(g4).unwrap(); +var thisw = g1w.makeDebuggeeValue(this).unwrap(); + +// Check that they're all there. +assertEq(dbg.hasDebuggee(g1w), true); +assertEq(dbg.hasDebuggee(g2w), true); +assertEq(dbg.hasDebuggee(g3w), true); +assertEq(dbg.hasDebuggee(g4w), true); +// The debugger's global is not a debuggee. +assertEq(dbg.hasDebuggee(thisw), false); diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index 2a2c3baf0dbf..03c34df2b4dd 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -883,6 +883,15 @@ JSCompartment::updateForDebugMode(FreeOp *fop, AutoDebugModeGC &dmgc) bool JSCompartment::addDebuggee(JSContext *cx, js::GlobalObject *global) +{ + AutoDebugModeGC dmgc(cx->runtime); + return addDebuggee(cx, global, dmgc); +} + +bool +JSCompartment::addDebuggee(JSContext *cx, + js::GlobalObject *global, + AutoDebugModeGC &dmgc) { bool wasEnabled = debugMode(); if (!debuggees.put(global)) { @@ -891,7 +900,6 @@ JSCompartment::addDebuggee(JSContext *cx, js::GlobalObject *global) } debugModeBits |= DebugFromJS; if (!wasEnabled) { - AutoDebugModeGC dmgc(cx->runtime); updateForDebugMode(cx->runtime->defaultFreeOp(), dmgc); } return true; @@ -901,6 +909,16 @@ void JSCompartment::removeDebuggee(FreeOp *fop, js::GlobalObject *global, js::GlobalObjectSet::Enum *debuggeesEnum) +{ + AutoDebugModeGC dmgc(rt); + return removeDebuggee(fop, global, dmgc, debuggeesEnum); +} + +void +JSCompartment::removeDebuggee(FreeOp *fop, + js::GlobalObject *global, + AutoDebugModeGC &dmgc, + js::GlobalObjectSet::Enum *debuggeesEnum) { bool wasEnabled = debugMode(); JS_ASSERT(debuggees.has(global)); @@ -912,7 +930,6 @@ JSCompartment::removeDebuggee(FreeOp *fop, if (debuggees.empty()) { debugModeBits &= ~DebugFromJS; if (wasEnabled && !debugMode()) { - AutoDebugModeGC dmgc(rt); DebugScopes::onCompartmentLeaveDebugMode(this); updateForDebugMode(fop, dmgc); } diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index ef30980e1664..95e95274097f 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -499,8 +499,13 @@ struct JSCompartment : private JS::shadow::Compartment, public js::gc::GraphNode public: js::GlobalObjectSet &getDebuggees() { return debuggees; } bool addDebuggee(JSContext *cx, js::GlobalObject *global); + bool addDebuggee(JSContext *cx, js::GlobalObject *global, + js::AutoDebugModeGC &dmgc); void removeDebuggee(js::FreeOp *fop, js::GlobalObject *global, js::GlobalObjectSet::Enum *debuggeesEnum = NULL); + void removeDebuggee(js::FreeOp *fop, js::GlobalObject *global, + js::AutoDebugModeGC &dmgc, + js::GlobalObjectSet::Enum *debuggeesEnum = NULL); bool setDebugModeFromC(JSContext *cx, bool b, js::AutoDebugModeGC &dmgc); void clearBreakpointsIn(js::FreeOp *fop, js::Debugger *dbg, JSObject *handler); diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 1e4e3ea6d346..76a63cbdf03f 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -1881,6 +1881,26 @@ Debugger::addDebuggee(JSContext *cx, unsigned argc, Value *vp) return true; } +JSBool +Debugger::addAllGlobalsAsDebuggees(JSContext *cx, unsigned argc, Value *vp) +{ + THIS_DEBUGGER(cx, argc, vp, "addAllGlobalsAsDebuggees", args, dbg); + AutoDebugModeGC dmgc(cx->runtime); + for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) { + if (c == dbg->object->compartment()) + continue; + c->scheduledForDestruction = false; + GlobalObject *global = c->maybeGlobal(); + if (global) { + Rooted rg(cx, global); + dbg->addDebuggeeGlobal(cx, rg, dmgc); + } + } + + args.rval().setUndefined(); + return true; +} + JSBool Debugger::removeDebuggee(JSContext *cx, unsigned argc, Value *vp) { @@ -1899,8 +1919,9 @@ JSBool Debugger::removeAllDebuggees(JSContext *cx, unsigned argc, Value *vp) { THIS_DEBUGGER(cx, argc, vp, "removeAllDebuggees", args, dbg); + AutoDebugModeGC dmgc(cx->runtime); for (GlobalObjectSet::Enum e(dbg->debuggees); !e.empty(); e.popFront()) - dbg->removeDebuggeeGlobal(cx->runtime->defaultFreeOp(), e.front(), NULL, &e); + dbg->removeDebuggeeGlobal(cx->runtime->defaultFreeOp(), e.front(), dmgc, NULL, &e); args.rval().setUndefined(); return true; } @@ -2026,6 +2047,15 @@ Debugger::construct(JSContext *cx, unsigned argc, Value *vp) bool Debugger::addDebuggeeGlobal(JSContext *cx, Handle global) +{ + AutoDebugModeGC dmgc(cx->runtime); + return addDebuggeeGlobal(cx, global, dmgc); +} + +bool +Debugger::addDebuggeeGlobal(JSContext *cx, + Handle global, + AutoDebugModeGC &dmgc) { if (debuggees.has(global)) return true; @@ -2082,7 +2112,7 @@ Debugger::addDebuggeeGlobal(JSContext *cx, Handle global) } else { if (global->getDebuggers()->length() > 1) return true; - if (debuggeeCompartment->addDebuggee(cx, global)) + if (debuggeeCompartment->addDebuggee(cx, global, dmgc)) return true; /* Maintain consistency on error. */ @@ -2098,6 +2128,16 @@ void Debugger::removeDebuggeeGlobal(FreeOp *fop, GlobalObject *global, GlobalObjectSet::Enum *compartmentEnum, GlobalObjectSet::Enum *debugEnum) +{ + AutoDebugModeGC dmgc(global->compartment()->rt); + return removeDebuggeeGlobal(fop, global, dmgc, compartmentEnum, debugEnum); +} + +void +Debugger::removeDebuggeeGlobal(FreeOp *fop, GlobalObject *global, + AutoDebugModeGC &dmgc, + GlobalObjectSet::Enum *compartmentEnum, + GlobalObjectSet::Enum *debugEnum) { /* * Each debuggee is in two HashSets: one for its compartment and one for @@ -2151,7 +2191,7 @@ Debugger::removeDebuggeeGlobal(FreeOp *fop, GlobalObject *global, * global cannot be rooted on the stack without a cx. */ if (v->empty()) - global->compartment()->removeDebuggee(fop, global, compartmentEnum); + global->compartment()->removeDebuggee(fop, global, dmgc, compartmentEnum); } /* @@ -2538,6 +2578,7 @@ JSPropertySpec Debugger::properties[] = { JSFunctionSpec Debugger::methods[] = { JS_FN("addDebuggee", Debugger::addDebuggee, 1, 0), + JS_FN("addAllGlobalsAsDebuggees", Debugger::addAllGlobalsAsDebuggees, 0, 0), JS_FN("removeDebuggee", Debugger::removeDebuggee, 1, 0), JS_FN("removeAllDebuggees", Debugger::removeAllDebuggees, 0, 0), JS_FN("hasDebuggee", Debugger::hasDebuggee, 1, 0), diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index 084a60d16863..354cda66f51d 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -225,9 +225,15 @@ class Debugger : private mozilla::LinkedListElement class ScriptQuery; bool addDebuggeeGlobal(JSContext *cx, Handle obj); + bool addDebuggeeGlobal(JSContext *cx, Handle obj, + AutoDebugModeGC &dmgc); void removeDebuggeeGlobal(FreeOp *fop, GlobalObject *global, GlobalObjectSet::Enum *compartmentEnum, GlobalObjectSet::Enum *debugEnum); + void removeDebuggeeGlobal(FreeOp *fop, GlobalObject *global, + AutoDebugModeGC &dmgc, + GlobalObjectSet::Enum *compartmentEnum, + GlobalObjectSet::Enum *debugEnum); /* * Cope with an error or exception in a debugger hook. @@ -300,6 +306,7 @@ class Debugger : private mozilla::LinkedListElement static JSBool getUncaughtExceptionHook(JSContext *cx, unsigned argc, Value *vp); static JSBool setUncaughtExceptionHook(JSContext *cx, unsigned argc, Value *vp); static JSBool addDebuggee(JSContext *cx, unsigned argc, Value *vp); + static JSBool addAllGlobalsAsDebuggees(JSContext *cx, unsigned argc, Value *vp); static JSBool removeDebuggee(JSContext *cx, unsigned argc, Value *vp); static JSBool removeAllDebuggees(JSContext *cx, unsigned argc, Value *vp); static JSBool hasDebuggee(JSContext *cx, unsigned argc, Value *vp); diff --git a/toolkit/devtools/debugger/server/dbg-script-actors.js b/toolkit/devtools/debugger/server/dbg-script-actors.js index 0c7aafa9704a..9c4ae00ce5da 100644 --- a/toolkit/devtools/debugger/server/dbg-script-actors.js +++ b/toolkit/devtools/debugger/server/dbg-script-actors.js @@ -2266,10 +2266,8 @@ update(ChromeDebuggerActor.prototype, { */ globalManager: { findGlobals: function CDA_findGlobals() { - // Fetch the list of globals from the debugger. - for (let g of this.dbg.findAllGlobals()) { - this.addDebuggee(g); - } + // Add every global known to the debugger as debuggee. + this.dbg.addAllGlobalsAsDebuggees(); }, /** From 6593bde8658ad7e0c2e4f6f84668c7dcdee88be8 Mon Sep 17 00:00:00 2001 From: Heather Arthur Date: Thu, 3 Jan 2013 02:34:00 +0200 Subject: [PATCH 162/180] Bug 826180 - No stylesheets shown after reloading a page with an iframe; r=paul --- browser/devtools/framework/Target.jsm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/browser/devtools/framework/Target.jsm b/browser/devtools/framework/Target.jsm index 77889e56ab25..af7d2177ec5f 100644 --- a/browser/devtools/framework/Target.jsm +++ b/browser/devtools/framework/Target.jsm @@ -286,7 +286,8 @@ TabWebProgressListener.prototype = { return; } - if (this.target) { + // emit event if the top frame is navigating + if (this.target && this.target.window == progress.DOMWindow) { this.target.emit("will-navigate", request); } }, From d971b685ae52f0a83e79750daf0225eb02e2d087 Mon Sep 17 00:00:00 2001 From: Sergiu Dumitriu Date: Fri, 4 Jan 2013 06:01:00 +0200 Subject: [PATCH 163/180] Bug 826563 - CSS validation errors in toolbox.css. r=paul --- browser/themes/gnomestripe/devtools/toolbox.css | 14 +++++++------- browser/themes/pinstripe/devtools/toolbox.css | 14 +++++++------- browser/themes/winstripe/devtools/toolbox.css | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/browser/themes/gnomestripe/devtools/toolbox.css b/browser/themes/gnomestripe/devtools/toolbox.css index de87e46d4ccc..21f037a91f8a 100644 --- a/browser/themes/gnomestripe/devtools/toolbox.css +++ b/browser/themes/gnomestripe/devtools/toolbox.css @@ -72,7 +72,7 @@ } #command-button-responsive { - list-style-image: url(chrome://browser/skin/devtools/command-responsivemode.png); + list-style-image: url("chrome://browser/skin/devtools/command-responsivemode.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } #command-button-responsive:hover { @@ -86,7 +86,7 @@ } #command-button-tilt { - list-style-image: url(chrome://browser/skin/devtools/command-tilt.png); + list-style-image: url("chrome://browser/skin/devtools/command-tilt.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } #command-button-tilt:hover { @@ -102,7 +102,7 @@ } #command-button-scratchpad { - list-style-image: url(chrome://browser/skin/devtools/command-scratchpad.png); + list-style-image: url("chrome://browser/skin/devtools/command-scratchpad.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } @@ -119,7 +119,7 @@ .devtools-tabbar { -moz-appearance: none; - background-image: url(background-noise-toolbar.png), + background-image: url("background-noise-toolbar.png"), linear-gradient(#303840, #2d3640); border-top: 1px solid #060a0d; box-shadow: 0 1px 0 hsla(204,45%,98%,.05) inset, @@ -173,7 +173,7 @@ background-image: linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(206,37%,4%,.1), hsla(206,37%,4%,.2)); - background size: 1px 100%, + background-size: 1px 100%, 1px 100%, 100%; background-repeat: no-repeat, @@ -189,8 +189,8 @@ .devtools-tab[selected=true] { color: #f5f7fa; - background-image: radial-gradient(ellipse farthest-corner at center top, #9fdfff, hsla(200,100%,70%,.3)), - radial-gradient(ellipse farthest-side at center top, hsla(200,100%,70%,.4), hsla(200,100%,70%,0)), + background-image: radial-gradient(farthest-corner at center top, #9fdfff, hsla(200,100%,70%,.3)), + radial-gradient(farthest-side at center top, hsla(200,100%,70%,.4), hsla(200,100%,70%,0)), linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(204,45%,98%,.02), hsla(204,45%,98%,.04)), linear-gradient(hsla(206,37%,4%,.2), hsla(206,37%,4%,.3)); diff --git a/browser/themes/pinstripe/devtools/toolbox.css b/browser/themes/pinstripe/devtools/toolbox.css index 08d3c5f46f34..a7e7aa6e1288 100644 --- a/browser/themes/pinstripe/devtools/toolbox.css +++ b/browser/themes/pinstripe/devtools/toolbox.css @@ -59,7 +59,7 @@ } #command-button-responsive { - list-style-image: url(chrome://browser/skin/devtools/command-responsivemode.png); + list-style-image: url("chrome://browser/skin/devtools/command-responsivemode.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } #command-button-responsive:hover { @@ -73,7 +73,7 @@ } #command-button-tilt { - list-style-image: url(chrome://browser/skin/devtools/command-tilt.png); + list-style-image: url("chrome://browser/skin/devtools/command-tilt.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } #command-button-tilt:hover { @@ -89,7 +89,7 @@ } #command-button-scratchpad { - list-style-image: url(chrome://browser/skin/devtools/command-scratchpad.png); + list-style-image: url("chrome://browser/skin/devtools/command-scratchpad.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } @@ -106,7 +106,7 @@ .devtools-tabbar { -moz-appearance: none; - background-image: url(background-noise-toolbar.png), + background-image: url("background-noise-toolbar.png"), linear-gradient(#303840, #2d3640); border-top: 1px solid #060a0d; box-shadow: 0 1px 0 hsla(204,45%,98%,.05) inset, @@ -157,7 +157,7 @@ background-image: linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(206,37%,4%,.1), hsla(206,37%,4%,.2)); - background size: 1px 100%, + background-size: 1px 100%, 1px 100%, 100%; background-repeat: no-repeat, @@ -173,8 +173,8 @@ .devtools-tab[selected=true] { color: #f5f7fa; - background-image: radial-gradient(ellipse farthest-corner at center top, #9fdfff, hsla(200,100%,70%,.3)), - radial-gradient(ellipse farthest-side at center top, hsla(200,100%,70%,.4), hsla(200,100%,70%,0)), + background-image: radial-gradient(farthest-corner at center top, #9fdfff, hsla(200,100%,70%,.3)), + radial-gradient(farthest-side at center top, hsla(200,100%,70%,.4), hsla(200,100%,70%,0)), linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(204,45%,98%,.02), hsla(204,45%,98%,.04)), linear-gradient(hsla(206,37%,4%,.2), hsla(206,37%,4%,.3)); diff --git a/browser/themes/winstripe/devtools/toolbox.css b/browser/themes/winstripe/devtools/toolbox.css index 203e7ef2cd82..b4c64d310bba 100644 --- a/browser/themes/winstripe/devtools/toolbox.css +++ b/browser/themes/winstripe/devtools/toolbox.css @@ -75,7 +75,7 @@ } #command-button-responsive { - list-style-image: url(chrome://browser/skin/devtools/command-responsivemode.png); + list-style-image: url("chrome://browser/skin/devtools/command-responsivemode.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } #command-button-responsive:hover { @@ -89,7 +89,7 @@ } #command-button-tilt { - list-style-image: url(chrome://browser/skin/devtools/command-tilt.png); + list-style-image: url("chrome://browser/skin/devtools/command-tilt.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } #command-button-tilt:hover { @@ -105,7 +105,7 @@ } #command-button-scratchpad { - list-style-image: url(chrome://browser/skin/devtools/command-scratchpad.png); + list-style-image: url("chrome://browser/skin/devtools/command-scratchpad.png"); -moz-image-region: rect(0px, 16px, 16px, 0px); } @@ -122,7 +122,7 @@ .devtools-tabbar { -moz-appearance: none; - background-image: url(background-noise-toolbar.png), + background-image: url("background-noise-toolbar.png"), linear-gradient(#303840, #2d3640); border: none; box-shadow: 0 1px 0 hsla(204,45%,98%,.05) inset, @@ -174,7 +174,7 @@ background-image: linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(206,37%,4%,.1), hsla(206,37%,4%,.2)); - background size: 1px 100%, + background-size: 1px 100%, 1px 100%, 100%; background-repeat: no-repeat, @@ -190,8 +190,8 @@ .devtools-tab[selected=true] { color: #f5f7fa; - background-image: radial-gradient(ellipse farthest-corner at center top, #9fdfff, hsla(200,100%,70%,.3)), - radial-gradient(ellipse farthest-side at center top, hsla(200,100%,70%,.4), hsla(200,100%,70%,0)), + background-image: radial-gradient(farthest-corner at center top, #9fdfff, hsla(200,100%,70%,.3)), + radial-gradient(farthest-side at center top, hsla(200,100%,70%,.4), hsla(200,100%,70%,0)), linear-gradient(hsla(204,45%,98%,.05), hsla(204,45%,98%,.1)), linear-gradient(hsla(204,45%,98%,.02), hsla(204,45%,98%,.04)), linear-gradient(hsla(206,37%,4%,.2), hsla(206,37%,4%,.3)); From 378de2ffac0a2b2665d42d09928531a7e6d29249 Mon Sep 17 00:00:00 2001 From: Victor Porof Date: Fri, 4 Jan 2013 09:37:18 +0200 Subject: [PATCH 164/180] Bug 824487 - Transition event callbacks sometimes don't fire, r=rcampbell --- browser/devtools/debugger/debugger-panes.js | 3 +- browser/devtools/debugger/debugger-toolbar.js | 3 +- browser/devtools/debugger/debugger-view.js | 65 ++++++++++++------- browser/devtools/shared/VariablesView.jsm | 3 +- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/browser/devtools/debugger/debugger-panes.js b/browser/devtools/debugger/debugger-panes.js index efce1f0688e1..631e32867808 100644 --- a/browser/devtools/debugger/debugger-panes.js +++ b/browser/devtools/debugger/debugger-panes.js @@ -1739,12 +1739,11 @@ create({ constructor: GlobalSearchView, proto: MenuContainer.prototype }, { */ _bounceMatch: function DVGS__bounceMatch(aMatch) { Services.tm.currentThread.dispatch({ run: function() { - aMatch.setAttribute("focused", ""); - aMatch.addEventListener("transitionend", function onEvent() { aMatch.removeEventListener("transitionend", onEvent); aMatch.removeAttribute("focused"); }); + aMatch.setAttribute("focused", ""); }}, 0); }, diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index ff7dc15dc70d..90a5ae7737c9 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -113,7 +113,8 @@ ToolbarView.prototype = { _onTogglePanesPressed: function DVT__onTogglePanesPressed() { DebuggerView.togglePanes({ visible: DebuggerView.panesHidden, - animated: true + animated: true, + delayed: true }); }, diff --git a/browser/devtools/debugger/debugger-view.js b/browser/devtools/debugger/debugger-view.js index 86d82686727e..490ca1bcac65 100644 --- a/browser/devtools/debugger/debugger-view.js +++ b/browser/devtools/debugger/debugger-view.js @@ -394,47 +394,61 @@ let DebuggerView = { * An object containing some of the following boolean properties: * - visible: true if the pane should be shown, false for hidden * - animated: true to display an animation on toggle + * - delayed: true to wait a few cycles before toggle * - callback: a function to invoke when the panes toggle finishes */ togglePanes: function DV__togglePanes(aFlags = {}) { // Avoid useless toggles. if (aFlags.visible == !this.panesHidden) { - aFlags.callback && aFlags.callback(); + if (aFlags.callback) aFlags.callback(); return; } - if (aFlags.visible) { - this._stackframesAndBreakpoints.style.marginLeft = "0"; - this._variablesAndExpressions.style.marginRight = "0"; - this._togglePanesButton.removeAttribute("panesHidden"); - this._togglePanesButton.setAttribute("tooltiptext", L10N.getStr("collapsePanes")); - } else { - let marginL = ~~(this._stackframesAndBreakpoints.getAttribute("width")) + 1; - let marginR = ~~(this._variablesAndExpressions.getAttribute("width")) + 1; - this._stackframesAndBreakpoints.style.marginLeft = -marginL + "px"; - this._variablesAndExpressions.style.marginRight = -marginR + "px"; - this._togglePanesButton.setAttribute("panesHidden", "true"); - this._togglePanesButton.setAttribute("tooltiptext", L10N.getStr("expandPanes")); + // Computes and sets the panes margins in order to hide or show them. + function set() { + if (aFlags.visible) { + this._stackframesAndBreakpoints.style.marginLeft = "0"; + this._variablesAndExpressions.style.marginRight = "0"; + this._togglePanesButton.removeAttribute("panesHidden"); + this._togglePanesButton.setAttribute("tooltiptext", L10N.getStr("collapsePanes")); + } else { + let marginL = ~~(this._stackframesAndBreakpoints.getAttribute("width")) + 1; + let marginR = ~~(this._variablesAndExpressions.getAttribute("width")) + 1; + this._stackframesAndBreakpoints.style.marginLeft = -marginL + "px"; + this._variablesAndExpressions.style.marginRight = -marginR + "px"; + this._togglePanesButton.setAttribute("panesHidden", "true"); + this._togglePanesButton.setAttribute("tooltiptext", L10N.getStr("expandPanes")); + } + + if (aFlags.animated) { + // Displaying the panes may have the effect of triggering scrollbars to + // appear in the source editor, which would render the currently + // highlighted line to appear behind them in some cases. + window.addEventListener("transitionend", function onEvent() { + window.removeEventListener("transitionend", onEvent, false); + DebuggerView.updateEditor(); + + // Invoke the callback when the transition ended. + if (aFlags.callback) aFlags.callback(); + }, false); + } else { + // Invoke the callback immediately since there's no transition. + if (aFlags.callback) aFlags.callback(); + } } if (aFlags.animated) { this._stackframesAndBreakpoints.setAttribute("animated", ""); this._variablesAndExpressions.setAttribute("animated", ""); - - // Displaying the panes may have the effect of triggering scrollbars to - // appear in the source editor, which would render the currently - // highlighted line to appear behind them in some cases. - let self = this; - - window.addEventListener("transitionend", function onEvent() { - window.removeEventListener("transitionend", onEvent, false); - aFlags.callback && aFlags.callback(); - self.updateEditor(); - }, false); } else { this._stackframesAndBreakpoints.removeAttribute("animated"); this._variablesAndExpressions.removeAttribute("animated"); - aFlags.callback && aFlags.callback(); + } + + if (aFlags.delayed) { + window.setTimeout(set.bind(this), PANES_APPEARANCE_DELAY); + } else { + set.call(this); } }, @@ -450,6 +464,7 @@ let DebuggerView = { DebuggerView.togglePanes({ visible: true, animated: true, + delayed: true, callback: aCallback }); }, PANES_APPEARANCE_DELAY); diff --git a/browser/devtools/shared/VariablesView.jsm b/browser/devtools/shared/VariablesView.jsm index dd36454f8af6..ae19742d5c15 100644 --- a/browser/devtools/shared/VariablesView.jsm +++ b/browser/devtools/shared/VariablesView.jsm @@ -1683,12 +1683,11 @@ VariablesView.prototype.commitHierarchy = function VV_commitHierarchy() { // Dispatch this action after all the nodes have been drawn, so that // the transition efects can take place. this.window.setTimeout(function(aTarget) { - aTarget.setAttribute("changed", ""); - aTarget.addEventListener("transitionend", function onEvent() { aTarget.removeEventListener("transitionend", onEvent, false); aTarget.removeAttribute("changed"); }, false); + aTarget.setAttribute("changed", ""); }.bind(this, currVariable.target), LAZY_EMPTY_DELAY + 1); } }; From 480e7cc1c846ac2596a6594f7844378f060a6735 Mon Sep 17 00:00:00 2001 From: Jet Villegas Date: Fri, 4 Jan 2013 16:17:33 -0800 Subject: [PATCH 165/180] Bug 822854: Crash [@ nsRuleNode::ComputeColumnData] with -moz-column-rule-color: inherit r=heycam --- layout/style/nsRuleNode.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index e43121e70247..e31548f8d54c 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -7139,7 +7139,12 @@ nsRuleNode::ComputeColumnData(void* aStartStruct, canStoreInRuleTree = false; column->mColumnRuleColorIsForeground = false; if (parent->mColumnRuleColorIsForeground) { - column->mColumnRuleColor = parentContext->GetStyleColor()->mColor; + if (parentContext) { + column->mColumnRuleColor = parentContext->GetStyleColor()->mColor; + } else { + nsStyleColor defaultColumnRuleColor(mPresContext); + column->mColumnRuleColor = defaultColumnRuleColor.mColor; + } } else { column->mColumnRuleColor = parent->mColumnRuleColor; } From 970988bc3c739b7205f4a592598e249799b6efe3 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:24 +1300 Subject: [PATCH 166/180] Bug 826632. Part 1: Merge nsIViewManager into nsViewManager. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : d00947c925b17f860fcdc0e12b1ec3cc31b7c630 --- accessible/src/generic/DocAccessible.cpp | 4 +- accessible/src/mac/RootAccessibleWrap.mm | 2 +- accessible/src/msaa/AccessibleWrap.cpp | 4 +- accessible/src/msaa/DocAccessibleWrap.cpp | 2 +- content/base/public/nsIDocument.h | 4 +- content/base/src/Element.cpp | 2 +- content/base/src/FragmentOrElement.cpp | 2 +- content/base/src/nsContentSink.cpp | 6 +- content/base/src/nsContentSink.h | 2 +- content/base/src/nsContentUtils.cpp | 6 +- content/base/src/nsDocument.cpp | 4 +- content/base/src/nsDocument.h | 4 +- content/base/src/nsINode.cpp | 2 +- content/events/src/nsEventListenerManager.cpp | 2 +- content/events/src/nsIMEStateManager.cpp | 2 +- .../html/content/src/nsGenericHTMLElement.cpp | 2 +- content/html/document/src/MediaDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.cpp | 2 +- content/html/document/src/nsHTMLDocument.h | 2 +- content/xml/document/src/nsXMLContentSink.h | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- .../xul/content/src/nsXULPopupListener.cpp | 2 +- content/xul/document/src/nsXULContentSink.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 2 +- docshell/base/nsDocShell.cpp | 14 +- dom/base/nsDOMWindowUtils.cpp | 4 +- dom/base/nsFocusManager.cpp | 12 +- dom/base/nsGlobalWindow.cpp | 4 +- dom/ipc/TabParent.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +- .../webBrowser/nsDocShellTreeOwner.cpp | 4 +- extensions/widgetutils/src/nsWidgetUtils.cpp | 4 +- layout/base/nsCSSFrameConstructor.cpp | 4 +- layout/base/nsCSSRendering.cpp | 2 +- layout/base/nsCSSRenderingBorders.cpp | 2 +- layout/base/nsDisplayList.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 16 +- layout/base/nsIDocumentViewerPrint.h | 6 +- layout/base/nsIPresShell.h | 8 +- layout/base/nsPresContext.cpp | 4 +- layout/base/nsPresShell.cpp | 16 +- layout/base/nsPresShell.h | 2 +- layout/base/nsRefreshDriver.cpp | 4 +- layout/forms/nsComboboxControlFrame.cpp | 6 +- layout/forms/nsListControlFrame.cpp | 2 +- layout/forms/nsTextControlFrame.cpp | 2 +- layout/generic/nsContainerFrame.cpp | 16 +- layout/generic/nsFrame.cpp | 4 +- layout/generic/nsFrameSetFrame.cpp | 2 +- layout/generic/nsGfxScrollFrame.cpp | 2 +- layout/generic/nsObjectFrame.cpp | 10 +- layout/generic/nsSubDocumentFrame.cpp | 8 +- layout/printing/nsPrintEngine.cpp | 4 +- layout/printing/nsPrintObject.h | 4 +- .../src/nsLayoutDebuggingTools.cpp | 8 +- .../layout-debug/src/nsRegressionTester.cpp | 2 +- layout/xul/base/src/nsBoxFrame.cpp | 2 +- layout/xul/base/src/nsDeckFrame.cpp | 2 +- layout/xul/base/src/nsLeafBoxFrame.cpp | 2 +- layout/xul/base/src/nsListBoxBodyFrame.cpp | 2 +- layout/xul/base/src/nsMenuPopupFrame.cpp | 10 +- layout/xul/base/src/nsMenuPopupFrame.h | 2 +- layout/xul/base/src/nsXULPopupManager.cpp | 6 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 2 +- view/public/Makefile.in | 2 +- view/public/nsView.h | 15 +- .../{nsIViewManager.h => nsViewManager.h} | 218 +++++++++++++++--- view/src/nsView.cpp | 2 +- view/src/nsViewManager.cpp | 14 +- view/src/nsViewManager.h | 214 ----------------- widget/android/nsWindow.cpp | 2 +- widget/cocoa/nsChildView.mm | 2 +- widget/gtk2/nsDragService.cpp | 4 +- widget/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/tests/TestWinTSF.cpp | 4 +- widget/xpwidgets/nsBaseDragService.cpp | 2 +- 76 files changed, 345 insertions(+), 418 deletions(-) rename view/public/{nsIViewManager.h => nsViewManager.h} (60%) delete mode 100644 view/src/nsViewManager.h diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 4163a9ed83fa..b579a96d2c02 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -35,7 +35,7 @@ #include "nsINameSpaceManager.h" #include "nsIPresShell.h" #include "nsIServiceManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsUnicharUtils.h" #include "nsIURI.h" @@ -1253,7 +1253,7 @@ DocAccessible::GetNativeWindow() const if (!mPresShell) return nullptr; - nsIViewManager* vm = mPresShell->GetViewManager(); + nsViewManager* vm = mPresShell->GetViewManager(); if (!vm) return nullptr; diff --git a/accessible/src/mac/RootAccessibleWrap.mm b/accessible/src/mac/RootAccessibleWrap.mm index 6e332c935850..729087d03468 100644 --- a/accessible/src/mac/RootAccessibleWrap.mm +++ b/accessible/src/mac/RootAccessibleWrap.mm @@ -10,7 +10,7 @@ #include "nsCOMPtr.h" #include "nsObjCExceptions.h" #include "nsIWidget.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" using namespace mozilla::a11y; diff --git a/accessible/src/msaa/AccessibleWrap.cpp b/accessible/src/msaa/AccessibleWrap.cpp index 4f0704b5ff62..ec20bad885d4 100644 --- a/accessible/src/msaa/AccessibleWrap.cpp +++ b/accessible/src/msaa/AccessibleWrap.cpp @@ -34,7 +34,7 @@ #include "nsIServiceManager.h" #include "nsTextFormatter.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventMap.h" #include "nsArrayUtils.h" #include "mozilla/Preferences.h" @@ -1653,7 +1653,7 @@ AccessibleWrap::GetHWNDFor(Accessible* aAccessible) nsIWidget* widget = frame->GetNearestWidget(); if (widget && widget->IsVisible()) { nsIPresShell* shell = document->PresShell(); - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (vm) { nsCOMPtr rootWidget; vm->GetRootWidget(getter_AddRefs(rootWidget)); diff --git a/accessible/src/msaa/DocAccessibleWrap.cpp b/accessible/src/msaa/DocAccessibleWrap.cpp index 8fd23d488887..876958f24dff 100644 --- a/accessible/src/msaa/DocAccessibleWrap.cpp +++ b/accessible/src/msaa/DocAccessibleWrap.cpp @@ -21,7 +21,7 @@ #include "nsISelectionController.h" #include "nsIServiceManager.h" #include "nsIURI.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWebNavigation.h" using namespace mozilla; diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 12544516354b..a8c45d36846e 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -65,7 +65,7 @@ class nsIStyleRule; class nsIStyleSheet; class nsIURI; class nsIVariant; -class nsIViewManager; +class nsViewManager; class nsPresContext; class nsRange; class nsScriptLoader; @@ -478,7 +478,7 @@ public: * presshell if the presshell should observe document mutations. */ virtual nsresult CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) = 0; virtual void DeleteShell() = 0; diff --git a/content/base/src/Element.cpp b/content/base/src/Element.cpp index bc5538b3a1fb..0f6a7a1e4f9e 100644 --- a/content/base/src/Element.cpp +++ b/content/base/src/Element.cpp @@ -94,7 +94,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsXBLInsertionPoint.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index e43cd5301611..fb51d78dde75 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -93,7 +93,7 @@ #include "nsContentCreatorFunctions.h" #include "nsIControllers.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsXBLInsertionPoint.h" #include "mozilla/css/StyleRule.h" /* For nsCSSSelectorList */ diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index a2bdec6a9cac..81bec6f4af40 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -25,7 +25,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsPresContext.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIAtom.h" #include "nsGkAtoms.h" #include "nsIDOMWindow.h" @@ -1371,7 +1371,7 @@ nsContentSink::DidProcessATokenImpl() // Check if there's a pending event if (sPendingEventMode != 0 && !mHasPendingEvent && (mDeflectedCount % sEventProbeRate) == 0) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1518,7 +1518,7 @@ nsContentSink::WillParseImpl(void) uint32_t currentTime = PR_IntervalToMicroseconds(PR_IntervalNow()); if (sEnablePerfMode == 0) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); uint32_t lastEventTime; vm->GetLastUserEventTime(lastEventTime); diff --git a/content/base/src/nsContentSink.h b/content/base/src/nsContentSink.h index 4cb8bbce8480..9537c801ab7c 100644 --- a/content/base/src/nsContentSink.h +++ b/content/base/src/nsContentSink.h @@ -34,7 +34,7 @@ class nsIParser; class nsIAtom; class nsIChannel; class nsIContent; -class nsIViewManager; +class nsViewManager; class nsNodeInfoManager; class nsScriptLoader; class nsIApplicationCache; diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index d2b910cea9e1..dd70005135a9 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -115,7 +115,7 @@ #include "nsTextEditorState.h" #include "nsIPluginHost.h" #include "nsICategoryManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventStateManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsParserConstants.h" @@ -6435,11 +6435,11 @@ nsContentUtils::WidgetForDocument(nsIDocument* aDoc) { nsIPresShell* shell = FindPresShellForDocument(aDoc); if (shell) { - nsIViewManager* VM = shell->GetViewManager(); + nsViewManager* VM = shell->GetViewManager(); if (VM) { nsView* rootView = VM->GetRootView(); if (rootView) { - nsView* displayRoot = nsIViewManager::GetDisplayRootFor(rootView); + nsView* displayRoot = nsViewManager::GetDisplayRootFor(rootView); if (displayRoot) { return displayRoot->GetNearestWidget(nullptr); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index fb018d1a03da..3cf1e8bd782f 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3119,7 +3119,7 @@ nsDocument::TryChannelCharset(nsIChannel *aChannel, } nsresult -nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager, +nsDocument::CreateShell(nsPresContext* aContext, nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { @@ -3132,7 +3132,7 @@ nsDocument::CreateShell(nsPresContext* aContext, nsIViewManager* aViewManager, nsresult nsDocument::doCreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, nsStyleSet* aStyleSet, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult) { diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index adbd2a66bd11..9da0d22572f2 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -568,7 +568,7 @@ public: * shared among multiple presentation shell's). */ virtual nsresult CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); virtual void DeleteShell(); @@ -1076,7 +1076,7 @@ public: protected: nsresult doCreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, nsStyleSet* aStyleSet, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode, nsIPresShell** aInstancePtrResult); diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 90eb565a7e4d..6ae96a8cfaed 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -74,7 +74,7 @@ #include "nsIServiceManager.h" #include "nsIURL.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWebNavigation.h" #include "nsIWidget.h" #include "nsLayoutStatics.h" diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 23c0174a27f8..e235fe40626d 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -27,7 +27,7 @@ #include "mozilla/dom/Element.h" #include "nsIFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsCOMPtr.h" #include "nsIServiceManager.h" #include "nsIScriptSecurityManager.h" diff --git a/content/events/src/nsIMEStateManager.cpp b/content/events/src/nsIMEStateManager.cpp index 75aa6b148fd0..216d1dea558e 100644 --- a/content/events/src/nsIMEStateManager.cpp +++ b/content/events/src/nsIMEStateManager.cpp @@ -6,7 +6,7 @@ #include "nsIMEStateManager.h" #include "nsCOMPtr.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIPresShell.h" #include "nsISupports.h" #include "nsPIDOMWindow.h" diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 559d8aea071a..d52947b19d9d 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -38,7 +38,7 @@ #include "nsIFrame.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsRange.h" #include "nsIPresShell.h" diff --git a/content/html/document/src/MediaDocument.cpp b/content/html/document/src/MediaDocument.cpp index 0f86c50208f7..7576db42357b 100644 --- a/content/html/document/src/MediaDocument.cpp +++ b/content/html/document/src/MediaDocument.cpp @@ -9,7 +9,7 @@ #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsIScrollable.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsITextToSubURI.h" #include "nsIURL.h" #include "nsIContentViewer.h" diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index a15ddf6b8c01..7f2b5bdaa3ca 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -305,7 +305,7 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup, nsresult nsHTMLDocument::CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult) { diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 2ceecf8c5c95..a7124471a44e 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -55,7 +55,7 @@ public: nsIPrincipal* aPrincipal); virtual nsresult CreateShell(nsPresContext* aContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsIPresShell** aInstancePtrResult); diff --git a/content/xml/document/src/nsXMLContentSink.h b/content/xml/document/src/nsXMLContentSink.h index a7c31295dbcb..140fb66be030 100644 --- a/content/xml/document/src/nsXMLContentSink.h +++ b/content/xml/document/src/nsXMLContentSink.h @@ -22,7 +22,7 @@ class nsIURI; class nsIContent; class nsINodeInfo; class nsIParser; -class nsIViewManager; +class nsViewManager; typedef enum { eXMLContentSinkState_InProlog, diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 0afe23e0538f..c87be6820afd 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -54,7 +54,7 @@ #include "mozilla/css/StyleRule.h" #include "nsIStyleSheet.h" #include "nsIURL.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsIXULDocument.h" #include "nsIXULTemplateBuilder.h" diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 26577548f2cd..4382be6ddae7 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -40,7 +40,7 @@ #include "nsIPresShell.h" #include "nsFocusManager.h" #include "nsPIDOMWindow.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsError.h" #include "nsMenuFrame.h" diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp index 3068587e3970..54eb53f8a48f 100644 --- a/content/xul/document/src/nsXULContentSink.cpp +++ b/content/xul/document/src/nsXULContentSink.cpp @@ -30,7 +30,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIServiceManager.h" #include "nsIURL.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIXULDocument.h" #include "nsIScriptSecurityManager.h" #include "nsLayoutCID.h" diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index ddebfd771566..583b8adebabe 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -30,7 +30,7 @@ #include "nsIBoxObject.h" #include "nsIChromeRegistry.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIContentViewer.h" #include "nsGUIEvent.h" #include "nsIDOMXULElement.h" diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c5a5b46bbad0..acde564214c6 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -66,7 +66,7 @@ #include "nsDOMJSUtils.h" #include "nsIInterfaceRequestorUtils.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScriptChannel.h" #include "nsIOfflineCacheUpdate.h" #include "nsITimedChannel.h" @@ -3249,7 +3249,7 @@ PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel) nsCOMPtr domwin(doc->GetWindow()); nsCOMPtr widget; - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { vm->GetWidget(getter_AddRefs(widget)); } @@ -5048,7 +5048,7 @@ nsDocShell::Repaint(bool aForce) nsCOMPtr presShell =GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsIViewManager* viewManager = presShell->GetViewManager(); + nsViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE); @@ -5115,7 +5115,7 @@ nsDocShell::GetVisibility(bool * aVisibility) return NS_OK; // get the view manager - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); // get the root view @@ -7388,7 +7388,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr oldPresShell = GetPresShell(); if (oldPresShell) { - nsIViewManager *vm = oldPresShell->GetViewManager(); + nsViewManager *vm = oldPresShell->GetViewManager(); if (vm) { nsView *oldRootView = vm->GetRootView(); @@ -7609,7 +7609,7 @@ nsDocShell::RestoreFromHistory() nsCOMPtr shell = GetPresShell(); - nsIViewManager *newVM = shell ? shell->GetViewManager() : nullptr; + nsViewManager *newVM = shell ? shell->GetViewManager() : nullptr; nsView *newRootView = newVM ? newVM->GetRootView() : nullptr; // Insert the new root view at the correct location in the view tree. @@ -7625,7 +7625,7 @@ nsDocShell::RestoreFromHistory() rootViewSibling = nullptr; } if (rootViewParent && newRootView && newRootView->GetParent() != rootViewParent) { - nsIViewManager *parentVM = rootViewParent->GetViewManager(); + nsViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { // InsertChild(parent, child, sib, true) inserts the child after // sib in content order, which is before sib in view order. BUT diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 77a94372207b..17501cdc436d 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -33,7 +33,7 @@ #include "nsJSEnvironment.h" #include "nsJSUtils.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMHTMLCanvasElement.h" #include "gfxContext.h" @@ -661,7 +661,7 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, nsCOMPtr presShell = presContext->PresShell(); if (!presShell) return NS_ERROR_FAILURE; - nsIViewManager* viewManager = presShell->GetViewManager(); + nsViewManager* viewManager = presShell->GetViewManager(); if (!viewManager) return NS_ERROR_FAILURE; nsView* view = viewManager->GetRootView(); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index f382d73e67fa..54bca81fa689 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -39,7 +39,7 @@ #include "nsIWebNavigation.h" #include "nsCaret.h" #include "nsIBaseWindow.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsFrameSelection.h" #include "mozilla/Selection.h" #include "nsXULPopupManager.h" @@ -1055,7 +1055,7 @@ nsFocusManager::EnsureCurrentWidgetFocused() if (docShell) { nsCOMPtr presShell = docShell->GetPresShell(); if (presShell) { - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1552,7 +1552,7 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, if (aAdjustWidgets && objectFrame && !sTestMode) { // note that the presshell's widget is being retrieved here, not the one // for the object frame. - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1726,7 +1726,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, objectFrameWidget = objectFrame->GetWidget(); } if (aAdjustWidgets && !objectFrameWidget && !sTestMode) { - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1812,7 +1812,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow, if (aAdjustWidgets && objectFrameWidget && mFocusedWindow == aWindow && mFocusedContent == nullptr && !sTestMode) { - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); @@ -1974,7 +1974,7 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow) if (!presShell) return; - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); if (vm) { nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 48f071dad082..011c79740d45 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -118,7 +118,7 @@ #include "nsIScriptSecurityManager.h" #include "nsIScrollableFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsISelectionController.h" #include "nsISelection.h" #include "nsIPrompt.h" @@ -11024,7 +11024,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor) nsCOMPtr presShell = mDocShell->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsIViewManager* vm = presShell->GetViewManager(); + nsViewManager* vm = presShell->GetViewManager(); NS_ENSURE_TRUE(vm, NS_ERROR_FAILURE); nsView* rootView = vm->GetRootView(); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 70a607aa7081..a64e07c96362 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -41,7 +41,7 @@ #include "nsIURI.h" #include "nsIMozBrowserFrame.h" #include "nsIScriptSecurityManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsIWindowWatcher.h" #include "nsNetUtil.h" @@ -883,7 +883,7 @@ TabParent::RecvGetWidgetNativeData(WindowsHandle* aValue) if (content) { nsIPresShell* shell = content->OwnerDoc()->GetShell(); if (shell) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); nsCOMPtr widget; vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index ac7ad95dbe2a..1f85478b3b57 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -45,7 +45,7 @@ using mozilla::DefaultXDisplay; #include "nsIWebBrowserChrome.h" #include "nsLayoutUtils.h" #include "nsIPluginWidget.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDocShellTreeOwner.h" #include "nsIDOMHTMLObjectElement.h" #include "nsIAppShell.h" @@ -693,7 +693,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #if defined(XP_WIN) || defined(XP_OS2) void** pvalue = (void**)value; - nsIViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager(); + nsViewManager* vm = mObjectFrame->PresContext()->GetPresShell()->GetViewManager(); if (!vm) return NS_ERROR_FAILURE; #if defined(XP_WIN) diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 68985c3cb8d3..b11429c539a6 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -61,7 +61,7 @@ #include "imgIContainer.h" #include "nsContextMenuInfo.h" #include "nsPresContext.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsEventListenerManager.h" #include "nsIDOMDragEvent.h" @@ -1443,7 +1443,7 @@ ChromeTooltipListener::sTooltipCallback(nsITimer *aTimer, nsIWidget* widget = nullptr; if (shell) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (vm) { nsView* view = vm->GetRootView(); if (view) { diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index 9810e14b0a81..1c17043fa445 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -36,7 +36,7 @@ #include "nsIDOMWheelEvent.h" #include "nsView.h" #include "nsGUIEvent.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIContentPolicy.h" #include "nsIDocShellTreeItem.h" #include "nsIContent.h" @@ -89,7 +89,7 @@ private: static void StopPanningCallback(nsITimer *timer, void *closure); nsCOMPtr mWidget; - nsCOMPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mTimer; }; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index f5d4dd66c202..21a9a2f24dc2 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -36,7 +36,7 @@ #include "nsIPresShell.h" #include "nsUnicharUtils.h" #include "nsStyleSet.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventStates.h" #include "nsStyleConsts.h" #include "nsTableOuterFrame.h" @@ -12023,7 +12023,7 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) return; // Make sure that the viewmanager will outlive the presshell - nsCOMPtr vm = mPresShell->GetViewManager(); + nsCOMPtr vm = mPresShell->GetViewManager(); // Processing the style changes could cause a flush that propagates to // the parent frame and thus destroys the pres shell. diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 98d67dd741d4..f8162d78d477 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -19,7 +19,7 @@ #include "nsIFrame.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIPresShell.h" #include "nsFrameManager.h" #include "nsStyleContext.h" diff --git a/layout/base/nsCSSRenderingBorders.cpp b/layout/base/nsCSSRenderingBorders.cpp index a28b2a7dc2b1..07fe86babf11 100644 --- a/layout/base/nsCSSRenderingBorders.cpp +++ b/layout/base/nsCSSRenderingBorders.cpp @@ -7,7 +7,7 @@ #include "nsStyleConsts.h" #include "nsPoint.h" #include "nsRect.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsFrameManager.h" #include "nsStyleContext.h" #include "nsGkAtoms.h" diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index d17034b2bd08..8111f8c6a57a 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -46,7 +46,7 @@ #include "sampler.h" #include "nsAnimationManager.h" #include "nsTransitionManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "ImageLayers.h" #include "ImageContainer.h" #include "nsCanvasFrame.h" diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 870cfc3fd1ee..8d434d5bfc74 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -42,7 +42,7 @@ #include "nsViewsCID.h" #include "nsIDeviceContextSpec.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsIPageSequenceFrame.h" @@ -379,7 +379,7 @@ protected: // These return the current shell/prescontext etc. nsIPresShell* GetPresShell(); nsPresContext* GetPresContext(); - nsIViewManager* GetViewManager(); + nsViewManager* GetViewManager(); void DetachFromTopLevelWidget(); @@ -397,7 +397,7 @@ protected: // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsCOMPtr mViewManager; + nsCOMPtr mViewManager; nsRefPtr mPresContext; nsCOMPtr mPresShell; @@ -1399,7 +1399,7 @@ nsDocumentViewer::Open(nsISupports *aState, nsISHEntry *aSHEntry) // If the old view is already attached to our parent, detach DetachFromTopLevelWidget(); - nsIViewManager *vm = GetViewManager(); + nsViewManager *vm = GetViewManager(); NS_ABORT_IF_FALSE(vm, "no view manager"); nsView* v = vm->GetRootView(); NS_ABORT_IF_FALSE(v, "no root view"); @@ -1546,7 +1546,7 @@ nsDocumentViewer::Destroy() // Remove our root view from the view hierarchy. if (mPresShell) { - nsIViewManager *vm = mPresShell->GetViewManager(); + nsViewManager *vm = mPresShell->GetViewManager(); if (vm) { nsView *rootView = vm->GetRootView(); @@ -1559,7 +1559,7 @@ nsDocumentViewer::Destroy() nsView *rootViewParent = rootView->GetParent(); if (rootViewParent) { - nsIViewManager *parentVM = rootViewParent->GetViewManager(); + nsViewManager *parentVM = rootViewParent->GetViewManager(); if (parentVM) { parentVM->RemoveChild(rootView); } @@ -1806,7 +1806,7 @@ nsDocumentViewer::GetPresContext() return mPresContext; } -nsIViewManager* +nsViewManager* nsDocumentViewer::GetViewManager() { return mViewManager; @@ -4388,7 +4388,7 @@ nsDocumentViewer::InitializeForPrintPreview() } void -nsDocumentViewer::SetPrintPreviewPresentation(nsIViewManager* aViewManager, +nsDocumentViewer::SetPrintPreviewPresentation(nsViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) { diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index 083afc1219a1..e99d39198339 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -12,7 +12,7 @@ class nsStyleSet; class nsIPresShell; class nsPresContext; class nsIWidget; -class nsIViewManager; +class nsViewManager; // {c6f255cf-cadd-4382-b57f-cd2a9874169b} #define NS_IDOCUMENT_VIEWER_PRINT_IID \ @@ -58,7 +58,7 @@ public: /** * Replaces the current presentation with print preview presentation. */ - virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, + virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, nsPresContext* aPresContext, nsIPresShell* aPresShell) = 0; }; @@ -78,7 +78,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, virtual void OnDonePrinting(); \ virtual bool IsInitializedForPrintPreview(); \ virtual void InitializeForPrintPreview(); \ - virtual void SetPrintPreviewPresentation(nsIViewManager* aViewManager, \ + virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, \ nsPresContext* aPresContext, \ nsIPresShell* aPresShell); diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 39aa465b9b91..afc91f51df71 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -44,7 +44,7 @@ class nsIDocument; class nsIFrame; class nsPresContext; class nsStyleSet; -class nsIViewManager; +class nsViewManager; class nsView; class nsRenderingContext; class nsIPageSequenceFrame; @@ -176,7 +176,7 @@ protected: public: virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) = 0; @@ -272,7 +272,7 @@ public: nsPresContext* GetPresContext() const { return mPresContext; } - nsIViewManager* GetViewManager() const { return mViewManager; } + nsViewManager* GetViewManager() const { return mViewManager; } #ifdef ACCESSIBILITY /** @@ -1381,7 +1381,7 @@ protected: nsPresContext* mPresContext; // [STRONG] nsStyleSet* mStyleSet; // [OWNS] nsCSSFrameConstructor* mFrameConstructor; // [OWNS] - nsIViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to + nsViewManager* mViewManager; // [WEAK] docViewer owns it so I don't have to nsPresArena mFrameArena; nsFrameSelection* mSelection; // Pointer into mFrameConstructor - this is purely so that FrameManager() and diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 00c6e59fa601..10350a5bf5f2 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -43,7 +43,7 @@ #include "nsThreadUtils.h" #include "nsFrameManager.h" #include "nsLayoutUtils.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsCSSFrameConstructor.h" #include "nsCSSRuleProcessor.h" #include "nsStyleChangeList.h" @@ -826,7 +826,7 @@ nsPresContext::PreferenceChanged(const char* aPrefName) // Re-fetch the view manager's window dimensions in case there's a deferred // resize which hasn't affected our mVisibleArea yet nscoord oldWidthAppUnits, oldHeightAppUnits; - nsIViewManager* vm = mShell->GetViewManager(); + nsViewManager* vm = mShell->GetViewManager(); vm->GetWindowDimensions(&oldWidthAppUnits, &oldHeightAppUnits); float oldWidthDevPixels = oldWidthAppUnits/oldAppUnitsPerDevPixel; float oldHeightDevPixels = oldHeightAppUnits/oldAppUnitsPerDevPixel; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 0e19a038b38e..fd3ab466f9f4 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -788,7 +788,7 @@ PresShell::~PresShell() nsresult PresShell::Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode) { @@ -1857,7 +1857,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_ERROR_NOT_AVAILABLE; } - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first nsCOMPtr kungFuDeathGrip(this); @@ -1897,7 +1897,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) // Kick off a top-down reflow AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager); + nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); mDirtyRoots.RemoveElement(rootFrame); DoReflow(rootFrame, true); @@ -3735,7 +3735,7 @@ PresShell::IsSafeToFlush() const if (isSafeToFlush) { // Not safe if we are painting - nsIViewManager* viewManager = GetViewManager(); + nsViewManager* viewManager = GetViewManager(); if (viewManager) { bool isPainting = false; viewManager->IsPainting(isPainting); @@ -3808,7 +3808,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsCOMPtr viewManagerDeathGrip = mViewManager; if (isSafeToFlush && mViewManager) { // Processing pending notifications can kill us, and some callers only // hold weak refs when calling FlushPendingNotifications(). :( @@ -5186,7 +5186,7 @@ PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) // We always dispatch the event to the pres shell that contains the view that // the mouse is over. pointVM is the VM of that pres shell. - nsIViewManager *pointVM = nullptr; + nsViewManager *pointVM = nullptr; // This could be a bit slow (traverses entire view hierarchy) // but it's OK to do it once per synthetic mouse event @@ -7652,7 +7652,7 @@ PresShell::ProcessReflowCommands(bool aInterruptible) nsAutoScriptBlocker scriptBlocker; WillDoReflow(); AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsIViewManager::AutoDisableRefresh refreshBlocker(mViewManager); + nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); do { // Send an incremental reflow notification to the target frame. @@ -8270,7 +8270,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsCOMPtr vm = do_CreateInstance(kViewManagerCID); + nsCOMPtr vm = do_CreateInstance(kViewManagerCID); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index 89ae708e5a2f..bde4b2f3e9a8 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -70,7 +70,7 @@ public: // nsIPresShell virtual NS_HIDDEN_(nsresult) Init(nsIDocument* aDocument, nsPresContext* aPresContext, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsStyleSet* aStyleSet, nsCompatibility aCompatMode); virtual NS_HIDDEN_(void) Destroy(); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 2b3993a3a752..00af04528c54 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -39,7 +39,7 @@ #include "jsapi.h" #include "nsContentUtils.h" #include "mozilla/Preferences.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "sampler.h" #include "nsNPAPIPluginInstance.h" @@ -951,7 +951,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); + nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef DEBUG_INVALIDATIONS printf("Ending ProcessPendingUpdates\n"); diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 7231f4d72633..bae444b06e8c 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -24,7 +24,7 @@ #include "nsIPresShell.h" #include "nsContentList.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsEventDispatcher.h" #include "nsEventListenerManager.h" #include "nsIDOMNode.h" @@ -356,7 +356,7 @@ void nsComboboxControlFrame::ShowPopup(bool aShowPopup) { nsView* view = mDropdownFrame->GetView(); - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); if (aShowPopup) { nsRect rect = mDropdownFrame->GetRect(); @@ -510,7 +510,7 @@ nsComboboxControlFrame::ReflowDropdown(nsPresContext* aPresContext, // ensure we start off hidden if (GetStateBits() & NS_FRAME_FIRST_REFLOW) { nsView* view = mDropdownFrame->GetView(); - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); viewManager->SetViewVisibility(view, nsViewVisibility_kHide); nsRect emptyRect(0, 0, 0, 0); viewManager->ResizeView(view, emptyRect); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 7574138c8c1b..120ac259c914 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -17,7 +17,7 @@ #include "nsIDOMHTMLSelectElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsComboboxControlFrame.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsWidgetsCID.h" #include "nsIPresShell.h" diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 8a9497a06f8f..94ccfc181392 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -39,7 +39,7 @@ #include "nsLayoutUtils.h" #include "nsIComponentManager.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMElement.h" #include "nsIDOMHTMLElement.h" diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index b6e27140d8ef..623de06d899e 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -22,7 +22,7 @@ #include "nsCOMPtr.h" #include "nsGkAtoms.h" #include "nsCSSAnonBoxes.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIWidget.h" #include "nsGfxCIID.h" #include "nsIServiceManager.h" @@ -373,7 +373,7 @@ nsContainerFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset, static nsresult ReparentFrameViewTo(nsIFrame* aFrame, - nsIViewManager* aViewManager, + nsViewManager* aViewManager, nsView* aNewParentView, nsView* aOldParentView) { @@ -432,7 +432,7 @@ nsContainerFrame::CreateViewForFrame(nsIFrame* aFrame, nsView* parentView = aFrame->GetParent()->GetClosestView(); NS_ASSERTION(parentView, "no parent with view"); - nsIViewManager* viewManager = parentView->GetViewManager(); + nsViewManager* viewManager = parentView->GetViewManager(); NS_ASSERTION(viewManager, "null view manager"); // Create a view @@ -480,7 +480,7 @@ nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame) return; nsView* view = aKidFrame->GetView(); - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); nsPoint pt; nsView* ancestorView = parentFrame->GetClosestView(&pt); @@ -607,7 +607,7 @@ nsContainerFrame::ReparentFrameViewList(nsPresContext* aPresContext, // same view sub-hierarchy. If they are then we don't have to do // anything if (oldParentView != newParentView) { - nsIViewManager* viewManager = oldParentView->GetViewManager(); + nsViewManager* viewManager = oldParentView->GetViewManager(); // They're not so we need to reparent any child views for (nsFrameList::Enumerator e(aChildFrameList); !e.AtEnd(); e.Next()) { @@ -656,7 +656,7 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext, if (!windowWidget || !IsTopLevelWidget(windowWidget)) return; - nsIViewManager* vm = aView->GetViewManager(); + nsViewManager* vm = aView->GetViewManager(); nsView* rootView = vm->GetRootView(); if (aView != rootView) @@ -748,7 +748,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext, } if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) { - nsIViewManager* vm = aView->GetViewManager(); + nsViewManager* vm = aView->GetViewManager(); vm->ResizeView(aView, aVisualOverflowArea, true); } @@ -768,7 +768,7 @@ nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext, return; } - nsIViewManager* vm = aView->GetViewManager(); + nsViewManager* vm = aView->GetViewManager(); if (nullptr == aStyleContext) { aStyleContext = aFrame->GetStyleContext(); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index fbd308f54891..be9082de186b 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -22,7 +22,7 @@ #include "nsStyleContext.h" #include "nsTableOuterFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIScrollableFrame.h" #include "nsPresContext.h" #include "nsCRT.h" @@ -5289,7 +5289,7 @@ nsFrame::UpdateOverflow() if ((flags & NS_FRAME_NO_SIZE_VIEW) == 0) { // Make sure the frame's view is properly sized. - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); vm->ResizeView(view, overflowAreas.VisualOverflow(), true); } } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 843ef0ca5b55..7ea3d8e737ba 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -22,7 +22,7 @@ #include "nsIDocument.h" #include "nsINodeInfo.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsWidgetsCID.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 541abd69edc9..e0510aa491b9 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -11,7 +11,7 @@ #include "nsIServiceManager.h" #include "nsView.h" #include "nsIScrollable.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsContainerFrame.h" #include "nsGfxScrollFrame.h" #include "nsGkAtoms.h" diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index c7b9fed522e9..7f1b46428bc8 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -14,7 +14,7 @@ #include "nsIPresShell.h" #include "nsWidgetsCID.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMEventListener.h" #include "nsIDOMDragEvent.h" #include "nsPluginHost.h" @@ -329,7 +329,7 @@ nsObjectFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) { if (HasView()) { nsView* view = GetView(); - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); if (vm) { nsViewVisibility visibility = IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow; @@ -365,7 +365,7 @@ nsObjectFrame::PrepForDrawing(nsIWidget *aWidget) return NS_ERROR_FAILURE; } - nsIViewManager* viewMan = view->GetViewManager(); + nsViewManager* viewMan = view->GetViewManager(); // mark the view as hidden since we don't know the (x,y) until Paint // XXX is the above comment correct? viewMan->SetViewVisibility(view, nsViewVisibility_kHide); @@ -593,7 +593,7 @@ nsObjectFrame::Reflow(nsPresContext* aPresContext, r.Deflate(aReflowState.mComputedBorderPadding); if (mInnerView) { - nsIViewManager* vm = mInnerView->GetViewManager(); + nsViewManager* vm = mInnerView->GetViewManager(); vm->MoveViewTo(mInnerView, r.x, r.y); vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), r.Size()), true); } @@ -884,7 +884,7 @@ nsObjectFrame::DidReflow(nsPresContext* aPresContext, if (HasView()) { nsView* view = GetView(); - nsIViewManager* vm = view->GetViewManager(); + nsViewManager* vm = view->GetViewManager(); if (vm) vm->SetViewVisibility(view, IsHidden() ? nsViewVisibility_kHide : nsViewVisibility_kShow); } diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 4a5bf79aa73e..9ead05a2f475 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -30,7 +30,7 @@ #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsGkAtoms.h" #include "nsStyleCoord.h" #include "nsStyleContext.h" @@ -674,7 +674,7 @@ nsSubDocumentFrame::Reflow(nsPresContext* aPresContext, } if (mInnerView) { - nsIViewManager* vm = mInnerView->GetViewManager(); + nsViewManager* vm = mInnerView->GetViewManager(); vm->MoveViewTo(mInnerView, offset.x, offset.y); vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), innerSize), true); } @@ -958,7 +958,7 @@ InsertViewsInReverseOrder(nsView* aSibling, nsView* aParent) NS_PRECONDITION(aParent, ""); NS_PRECONDITION(!aParent->GetFirstChild(), "inserting into non-empty list"); - nsIViewManager* vm = aParent->GetViewManager(); + nsViewManager* vm = aParent->GetViewManager(); while (aSibling) { nsView* next = aSibling->GetNextSibling(); aSibling->SetNextSibling(nullptr); @@ -1092,7 +1092,7 @@ nsSubDocumentFrame::EnsureInnerView() NS_ASSERTION(outerView, "Must have an outer view already"); nsRect viewBounds(0, 0, 0, 0); // size will be fixed during reflow - nsIViewManager* viewMan = outerView->GetViewManager(); + nsViewManager* viewMan = outerView->GetViewManager(); nsView* innerView = viewMan->CreateView(viewBounds, outerView); if (!innerView) { NS_ERROR("Could not create inner view"); diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 41042894f8e6..225ed61290b5 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -90,7 +90,7 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsViewsCID.h" #include "nsWidgetsCID.h" #include "nsIDeviceContextSpec.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsRenderingContext.h" @@ -3793,7 +3793,7 @@ DumpViews(nsIDocShell* aDocShell, FILE* out) fprintf(out, "docshell=%p \n", aDocShell); nsIPresShell* shell = nsPrintEngine::GetPresShellFor(aDocShell); if (shell) { - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (vm) { nsView* root = vm->GetRootView(); if (root) { diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 672d05d56c90..5f3e4cdfeafc 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -12,7 +12,7 @@ #include "nsIContent.h" #include "nsIPresShell.h" #include "nsStyleSet.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDocShell.h" #include "nsIDocument.h" #include "nsIDocShellTreeOwner.h" @@ -46,7 +46,7 @@ public: nsRefPtr mPresContext; nsCOMPtr mPresShell; - nsCOMPtr mViewManager; + nsCOMPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index 2e86a23f7c77..dc94218e3810 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -21,7 +21,7 @@ #include "nsIDOMDocument.h" #include "nsIPresShell.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIFrame.h" #include "nsILayoutDebugger.h" @@ -55,7 +55,7 @@ pres_shell(nsIDocShell *aDocShell) return result.forget(); } -static nsIViewManager* +static nsViewManager* view_manager(nsIDocShell *aDocShell) { nsCOMPtr shell(pres_shell(aDocShell)); @@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsCOMPtr vm(view_manager(aDocShell)); + nsCOMPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsCOMPtr vm(view_manager(mDocShell)); + nsCOMPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/tools/layout-debug/src/nsRegressionTester.cpp b/layout/tools/layout-debug/src/nsRegressionTester.cpp index a23195f613db..af942203e6da 100644 --- a/layout/tools/layout-debug/src/nsRegressionTester.cpp +++ b/layout/tools/layout-debug/src/nsRegressionTester.cpp @@ -25,7 +25,7 @@ #include "nsLayoutCID.h" #include "nsNetUtil.h" #include "nsIFile.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index e7c44eb816ed..011b9ea9d354 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -41,7 +41,7 @@ #include "nsGkAtoms.h" #include "nsIContent.h" #include "nsHTMLParts.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsView.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" diff --git a/layout/xul/base/src/nsDeckFrame.cpp b/layout/xul/base/src/nsDeckFrame.cpp index 50f4611bf7f6..34932e816285 100644 --- a/layout/xul/base/src/nsDeckFrame.cpp +++ b/layout/xul/base/src/nsDeckFrame.cpp @@ -20,7 +20,7 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsBoxLayoutState.h" #include "nsStackLayout.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsLeafBoxFrame.cpp b/layout/xul/base/src/nsLeafBoxFrame.cpp index 163ed3ce0a30..1ce3541532b1 100644 --- a/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -20,7 +20,7 @@ #include "nsINameSpaceManager.h" #include "nsBoxLayoutState.h" #include "nsWidgetsCID.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsContainerFrame.h" #include "nsDisplayList.h" diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index b5496a07cc1b..72eaf2c9f3ad 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -22,7 +22,7 @@ #include "nsIScrollableFrame.h" #include "nsScrollbarFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsStyleContext.h" #include "nsFontMetrics.h" #include "nsITimer.h" diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index eb20199c67c8..c463591f28d0 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -12,7 +12,7 @@ #include "nsStyleContext.h" #include "nsCSSRendering.h" #include "nsINameSpaceManager.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsWidgetsCID.h" #include "nsMenuFrame.h" #include "nsMenuBarFrame.h" @@ -125,7 +125,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent, // so we use the nsView::SetFloating() to tell the view manager // about that constraint. nsView* ourView = GetView(); - nsIViewManager* viewManager = ourView->GetViewManager(); + nsViewManager* viewManager = ourView->GetViewManager(); viewManager->SetViewFloating(ourView, true); mPopupType = ePopupTypePanel; @@ -459,7 +459,7 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, b } if (isOpen) { - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); nsRect rect = GetRect(); rect.x = rect.y = 0; viewManager->ResizeView(view, rect); @@ -794,7 +794,7 @@ nsMenuPopupFrame::HidePopup(bool aDeselectMenu, nsPopupState aNewState) mHFlip = mVFlip = false; nsView* view = GetView(); - nsIViewManager* viewManager = view->GetViewManager(); + nsViewManager* viewManager = view->GetViewManager(); viewManager->SetViewVisibility(view, nsViewVisibility_kHide); FireDOMEvent(NS_LITERAL_STRING("DOMMenuInactive"), mContent); @@ -1919,7 +1919,7 @@ nsMenuPopupFrame::CreatePopupView() return NS_OK; } - nsIViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); + nsViewManager* viewManager = PresContext()->GetPresShell()->GetViewManager(); NS_ASSERTION(nullptr != viewManager, "null view manager"); // Create a view diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index bcf09d20e979..10b977609aa9 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -90,7 +90,7 @@ enum FlipStyle { nsIFrame* NS_NewMenuPopupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); -class nsIViewManager; +class nsViewManager; class nsView; class nsMenuPopupFrame; diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index cf6befa60196..32b2b0e50e0c 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -20,7 +20,7 @@ #include "nsEventStateManager.h" #include "nsCSSFrameConstructor.h" #include "nsLayoutUtils.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIComponentManager.h" #include "nsITimer.h" #include "nsFocusManager.h" @@ -2262,7 +2262,7 @@ nsXULMenuCommandEvent::Run() if (!pm) return NS_OK; - // The order of the nsIViewManager and nsIPresShell COM pointers is + // The order of the nsViewManager and nsIPresShell COM pointers is // important below. We want the pres shell to get released before the // associated view manager on exit from this function. // See bug 54233. @@ -2295,7 +2295,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); + nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index f889eba2383d..e0f6f69aa3f8 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -39,7 +39,7 @@ #include "nsXPIDLString.h" #include "nsContainerFrame.h" #include "nsView.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsWidgetsCID.h" #include "nsBoxFrame.h" #include "nsBoxObject.h" diff --git a/view/public/Makefile.in b/view/public/Makefile.in index f4c2731040a9..15a90772c1f2 100644 --- a/view/public/Makefile.in +++ b/view/public/Makefile.in @@ -14,7 +14,7 @@ MODULE = view EXPORTS = \ nsView.h \ - nsIViewManager.h \ + nsViewManager.h \ nsViewsCID.h \ nsIScrollPositionListener.h \ $(NULL) diff --git a/view/public/nsView.h b/view/public/nsView.h index a9bade64954b..686a97abc3d6 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -20,7 +20,6 @@ #include "nsIWidgetListener.h" #include -class nsIViewManager; class nsViewManager; class nsIWidget; class nsIFrame; @@ -59,7 +58,7 @@ enum nsViewVisibility { * view manager that owns the views. * * Most of the methods here are read-only. To set the corresponding properties - * of a view, go through nsIViewManager. + * of a view, go through nsViewManager. */ class nsView MOZ_FINAL : public nsIWidgetListener @@ -75,8 +74,8 @@ public: * view manager from somewhere else, do that instead. * @result the view manager */ - nsIViewManager* GetViewManager() const - { return reinterpret_cast(mViewManager); } + nsViewManager* GetViewManager() const + { return reinterpret_cast(mViewManager); } nsViewManager* GetViewManagerInternal() const { return mViewManager; } /** @@ -460,13 +459,13 @@ private: // released if it points to any view in this view hierarchy. void InvalidateHierarchy(nsViewManager *aViewManagerParent); - nsViewManager *mViewManager; + nsViewManager *mViewManager; nsView *mParent; - nsIWidget *mWindow; + nsIWidget *mWindow; nsView *mNextSibling; nsView *mFirstChild; - nsIFrame *mFrame; - nsRegion *mDirtyRegion; + nsIFrame *mFrame; + nsRegion *mDirtyRegion; int32_t mZIndex; nsViewVisibility mVis; // position relative our parent view origin but in our appunits diff --git a/view/public/nsIViewManager.h b/view/public/nsViewManager.h similarity index 60% rename from view/public/nsIViewManager.h rename to view/public/nsViewManager.h index b8ca74541cbd..685e59c4bda2 100644 --- a/view/public/nsIViewManager.h +++ b/view/public/nsViewManager.h @@ -3,35 +3,54 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef nsIViewManager_h___ -#define nsIViewManager_h___ +#ifndef nsViewManager_h___ +#define nsViewManager_h___ #include "nscore.h" #include "nsView.h" #include "nsEvent.h" +#include "nsCOMPtr.h" +#include "nsCRT.h" +#include "nsITimer.h" +#include "prtime.h" +#include "prinrval.h" +#include "nsVoidArray.h" +#include "nsThreadUtils.h" +#include "nsIPresShell.h" +#include "nsDeviceContext.h" class nsIWidget; struct nsRect; class nsRegion; class nsDeviceContext; class nsIPresShell; +class nsView; #define NS_IVIEWMANAGER_IID \ { 0x540610a6, 0x4fdd, 0x4ae3, \ { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } } -class nsIViewManager : public nsISupports +class nsViewManager : public nsISupports { public: + friend class nsView; NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID) + + NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW + + NS_DECL_ISUPPORTS + + nsViewManager(); + virtual ~nsViewManager(); + /** * Initialize the ViewManager * Note: this instance does not hold a reference to the presshell * because it holds a reference to this instance. * @result The result of the initialization, NS_OK if no errors */ - NS_IMETHOD Init(nsDeviceContext* aContext) = 0; + NS_IMETHOD Init(nsDeviceContext* aContext); /** * Create an ordinary view @@ -47,13 +66,13 @@ public: */ NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0; + nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); /** * Get the root of the view tree. * @result the root view */ - NS_IMETHOD_(nsView*) GetRootView() = 0; + NS_IMETHOD_(nsView*) GetRootView() { return mRootView; } /** * Set the root of the view tree. Does not destroy the current root view. @@ -61,7 +80,7 @@ public: * aView may have a widget (anything but printing) or may not (printing). * @param aView view to set as root */ - NS_IMETHOD SetRootView(nsView *aView) = 0; + NS_IMETHOD SetRootView(nsView *aView); /** * Get the dimensions of the root window. The dimensions are in @@ -69,7 +88,7 @@ public: * @param aWidth out parameter for width of window in twips * @param aHeight out parameter for height of window in twips */ - NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0; + NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); /** * Set the dimensions of the root window. @@ -78,19 +97,19 @@ public: * @param aWidth of window in twips * @param aHeight of window in twips */ - NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0; + NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight); /** * Do any resizes that are pending. */ - NS_IMETHOD FlushDelayedResize(bool aDoReflow) = 0; + NS_IMETHOD FlushDelayedResize(bool aDoReflow); /** * Called to inform the view manager that the entire area of a view * is dirty and needs to be redrawn. * @param aView view to paint. should be root view */ - NS_IMETHOD InvalidateView(nsView *aView) = 0; + NS_IMETHOD InvalidateView(nsView *aView); /** * Called to inform the view manager that some portion of a view is dirty and @@ -99,12 +118,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect) = 0; + NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); /** * Called to inform the view manager that it should invalidate all views. */ - NS_IMETHOD InvalidateAllViews() = 0; + NS_IMETHOD InvalidateAllViews(); /** * Called to dispatch an event to the appropriate view. Often called @@ -115,7 +134,7 @@ public: * @param aStatus event handling status */ NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, - nsView* aViewTarget, nsEventStatus* aStatus) = 0; + nsView* aViewTarget, nsEventStatus* aStatus); /** * Given a parent view, insert another view as its child. @@ -133,7 +152,9 @@ public: * @param aAfter after or before in the document order */ NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter) = 0; + bool aAfter); + + NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); /** * Remove a specific child view from its parent. This will NOT remove its placeholder @@ -142,7 +163,7 @@ public: * @param aParent parent view * @param aChild child view */ - NS_IMETHOD RemoveChild(nsView *aChild) = 0; + NS_IMETHOD RemoveChild(nsView *aChild); /** * Move a view to the specified position, provided in parent coordinates. @@ -153,7 +174,7 @@ public: * @param aX x value for new view position * @param aY y value for new view position */ - NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY) = 0; + NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); /** * Resize a view. In addition to setting the width and height, you can @@ -168,7 +189,7 @@ public: * if false Repaint the union of the old and new rectangles. */ NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, - bool aRepaintExposedAreaOnly = false) = 0; + bool aRepaintExposedAreaOnly = false); /** * Set the visibility of a view. Hidden views have the effect of hiding @@ -181,7 +202,7 @@ public: * @param aView view to change visibility state of * @param visible new visibility state */ - NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible) = 0; + NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); /** * Set the z-index of a view. Positive z-indices mean that a view @@ -199,7 +220,7 @@ public: * true if the view should be topmost when compared with * other z-index:auto views. */ - NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false) = 0; + NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); /** * Set whether the view "floats" above all other views, @@ -208,24 +229,24 @@ public: * this view. This is a hack, but it fixes some problems with * views that need to be drawn in front of all other views. */ - NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView) = 0; + NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView); /** * Set the presshell associated with this manager * @param aPresShell - new presshell */ - virtual void SetPresShell(nsIPresShell *aPresShell) = 0; + virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } /** * Get the pres shell associated with this manager */ - virtual nsIPresShell* GetPresShell() = 0; + virtual nsIPresShell* GetPresShell() { return mPresShell; } /** * Get the device context associated with this manager * @result device context */ - NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext) = 0; + NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); /** * A stack class for disallowing changes that would enter painting. For @@ -241,7 +262,7 @@ public: */ class NS_STACK_CLASS AutoDisableRefresh { public: - AutoDisableRefresh(nsIViewManager* aVM) { + AutoDisableRefresh(nsViewManager* aVM) { if (aVM) { mRootVM = aVM->IncrementDisableRefreshCount(); } @@ -255,21 +276,21 @@ public: AutoDisableRefresh(const AutoDisableRefresh& aOther); const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - nsCOMPtr mRootVM; + nsCOMPtr mRootVM; }; private: friend class AutoDisableRefresh; - virtual nsIViewManager* IncrementDisableRefreshCount() = 0; - virtual void DecrementDisableRefreshCount() = 0; + virtual nsViewManager* IncrementDisableRefreshCount(); + virtual void DecrementDisableRefreshCount(); public: /** * Retrieve the widget at the root of the nearest enclosing * view manager whose root view has a widget. */ - NS_IMETHOD GetRootWidget(nsIWidget **aWidget) = 0; + NS_IMETHOD GetRootWidget(nsIWidget **aWidget); /** * Indicate whether the viewmanager is currently painting @@ -277,7 +298,7 @@ public: * @param aPainting true if the viewmanager is painting * false otherwise */ - NS_IMETHOD IsPainting(bool& aIsPainting)=0; + NS_IMETHOD IsPainting(bool& aIsPainting); /** * Retrieve the time of the last user event. User events @@ -286,7 +307,7 @@ public: * * @param aTime Last user event time in microseconds */ - NS_IMETHOD GetLastUserEventTime(uint32_t& aTime)=0; + NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); /** * Find the nearest display root view for the view aView. This is the view for @@ -298,14 +319,141 @@ public: * Flush the accumulated dirty region to the widget and update widget * geometry. */ - virtual void ProcessPendingUpdates()=0; + virtual void ProcessPendingUpdates(); /** * Just update widget geometry without flushing the dirty region */ - virtual void UpdateWidgetGeometry() = 0; + virtual void UpdateWidgetGeometry(); + + uint32_t AppUnitsPerDevPixel() const + { + return mContext->AppUnitsPerDevPixel(); + } + nsView* GetRootViewImpl() const { return mRootView; } + +private: + static uint32_t gLastUserEventTime; + + /* Update the cached RootViewManager pointer on this view manager. */ + void InvalidateHierarchy(); + void FlushPendingInvalidates(); + + void ProcessPendingUpdatesForView(nsView *aView, + bool aFlushDirtyRegion = true); + void FlushDirtyRegionToWidget(nsView* aView); + /** + * Call WillPaint() on all view observers under this vm root. + */ + void CallWillPaintOnObservers(bool aWillSendDidPaint); + void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget); + void ReparentWidgets(nsView* aView, nsView *aParent); + void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); + + void InvalidateViews(nsView *aView); + + // aView is the view for aWidget and aRegion is relative to aWidget. + void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint); + + void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); + void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, + nscoord aY1, nscoord aY2, bool aInCutOut); + + // Utilities + + bool IsViewInserted(nsView *aView); + + /** + * Intersects aRect with aView's bounds and then transforms it from aView's + * coordinate system to the coordinate system of the widget attached to + * aView. + */ + nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const; + + void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight); + + bool IsPainting() const { + return RootViewManager()->mPainting; + } + + void SetPainting(bool aPainting) { + RootViewManager()->mPainting = aPainting; + } + + nsresult InvalidateView(nsView *aView, const nsRect &aRect); + + nsViewManager* RootViewManager() const { return mRootViewManager; } + bool IsRootVM() const { return this == RootViewManager(); } + + // Whether synchronous painting is allowed at the moment. For example, + // widget geometry changes can cause synchronous painting, so they need to + // be deferred while refresh is disabled. + bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; } + + void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint); + bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, + uint32_t aFlags); + void DidPaintWindow(); + + // Call this when you need to let the viewmanager know that it now has + // pending updates. + void PostPendingUpdate(); + + nsRefPtr mContext; + nsIPresShell *mPresShell; + + // The size for a resize that we delayed until the root view becomes + // visible again. + nsSize mDelayedResize; + + nsView *mRootView; + // mRootViewManager is a strong ref unless it equals |this|. It's + // never null (if we have no ancestors, it will be |this|). + nsViewManager *mRootViewManager; + + // The following members should not be accessed directly except by + // the root view manager. Some have accessor functions to enforce + // this, as noted. + + int32_t mRefreshDisableCount; + // Use IsPainting() and SetPainting() to access mPainting. + bool mPainting; + bool mRecursiveRefreshPending; + bool mHasPendingWidgetGeometryChanges; + bool mInScroll; + + //from here to public should be static and locked... MMP + static int32_t mVMCount; //number of viewmanagers + + //list of view managers + static nsVoidArray *gViewManagers; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIViewManager, NS_IVIEWMANAGER_IID) +NS_DEFINE_STATIC_IID_ACCESSOR(nsViewManager, NS_IVIEWMANAGER_IID) -#endif // nsIViewManager_h___ + +/** + Invalidation model: + + 1) Callers call into the view manager and ask it to invalidate a view. + + 2) The view manager finds the "right" widget for the view, henceforth called + the root widget. + + 3) The view manager traverses descendants of the root widget and for each + one that needs invalidation stores the rect to invalidate on the widget's + view (batching). + + 4) The dirty region is flushed to the right widget when + ProcessPendingUpdates is called from the RefreshDriver. + + It's important to note that widgets associated to views outside this view + manager can end up being invalidated during step 3. Therefore, the end of a + view update batch really needs to traverse the entire view tree, to ensure + that those invalidates happen. + + To cope with this, invalidation processing and should only happen on the + root viewmanager. +*/ + +#endif // nsViewManager_h___ diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 31deaad1aecf..64949a9cce17 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) } if (view) { - nsCOMPtr vm = view->GetViewManager(); + nsCOMPtr vm = view->GetViewManager(); vm->DispatchEvent(aEvent, view, &result); } diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 442b7056e849..414fc77dedee 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -122,7 +122,7 @@ nsViewManager::~nsViewManager() mPresShell = nullptr; } -NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager) +NS_IMPL_ISUPPORTS1(nsViewManager, nsViewManager) // We don't hold a reference to the presentation context because it // holds a reference to us. @@ -156,12 +156,6 @@ nsViewManager::CreateView(const nsRect& aBounds, return v; } -NS_IMETHODIMP_(nsView*) -nsViewManager::GetRootView() -{ - return mRootView; -} - NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) { NS_PRECONDITION(!aView || aView->GetViewManager() == this, @@ -278,7 +272,7 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn, return out; } -nsView* nsIViewManager::GetDisplayRootFor(nsView* aView) +nsView* nsViewManager::GetDisplayRootFor(nsView* aView) { nsView *displayRoot = aView; for (;;) { @@ -571,7 +565,7 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) if (!shell || shell->ShouldIgnoreInvalidation()) { return true; } - nsView* view = aVM->GetRootViewImpl()->GetParent(); + nsView* view = aVM->GetRootView()->GetParent(); aVM = view ? view->GetViewManagerInternal() : nullptr; } return false; @@ -1107,7 +1101,7 @@ NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) return NS_OK; } -nsIViewManager* +nsViewManager* nsViewManager::IncrementDisableRefreshCount() { if (!IsRootVM()) { diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h deleted file mode 100644 index 7315a3bd6683..000000000000 --- a/view/src/nsViewManager.h +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsViewManager_h___ -#define nsViewManager_h___ -#include "nsCOMPtr.h" -#include "nsIViewManager.h" -#include "nsCRT.h" -#include "nsITimer.h" -#include "prtime.h" -#include "prinrval.h" -#include "nsVoidArray.h" -#include "nsThreadUtils.h" -#include "nsIPresShell.h" -#include "nsDeviceContext.h" - - -/** - Invalidation model: - - 1) Callers call into the view manager and ask it to invalidate a view. - - 2) The view manager finds the "right" widget for the view, henceforth called - the root widget. - - 3) The view manager traverses descendants of the root widget and for each - one that needs invalidation stores the rect to invalidate on the widget's - view (batching). - - 4) The dirty region is flushed to the right widget when - ProcessPendingUpdates is called from the RefreshDriver. - - It's important to note that widgets associated to views outside this view - manager can end up being invalidated during step 3. Therefore, the end of a - view update batch really needs to traverse the entire view tree, to ensure - that those invalidates happen. - - To cope with this, invalidation processing and should only happen on the - root viewmanager. -*/ - -class nsViewManager : public nsIViewManager { -public: - nsViewManager(); - - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - - NS_DECL_ISUPPORTS - - NS_IMETHOD Init(nsDeviceContext* aContext); - - NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, - const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); - - NS_IMETHOD_(nsView*) GetRootView(); - NS_IMETHOD SetRootView(nsView *aView); - - NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height); - NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height); - NS_IMETHOD FlushDelayedResize(bool aDoReflow); - - NS_IMETHOD InvalidateView(nsView *aView); - NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); - NS_IMETHOD InvalidateAllViews(); - - NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, - nsView* aTargetView, nsEventStatus* aStatus); - - NS_IMETHOD InsertChild(nsView *parent, nsView *child, nsView *sibling, - bool above); - - NS_IMETHOD InsertChild(nsView *parent, nsView *child, - int32_t zindex); - - NS_IMETHOD RemoveChild(nsView *parent); - - NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); - - NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly = false); - - NS_IMETHOD SetViewFloating(nsView *aView, bool aFloating); - - NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); - - NS_IMETHOD SetViewZIndex(nsView *aView, bool aAuto, int32_t aZIndex, bool aTopMost=false); - - virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } - virtual nsIPresShell* GetPresShell() { return mPresShell; } - - NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); - - virtual nsIViewManager* IncrementDisableRefreshCount(); - virtual void DecrementDisableRefreshCount(); - - NS_IMETHOD GetRootWidget(nsIWidget **aWidget); - - NS_IMETHOD IsPainting(bool& aIsPainting); - NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); - static uint32_t gLastUserEventTime; - - /* Update the cached RootViewManager pointer on this view manager. */ - void InvalidateHierarchy(); - - virtual void ProcessPendingUpdates(); - virtual void UpdateWidgetGeometry(); - -protected: - virtual ~nsViewManager(); - -private: - - void FlushPendingInvalidates(); - void ProcessPendingUpdatesForView(nsView *aView, - bool aFlushDirtyRegion = true); - void FlushDirtyRegionToWidget(nsView* aView); - /** - * Call WillPaint() on all view observers under this vm root. - */ - void CallWillPaintOnObservers(bool aWillSendDidPaint); - void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget); - void ReparentWidgets(nsView* aView, nsView *aParent); - void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); - - void InvalidateViews(nsView *aView); - - // aView is the view for aWidget and aRegion is relative to aWidget. - void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint); - - void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); - void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, - nscoord aY1, nscoord aY2, bool aInCutOut); - - // Utilities - - bool IsViewInserted(nsView *aView); - - /** - * Intersects aRect with aView's bounds and then transforms it from aView's - * coordinate system to the coordinate system of the widget attached to - * aView. - */ - nsIntRect ViewToWidget(nsView *aView, const nsRect &aRect) const; - - void DoSetWindowDimensions(nscoord aWidth, nscoord aHeight); - - bool IsPainting() const { - return RootViewManager()->mPainting; - } - - void SetPainting(bool aPainting) { - RootViewManager()->mPainting = aPainting; - } - - nsresult InvalidateView(nsView *aView, const nsRect &aRect); - -public: // NOT in nsIViewManager, so private to the view module - nsView* GetRootViewImpl() const { return mRootView; } - nsViewManager* RootViewManager() const { return mRootViewManager; } - bool IsRootVM() const { return this == RootViewManager(); } - - // Whether synchronous painting is allowed at the moment. For example, - // widget geometry changes can cause synchronous painting, so they need to - // be deferred while refresh is disabled. - bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; } - - void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint); - bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, - uint32_t aFlags); - void DidPaintWindow(); - - // Call this when you need to let the viewmanager know that it now has - // pending updates. - void PostPendingUpdate(); - - uint32_t AppUnitsPerDevPixel() const - { - return mContext->AppUnitsPerDevPixel(); - } - -private: - nsRefPtr mContext; - nsIPresShell *mPresShell; - - // The size for a resize that we delayed until the root view becomes - // visible again. - nsSize mDelayedResize; - - nsView *mRootView; - // mRootViewManager is a strong ref unless it equals |this|. It's - // never null (if we have no ancestors, it will be |this|). - nsViewManager *mRootViewManager; - - // The following members should not be accessed directly except by - // the root view manager. Some have accessor functions to enforce - // this, as noted. - - int32_t mRefreshDisableCount; - // Use IsPainting() and SetPainting() to access mPainting. - bool mPainting; - bool mRecursiveRefreshPending; - bool mHasPendingWidgetGeometryChanges; - bool mInScroll; - - //from here to public should be static and locked... MMP - static int32_t mVMCount; //number of viewmanagers - - //list of view managers - static nsVoidArray *gViewManagers; -}; - -#endif /* nsViewManager_h___ */ diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 6c86c30ccdab..7d42ad969b03 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -23,7 +23,7 @@ using mozilla::unused; #include "nsIObserverService.h" #include "nsFocusManager.h" #include "nsIWidgetListener.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsRenderingContext.h" #include "nsIDOMSimpleGestureEvent.h" diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 0f84ca234fec..71ea4e226fa8 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -23,7 +23,7 @@ #include "nsFontMetrics.h" #include "nsIRollupListener.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIInterfaceRequestor.h" #include "nsIFile.h" #include "nsILocalFileMac.h" diff --git a/widget/gtk2/nsDragService.cpp b/widget/gtk2/nsDragService.cpp index 2f98d290ca39..82b403b4dc74 100644 --- a/widget/gtk2/nsDragService.cpp +++ b/widget/gtk2/nsDragService.cpp @@ -31,7 +31,7 @@ #include "nsPresContext.h" #include "nsIDocument.h" #include "nsISelection.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIFrame.h" // This sets how opaque the drag image is @@ -269,7 +269,7 @@ GetGtkWindow(nsIDOMDocument *aDocument) if (!presShell) return NULL; - nsCOMPtr vm = presShell->GetViewManager(); + nsCOMPtr vm = presShell->GetViewManager(); if (!vm) return NULL; diff --git a/widget/gtk2/nsNativeThemeGTK.cpp b/widget/gtk2/nsNativeThemeGTK.cpp index 59132735dada..35b786aec4c5 100644 --- a/widget/gtk2/nsNativeThemeGTK.cpp +++ b/widget/gtk2/nsNativeThemeGTK.cpp @@ -12,7 +12,7 @@ #include "nsIFrame.h" #include "nsIPresShell.h" #include "nsIContent.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsINameSpaceManager.h" #include "nsGfxCIID.h" #include "nsTransform2D.h" @@ -75,7 +75,7 @@ nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame) if (!shell) return; - nsIViewManager* vm = shell->GetViewManager(); + nsViewManager* vm = shell->GetViewManager(); if (!vm) return; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index 150c72c075a6..6a1aa6d79660 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -65,7 +65,7 @@ template class nsReadingIterator; #include "nsIDOMHTMLTextAreaElement.h" #include "nsIDOMElement.h" #include "nsISelectionController.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsTArray.h" #include "nsGUIEvent.h" @@ -3144,7 +3144,7 @@ TestApp::GetWidget(nsIWidget** aWidget) return false; } - nsCOMPtr viewManager = presShell->GetViewManager(); + nsCOMPtr viewManager = presShell->GetViewManager(); if (!viewManager) { return false; } diff --git a/widget/xpwidgets/nsBaseDragService.cpp b/widget/xpwidgets/nsBaseDragService.cpp index df2bb433365b..60c677fb00e3 100644 --- a/widget/xpwidgets/nsBaseDragService.cpp +++ b/widget/xpwidgets/nsBaseDragService.cpp @@ -18,7 +18,7 @@ #include "nsIDocument.h" #include "nsIContent.h" #include "nsIPresShell.h" -#include "nsIViewManager.h" +#include "nsViewManager.h" #include "nsIDOMNode.h" #include "nsIDOMDragEvent.h" #include "nsISelection.h" From aba980bcb47ec832d6dc3c36d851a31abcf5eaff Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:42 +1300 Subject: [PATCH 167/180] Bug 826632. Part 2: Use nsRefPtr instead of nsCOMPtr. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : 7245e7c988a208471d8c860449ff7b06c29a4a52 --- extensions/widgetutils/src/nsWidgetUtils.cpp | 2 +- layout/base/nsCSSFrameConstructor.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 2 +- layout/base/nsPresShell.cpp | 6 +++--- layout/base/nsRefreshDriver.cpp | 2 +- layout/printing/nsPrintObject.h | 2 +- layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp | 4 ++-- layout/xul/base/src/nsXULPopupManager.cpp | 2 +- view/public/nsViewManager.h | 2 +- view/src/nsView.cpp | 8 ++++---- widget/gtk2/nsDragService.cpp | 2 +- widget/tests/TestWinTSF.cpp | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/extensions/widgetutils/src/nsWidgetUtils.cpp b/extensions/widgetutils/src/nsWidgetUtils.cpp index 1c17043fa445..ec6ccbf78717 100644 --- a/extensions/widgetutils/src/nsWidgetUtils.cpp +++ b/extensions/widgetutils/src/nsWidgetUtils.cpp @@ -89,7 +89,7 @@ private: static void StopPanningCallback(nsITimer *timer, void *closure); nsCOMPtr mWidget; - nsCOMPtr mViewManager; + nsRefPtr mViewManager; nsCOMPtr mTimer; }; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 21a9a2f24dc2..271102f07fcd 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -12023,7 +12023,7 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) return; // Make sure that the viewmanager will outlive the presshell - nsCOMPtr vm = mPresShell->GetViewManager(); + nsRefPtr vm = mPresShell->GetViewManager(); // Processing the style changes could cause a flush that propagates to // the parent frame and thus destroys the pres shell. diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 8d434d5bfc74..d1a91c4702fa 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -397,7 +397,7 @@ protected: // so they will be destroyed in the reverse order (pinkerton, scc) nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null - nsCOMPtr mViewManager; + nsRefPtr mViewManager; nsRefPtr mPresContext; nsCOMPtr mPresShell; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index fd3ab466f9f4..0d50d8092c05 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1857,7 +1857,7 @@ PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) return NS_ERROR_NOT_AVAILABLE; } - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsRefPtr viewManagerDeathGrip = mViewManager; // Take this ref after viewManager so it'll make sure to go away first nsCOMPtr kungFuDeathGrip(this); @@ -3808,7 +3808,7 @@ PresShell::FlushPendingNotifications(mozilla::ChangesToFlush aFlush) NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager"); // Make sure the view manager stays alive. - nsCOMPtr viewManagerDeathGrip = mViewManager; + nsRefPtr viewManagerDeathGrip = mViewManager; if (isSafeToFlush && mViewManager) { // Processing pending notifications can kill us, and some callers only // hold weak refs when calling FlushPendingNotifications(). :( @@ -8270,7 +8270,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsCOMPtr vm = do_CreateInstance(kViewManagerCID); + nsRefPtr vm = do_CreateInstance(kViewManagerCID); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 00af04528c54..66cd63ae4f33 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -951,7 +951,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime) #endif mViewManagerFlushIsPending = false; - nsCOMPtr vm = mPresContext->GetPresShell()->GetViewManager(); + nsRefPtr vm = mPresContext->GetPresShell()->GetViewManager(); vm->ProcessPendingUpdates(); #ifdef DEBUG_INVALIDATIONS printf("Ending ProcessPendingUpdates\n"); diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index 5f3e4cdfeafc..2ea10001b046 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -46,7 +46,7 @@ public: nsRefPtr mPresContext; nsCOMPtr mPresShell; - nsCOMPtr mViewManager; + nsRefPtr mViewManager; nsCOMPtr mContent; PrintObjectType mFrameType; diff --git a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp index dc94218e3810..072b2f216d7d 100644 --- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -433,7 +433,7 @@ DumpViewsRecur(nsIDocShell* aDocShell, FILE* out) { #ifdef DEBUG fprintf(out, "docshell=%p \n", static_cast(aDocShell)); - nsCOMPtr vm(view_manager(aDocShell)); + nsRefPtr vm(view_manager(aDocShell)); if (vm) { nsView* root = vm->GetRootView(); if (root) { @@ -524,7 +524,7 @@ nsLayoutDebuggingTools::DumpReflowStats() void nsLayoutDebuggingTools::ForceRefresh() { - nsCOMPtr vm(view_manager(mDocShell)); + nsRefPtr vm(view_manager(mDocShell)); if (!vm) return; nsView* root = vm->GetRootView(); diff --git a/layout/xul/base/src/nsXULPopupManager.cpp b/layout/xul/base/src/nsXULPopupManager.cpp index 32b2b0e50e0c..340fe7ec364a 100644 --- a/layout/xul/base/src/nsXULPopupManager.cpp +++ b/layout/xul/base/src/nsXULPopupManager.cpp @@ -2295,7 +2295,7 @@ nsXULMenuCommandEvent::Run() nsPresContext* presContext = menuFrame->PresContext(); nsCOMPtr shell = presContext->PresShell(); - nsCOMPtr kungFuDeathGrip = shell->GetViewManager(); + nsRefPtr kungFuDeathGrip = shell->GetViewManager(); // Deselect ourselves. if (mCloseMenuMode != CloseMenuMode_None) diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index 685e59c4bda2..c959b7d1f56b 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -276,7 +276,7 @@ public: AutoDisableRefresh(const AutoDisableRefresh& aOther); const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - nsCOMPtr mRootVM; + nsRefPtr mRootVM; }; private: diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 64949a9cce17..64b9ff50072c 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -953,7 +953,7 @@ nsView::RequestWindowClose(nsIWidget* aWidget) void nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - nsCOMPtr vm = mViewManager; + nsRefPtr vm = mViewManager; vm->WillPaintWindow(aWidget, aWillSendDidPaint); } @@ -963,7 +963,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?"); mInAlternatePaint = aFlags & PAINT_IS_ALTERNATE; - nsCOMPtr vm = mViewManager; + nsRefPtr vm = mViewManager; bool result = vm->PaintWindow(aWidget, aRegion, aFlags); // PaintWindow can destroy this via WillPaintWindow notification, so we have // to re-get the view from the widget. @@ -977,7 +977,7 @@ nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) void nsView::DidPaintWindow() { - nsCOMPtr vm = mViewManager; + nsRefPtr vm = mViewManager; vm->DidPaintWindow(); } @@ -1006,7 +1006,7 @@ nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) } if (view) { - nsCOMPtr vm = view->GetViewManager(); + nsRefPtr vm = view->GetViewManager(); vm->DispatchEvent(aEvent, view, &result); } diff --git a/widget/gtk2/nsDragService.cpp b/widget/gtk2/nsDragService.cpp index 82b403b4dc74..73900e74ffed 100644 --- a/widget/gtk2/nsDragService.cpp +++ b/widget/gtk2/nsDragService.cpp @@ -269,7 +269,7 @@ GetGtkWindow(nsIDOMDocument *aDocument) if (!presShell) return NULL; - nsCOMPtr vm = presShell->GetViewManager(); + nsRefPtr vm = presShell->GetViewManager(); if (!vm) return NULL; diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index 6a1aa6d79660..e9f4cc049911 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -3144,7 +3144,7 @@ TestApp::GetWidget(nsIWidget** aWidget) return false; } - nsCOMPtr viewManager = presShell->GetViewManager(); + nsRefPtr viewManager = presShell->GetViewManager(); if (!viewManager) { return false; } From 88df3e818e69b82ff5d726816d1be25c8c7a8a44 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:49 +1300 Subject: [PATCH 168/180] Bug 826632. Part 3: Create nsViewManagers directly instead of using XPCOM. r=tnikkel --HG-- extra : rebase_source : f6286a4bcffa2f80bd9d444f7c04005644b8cb2f --- layout/base/nsDocumentViewer.cpp | 10 ++-------- layout/base/nsPresShell.cpp | 5 +---- layout/build/nsLayoutModule.cpp | 7 ------- layout/printing/nsPrintEngine.cpp | 7 +------ view/public/Makefile.in | 1 - view/public/nsViewsCID.h | 17 ----------------- 6 files changed, 4 insertions(+), 43 deletions(-) delete mode 100644 view/public/nsViewsCID.h diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index d1a91c4702fa..a8f3cfc43811 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -40,7 +40,6 @@ #include "nsLayoutStylesheetCache.h" #include "mozilla/Preferences.h" -#include "nsViewsCID.h" #include "nsIDeviceContextSpec.h" #include "nsViewManager.h" #include "nsView.h" @@ -497,8 +496,6 @@ private: //------------------------------------------------------------------ // nsDocumentViewer //------------------------------------------------------------------ -// Class IDs -static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); //------------------------------------------------------------------ nsresult @@ -2272,14 +2269,11 @@ nsDocumentViewer::MakeWindow(const nsSize& aSize, nsView* aContainerView) DetachFromTopLevelWidget(); } - nsresult rv; - mViewManager = do_CreateInstance(kViewManagerCID, &rv); - if (NS_FAILED(rv)) - return rv; + mViewManager = new nsViewManager(); nsDeviceContext *dx = mPresContext->DeviceContext(); - rv = mViewManager->Init(dx); + nsresult rv = mViewManager->Init(dx); if (NS_FAILED(rv)) return rv; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 0d50d8092c05..427aecd9deb3 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -72,7 +72,6 @@ #include "nsCaret.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMXMLDocument.h" -#include "nsViewsCID.h" #include "nsFrameManager.h" #include "nsEventStateManager.h" #include "nsIMEStateManager.h" @@ -7926,8 +7925,6 @@ nsIPresShell::RemoveRefreshObserverExternal(nsARefreshObserver* aObserver, #include "nsIURL.h" #include "nsILinkHandler.h" -static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); - static void LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg) { @@ -8270,7 +8267,7 @@ PresShell::VerifyIncrementalReflow() nsIWidget* parentWidget = rootView->GetWidget(); // Create a new view manager. - nsRefPtr vm = do_CreateInstance(kViewManagerCID); + nsRefPtr vm = new nsViewManager(); NS_ENSURE_TRUE(vm, false); rv = vm->Init(dc); NS_ENSURE_SUCCESS(rv, false); diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index ad41b6b499d4..0589851d6361 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -66,8 +66,6 @@ #include "nsChannelPolicy.h" // view stuff -#include "nsViewsCID.h" -#include "nsViewManager.h" #include "nsContentCreatorFunctions.h" // DOM includes @@ -594,8 +592,6 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \ return rv; \ } \ -NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewManager) - static nsresult CreateHTMLImgElement(nsISupports* aOuter, REFNSIID aIID, void** aResult) { @@ -755,7 +751,6 @@ NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID); NS_DEFINE_NAMED_CID(NS_JSURI_CID); NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID); NS_DEFINE_NAMED_CID(NS_WINDOWCONTROLLER_CID); -NS_DEFINE_NAMED_CID(NS_VIEW_MANAGER_CID); NS_DEFINE_NAMED_CID(NS_PLUGINDOCLOADERFACTORY_CID); NS_DEFINE_NAMED_CID(NS_PLUGINDOCUMENT_CID); #ifdef MOZ_MEDIA @@ -1039,7 +1034,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = { { &kNS_JSURI_CID, false, NULL, nsJSURIConstructor }, { &kNS_WINDOWCOMMANDTABLE_CID, false, NULL, CreateWindowCommandTableConstructor }, { &kNS_WINDOWCONTROLLER_CID, false, NULL, CreateWindowControllerWithSingletonCommandTable }, - { &kNS_VIEW_MANAGER_CID, false, NULL, nsViewManagerConstructor }, { &kNS_PLUGINDOCLOADERFACTORY_CID, false, NULL, CreateContentDLF }, { &kNS_PLUGINDOCUMENT_CID, false, NULL, CreatePluginDocument }, #ifdef MOZ_MEDIA @@ -1189,7 +1183,6 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID }, { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID }, { NS_WINDOWCONTROLLER_CONTRACTID, &kNS_WINDOWCONTROLLER_CID }, - { "@mozilla.org/view-manager;1", &kNS_VIEW_MANAGER_CID }, { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID }, { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID }, { TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID, &kTRANSFORMIIX_XSLT_PROCESSOR_CID }, diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 225ed61290b5..2224765fddce 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -87,7 +87,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "nsLayoutUtils.h" #include "mozilla/Preferences.h" -#include "nsViewsCID.h" #include "nsWidgetsCID.h" #include "nsIDeviceContextSpec.h" #include "nsViewManager.h" @@ -216,9 +215,6 @@ protected: bool mSuppressed; }; -// Class IDs -static NS_DEFINE_CID(kViewManagerCID, NS_VIEW_MANAGER_CID); - NS_IMPL_ISUPPORTS3(nsPrintEngine, nsIWebProgressListener, nsISupportsWeakReference, nsIObserver) @@ -2197,8 +2193,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO) nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDC); NS_ENSURE_SUCCESS(rv, rv); - aPO->mViewManager = do_CreateInstance(kViewManagerCID, &rv); - NS_ENSURE_SUCCESS(rv,rv); + aPO->mViewManager = new nsViewManager(); rv = aPO->mViewManager->Init(mPrt->mPrintDC); NS_ENSURE_SUCCESS(rv,rv); diff --git a/view/public/Makefile.in b/view/public/Makefile.in index 15a90772c1f2..49effdfb71a2 100644 --- a/view/public/Makefile.in +++ b/view/public/Makefile.in @@ -15,7 +15,6 @@ MODULE = view EXPORTS = \ nsView.h \ nsViewManager.h \ - nsViewsCID.h \ nsIScrollPositionListener.h \ $(NULL) diff --git a/view/public/nsViewsCID.h b/view/public/nsViewsCID.h deleted file mode 100644 index 5c06871a4235..000000000000 --- a/view/public/nsViewsCID.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef nsViewsCID_h__ -#define nsViewsCID_h__ - -#include "nsISupports.h" -#include "nsIFactory.h" -#include "nsIComponentManager.h" - -#define NS_VIEW_MANAGER_CID \ -{ 0xc95f1831, 0xc376, 0x11d1, \ - {0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}} - -#endif // nsViewsCID_h__ From babc3f0e497e7f9abc977004f3046319c6695270 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:12:57 +1300 Subject: [PATCH 169/180] Bug 826632. Part 4: nsViewManager does not need to implement nsISupports anymore. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : c075212306ddadf37218d440f629becd5d2c52e2 --- view/public/nsViewManager.h | 13 ++----------- view/src/nsViewManager.cpp | 2 -- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index c959b7d1f56b..2daab6467684 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -26,20 +26,14 @@ class nsDeviceContext; class nsIPresShell; class nsView; -#define NS_IVIEWMANAGER_IID \ -{ 0x540610a6, 0x4fdd, 0x4ae3, \ - { 0x9b, 0xdb, 0xa6, 0x4d, 0x8b, 0xca, 0x02, 0x0f } } - -class nsViewManager : public nsISupports +class nsViewManager { public: friend class nsView; - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IVIEWMANAGER_IID) - NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW - NS_DECL_ISUPPORTS + NS_INLINE_DECL_REFCOUNTING(nsViewManager) nsViewManager(); virtual ~nsViewManager(); @@ -429,9 +423,6 @@ private: static nsVoidArray *gViewManagers; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsViewManager, NS_IVIEWMANAGER_IID) - - /** Invalidation model: diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 414fc77dedee..d40d44a0a88c 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -122,8 +122,6 @@ nsViewManager::~nsViewManager() mPresShell = nullptr; } -NS_IMPL_ISUPPORTS1(nsViewManager, nsViewManager) - // We don't hold a reference to the presentation context because it // holds a reference to us. NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) From cb844b988c592dc46a1885c7e03dd9d1c98a577e Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:13:05 +1300 Subject: [PATCH 170/180] Bug 826632. Part 5: nsViewManager methods do not need to be virtual and most of the ones that return nsresult don't need to. r=tnikkel Also, just use GetRootView instead of GetRootViewImpl. --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : c2417fdf6c5e4c94ca759ac12175a2d3a0de52e6 --- docshell/base/nsDocShell.cpp | 2 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +- view/public/nsViewManager.h | 74 ++++++------ view/src/nsView.cpp | 14 +-- view/src/nsViewManager.cpp | 125 ++++++++++----------- 5 files changed, 106 insertions(+), 113 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index acde564214c6..f4f10dabb371 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -5051,7 +5051,7 @@ nsDocShell::Repaint(bool aForce) nsViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(viewManager->InvalidateAllViews(), NS_ERROR_FAILURE); + viewManager->InvalidateAllViews(); return NS_OK; } diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 1f85478b3b57..0b46a8ce1105 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -743,14 +743,14 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) #endif // simply return the topmost document window nsCOMPtr widget; - nsresult rv = vm->GetRootWidget(getter_AddRefs(widget)); + vm->GetRootWidget(getter_AddRefs(widget)); if (widget) { *pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW); } else { NS_ASSERTION(widget, "couldn't get doc's widget in getting doc's window handle"); } - return rv; + return NS_OK; #elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11) // X11 window managers want the toplevel window for WM_TRANSIENT_FOR. nsIWidget* win = mObjectFrame->GetNearestWidget(); diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index 2daab6467684..bfc729758f2e 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -24,9 +24,8 @@ struct nsRect; class nsRegion; class nsDeviceContext; class nsIPresShell; -class nsView; -class nsViewManager +class nsViewManager MOZ_FINAL { public: friend class nsView; @@ -36,7 +35,7 @@ public: NS_INLINE_DECL_REFCOUNTING(nsViewManager) nsViewManager(); - virtual ~nsViewManager(); + ~nsViewManager(); /** * Initialize the ViewManager @@ -44,7 +43,7 @@ public: * because it holds a reference to this instance. * @result The result of the initialization, NS_OK if no errors */ - NS_IMETHOD Init(nsDeviceContext* aContext); + nsresult Init(nsDeviceContext* aContext); /** * Create an ordinary view @@ -58,15 +57,15 @@ public: * XXX We should eliminate this parameter; you can set it after CreateView * @result The new view */ - NS_IMETHOD_(nsView*) CreateView(const nsRect& aBounds, - const nsView* aParent, - nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); + nsView* CreateView(const nsRect& aBounds, + const nsView* aParent, + nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow); /** * Get the root of the view tree. * @result the root view */ - NS_IMETHOD_(nsView*) GetRootView() { return mRootView; } + nsView* GetRootView() { return mRootView; } /** * Set the root of the view tree. Does not destroy the current root view. @@ -74,7 +73,7 @@ public: * aView may have a widget (anything but printing) or may not (printing). * @param aView view to set as root */ - NS_IMETHOD SetRootView(nsView *aView); + void SetRootView(nsView *aView); /** * Get the dimensions of the root window. The dimensions are in @@ -82,7 +81,7 @@ public: * @param aWidth out parameter for width of window in twips * @param aHeight out parameter for height of window in twips */ - NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); + void GetWindowDimensions(nscoord *aWidth, nscoord *aHeight); /** * Set the dimensions of the root window. @@ -91,19 +90,19 @@ public: * @param aWidth of window in twips * @param aHeight of window in twips */ - NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight); + void SetWindowDimensions(nscoord aWidth, nscoord aHeight); /** * Do any resizes that are pending. */ - NS_IMETHOD FlushDelayedResize(bool aDoReflow); + void FlushDelayedResize(bool aDoReflow); /** * Called to inform the view manager that the entire area of a view * is dirty and needs to be redrawn. * @param aView view to paint. should be root view */ - NS_IMETHOD InvalidateView(nsView *aView); + void InvalidateView(nsView *aView); /** * Called to inform the view manager that some portion of a view is dirty and @@ -112,12 +111,12 @@ public: * @param aView view to paint. should be root view * @param rect rect to mark as damaged */ - NS_IMETHOD InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); + void InvalidateViewNoSuppression(nsView *aView, const nsRect &aRect); /** * Called to inform the view manager that it should invalidate all views. */ - NS_IMETHOD InvalidateAllViews(); + void InvalidateAllViews(); /** * Called to dispatch an event to the appropriate view. Often called @@ -127,7 +126,7 @@ public: * @param aViewTarget dispatch the event to this view * @param aStatus event handling status */ - NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, + void DispatchEvent(nsGUIEvent *aEvent, nsView* aViewTarget, nsEventStatus* aStatus); /** @@ -145,10 +144,10 @@ public: * @param aSibling sibling view * @param aAfter after or before in the document order */ - NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter); + void InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, + bool aAfter); - NS_IMETHOD InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); + void InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex); /** * Remove a specific child view from its parent. This will NOT remove its placeholder @@ -157,7 +156,7 @@ public: * @param aParent parent view * @param aChild child view */ - NS_IMETHOD RemoveChild(nsView *aChild); + void RemoveChild(nsView *aChild); /** * Move a view to the specified position, provided in parent coordinates. @@ -168,7 +167,7 @@ public: * @param aX x value for new view position * @param aY y value for new view position */ - NS_IMETHOD MoveViewTo(nsView *aView, nscoord aX, nscoord aY); + void MoveViewTo(nsView *aView, nscoord aX, nscoord aY); /** * Resize a view. In addition to setting the width and height, you can @@ -182,8 +181,8 @@ public: * if true Repaint only the expanded or contracted region, * if false Repaint the union of the old and new rectangles. */ - NS_IMETHOD ResizeView(nsView *aView, const nsRect &aRect, - bool aRepaintExposedAreaOnly = false); + void ResizeView(nsView *aView, const nsRect &aRect, + bool aRepaintExposedAreaOnly = false); /** * Set the visibility of a view. Hidden views have the effect of hiding @@ -196,7 +195,7 @@ public: * @param aView view to change visibility state of * @param visible new visibility state */ - NS_IMETHOD SetViewVisibility(nsView *aView, nsViewVisibility aVisible); + void SetViewVisibility(nsView *aView, nsViewVisibility aVisible); /** * Set the z-index of a view. Positive z-indices mean that a view @@ -214,7 +213,7 @@ public: * true if the view should be topmost when compared with * other z-index:auto views. */ - NS_IMETHOD SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); + void SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZindex, bool aTopMost = false); /** * Set whether the view "floats" above all other views, @@ -223,24 +222,24 @@ public: * this view. This is a hack, but it fixes some problems with * views that need to be drawn in front of all other views. */ - NS_IMETHOD SetViewFloating(nsView *aView, bool aFloatingView); + void SetViewFloating(nsView *aView, bool aFloatingView); /** * Set the presshell associated with this manager * @param aPresShell - new presshell */ - virtual void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } + void SetPresShell(nsIPresShell *aPresShell) { mPresShell = aPresShell; } /** * Get the pres shell associated with this manager */ - virtual nsIPresShell* GetPresShell() { return mPresShell; } + nsIPresShell* GetPresShell() { return mPresShell; } /** * Get the device context associated with this manager * @result device context */ - NS_IMETHOD GetDeviceContext(nsDeviceContext *&aContext); + void GetDeviceContext(nsDeviceContext *&aContext); /** * A stack class for disallowing changes that would enter painting. For @@ -276,15 +275,15 @@ public: private: friend class AutoDisableRefresh; - virtual nsViewManager* IncrementDisableRefreshCount(); - virtual void DecrementDisableRefreshCount(); + nsViewManager* IncrementDisableRefreshCount(); + void DecrementDisableRefreshCount(); public: /** * Retrieve the widget at the root of the nearest enclosing * view manager whose root view has a widget. */ - NS_IMETHOD GetRootWidget(nsIWidget **aWidget); + void GetRootWidget(nsIWidget **aWidget); /** * Indicate whether the viewmanager is currently painting @@ -292,7 +291,7 @@ public: * @param aPainting true if the viewmanager is painting * false otherwise */ - NS_IMETHOD IsPainting(bool& aIsPainting); + void IsPainting(bool& aIsPainting); /** * Retrieve the time of the last user event. User events @@ -301,7 +300,7 @@ public: * * @param aTime Last user event time in microseconds */ - NS_IMETHOD GetLastUserEventTime(uint32_t& aTime); + void GetLastUserEventTime(uint32_t& aTime); /** * Find the nearest display root view for the view aView. This is the view for @@ -313,18 +312,17 @@ public: * Flush the accumulated dirty region to the widget and update widget * geometry. */ - virtual void ProcessPendingUpdates(); + void ProcessPendingUpdates(); /** * Just update widget geometry without flushing the dirty region */ - virtual void UpdateWidgetGeometry(); + void UpdateWidgetGeometry(); uint32_t AppUnitsPerDevPixel() const { return mContext->AppUnitsPerDevPixel(); } - nsView* GetRootViewImpl() const { return mRootView; } private: static uint32_t gLastUserEventTime; @@ -374,7 +372,7 @@ private: RootViewManager()->mPainting = aPainting; } - nsresult InvalidateView(nsView *aView, const nsRect &aRect); + void InvalidateView(nsView *aView, const nsRect &aRect); nsViewManager* RootViewManager() const { return mRootViewManager; } bool IsRootVM() const { return this == RootViewManager(); } diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index 64b9ff50072c..fc54bee54f03 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -63,7 +63,7 @@ nsView::~nsView() { DropMouseGrabbing(); - nsView *rootView = mViewManager->GetRootViewImpl(); + nsView *rootView = mViewManager->GetRootView(); if (rootView) { @@ -225,7 +225,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly, bool aInvalidateChangedSize) { // The geometry of a root view's widget is controlled externally, // NOT by sizing or positioning the view - if (mViewManager->GetRootViewImpl() == this) { + if (mViewManager->GetRootView() == this) { return; } @@ -347,7 +347,7 @@ void nsView::SetFloating(bool aFloatingView) void nsView::InvalidateHierarchy(nsViewManager *aViewManagerParent) { - if (mViewManager->GetRootViewImpl() == this) + if (mViewManager->GetRootView() == this) mViewManager->InvalidateHierarchy(); for (nsView *child = mFirstChild; child; child = child->GetNextSibling()) @@ -380,7 +380,7 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // on all view managers in the new subtree. nsViewManager *vm = aChild->GetViewManagerInternal(); - if (vm->GetRootViewImpl() == aChild) + if (vm->GetRootView() == aChild) { aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs } @@ -416,7 +416,7 @@ void nsView::RemoveChild(nsView *child) // on all view managers in the removed subtree. nsViewManager *vm = child->GetViewManagerInternal(); - if (vm->GetRootViewImpl() == child) + if (vm->GetRootView() == child) { child->InvalidateHierarchy(GetViewManagerInternal()); } @@ -856,7 +856,7 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const bool nsView::IsRoot() const { NS_ASSERTION(mViewManager != nullptr," View manager is null in nsView::IsRoot()"); - return mViewManager->GetRootViewImpl() == this; + return mViewManager->GetRootView() == this; } nsRect @@ -864,7 +864,7 @@ nsView::GetBoundsInParentUnits() const { nsView* parent = GetParent(); nsViewManager* VM = GetViewManagerInternal(); - if (this != VM->GetRootViewImpl() || !parent) { + if (this != VM->GetRootView() || !parent) { return mDimBounds; } int32_t ourAPD = VM->AppUnitsPerDevPixel(); diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index d40d44a0a88c..13bec8949699 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -124,7 +124,8 @@ nsViewManager::~nsViewManager() // We don't hold a reference to the presentation context because it // holds a reference to us. -NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) +nsresult +nsViewManager::Init(nsDeviceContext* aContext) { NS_PRECONDITION(nullptr != aContext, "null ptr"); @@ -139,7 +140,7 @@ NS_IMETHODIMP nsViewManager::Init(nsDeviceContext* aContext) return NS_OK; } -NS_IMETHODIMP_(nsView *) +nsView* nsViewManager::CreateView(const nsRect& aBounds, const nsView* aParent, nsViewVisibility aVisibilityFlag) @@ -154,7 +155,8 @@ nsViewManager::CreateView(const nsRect& aBounds, return v; } -NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) +void +nsViewManager::SetRootView(nsView *aView) { NS_PRECONDITION(!aView || aView->GetViewManager() == this, "Unexpected viewmanager on root view"); @@ -176,11 +178,10 @@ NS_IMETHODIMP nsViewManager::SetRootView(nsView *aView) mRootView->SetZIndex(false, 0, false); } // Else don't touch mRootViewManager - - return NS_OK; } -NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) +void +nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) { if (nullptr != mRootView) { if (mDelayedResize == nsSize(NSCOORD_NONE, NSCOORD_NONE)) { @@ -197,7 +198,6 @@ NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *aWidth, nscoord *aHeig *aWidth = 0; *aHeight = 0; } - return NS_OK; } void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) @@ -213,7 +213,8 @@ void nsViewManager::DoSetWindowDimensions(nscoord aWidth, nscoord aHeight) } } -NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) +void +nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight) { if (mRootView) { if (mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { @@ -236,11 +237,10 @@ NS_IMETHODIMP nsViewManager::SetWindowDimensions(nscoord aWidth, nscoord aHeight } } } - - return NS_OK; } -NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow) +void +nsViewManager::FlushDelayedResize(bool aDoReflow) { if (mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE)) { if (aDoReflow) { @@ -253,7 +253,6 @@ NS_IMETHODIMP nsViewManager::FlushDelayedResize(bool aDoReflow) } } } - return NS_OK; } // Convert aIn from being relative to and in appunits of aFromView, to being @@ -447,10 +446,11 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) dirtyRegion->SetEmpty(); } -NS_IMETHODIMP nsViewManager::InvalidateView(nsView *aView) +void +nsViewManager::InvalidateView(nsView *aView) { // Mark the entire view as damaged - return InvalidateView(aView, aView->GetDimensions()); + InvalidateView(aView, aView->GetDimensions()); } static void @@ -569,19 +569,21 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) return false; } -nsresult nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect) +void +nsViewManager::InvalidateView(nsView *aView, const nsRect &aRect) { // If painting is suppressed in the presshell or an ancestor drop all // invalidates, it will invalidate everything when it unsuppresses. if (ShouldIgnoreInvalidation(this)) { - return NS_OK; + return; } - return InvalidateViewNoSuppression(aView, aRect); + InvalidateViewNoSuppression(aView, aRect); } -NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, - const nsRect &aRect) +void +nsViewManager::InvalidateViewNoSuppression(nsView *aView, + const nsRect &aRect) { NS_PRECONDITION(nullptr != aView, "null view"); @@ -590,7 +592,7 @@ NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, nsRect damagedRect(aRect); if (damagedRect.IsEmpty()) { - return NS_OK; + return; } nsView* displayRoot = GetDisplayRootFor(aView); @@ -606,18 +608,16 @@ NS_IMETHODIMP nsViewManager::InvalidateViewNoSuppression(nsView *aView, // accumulate this rectangle in the view's dirty region, so we can // process it later. AddDirtyRegion(displayRoot, nsRegion(damagedRect)); - - return NS_OK; } -NS_IMETHODIMP nsViewManager::InvalidateAllViews() +void +nsViewManager::InvalidateAllViews() { if (RootViewManager() != this) { return RootViewManager()->InvalidateAllViews(); } InvalidateViews(mRootView); - return NS_OK; } void nsViewManager::InvalidateViews(nsView *aView) @@ -708,7 +708,8 @@ void nsViewManager::DidPaintWindow() } } -nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) +void +nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEventStatus* aStatus) { SAMPLE_LABEL("event", "nsViewManager::DispatchEvent"); @@ -759,13 +760,12 @@ nsresult nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsView* aView, nsEvent // want to cause its destruction in, say, some JavaScript event handler. nsCOMPtr shell = view->GetViewManager()->GetPresShell(); if (shell) { - return shell->HandleEvent(frame, aEvent, false, aStatus); + shell->HandleEvent(frame, aEvent, false, aStatus); + return; } } *aStatus = nsEventStatus_eIgnore; - - return NS_OK; } // Recursively reparent widgets if necessary @@ -829,8 +829,9 @@ void nsViewManager::ReparentWidgets(nsView* aView, nsView *aParent) } } -NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, - bool aAfter) +void +nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, + bool aAfter) { NS_PRECONDITION(nullptr != aParent, "null ptr"); NS_PRECONDITION(nullptr != aChild, "null ptr"); @@ -891,20 +892,21 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView if (nsViewVisibility_kHide != aChild->GetVisibility()) aChild->GetViewManagerInternal()->InvalidateView(aChild); } - return NS_OK; } -NS_IMETHODIMP nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex) +void +nsViewManager::InsertChild(nsView *aParent, nsView *aChild, int32_t aZIndex) { // no-one really calls this with anything other than aZIndex == 0 on a fresh view // XXX this method should simply be eliminated and its callers redirected to the real method SetViewZIndex(aChild, false, aZIndex, false); - return InsertChild(aParent, aChild, nullptr, true); + InsertChild(aParent, aChild, nullptr, true); } -NS_IMETHODIMP nsViewManager::RemoveChild(nsView *aChild) +void +nsViewManager::RemoveChild(nsView *aChild) { - NS_ENSURE_ARG_POINTER(aChild); + NS_ASSERTION(aChild, "aChild must not be null"); nsView* parent = aChild->GetParent(); @@ -914,11 +916,10 @@ NS_IMETHODIMP nsViewManager::RemoveChild(nsView *aChild) aChild->GetViewManagerInternal()->InvalidateView(aChild); parent->RemoveChild(aChild); } - - return NS_OK; } -NS_IMETHODIMP nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) +void +nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); nsPoint oldPt = aView->GetPosition(); @@ -937,7 +938,6 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) } } } - return NS_OK; } void nsViewManager::InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut, @@ -971,7 +971,8 @@ void nsViewManager::InvalidateRectDifference(nsView *aView, const nsRect& aRect, } } -NS_IMETHODIMP nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly) +void +nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExposedAreaOnly) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -1006,20 +1007,18 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool // in the case where mClipRect has been optimized away to just be a null // pointer, and this resize is implicitly changing the clip rect, it's OK // because layout will change it back again if necessary. - - return NS_OK; } -NS_IMETHODIMP nsViewManager::SetViewFloating(nsView *aView, bool aFloating) +void +nsViewManager::SetViewFloating(nsView *aView, bool aFloating) { NS_ASSERTION(!(nullptr == aView), "no view"); aView->SetFloating(aFloating); - - return NS_OK; } -NS_IMETHODIMP nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) +void +nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -1041,7 +1040,6 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility a } } } - return NS_OK; } bool nsViewManager::IsViewInserted(nsView *aView) @@ -1062,16 +1060,15 @@ bool nsViewManager::IsViewInserted(nsView *aView) } } -NS_IMETHODIMP nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost) +void +nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int32_t aZIndex, bool aTopMost) { - nsresult rv = NS_OK; - NS_ASSERTION((aView != nullptr), "no view"); // don't allow the root view's z-index to be changed. It should always be zero. // This could be removed and replaced with a style rule, or just removed altogether, with interesting consequences if (aView == mRootView) { - return rv; + return; } bool oldTopMost = aView->IsTopMost(); @@ -1088,15 +1085,13 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsView *aView, bool aAutoZIndex, int3 oldIsAuto != aAutoZIndex) { InvalidateView(aView); } - - return rv; } -NS_IMETHODIMP nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) +void +nsViewManager::GetDeviceContext(nsDeviceContext *&aContext) { aContext = mContext; NS_IF_ADDREF(aContext); - return NS_OK; } nsViewManager* @@ -1119,21 +1114,23 @@ nsViewManager::DecrementDisableRefreshCount() NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!"); } -NS_IMETHODIMP nsViewManager::GetRootWidget(nsIWidget **aWidget) +void +nsViewManager::GetRootWidget(nsIWidget **aWidget) { if (!mRootView) { *aWidget = nullptr; - return NS_OK; + return; } if (mRootView->HasWidget()) { *aWidget = mRootView->GetWidget(); NS_ADDREF(*aWidget); - return NS_OK; + return; + } + if (mRootView->GetParent()) { + mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); + return; } - if (mRootView->GetParent()) - return mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); *aWidget = nullptr; - return NS_OK; } nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const @@ -1147,11 +1144,10 @@ nsIntRect nsViewManager::ViewToWidget(nsView *aView, const nsRect &aRect) const return rect.ToOutsidePixels(AppUnitsPerDevPixel()); } -NS_IMETHODIMP +void nsViewManager::IsPainting(bool& aIsPainting) { aIsPainting = IsPainting(); - return NS_OK; } void @@ -1214,11 +1210,10 @@ nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint) } } -NS_IMETHODIMP +void nsViewManager::GetLastUserEventTime(uint32_t& aTime) { aTime = gLastUserEventTime; - return NS_OK; } void From 3dab6ad22daa9099f9af73cb327df9a73a06a894 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:13:13 +1300 Subject: [PATCH 171/180] Bug 826632. Part 6: Remove some unnecessary #includes from nsView.h and nsViewManager.h. r=tnikkel --HG-- rename : view/public/nsIViewManager.h => view/public/nsViewManager.h extra : rebase_source : f99b6ff33490cf6ad5467296eca573752518ea96 --- view/public/nsView.h | 6 ------ view/public/nsViewManager.h | 5 ----- 2 files changed, 11 deletions(-) diff --git a/view/public/nsView.h b/view/public/nsView.h index 686a97abc3d6..42ae807d3526 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -6,19 +6,13 @@ #ifndef nsView_h__ #define nsView_h__ -#include "nsISupports.h" #include "nsCoord.h" #include "nsRect.h" #include "nsPoint.h" -#include "nsNativeWidget.h" -#include "nsIWidget.h" -#include "nsWidgetInitData.h" #include "nsRegion.h" #include "nsCRT.h" -#include "nsIFactory.h" #include "nsEvent.h" #include "nsIWidgetListener.h" -#include class nsViewManager; class nsIWidget; diff --git a/view/public/nsViewManager.h b/view/public/nsViewManager.h index bfc729758f2e..f5ba8823e065 100644 --- a/view/public/nsViewManager.h +++ b/view/public/nsViewManager.h @@ -11,12 +11,7 @@ #include "nsEvent.h" #include "nsCOMPtr.h" #include "nsCRT.h" -#include "nsITimer.h" -#include "prtime.h" -#include "prinrval.h" #include "nsVoidArray.h" -#include "nsThreadUtils.h" -#include "nsIPresShell.h" #include "nsDeviceContext.h" class nsIWidget; From 3c1960d5dba736745098487c7a050d4277ff7066 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:13:23 +1300 Subject: [PATCH 172/180] Bug 826632. Part 7: nsView::GetViewManagerInternal is no longer relevant, so remove it. r=tnikkel --HG-- extra : rebase_source : 82bb5be5e3dc16f42d7f13a0b7d9eabef1f2fe5c --- view/public/nsView.h | 4 +--- view/src/nsView.cpp | 30 +++++++++++++++--------------- view/src/nsViewManager.cpp | 30 +++++++++++++++--------------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/view/public/nsView.h b/view/public/nsView.h index 42ae807d3526..9e2d9f02c728 100644 --- a/view/public/nsView.h +++ b/view/public/nsView.h @@ -68,9 +68,7 @@ public: * view manager from somewhere else, do that instead. * @result the view manager */ - nsViewManager* GetViewManager() const - { return reinterpret_cast(mViewManager); } - nsViewManager* GetViewManagerInternal() const { return mViewManager; } + nsViewManager* GetViewManager() const { return mViewManager; } /** * Find the view for the given widget, if there is one. diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp index fc54bee54f03..a2dc372a6fdb 100644 --- a/view/src/nsView.cpp +++ b/view/src/nsView.cpp @@ -379,7 +379,7 @@ void nsView::InsertChild(nsView *aChild, nsView *aSibling) // If we just inserted a root view, then update the RootViewManager // on all view managers in the new subtree. - nsViewManager *vm = aChild->GetViewManagerInternal(); + nsViewManager *vm = aChild->GetViewManager(); if (vm->GetRootView() == aChild) { aChild->InvalidateHierarchy(nullptr); // don't care about releasing grabs @@ -415,10 +415,10 @@ void nsView::RemoveChild(nsView *child) // If we just removed a root view, then update the RootViewManager // on all view managers in the removed subtree. - nsViewManager *vm = child->GetViewManagerInternal(); + nsViewManager *vm = child->GetViewManager(); if (vm->GetRootView() == child) { - child->InvalidateHierarchy(GetViewManagerInternal()); + child->InvalidateHierarchy(GetViewManager()); } } } @@ -736,7 +736,7 @@ void nsView::List(FILE* out, int32_t aIndent) const nsPoint nsView::GetOffsetTo(const nsView* aOther) const { - return GetOffsetTo(aOther, GetViewManagerInternal()->AppUnitsPerDevPixel()); + return GetOffsetTo(aOther, GetViewManager()->AppUnitsPerDevPixel()); } nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const @@ -749,11 +749,11 @@ nsPoint nsView::GetOffsetTo(const nsView* aOther, const int32_t aAPD) const // The offset currently accumulated at the current APD nsPoint docOffset(0, 0); const nsView* v = this; - nsViewManager* currVM = v->GetViewManagerInternal(); + nsViewManager* currVM = v->GetViewManager(); int32_t currAPD = currVM->AppUnitsPerDevPixel(); const nsView* root = nullptr; for ( ; v != aOther && v; root = v, v = v->GetParent()) { - nsViewManager* newVM = v->GetViewManagerInternal(); + nsViewManager* newVM = v->GetViewManager(); if (newVM != currVM) { int32_t newAPD = newVM->AppUnitsPerDevPixel(); if (newAPD != currAPD) { @@ -799,15 +799,15 @@ nsPoint nsView::GetOffsetToWidget(nsIWidget* aWidget) const pt += widgetView->ViewToWidgetOffset(); // Convert to our appunits. - int32_t widgetAPD = widgetView->GetViewManagerInternal()->AppUnitsPerDevPixel(); - int32_t ourAPD = GetViewManagerInternal()->AppUnitsPerDevPixel(); + int32_t widgetAPD = widgetView->GetViewManager()->AppUnitsPerDevPixel(); + int32_t ourAPD = GetViewManager()->AppUnitsPerDevPixel(); pt = pt.ConvertAppUnits(widgetAPD, ourAPD); return pt; } nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset) const { - return GetNearestWidget(aOffset, GetViewManagerInternal()->AppUnitsPerDevPixel()); + return GetNearestWidget(aOffset, GetViewManager()->AppUnitsPerDevPixel()); } nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const @@ -820,10 +820,10 @@ nsIWidget* nsView::GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const // The offset currently accumulated at the current APD nsPoint docPt(0,0); const nsView* v = this; - nsViewManager* currVM = v->GetViewManagerInternal(); + nsViewManager* currVM = v->GetViewManager(); int32_t currAPD = currVM->AppUnitsPerDevPixel(); for ( ; v && !v->HasWidget(); v = v->GetParent()) { - nsViewManager* newVM = v->GetViewManagerInternal(); + nsViewManager* newVM = v->GetViewManager(); if (newVM != currVM) { int32_t newAPD = newVM->AppUnitsPerDevPixel(); if (newAPD != currAPD) { @@ -863,12 +863,12 @@ nsRect nsView::GetBoundsInParentUnits() const { nsView* parent = GetParent(); - nsViewManager* VM = GetViewManagerInternal(); + nsViewManager* VM = GetViewManager(); if (this != VM->GetRootView() || !parent) { return mDimBounds; } int32_t ourAPD = VM->AppUnitsPerDevPixel(); - int32_t parentAPD = parent->GetViewManagerInternal()->AppUnitsPerDevPixel(); + int32_t parentAPD = parent->GetViewManager()->AppUnitsPerDevPixel(); return mDimBounds.ConvertAppUnitsRoundOut(ourAPD, parentAPD); } @@ -877,8 +877,8 @@ nsView::ConvertFromParentCoords(nsPoint aPt) const { const nsView* parent = GetParent(); if (parent) { - aPt = aPt.ConvertAppUnits(parent->GetViewManagerInternal()->AppUnitsPerDevPixel(), - GetViewManagerInternal()->AppUnitsPerDevPixel()); + aPt = aPt.ConvertAppUnits(parent->GetViewManager()->AppUnitsPerDevPixel(), + GetViewManager()->AppUnitsPerDevPixel()); } aPt -= GetPosition(); return aPt; diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 13bec8949699..6bf8b108e55a 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -264,8 +264,8 @@ static nsRegion ConvertRegionBetweenViews(const nsRegion& aIn, nsRegion out = aIn; out.MoveBy(aFromView->GetOffsetTo(aToView)); out = out.ConvertAppUnitsRoundOut( - aFromView->GetViewManagerInternal()->AppUnitsPerDevPixel(), - aToView->GetViewManagerInternal()->AppUnitsPerDevPixel()); + aFromView->GetViewManager()->AppUnitsPerDevPixel(), + aToView->GetViewManager()->AppUnitsPerDevPixel()); return out; } @@ -396,7 +396,7 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // have a delayed resize to handle. for (nsViewManager *vm = this; vm; vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManagerInternal() + ? vm->mRootView->GetParent()->GetViewManager() : nullptr) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && vm->mRootView->IsEffectivelyVisible() && @@ -441,7 +441,7 @@ void nsViewManager::FlushDirtyRegionToWidget(nsView* aView) } nsRegion r = ConvertRegionBetweenViews(*dirtyRegion, aView, nearestViewWithWidget); - nsViewManager* widgetVM = nearestViewWithWidget->GetViewManagerInternal(); + nsViewManager* widgetVM = nearestViewWithWidget->GetViewManager(); widgetVM->InvalidateWidgetArea(nearestViewWithWidget, r); dirtyRegion->SetEmpty(); } @@ -564,7 +564,7 @@ ShouldIgnoreInvalidation(nsViewManager* aVM) return true; } nsView* view = aVM->GetRootView()->GetParent(); - aVM = view ? view->GetViewManagerInternal() : nullptr; + aVM = view ? view->GetViewManager() : nullptr; } return false; } @@ -596,7 +596,7 @@ nsViewManager::InvalidateViewNoSuppression(nsView *aView, } nsView* displayRoot = GetDisplayRootFor(aView); - nsViewManager* displayRootVM = displayRoot->GetViewManagerInternal(); + nsViewManager* displayRootVM = displayRoot->GetViewManager(); // Propagate the update to the displayRoot, since iframes, for example, // can overlap each other and be translucent. So we have to possibly // invalidate our rect in each of the widgets we have lying about. @@ -628,7 +628,7 @@ void nsViewManager::InvalidateViews(nsView *aView) // Invalidate all children as well. nsView* childView = aView->GetFirstChild(); while (nullptr != childView) { - childView->GetViewManagerInternal()->InvalidateViews(childView); + childView->GetViewManager()->InvalidateViews(childView); childView = childView->GetNextSibling(); } } @@ -640,7 +640,7 @@ void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) // have a delayed resize to handle. for (nsViewManager *vm = this; vm; vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManagerInternal() + ? vm->mRootView->GetParent()->GetViewManager() : nullptr) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && vm->mRootView->IsEffectivelyVisible() && @@ -890,7 +890,7 @@ nsViewManager::InsertChild(nsView *aParent, nsView *aChild, nsView *aSibling, //and mark this area as dirty if the view is visible... if (nsViewVisibility_kHide != aChild->GetVisibility()) - aChild->GetViewManagerInternal()->InvalidateView(aChild); + aChild->GetViewManager()->InvalidateView(aChild); } } @@ -913,7 +913,7 @@ nsViewManager::RemoveChild(nsView *aChild) if (nullptr != parent) { NS_ASSERTION(aChild->GetViewManager() == this || parent->GetViewManager() == this, "wrong view manager"); - aChild->GetViewManagerInternal()->InvalidateView(aChild); + aChild->GetViewManager()->InvalidateView(aChild); parent->RemoveChild(aChild); } } @@ -932,7 +932,7 @@ nsViewManager::MoveViewTo(nsView *aView, nscoord aX, nscoord aY) if (aView->GetVisibility() != nsViewVisibility_kHide) { nsView* parentView = aView->GetParent(); if (parentView) { - nsViewManager* parentVM = parentView->GetViewManagerInternal(); + nsViewManager* parentVM = parentView->GetViewManager(); parentVM->InvalidateView(parentView, oldBounds); parentVM->InvalidateView(parentView, aView->GetBoundsInParentUnits()); } @@ -989,7 +989,7 @@ nsViewManager::ResizeView(nsView *aView, const nsRect &aRect, bool aRepaintExpos } nsRect oldBounds = aView->GetBoundsInParentUnits(); aView->SetDimensions(aRect, true); - nsViewManager* parentVM = parentView->GetViewManagerInternal(); + nsViewManager* parentVM = parentView->GetViewManager(); if (!aRepaintExposedAreaOnly) { // Invalidate the union of the old and new size InvalidateView(aView, aRect); @@ -1030,7 +1030,7 @@ nsViewManager::SetViewVisibility(nsView *aView, nsViewVisibility aVisible) if (nsViewVisibility_kHide == aVisible) { nsView* parentView = aView->GetParent(); if (parentView) { - parentView->GetViewManagerInternal()-> + parentView->GetViewManager()-> InvalidateView(parentView, aView->GetBoundsInParentUnits()); } } @@ -1127,7 +1127,7 @@ nsViewManager::GetRootWidget(nsIWidget **aWidget) return; } if (mRootView->GetParent()) { - mRootView->GetParent()->GetViewManagerInternal()->GetRootWidget(aWidget); + mRootView->GetParent()->GetViewManager()->GetRootWidget(aWidget); return; } *aWidget = nullptr; @@ -1225,7 +1225,7 @@ nsViewManager::InvalidateHierarchy() } nsView *parent = mRootView->GetParent(); if (parent) { - mRootViewManager = parent->GetViewManagerInternal()->RootViewManager(); + mRootViewManager = parent->GetViewManager()->RootViewManager(); NS_ADDREF(mRootViewManager); NS_ASSERTION(mRootViewManager != this, "Root view had a parent, but it has the same view manager"); From 09cf7c5863eb856d0dd640ba037a2670238704d7 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sat, 5 Jan 2013 16:14:17 +1300 Subject: [PATCH 173/180] Bug 826635. Refresh-driver painting is always enabled now, so remove the alternative code path. r=tnikkel --HG-- extra : rebase_source : e349986d12bd4e6a6afeb3ee6f28290440b39f27 --- view/src/nsViewManager.cpp | 133 +++++++++++-------------------------- 1 file changed, 39 insertions(+), 94 deletions(-) diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 6bf8b108e55a..a7327d230bd2 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -46,22 +46,6 @@ #undef DEBUG_MOUSE_LOCATION -static bool -IsRefreshDriverPaintingEnabled() -{ - static bool sRefreshDriverPaintingEnabled; - static bool sRefreshDriverPaintingPrefCached = false; - - if (!sRefreshDriverPaintingPrefCached) { - sRefreshDriverPaintingPrefCached = true; - mozilla::Preferences::AddBoolVarCache(&sRefreshDriverPaintingEnabled, - "viewmanager.refresh-driver-painting.enabled", - true); - } - - return sRefreshDriverPaintingEnabled; -} - int32_t nsViewManager::mVMCount = 0; // Weakly held references to all of the view managers @@ -348,7 +332,6 @@ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion, printf("--COMPOSITE-- %p\n", mPresShell); #endif mPresShell->Paint(aView, damageRegion, - (IsRefreshDriverPaintingEnabled() ? 0 : nsIPresShell::PAINT_LAYERS) | nsIPresShell::PAINT_COMPOSITE | (aWillSendDidPaint ? nsIPresShell::PAINT_WILL_SEND_DID_PAINT : 0)); #ifdef DEBUG_INVALIDATIONS @@ -389,40 +372,38 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // Push out updates after we've processed the children; ensures that // damage is applied based on the final widget geometry if (aFlushDirtyRegion) { - if (IsRefreshDriverPaintingEnabled()) { - nsIWidget *widget = aView->GetWidget(); - if (widget && widget->NeedsPaint()) { - // If an ancestor widget was hidden and then shown, we could - // have a delayed resize to handle. - for (nsViewManager *vm = this; vm; - vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManager() - : nullptr) { - if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && - vm->mRootView->IsEffectivelyVisible() && - mPresShell && mPresShell->IsVisible()) { - vm->FlushDelayedResize(true); - vm->InvalidateView(vm->mRootView); - } + nsIWidget *widget = aView->GetWidget(); + if (widget && widget->NeedsPaint()) { + // If an ancestor widget was hidden and then shown, we could + // have a delayed resize to handle. + for (nsViewManager *vm = this; vm; + vm = vm->mRootView->GetParent() + ? vm->mRootView->GetParent()->GetViewManager() + : nullptr) { + if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && + vm->mRootView->IsEffectivelyVisible() && + mPresShell && mPresShell->IsVisible()) { + vm->FlushDelayedResize(true); + vm->InvalidateView(vm->mRootView); } - - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - - SetPainting(true); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); -#endif - nsAutoScriptBlocker scriptBlocker; - NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); - mPresShell->Paint(aView, nsRegion(), - nsIPresShell::PAINT_LAYERS | - nsIPresShell::PAINT_WILL_SEND_DID_PAINT); -#ifdef DEBUG_INVALIDATIONS - printf("---- PAINT END ----\n"); -#endif - aView->SetForcedRepaint(false); - SetPainting(false); } + + NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); + + SetPainting(true); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); +#endif + nsAutoScriptBlocker scriptBlocker; + NS_ASSERTION(aView->HasWidget(), "Must have a widget!"); + mPresShell->Paint(aView, nsRegion(), + nsIPresShell::PAINT_LAYERS | + nsIPresShell::PAINT_WILL_SEND_DID_PAINT); +#ifdef DEBUG_INVALIDATIONS + printf("---- PAINT END ----\n"); +#endif + aView->SetForcedRepaint(false); + SetPainting(false); } FlushDirtyRegionToWidget(aView); } @@ -635,30 +616,7 @@ void nsViewManager::InvalidateViews(nsView *aView) void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { - if (!IsRefreshDriverPaintingEnabled() && aWidget && mContext) { - // If an ancestor widget was hidden and then shown, we could - // have a delayed resize to handle. - for (nsViewManager *vm = this; vm; - vm = vm->mRootView->GetParent() - ? vm->mRootView->GetParent()->GetViewManager() - : nullptr) { - if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && - vm->mRootView->IsEffectivelyVisible() && - mPresShell && mPresShell->IsVisible()) { - vm->FlushDelayedResize(true); - vm->InvalidateView(vm->mRootView); - } - } - - // Flush things like reflows by calling WillPaint on observer presShells. - nsRefPtr rootVM = RootViewManager(); - rootVM->CallWillPaintOnObservers(aWillSendDidPaint); - - // Flush view widget geometry updates and invalidations. - rootVM->ProcessPendingUpdates(); - } - - if (aWidget && IsRefreshDriverPaintingEnabled()) { + if (aWidget) { nsView* view = nsView::GetViewFor(aWidget); if (view && view->ForcedRepaint()) { ProcessPendingUpdates(); @@ -686,10 +644,6 @@ bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, NS_ASSERTION(IsPaintingAllowed(), "shouldn't be receiving paint events while painting is disallowed!"); - if (!(aFlags & nsIWidgetListener::SENT_WILL_PAINT) && !IsRefreshDriverPaintingEnabled()) { - WillPaintWindow(aWidget, (aFlags & nsIWidgetListener::WILL_SEND_DID_PAINT)); - } - // Get the view pointer here since NS_WILL_PAINT might have // destroyed it during CallWillPaintOnObservers (bug 378273). nsView* view = nsView::GetViewFor(aWidget); @@ -1053,7 +1007,7 @@ bool nsViewManager::IsViewInserted(nsView *aView) while (view != nullptr) { if (view == aView) { return true; - } + } view = view->GetNextSibling(); } return false; @@ -1158,17 +1112,13 @@ nsViewManager::ProcessPendingUpdates() return; } - if (IsRefreshDriverPaintingEnabled()) { - mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush(); - - // Flush things like reflows by calling WillPaint on observer presShells. - if (mPresShell) { - CallWillPaintOnObservers(true); - } - ProcessPendingUpdatesForView(mRootView, true); - } else { - ProcessPendingUpdatesForView(mRootView, true); + mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush(); + + // Flush things like reflows by calling WillPaint on observer presShells. + if (mPresShell) { + CallWillPaintOnObservers(true); } + ProcessPendingUpdatesForView(mRootView, true); } void @@ -1180,13 +1130,8 @@ nsViewManager::UpdateWidgetGeometry() } if (mHasPendingWidgetGeometryChanges) { - if (IsRefreshDriverPaintingEnabled()) { - mHasPendingWidgetGeometryChanges = false; - } + mHasPendingWidgetGeometryChanges = false; ProcessPendingUpdatesForView(mRootView, false); - if (!IsRefreshDriverPaintingEnabled()) { - mHasPendingWidgetGeometryChanges = false; - } } } From 8e64472f5ccb37cbd415c7003fb7a04edfa63a2d Mon Sep 17 00:00:00 2001 From: ffxbld Date: Sat, 5 Jan 2013 03:21:45 -0800 Subject: [PATCH 174/180] No bug, Automated blocklist update from host bld-linux64-ec2-684 - a=blocklist-update --- browser/app/blocklist.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/browser/app/blocklist.xml b/browser/app/blocklist.xml index 65a8cd36caad..e4321ecf1fee 100644 --- a/browser/app/blocklist.xml +++ b/browser/app/blocklist.xml @@ -1,5 +1,5 @@ - + @@ -379,7 +379,7 @@ - + @@ -576,14 +576,14 @@ - + - + From d714fbe57a95ad88a684e1033f945f8251272beb Mon Sep 17 00:00:00 2001 From: Serge Gautherie Date: Sat, 5 Jan 2013 20:27:12 +0800 Subject: [PATCH 175/180] Bug 747668. (Iv2a) XPFE autocomplete.xml: Implement (nsIAutoCompleteInput) searchCount and getSearchAt(), Nits. r=Neil. DONTBUILD (npotb). --- .../resources/content/autocomplete.xml | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/xpfe/components/autocomplete/resources/content/autocomplete.xml b/xpfe/components/autocomplete/resources/content/autocomplete.xml index 15103a67aba3..133b741eb7c8 100644 --- a/xpfe/components/autocomplete/resources/content/autocomplete.xml +++ b/xpfe/components/autocomplete/resources/content/autocomplete.xml @@ -151,6 +151,21 @@ onget="return this.getAttribute('autocompletesearchparam') || '';" onset="this.setAttribute('autocompletesearchparam', val); return val;"/> + + + + + + + @@ -556,12 +571,11 @@ @@ -580,7 +594,7 @@ Date: Sat, 5 Jan 2013 15:53:16 +0100 Subject: [PATCH 176/180] Gecko work for bug 823619: Dispatch spec-compliant mouse events when touch events are available. r=cjones,jlebar,schien,vingtetun a=blocking-basecamp This is a rollowup of the following patches Bug 823619, part 1: Make TabChild dispatch spec-compliant compat mouse events. r=mwu Bug 823619, part 2: Use touch event for scrolling if available. r=cjones,schien,vingtetun a=blocking-basecamp --- b2g/app/b2g.js | 4 + .../BrowserElementScrolling.js | 208 ++++++++++++++++-- dom/ipc/TabChild.cpp | 162 +++++++++++--- dom/ipc/TabChild.h | 23 +- gfx/layers/ipc/AsyncPanZoomController.cpp | 38 +++- gfx/layers/ipc/AsyncPanZoomController.h | 14 +- layout/ipc/PRenderFrame.ipdl | 1 + layout/ipc/RenderFrameChild.cpp | 6 + layout/ipc/RenderFrameChild.h | 1 + layout/ipc/RenderFrameParent.cpp | 9 + layout/ipc/RenderFrameParent.h | 1 + modules/libpref/src/init/all.js | 5 + 12 files changed, 419 insertions(+), 53 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index f5cc8833bdd8..22f2fcccbfc4 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -283,10 +283,14 @@ pref("content.image.allow_locking", true); pref("image.mem.min_discard_timeout_ms", 10000); pref("image.mem.max_decoded_image_kb", 5120); /* 5MB */ +// XXX this isn't a good check for "are touch events supported", but +// we don't really have a better one at the moment. +#ifdef MOZ_WIDGET_GONK // enable touch events interfaces pref("dom.w3c_touch_events.enabled", 1); pref("dom.w3c_touch_events.safetyX", 0); // escape borders in units of 1/240" pref("dom.w3c_touch_events.safetyY", 120); // escape borders in units of 1/240" +#endif #ifdef MOZ_SAFE_BROWSING // Safe browsing does nothing unless this pref is set diff --git a/dom/browser-element/BrowserElementScrolling.js b/dom/browser-element/BrowserElementScrolling.js index 8f73accadcda..84ee9c166505 100644 --- a/dom/browser-element/BrowserElementScrolling.js +++ b/dom/browser-element/BrowserElementScrolling.js @@ -6,8 +6,35 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ const ContentPanning = { + // Are we listening to touch or mouse events? + watchedEventsType: '', + + // Are mouse events being delivered to this content along with touch + // events, in violation of spec? + hybridEvents: false, + init: function cp_init() { - ['mousedown', 'mouseup', 'mousemove'].forEach(function(type) { + var events; + try { + content.document.createEvent('TouchEvent'); + events = ['touchstart', 'touchend', 'touchmove']; + this.watchedEventsType = 'touch'; +#ifdef MOZ_WIDGET_GONK + // The gonk widget backend does not deliver mouse events per + // spec. Third-party content isn't exposed to this behavior, + // but that behavior creates some extra work for us here. + let appInfo = Cc["@mozilla.org/xre/app-info;1"]; + let isParentProcess = + !appInfo || appInfo.getService(Ci.nsIXULRuntime) + .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; + this.hybridEvents = isParentProcess; +#endif + } catch(e) { + // Touch events aren't supported, so fall back on mouse. + events = ['mousedown', 'mouseup', 'mousemove']; + this.watchedEventsType = 'mouse'; + } + events.forEach(function(type) { addEventListener(type, ContentPanning, false); }); @@ -16,14 +43,20 @@ const ContentPanning = { }, handleEvent: function cp_handleEvent(evt) { + if (evt.defaultPrevented) + return; + switch (evt.type) { case 'mousedown': + case 'touchstart': this.onTouchStart(evt); break; case 'mousemove': + case 'touchmove': this.onTouchMove(evt); break; case 'mouseup': + case 'touchend': this.onTouchEnd(evt); break; case 'click': @@ -40,21 +73,68 @@ const ContentPanning = { position: new Point(0 , 0), + findPrimaryPointer: function cp_findPrimaryPointer(touches) { + if (!('primaryPointerId' in this)) + return null; + + for (let i = 0; i < touches.length; i++) { + if (touches[i].identifier === this.primaryPointerId) { + return touches[i]; + } + } + return null; + }, + onTouchStart: function cp_onTouchStart(evt) { + let screenX, screenY; + if (this.watchedEventsType == 'touch') { + if ('primaryPointerId' in this) { + return; + } + + let firstTouch = evt.changedTouches[0]; + this.primaryPointerId = firstTouch.identifier; + this.pointerDownTarget = firstTouch.target; + screenX = firstTouch.screenX; + screenY = firstTouch.screenY; + } else { + this.pointerDownTarget = evt.target; + screenX = evt.screenX; + screenY = evt.screenY; + } this.dragging = true; this.panning = false; let oldTarget = this.target; - [this.target, this.scrollCallback] = this.getPannable(evt.target); + [this.target, this.scrollCallback] = this.getPannable(this.pointerDownTarget); // If we found a target, that means we have found a scrollable subframe. In // this case, and if we are using async panning and zooming on the parent // frame, inform the pan/zoom controller that it should not attempt to // handle any touch events it gets until the next batch (meaning the next // time we get a touch end). - if (this.target != null && ContentPanning._asyncPanZoomForViewportFrame) { + if (this.target != null && this._asyncPanZoomForViewportFrame) { + this.detectingScrolling = true; var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); - os.notifyObservers(docShell, 'cancel-default-pan-zoom', null); + os.notifyObservers(docShell, 'detect-scrollable-subframe', null); + } + + // If we have a pointer down target and we're not async + // pan/zooming, we may need to fill in for EventStateManager in + // setting the active state on the target element. Set a timer to + // ensure the pointer-down target is active. (If it's already + // active, the timer is a no-op.) + if (this.pointerDownTarget !== null && !this.detectingScrolling) { + // If there's no possibility this is a drag/pan, activate now. + // Otherwise wait a little bit to see if the gesture isn't a + // tap. + if (this.target === null) { + this.notify(this._activationTimer); + } else { + this._activationTimer.initWithCallback(this, + this._activationDelayMs, + Ci.nsITimer.TYPE_ONE_SHOT); + } } // If there is a pan animation running (from a previous pan gesture) and @@ -69,19 +149,38 @@ const ContentPanning = { this.preventNextClick = true; } - - this.position.set(evt.screenX, evt.screenY); + this.position.set(screenX, screenY); KineticPanning.record(new Point(0, 0), evt.timeStamp); }, onTouchEnd: function cp_onTouchEnd(evt) { - if (!this.dragging) + let touch = null; + if (!this.dragging || + (this.watchedEventsType == 'touch' && + !(touch = this.findPrimaryPointer(evt.changedTouches)))) { return; - this.dragging = false; + } - this.onTouchMove(evt); + // !isPan() and evt.detail should always give the same answer here + // since they use the same heuristics, but use the native gecko + // computation when possible. + // + // NB: when we're using touch events, then !KineticPanning.isPan() + // => this.panning, so we'll never attempt to block the click + // event. That's OK however, because we won't fire a synthetic + // click when we're using touch events and this touch series + // wasn't a "tap" gesture. + let click = (this.watchedEventsType == 'mouse') ? + evt.detail : !KineticPanning.isPan(); + // Additionally, if we're seeing non-compliant hybrid events, a + // "real" click will be generated if we started and ended on the + // same element. + if (this.hybridEvents) { + let target = + content.document.elementFromPoint(touch.clientX, touch.clientY); + click |= (target === this.pointerDownTarget); + } - let click = evt.detail; if (this.target && click && (this.panning || this.preventNextClick)) { let target = this.target; let view = target.ownerDocument ? target.ownerDocument.defaultView @@ -89,31 +188,84 @@ const ContentPanning = { view.addEventListener('click', this, true, true); } - if (this.panning) + this._resetActive(); + this.dragging = false; + this.detectingScrolling = false; + delete this.primaryPointerId; + this._activationTimer.cancel(); + + if (this.panning) { KineticPanning.start(this); + } }, + // True when there's an async pan-zoom controll watching the + // outermost scrollable frame, and we're waiting to see whether + // we're going to take over from it and synchronously scroll an + // inner scrollable frame. + detectingScrolling: false, + onTouchMove: function cp_onTouchMove(evt) { - if (!this.dragging || !this.scrollCallback) + if (!this.dragging) return; + let screenX, screenY; + if (this.watchedEventsType == 'touch') { + let primaryTouch = this.findPrimaryPointer(evt.changedTouches); + if (evt.touches.length > 1 || !primaryTouch) + return; + screenX = primaryTouch.screenX; + screenY = primaryTouch.screenY; + } else { + screenX = evt.screenX; + screenY = evt.screenY; + } + let current = this.position; - let delta = new Point(evt.screenX - current.x, evt.screenY - current.y); - current.set(evt.screenX, evt.screenY); + let delta = new Point(screenX - current.x, screenY - current.y); + current.set(screenX, screenY); KineticPanning.record(delta, evt.timeStamp); + + // There's no possibility of us panning anything. + if (!this.scrollCallback) { + return; + } + + let isPan = KineticPanning.isPan(); + if (this.detectingScrolling) { + this.detectingScrolling = false; + // Stop async-pan-zooming if the user is panning the subframe. + if (isPan) { + // We're going to drive synchronously scrolling an inner frame. + Services.obs.notifyObservers(docShell, 'cancel-default-pan-zoom', null); + } else { + // Let AsyncPanZoomController handle the scrolling gesture. + this.scrollCallback = null; + return; + } + } + this.scrollCallback(delta.scale(-1)); // If a pan action happens, cancel the active state of the // current target. - if (!this.panning && KineticPanning.isPan()) { + if (!this.panning && isPan) { this.panning = true; this._resetActive(); + this._activationTimer.cancel(); + } + + if (this.panning) { + evt.stopPropagation(); + evt.preventDefault(); } - evt.stopPropagation(); - evt.preventDefault(); }, + // nsITimerCallback + notify: function cp_notify(timer) { + this._setActive(this.pointerDownTarget); + }, onKineticBegin: function cp_onKineticBegin(evt) { }, @@ -249,11 +401,27 @@ const ContentPanning = { .getService(Ci.inIDOMUtils); }, - _resetActive: function cp_resetActive() { - let root = this.target.ownerDocument || this.target.document; + get _activationTimer() { + delete this._activationTimer; + return this._activationTimer = Cc["@mozilla.org/timer;1"] + .createInstance(Ci.nsITimer); + }, + get _activationDelayMs() { + let delay = Services.prefs.getIntPref('ui.touch_activation.delay_ms'); + delete this._activationDelayMs; + return this._activationDelayMs = delay; + }, + + _resetActive: function cp_resetActive() { + let elt = this.target || this.pointerDownTarget; + let root = elt.ownerDocument || elt.document; + this._setActive(root.documentElement); + }, + + _setActive: function cp_setActive(elt) { const kStateActive = 0x00000001; - this._domUtils.setContentState(root.documentElement, kStateActive); + this._domUtils.setContentState(elt, kStateActive); }, get _asyncPanZoomForViewportFrame() { diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index cd0f14e8cb94..3aa899aa6249 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -97,6 +97,7 @@ static const nsIntSize kDefaultViewportSize(980, 480); static const char CANCEL_DEFAULT_PAN_ZOOM[] = "cancel-default-pan-zoom"; static const char BROWSER_ZOOM_TO_RECT[] = "browser-zoom-to-rect"; static const char BEFORE_FIRST_PAINT[] = "before-first-paint"; +static const char DETECT_SCROLLABLE_SUBFRAME[] = "detect-scrollable-subframe"; NS_IMETHODIMP ContentListener::HandleEvent(nsIDOMEvent* aEvent) @@ -162,6 +163,8 @@ TabChild::TabChild(const TabContext& aContext, uint32_t aChromeFlags) , mChromeFlags(aChromeFlags) , mOuterRect(0, 0, 0, 0) , mInnerSize(0, 0) + , mActivePointerId(-1) + , mTapHoldTimer(nullptr) , mOldViewportWidth(0.0f) , mLastBackgroundColor(NS_RGB(255, 255, 255)) , mDidFakeShow(false) @@ -243,6 +246,12 @@ TabChild::Observe(nsISupports *aSubject, HandlePossibleViewportChange(); } } + } else if (!strcmp(aTopic, DETECT_SCROLLABLE_SUBFRAME)) { + nsCOMPtr docShell(do_QueryInterface(aSubject)); + nsCOMPtr tabChild(GetTabChildFrom(docShell)); + if (tabChild == this) { + mRemoteFrame->DetectScrollableSubframe(); + } } return NS_OK; @@ -1349,42 +1358,135 @@ TabChild::RecvMouseWheelEvent(const WheelEvent& event) } void -TabChild::DispatchSynthesizedMouseEvent(const nsTouchEvent& aEvent) +TabChild::DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime, + const nsIntPoint& aRefPoint) { - // Synthesize a phony mouse event. - uint32_t msg; - switch (aEvent.message) { - case NS_TOUCH_START: - msg = NS_MOUSE_BUTTON_DOWN; - break; - case NS_TOUCH_MOVE: - msg = NS_MOUSE_MOVE; - break; - case NS_TOUCH_END: - case NS_TOUCH_CANCEL: - msg = NS_MOUSE_BUTTON_UP; - break; - default: - MOZ_NOT_REACHED("Unknown touch event message"); - } + MOZ_ASSERT(aMsg == NS_MOUSE_MOVE || aMsg == NS_MOUSE_BUTTON_DOWN || + aMsg == NS_MOUSE_BUTTON_UP); - nsIntPoint refPoint(0, 0); - if (aEvent.touches.Length()) { - refPoint = aEvent.touches[0]->mRefPoint; - } - - nsMouseEvent event(true, msg, NULL, + nsMouseEvent event(true, aMsg, NULL, nsMouseEvent::eReal, nsMouseEvent::eNormal); - event.refPoint = refPoint; - event.time = aEvent.time; + event.refPoint = aRefPoint; + event.time = aTime; event.button = nsMouseEvent::eLeftButton; - if (msg != NS_MOUSE_MOVE) { + if (aMsg != NS_MOUSE_MOVE) { event.clickCount = 1; } DispatchWidgetEvent(event); } +static nsDOMTouch* +GetTouchForIdentifier(const nsTouchEvent& aEvent, int32_t aId) +{ + for (uint32_t i = 0; i < aEvent.touches.Length(); ++i) { + nsDOMTouch* touch = static_cast(aEvent.touches[i].get()); + if (touch->mIdentifier == aId) { + return touch; + } + } + return nullptr; +} + +void +TabChild::UpdateTapState(const nsTouchEvent& aEvent, nsEventStatus aStatus) +{ + static bool sHavePrefs; + static bool sClickHoldContextMenusEnabled; + static nsIntSize sDragThreshold; + static int32_t sContextMenuDelayMs; + if (!sHavePrefs) { + sHavePrefs = true; + Preferences::AddBoolVarCache(&sClickHoldContextMenusEnabled, + "ui.click_hold_context_menus", true); + Preferences::AddIntVarCache(&sDragThreshold.width, + "ui.dragThresholdX", 25); + Preferences::AddIntVarCache(&sDragThreshold.height, + "ui.dragThresholdY", 25); + Preferences::AddIntVarCache(&sContextMenuDelayMs, + "ui.click_hold_context_menus.delay", 500); + } + + bool currentlyTrackingTouch = (mActivePointerId >= 0); + if (aEvent.message == NS_TOUCH_START) { + if (currentlyTrackingTouch || aEvent.touches.Length() > 1) { + // We're tracking a possible tap for another point, or we saw a + // touchstart for a later pointer after we canceled tracking of + // the first point. Ignore this one. + return; + } + if (aStatus == nsEventStatus_eConsumeNoDefault || + nsIPresShell::gPreventMouseEvents) { + return; + } + + nsDOMTouch* touch = static_cast(aEvent.touches[0].get()); + mGestureDownPoint = touch->mRefPoint; + mActivePointerId = touch->mIdentifier; + if (sClickHoldContextMenusEnabled) { + MOZ_ASSERT(!mTapHoldTimer); + mTapHoldTimer = NewRunnableMethod(this, + &TabChild::FireContextMenuEvent); + MessageLoop::current()->PostDelayedTask(FROM_HERE, mTapHoldTimer, + sContextMenuDelayMs); + } + return; + } + + // If we're not tracking a touch or this event doesn't include the + // one we care about, bail. + if (!currentlyTrackingTouch) { + return; + } + nsDOMTouch* trackedTouch = GetTouchForIdentifier(aEvent, mActivePointerId); + if (!trackedTouch) { + return; + } + + nsIntPoint currentPoint = trackedTouch->mRefPoint; + int64_t time = aEvent.time; + switch (aEvent.message) { + case NS_TOUCH_MOVE: + if (abs(currentPoint.x - mGestureDownPoint.x) > sDragThreshold.width || + abs(currentPoint.y - mGestureDownPoint.y) > sDragThreshold.height) { + CancelTapTracking(); + } + return; + + case NS_TOUCH_END: + if (!nsIPresShell::gPreventMouseEvents) { + DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint); + DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint); + DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_UP, time, currentPoint); + } + // fall through + case NS_TOUCH_CANCEL: + CancelTapTracking(); + return; + + default: + NS_WARNING("Unknown touch event type"); + } +} + +void +TabChild::FireContextMenuEvent() +{ + MOZ_ASSERT(mTapHoldTimer && mActivePointerId >= 0); + RecvHandleLongTap(mGestureDownPoint); + CancelTapTracking(); +} + +void +TabChild::CancelTapTracking() +{ + mActivePointerId = -1; + if (mTapHoldTimer) { + mTapHoldTimer->Cancel(); + } + mTapHoldTimer = nullptr; +} + bool TabChild::RecvRealTouchEvent(const nsTouchEvent& aEvent) { @@ -1398,8 +1500,8 @@ TabChild::RecvRealTouchEvent(const nsTouchEvent& aEvent) if (innerWindow && innerWindow->HasTouchEventListeners()) { SendContentReceivedTouch(nsIPresShell::gPreventMouseEvents); } - } else if (status != nsEventStatus_eConsumeNoDefault) { - DispatchSynthesizedMouseEvent(aEvent); + } else { + UpdateTapState(aEvent, status); } return true; @@ -1680,6 +1782,7 @@ TabChild::RecvDestroy() observerService->RemoveObserver(this, CANCEL_DEFAULT_PAN_ZOOM); observerService->RemoveObserver(this, BROWSER_ZOOM_TO_RECT); observerService->RemoveObserver(this, BEFORE_FIRST_PAINT); + observerService->RemoveObserver(this, DETECT_SCROLLABLE_SUBFRAME); const InfallibleTArray& idbActors = ManagedPIndexedDBChild(); @@ -1815,6 +1918,9 @@ TabChild::InitRenderingState() observerService->AddObserver(this, BEFORE_FIRST_PAINT, false); + observerService->AddObserver(this, + DETECT_SCROLLABLE_SUBFRAME, + false); } return true; diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index e565c1f1ceb8..07701437fa68 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -384,8 +384,18 @@ private: void DispatchMessageManagerMessage(const nsAString& aMessageName, const nsACString& aJSONData); - // Sends a simulated mouse event from a touch event for compatibility. - void DispatchSynthesizedMouseEvent(const nsTouchEvent& aEvent); + void DispatchSynthesizedMouseEvent(uint32_t aMsg, uint64_t aTime, + const nsIntPoint& aRefPoint); + + // These methods are used for tracking synthetic mouse events + // dispatched for compatibility. On each touch event, we + // UpdateTapState(). If we've detected that the current gesture + // isn't a tap, then we CancelTapTracking(). In the meantime, we + // may detect a context-menu event, and if so we + // FireContextMenuEvent(). + void FireContextMenuEvent(); + void CancelTapTracking(); + void UpdateTapState(const nsTouchEvent& aEvent, nsEventStatus aStatus); nsresult BrowserFrameProvideWindow(nsIDOMWindow* aOpener, @@ -411,6 +421,15 @@ private: uint32_t mChromeFlags; nsIntRect mOuterRect; nsIntSize mInnerSize; + // When we're tracking a possible tap gesture, this is the "down" + // point of the touchstart. + nsIntPoint mGestureDownPoint; + // The touch identifier of the active gesture. + int32_t mActivePointerId; + // A timer task that fires if the tap-hold timeout is exceeded by + // the touch we're tracking. That is, if touchend or a touchmove + // that exceeds the gesture threshold doesn't happen. + CancelableTask* mTapHoldTimer; float mOldViewportWidth; nscolor mLastBackgroundColor; ScrollingBehavior mScrolling; diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 80551630499c..1df1192b5d1d 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -247,6 +247,26 @@ nsEventStatus AsyncPanZoomController::HandleInputEvent(const InputData& aEvent) return rv; } + if (mDelayPanning && aEvent.mInputType == MULTITOUCH_INPUT) { + const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); + if (multiTouchInput.mType == MultiTouchInput::MULTITOUCH_MOVE) { + // Let BrowserElementScrolling perform panning gesture first. + SetState(WAITING_LISTENERS); + mTouchQueue.AppendElement(multiTouchInput); + + if (!mTouchListenerTimeoutTask) { + mTouchListenerTimeoutTask = + NewRunnableMethod(this, &AsyncPanZoomController::TimeoutTouchListeners); + + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + mTouchListenerTimeoutTask, + TOUCH_LISTENER_TIMEOUT); + } + return nsEventStatus_eConsumeNoDefault; + } + } + switch (aEvent.mInputType) { case MULTITOUCH_INPUT: { const MultiTouchInput& multiTouchInput = aEvent.AsMultiTouchInput(); @@ -1130,6 +1150,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFr mLastContentPaintMetrics = aViewportFrame; + mFrameMetrics.mMayHaveTouchListeners = aViewportFrame.mMayHaveTouchListeners; if (mWaitingForContentToPaint) { // Remove the oldest sample we have if adding a new sample takes us over our // desired number of samples. @@ -1223,6 +1244,10 @@ void AsyncPanZoomController::CancelDefaultPanZoom() { } } +void AsyncPanZoomController::DetectScrollableSubframe() { + mDelayPanning = true; +} + void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) { gfx::Rect zoomToRect(gfx::Rect(aRect.x, aRect.y, aRect.width, aRect.height)); @@ -1309,7 +1334,7 @@ void AsyncPanZoomController::ZoomToRect(const gfxRect& aRect) { } void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) { - if (!mFrameMetrics.mMayHaveTouchListeners) { + if (!mFrameMetrics.mMayHaveTouchListeners && !mDelayPanning) { mTouchQueue.Clear(); return; } @@ -1321,12 +1346,21 @@ void AsyncPanZoomController::ContentReceivedTouch(bool aPreventDefault) { if (mState == WAITING_LISTENERS) { if (!aPreventDefault) { - SetState(NOTHING); + // Delayed scrolling gesture is pending at TOUCHING state. + if (mDelayPanning) { + SetState(TOUCHING); + } else { + SetState(NOTHING); + } } mHandlingTouchQueue = true; while (!mTouchQueue.IsEmpty()) { + // we need to reset mDelayPanning before handling scrolling gesture. + if (mTouchQueue[0].mType == MultiTouchInput::MULTITOUCH_MOVE) { + mDelayPanning = false; + } if (!aPreventDefault) { HandleInputEvent(mTouchQueue[0]); } diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h index 4c7eb05a8401..3363d0709629 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.h +++ b/gfx/layers/ipc/AsyncPanZoomController.h @@ -109,7 +109,7 @@ public: void UpdateCompositionBounds(const nsIntRect& aCompositionBounds); /** - * We have found a scrollable subframe, so disable our machinery until we hit + * We are scrolling a subframe, so disable our machinery until we hit * a touch end or a new touch start. This prevents us from accidentally * panning both the subframe and the parent frame. * @@ -118,6 +118,12 @@ public: */ void CancelDefaultPanZoom(); + /** + * We have found a scrollable subframe, so we need to delay the scrolling + * gesture executed and let subframe do the scrolling first. + */ + void DetectScrollableSubframe(); + /** * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom * in. The actual animation is done on the compositor thread after being set @@ -585,6 +591,12 @@ private: // and we don't want to queue the events back up again. bool mHandlingTouchQueue; + // Flag used to determine whether or not we should try scrolling by + // BrowserElementScrolling first. If set, we delay delivering + // touchmove events to GestureListener until BrowserElementScrolling + // decides whether it wants to handle panning for this touch series. + bool mDelayPanning; + friend class Axis; }; diff --git a/layout/ipc/PRenderFrame.ipdl b/layout/ipc/PRenderFrame.ipdl index 0a30fc838748..dd5a17eb75ab 100644 --- a/layout/ipc/PRenderFrame.ipdl +++ b/layout/ipc/PRenderFrame.ipdl @@ -42,6 +42,7 @@ parent: async NotifyCompositorTransaction(); async CancelDefaultPanZoom(); + async DetectScrollableSubframe(); async __delete__(); diff --git a/layout/ipc/RenderFrameChild.cpp b/layout/ipc/RenderFrameChild.cpp index a2af75b60272..93cd0a626e4e 100644 --- a/layout/ipc/RenderFrameChild.cpp +++ b/layout/ipc/RenderFrameChild.cpp @@ -38,6 +38,12 @@ RenderFrameChild::CancelDefaultPanZoom() SendCancelDefaultPanZoom(); } +void +RenderFrameChild::DetectScrollableSubframe() +{ + SendDetectScrollableSubframe(); +} + PLayersChild* RenderFrameChild::AllocPLayers() { diff --git a/layout/ipc/RenderFrameChild.h b/layout/ipc/RenderFrameChild.h index 44f38b175fa5..832c4e1fe7d3 100644 --- a/layout/ipc/RenderFrameChild.h +++ b/layout/ipc/RenderFrameChild.h @@ -20,6 +20,7 @@ public: virtual ~RenderFrameChild() {} void CancelDefaultPanZoom(); + void DetectScrollableSubframe(); void Destroy(); diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 8957d9e9973f..305e7308aec5 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -829,6 +829,15 @@ RenderFrameParent::RecvCancelDefaultPanZoom() return true; } +bool +RenderFrameParent::RecvDetectScrollableSubframe() +{ + if (mPanZoomController) { + mPanZoomController->DetectScrollableSubframe(); + } + return true; +} + PLayersParent* RenderFrameParent::AllocPLayers() { diff --git a/layout/ipc/RenderFrameParent.h b/layout/ipc/RenderFrameParent.h index dd13148f047e..8848e9b8dfea 100644 --- a/layout/ipc/RenderFrameParent.h +++ b/layout/ipc/RenderFrameParent.h @@ -109,6 +109,7 @@ protected: virtual bool RecvNotifyCompositorTransaction() MOZ_OVERRIDE; virtual bool RecvCancelDefaultPanZoom() MOZ_OVERRIDE; + virtual bool RecvDetectScrollableSubframe() MOZ_OVERRIDE; virtual PLayersParent* AllocPLayers() MOZ_OVERRIDE; virtual bool DeallocPLayers(PLayersParent* aLayers) MOZ_OVERRIDE; diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 97d42cb998ca..e3d93edaf062 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3927,3 +3927,8 @@ pref("dom.placeholder.show_on_focus", true); pref("wap.UAProf.url", ""); pref("wap.UAProf.tagname", "x-wap-profile"); +// If the user puts a finger down on an element and we think the user +// might be executing a pan gesture, how long do we wait before +// tentatively deciding the gesture is actually a tap and activating +// the target element? +pref("ui.touch_activation.delay_ms", 50); From 62132fce09a9352524cef73850266ec797ec28aa Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Sat, 5 Jan 2013 11:16:06 -0800 Subject: [PATCH 177/180] Bug 827020 - Add null check to nsXULPrototypeDocument::TraceProtos. r=smaug --- content/xul/document/src/nsXULPrototypeDocument.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/content/xul/document/src/nsXULPrototypeDocument.cpp b/content/xul/document/src/nsXULPrototypeDocument.cpp index 6922dacafc59..5037b67951b3 100644 --- a/content/xul/document/src/nsXULPrototypeDocument.cpp +++ b/content/xul/document/src/nsXULPrototypeDocument.cpp @@ -688,7 +688,9 @@ nsXULPrototypeDocument::TraceProtos(JSTracer* aTrc, uint32_t aGCNumber) } mGCNumber = aGCNumber; - mRoot->TraceAllScripts(aTrc); + if (mRoot) { + mRoot->TraceAllScripts(aTrc); + } } //---------------------------------------------------------------------- From 0d58c29acf2ff794494a0f44e92b87bb7326149a Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Sat, 5 Jan 2013 20:45:06 +0100 Subject: [PATCH 178/180] Fix bustage from bug 824907 on a CLOSED TREE. --HG-- extra : rebase_source : 0b74574fdaf08be7428aa46de1e0f8c213131e11 --- content/html/content/src/HTMLTableElement.h | 2 +- content/html/content/src/HTMLTableRowElement.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/html/content/src/HTMLTableElement.h b/content/html/content/src/HTMLTableElement.h index 092a908e51d3..2a0550a57fcb 100644 --- a/content/html/content/src/HTMLTableElement.h +++ b/content/html/content/src/HTMLTableElement.h @@ -25,7 +25,7 @@ public: HTMLTableElement(already_AddRefed aNodeInfo); virtual ~HTMLTableElement(); - NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableElement, nsGkAtoms::table) + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableElement, table) // nsISupports NS_DECL_ISUPPORTS_INHERITED diff --git a/content/html/content/src/HTMLTableRowElement.h b/content/html/content/src/HTMLTableRowElement.h index fd1fec1db920..4b652b1d586d 100644 --- a/content/html/content/src/HTMLTableRowElement.h +++ b/content/html/content/src/HTMLTableRowElement.h @@ -24,7 +24,7 @@ public: SetIsDOMBinding(); } - NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableRowElement, nsGkAtoms::tr) + NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLTableRowElement, tr) // nsISupports NS_DECL_ISUPPORTS_INHERITED From 58efdf22ec893cdb4f45605a9c4de2ffa4b1d5c0 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Sat, 5 Jan 2013 11:52:53 -0800 Subject: [PATCH 179/180] (no bug) Clarify comment in ConstructFieldSetFrame (and fix typo s/list frame/fieldset frame/). comment-only, DONTBUILD --- layout/base/nsCSSFrameConstructor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 9357e37fd7c7..cb7829a7b873 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3149,7 +3149,7 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState, newFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT); - // our new frame returned is the top frame which is the list frame. + // Our new frame returned is the outer frame, which is the fieldset frame. *aNewFrame = newFrame; return NS_OK; From 4a4870b37292f6dde720aaf2705c90ea2e62ca28 Mon Sep 17 00:00:00 2001 From: Alfred Kayser Date: Sun, 6 Jan 2013 14:51:12 +0100 Subject: [PATCH 180/180] bug 814010: diskcache: skip buffer when writing to file. r=michal.novotny --- netwerk/cache/nsDiskCacheStreams.cpp | 356 ++++++++------------------- netwerk/cache/nsDiskCacheStreams.h | 16 +- 2 files changed, 103 insertions(+), 269 deletions(-) diff --git a/netwerk/cache/nsDiskCacheStreams.cpp b/netwerk/cache/nsDiskCacheStreams.cpp index 3dda142e01c0..e94c393c89c0 100644 --- a/netwerk/cache/nsDiskCacheStreams.cpp +++ b/netwerk/cache/nsDiskCacheStreams.cpp @@ -16,6 +16,10 @@ #include "mozilla/TimeStamp.h" +// we pick 16k as the max buffer size because that is the threshold above which +// we are unable to store the data in the cache block files +// see nsDiskCacheMap.[cpp,h] +#define kMaxBufferSize (16 * 1024) // Assumptions: // - cache descriptors live for life of streams @@ -290,22 +294,13 @@ nsDiskCacheOutputStream::IsNonBlocking(bool * nonBlocking) *****************************************************************************/ NS_IMPL_THREADSAFE_ISUPPORTS0(nsDiskCacheStreamIO) -// we pick 16k as the max buffer size because that is the threshold above which -// we are unable to store the data in the cache block files -// see nsDiskCacheMap.[cpp,h] -#define kMaxBufferSize (16 * 1024) - nsDiskCacheStreamIO::nsDiskCacheStreamIO(nsDiskCacheBinding * binding) : mBinding(binding) , mOutStream(nullptr) , mInStreamCount(0) , mFD(nullptr) - , mStreamPos(0) , mStreamEnd(0) - , mBufPos(0) - , mBufEnd(0) , mBufSize(0) - , mBufDirty(false) , mBuffer(nullptr) { mDevice = (nsDiskCacheDevice *)mBinding->mCacheEntry->CacheDevice(); @@ -372,7 +367,7 @@ nsDiskCacheStreamIO::GetInputStream(uint32_t offset, nsIInputStream ** inputStre } else if (!mBuffer) { // read block file for data - rv = ReadCacheBlocks(); + rv = ReadCacheBlocks(mStreamEnd); if (NS_FAILED(rv)) return rv; } // else, mBuffer already contains all of the data (left over from a @@ -402,18 +397,10 @@ nsDiskCacheStreamIO::GetOutputStream(uint32_t offset, nsIOutputStream ** outputS NS_ASSERTION(mInStreamCount == 0, "we already have input streams open"); if (mOutStream || mInStreamCount) return NS_ERROR_NOT_AVAILABLE; - // mBuffer lazily allocated, but might exist if a previous stream already - // created one. - mBufPos = 0; - mStreamPos = 0; mStreamEnd = mBinding->mCacheEntry->DataSize(); - nsresult rv; - if (offset) { - rv = Seek(PR_SEEK_SET, offset); - if (NS_FAILED(rv)) return rv; - } - rv = SetEOF(); + // Inits file or buffer and truncate at the desired offset + nsresult rv = SeekAndTruncate(offset); if (NS_FAILED(rv)) return rv; // create a new output stream @@ -439,8 +426,6 @@ nsDiskCacheStreamIO::CloseOutputStream(nsDiskCacheOutputStream * outputStream) { nsCacheServiceAutoLock lock(LOCK_TELEM(NSDISKCACHESTREAMIO_CLOSEOUTPUTSTREAM)); // grab service lock - nsresult rv; - if (outputStream != mOutStream) { NS_WARNING("mismatched output streams"); return NS_ERROR_UNEXPECTED; @@ -448,13 +433,12 @@ nsDiskCacheStreamIO::CloseOutputStream(nsDiskCacheOutputStream * outputStream) // output stream is closing if (!mBinding) { // if we're severed, just clear member variables - NS_ASSERTION(!mBufDirty, "oops"); mOutStream = nullptr; outputStream->ReleaseStreamIO(); return NS_ERROR_NOT_AVAILABLE; } - rv = Flush(); + nsresult rv = Flush(); if (NS_FAILED(rv)) NS_WARNING("Flush() failed"); @@ -470,11 +454,10 @@ nsDiskCacheStreamIO::Flush() CACHE_LOG_DEBUG(("CACHE: Flush [%x doomed=%u]\n", mBinding->mRecord.HashNumber(), mBinding->mDoomed)); - if (!mBufDirty) { - if (mFD) { - (void) PR_Close(mFD); - mFD = nullptr; - } + // When writing to a file, just close the file + if (mFD) { + (void) PR_Close(mFD); + mFD = nullptr; return NS_OK; } @@ -487,8 +470,6 @@ nsDiskCacheStreamIO::Flush() if (mStreamEnd <= kMaxBufferSize) { // store data (if any) in cache block files - mBufDirty = false; - // delete existing storage nsDiskCacheRecord * record = &mBinding->mRecord; if (record->DataLocationInitialized()) { @@ -497,16 +478,12 @@ nsDiskCacheStreamIO::Flush() NS_WARNING("cacheMap->DeleteStorage() failed."); return rv; } - if (mFD) { - PR_Close(mFD); - mFD = nullptr; - } } // flush buffer to block files written = true; if (mStreamEnd > 0) { - rv = cacheMap->WriteDataCacheBlocks(mBinding, mBuffer, mBufEnd); + rv = cacheMap->WriteDataCacheBlocks(mBinding, mBuffer, mStreamEnd); if (NS_FAILED(rv)) { NS_WARNING("WriteDataCacheBlocks() failed."); written = false; @@ -515,7 +492,7 @@ nsDiskCacheStreamIO::Flush() } if (!written) { - // make sure we save as separate file + // failed to store in cacheblocks, save as separate file rv = FlushBufferToFile(); // initializes DataFileLocation() if necessary if (mFD) { @@ -532,13 +509,6 @@ nsDiskCacheStreamIO::Flush() // close mFD first if possible before returning if FlushBufferToFile // failed NS_ENSURE_SUCCESS(rv, rv); - - // since the data location is on disk as a single file, the only value - // in keeping mBuffer around is to avoid an extra malloc the next time - // we need to write to this file. reading will use a file descriptor. - // therefore, it's probably not worth optimizing for the subsequent - // write, so we unconditionally delete mBuffer here. - DeleteBuffer(); } // XXX do we need this here? WriteDataCacheBlocks() calls UpdateRecord() @@ -565,8 +535,8 @@ nsDiskCacheStreamIO::Write( const char * buffer, uint32_t count, uint32_t * bytesWritten) { - nsresult rv = NS_OK; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSDISKCACHESTREAMIO_WRITE)); // grab service lock + // grab service lock + nsCacheServiceAutoLock lock(LOCK_TELEM(NSDISKCACHESTREAMIO_WRITE)); if (!mBinding) return NS_ERROR_NOT_AVAILABLE; if (mInStreamCount) { @@ -577,62 +547,53 @@ nsDiskCacheStreamIO::Write( const char * buffer, } NS_ASSERTION(count, "Write called with count of zero"); - NS_ASSERTION(mBufPos <= mBufEnd, "streamIO buffer corrupted"); - uint32_t bytesLeft = count; - bool flushed = false; - - while (bytesLeft) { - if (mBufPos == mBufSize) { - if (mBufSize < kMaxBufferSize) { + // Not writing to file, and it will fit in the cachedatablocks? + if (!mFD && (mStreamEnd + count <= kMaxBufferSize)) { + + // We have more data than the current buffer size? + if ((mStreamEnd + count > mBufSize) && (mBufSize < kMaxBufferSize)) { + // Try to increase buffer to the max size, no problem if not + // succesful, we just use what is available. + char *newbuf = (char *) realloc(mBuffer, kMaxBufferSize); + if (newbuf) { + // Use the new larger buffer + mBuffer = newbuf; mBufSize = kMaxBufferSize; - char *buffer = mBuffer; - - mBuffer = (char *) realloc(mBuffer, mBufSize); - if (!mBuffer) { - free(buffer); - mBufSize = 0; - break; - } - } else { - nsresult rv = FlushBufferToFile(); - if (NS_FAILED(rv)) break; - flushed = true; } } - - uint32_t chunkSize = bytesLeft; - if (chunkSize > (mBufSize - mBufPos)) - chunkSize = mBufSize - mBufPos; - - memcpy(mBuffer + mBufPos, buffer, chunkSize); - mBufDirty = true; - mBufPos += chunkSize; - bytesLeft -= chunkSize; - buffer += chunkSize; - - if (mBufEnd < mBufPos) - mBufEnd = mBufPos; - } - if (bytesLeft) { - *bytesWritten = 0; - return NS_ERROR_FAILURE; - } - *bytesWritten = count; - // update mStreamPos, mStreamEnd - mStreamPos += count; - if (mStreamEnd < mStreamPos) { - mStreamEnd = mStreamPos; - NS_ASSERTION(mBinding->mCacheEntry->DataSize() == mStreamEnd, "bad stream"); - - // If we have flushed to a file, update the file size - if (flushed && mFD) { - UpdateFileSize(); + // Store in the buffer but only if it fits + if ((count > 0) && (mStreamEnd + count <= mBufSize)) { + memcpy(mBuffer + mStreamEnd, buffer, count); + mStreamEnd += count; + *bytesWritten = count; + return NS_OK; } } - - return rv; + + // There are more bytes than fit in the buffer/cacheblocks, switch to file + if (!mFD) { + // Opens a cache file and write the buffer to it + nsresult rv = FlushBufferToFile(); + if (NS_FAILED(rv)) { + *bytesWritten = 0; + return rv; + } + } + // Write directly to the file + if (PR_Write(mFD, buffer, count) != (int32_t)count) { + NS_WARNING("failed to write all data"); + *bytesWritten = 0; + return NS_ERROR_UNEXPECTED; // NS_ErrorAccordingToNSPR() + } + mStreamEnd += count; + *bytesWritten = count; + + UpdateFileSize(); + NS_ASSERTION(mBinding->mCacheEntry->DataSize() == mStreamEnd, "bad stream"); + + return NS_OK; } @@ -691,10 +652,11 @@ nsDiskCacheStreamIO::OpenCacheFile(int flags, PRFileDesc ** fd) nsresult -nsDiskCacheStreamIO::ReadCacheBlocks() +nsDiskCacheStreamIO::ReadCacheBlocks(uint32_t bufferSize) { NS_ASSERTION(mStreamEnd == mBinding->mCacheEntry->DataSize(), "bad stream"); - NS_ASSERTION(mStreamEnd <= kMaxBufferSize, "data too large for buffer"); + NS_ASSERTION(bufferSize <= kMaxBufferSize, "bufferSize too large for buffer"); + NS_ASSERTION(mStreamEnd <= bufferSize, "data too large for buffer"); nsDiskCacheRecord * record = &mBinding->mRecord; if (!record->DataLocationInitialized()) return NS_OK; @@ -703,23 +665,16 @@ nsDiskCacheStreamIO::ReadCacheBlocks() if (!mBuffer) { // allocate buffer - mBuffer = (char *) malloc(mStreamEnd); + mBuffer = (char *) malloc(bufferSize); if (!mBuffer) { return NS_ERROR_OUT_OF_MEMORY; } - mBufSize = mStreamEnd; + mBufSize = bufferSize; } // read data stored in cache block files nsDiskCacheMap *map = mDevice->CacheMap(); // get map reference - nsresult rv = map->ReadDataCacheBlocks(mBinding, mBuffer, mStreamEnd); - if (NS_FAILED(rv)) return rv; - - // update streamIO variables - mBufPos = 0; - mBufEnd = mStreamEnd; - - return NS_OK; + return map->ReadDataCacheBlocks(mBinding, mBuffer, mStreamEnd); } @@ -747,18 +702,15 @@ nsDiskCacheStreamIO::FlushBufferToFile() mozilla::fallocate(mFD, NS_MIN(dataSize, kPreallocateLimit)); } - // write buffer - int32_t bytesWritten = PR_Write(mFD, mBuffer, mBufEnd); - if (uint32_t(bytesWritten) != mBufEnd) { + // write buffer to the file + if (PR_Write(mFD, mBuffer, mStreamEnd) != (int32_t)mStreamEnd) { NS_WARNING("failed to flush all data"); return NS_ERROR_UNEXPECTED; // NS_ErrorAccordingToNSPR() } - mBufDirty = false; - - // reset buffer - mBufPos = 0; - mBufEnd = 0; - + + // buffer is no longer valid + DeleteBuffer(); + return NS_OK; } @@ -767,11 +719,8 @@ void nsDiskCacheStreamIO::DeleteBuffer() { if (mBuffer) { - NS_ASSERTION(!mBufDirty, "deleting dirty buffer"); free(mBuffer); mBuffer = nullptr; - mBufPos = 0; - mBufEnd = 0; mBufSize = 0; } } @@ -787,157 +736,50 @@ nsDiskCacheStreamIO::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) return usage; } -// NOTE: called with service lock held nsresult -nsDiskCacheStreamIO::Seek(int32_t whence, int32_t offset) +nsDiskCacheStreamIO::SeekAndTruncate(uint32_t offset) { - int32_t newPos; if (!mBinding) return NS_ERROR_NOT_AVAILABLE; if (uint32_t(offset) > mStreamEnd) return NS_ERROR_FAILURE; - if (mBinding->mRecord.DataLocationInitialized()) { - if (mBinding->mRecord.DataFile() == 0) { - if (!mFD) { - // we need an mFD, we better open it now - nsresult rv = OpenCacheFile(PR_RDWR | PR_CREATE_FILE, &mFD); - if (NS_FAILED(rv)) return rv; - } - } - } - - if (mFD) { - // do we have data in the buffer that needs to be flushed? - if (mBufDirty) { - // XXX optimization: are we just moving within the current buffer? - nsresult rv = FlushBufferToFile(); + // Set the current end to the desired offset + mStreamEnd = offset; + + // Currently stored in file? + if (mBinding->mRecord.DataLocationInitialized() && + (mBinding->mRecord.DataFile() == 0)) { + if (!mFD) { + // we need an mFD, we better open it now + nsresult rv = OpenCacheFile(PR_RDWR | PR_CREATE_FILE, &mFD); if (NS_FAILED(rv)) return rv; } - - newPos = PR_Seek(mFD, offset, (PRSeekWhence)whence); - if (newPos == -1) - return NS_ErrorAccordingToNSPR(); - - mStreamPos = (uint32_t) newPos; - mBufPos = 0; - mBufEnd = 0; - return NS_OK; - } - - // else, seek in mBuffer - - switch(whence) { - case PR_SEEK_SET: - newPos = offset; - break; - - case PR_SEEK_CUR: // relative from current posistion - newPos = offset + (uint32_t)mStreamPos; - break; - - case PR_SEEK_END: // relative from end - newPos = offset + (uint32_t)mBufEnd; - break; - - default: - return NS_ERROR_INVALID_ARG; - } - - // read data into mBuffer if not read yet. - if (mStreamEnd && !mBufEnd) { - if (newPos > 0) { - nsresult rv = ReadCacheBlocks(); - if (NS_FAILED(rv)) return rv; + if (offset) { + if (PR_Seek(mFD, offset, PR_SEEK_SET) == -1) + return NS_ErrorAccordingToNSPR(); } - } - - // stream buffer sanity checks - NS_ASSERTION(mBufEnd <= kMaxBufferSize, "bad stream"); - NS_ASSERTION(mBufPos <= mBufEnd, "bad stream"); - NS_ASSERTION(mStreamPos == mBufPos, "bad stream"); - NS_ASSERTION(mStreamEnd == mBufEnd, "bad stream"); - - if ((newPos < 0) || (uint32_t(newPos) > mBufEnd)) { - NS_WARNING("seek offset out of range"); - return NS_ERROR_INVALID_ARG; - } - - mStreamPos = newPos; - mBufPos = newPos; - return NS_OK; -} - - -// called only from nsDiskCacheOutputStream::Tell -nsresult -nsDiskCacheStreamIO::Tell(uint32_t * result) -{ - NS_ENSURE_ARG_POINTER(result); - *result = mStreamPos; - return NS_OK; -} - - -// NOTE: called with service lock held -nsresult -nsDiskCacheStreamIO::SetEOF() -{ - nsresult rv; - bool needToCloseFD = false; - - NS_ASSERTION(mStreamPos <= mStreamEnd, "bad stream"); - if (!mBinding) return NS_ERROR_NOT_AVAILABLE; - - if (mBinding->mRecord.DataLocationInitialized()) { - if (mBinding->mRecord.DataFile() == 0) { - if (!mFD) { - // we need an mFD, we better open it now - rv = OpenCacheFile(PR_RDWR | PR_CREATE_FILE, &mFD); - if (NS_FAILED(rv)) return rv; - needToCloseFD = true; - } - } else { - // data in cache block files - if ((mStreamPos != 0) && (mStreamPos != mBufPos)) { - // only read data if there will be some left after truncation - rv = ReadCacheBlocks(); - if (NS_FAILED(rv)) return rv; - } - - // We need to make sure we reflect this change in Flush(). - // In particular, if mStreamPos is 0 and we never write to - // the buffer, we want the storage to be deleted. - mBufDirty = true; - } - } - - if (mFD) { - rv = nsDiskCache::Truncate(mFD, mStreamPos); -#ifdef DEBUG - uint32_t oldSizeK = (mStreamEnd + 0x03FF) >> 10; - NS_ASSERTION(mBinding->mRecord.DataFileSize() == oldSizeK, "bad disk cache entry size"); - } else { - // data stored in buffer. - NS_ASSERTION(mStreamEnd <= kMaxBufferSize, "buffer truncation inadequate"); - NS_ASSERTION(mBufPos == mStreamPos, "bad stream"); - NS_ASSERTION(mBuffer ? mBufEnd == mStreamEnd : true, "bad stream"); -#endif - } - - NS_ASSERTION(mStreamEnd == mBinding->mCacheEntry->DataSize(), "cache entry not updated"); - // we expect nsCacheEntryDescriptor::TransportWrapper::OpenOutputStream() - // to eventually update the cache entry - - mStreamEnd = mStreamPos; - mBufEnd = mBufPos; - - if (mFD) { + nsDiskCache::Truncate(mFD, offset); UpdateFileSize(); - if (needToCloseFD) { + + // When we starting at zero again, close file and start with buffer. + // If offset is non-zero (and within buffer) an option would be + // to read the file into the buffer, but chance is high that it is + // rewritten to the file anyway. + if (offset == 0) { + // close file descriptor (void) PR_Close(mFD); mFD = nullptr; } + return NS_OK; + } + + // read data into mBuffer if not read yet. + if (offset && !mBuffer) { + nsresult rv = ReadCacheBlocks(kMaxBufferSize); + if (NS_FAILED(rv)) return rv; } - return NS_OK; + // stream buffer sanity check + NS_ASSERTION(mStreamEnd <= kMaxBufferSize, "bad stream"); + return NS_OK; } diff --git a/netwerk/cache/nsDiskCacheStreams.h b/netwerk/cache/nsDiskCacheStreams.h index 1c5f571cc19f..f10959003b9e 100644 --- a/netwerk/cache/nsDiskCacheStreams.h +++ b/netwerk/cache/nsDiskCacheStreams.h @@ -37,10 +37,6 @@ public: uint32_t count, uint32_t * bytesWritten); - nsresult Seek(int32_t whence, int32_t offset); - nsresult Tell(uint32_t * position); - nsresult SetEOF(); - nsresult ClearBinding(); void IncrementInputStreamCount() { PR_ATOMIC_INCREMENT(&mInStreamCount); } @@ -55,16 +51,17 @@ public: // GCC 2.95.2 requires this to be defined, although we never call it. // and OS/2 requires that it not be private nsDiskCacheStreamIO() { NS_NOTREACHED("oops"); } -private: +private: void Close(); nsresult OpenCacheFile(int flags, PRFileDesc ** fd); - nsresult ReadCacheBlocks(); + nsresult ReadCacheBlocks(uint32_t bufferSize); nsresult FlushBufferToFile(); void UpdateFileSize(); void DeleteBuffer(); nsresult Flush(); + nsresult SeekAndTruncate(uint32_t offset); nsDiskCacheBinding * mBinding; // not an owning reference nsDiskCacheDevice * mDevice; @@ -72,14 +69,9 @@ private: int32_t mInStreamCount; PRFileDesc * mFD; - uint32_t mStreamPos; // for Output Streams - uint32_t mStreamEnd; - uint32_t mBufPos; // current mark in buffer - uint32_t mBufEnd; // current end of data in buffer + uint32_t mStreamEnd; // current size of data uint32_t mBufSize; // current end of buffer - bool mBufDirty; char * mBuffer; - }; #endif // _nsDiskCacheStreams_h_