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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 this._element.classList.add("elements-tree-outline", "source-code"); | 50 this._element.classList.add("elements-tree-outline", "source-code"); |
51 this._element.addEventListener("mousedown", this._onmousedown.bind(this), fa
lse); | 51 this._element.addEventListener("mousedown", this._onmousedown.bind(this), fa
lse); |
52 this._element.addEventListener("mousemove", this._onmousemove.bind(this), fa
lse); | 52 this._element.addEventListener("mousemove", this._onmousemove.bind(this), fa
lse); |
53 this._element.addEventListener("mouseleave", this._onmouseleave.bind(this),
false); | 53 this._element.addEventListener("mouseleave", this._onmouseleave.bind(this),
false); |
54 this._element.addEventListener("dragstart", this._ondragstart.bind(this), fa
lse); | 54 this._element.addEventListener("dragstart", this._ondragstart.bind(this), fa
lse); |
55 this._element.addEventListener("dragover", this._ondragover.bind(this), fals
e); | 55 this._element.addEventListener("dragover", this._ondragover.bind(this), fals
e); |
56 this._element.addEventListener("dragleave", this._ondragleave.bind(this), fa
lse); | 56 this._element.addEventListener("dragleave", this._ondragleave.bind(this), fa
lse); |
57 this._element.addEventListener("drop", this._ondrop.bind(this), false); | 57 this._element.addEventListener("drop", this._ondrop.bind(this), false); |
58 this._element.addEventListener("dragend", this._ondragend.bind(this), false)
; | 58 this._element.addEventListener("dragend", this._ondragend.bind(this), false)
; |
59 this._element.addEventListener("contextmenu", this._contextMenuEventFired.bi
nd(this), false); | 59 this._element.addEventListener("contextmenu", this._contextMenuEventFired.bi
nd(this), false); |
| 60 this._element.addEventListener("clipboard-beforecopy", this._onBeforeCopy.bi
nd(this), false); |
| 61 this._element.addEventListener("clipboard-copy", this._onCopyOrCut.bind(this
, false), false); |
| 62 this._element.addEventListener("clipboard-cut", this._onCopyOrCut.bind(this,
true), false); |
| 63 this._element.addEventListener("clipboard-paste", this._onPaste.bind(this),
false); |
60 | 64 |
61 outlineDisclosureElement.appendChild(this._element); | 65 outlineDisclosureElement.appendChild(this._element); |
62 this.element = element; | 66 this.element = element; |
63 | 67 |
64 this._includeRootDOMNode = !omitRootDOMNode; | 68 this._includeRootDOMNode = !omitRootDOMNode; |
65 this._selectEnabled = selectEnabled; | 69 this._selectEnabled = selectEnabled; |
66 /** @type {?WebInspector.DOMNode} */ | 70 /** @type {?WebInspector.DOMNode} */ |
67 this._rootDOMNode = null; | 71 this._rootDOMNode = null; |
68 /** @type {?WebInspector.DOMNode} */ | 72 /** @type {?WebInspector.DOMNode} */ |
69 this._selectedDOMNode = null; | 73 this._selectedDOMNode = null; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 /** | 219 /** |
216 * @param {!WebInspector.DOMNode} removedNode | 220 * @param {!WebInspector.DOMNode} removedNode |
217 */ | 221 */ |
218 resetClipboardIfNeeded: function(removedNode) | 222 resetClipboardIfNeeded: function(removedNode) |
219 { | 223 { |
220 if (this._clipboardNodeData && this._clipboardNodeData.node === removedN
ode) | 224 if (this._clipboardNodeData && this._clipboardNodeData.node === removedN
ode) |
221 this._setClipboardData(null); | 225 this._setClipboardData(null); |
222 }, | 226 }, |
223 | 227 |
224 /** | 228 /** |
| 229 * @param {!Event} event |
| 230 */ |
| 231 _onBeforeCopy: function(event) |
| 232 { |
| 233 event.handled = true; |
| 234 }, |
| 235 |
| 236 /** |
225 * @param {boolean} isCut | 237 * @param {boolean} isCut |
226 * @param {!Event} event | 238 * @param {!Event} event |
227 */ | 239 */ |
228 handleCopyOrCutKeyboardEvent: function(isCut, event) | 240 _onCopyOrCut: function(isCut, event) |
229 { | 241 { |
230 this._setClipboardData(null); | 242 this._setClipboardData(null); |
| 243 var originalEvent = event["original"]; |
231 | 244 |
232 // Don't prevent the normal copy if the user has a selection. | 245 // Don't prevent the normal copy if the user has a selection. |
233 if (!event.target.isComponentSelectionCollapsed()) | 246 if (!originalEvent.target.isComponentSelectionCollapsed()) |
234 return; | 247 return; |
235 | 248 |
236 // Do not interfere with text editing. | 249 // Do not interfere with text editing. |
237 if (WebInspector.isEditing()) | 250 if (WebInspector.isEditing()) |
238 return; | 251 return; |
239 | 252 |
240 var targetNode = this.selectedDOMNode(); | 253 var targetNode = this.selectedDOMNode(); |
241 if (!targetNode) | 254 if (!targetNode) |
242 return; | 255 return; |
243 | 256 |
244 event.clipboardData.clearData(); | 257 originalEvent.clipboardData.clearData(); |
245 event.preventDefault(); | 258 event.handled = true; |
246 | 259 |
247 this.performCopyOrCut(isCut, targetNode); | 260 this.performCopyOrCut(isCut, targetNode); |
248 }, | 261 }, |
249 | 262 |
250 /** | 263 /** |
251 * @param {boolean} isCut | 264 * @param {boolean} isCut |
252 * @param {?WebInspector.DOMNode} node | 265 * @param {?WebInspector.DOMNode} node |
253 */ | 266 */ |
254 performCopyOrCut: function(isCut, node) | 267 performCopyOrCut: function(isCut, node) |
255 { | 268 { |
(...skipping 30 matching lines...) Expand all Loading... |
286 */ | 299 */ |
287 pasteNode: function(targetNode) | 300 pasteNode: function(targetNode) |
288 { | 301 { |
289 if (this.canPaste(targetNode)) | 302 if (this.canPaste(targetNode)) |
290 this._performPaste(targetNode); | 303 this._performPaste(targetNode); |
291 }, | 304 }, |
292 | 305 |
293 /** | 306 /** |
294 * @param {!Event} event | 307 * @param {!Event} event |
295 */ | 308 */ |
296 handlePasteKeyboardEvent: function(event) | 309 _onPaste: function(event) |
297 { | 310 { |
298 // Do not interfere with text editing. | 311 // Do not interfere with text editing. |
299 if (WebInspector.isEditing()) | 312 if (WebInspector.isEditing()) |
300 return; | 313 return; |
301 | 314 |
302 var targetNode = this.selectedDOMNode(); | 315 var targetNode = this.selectedDOMNode(); |
303 if (!targetNode || !this.canPaste(targetNode)) | 316 if (!targetNode || !this.canPaste(targetNode)) |
304 return; | 317 return; |
305 | 318 |
306 event.preventDefault(); | 319 event.handled = true; |
307 this._performPaste(targetNode); | 320 this._performPaste(targetNode); |
308 }, | 321 }, |
309 | 322 |
310 /** | 323 /** |
311 * @param {!WebInspector.DOMNode} targetNode | 324 * @param {!WebInspector.DOMNode} targetNode |
312 */ | 325 */ |
313 _performPaste: function(targetNode) | 326 _performPaste: function(targetNode) |
314 { | 327 { |
315 if (this._clipboardNodeData.isCut) { | 328 if (this._clipboardNodeData.isCut) { |
316 this._clipboardNodeData.node.moveTo(targetNode, null, expandCallback
.bind(this)); | 329 this._clipboardNodeData.node.moveTo(targetNode, null, expandCallback
.bind(this)); |
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 if (node) { | 1793 if (node) { |
1781 this.treeOutline._selectedDOMNode = node; | 1794 this.treeOutline._selectedDOMNode = node; |
1782 this.treeOutline._selectedNodeChanged(); | 1795 this.treeOutline._selectedNodeChanged(); |
1783 } | 1796 } |
1784 } | 1797 } |
1785 return true; | 1798 return true; |
1786 }, | 1799 }, |
1787 | 1800 |
1788 __proto__: TreeElement.prototype | 1801 __proto__: TreeElement.prototype |
1789 } | 1802 } |
OLD | NEW |