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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 /** | 247 /** |
248 * @param {!WebInspector.DOMNode} node | 248 * @param {!WebInspector.DOMNode} node |
249 * @param {string} pseudoClass | 249 * @param {string} pseudoClass |
250 * @param {boolean} enable | 250 * @param {boolean} enable |
251 */ | 251 */ |
252 _setPseudoClassForNode: function(node, pseudoClass, enable) | 252 _setPseudoClassForNode: function(node, pseudoClass, enable) |
253 { | 253 { |
254 if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass, enable)) | 254 if (!node || !node.target().cssModel.forcePseudoState(node, pseudoClass, enable)) |
255 return; | 255 return; |
256 | 256 |
257 this._targetToTreeOutline.get(node.target()).updateOpenCloseTags(node); | 257 this._treeOutlineForNode(node).updateOpenCloseTags(node); |
258 this._metricsPaneEdited(); | 258 this._metricsPaneEdited(); |
259 this._stylesPaneEdited(); | 259 this._stylesPaneEdited(); |
260 | 260 |
261 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, { | 261 WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMet rics.UserAction, { |
262 action: WebInspector.UserMetrics.UserActionNames.ForcedElementState, | 262 action: WebInspector.UserMetrics.UserActionNames.ForcedElementState, |
263 selector: WebInspector.DOMPresentationUtils.fullQualifiedSelector(no de, false), | 263 selector: WebInspector.DOMPresentationUtils.fullQualifiedSelector(no de, false), |
264 enabled: enable, | 264 enabled: enable, |
265 state: pseudoClass | 265 state: pseudoClass |
266 }); | 266 }); |
267 }, | 267 }, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 { | 451 { |
452 if (event.data) | 452 if (event.data) |
453 this.contentElement.classList.remove("nowrap"); | 453 this.contentElement.classList.remove("nowrap"); |
454 else | 454 else |
455 this.contentElement.classList.add("nowrap"); | 455 this.contentElement.classList.add("nowrap"); |
456 | 456 |
457 var selectedNode = this.selectedDOMNode(); | 457 var selectedNode = this.selectedDOMNode(); |
458 if (!selectedNode) | 458 if (!selectedNode) |
459 return; | 459 return; |
460 | 460 |
461 var treeOutline = this._targetToTreeOutline.get(selectedNode.target()); | 461 var treeElement = this._treeElementForNode(selectedNode); |
462 var treeElement = treeOutline.findTreeElement(selectedNode); | |
463 if (treeElement) | 462 if (treeElement) |
464 treeElement.updateSelection(); // Recalculate selection highlight di mensions. | 463 treeElement.updateSelection(); // Recalculate selection highlight di mensions. |
465 }, | 464 }, |
466 | 465 |
467 switchToAndFocus: function(node) | 466 switchToAndFocus: function(node) |
468 { | 467 { |
469 // Reset search restore. | 468 // Reset search restore. |
470 this._searchableView.cancelSearch(); | 469 this._searchableView.cancelSearch(); |
471 WebInspector.inspectorView.setCurrentPanel(this); | 470 WebInspector.inspectorView.setCurrentPanel(this); |
472 this.selectDOMNode(node, true); | 471 this.selectDOMNode(node, true); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
614 } | 613 } |
615 | 614 |
616 if (typeof searchResult.node === "undefined") { | 615 if (typeof searchResult.node === "undefined") { |
617 // No data for slot, request it. | 616 // No data for slot, request it. |
618 searchResult.target.domModel.searchResult(searchResult.index, search Callback.bind(this)); | 617 searchResult.target.domModel.searchResult(searchResult.index, search Callback.bind(this)); |
619 return; | 618 return; |
620 } | 619 } |
621 | 620 |
622 this._searchableView.updateCurrentMatchIndex(index); | 621 this._searchableView.updateCurrentMatchIndex(index); |
623 | 622 |
624 var treeOutline = this._targetToTreeOutline.get(searchResult.target); | 623 var treeElement = this._treeElementForNode(searchResult.node); |
625 var treeElement = treeOutline.findTreeElement(searchResult.node); | |
626 if (treeElement) { | 624 if (treeElement) { |
627 treeElement.highlightSearchResults(this._searchQuery); | 625 treeElement.highlightSearchResults(this._searchQuery); |
628 treeElement.reveal(); | 626 treeElement.reveal(); |
629 var matches = treeElement.listItemElement.getElementsByClassName("hi ghlighted-search-result"); | 627 var matches = treeElement.listItemElement.getElementsByClassName("hi ghlighted-search-result"); |
630 if (matches.length) | 628 if (matches.length) |
631 matches[0].scrollIntoViewIfNeeded(); | 629 matches[0].scrollIntoViewIfNeeded(); |
632 } | 630 } |
633 }, | 631 }, |
634 | 632 |
635 _hideSearchHighlights: function() | 633 _hideSearchHighlights: function() |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 | 1188 |
1191 if (!treeOutline.editing()) { | 1189 if (!treeOutline.editing()) { |
1192 handleUndoRedo.call(this, treeOutline); | 1190 handleUndoRedo.call(this, treeOutline); |
1193 if (event.handled) | 1191 if (event.handled) |
1194 return; | 1192 return; |
1195 } | 1193 } |
1196 | 1194 |
1197 treeOutline.handleShortcut(event); | 1195 treeOutline.handleShortcut(event); |
1198 }, | 1196 }, |
1199 | 1197 |
1198 /** | |
1199 * @param {!Event} event | |
1200 */ | |
1200 handleCopyEvent: function(event) | 1201 handleCopyEvent: function(event) |
1201 { | 1202 { |
1203 this._handleCopyOrCutEvent(event, false); | |
1204 }, | |
1205 | |
1206 /** | |
1207 * @param {!Event} event | |
1208 */ | |
1209 handleCutEvent: function(event) | |
1210 { | |
1211 this._handleCopyOrCutEvent(event, true); | |
1212 }, | |
1213 | |
1214 /** | |
1215 * @param {!WebInspector.DOMNode} node | |
1216 * @return {?WebInspector.ElementsTreeOutline} | |
1217 */ | |
1218 _treeOutlineForNode: function(node) | |
1219 { | |
1220 return this._targetToTreeOutline.get(node.target()) || null; | |
1221 }, | |
1222 | |
1223 /** | |
1224 * @param {!WebInspector.DOMNode} node | |
1225 * @return {?WebInspector.ElementsTreeElement} | |
1226 */ | |
1227 _treeElementForNode: function(node) | |
1228 { | |
1229 var treeOutline = this._treeOutlineForNode(node); | |
1230 return /** @type {?WebInspector.ElementsTreeElement} */ (treeOutline.fin dTreeElement(node)); | |
1231 }, | |
1232 | |
1233 /** | |
1234 * @param {?WebInspector.DOMNode} node | |
1235 */ | |
1236 _setNodeInClipboard: function(node) | |
1237 { | |
1238 var treeElement; | |
1239 if (!node) { | |
1240 if (this._clipboardNodeData) { | |
1241 treeElement = this._treeElementForNode(this._clipboardNodeData.n ode); | |
1242 if (treeElement) | |
1243 treeElement.setInClipboard(false); | |
1244 } | |
1245 delete this._clipboardNodeData; | |
1246 return; | |
1247 } | |
1248 treeElement = this._treeElementForNode(node); | |
1249 if (treeElement) | |
1250 treeElement.setInClipboard(true); | |
1251 }, | |
1252 | |
1253 /** | |
1254 * @param {!Event} event | |
1255 * @param {boolean} isCut | |
1256 */ | |
1257 _handleCopyOrCutEvent: function(event, isCut) | |
1258 { | |
1259 this._setNodeInClipboard(null); | |
1260 delete this._clipboardNodeData; | |
aandrey
2014/07/18 05:30:04
remove
apavlov
2014/07/18 09:02:07
Done.
| |
1202 var currentFocusElement = WebInspector.currentFocusElement(); | 1261 var currentFocusElement = WebInspector.currentFocusElement(); |
1203 if (currentFocusElement && WebInspector.isBeingEdited(currentFocusElemen t)) | 1262 if (currentFocusElement && WebInspector.isBeingEdited(currentFocusElemen t)) |
1204 return; | 1263 return; |
1205 | 1264 |
1206 // Don't prevent the normal copy if the user has a selection. | 1265 // Don't prevent the normal copy if the user has a selection. |
1207 if (!window.getSelection().isCollapsed) | 1266 if (!window.getSelection().isCollapsed) |
1208 return; | 1267 return; |
1268 | |
1269 var selectedNode = this.selectedDOMNode(); | |
1270 if (!selectedNode) | |
1271 return; | |
1272 | |
1209 event.clipboardData.clearData(); | 1273 event.clipboardData.clearData(); |
1210 event.preventDefault(); | 1274 event.preventDefault(); |
1211 this.selectedDOMNode().copyNode(); | 1275 selectedNode.copyNode(); |
1276 this._clipboardNodeData = {node: selectedNode, isCut: isCut}; | |
1277 this._setNodeInClipboard(selectedNode); | |
1212 }, | 1278 }, |
1213 | 1279 |
1214 /** | 1280 /** |
1281 * @param {!Event} event | |
1282 */ | |
1283 handlePasteEvent: function(event) | |
1284 { | |
1285 if (!this._clipboardNodeData) | |
1286 return; | |
1287 | |
1288 // Don't prevent the normal copy if the user has a selection. | |
1289 if (!window.getSelection().isCollapsed) | |
1290 return; | |
1291 | |
1292 var currentFocusElement = WebInspector.currentFocusElement(); | |
1293 if (currentFocusElement && WebInspector.isBeingEdited(currentFocusElemen t)) | |
1294 return; | |
1295 | |
1296 var targetNode = this.selectedDOMNode(); | |
1297 if (!targetNode) | |
1298 return; | |
1299 | |
1300 var node = this._clipboardNodeData.node; | |
1301 if (targetNode.target() !== node.target()) | |
1302 return; | |
1303 | |
1304 event.preventDefault(); | |
1305 if (this._clipboardNodeData.isCut) | |
1306 node.moveTo(targetNode, null, expandCallback); | |
aandrey
2014/07/18 05:30:05
will it work for consecutive paste events? should
apavlov
2014/07/18 09:02:07
Thanks, I knew I had missed something for this cas
| |
1307 else | |
1308 node.copyTo(targetNode, null, true, expandCallback); | |
1309 | |
1310 var treeOutline = this._treeOutlineForNode(targetNode); | |
1311 | |
1312 /** | |
1313 * @param {?Protocol.Error} error | |
1314 * @param {!DOMAgent.NodeId} nodeId | |
1315 */ | |
1316 function expandCallback(error, nodeId) | |
1317 { | |
1318 if (error) | |
1319 return; | |
1320 var pastedNode = targetNode.target().domModel.nodeForId(nodeId); | |
1321 if (!pastedNode) | |
1322 return; | |
1323 treeOutline.selectDOMNode(pastedNode); | |
1324 } | |
1325 }, | |
1326 | |
1327 /** | |
1215 * @param {!WebInspector.DOMNode} node | 1328 * @param {!WebInspector.DOMNode} node |
1216 * @return {!WebInspector.DOMNode} | 1329 * @return {!WebInspector.DOMNode} |
1217 */ | 1330 */ |
1218 _leaveUserAgentShadowDOM: function(node) | 1331 _leaveUserAgentShadowDOM: function(node) |
1219 { | 1332 { |
1220 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot(); | 1333 var userAgentShadowRoot = node.ancestorUserAgentShadowRoot(); |
1221 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA gentShadowRoot.parentNode) : node; | 1334 return userAgentShadowRoot ? /** @type {!WebInspector.DOMNode} */ (userA gentShadowRoot.parentNode) : node; |
1222 }, | 1335 }, |
1223 | 1336 |
1224 /** | 1337 /** |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1501 /** | 1614 /** |
1502 * @suppressReceiverCheck | 1615 * @suppressReceiverCheck |
1503 * @this {Element} | 1616 * @this {Element} |
1504 */ | 1617 */ |
1505 function parentElement() | 1618 function parentElement() |
1506 { | 1619 { |
1507 return this.parentElement; | 1620 return this.parentElement; |
1508 } | 1621 } |
1509 } | 1622 } |
1510 } | 1623 } |
OLD | NEW |