Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/main/Main.js

Issue 2138123003: DevTools: remove panel-based clipboard events dispatching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lcean Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/elements/ElementsTreeOutline.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 WebInspector.inspectorView.currentPanel().handleShortcut(event); 486 WebInspector.inspectorView.currentPanel().handleShortcut(event);
487 if (event.handled) { 487 if (event.handled) {
488 event.consume(true); 488 event.consume(true);
489 return; 489 return;
490 } 490 }
491 } 491 }
492 492
493 WebInspector.shortcutRegistry.handleShortcut(event); 493 WebInspector.shortcutRegistry.handleShortcut(event);
494 }, 494 },
495 495
496 _documentCanCopy: function(event) 496 /**
497 * @param {!Event} event
498 */
499 _redispatchClipboardEvent: function(event)
497 { 500 {
498 var panel = WebInspector.inspectorView.currentPanel(); 501 var eventCopy = new CustomEvent("clipboard-" + event.type);
499 if (panel && panel["handleCopyEvent"]) 502 eventCopy["original"] = event;
lushnikov 2016/07/12 03:21:55 Can we use CustomEvent.detail for this? https://de
pfeldman 2016/07/12 20:56:46 Did not work for me.
503 event.deepActiveElement().dispatchEvent(eventCopy);
504 if (eventCopy.handled)
lushnikov 2016/07/12 03:21:55 Can we check for eventCopy.defaultPrevented here?
pfeldman 2016/07/12 20:56:46 It does not work on custom events.
500 event.preventDefault(); 505 event.preventDefault();
501 }, 506 },
502 507
503 _documentCopy: function(event)
504 {
505 var panel = WebInspector.inspectorView.currentPanel();
506 if (panel && panel["handleCopyEvent"])
507 panel["handleCopyEvent"](event);
508 },
509
510 _documentCut: function(event)
511 {
512 var panel = WebInspector.inspectorView.currentPanel();
513 if (panel && panel["handleCutEvent"])
514 panel["handleCutEvent"](event);
515 },
516
517 _documentPaste: function(event)
518 {
519 var panel = WebInspector.inspectorView.currentPanel();
520 if (panel && panel["handlePasteEvent"])
521 panel["handlePasteEvent"](event);
522 },
523
524 _contextMenuEventFired: function(event) 508 _contextMenuEventFired: function(event)
525 { 509 {
526 if (event.handled || event.target.classList.contains("popup-glasspane")) 510 if (event.handled || event.target.classList.contains("popup-glasspane"))
527 event.preventDefault(); 511 event.preventDefault();
528 }, 512 },
529 513
530 /** 514 /**
531 * @param {!Document} document 515 * @param {!Document} document
532 */ 516 */
533 _addMainEventListeners: function(document) 517 _addMainEventListeners: function(document)
534 { 518 {
535 document.addEventListener("keydown", this._postDocumentKeyDown.bind(this ), false); 519 document.addEventListener("keydown", this._postDocumentKeyDown.bind(this ), false);
536 document.addEventListener("beforecopy", this._documentCanCopy.bind(this) , true); 520 document.addEventListener("beforecopy", this._redispatchClipboardEvent.b ind(this), true);
537 document.addEventListener("copy", this._documentCopy.bind(this), false); 521 document.addEventListener("copy", this._redispatchClipboardEvent.bind(th is), false);
538 document.addEventListener("cut", this._documentCut.bind(this), false); 522 document.addEventListener("cut", this._redispatchClipboardEvent.bind(thi s), false);
539 document.addEventListener("paste", this._documentPaste.bind(this), false ); 523 document.addEventListener("paste", this._redispatchClipboardEvent.bind(t his), false);
540 document.addEventListener("contextmenu", this._contextMenuEventFired.bin d(this), true); 524 document.addEventListener("contextmenu", this._contextMenuEventFired.bin d(this), true);
541 document.addEventListener("click", this._documentClick.bind(this), false ); 525 document.addEventListener("click", this._documentClick.bind(this), false );
542 }, 526 },
543 527
544 /** 528 /**
545 * @param {!WebInspector.Event} event 529 * @param {!WebInspector.Event} event
546 */ 530 */
547 _reloadInspectedPage: function(event) 531 _reloadInspectedPage: function(event)
548 { 532 {
549 var hard = /** @type {boolean} */ (event.data); 533 var hard = /** @type {boolean} */ (event.data);
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 * @return {?Element} 1109 * @return {?Element}
1126 */ 1110 */
1127 settingElement: function() 1111 settingElement: function()
1128 { 1112 {
1129 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers")); 1113 return WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIStri ng("Show rulers"), WebInspector.moduleSetting("showMetricsRulers"));
1130 } 1114 }
1131 } 1115 }
1132 1116
1133 1117
1134 new WebInspector.Main(); 1118 new WebInspector.Main();
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/elements/ElementsTreeOutline.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698