From 51505bd8861b0d63b2faa6fa13b90666eacda6e6 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 28 Nov 2016 20:46:47 -0600 Subject: [PATCH 01/27] Bug 1318675 - Reconnect find bar when toggling RDM. r=ochameau MozReview-Commit-ID: 4IoXvTZXbKW --HG-- extra : rebase_source : f86449933dbc3946a94de41ef723eddae1d8361e --- .../client/responsive.html/browser/swap.js | 23 +++++++++++++++++++ .../client/responsive.html/browser/tunnel.js | 1 + 2 files changed, 24 insertions(+) diff --git a/devtools/client/responsive.html/browser/swap.js b/devtools/client/responsive.html/browser/swap.js index 782c3707acb1..89c2ac279932 100644 --- a/devtools/client/responsive.html/browser/swap.js +++ b/devtools/client/responsive.html/browser/swap.js @@ -107,6 +107,17 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) { tunnel = tunnelToInnerBrowser(tab.linkedBrowser, innerBrowser); yield tunnel.start(); + // Swapping browsers disconnects the find bar UI from the browser. + // If the find bar has been initialized, reconnect it. + if (gBrowser.isFindBarInitialized(tab)) { + let findBar = gBrowser.getFindBar(tab); + findBar.browser = tab.linkedBrowser; + if (!findBar.hidden) { + // Force the find bar to activate again, restoring the search string. + findBar.onFindCommand(); + } + } + // Force the browser UI to match the new state of the tab and browser. thawNavigationState(tab); gBrowser.setTabTitle(tab); @@ -147,6 +158,18 @@ function swapToInnerBrowser({ tab, containerURL, getInnerBrowser }) { // `swapBrowsersAndCloseOther`. dispatchDevToolsBrowserSwap(contentBrowser, tab.linkedBrowser); gBrowser.swapBrowsersAndCloseOther(tab, contentTab); + + // Swapping browsers disconnects the find bar UI from the browser. + // If the find bar has been initialized, reconnect it. + if (gBrowser.isFindBarInitialized(tab)) { + let findBar = gBrowser.getFindBar(tab); + findBar.browser = tab.linkedBrowser; + if (!findBar.hidden) { + // Force the find bar to activate again, restoring the search string. + findBar.onFindCommand(); + } + } + gBrowser = null; // The focus manager seems to get a little dizzy after all this swapping. If a diff --git a/devtools/client/responsive.html/browser/tunnel.js b/devtools/client/responsive.html/browser/tunnel.js index 024ee5f7a82f..e2153251e392 100644 --- a/devtools/client/responsive.html/browser/tunnel.js +++ b/devtools/client/responsive.html/browser/tunnel.js @@ -23,6 +23,7 @@ function debug(msg) { * list at /devtools/client/responsive.html/docs/browser-swap.md. */ const SWAPPED_BROWSER_STATE = [ + "_remoteFinder", "_securityUI", "_documentURI", "_documentContentType", From 39c3163cf75b265f954de155fad5616e95a3c978 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Wed, 30 Nov 2016 17:28:52 -0500 Subject: [PATCH 02/27] Bug 1321396 - Skip oversized records without aborting the sync by default in sync engines. r=markh MozReview-Commit-ID: 7hgzyKb2UxY --HG-- extra : rebase_source : 7c7f238a8e46b0776afe83798061d1539b07f76c --- services/sync/modules/engines.js | 2 +- services/sync/modules/engines/bookmarks.js | 1 + services/sync/modules/engines/clients.js | 1 + services/sync/modules/engines/extension-storage.js | 1 + services/sync/modules/engines/forms.js | 1 - services/sync/modules/engines/history.js | 1 - services/sync/modules/engines/prefs.js | 1 + services/sync/tests/unit/test_syncengine_sync.js | 2 +- 8 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/sync/modules/engines.js b/services/sync/modules/engines.js index 2d88078b75b7..d60777d24cc3 100644 --- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -653,7 +653,7 @@ Engine.prototype = { // If this is false, we'll throw, otherwise, we'll ignore the record and // continue. This currently can only happen due to the record being larger // than the record upload limit. - allowSkippedRecord: false, + allowSkippedRecord: true, get prefName() { return this.name; diff --git a/services/sync/modules/engines/bookmarks.js b/services/sync/modules/engines/bookmarks.js index 2f4160a476cc..2143e60f3d79 100644 --- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -275,6 +275,7 @@ BookmarksEngine.prototype = { _defaultSort: "index", syncPriority: 4, + allowSkippedRecord: false, // A diagnostic helper to get the string value for a bookmark's URL given // its ID. Always returns a string - on error will return a string in the diff --git a/services/sync/modules/engines/clients.js b/services/sync/modules/engines/clients.js index 18e27e2f2144..3dd67957019d 100644 --- a/services/sync/modules/engines/clients.js +++ b/services/sync/modules/engines/clients.js @@ -81,6 +81,7 @@ ClientEngine.prototype = { _storeObj: ClientStore, _recordObj: ClientsRec, _trackerObj: ClientsTracker, + allowSkippedRecord: false, // Always sync client data as it controls other sync behavior get enabled() { diff --git a/services/sync/modules/engines/extension-storage.js b/services/sync/modules/engines/extension-storage.js index 45eb433ab19c..c44d1435d3aa 100644 --- a/services/sync/modules/engines/extension-storage.js +++ b/services/sync/modules/engines/extension-storage.js @@ -41,6 +41,7 @@ ExtensionStorageEngine.prototype = { _recordObj: undefined, syncPriority: 10, + allowSkippedRecord: false, _sync: function () { return Async.promiseSpinningly(ExtensionStorageSync.syncAll()); diff --git a/services/sync/modules/engines/forms.js b/services/sync/modules/engines/forms.js index d7945a254f68..43f79d4f7e2c 100644 --- a/services/sync/modules/engines/forms.js +++ b/services/sync/modules/engines/forms.js @@ -111,7 +111,6 @@ FormEngine.prototype = { _trackerObj: FormTracker, _recordObj: FormRec, applyIncomingBatchSize: FORMS_STORE_BATCH_SIZE, - allowSkippedRecord: true, syncPriority: 6, diff --git a/services/sync/modules/engines/history.js b/services/sync/modules/engines/history.js index 0fa479113e90..acb82ec9d914 100644 --- a/services/sync/modules/engines/history.js +++ b/services/sync/modules/engines/history.js @@ -42,7 +42,6 @@ HistoryEngine.prototype = { _trackerObj: HistoryTracker, downloadLimit: MAX_HISTORY_DOWNLOAD, applyIncomingBatchSize: HISTORY_STORE_BATCH_SIZE, - allowSkippedRecord: true, syncPriority: 7, diff --git a/services/sync/modules/engines/prefs.js b/services/sync/modules/engines/prefs.js index fafdee004a8d..9ceeb9ac6944 100644 --- a/services/sync/modules/engines/prefs.js +++ b/services/sync/modules/engines/prefs.js @@ -42,6 +42,7 @@ PrefsEngine.prototype = { version: 2, syncPriority: 1, + allowSkippedRecord: false, getChangedIDs: function () { // No need for a proper timestamp (no conflict resolution needed). diff --git a/services/sync/tests/unit/test_syncengine_sync.js b/services/sync/tests/unit/test_syncengine_sync.js index a5b2f754760c..e5322280a5cd 100644 --- a/services/sync/tests/unit/test_syncengine_sync.js +++ b/services/sync/tests/unit/test_syncengine_sync.js @@ -1552,7 +1552,7 @@ add_task(async function test_uploadOutgoing_largeRecords() { let collection = new ServerCollection(); let engine = makeRotaryEngine(); - + engine.allowSkippedRecord = false; engine._store.items["large-item"] = "Y".repeat(MAX_UPLOAD_BYTES*2); engine._tracker.addChangedID("large-item", 0); collection.insert("large-item"); From 492e3e6a3b208365318406bafcf4cc16f6dc4146 Mon Sep 17 00:00:00 2001 From: Ralph Giles Date: Mon, 28 Nov 2016 10:51:59 -0800 Subject: [PATCH 03/27] Bug 1320741 - Recommend `rustup target add`. r=chmanchester Provide some guidance on how to resolve the common error: can't find crate for `std` when cross-compiling rust code. This most commonly comes up with the Android build. MozReview-Commit-ID: 8PKKt7tf1KS --HG-- extra : rebase_source : 5d18bb3a2ef8b3c4c5700b87c4a899b26160999d --- build/moz.configure/rust.configure | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index 2de5c04a1c8d..ca1758a28e92 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -85,6 +85,7 @@ def rust_triple_alias(host_or_target): @imports(_from='mozbuild.configure.util', _import='LineIO') @imports(_from='mozbuild.shellutil', _import='quote') @imports(_from='tempfile', _import='mkstemp') + @imports(_from='textwrap', _import='dedent') def rust_target(rustc, host_or_target): # Rust's --target options are similar to, but not exactly the same # as, the autoconf-derived targets we use. An example would be that @@ -155,7 +156,13 @@ def rust_triple_alias(host_or_target): in_path, ] def failed(): - die('Cannot compile for {} with {}'.format(host_or_target.alias, rustc)) + die(dedent('''\ + Cannot compile for {} with {} + The target may be unsupported, or you may not have + a rust std library for that target installed. Try: + + rustup target add {} + '''.format(host_or_target.alias, rustc, rustc_target))) check_cmd_output(*cmd, onerror=failed) if not os.path.exists(out_path) or os.path.getsize(out_path) == 0: failed() From 271c772320995f7688d0c4adbf535419f0fb282c Mon Sep 17 00:00:00 2001 From: "Adrianzatreanu adrianzatreanu1@gmail.com" Date: Thu, 1 Dec 2016 14:38:11 +0200 Subject: [PATCH 04/27] Bug 1321480: Make Firefox Puppeteer use Marionette's "page load" timeout r=whimboo This is being used instead of a self-defined Browser.timeout. MozReview-Commit-ID: 5zAqI38AdHs --HG-- extra : rebase_source : 1d47dd27db65cde30f5b8b6e7fd38c18fc67243e --- .../private_browsing/test_about_private_browsing.py | 2 +- .../security/test_mixed_script_content_blocking.py | 2 +- .../security/test_safe_browsing_notification.py | 8 ++++---- .../security/test_safe_browsing_warning_pages.py | 8 ++++---- .../functional/security/test_ssl_disabled_error_page.py | 2 +- .../security/test_submit_unencrypted_info_warning.py | 4 ++-- .../security/test_untrusted_connection_error_page.py | 2 +- .../firefox/firefox_puppeteer/ui/browser/window.py | 3 --- 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py b/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py index 9117d5ee6527..f727fe54d00e 100644 --- a/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py +++ b/testing/firefox-ui/tests/functional/private_browsing/test_about_private_browsing.py @@ -53,7 +53,7 @@ class TestAboutPrivateBrowsing(PuppeteerMixin, MarionetteTestCase): link.click() tab = pb_window.tabbar.open_tab(trigger=tab_opener) - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda _: tab.location == self.pb_url) finally: diff --git a/testing/firefox-ui/tests/functional/security/test_mixed_script_content_blocking.py b/testing/firefox-ui/tests/functional/security/test_mixed_script_content_blocking.py index a826bad68b5d..be0346b41544 100644 --- a/testing/firefox-ui/tests/functional/security/test_mixed_script_content_blocking.py +++ b/testing/firefox-ui/tests/functional/security/test_mixed_script_content_blocking.py @@ -45,7 +45,7 @@ class TestMixedScriptContentBlocking(PuppeteerMixin, MarionetteTestCase): ) # First call to Wait() needs a longer timeout due to the reload of the web page. - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda _: self.locationbar.identity_box.get_attribute('className') == identity, message='Expected identity "{}" not found'.format(identity) ) diff --git a/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py b/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py index a03421ac94a4..313cef8fcd98 100644 --- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py +++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_notification.py @@ -94,7 +94,7 @@ class TestSafeBrowsingNotificationBar(PuppeteerMixin, MarionetteTestCase): button = self.marionette.find_element(By.ID, 'ignoreWarningButton') button.click() - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'main-feature'), message='Expected target element "#main-feature" has not been found', ) @@ -113,7 +113,7 @@ class TestSafeBrowsingNotificationBar(PuppeteerMixin, MarionetteTestCase): self.browser.tabbar.open_tab(lambda _: button.click()) - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: report_page in mn.get_url(), message='The expected safe-browsing report page has not been opened', ) @@ -129,7 +129,7 @@ class TestSafeBrowsingNotificationBar(PuppeteerMixin, MarionetteTestCase): .find_element('anon attribute', {'label': label})) button.click() - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: self.browser.default_homepage in mn.get_url(), message='The default home page has not been loaded', ) @@ -143,7 +143,7 @@ class TestSafeBrowsingNotificationBar(PuppeteerMixin, MarionetteTestCase): {'class': 'messageCloseButton close-icon tabbable'})) button.click() - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_stale(button), message='The notification bar has not been closed', ) diff --git a/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py b/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py index 923c70451b93..c8e9706b0e69 100644 --- a/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py +++ b/testing/firefox-ui/tests/functional/security/test_safe_browsing_warning_pages.py @@ -69,7 +69,7 @@ class TestSafeBrowsingWarningPages(PuppeteerMixin, MarionetteTestCase): button = self.marionette.find_element(By.ID, "getMeOutButton") button.click() - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: self.browser.default_homepage in mn.get_url()) def check_report_button(self, unsafe_page): @@ -86,12 +86,12 @@ class TestSafeBrowsingWarningPages(PuppeteerMixin, MarionetteTestCase): # Wait for the button to become stale, whereby a longer timeout is needed # here to not fail in case of slow connections. - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_stale(button)) # Wait for page load to be completed, so we can verify the URL even if a redirect happens. # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: mn.execute_script('return document.readyState == "DOMContentLoaded" ||' ' document.readyState == "complete";') ) @@ -103,7 +103,7 @@ class TestSafeBrowsingWarningPages(PuppeteerMixin, MarionetteTestCase): button = self.marionette.find_element(By.ID, 'ignoreWarningButton') button.click() - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.ID, 'main-feature')) self.assertEquals(self.marionette.get_url(), self.browser.get_final_url(unsafe_page)) diff --git a/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py b/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py index c0880e6edce3..cd571a5c6b90 100644 --- a/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py +++ b/testing/firefox-ui/tests/functional/security/test_ssl_disabled_error_page.py @@ -56,5 +56,5 @@ class TestSSLDisabledErrorPage(PuppeteerMixin, MarionetteTestCase): reset_button.click() # With the preferences reset, the page has to load correctly - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( expected.element_present(By.LINK_TEXT, 'http://quality.mozilla.org')) diff --git a/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py b/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py index 16b338ca5cda..2fbec4f88fee 100644 --- a/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py +++ b/testing/firefox-ui/tests/functional/security/test_submit_unencrypted_info_warning.py @@ -46,7 +46,7 @@ class TestSubmitUnencryptedInfoWarning(PuppeteerMixin, MarionetteTestCase): try: Wait(self.marionette, ignored_exceptions=NoAlertPresentException, - timeout=self.browser.timeout_page_load).until( + timeout=self.marionette.timeout.page_load).until( lambda _: warning.text == message) finally: warning.accept() @@ -55,7 +55,7 @@ class TestSubmitUnencryptedInfoWarning(PuppeteerMixin, MarionetteTestCase): Wait(self.marionette).until(expected.element_stale(searchbox)) # TODO: Bug 1140470: use replacement for mozmill's waitforPageLoad - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: mn.execute_script('return document.readyState == "DOMContentLoaded" ||' ' document.readyState == "complete";') ) diff --git a/testing/firefox-ui/tests/functional/security/test_untrusted_connection_error_page.py b/testing/firefox-ui/tests/functional/security/test_untrusted_connection_error_page.py index 75450e3165c2..a4cf39152ff0 100644 --- a/testing/firefox-ui/tests/functional/security/test_untrusted_connection_error_page.py +++ b/testing/firefox-ui/tests/functional/security/test_untrusted_connection_error_page.py @@ -31,5 +31,5 @@ class TestUntrustedConnectionErrorPage(PuppeteerMixin, MarionetteTestCase): button = self.marionette.find_element(By.ID, "returnButton") button.click() - Wait(self.marionette, timeout=self.browser.timeout_page_load).until( + Wait(self.marionette, timeout=self.marionette.timeout.page_load).until( lambda mn: target_url == self.marionette.get_url()) diff --git a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py index d558a70f84d9..743e0fb6eb73 100644 --- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py +++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/ui/browser/window.py @@ -45,9 +45,6 @@ class BrowserWindow(BaseWindow): self._navbar = None self._tabbar = None - # Timeout for loading remote web pages - self.timeout_page_load = 30 - @property def default_homepage(self): """The default homepage as used by the current locale. From 38a04b81383686299a02099093e2c394395d7fc2 Mon Sep 17 00:00:00 2001 From: Rob Wood Date: Thu, 1 Dec 2016 11:20:22 -0500 Subject: [PATCH 05/27] Bug 1321048 - add talos-test option to not download tp5 pageset; r=jmaher MozReview-Commit-ID: KtpbABSg40a --HG-- extra : rebase_source : cb6eece796aa41b03b86dcef503d096fad570fe3 --- .../mozharness/mozilla/testing/talos.py | 30 +++++++++++-------- testing/talos/talos/cmdline.py | 2 ++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/testing/mozharness/mozharness/mozilla/testing/talos.py b/testing/mozharness/mozharness/mozilla/testing/talos.py index be7968c9d018..f56b16de8589 100755 --- a/testing/mozharness/mozharness/mozilla/testing/talos.py +++ b/testing/mozharness/mozharness/mozilla/testing/talos.py @@ -326,20 +326,24 @@ class Talos(TestingMixin, MercurialScript, BlobUploadMixin, TooltoolMixin): self.suite = self.config['suite'] # now that have the suite name, check if pageset is required, if so download it + # the --no-download option will override this if self.query_pagesets_name(): - self.info("Downloading pageset with tooltool...") - self.src_talos_webdir = os.path.join(self.talos_path, 'talos') - src_talos_pageset = os.path.join(self.src_talos_webdir, 'tests') - manifest_file = os.path.join(self.talos_path, 'tp5n-pageset.manifest') - self.tooltool_fetch( - manifest_file, - output_dir=src_talos_pageset, - cache=self.config.get('tooltool_cache') - ) - archive = os.path.join(src_talos_pageset, self.pagesets_name) - unzip = self.query_exe('unzip') - unzip_cmd = [unzip, '-q', '-o', archive, '-d', src_talos_pageset] - self.run_command(unzip_cmd, halt_on_failure=True) + if '--no-download' not in self.config['talos_extra_options']: + self.info("Downloading pageset with tooltool...") + self.src_talos_webdir = os.path.join(self.talos_path, 'talos') + src_talos_pageset = os.path.join(self.src_talos_webdir, 'tests') + manifest_file = os.path.join(self.talos_path, 'tp5n-pageset.manifest') + self.tooltool_fetch( + manifest_file, + output_dir=src_talos_pageset, + cache=self.config.get('tooltool_cache') + ) + archive = os.path.join(src_talos_pageset, self.pagesets_name) + unzip = self.query_exe('unzip') + unzip_cmd = [unzip, '-q', '-o', archive, '-d', src_talos_pageset] + self.run_command(unzip_cmd, halt_on_failure=True) + else: + self.info("Not downloading pageset because the no-download option was specified") # Action methods. {{{1 # clobber defined in BaseScript diff --git a/testing/talos/talos/cmdline.py b/testing/talos/talos/cmdline.py index 7d4cd20d9eb1..3f4ea47add63 100644 --- a/testing/talos/talos/cmdline.py +++ b/testing/talos/talos/cmdline.py @@ -127,6 +127,8 @@ def create_parser(mach_interface=False): ' the manifest') add_arg('--tpdelay', type=int, help="length of the pageloader delay") + add_arg('--no-download', action="store_true", dest="no_download", + help="Do not download the talos test pagesets") add_arg('--sourcestamp', help='Specify the hg revision or sourcestamp for the changeset' ' we are testing. This will use the value found in' From b6eca933c12ebe3ef139762f3267d9c38dfcf2da Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 14 Nov 2016 15:46:19 -0700 Subject: [PATCH 06/27] Bug 1316630 - move PrefObserver to devtools/shared/prefs.js; r=jdescottes MozReview-Commit-ID: C4KxFxv2LVT --HG-- extra : rebase_source : 484a654309eab406913f944d6aa8988c567641d7 --- .../client/inspector/computed/computed.js | 4 +- devtools/client/inspector/markup/markup.js | 2 +- devtools/client/inspector/rules/rules.js | 3 +- ...ser_rules_context-menu-show-mdn-docs-03.js | 2 +- .../test/browser_rules_user-agent-styles.js | 2 +- .../inspector/rules/views/rule-editor.js | 3 +- .../inspector/shared/style-inspector-menu.js | 2 +- devtools/client/shared/prefs.js | 28 +++++++++++++ devtools/client/sourceeditor/editor.js | 2 +- devtools/client/styleeditor/StyleEditorUI.jsm | 3 +- devtools/client/styleeditor/moz.build | 1 - devtools/client/styleeditor/utils.js | 40 ------------------- 12 files changed, 42 insertions(+), 50 deletions(-) delete mode 100644 devtools/client/styleeditor/utils.js diff --git a/devtools/client/inspector/computed/computed.js b/devtools/client/inspector/computed/computed.js index 7d9d5ec5b232..f89c99fdff34 100644 --- a/devtools/client/inspector/computed/computed.js +++ b/devtools/client/inspector/computed/computed.js @@ -13,7 +13,7 @@ const promise = require("promise"); const defer = require("devtools/shared/defer"); const Services = require("Services"); const {OutputParser} = require("devtools/client/shared/output-parser"); -const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils"); +const {PrefObserver} = require("devtools/client/shared/prefs"); const {createChild} = require("devtools/client/inspector/shared/utils"); const {gDevTools} = require("devtools/client/framework/devtools"); const {getCssProperties} = require("devtools/shared/fronts/css-properties"); @@ -33,6 +33,8 @@ const STYLE_INSPECTOR_PROPERTIES = "devtools/shared/locales/styleinspector.prope const {LocalizationHelper} = require("devtools/shared/l10n"); const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES); +const PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; + const FILTER_CHANGED_TIMEOUT = 150; const HTML_NS = "http://www.w3.org/1999/xhtml"; diff --git a/devtools/client/inspector/markup/markup.js b/devtools/client/inspector/markup/markup.js index d6e9f8c11577..b97dd5ec6ec1 100644 --- a/devtools/client/inspector/markup/markup.js +++ b/devtools/client/inspector/markup/markup.js @@ -19,7 +19,7 @@ const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts"); const {scrollIntoViewIfNeeded} = require("devtools/client/shared/scroll"); const {UndoStack} = require("devtools/client/shared/undo"); const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip"); -const {PrefObserver} = require("devtools/client/styleeditor/utils"); +const {PrefObserver} = require("devtools/client/shared/prefs"); const HTMLEditor = require("devtools/client/inspector/markup/views/html-editor"); const MarkupElementContainer = require("devtools/client/inspector/markup/views/element-container"); const MarkupReadOnlyContainer = require("devtools/client/inspector/markup/views/read-only-container"); diff --git a/devtools/client/inspector/rules/rules.js b/devtools/client/inspector/rules/rules.js index 4886cdccb845..afa540af0307 100644 --- a/devtools/client/inspector/rules/rules.js +++ b/devtools/client/inspector/rules/rules.js @@ -13,7 +13,7 @@ const {Tools} = require("devtools/client/definitions"); const {l10n} = require("devtools/shared/inspector/css-logic"); const {ELEMENT_STYLE} = require("devtools/shared/specs/styles"); const {OutputParser} = require("devtools/client/shared/output-parser"); -const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils"); +const {PrefObserver} = require("devtools/client/shared/prefs"); const {ElementStyle} = require("devtools/client/inspector/rules/models/element-style"); const {Rule} = require("devtools/client/inspector/rules/models/rule"); const {RuleEditor} = require("devtools/client/inspector/rules/views/rule-editor"); @@ -40,6 +40,7 @@ const PREF_DEFAULT_COLOR_UNIT = "devtools.defaultColorUnit"; const PREF_ENABLE_MDN_DOCS_TOOLTIP = "devtools.inspector.mdnDocsTooltip.enabled"; const FILTER_CHANGED_TIMEOUT = 150; +const PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; // This is used to parse user input when filtering. const FILTER_PROP_RE = /\s*([^:\s]*)\s*:\s*(.*?)\s*;?$/; diff --git a/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js b/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js index d1089fcf61c3..af88bfeb7c4e 100644 --- a/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js +++ b/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js @@ -14,7 +14,7 @@ "use strict"; -const { PrefObserver } = require("devtools/client/styleeditor/utils"); +const { PrefObserver } = require("devtools/client/shared/prefs"); const PREF_ENABLE_MDN_DOCS_TOOLTIP = "devtools.inspector.mdnDocsTooltip.enabled"; const PROPERTY_NAME_CLASS = "ruleview-propertyname"; diff --git a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js index 6852e3c03491..509617a85075 100644 --- a/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js +++ b/devtools/client/inspector/rules/test/browser_rules_user-agent-styles.js @@ -8,7 +8,7 @@ // it is preffed on. var PREF_UA_STYLES = "devtools.inspector.showUserAgentStyles"; -const { PrefObserver } = require("devtools/client/styleeditor/utils"); +const { PrefObserver } = require("devtools/client/shared/prefs"); const TEST_URI = URL_ROOT + "doc_author-sheet.html"; diff --git a/devtools/client/inspector/rules/views/rule-editor.js b/devtools/client/inspector/rules/views/rule-editor.js index 2587bf19cf5d..570c98cf4537 100644 --- a/devtools/client/inspector/rules/views/rule-editor.js +++ b/devtools/client/inspector/rules/views/rule-editor.js @@ -6,7 +6,6 @@ const {l10n} = require("devtools/shared/inspector/css-logic"); const {ELEMENT_STYLE} = require("devtools/shared/specs/styles"); -const {PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils"); const {Rule} = require("devtools/client/inspector/rules/models/rule"); const {InplaceEditor, editableField, editableItem} = require("devtools/client/shared/inplace-editor"); @@ -33,6 +32,8 @@ const STYLE_INSPECTOR_PROPERTIES = "devtools/shared/locales/styleinspector.prope const {LocalizationHelper} = require("devtools/shared/l10n"); const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES); +const PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; + /** * RuleEditor is responsible for the following: * Owns a Rule object and creates a list of TextPropertyEditors diff --git a/devtools/client/inspector/shared/style-inspector-menu.js b/devtools/client/inspector/shared/style-inspector-menu.js index 975074609cdb..615057cfbba3 100644 --- a/devtools/client/inspector/shared/style-inspector-menu.js +++ b/devtools/client/inspector/shared/style-inspector-menu.js @@ -6,7 +6,6 @@ "use strict"; -const {PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils"); const Services = require("Services"); const {Task} = require("devtools/shared/task"); @@ -28,6 +27,7 @@ const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES); const PREF_ENABLE_MDN_DOCS_TOOLTIP = "devtools.inspector.mdnDocsTooltip.enabled"; +const PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; /** * Style inspector context menu diff --git a/devtools/client/shared/prefs.js b/devtools/client/shared/prefs.js index 9b44d4d58355..b8e0aead9f0d 100644 --- a/devtools/client/shared/prefs.js +++ b/devtools/client/shared/prefs.js @@ -176,3 +176,31 @@ function makeObserver(self, cache, prefsRoot, prefsBlueprint) { } exports.PrefsHelper = PrefsHelper; + +/** + * A PreferenceObserver observes a pref branch for pref changes. + * It emits an event for each preference change. + */ +function PrefObserver(branchName) { + this.branchName = branchName; + this.branch = Services.prefs.getBranch(branchName); + this.branch.addObserver("", this, false); + + EventEmitter.decorate(this); +} + +exports.PrefObserver = PrefObserver; + +PrefObserver.prototype = { + observe: function (subject, topic, data) { + if (topic == "nsPref:changed") { + this.emit(this.branchName + data); + } + }, + + destroy: function () { + if (this.branch) { + this.branch.removeObserver("", this); + } + }, +}; diff --git a/devtools/client/sourceeditor/editor.js b/devtools/client/sourceeditor/editor.js index ce2136afc960..5338a9eaee8f 100644 --- a/devtools/client/sourceeditor/editor.js +++ b/devtools/client/sourceeditor/editor.js @@ -32,7 +32,7 @@ const RE_JUMP_TO_LINE = /^(\d+):?(\d+)?/; const Services = require("Services"); const promise = require("promise"); const events = require("devtools/shared/event-emitter"); -const { PrefObserver } = require("devtools/client/styleeditor/utils"); +const { PrefObserver } = require("devtools/client/shared/prefs"); const { getClientCssProperties } = require("devtools/shared/fronts/css-properties"); const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts"); diff --git a/devtools/client/styleeditor/StyleEditorUI.jsm b/devtools/client/styleeditor/StyleEditorUI.jsm index c2bbc8e15af1..b6451ca3b0c0 100644 --- a/devtools/client/styleeditor/StyleEditorUI.jsm +++ b/devtools/client/styleeditor/StyleEditorUI.jsm @@ -26,7 +26,7 @@ const { const {SplitView} = require("resource://devtools/client/shared/SplitView.jsm"); const {StyleSheetEditor} = require("resource://devtools/client/styleeditor/StyleSheetEditor.jsm"); const {PluralForm} = require("devtools/shared/plural-form"); -const {PrefObserver, PREF_ORIG_SOURCES} = require("devtools/client/styleeditor/utils"); +const {PrefObserver} = require("devtools/client/shared/prefs"); const csscoverage = require("devtools/shared/fronts/csscoverage"); const {console} = require("resource://gre/modules/Console.jsm"); const promise = require("promise"); @@ -41,6 +41,7 @@ const SELECTOR_HIGHLIGHTER_TYPE = "SelectorHighlighter"; const PREF_MEDIA_SIDEBAR = "devtools.styleeditor.showMediaSidebar"; const PREF_SIDEBAR_WIDTH = "devtools.styleeditor.mediaSidebarWidth"; const PREF_NAV_WIDTH = "devtools.styleeditor.navSidebarWidth"; +const PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; /** * StyleEditorUI is controls and builds the UI of the Style Editor, including diff --git a/devtools/client/styleeditor/moz.build b/devtools/client/styleeditor/moz.build index 4fc06b660988..37b87b7cbceb 100644 --- a/devtools/client/styleeditor/moz.build +++ b/devtools/client/styleeditor/moz.build @@ -12,5 +12,4 @@ DevToolsModules( 'StyleEditorUI.jsm', 'StyleEditorUtil.jsm', 'StyleSheetEditor.jsm', - 'utils.js', ) diff --git a/devtools/client/styleeditor/utils.js b/devtools/client/styleeditor/utils.js deleted file mode 100644 index 6cb1aa8cc019..000000000000 --- a/devtools/client/styleeditor/utils.js +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript 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/. */ - -"use strict"; - -const Services = require("Services"); -const EventEmitter = require("devtools/shared/event-emitter"); - -exports.PREF_ORIG_SOURCES = "devtools.styleeditor.source-maps-enabled"; - -/** - * A PreferenceObserver observes a pref branch for pref changes. - * It emits an event for each preference change. - */ -function PrefObserver(branchName) { - this.branchName = branchName; - this.branch = Services.prefs.getBranch(branchName); - this.branch.addObserver("", this, false); - - EventEmitter.decorate(this); -} - -exports.PrefObserver = PrefObserver; - -PrefObserver.prototype = { - observe: function (subject, topic, data) { - if (topic == "nsPref:changed") { - this.emit(this.branchName + data); - } - }, - - destroy: function () { - if (this.branch) { - this.branch.removeObserver("", this); - } - } -}; From f504948b281f5e623e091d9db1f55dde4a07ca17 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 21 Nov 2016 08:47:10 -0700 Subject: [PATCH 07/27] Bug 1316630 - don't emit pref-changed event on gDevTools; r=jdescottes MozReview-Commit-ID: CCqAf8dBFSY --HG-- extra : rebase_source : dac78e13ef9e52c5f36c17372d023be62c4396e7 --- devtools/client/framework/devtools.js | 8 ---- .../framework/test/browser_toolbox_options.js | 34 ++++++++------- devtools/client/framework/toolbox-options.js | 22 ++-------- devtools/client/framework/toolbox.js | 36 +++++----------- .../client/inspector/computed/computed.js | 14 +++---- .../performance/performance-controller.js | 19 ++++----- devtools/client/shared/autocomplete-popup.js | 37 ++++++++--------- devtools/client/shared/test/browser_theme.js | 14 ++++--- devtools/client/shared/theme.js | 12 +----- devtools/client/webaudioeditor/controller.js | 14 +++++-- .../browser_webconsole_timestamps.js | 12 +++--- ...rowser_webconsole_expandable_timestamps.js | 10 +++-- devtools/client/webconsole/webconsole.js | 41 ++++++++----------- 13 files changed, 113 insertions(+), 160 deletions(-) diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js index fdb145dea348..df69146111db 100644 --- a/devtools/client/framework/devtools.js +++ b/devtools/client/framework/devtools.js @@ -318,14 +318,6 @@ DevTools.prototype = { theme.id == currTheme) { Services.prefs.setCharPref("devtools.theme", "light"); - let data = { - pref: "devtools.theme", - newValue: "light", - oldValue: currTheme - }; - - this.emit("pref-changed", data); - this.emit("theme-unregistered", theme); } diff --git a/devtools/client/framework/test/browser_toolbox_options.js b/devtools/client/framework/test/browser_toolbox_options.js index d86111d8952e..57430cefa080 100644 --- a/devtools/client/framework/test/browser_toolbox_options.js +++ b/devtools/client/framework/test/browser_toolbox_options.js @@ -12,6 +12,7 @@ var doc = null, toolbox = null, panelWin = null, modifiedPrefs = []; const {LocalizationHelper} = require("devtools/shared/l10n"); const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties"); +const {PrefObserver} = require("devtools/client/shared/prefs"); add_task(function* () { const URL = "data:text/html;charset=utf8,test for dynamically registering " + @@ -151,14 +152,13 @@ function* testSelect(select) { continue; } + let observer = new PrefObserver("devtools."); + let deferred = defer(); - gDevTools.once("pref-changed", (event, data) => { - if (data.pref == pref) { - ok(true, "Correct pref was changed"); - is(GetPref(pref), option.value, "Preference been switched for " + pref); - } else { - ok(false, "Pref " + pref + " was not changed correctly"); - } + let changeSeen = false; + observer.once(pref, () => { + changeSeen = true; + is(GetPref(pref), option.value, "Preference been switched for " + pref); deferred.resolve(); }); @@ -167,21 +167,22 @@ function* testSelect(select) { select.dispatchEvent(changeEvent); yield deferred.promise; + + ok(changeSeen, "Correct pref was changed"); + observer.destroy(); } } function* testMouseClick(node, prefValue) { let deferred = defer(); + let observer = new PrefObserver("devtools."); + let pref = node.getAttribute("data-pref"); - gDevTools.once("pref-changed", (event, data) => { - if (data.pref == pref) { - ok(true, "Correct pref was changed"); - is(data.oldValue, prefValue, "Previous value is correct for " + pref); - is(data.newValue, !prefValue, "New value is correct for " + pref); - } else { - ok(false, "Pref " + pref + " was not changed correctly"); - } + let changeSeen = false; + observer.once(pref, () => { + changeSeen = true; + is(GetPref(pref), !prefValue, "New value is correct for " + pref); deferred.resolve(); }); @@ -195,6 +196,9 @@ function* testMouseClick(node, prefValue) { }); yield deferred.promise; + + ok(changeSeen, "Correct pref was changed"); + observer.destroy(); } function* testToggleTools() { diff --git a/devtools/client/framework/toolbox-options.js b/devtools/client/framework/toolbox-options.js index f3c31d10471b..80d377854347 100644 --- a/devtools/client/framework/toolbox-options.js +++ b/devtools/client/framework/toolbox-options.js @@ -275,7 +275,7 @@ OptionsPanel.prototype = { inputRadio.setAttribute("value", theme.id); inputRadio.setAttribute("name", "devtools-theme-item"); inputRadio.addEventListener("change", function (e) { - setPrefAndEmit(themeBox.getAttribute("data-pref"), + SetPref(themeBox.getAttribute("data-pref"), e.target.value); }); @@ -305,7 +305,7 @@ OptionsPanel.prototype = { } prefCheckbox.addEventListener("change", function (e) { let checkbox = e.target; - setPrefAndEmit(checkbox.getAttribute("data-pref"), checkbox.checked); + SetPref(checkbox.getAttribute("data-pref"), checkbox.checked); }); } // Themes radio inputs are handled in setupThemeList @@ -320,7 +320,7 @@ OptionsPanel.prototype = { } radioInput.addEventListener("change", function (e) { - setPrefAndEmit(radioGroup.getAttribute("data-pref"), + SetPref(radioGroup.getAttribute("data-pref"), e.target.value); }); } @@ -340,7 +340,7 @@ OptionsPanel.prototype = { prefSelect.addEventListener("change", function (e) { let select = e.target; - setPrefAndEmit(select.getAttribute("data-pref"), + SetPref(select.getAttribute("data-pref"), select.options[select.selectedIndex].value); }); } @@ -422,17 +422,3 @@ OptionsPanel.prototype = { return this.destroyPromise; } }; - -/* Set a pref and emit the pref-changed event if needed. */ -function setPrefAndEmit(prefName, newValue) { - let data = { - pref: prefName, - newValue: newValue - }; - data.oldValue = GetPref(data.pref); - SetPref(data.pref, data.newValue); - - if (data.newValue != data.oldValue) { - gDevTools.emit("pref-changed", data); - } -} diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index efbae90bf5b6..b4a0c05ce200 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -113,7 +113,9 @@ function Toolbox(target, selectedTool, hostType, contentWindow, frameId) { this.highlighterUtils = getHighlighterUtils(this); this._highlighterReady = this._highlighterReady.bind(this); this._highlighterHidden = this._highlighterHidden.bind(this); - this._prefChanged = this._prefChanged.bind(this); + this._applyCacheSettings = this._applyCacheSettings.bind(this); + this._applyServiceWorkersTestingSettings = + this._applyServiceWorkersTestingSettings.bind(this); this._saveSplitConsoleHeight = this._saveSplitConsoleHeight.bind(this); this._onFocus = this._onFocus.bind(this); this._onBrowserMessage = this._onBrowserMessage.bind(this); @@ -367,7 +369,10 @@ Toolbox.prototype = { this.closeButton = this.doc.getElementById("toolbox-close"); this.closeButton.addEventListener("click", this.destroy, true); - gDevTools.on("pref-changed", this._prefChanged); + Services.prefs.addObserver("devtools.cache.disabled", this._applyCacheSettings, + false); + Services.prefs.addObserver("devtools.serviceWorkers.testing.enabled", + this._applyServiceWorkersTestingSettings, false); let framesMenu = this.doc.getElementById("command-button-frames"); framesMenu.addEventListener("click", this.showFramesMenu, false); @@ -485,29 +490,6 @@ Toolbox.prototype = { this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); }, - /** - * Because our panels are lazy loaded this is a good place to watch for - * "pref-changed" events. - * @param {String} event - * The event type, "pref-changed". - * @param {Object} data - * { - * newValue: The new value - * oldValue: The old value - * pref: The name of the preference that has changed - * } - */ - _prefChanged: function (event, data) { - switch (data.pref) { - case "devtools.cache.disabled": - this._applyCacheSettings(); - break; - case "devtools.serviceWorkers.testing.enabled": - this._applyServiceWorkersTestingSettings(); - break; - } - }, - _buildOptions: function () { let selectOptions = (name, event) => { // Flip back to the last used panel if we are already @@ -2214,7 +2196,9 @@ Toolbox.prototype = { gDevTools.off("tool-registered", this._toolRegistered); gDevTools.off("tool-unregistered", this._toolUnregistered); - gDevTools.off("pref-changed", this._prefChanged); + Services.prefs.removeObserver("devtools.cache.disabled", this._applyCacheSettings); + Services.prefs.removeObserver("devtools.serviceWorkers.testing.enabled", + this._applyServiceWorkersTestingSettings); this._lastFocusedElement = null; if (this._sourceMapService) { diff --git a/devtools/client/inspector/computed/computed.js b/devtools/client/inspector/computed/computed.js index f89c99fdff34..12be8ed03b30 100644 --- a/devtools/client/inspector/computed/computed.js +++ b/devtools/client/inspector/computed/computed.js @@ -198,14 +198,13 @@ function CssComputedView(inspector, document, pageStyle) { // No results text. this.noResults = this.styleDocument.getElementById("computedview-no-results"); - // Refresh panel when color unit changed. + // Refresh panel when color unit changed or pref for showing + // original sources changes. this._handlePrefChange = this._handlePrefChange.bind(this); - gDevTools.on("pref-changed", this._handlePrefChange); - - // Refresh panel when pref for showing original sources changes this._onSourcePrefChanged = this._onSourcePrefChanged.bind(this); this._prefObserver = new PrefObserver("devtools."); this._prefObserver.on(PREF_ORIG_SOURCES, this._onSourcePrefChanged); + this._prefObserver.on("devtools.defaultColorUnit", this._handlePrefChange); // The element that we're inspecting, and the document that it comes from. this._viewedElement = null; @@ -262,8 +261,7 @@ CssComputedView.prototype = { }, _handlePrefChange: function (event, data) { - if (this._computed && (data.pref === "devtools.defaultColorUnit" || - data.pref === PREF_ORIG_SOURCES)) { + if (this._computed) { this.refreshPanel(); } }, @@ -600,6 +598,7 @@ CssComputedView.prototype = { }, _onSourcePrefChanged: function () { + this._handlePrefChange(); for (let propView of this.propertyViews) { propView.updateSourceLinks(); } @@ -734,9 +733,8 @@ CssComputedView.prototype = { this._viewedElement = null; this._outputParser = null; - gDevTools.off("pref-changed", this._handlePrefChange); - this._prefObserver.off(PREF_ORIG_SOURCES, this._onSourcePrefChanged); + this._prefObserver.off("devtools.defaultColorUnit", this._handlePrefChange); this._prefObserver.destroy(); // Cancel tree construction diff --git a/devtools/client/performance/performance-controller.js b/devtools/client/performance/performance-controller.js index e47a0c4010d5..7d2295fa5419 100644 --- a/devtools/client/performance/performance-controller.js +++ b/devtools/client/performance/performance-controller.js @@ -16,7 +16,7 @@ var { loader, require } = BrowserLoaderModule.BrowserLoader({ var { Task } = require("devtools/shared/task"); /* exported Heritage, ViewHelpers, WidgetMethods, setNamedTimeout, clearNamedTimeout */ var { Heritage, ViewHelpers, WidgetMethods, setNamedTimeout, clearNamedTimeout } = require("devtools/client/shared/widgets/view-helpers"); -var { gDevTools } = require("devtools/client/framework/devtools"); +var { PrefObserver } = require("devtools/client/shared/prefs"); // Events emitted by various objects in the panel. var EVENTS = require("devtools/client/performance/events"); @@ -143,7 +143,8 @@ var PerformanceController = { RecordingsView.on(EVENTS.UI_RECORDING_SELECTED, this._onRecordingSelectFromView); DetailsView.on(EVENTS.UI_DETAILS_VIEW_SELECTED, this._pipe); - gDevTools.on("pref-changed", this._onThemeChanged); + this._prefObserver = new PrefObserver("devtools."); + this._prefObserver.on("devtools.theme", this._onThemeChanged); }), /** @@ -163,7 +164,8 @@ var PerformanceController = { RecordingsView.off(EVENTS.UI_RECORDING_SELECTED, this._onRecordingSelectFromView); DetailsView.off(EVENTS.UI_DETAILS_VIEW_SELECTED, this._pipe); - gDevTools.off("pref-changed", this._onThemeChanged); + this._prefObserver.off("devtools.theme", this._onThemeChanged); + this._prefObserver.destroy(); }, /** @@ -402,14 +404,9 @@ var PerformanceController = { /* * Called when the developer tools theme changes. */ - _onThemeChanged: function (_, data) { - // Right now, gDevTools only emits `pref-changed` for the theme, - // but this could change in the future. - if (data.pref !== "devtools.theme") { - return; - } - - this.emit(EVENTS.THEME_CHANGED, data.newValue); + _onThemeChanged: function () { + let newValue = Services.prefs.getCharPref("devtools.theme"); + this.emit(EVENTS.THEME_CHANGED, newValue); }, /** diff --git a/devtools/client/shared/autocomplete-popup.js b/devtools/client/shared/autocomplete-popup.js index 1d24c948ef00..6b44ea528ebe 100644 --- a/devtools/client/shared/autocomplete-popup.js +++ b/devtools/client/shared/autocomplete-popup.js @@ -7,9 +7,9 @@ const HTML_NS = "http://www.w3.org/1999/xhtml"; const Services = require("Services"); -const {gDevTools} = require("devtools/client/framework/devtools"); const {HTMLTooltip} = require("devtools/client/shared/widgets/tooltip/HTMLTooltip"); const EventEmitter = require("devtools/shared/event-emitter"); +const {PrefObserver} = require("devtools/client/shared/prefs"); let itemIdCounter = 0; /** @@ -47,7 +47,9 @@ function AutocompletePopup(toolboxDoc, options = {}) { this.autoThemeEnabled = true; // Setup theme change listener. this._handleThemeChange = this._handleThemeChange.bind(this); - gDevTools.on("pref-changed", this._handleThemeChange); + this._prefObserver = new PrefObserver("devtools."); + this._prefObserver.on("devtools.theme", this._handleThemeChange); + this._currentTheme = theme; } // Create HTMLTooltip instance @@ -194,7 +196,8 @@ AutocompletePopup.prototype = { this._list.removeEventListener("click", this.onClick, false); if (this.autoThemeEnabled) { - gDevTools.off("pref-changed", this._handleThemeChange); + this._prefObserver.off("devtools.theme", this._handleThemeChange); + this._prefObserver.destroy(); } this._list.remove(); @@ -562,25 +565,17 @@ AutocompletePopup.prototype = { /** * Manages theme switching for the popup based on the devtools.theme pref. - * - * @private - * - * @param {String} event - * The name of the event. In this case, "pref-changed". - * @param {Object} data - * An object passed by the emitter of the event. In this case, the - * object consists of three properties: - * - pref {String} The name of the preference that was modified. - * - newValue {Object} The new value of the preference. - * - oldValue {Object} The old value of the preference. */ - _handleThemeChange: function (event, data) { - if (data.pref === "devtools.theme") { - this._tooltip.panel.classList.toggle(data.oldValue + "-theme", false); - this._tooltip.panel.classList.toggle(data.newValue + "-theme", true); - this._list.classList.toggle(data.oldValue + "-theme", false); - this._list.classList.toggle(data.newValue + "-theme", true); - } + _handleThemeChange: function () { + const oldValue = this._currentTheme; + const newValue = Services.prefs.getCharPref("devtools.theme"); + + this._tooltip.panel.classList.toggle(oldValue + "-theme", false); + this._tooltip.panel.classList.toggle(newValue + "-theme", true); + this._list.classList.toggle(oldValue + "-theme", false); + this._list.classList.toggle(newValue + "-theme", true); + + this._currentTheme = newValue; }, /** diff --git a/devtools/client/shared/test/browser_theme.js b/devtools/client/shared/test/browser_theme.js index 174e5aeec93f..c76503487e29 100644 --- a/devtools/client/shared/test/browser_theme.js +++ b/devtools/client/shared/test/browser_theme.js @@ -7,6 +7,7 @@ // Tests that theme utilities work const {getColor, getTheme, setTheme} = require("devtools/client/shared/theme"); +const {PrefObserver} = require("devtools/client/shared/prefs"); add_task(function* () { testGetTheme(); @@ -31,13 +32,14 @@ function testGetTheme() { function testSetTheme() { let originalTheme = getTheme(); - gDevTools.once("pref-changed", (_, { pref, oldValue, newValue }) => { + + let prefObserver = new PrefObserver("devtools."); + prefObserver.once("devtools.theme", pref => { is(pref, "devtools.theme", - "The 'pref-changed' event triggered by setTheme has correct pref."); - is(oldValue, originalTheme, - "The 'pref-changed' event triggered by setTheme has correct oldValue."); + "A preference event triggered by setTheme has correct pref."); + let newValue = Services.prefs.getCharPref("devtools.theme"); is(newValue, "dark", - "The 'pref-changed' event triggered by setTheme has correct newValue."); + "A preference event triggered by setTheme comes after the value is set."); }); setTheme("dark"); is(Services.prefs.getCharPref("devtools.theme"), "dark", @@ -52,6 +54,8 @@ function testSetTheme() { is(Services.prefs.getCharPref("devtools.theme"), "unknown", "setTheme() correctly sets an unknown theme."); Services.prefs.setCharPref("devtools.theme", originalTheme); + + prefObserver.destroy(); } function testGetColor() { diff --git a/devtools/client/shared/theme.js b/devtools/client/shared/theme.js index 6ba956f64be3..8fe9fceef782 100644 --- a/devtools/client/shared/theme.js +++ b/devtools/client/shared/theme.js @@ -10,7 +10,6 @@ */ const Services = require("Services"); -const { gDevTools } = require("devtools/client/framework/devtools"); const variableFileContents = require("raw!devtools/client/themes/variables.css"); @@ -67,18 +66,9 @@ const getColor = exports.getColor = (type, theme) => { }; /** - * Mimics selecting the theme selector in the toolbox; - * sets the preference and emits an event on gDevTools to trigger - * the themeing. + * Set the theme preference. */ const setTheme = exports.setTheme = (newTheme) => { - let oldTheme = getTheme(); - Services.prefs.setCharPref("devtools.theme", newTheme); - gDevTools.emit("pref-changed", { - pref: "devtools.theme", - newValue: newTheme, - oldValue: oldTheme - }); }; /* eslint-enable */ diff --git a/devtools/client/webaudioeditor/controller.js b/devtools/client/webaudioeditor/controller.js index 248a2a6f3524..efefc9c1598f 100644 --- a/devtools/client/webaudioeditor/controller.js +++ b/devtools/client/webaudioeditor/controller.js @@ -2,6 +2,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/. */ +const {PrefObserver} = require("devtools/client/shared/prefs"); + /** * A collection of `AudioNodeModel`s used throughout the editor * to keep track of audio nodes within the audio context. @@ -58,7 +60,9 @@ var WebAudioEditorController = { // Hook into theme change so we can change // the graph's marker styling, since we can't do this // with CSS - gDevTools.on("pref-changed", this._onThemeChange); + + this._prefObserver = new PrefObserver(""); + this._prefObserver.on("devtools.theme", this._onThemeChange); // Store the AudioNode definitions from the WebAudioFront, if the method exists. // If not, get the JSON directly. Using the actor method is preferable so the client @@ -90,7 +94,8 @@ var WebAudioEditorController = { gFront.off("disconnect-node", this._onDisconnectNode); gFront.off("change-param", this._onChangeParam); gFront.off("destroy-node", this._onDestroyNode); - gDevTools.off("pref-changed", this._onThemeChange); + this._prefObserver.off("devtools.theme", this._onThemeChange); + this._prefObserver.destroy(); }, /** @@ -129,8 +134,9 @@ var WebAudioEditorController = { * so that the graph can update marker styling, as that * cannot currently be done with CSS. */ - _onThemeChange: function (event, data) { - window.emit(EVENTS.THEME_CHANGE, data.newValue); + _onThemeChange: function () { + let newValue = Services.prefs.getCharPref("devtools.theme"); + window.emit(EVENTS.THEME_CHANGE, newValue); }, /** diff --git a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js index 7de7dbe0009c..9866db3e6d7f 100644 --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_timestamps.js @@ -8,6 +8,8 @@ "use strict"; +const {PrefObserver} = require("devtools/client/shared/prefs"); + const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " + "bug 1307871 - preference for toggling timestamps in messages"; const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; @@ -19,9 +21,11 @@ add_task(function* () { testPrefDefaults(outputEl); + let observer = new PrefObserver(""); let toolbox = gDevTools.getToolbox(hud.target); let optionsPanel = yield toolbox.selectTool("options"); - yield togglePref(optionsPanel); + yield togglePref(optionsPanel, observer); + observer.destroy(); yield testChangedPref(outputEl); @@ -35,13 +39,11 @@ function testPrefDefaults(outputEl) { "Messages should have no timestamp (class name check)"); } -function* togglePref(panel) { +function* togglePref(panel, observer) { info("Options panel opened"); info("Changing pref"); - let prefChanged = new Promise(resolve => { - gDevTools.once("pref-changed", resolve); - }); + let prefChanged = observer.once(PREF_MESSAGE_TIMESTAMP, () => {}); let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); checkbox.click(); diff --git a/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js b/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js index 192387e8adea..35ce7d9dd3cd 100644 --- a/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js +++ b/devtools/client/webconsole/test/browser_webconsole_expandable_timestamps.js @@ -8,6 +8,8 @@ "use strict"; +const {PrefObserver} = require("devtools/client/shared/prefs"); + const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " + "bug 722267 - preference for toggling timestamps in messages"; const PREF_MESSAGE_TIMESTAMP = "devtools.webconsole.timestampMessages"; @@ -19,8 +21,10 @@ add_task(function* () { hud = yield openConsole(); let panel = yield consoleOpened(); - yield onOptionsPanelSelected(panel); + let observer = new PrefObserver(""); + yield onOptionsPanelSelected(panel, observer); onPrefChanged(); + observer.destroy(); Services.prefs.clearUserPref(PREF_MESSAGE_TIMESTAMP); hud = null; @@ -37,10 +41,10 @@ function consoleOpened() { return toolbox.selectTool("options"); } -function onOptionsPanelSelected(panel) { +function onOptionsPanelSelected(panel, observer) { info("options panel opened"); - let prefChanged = gDevTools.once("pref-changed", onPrefChanged); + let prefChanged = observer.once(PREF_MESSAGE_TIMESTAMP, () => {}); let checkbox = panel.panelDoc.getElementById("webconsole-timestamp-messages"); checkbox.click(); diff --git a/devtools/client/webconsole/webconsole.js b/devtools/client/webconsole/webconsole.js index 236b5f25e9db..214ac4620db6 100644 --- a/devtools/client/webconsole/webconsole.js +++ b/devtools/client/webconsole/webconsole.js @@ -17,6 +17,7 @@ Cu.import("resource://devtools/client/shared/browser-loader.js", BrowserLoaderMo const promise = require("promise"); const Services = require("Services"); const Telemetry = require("devtools/client/shared/telemetry"); +const {PrefObserver} = require("devtools/client/shared/prefs"); loader.lazyServiceGetter(this, "clipboardHelper", "@mozilla.org/widget/clipboardhelper;1", @@ -636,11 +637,9 @@ WebConsoleFrame.prototype = { }); // Toggle the timestamp on preference change - gDevTools.on("pref-changed", this._onToolboxPrefChanged); - this._onToolboxPrefChanged("pref-changed", { - pref: PREF_MESSAGE_TIMESTAMP, - newValue: Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP), - }); + this._prefObserver = new PrefObserver(""); + this._prefObserver.on(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged); + this._onToolboxPrefChanged(); this._initShortcuts(); @@ -2691,25 +2690,16 @@ WebConsoleFrame.prototype = { }, /** - * Handler for the pref-changed event coming from the toolbox. - * Currently this function only handles the timestamps preferences. - * - * @private - * @param object event - * This parameter is a string that holds the event name - * pref-changed in this case. - * @param object data - * This is the pref-changed data object. - */ - _onToolboxPrefChanged: function (event, data) { - if (data.pref == PREF_MESSAGE_TIMESTAMP) { - if (this.NEW_CONSOLE_OUTPUT_ENABLED) { - this.newConsoleOutput.dispatchTimestampsToggle(data.newValue); - } else if (data.newValue) { - this.outputNode.classList.remove("hideTimestamps"); - } else { - this.outputNode.classList.add("hideTimestamps"); - } + * Called when the message timestamp pref changes. + */ + _onToolboxPrefChanged: function () { + let newValue = Services.prefs.getBoolPref(PREF_MESSAGE_TIMESTAMP); + if (this.NEW_CONSOLE_OUTPUT_ENABLED) { + this.newConsoleOutput.dispatchTimestampsToggle(newValue); + } else if (newValue) { + this.outputNode.classList.remove("hideTimestamps"); + } else { + this.outputNode.classList.add("hideTimestamps"); } }, @@ -2818,7 +2808,8 @@ WebConsoleFrame.prototype = { toolbox.off("webconsole-selected", this._onPanelSelected); } - gDevTools.off("pref-changed", this._onToolboxPrefChanged); + this._prefObserver.off(PREF_MESSAGE_TIMESTAMP, this._onToolboxPrefChanged); + this._prefObserver.destroy(); this.window.removeEventListener("resize", this.resize, true); this._repeatNodes = {}; From 8caa8a245972dad47aea9c36e756aa42b4e69d97 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Fri, 25 Nov 2016 17:51:13 +1300 Subject: [PATCH 08/27] bug 1319650 implement pre-3.20 MOZ_GTK_PROGRESS_CHUNK in WidgetStyleCache r=stransky+263117 MozReview-Commit-ID: 1VOZKRw3gj4 --HG-- extra : rebase_source : 97cf866ee58a6b06b0bcfa850a50e3a24304d70d --- widget/gtk/WidgetStyleCache.cpp | 7 +++++++ widget/gtk/gtk3drawing.cpp | 13 ++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/widget/gtk/WidgetStyleCache.cpp b/widget/gtk/WidgetStyleCache.cpp index 2292bfafb017..8b06b60205d6 100644 --- a/widget/gtk/WidgetStyleCache.cpp +++ b/widget/gtk/WidgetStyleCache.cpp @@ -997,6 +997,13 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_PROGRESS_TROUGH: return GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, GTK_STYLE_CLASS_TROUGH); + case MOZ_GTK_PROGRESS_CHUNK: { + GtkStyleContext* style = + GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, + GTK_STYLE_CLASS_PROGRESSBAR); + gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); + return style; + } case MOZ_GTK_GRIPPER: return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER, GTK_STYLE_CLASS_GRIP); diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp index 220a7dc56015..32f090a26ddb 100644 --- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -1376,17 +1376,8 @@ moz_gtk_progress_chunk_paint(cairo_t *cr, GdkRectangle* rect, GtkTextDirection direction, WidgetNodeType widget) { - GtkStyleContext* style; - - if (gtk_check_version(3, 20, 0) != nullptr) { - /* Ask for MOZ_GTK_PROGRESS_TROUGH instead of MOZ_GTK_PROGRESSBAR - * because ClaimStyleContext() saves/restores that style */ - style = ClaimStyleContext(MOZ_GTK_PROGRESS_TROUGH, direction); - gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); - gtk_style_context_add_class(style, GTK_STYLE_CLASS_PROGRESSBAR); - } else { - style = ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction); - } + GtkStyleContext* style = + ClaimStyleContext(MOZ_GTK_PROGRESS_CHUNK, direction); if (widget == MOZ_GTK_PROGRESS_CHUNK_INDETERMINATE || widget == MOZ_GTK_PROGRESS_CHUNK_VERTICAL_INDETERMINATE) { From ae355be79919c19139570ca545ff367f0dca0625 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Wed, 23 Nov 2016 16:41:57 +1300 Subject: [PATCH 09/27] bug 1319650 mimic gtk_style_context_save() in WidgetStyleCache with a new context r=stransky+263117 This makes balancing with gtk_style_context_restore()/ReleaseStyleContext() unnecessary, and the style resolution cached in the style contexts is not invalidated so frequently. MozReview-Commit-ID: BKwyqoQsjv2 --HG-- extra : rebase_source : 44c82ff74e1e52046799659f3bfa37c7faafeb58 --- widget/gtk/WidgetStyleCache.cpp | 279 +++++++++++++++++++------------- widget/gtk/mozgtk/mozgtk.c | 1 + 2 files changed, 168 insertions(+), 112 deletions(-) diff --git a/widget/gtk/WidgetStyleCache.cpp b/widget/gtk/WidgetStyleCache.cpp index 8b06b60205d6..28781789c69b 100644 --- a/widget/gtk/WidgetStyleCache.cpp +++ b/widget/gtk/WidgetStyleCache.cpp @@ -20,10 +20,6 @@ static_assert(GTK_STATE_FLAG_DIR_LTR == STATE_FLAG_DIR_LTR && static GtkWidget* sWidgetStorage[MOZ_GTK_WIDGET_NODE_COUNT]; static GtkStyleContext* sStyleStorage[MOZ_GTK_WIDGET_NODE_COUNT]; -static bool sStyleContextNeedsRestore; -#ifdef DEBUG -static GtkStyleContext* sCurrentStyleContext; -#endif static GtkStyleContext* GetWidgetRootStyle(WidgetNodeType aNodeType); static GtkStyleContext* @@ -631,6 +627,16 @@ GetWidget(WidgetNodeType aWidgetType) return widget; } +static void +AddStyleClassesFromStyle(GtkStyleContext* aDest, GtkStyleContext* aSrc) +{ + GList* classes = gtk_style_context_list_classes(aSrc); + for (GList* link = classes; link; link = link->next) { + gtk_style_context_add_class(aDest, static_cast(link->data)); + } + g_list_free(classes); +} + GtkStyleContext* CreateStyleForWidget(GtkWidget* aWidget, GtkStyleContext* aParentStyle) { @@ -662,11 +668,7 @@ CreateStyleForWidget(GtkWidget* aWidget, GtkStyleContext* aParentStyle) // gtk_widget_path_append_for_widget() from finding classes in GTK 3.20, // is not a problem. GtkStyleContext* widgetStyle = gtk_widget_get_style_context(aWidget); - GList* classes = gtk_style_context_list_classes(widgetStyle); - for (GList* link = classes; link; link = link->next) { - gtk_style_context_add_class(context, static_cast(link->data)); - } - g_list_free(classes); + AddStyleClassesFromStyle(context, widgetStyle); // Release any floating reference on aWidget. g_object_ref_sink(aWidget); @@ -782,13 +784,58 @@ CreateChildCSSNode(const char* aName, WidgetNodeType aParentNodeType) return CreateCSSNode(aName, GetCssNodeStyleInternal(aParentNodeType)); } +// Create a style context equivalent to a saved root style context of +// |aWidgetType| with |aStyleClass| as an additional class. This is used to +// produce a context equivalent to what GTK versions < 3.20 use for many +// internal parts of widgets. static GtkStyleContext* -GetWidgetStyleWithClass(WidgetNodeType aWidgetType, const gchar* aStyleClass) +CreateSubStyleWithClass(WidgetNodeType aWidgetType, const gchar* aStyleClass) { - GtkStyleContext* style = GetWidgetRootStyle(aWidgetType); - gtk_style_context_save(style); - MOZ_ASSERT(!sStyleContextNeedsRestore); - sStyleContextNeedsRestore = true; + static auto sGtkWidgetPathIterGetObjectName = + reinterpret_cast + (dlsym(RTLD_DEFAULT, "gtk_widget_path_iter_get_object_name")); + + GtkStyleContext* parentStyle = GetWidgetRootStyle(aWidgetType); + + // Create a new context that behaves like |parentStyle| would after + // gtk_style_context_save(parentStyle). + // + // Avoiding gtk_style_context_save() avoids the need to manage the + // restore, and a new context permits caching style resolution. + // + // gtk_style_context_save(context) changes the node hierarchy of |context| + // to add a new GtkCssNodeDeclaration that is a copy of its original node. + // The new node is a child of the original node, and so the new heirarchy is + // one level deeper. The new node receives the same classes as the + // original, but any changes to the classes on |context| will change only + // the new node. The new node inherits properties from the original node + // (which retains the original heirarchy and classes) and matches CSS rules + // with the new heirarchy and any changes to the classes. + // + // The change in hierarchy can produce some surprises in matching theme CSS + // rules (e.g. https://bugzilla.gnome.org/show_bug.cgi?id=761870#c2), but it + // is important here to produce the same behavior so that rules match the + // same widget parts in Gecko as they do in GTK. + // + // When using public GTK API to construct style contexts, a widget path is + // required. CSS rules are not matched against the style context heirarchy + // but according to the heirarchy in the widget path. The path that matches + // the same CSS rules as a saved context is like the path of |parentStyle| + // but with an extra copy of the head (last) object appended. Setting + // |parentStyle| as the parent context provides the same inheritance of + // properties from the widget root node. + const GtkWidgetPath* parentPath = gtk_style_context_get_path(parentStyle); + const gchar* name = sGtkWidgetPathIterGetObjectName ? + sGtkWidgetPathIterGetObjectName(parentPath, -1) : nullptr; + GType objectType = gtk_widget_path_get_object_type(parentPath); + + GtkStyleContext* style = CreateCSSNode(name, parentStyle, objectType); + + // Start with the same classes on the new node as were on |parentStyle|. + // GTK puts no regions or junction_sides on widget root nodes, and so there + // is no need to copy these. + AddStyleClassesFromStyle(style, parentStyle); + gtk_style_context_add_class(style, aStyleClass); return style; } @@ -857,20 +904,24 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) break; case MOZ_GTK_GRIPPER: // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER, - GTK_STYLE_CLASS_GRIP); + style = CreateSubStyleWithClass(MOZ_GTK_GRIPPER, + GTK_STYLE_CLASS_GRIP); + break; case MOZ_GTK_INFO_BAR: // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_INFO_BAR, - GTK_STYLE_CLASS_INFO); + style = CreateSubStyleWithClass(MOZ_GTK_INFO_BAR, + GTK_STYLE_CLASS_INFO); + break; case MOZ_GTK_SPINBUTTON_ENTRY: // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_SPINBUTTON, - GTK_STYLE_CLASS_ENTRY); + style = CreateSubStyleWithClass(MOZ_GTK_SPINBUTTON, + GTK_STYLE_CLASS_ENTRY); + break; case MOZ_GTK_SCROLLED_WINDOW: // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, - GTK_STYLE_CLASS_FRAME); + style = CreateSubStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, + GTK_STYLE_CLASS_FRAME); + break; case MOZ_GTK_TEXT_VIEW_TEXT: case MOZ_GTK_RESIZER: style = CreateChildCSSNode("text", MOZ_GTK_TEXT_VIEW); @@ -891,12 +942,14 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) break; case MOZ_GTK_TREEVIEW_VIEW: // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_TREEVIEW, - GTK_STYLE_CLASS_VIEW); + style = CreateSubStyleWithClass(MOZ_GTK_TREEVIEW, + GTK_STYLE_CLASS_VIEW); + break; case MOZ_GTK_TREEVIEW_EXPANDER: // TODO - create from CSS node - return GetWidgetStyleWithClass(MOZ_GTK_TREEVIEW, - GTK_STYLE_CLASS_EXPANDER); + style = CreateSubStyleWithClass(MOZ_GTK_TREEVIEW, + GTK_STYLE_CLASS_EXPANDER); + break; case MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL: style = CreateChildCSSNode("separator", MOZ_GTK_SPLITTER_HORIZONTAL); @@ -932,7 +985,7 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_TAB_TOP: { // TODO - create from CSS node - style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, + style = CreateSubStyleWithClass(MOZ_GTK_NOTEBOOK, GTK_STYLE_CLASS_TOP); gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, static_cast(0)); @@ -941,7 +994,7 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) case MOZ_GTK_TAB_BOTTOM: { // TODO - create from CSS node - style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, + style = CreateSubStyleWithClass(MOZ_GTK_NOTEBOOK, GTK_STYLE_CLASS_BOTTOM); gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, static_cast(0)); @@ -969,106 +1022,121 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType) static GtkStyleContext* GetWidgetStyleInternal(WidgetNodeType aNodeType) { + GtkStyleContext* style = sStyleStorage[aNodeType]; + if (style) + return style; + switch (aNodeType) { case MOZ_GTK_SCROLLBAR_TROUGH_HORIZONTAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCROLLBAR_HORIZONTAL, - GTK_STYLE_CLASS_TROUGH); + style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_HORIZONTAL, + GTK_STYLE_CLASS_TROUGH); + break; case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCROLLBAR_HORIZONTAL, - GTK_STYLE_CLASS_SLIDER); + style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_HORIZONTAL, + GTK_STYLE_CLASS_SLIDER); + break; case MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCROLLBAR_VERTICAL, - GTK_STYLE_CLASS_TROUGH); + style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_VERTICAL, + GTK_STYLE_CLASS_TROUGH); + break; case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCROLLBAR_VERTICAL, - GTK_STYLE_CLASS_SLIDER); + style = CreateSubStyleWithClass(MOZ_GTK_SCROLLBAR_VERTICAL, + GTK_STYLE_CLASS_SLIDER); + break; case MOZ_GTK_RADIOBUTTON: - return GetWidgetStyleWithClass(MOZ_GTK_RADIOBUTTON_CONTAINER, - GTK_STYLE_CLASS_RADIO); + style = CreateSubStyleWithClass(MOZ_GTK_RADIOBUTTON_CONTAINER, + GTK_STYLE_CLASS_RADIO); + break; case MOZ_GTK_CHECKBUTTON: - return GetWidgetStyleWithClass(MOZ_GTK_CHECKBUTTON_CONTAINER, - GTK_STYLE_CLASS_CHECK); + style = CreateSubStyleWithClass(MOZ_GTK_CHECKBUTTON_CONTAINER, + GTK_STYLE_CLASS_CHECK); + break; case MOZ_GTK_RADIOMENUITEM_INDICATOR: - return GetWidgetStyleWithClass(MOZ_GTK_RADIOMENUITEM, - GTK_STYLE_CLASS_RADIO); + style = CreateSubStyleWithClass(MOZ_GTK_RADIOMENUITEM, + GTK_STYLE_CLASS_RADIO); + break; case MOZ_GTK_CHECKMENUITEM_INDICATOR: - return GetWidgetStyleWithClass(MOZ_GTK_CHECKMENUITEM, - GTK_STYLE_CLASS_CHECK); + style = CreateSubStyleWithClass(MOZ_GTK_CHECKMENUITEM, + GTK_STYLE_CLASS_CHECK); + break; case MOZ_GTK_PROGRESS_TROUGH: - return GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, - GTK_STYLE_CLASS_TROUGH); - case MOZ_GTK_PROGRESS_CHUNK: { - GtkStyleContext* style = - GetWidgetStyleWithClass(MOZ_GTK_PROGRESSBAR, - GTK_STYLE_CLASS_PROGRESSBAR); + style = CreateSubStyleWithClass(MOZ_GTK_PROGRESSBAR, + GTK_STYLE_CLASS_TROUGH); + break; + case MOZ_GTK_PROGRESS_CHUNK: + style = CreateSubStyleWithClass(MOZ_GTK_PROGRESSBAR, + GTK_STYLE_CLASS_PROGRESSBAR); gtk_style_context_remove_class(style, GTK_STYLE_CLASS_TROUGH); - return style; - } + break; case MOZ_GTK_GRIPPER: - return GetWidgetStyleWithClass(MOZ_GTK_GRIPPER, - GTK_STYLE_CLASS_GRIP); + style = CreateSubStyleWithClass(MOZ_GTK_GRIPPER, + GTK_STYLE_CLASS_GRIP); + break; case MOZ_GTK_INFO_BAR: - return GetWidgetStyleWithClass(MOZ_GTK_INFO_BAR, - GTK_STYLE_CLASS_INFO); + style = CreateSubStyleWithClass(MOZ_GTK_INFO_BAR, + GTK_STYLE_CLASS_INFO); + break; case MOZ_GTK_SPINBUTTON_ENTRY: - return GetWidgetStyleWithClass(MOZ_GTK_SPINBUTTON, - GTK_STYLE_CLASS_ENTRY); + style = CreateSubStyleWithClass(MOZ_GTK_SPINBUTTON, + GTK_STYLE_CLASS_ENTRY); + break; case MOZ_GTK_SCROLLED_WINDOW: - return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, - GTK_STYLE_CLASS_FRAME); + style = CreateSubStyleWithClass(MOZ_GTK_SCROLLED_WINDOW, + GTK_STYLE_CLASS_FRAME); + break; case MOZ_GTK_TEXT_VIEW_TEXT: - case MOZ_GTK_RESIZER: { + case MOZ_GTK_RESIZER: // GTK versions prior to 3.20 do not have the view class on the root // node, but add this to determine the background for the text window. - GtkStyleContext* style = - GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, GTK_STYLE_CLASS_VIEW); + style = CreateSubStyleWithClass(MOZ_GTK_TEXT_VIEW, GTK_STYLE_CLASS_VIEW); if (aNodeType == MOZ_GTK_RESIZER) { gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP); } - return style; - } + break; case MOZ_GTK_FRAME_BORDER: return GetWidgetRootStyle(MOZ_GTK_FRAME); case MOZ_GTK_TREEVIEW_VIEW: - return GetWidgetStyleWithClass(MOZ_GTK_TREEVIEW, - GTK_STYLE_CLASS_VIEW); + style = CreateSubStyleWithClass(MOZ_GTK_TREEVIEW, + GTK_STYLE_CLASS_VIEW); + break; case MOZ_GTK_TREEVIEW_EXPANDER: - return GetWidgetStyleWithClass(MOZ_GTK_TREEVIEW, - GTK_STYLE_CLASS_EXPANDER); + style = CreateSubStyleWithClass(MOZ_GTK_TREEVIEW, + GTK_STYLE_CLASS_EXPANDER); + break; case MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL: - return GetWidgetStyleWithClass(MOZ_GTK_SPLITTER_HORIZONTAL, - GTK_STYLE_CLASS_PANE_SEPARATOR); + style = CreateSubStyleWithClass(MOZ_GTK_SPLITTER_HORIZONTAL, + GTK_STYLE_CLASS_PANE_SEPARATOR); + break; case MOZ_GTK_SPLITTER_SEPARATOR_VERTICAL: - return GetWidgetStyleWithClass(MOZ_GTK_SPLITTER_VERTICAL, - GTK_STYLE_CLASS_PANE_SEPARATOR); + style = CreateSubStyleWithClass(MOZ_GTK_SPLITTER_VERTICAL, + GTK_STYLE_CLASS_PANE_SEPARATOR); + break; case MOZ_GTK_SCALE_TROUGH_HORIZONTAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCALE_HORIZONTAL, - GTK_STYLE_CLASS_TROUGH); + style = CreateSubStyleWithClass(MOZ_GTK_SCALE_HORIZONTAL, + GTK_STYLE_CLASS_TROUGH); + break; case MOZ_GTK_SCALE_TROUGH_VERTICAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCALE_VERTICAL, - GTK_STYLE_CLASS_TROUGH); + style = CreateSubStyleWithClass(MOZ_GTK_SCALE_VERTICAL, + GTK_STYLE_CLASS_TROUGH); + break; case MOZ_GTK_SCALE_THUMB_HORIZONTAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCALE_HORIZONTAL, - GTK_STYLE_CLASS_SLIDER); + style = CreateSubStyleWithClass(MOZ_GTK_SCALE_HORIZONTAL, + GTK_STYLE_CLASS_SLIDER); + break; case MOZ_GTK_SCALE_THUMB_VERTICAL: - return GetWidgetStyleWithClass(MOZ_GTK_SCALE_VERTICAL, - GTK_STYLE_CLASS_SLIDER); + style = CreateSubStyleWithClass(MOZ_GTK_SCALE_VERTICAL, + GTK_STYLE_CLASS_SLIDER); + break; case MOZ_GTK_TAB_TOP: - { - GtkStyleContext* style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, - GTK_STYLE_CLASS_TOP); + style = CreateSubStyleWithClass(MOZ_GTK_NOTEBOOK, GTK_STYLE_CLASS_TOP); gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, static_cast(0)); - return style; - } + break; case MOZ_GTK_TAB_BOTTOM: - { - GtkStyleContext* style = GetWidgetStyleWithClass(MOZ_GTK_NOTEBOOK, - GTK_STYLE_CLASS_BOTTOM); + style = CreateSubStyleWithClass(MOZ_GTK_NOTEBOOK, GTK_STYLE_CLASS_BOTTOM); gtk_style_context_add_region(style, GTK_STYLE_REGION_TAB, static_cast(0)); - return style; - } + break; case MOZ_GTK_NOTEBOOK: case MOZ_GTK_NOTEBOOK_HEADER: case MOZ_GTK_TABPANELS: @@ -1080,16 +1148,15 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType) default: return GetWidgetRootStyle(aNodeType); } + + MOZ_ASSERT(style); + sStyleStorage[aNodeType] = style; + return style; } void ResetWidgetCache(void) { - MOZ_ASSERT(!sStyleContextNeedsRestore); -#ifdef DEBUG - MOZ_ASSERT(!sCurrentStyleContext); -#endif - for (int i = 0; i < MOZ_GTK_WIDGET_NODE_COUNT; i++) { if (sStyleStorage[i]) g_object_unref(sStyleStorage[i]); @@ -1108,17 +1175,12 @@ GtkStyleContext* ClaimStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection, GtkStateFlags aStateFlags, StyleFlags aFlags) { - MOZ_ASSERT(!sStyleContextNeedsRestore); GtkStyleContext* style; if (gtk_check_version(3, 20, 0) != nullptr) { style = GetWidgetStyleInternal(aNodeType); } else { style = GetCssNodeStyleInternal(aNodeType); } -#ifdef DEBUG - MOZ_ASSERT(!sCurrentStyleContext); - sCurrentStyleContext = style; -#endif bool stateChanged = false; bool stateHasDirection = gtk_get_minor_version() >= 8; GtkStateFlags oldState = gtk_style_context_get_state(style); @@ -1158,9 +1220,10 @@ ClaimStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection, // // https://bugzilla.mozilla.org/show_bug.cgi?id=1272194#c7 // - // Avoid calling invalidate on saved contexts to avoid performing - // build_properties() (in 3.16 stylecontext.c) unnecessarily early. - if (stateChanged && !sStyleContextNeedsRestore) { + // Avoid calling invalidate on contexts that are not owned and constructed + // by widgets to avoid performing build_properties() (in 3.16 stylecontext.c) + // unnecessarily early. + if (stateChanged && sWidgetStorage[aNodeType]) { gtk_style_context_invalidate(style); } return style; @@ -1169,12 +1232,4 @@ ClaimStyleContext(WidgetNodeType aNodeType, GtkTextDirection aDirection, void ReleaseStyleContext(GtkStyleContext* aStyleContext) { - if (sStyleContextNeedsRestore) { - gtk_style_context_restore(aStyleContext); - } - sStyleContextNeedsRestore = false; -#ifdef DEBUG - MOZ_ASSERT(sCurrentStyleContext == aStyleContext); - sCurrentStyleContext = nullptr; -#endif } diff --git a/widget/gtk/mozgtk/mozgtk.c b/widget/gtk/mozgtk/mozgtk.c index 8b629434e631..d7d3a66d9665 100644 --- a/widget/gtk/mozgtk/mozgtk.c +++ b/widget/gtk/mozgtk/mozgtk.c @@ -581,6 +581,7 @@ STUB(gtk_widget_path_append_type) STUB(gtk_widget_path_copy) STUB(gtk_widget_path_free) STUB(gtk_widget_path_iter_add_class) +STUB(gtk_widget_path_get_object_type) STUB(gtk_widget_path_new) STUB(gtk_widget_path_unref) STUB(gtk_widget_set_visual) From 450ffed1e46bcc7a4d624396bb653e5245685265 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Tue, 29 Nov 2016 18:50:20 +1300 Subject: [PATCH 10/27] bug 1319650 draw tab gap with tabpanel style context r=stransky+263117 This is more consistent with moz_gtk_tabpanels_paint() and avoids modifying the tab style context. MozReview-Commit-ID: HpKSVrpvO9b --HG-- extra : rebase_source : 4b3acb6ae1f2ad5fdd7bfb3e54dd75ef1a8041a3 --- widget/gtk/gtk3drawing.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp index 32f090a26ddb..cd9f2beb1f32 100644 --- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -1515,8 +1515,8 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, * . outside of the tab . v * ---------------------------------------------- * - * To draw the gap, we use gtk_paint_box_gap(), see comment in - * moz_gtk_tabpanels_paint(). This box_gap is made 3 * gap_height tall, + * To draw the gap, we use gtk_render_frame_gap(), see comment in + * moz_gtk_tabpanels_paint(). This gap is made 3 * gap_height tall, * which should suffice to ensure that the only visible border is the * pierced one. If the tab is in the middle, we make the box_gap begin * a bit to the left of the tab and end a bit to the right, adjusting @@ -1545,6 +1545,9 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, gap_loffset = initial_gap; } + GtkStyleContext* panelStyle = + ClaimStyleContext(MOZ_GTK_TABPANELS, direction); + if (isBottomTab) { /* Draw the tab on bottom */ focusRect.y += gap_voffset; @@ -1554,20 +1557,18 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, tabRect.x, tabRect.y + gap_voffset, tabRect.width, tabRect.height - gap_voffset, GTK_POS_TOP); - gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB); - backRect.y += (gap_voffset - gap_height); backRect.height = gap_height; /* Draw the gap; erase with background color before painting in * case theme does not */ - gtk_render_background(style, cr, backRect.x, backRect.y, + gtk_render_background(panelStyle, cr, backRect.x, backRect.y, backRect.width, backRect.height); cairo_save(cr); cairo_rectangle(cr, backRect.x, backRect.y, backRect.width, backRect.height); cairo_clip(cr); - gtk_render_frame_gap(style, cr, + gtk_render_frame_gap(panelStyle, cr, tabRect.x - gap_loffset, tabRect.y + gap_voffset - 3 * gap_height, tabRect.width + gap_loffset + gap_roffset, @@ -1581,21 +1582,19 @@ moz_gtk_tab_paint(cairo_t *cr, GdkRectangle* rect, tabRect.x, tabRect.y, tabRect.width, tabRect.height - gap_voffset, GTK_POS_BOTTOM); - gtk_style_context_remove_region(style, GTK_STYLE_REGION_TAB); - backRect.y += (tabRect.height - gap_voffset); backRect.height = gap_height; /* Draw the gap; erase with background color before painting in * case theme does not */ - gtk_render_background(style, cr, backRect.x, backRect.y, + gtk_render_background(panelStyle, cr, backRect.x, backRect.y, backRect.width, backRect.height); cairo_save(cr); cairo_rectangle(cr, backRect.x, backRect.y, backRect.width, backRect.height); cairo_clip(cr); - gtk_render_frame_gap(style, cr, + gtk_render_frame_gap(panelStyle, cr, tabRect.x - gap_loffset, tabRect.y + tabRect.height - gap_voffset, tabRect.width + gap_loffset + gap_roffset, From 6fe0be02c7449a495a7e161d4b44315f756d199c Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 1 Dec 2016 14:13:16 -0500 Subject: [PATCH 11/27] Bug 1321614 - fix android_stuff kind to use build secrets, because it uses the same mozharness stuff as build jobs. r=dustin MozReview-Commit-ID: D6wV1KSa6mp --HG-- extra : rebase_source : ea2a3ad899d9e099631c0d06efceeaf260383f0a --- taskcluster/taskgraph/transforms/android_stuff.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/taskcluster/taskgraph/transforms/android_stuff.py b/taskcluster/taskgraph/transforms/android_stuff.py index cb1e0fa5b122..7e74b519bccb 100644 --- a/taskcluster/taskgraph/transforms/android_stuff.py +++ b/taskcluster/taskgraph/transforms/android_stuff.py @@ -8,6 +8,7 @@ Set dynamic task description properties of the android stuff. Temporary! from __future__ import absolute_import, print_function, unicode_literals from taskgraph.transforms.base import TransformSequence +from taskgraph.transforms.job.common import SECRET_SCOPE transforms = TransformSequence() @@ -42,5 +43,10 @@ def setup_task(config, tasks): 'mount-point': "/home/worker/workspace", }) + # Need appropriate scopes for secrets, from the 'build' section + task['worker']['taskcluster-proxy'] = True + task['scopes'].append(SECRET_SCOPE.format( + 'build', config.params['level'], '*')) + del task['name'] yield task From 5b80eb8f497f4ca96c1eb63d7f1a5a5bf2abd2ee Mon Sep 17 00:00:00 2001 From: Nicolas Chevobbe Date: Thu, 1 Dec 2016 19:47:36 +0100 Subject: [PATCH 12/27] Bug 1321518 - Fix requireHelper for enzyme. r=bgrins Bug 1312236 updated React to v15.3.2 which was making webconsole's mocha test fail. An error was thrown because the path and export we do in requireHelper to make enzyme able to call React functions was changed. We fix the require to ReactDOM by using the react-dom.js file, and we add the similar react-dom-server.js for ReactDOMServer functions. Tests now run like they used to. MozReview-Commit-ID: GXIQJPlqp4A --HG-- extra : rebase_source : 909bde919dd4d77d8910b4dba7392283f130333a --- devtools/client/shared/vendor/REACT_UPGRADING | 4 +- devtools/client/shared/vendor/moz.build | 1 + .../client/shared/vendor/react-dom-server.js | 42 +++++++++++++++++++ .../new-console-output/test/require-helper.js | 3 +- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 devtools/client/shared/vendor/react-dom-server.js diff --git a/devtools/client/shared/vendor/REACT_UPGRADING b/devtools/client/shared/vendor/REACT_UPGRADING index addae3e9ae34..0532ce93522c 100644 --- a/devtools/client/shared/vendor/REACT_UPGRADING +++ b/devtools/client/shared/vendor/REACT_UPGRADING @@ -51,9 +51,11 @@ version over: * cp build/react-with-addons.js /devtools/client/shared/vendor/react.js -You also need to copy the ReactDOM package. It requires React, so +You also need to copy the ReactDOM and ReactDOMServer package. It requires React, so right now we are just manually changing the path from `react` to `devtools/client/shared/vendor/react`. * cp build/react-dom.js /devtools/client/shared/vendor/react-dom.js * (change `require('react')` at the top of the file to the right path) +* cp build/react-dom.js /devtools/client/shared/vendor/react-dom-server.js +* (change `require('react')` at the top of the file to the right path) diff --git a/devtools/client/shared/vendor/moz.build b/devtools/client/shared/vendor/moz.build index e04221293855..d1bcf11ac944 100644 --- a/devtools/client/shared/vendor/moz.build +++ b/devtools/client/shared/vendor/moz.build @@ -16,6 +16,7 @@ if CONFIG['DEBUG_JS_MODULES'] or CONFIG['MOZ_DEBUG']: modules += ['react-dev.js'] modules += [ + 'react-dom-server.js', 'react-dom.js', 'react-proxy.js', 'react-redux.js', diff --git a/devtools/client/shared/vendor/react-dom-server.js b/devtools/client/shared/vendor/react-dom-server.js new file mode 100644 index 000000000000..3ce184378868 --- /dev/null +++ b/devtools/client/shared/vendor/react-dom-server.js @@ -0,0 +1,42 @@ +/** + * ReactDOMServer v15.3.2 + * + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ +// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js +;(function(f) { + // CommonJS + if (typeof exports === "object" && typeof module !== "undefined") { + module.exports = f(require('react')); + + // RequireJS + } else if (typeof define === "function" && define.amd) { + define(['react'], f); + + //