From 41610f2794e3565f3077b2fc8cd541308274ef3b Mon Sep 17 00:00:00 2001 From: dpapad Date: Tue, 12 Mar 2019 02:33:43 +0000 Subject: [PATCH] WebUI cleanup: Delete unused cr.ui.ContextMenuButton. c/b/r/ntp4/: Was including context_menu_button.js at runtime, but still does not seem it was actually used anywhere. ui/file_manager: Was declaring context_menu_button as a dependency for type-checking purposes, but the file was never included in the page at runtime. Bug: None Change-Id: I1e4c0b1c5ddac9e71c280d3ea8d47bb1636f14f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1513084 Reviewed-by: Luciano Pacheco Reviewed-by: Dan Beam Commit-Queue: Dan Beam Auto-Submit: Demetrios Papadopoulos Cr-Commit-Position: refs/heads/master@{#639776} --- chrome/browser/resources/ntp4/BUILD.gn | 1 - chrome/browser/resources/ntp4/new_tab.html | 1 - .../file_manager/foreground/js/BUILD.gn | 2 - .../file_manager/foreground/js/ui/BUILD.gn | 8 +- .../html/cr/ui/context_menu_button.html | 1 - ui/webui/resources/js/cr/ui/BUILD.gn | 7 -- .../resources/js/cr/ui/context_menu_button.js | 94 ------------------- ui/webui/resources/webui_resources.grd | 6 -- 8 files changed, 3 insertions(+), 117 deletions(-) delete mode 100644 ui/webui/resources/html/cr/ui/context_menu_button.html delete mode 100644 ui/webui/resources/js/cr/ui/context_menu_button.js diff --git a/chrome/browser/resources/ntp4/BUILD.gn b/chrome/browser/resources/ntp4/BUILD.gn index 7bd99669526bcf..af3b6cca0a1d67 100644 --- a/chrome/browser/resources/ntp4/BUILD.gn +++ b/chrome/browser/resources/ntp4/BUILD.gn @@ -23,7 +23,6 @@ js_library("apps_page") { "//ui/webui/resources/js/cr/ui/bubble.js", "//ui/webui/resources/js/cr/ui/card_slider.js", "//ui/webui/resources/js/cr/ui/command.js", - "//ui/webui/resources/js/cr/ui/context_menu_button.js", "//ui/webui/resources/js/cr/ui/context_menu_handler.js", "//ui/webui/resources/js/cr/ui/drag_wrapper.js", "//ui/webui/resources/js/cr/ui/expandable_bubble.js", diff --git a/chrome/browser/resources/ntp4/new_tab.html b/chrome/browser/resources/ntp4/new_tab.html index d6f57b23e2af59..1a017b05921b63 100644 --- a/chrome/browser/resources/ntp4/new_tab.html +++ b/chrome/browser/resources/ntp4/new_tab.html @@ -49,7 +49,6 @@ - diff --git a/ui/file_manager/file_manager/foreground/js/BUILD.gn b/ui/file_manager/file_manager/foreground/js/BUILD.gn index cabae49b59ee83..4209133064f43e 100644 --- a/ui/file_manager/file_manager/foreground/js/BUILD.gn +++ b/ui/file_manager/file_manager/foreground/js/BUILD.gn @@ -442,7 +442,6 @@ js_library("gear_menu_controller") { ":file_manager_commands", "../elements:files_toggle_ripple", "ui:gear_menu", - "//ui/webui/resources/js/cr/ui:context_menu_button", ] } @@ -679,7 +678,6 @@ js_library("sort_menu_controller") { deps = [ ":file_list_model", "../elements:files_toggle_ripple", - "//ui/webui/resources/js/cr/ui:context_menu_button", ] } diff --git a/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn b/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn index e9b135b7cb0122..91a98b428b89a7 100644 --- a/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn +++ b/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn @@ -147,7 +147,6 @@ js_library("directory_tree") { "../../../common/js:util", "../metadata:metadata_model", "//ui/file_manager/base/js:volume_manager_types", - "//ui/webui/resources/js/cr/ui:context_menu_button", "//ui/webui/resources/js/cr/ui:context_menu_handler", "//ui/webui/resources/js/cr/ui:menu", "//ui/webui/resources/js/cr/ui:tree", @@ -254,7 +253,6 @@ js_library("file_manager_ui") { "//ui/file_manager/file_manager/foreground/js:launch_param", "//ui/file_manager/file_manager/foreground/js:providers_model", "//ui/webui/resources/js:util", - "//ui/webui/resources/js/cr/ui:context_menu_button", "//ui/webui/resources/js/cr/ui:dialogs", "//ui/webui/resources/js/cr/ui:menu", ] @@ -301,13 +299,13 @@ js_library("file_table_list") { js_unittest("file_table_list_unittest") { deps = [ - ":file_table_list", ":file_table", + ":file_table_list", "../../../common/js:util", "//ui/file_manager/base/js:test_error_reporting", - "//ui/webui/resources/js:webui_resource_test", "//ui/file_manager/file_manager/background/js:mock_volume_manager", "//ui/file_manager/file_manager/foreground/js/metadata:mock_metadata", + "//ui/webui/resources/js:webui_resource_test", ] } @@ -473,10 +471,10 @@ js_unit_tests("unit_tests") { ":actions_submenu_unittest", ":directory_tree_unittest", ":file_list_selection_model_unittest", + ":file_table_list_unittest", ":file_table_unittest", ":file_tap_handler_unittest", ":list_container_unittest", - ":file_table_list_unittest", ":multi_menu_unittest", ] } diff --git a/ui/webui/resources/html/cr/ui/context_menu_button.html b/ui/webui/resources/html/cr/ui/context_menu_button.html deleted file mode 100644 index da2eec459d877f..00000000000000 --- a/ui/webui/resources/html/cr/ui/context_menu_button.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ui/webui/resources/js/cr/ui/BUILD.gn b/ui/webui/resources/js/cr/ui/BUILD.gn index 8e3229d1b28e98..6d250c7a241ce3 100644 --- a/ui/webui/resources/js/cr/ui/BUILD.gn +++ b/ui/webui/resources/js/cr/ui/BUILD.gn @@ -16,7 +16,6 @@ js_type_check("ui_resources") { ":array_data_model", ":autocomplete_list", ":command", - ":context_menu_button", ":context_menu_handler", ":dialogs", ":drag_wrapper", @@ -77,12 +76,6 @@ js_library("command") { ] } -js_library("context_menu_button") { - deps = [ - ":menu_button", - ] -} - js_library("context_menu_handler") { deps = [ ":menu", diff --git a/ui/webui/resources/js/cr/ui/context_menu_button.js b/ui/webui/resources/js/cr/ui/context_menu_button.js deleted file mode 100644 index 1c1bd27307f04e..00000000000000 --- a/ui/webui/resources/js/cr/ui/context_menu_button.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * @fileoverview This implements a special button that is useful for showing a - * context menu. - */ - -cr.define('cr.ui', function() { - /** @const */ const MenuButton = cr.ui.MenuButton; - - /** - * Helper function for ContextMenuButton to find the first ancestor of the - * button that has a context menu. - * @param {!cr.ui.MenuButton} button The button to start the search from. - * @return {HTMLElement} The found element or null if not found. - */ - function getContextMenuTarget(button) { - let el = button; - do { - el = el.parentNode; - } while (el && !('contextMenu' in el)); - return el ? assertInstanceof(el, HTMLElement) : null; - } - - /** - * Creates a new menu button which is used to show the context menu for an - * ancestor that has a {@code contextMenu} property. - * @param {Object=} opt_propertyBag Optional properties. - * @constructor - * @extends {cr.ui.MenuButton} - */ - const ContextMenuButton = cr.ui.define('button'); - - ContextMenuButton.prototype = { - __proto__: MenuButton.prototype, - - /** - * Override to return the contextMenu for the ancestor. - * @override - * @type {cr.ui.Menu} - */ - get menu() { - const target = getContextMenuTarget(this); - return target && target.contextMenu; - }, - - /** @override */ - decorate: function() { - this.tabIndex = -1; - this.addEventListener('mouseup', this); - MenuButton.prototype.decorate.call(this); - }, - - /** @override */ - handleEvent: function(e) { - switch (e.type) { - case 'mousedown': - // Menu buttons prevent focus changes. - const target = getContextMenuTarget(this); - if (target) { - target.focus(); - } - break; - case 'mouseup': - // Stop mouseup to prevent selection changes. - e.stopPropagation(); - break; - } - MenuButton.prototype.handleEvent.call(this, e); - }, - - /** - * Override MenuButton showMenu to allow the mousedown to be fully handled - * before the menu is shown. This is important in case the mousedown - * triggers command changes. - * @param {boolean} shouldSetFocus Whether the menu should be focused after - * the menu is shown. - * @param {{x: number, y: number}=} opt_mousePos The position of the mouse - * when shown (in screen coordinates). - * @override - */ - showMenu: function(shouldSetFocus, opt_mousePos) { - const self = this; - window.setTimeout(function() { - MenuButton.prototype.showMenu.call(self, shouldSetFocus, opt_mousePos); - }, 0); - } - }; - - // Export - return {ContextMenuButton: ContextMenuButton}; -}); diff --git a/ui/webui/resources/webui_resources.grd b/ui/webui/resources/webui_resources.grd index 0e8190ee6cc22c..354fc9de50fc34 100644 --- a/ui/webui/resources/webui_resources.grd +++ b/ui/webui/resources/webui_resources.grd @@ -292,9 +292,6 @@ without changes to the corresponding grd file. --> - @@ -406,9 +403,6 @@ without changes to the corresponding grd file. --> -