OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> | 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 /** | 243 /** |
244 * @param {!WebInspector.DOMNode} node | 244 * @param {!WebInspector.DOMNode} node |
245 * @param {string} pseudoClass | 245 * @param {string} pseudoClass |
246 * @param {boolean} enable | 246 * @param {boolean} enable |
247 */ | 247 */ |
248 _setPseudoClassForNode: function(node, pseudoClass, enable) | 248 _setPseudoClassForNode: function(node, pseudoClass, enable) |
249 { | 249 { |
250 if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass,
enable)) | 250 if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass,
enable)) |
251 return; | 251 return; |
252 | 252 |
253 this._targetToTreeOutline.get(node.target()).updateOpenCloseTags(node); | 253 this._treeOutlineForNode(node).updateOpenCloseTags(node); |
254 this._metricsPaneEdited(); | 254 this._metricsPaneEdited(); |
255 this._stylesPaneEdited(); | 255 this._stylesPaneEdited(); |
256 | 256 |
257 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet
rics.UserAction, { | 257 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet
rics.UserAction, { |
258 action: WebInspector.UserMetrics.UserActionNames.ForcedElementState, | 258 action: WebInspector.UserMetrics.UserActionNames.ForcedElementState, |
259 selector: WebInspector.DOMPresentationUtils.fullQualifiedSelector(no
de, false), | 259 selector: WebInspector.DOMPresentationUtils.fullQualifiedSelector(no
de, false), |
260 enabled: enable, | 260 enabled: enable, |
261 state: pseudoClass | 261 state: pseudoClass |
262 }); | 262 }); |
263 }, | 263 }, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 { | 447 { |
448 if (event.data) | 448 if (event.data) |
449 this.contentElement.classList.remove("nowrap"); | 449 this.contentElement.classList.remove("nowrap"); |
450 else | 450 else |
451 this.contentElement.classList.add("nowrap"); | 451 this.contentElement.classList.add("nowrap"); |
452 | 452 |
453 var selectedNode = this.selectedDOMNode(); | 453 var selectedNode = this.selectedDOMNode(); |
454 if (!selectedNode) | 454 if (!selectedNode) |
455 return; | 455 return; |
456 | 456 |
457 var treeOutline = this._targetToTreeOutline.get(selectedNode.target()); | 457 var treeElement = this._treeElementForNode(selectedNode); |
458 var treeElement = treeOutline.findTreeElement(selectedNode); | |
459 if (treeElement) | 458 if (treeElement) |
460 treeElement.updateSelection(); // Recalculate selection highlight di
mensions. | 459 treeElement.updateSelection(); // Recalculate selection highlight di
mensions. |
461 }, | 460 }, |
462 | 461 |
463 switchToAndFocus: function(node) | 462 switchToAndFocus: function(node) |
464 { | 463 { |
465 // Reset search restore. | 464 // Reset search restore. |
466 this._searchableView.cancelSearch(); | 465 this._searchableView.cancelSearch(); |
467 WebInspector.inspectorView.setCurrentPanel(this); | 466 WebInspector.inspectorView.setCurrentPanel(this); |
468 this.selectDOMNode(node, true); | 467 this.selectDOMNode(node, true); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 609 } |
611 | 610 |
612 if (typeof searchResult.node === "undefined") { | 611 if (typeof searchResult.node === "undefined") { |
613 // No data for slot, request it. | 612 // No data for slot, request it. |
614 searchResult.target.domModel.searchResult(searchResult.index, search
Callback.bind(this)); | 613 searchResult.target.domModel.searchResult(searchResult.index, search
Callback.bind(this)); |
615 return; | 614 return; |
616 } | 615 } |
617 | 616 |
618 this._searchableView.updateCurrentMatchIndex(index); | 617 this._searchableView.updateCurrentMatchIndex(index); |
619 | 618 |
620 var treeOutline = this._targetToTreeOutline.get(searchResult.target); | 619 var treeElement = this._treeElementForNode(searchResult.node); |
621 var treeElement = treeOutline.findTreeElement(searchResult.node); | |
622 if (treeElement) { | 620 if (treeElement) { |
623 treeElement.highlightSearchResults(this._searchQuery); | 621 treeElement.highlightSearchResults(this._searchQuery); |
624 treeElement.reveal(); | 622 treeElement.reveal(); |
625 var matches = treeElement.listItemElement.getElementsByClassName("hi
ghlighted-search-result"); | 623 var matches = treeElement.listItemElement.getElementsByClassName("hi
ghlighted-search-result"); |
626 if (matches.length) | 624 if (matches.length) |
627 matches[0].scrollIntoViewIfNeeded(); | 625 matches[0].scrollIntoViewIfNeeded(); |
628 } | 626 } |
629 }, | 627 }, |
630 | 628 |
631 _hideSearchHighlights: function() | 629 _hideSearchHighlights: function() |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 | 1184 |
1187 if (!treeOutline.editing()) { | 1185 if (!treeOutline.editing()) { |
1188 handleUndoRedo.call(this, treeOutline); | 1186 handleUndoRedo.call(this, treeOutline); |
1189 if (event.handled) | 1187 if (event.handled) |
1190 return; | 1188 return; |
1191 } | 1189 } |
1192 | 1190 |
1193 treeOutline.handleShortcut(event); | 1191 treeOutline.handleShortcut(event); |
1194 }, | 1192 }, |
1195 | 1193 |
1196 handleCopyEvent: function(event) | 1194 /** |
| 1195 * @param {?WebInspector.DOMNode} node |
| 1196 * @return {?WebInspector.ElementsTreeOutline} |
| 1197 */ |
| 1198 _treeOutlineForNode: function(node) |
1197 { | 1199 { |
1198 var currentFocusElement = WebInspector.currentFocusElement(); | 1200 if (!node) |
1199 if (currentFocusElement && WebInspector.isBeingEdited(currentFocusElemen
t)) | 1201 return null; |
1200 return; | 1202 return this._targetToTreeOutline.get(node.target()) || null; |
1201 | |
1202 // Don't prevent the normal copy if the user has a selection. | |
1203 if (!window.getSelection().isCollapsed) | |
1204 return; | |
1205 event.clipboardData.clearData(); | |
1206 event.preventDefault(); | |
1207 this.selectedDOMNode().copyNode(); | |
1208 }, | 1203 }, |
1209 | 1204 |
1210 /** | 1205 /** |
| 1206 * @param {!WebInspector.DOMNode} node |
| 1207 * @return {?WebInspector.ElementsTreeElement} |
| 1208 */ |
| 1209 _treeElementForNode: function(node) |
| 1210 { |
| 1211 var treeOutline = this._treeOutlineForNode(node); |
| 1212 return /** @type {?WebInspector.ElementsTreeElement} */ (treeOutline.fin
dTreeElement(node)); |
| 1213 }, |
| 1214 |
| 1215 /** |
| 1216 * @param {!Event} event |
| 1217 */ |
| 1218 handleCopyEvent: function(event) |
| 1219 { |
| 1220 var treeOutline = this._treeOutlineForNode(this.selectedDOMNode()); |
| 1221 if (treeOutline) |
| 1222 treeOutline.handleCopyOrCutEvent(false, event); |
| 1223 }, |
| 1224 |
| 1225 /** |
| 1226 * @param {!Event} event |
| 1227 */ |
| 1228 handleCutEvent: function(event) |
| 1229 { |
| 1230 var treeOutline = this._treeOutlineForNode(this.selectedDOMNode()); |
| 1231 if (treeOutline) |
| 1232 treeOutline.handleCopyOrCutEvent(true, event); |
| 1233 }, |
| 1234 |
| 1235 /** |
| 1236 * @param {!Event} event |
| 1237 */ |
| 1238 handlePasteEvent: function(event) |
| 1239 { |
| 1240 var treeOutline = this._treeOutlineForNode(this.selectedDOMNode()); |
| 1241 if (treeOutline) |
| 1242 treeOutline.handlePasteEvent(event); |
| 1243 }, |
| 1244 |
| 1245 /** |
1211 * @param {!WebInspector.DOMNode} node | 1246 * @param {!WebInspector.DOMNode} node |
1212 * @return {!WebInspector.DOMNode} | 1247 * @return {!WebInspector.DOMNode} |
1213 */ | 1248 */ |
1214 _leaveUserAgentShadowDOM: function(node) | 1249 _leaveUserAgentShadowDOM: function(node) |
1215 { | 1250 { |
1216 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot(); | 1251 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot(); |
1217 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA
gentShadowRoot.parentNode) : node; | 1252 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA
gentShadowRoot.parentNode) : node; |
1218 }, | 1253 }, |
1219 | 1254 |
1220 /** | 1255 /** |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 /** | 1532 /** |
1498 * @suppressReceiverCheck | 1533 * @suppressReceiverCheck |
1499 * @this {Element} | 1534 * @this {Element} |
1500 */ | 1535 */ |
1501 function parentElement() | 1536 function parentElement() |
1502 { | 1537 { |
1503 return this.parentElement; | 1538 return this.parentElement; |
1504 } | 1539 } |
1505 } | 1540 } |
1506 } | 1541 } |
OLD | NEW |