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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 if (!node.parentNode || node.parentNode.nodeType() !== Node.ELEMENT_NODE
) | 379 if (!node.parentNode || node.parentNode.nodeType() !== Node.ELEMENT_NODE
) |
380 return false; | 380 return false; |
381 | 381 |
382 return true; | 382 return true; |
383 }, | 383 }, |
384 | 384 |
385 _ondrop: function(event) | 385 _ondrop: function(event) |
386 { | 386 { |
387 event.preventDefault(); | 387 event.preventDefault(); |
388 var treeElement = this._treeElementFromEvent(event); | 388 var treeElement = this._treeElementFromEvent(event); |
389 if (this._nodeBeingDragged && treeElement) { | 389 if (treeElement) |
390 var parentNode; | 390 this._doMove(treeElement); |
391 var anchorNode; | 391 }, |
392 | 392 |
393 if (treeElement._elementCloseTag) { | 393 _doMove: function(treeElement) |
394 // Drop onto closing tag -> insert as last child. | 394 { |
395 parentNode = treeElement.representedObject; | 395 if (!this._nodeBeingDragged) |
396 } else { | 396 return; |
397 var dragTargetNode = treeElement.representedObject; | |
398 parentNode = dragTargetNode.parentNode; | |
399 anchorNode = dragTargetNode; | |
400 } | |
401 | 397 |
402 function callback(error, newNodeId) | 398 var parentNode; |
403 { | 399 var anchorNode; |
404 if (error) | |
405 return; | |
406 | 400 |
407 this._updateModifiedNodes(); | 401 if (treeElement._elementCloseTag) { |
408 var newNode = WebInspector.domAgent.nodeForId(newNodeId); | 402 // Drop onto closing tag -> insert as last child. |
409 if (newNode) | 403 parentNode = treeElement.representedObject; |
410 this.selectDOMNode(newNode, true); | 404 } else { |
411 } | 405 var dragTargetNode = treeElement.representedObject; |
412 this._nodeBeingDragged.moveTo(parentNode, anchorNode, callback.bind(
this)); | 406 parentNode = dragTargetNode.parentNode; |
| 407 anchorNode = dragTargetNode; |
413 } | 408 } |
414 | 409 |
| 410 function callback(error, newNodeId) |
| 411 { |
| 412 if (error) |
| 413 return; |
| 414 |
| 415 this._updateModifiedNodes(); |
| 416 var newNode = WebInspector.domAgent.nodeForId(newNodeId); |
| 417 if (newNode) |
| 418 this.selectDOMNode(newNode, true); |
| 419 } |
| 420 |
| 421 this._nodeBeingDragged.moveTo(parentNode, anchorNode, callback.bind(this
)); |
| 422 |
415 delete this._nodeBeingDragged; | 423 delete this._nodeBeingDragged; |
416 }, | 424 }, |
417 | 425 |
418 _ondragend: function(event) | 426 _ondragend: function(event) |
419 { | 427 { |
420 event.preventDefault(); | 428 event.preventDefault(); |
421 this._clearDragOverTreeElementMarker(); | 429 this._clearDragOverTreeElementMarker(); |
422 delete this._nodeBeingDragged; | 430 delete this._nodeBeingDragged; |
423 }, | 431 }, |
424 | 432 |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 }, | 1853 }, |
1846 | 1854 |
1847 _reset: function() | 1855 _reset: function() |
1848 { | 1856 { |
1849 this._treeOutline.rootDOMNode = null; | 1857 this._treeOutline.rootDOMNode = null; |
1850 this._treeOutline.selectDOMNode(null, false); | 1858 this._treeOutline.selectDOMNode(null, false); |
1851 WebInspector.domAgent.hideDOMNodeHighlight(); | 1859 WebInspector.domAgent.hideDOMNodeHighlight(); |
1852 this._recentlyModifiedNodes = []; | 1860 this._recentlyModifiedNodes = []; |
1853 } | 1861 } |
1854 } | 1862 } |
OLD | NEW |