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

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

Issue 2510193003: [DevTools] Move link click and context menu handling to Linkifier. (Closed)
Patch Set: Created 4 years, 1 month 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
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); 339 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
340 if (uiSourceCode.url() === url) { 340 if (uiSourceCode.url() === url) {
341 Common.Revealer.reveal(uiSourceCode.uiLocation(lineNumber, columnNumber) ); 341 Common.Revealer.reveal(uiSourceCode.uiLocation(lineNumber, columnNumber) );
342 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISou rceCodeAdded, listener); 342 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISou rceCodeAdded, listener);
343 } 343 }
344 } 344 }
345 345
346 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Added, listener); 346 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCode Added, listener);
347 } 347 }
348 348
349 _documentClick(event) {
350 var target = event.target;
351 if (target.shadowRoot)
352 target = event.deepElementFromPoint();
353 if (!target)
354 return;
355
356 var anchor = target.enclosingNodeOrSelfWithNodeName('a');
357 if (!anchor || !anchor.href)
358 return;
359
360 // Prevent the link from navigating, since we don't do any navigation by fol lowing links normally.
361 event.consume(true);
362
363 if (anchor.preventFollow)
364 return;
365
366 function followLink() {
367 if (UI.isBeingEdited(target))
368 return;
369 if (Components.openAnchorLocationRegistry.dispatch({url: anchor.href, line Number: anchor.lineNumber}))
370 return;
371
372 var uiSourceCode = Workspace.workspace.uiSourceCodeForURL(anchor.href);
373 if (uiSourceCode) {
374 Common.Revealer.reveal(uiSourceCode.uiLocation(anchor.lineNumber || 0, a nchor.columnNumber || 0));
375 return;
376 }
377
378 var resource = Bindings.resourceForURL(anchor.href);
379 if (resource) {
380 Common.Revealer.reveal(resource);
381 return;
382 }
383
384 var request = SDK.NetworkLog.requestForURL(anchor.href);
385 if (request) {
386 Common.Revealer.reveal(request);
387 return;
388 }
389 InspectorFrontendHost.openInNewTab(anchor.href);
390 }
391
392 followLink();
393 }
394
395 _registerShortcuts() { 349 _registerShortcuts() {
396 var shortcut = UI.KeyboardShortcut; 350 var shortcut = UI.KeyboardShortcut;
397 var section = Components.shortcutsScreen.section(Common.UIString('All Panels ')); 351 var section = Components.shortcutsScreen.section(Common.UIString('All Panels '));
398 var keys = [ 352 var keys = [
399 shortcut.makeDescriptor('[', shortcut.Modifiers.CtrlOrMeta), 353 shortcut.makeDescriptor('[', shortcut.Modifiers.CtrlOrMeta),
400 shortcut.makeDescriptor(']', shortcut.Modifiers.CtrlOrMeta) 354 shortcut.makeDescriptor(']', shortcut.Modifiers.CtrlOrMeta)
401 ]; 355 ];
402 section.addRelatedKeys(keys, Common.UIString('Go to the panel to the left/ri ght')); 356 section.addRelatedKeys(keys, Common.UIString('Go to the panel to the left/ri ght'));
403 357
404 keys = [ 358 keys = [
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 /** 442 /**
489 * @param {!Document} document 443 * @param {!Document} document
490 */ 444 */
491 _addMainEventListeners(document) { 445 _addMainEventListeners(document) {
492 document.addEventListener('keydown', this._postDocumentKeyDown.bind(this), f alse); 446 document.addEventListener('keydown', this._postDocumentKeyDown.bind(this), f alse);
493 document.addEventListener('beforecopy', this._redispatchClipboardEvent.bind( this), true); 447 document.addEventListener('beforecopy', this._redispatchClipboardEvent.bind( this), true);
494 document.addEventListener('copy', this._redispatchClipboardEvent.bind(this), false); 448 document.addEventListener('copy', this._redispatchClipboardEvent.bind(this), false);
495 document.addEventListener('cut', this._redispatchClipboardEvent.bind(this), false); 449 document.addEventListener('cut', this._redispatchClipboardEvent.bind(this), false);
496 document.addEventListener('paste', this._redispatchClipboardEvent.bind(this) , false); 450 document.addEventListener('paste', this._redispatchClipboardEvent.bind(this) , false);
497 document.addEventListener('contextmenu', this._contextMenuEventFired.bind(th is), true); 451 document.addEventListener('contextmenu', this._contextMenuEventFired.bind(th is), true);
498 document.addEventListener('click', this._documentClick.bind(this), false);
499 } 452 }
500 453
501 /** 454 /**
502 * @param {!Common.Event} event 455 * @param {!Common.Event} event
503 */ 456 */
504 _reloadInspectedPage(event) { 457 _reloadInspectedPage(event) {
505 var hard = /** @type {boolean} */ (event.data); 458 var hard = /** @type {boolean} */ (event.data);
506 Main.Main._reloadPage(hard); 459 Main.Main._reloadPage(hard);
507 } 460 }
508 461
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 * @override 1002 * @override
1050 * @return {?Element} 1003 * @return {?Element}
1051 */ 1004 */
1052 settingElement() { 1005 settingElement() {
1053 return UI.SettingsUI.createSettingCheckbox( 1006 return UI.SettingsUI.createSettingCheckbox(
1054 Common.UIString('Show rulers'), Common.moduleSetting('showMetricsRulers' )); 1007 Common.UIString('Show rulers'), Common.moduleSetting('showMetricsRulers' ));
1055 } 1008 }
1056 }; 1009 };
1057 1010
1058 new Main.Main(); 1011 new Main.Main();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698