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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js

Issue 1952933002: DevTools: extract the report view to reuse in app manifest and service worker pane. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests fixed Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 499 }
500 500
501 return urlNode; 501 return urlNode;
502 } 502 }
503 503
504 return WebInspector.linkifyStringAsFragmentWithCustomLinkifier(string, linki fier); 504 return WebInspector.linkifyStringAsFragmentWithCustomLinkifier(string, linki fier);
505 } 505 }
506 506
507 /** 507 /**
508 * @param {string} url 508 * @param {string} url
509 * @param {string=} linkText
510 * @param {string=} classes
511 * @param {boolean=} isExternal
512 * @param {string=} tooltipText
513 * @return {!Element}
514 */
515 WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too ltipText)
516 {
517 if (!linkText)
518 linkText = url;
519
520 var a = createElementWithClass("a", classes);
521 var href = url;
522 if (url.trim().toLowerCase().startsWith("javascript:"))
523 href = null;
524 if (isExternal && WebInspector.ParsedURL.isRelativeURL(url))
525 href = null;
526 if (href !== null) {
527 a.href = href;
528 a.classList.add(isExternal ? "webkit-html-external-link" : "webkit-html- resource-link");
529 }
530 if (!tooltipText && linkText !== url)
531 a.title = url;
532 else if (tooltipText)
533 a.title = tooltipText;
534 a.textContent = linkText.trimMiddle(WebInspector.Linkifier.MaxLengthForDispl ayedURLs);
535 if (isExternal)
536 a.setAttribute("target", "_blank");
537
538 return a;
539 }
540
541 /**
542 * @param {string} article
543 * @param {string} title
544 * @return {!Element}
545 */
546 WebInspector.linkifyDocumentationURLAsNode = function(article, title)
547 {
548 return WebInspector.linkifyURLAsNode("https://developers.google.com/web/tool s/chrome-devtools/" + article, title, undefined, true);
549 }
550
551 /**
552 * @param {string} url
553 * @param {number=} lineNumber 509 * @param {number=} lineNumber
554 * @param {number=} columnNumber 510 * @param {number=} columnNumber
555 * @param {string=} classes 511 * @param {string=} classes
556 * @param {string=} tooltipText 512 * @param {string=} tooltipText
557 * @param {string=} urlDisplayName 513 * @param {string=} urlDisplayName
558 * @return {!Element} 514 * @return {!Element}
559 */ 515 */
560 WebInspector.linkifyResourceAsNode = function(url, lineNumber, columnNumber, cla sses, tooltipText, urlDisplayName) 516 WebInspector.linkifyResourceAsNode = function(url, lineNumber, columnNumber, cla sses, tooltipText, urlDisplayName)
561 { 517 {
562 var linkText = urlDisplayName ? urlDisplayName : url ? WebInspector.displayN ameForURL(url) : WebInspector.UIString("(program)"); 518 var linkText = urlDisplayName ? urlDisplayName : url ? WebInspector.displayN ameForURL(url) : WebInspector.UIString("(program)");
563 if (typeof lineNumber === "number") 519 if (typeof lineNumber === "number")
564 linkText += ":" + (lineNumber + 1); 520 linkText += ":" + (lineNumber + 1);
565 var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, to oltipText); 521 var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, to oltipText);
566 anchor.lineNumber = lineNumber; 522 anchor.lineNumber = lineNumber;
567 anchor.columnNumber = columnNumber; 523 anchor.columnNumber = columnNumber;
568 return anchor; 524 return anchor;
569 } 525 }
570 526
571 /** 527 /**
572 * @param {!WebInspector.NetworkRequest} request 528 * @param {!WebInspector.NetworkRequest} request
573 * @return {!Element} 529 * @return {!Element}
574 */ 530 */
575 WebInspector.linkifyRequestAsNode = function(request) 531 WebInspector.linkifyRequestAsNode = function(request)
576 { 532 {
577 var anchor = WebInspector.linkifyURLAsNode(request.url); 533 var anchor = WebInspector.linkifyURLAsNode(request.url);
578 anchor.requestId = request.requestId; 534 anchor.requestId = request.requestId;
579 return anchor; 535 return anchor;
580 } 536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698