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

Side by Side Diff: WebCore/inspector/front-end/StylesSidebarPane.js

Issue 6115007: Merge 74710 - 2010-12-28 Alexander Pavlov <apavlov@chromium.org>... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/597/
Patch Set: Created 9 years, 11 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 | « no previous file | 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) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 var nameElement = document.createElement("span"); 1195 var nameElement = document.createElement("span");
1196 nameElement.className = "webkit-css-property"; 1196 nameElement.className = "webkit-css-property";
1197 nameElement.textContent = this.name; 1197 nameElement.textContent = this.name;
1198 this.nameElement = nameElement; 1198 this.nameElement = nameElement;
1199 1199
1200 var valueElement = document.createElement("span"); 1200 var valueElement = document.createElement("span");
1201 valueElement.className = "value"; 1201 valueElement.className = "value";
1202 this.valueElement = valueElement; 1202 this.valueElement = valueElement;
1203 1203
1204 if (value) { 1204 if (value) {
1205 var self = this;
1206
1205 function processValue(regex, processor, nextProcessor, valueText) 1207 function processValue(regex, processor, nextProcessor, valueText)
1206 { 1208 {
1207 var container = document.createDocumentFragment(); 1209 var container = document.createDocumentFragment();
1208 1210
1209 var items = valueText.replace(regex, "\0$1\0").split("\0"); 1211 var items = valueText.replace(regex, "\0$1\0").split("\0");
1210 for (var i = 0; i < items.length; ++i) { 1212 for (var i = 0; i < items.length; ++i) {
1211 if ((i % 2) === 0) { 1213 if ((i % 2) === 0) {
1212 if (nextProcessor) 1214 if (nextProcessor)
1213 container.appendChild(nextProcessor(items[i])); 1215 container.appendChild(nextProcessor(items[i]));
1214 else 1216 else
1215 container.appendChild(document.createTextNode(items[ i])); 1217 container.appendChild(document.createTextNode(items[ i]));
1216 } else { 1218 } else {
1217 var processedNode = processor(items[i]); 1219 var processedNode = processor(items[i]);
1218 if (processedNode) 1220 if (processedNode)
1219 container.appendChild(processedNode); 1221 container.appendChild(processedNode);
1220 } 1222 }
1221 } 1223 }
1222 1224
1223 return container; 1225 return container;
1224 } 1226 }
1225 1227
1226 function linkifyURL(url) 1228 function linkifyURL(url)
1227 { 1229 {
1230 var hrefUrl = url;
1231 var match = hrefUrl.match(/['"]?([^'"]+)/);
1232 if (match)
1233 hrefUrl = match[1];
1228 var container = document.createDocumentFragment(); 1234 var container = document.createDocumentFragment();
1229 container.appendChild(document.createTextNode("url(")); 1235 container.appendChild(document.createTextNode("url("));
1230 var hasResource = !!WebInspector.resourceForURL(url); 1236 if (self._styleRule.sourceURL)
1231 container.appendChild(WebInspector.linkifyURLAsNode(url, url, nu ll, hasResource)); 1237 hrefUrl = WebInspector.completeURL(self._styleRule.sourceURL , hrefUrl);
1238 else if (WebInspector.panels.elements.focusedDOMNode)
1239 hrefUrl = WebInspector.resourceURLForRelatedNode(WebInspecto r.panels.elements.focusedDOMNode, hrefUrl);
1240 var hasResource = !!WebInspector.resourceForURL(hrefUrl);
1241 // FIXME: WebInspector.linkifyURLAsNode() should really use base URI.
1242 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl, url , null, hasResource));
1232 container.appendChild(document.createTextNode(")")); 1243 container.appendChild(document.createTextNode(")"));
1233 return container; 1244 return container;
1234 } 1245 }
1235 1246
1236 function processColor(text) 1247 function processColor(text)
1237 { 1248 {
1238 try { 1249 try {
1239 var color = new WebInspector.Color(text); 1250 var color = new WebInspector.Color(text);
1240 } catch (e) { 1251 } catch (e) {
1241 return document.createTextNode(text); 1252 return document.createTextNode(text);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 1334
1324 var container = document.createDocumentFragment(); 1335 var container = document.createDocumentFragment();
1325 container.appendChild(swatchElement); 1336 container.appendChild(swatchElement);
1326 container.appendChild(colorValueElement); 1337 container.appendChild(colorValueElement);
1327 return container; 1338 return container;
1328 } 1339 }
1329 1340
1330 var colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA- F]{3}|\b\w+\b(?!-))/g; 1341 var colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA- F]{3}|\b\w+\b(?!-))/g;
1331 var colorProcessor = processValue.bind(window, colorRegex, processCo lor, null); 1342 var colorProcessor = processValue.bind(window, colorRegex, processCo lor, null);
1332 1343
1333 valueElement.appendChild(processValue(/url\(([^)]+)\)/g, linkifyURL, colorProcessor, value)); 1344 valueElement.appendChild(processValue(/url\(\s*([^)\s]+)\s*\)/g, lin kifyURL, colorProcessor, value));
1334 } 1345 }
1335 1346
1336 this.listItemElement.removeChildren(); 1347 this.listItemElement.removeChildren();
1337 1348
1338 if (!this.treeOutline) 1349 if (!this.treeOutline)
1339 return; 1350 return;
1340 1351
1341 // Append the checkbox for root elements of an editable section. 1352 // Append the checkbox for root elements of an editable section.
1342 if (enabledCheckboxElement && this.treeOutline.section && this.treeOutli ne.section.editable && this.parent.root) 1353 if (enabledCheckboxElement && this.treeOutline.section && this.treeOutli ne.section.editable && this.parent.root)
1343 this.listItemElement.appendChild(enabledCheckboxElement); 1354 this.listItemElement.appendChild(enabledCheckboxElement);
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1776
1766 // Append a ";" if the new text does not end in ";". 1777 // Append a ";" if the new text does not end in ";".
1767 // FIXME: this does not handle trailing comments. 1778 // FIXME: this does not handle trailing comments.
1768 if (styleText.length && !/;\s*$/.test(styleText)) 1779 if (styleText.length && !/;\s*$/.test(styleText))
1769 styleText += ";"; 1780 styleText += ";";
1770 this.property.setText(styleText, updateInterface, callback.bind(this)); 1781 this.property.setText(styleText, updateInterface, callback.bind(this));
1771 } 1782 }
1772 } 1783 }
1773 1784
1774 WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototyp e; 1785 WebInspector.StylePropertyTreeElement.prototype.__proto__ = TreeElement.prototyp e;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698