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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/UIUtils.js

Issue 2527763003: [DevTools] Turn links into spans to prevent default behavior. (Closed)
Patch Set: Created 4 years 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 * @param {string} url 1912 * @param {string} url
1913 * @param {string=} linkText 1913 * @param {string=} linkText
1914 * @param {string=} className 1914 * @param {string=} className
1915 * @param {boolean=} preventClick 1915 * @param {boolean=} preventClick
1916 * @return {!Element} 1916 * @return {!Element}
1917 */ 1917 */
1918 UI.createExternalLink = function(url, linkText, className, preventClick) { 1918 UI.createExternalLink = function(url, linkText, className, preventClick) {
1919 if (!linkText) 1919 if (!linkText)
1920 linkText = url; 1920 linkText = url;
1921 1921
1922 var a = createElementWithClass('a', className); 1922 var a = createElementWithClass('span', className);
1923 var href = url; 1923 var href = url;
1924 if (url.trim().toLowerCase().startsWith('javascript:')) 1924 if (url.trim().toLowerCase().startsWith('javascript:'))
1925 href = null; 1925 href = null;
1926 if (Common.ParsedURL.isRelativeURL(url)) 1926 if (Common.ParsedURL.isRelativeURL(url))
1927 href = null; 1927 href = null;
1928 if (href !== null) { 1928 if (href !== null) {
1929 a.href = href; 1929 a.href = href;
1930 a.classList.add('webkit-html-external-link'); 1930 a.classList.add('devtools-link');
1931 a.addEventListener('click', (event) => { 1931 if (!preventClick) {
1932 event.consume(true); 1932 a.addEventListener('click', (event) => {
1933 if (!preventClick) 1933 event.consume(true);
1934 InspectorFrontendHost.openInNewTab(/** @type {string} */ (href)); 1934 InspectorFrontendHost.openInNewTab(/** @type {string} */ (href));
1935 }, false); 1935 }, false);
1936 } else {
1937 a.classList.add('devtools-link-prevent-clinkelements');
lushnikov 2016/11/24 00:14:39 clinkelements?
dgozman 2016/11/24 00:58:29 Fixed :-)
1938 }
1936 a[UI._externalLinkSymbol] = true; 1939 a[UI._externalLinkSymbol] = true;
1937 } 1940 }
1938 if (linkText !== url) 1941 if (linkText !== url)
1939 a.title = url; 1942 a.title = url;
1940 a.textContent = linkText.trimMiddle(150); 1943 a.textContent = linkText.trimMiddle(150);
1941 a.setAttribute('target', '_blank'); 1944 a.setAttribute('target', '_blank');
1942 1945
1943 return a; 1946 return a;
1944 }; 1947 };
1945 1948
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 return new Promise(fulfill => { 1988 return new Promise(fulfill => {
1986 var image = new Image(); 1989 var image = new Image();
1987 image.addEventListener('load', () => fulfill(image)); 1990 image.addEventListener('load', () => fulfill(image));
1988 image.addEventListener('error', () => fulfill(null)); 1991 image.addEventListener('error', () => fulfill(null));
1989 image.src = url; 1992 image.src = url;
1990 }); 1993 });
1991 }; 1994 };
1992 1995
1993 /** @type {!UI.ThemeSupport} */ 1996 /** @type {!UI.ThemeSupport} */
1994 UI.themeSupport; 1997 UI.themeSupport;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698