OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 WebInspector.InspectElementModeController.prototype = { | 49 WebInspector.InspectElementModeController.prototype = { |
50 /** | 50 /** |
51 * @override | 51 * @override |
52 * @param {!WebInspector.Target} target | 52 * @param {!WebInspector.Target} target |
53 */ | 53 */ |
54 targetAdded: function(target) | 54 targetAdded: function(target) |
55 { | 55 { |
56 // When DevTools are opening in the inspect element mode, the first targ
et comes in | 56 // When DevTools are opening in the inspect element mode, the first targ
et comes in |
57 // much later than the InspectorFrontendAPI.enterInspectElementMode even
t. | 57 // much later than the InspectorFrontendAPI.enterInspectElementMode even
t. |
58 if (!this.enabled()) | 58 if (!this.started()) |
59 return; | 59 return; |
60 var domModel = WebInspector.DOMModel.fromTarget(target); | 60 var domModel = WebInspector.DOMModel.fromTarget(target); |
61 domModel.setInspectMode(WebInspector.moduleSetting("showUAShadowDOM").ge
t() ? DOMAgent.InspectMode.SearchForUAShadowDOM : DOMAgent.InspectMode.SearchFor
Node); | 61 domModel.setInspectMode(WebInspector.moduleSetting("showUAShadowDOM").ge
t() ? DOMAgent.InspectMode.SearchForUAShadowDOM : DOMAgent.InspectMode.SearchFor
Node); |
62 }, | 62 }, |
63 | 63 |
64 /** | 64 /** |
65 * @override | 65 * @override |
66 * @param {!WebInspector.Target} target | 66 * @param {!WebInspector.Target} target |
67 */ | 67 */ |
68 targetRemoved: function(target) | 68 targetRemoved: function(target) |
69 { | 69 { |
70 }, | 70 }, |
71 | 71 |
72 /** | 72 /** |
73 * @return {boolean} | 73 * @return {boolean} |
74 */ | 74 */ |
75 enabled: function() | 75 started: function() |
76 { | 76 { |
77 return this._toggleSearchButton.toggled(); | 77 return this._toggleSearchButton.toggled(); |
78 }, | 78 }, |
79 | 79 |
| 80 stop: function() |
| 81 { |
| 82 if (this.started()) |
| 83 this._toggleSearch(); |
| 84 }, |
| 85 |
80 disable: function() | 86 disable: function() |
81 { | 87 { |
82 if (this.enabled()) | 88 this.stop(); |
83 this._toggleSearch(); | 89 this._toggleSearchButton.setEnabled(false); |
| 90 }, |
| 91 |
| 92 enable: function() |
| 93 { |
| 94 this._toggleSearchButton.setEnabled(true); |
84 }, | 95 }, |
85 | 96 |
86 _toggleSearch: function() | 97 _toggleSearch: function() |
87 { | 98 { |
88 var enabled = !this.enabled(); | 99 if (!this._toggleSearchButton.enabled()) |
89 this._toggleSearchButton.setToggled(enabled); | 100 return; |
| 101 |
| 102 var shouldEnable = !this.started(); |
| 103 this._toggleSearchButton.setToggled(shouldEnable); |
90 | 104 |
91 for (var domModel of WebInspector.DOMModel.instances()) { | 105 for (var domModel of WebInspector.DOMModel.instances()) { |
92 var mode; | 106 var mode; |
93 if (!enabled) | 107 if (!shouldEnable) |
94 mode = DOMAgent.InspectMode.None; | 108 mode = DOMAgent.InspectMode.None; |
95 else if (WebInspector.moduleSetting("showUAShadowDOM").get()) | 109 else if (WebInspector.moduleSetting("showUAShadowDOM").get()) |
96 mode = DOMAgent.InspectMode.SearchForUAShadowDOM; | 110 mode = DOMAgent.InspectMode.SearchForUAShadowDOM; |
97 else | 111 else |
98 mode = DOMAgent.InspectMode.SearchForNode; | 112 mode = DOMAgent.InspectMode.SearchForNode; |
99 | 113 |
100 domModel.setInspectMode(mode); | 114 domModel.setInspectMode(mode); |
101 } | 115 } |
102 }, | 116 }, |
103 | 117 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 { | 161 { |
148 if (!WebInspector.inspectElementModeController) | 162 if (!WebInspector.inspectElementModeController) |
149 return null; | 163 return null; |
150 | 164 |
151 return WebInspector.inspectElementModeController._toggleSearchButton; | 165 return WebInspector.inspectElementModeController._toggleSearchButton; |
152 } | 166 } |
153 } | 167 } |
154 | 168 |
155 /** @type {?WebInspector.InspectElementModeController} */ | 169 /** @type {?WebInspector.InspectElementModeController} */ |
156 WebInspector.inspectElementModeController = null; | 170 WebInspector.inspectElementModeController = null; |
OLD | NEW |