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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 1534323003: DevTools: [CSS] do not treat random css comments as disabled properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp ('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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 1432
1433 /** 1433 /**
1434 * @param {string} token 1434 * @param {string} token
1435 * @param {?string} tokenType 1435 * @param {?string} tokenType
1436 * @param {number} column 1436 * @param {number} column
1437 * @param {number} newColumn 1437 * @param {number} newColumn
1438 */ 1438 */
1439 function processToken(token, tokenType, column, newColumn) 1439 function processToken(token, tokenType, column, newColumn)
1440 { 1440 {
1441 if (!insideProperty) { 1441 if (!insideProperty) {
1442 var isDisabledProperty = tokenType && tokenType.includes("css-co mment") && token.includes(":"); 1442 var disabledProperty = tokenType && tokenType.includes("css-comm ent") && isDisabledProperty(token);
1443 var isPropertyStart = tokenType && (tokenType.includes("css-meta ") || tokenType.includes("css-property")); 1443 var isPropertyStart = tokenType && (tokenType.includes("css-meta ") || tokenType.includes("css-property"));
1444 if (isDisabledProperty) { 1444 if (disabledProperty) {
1445 result = result.trimRight() + indentation + token; 1445 result = result.trimRight() + indentation + token;
1446 } else if (isPropertyStart) { 1446 } else if (isPropertyStart) {
1447 insideProperty = true; 1447 insideProperty = true;
1448 propertyText = token; 1448 propertyText = token;
1449 } else if (token !== ";") { 1449 } else if (token !== ";") {
1450 result += token; 1450 result += token;
1451 } 1451 }
1452 return; 1452 return;
1453 } 1453 }
1454 1454
1455 if (token === "}" || token === ";") { 1455 if (token === "}" || token === ";") {
1456 result = result.trimRight() + indentation + propertyText.trim() + ";"; 1456 result = result.trimRight() + indentation + propertyText.trim() + ";";
1457 insideProperty = false; 1457 insideProperty = false;
1458 if (token === "}") 1458 if (token === "}")
1459 result += "}"; 1459 result += "}";
1460 } else { 1460 } else {
1461 propertyText += token; 1461 propertyText += token;
1462 } 1462 }
1463 } 1463 }
1464
1465 /**
1466 * @param {string} text
1467 * @return {boolean}
1468 */
1469 function isDisabledProperty(text)
1470 {
1471 var colon = text.indexOf(":");
1472 if (colon === -1)
1473 return false;
1474 var propertyName = text.substring(2, colon).trim();
1475 return CSS.supports(propertyName, "initial") || propertyName.startsW ith("-moz-") || propertyName.startsWith("-o-") || propertyName.startsWith("-webk it-") || propertyName.startsWith("-ms-");
pfeldman 2016/01/04 21:27:01 You should either query the target (generated) css
lushnikov 2016/01/11 23:52:11 How are your suggestions better than this?
1476 }
1464 }, 1477 },
1465 1478
1466 /** 1479 /**
1467 * @param {string} text 1480 * @param {string} text
1468 * @return {string} 1481 * @return {string}
1469 */ 1482 */
1470 _detectIndentation: function(text) 1483 _detectIndentation: function(text)
1471 { 1484 {
1472 var lines = text.split("\n"); 1485 var lines = text.split("\n");
1473 if (lines.length < 2) 1486 if (lines.length < 2)
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 * @constructor 2393 * @constructor
2381 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle 2394 * @param {?WebInspector.CSSStyleDeclaration} inlineStyle
2382 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle 2395 * @param {?WebInspector.CSSStyleDeclaration} attributesStyle
2383 */ 2396 */
2384 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle) 2397 WebInspector.CSSStyleModel.InlineStyleResult = function(inlineStyle, attributesS tyle)
2385 { 2398 {
2386 this.inlineStyle = inlineStyle; 2399 this.inlineStyle = inlineStyle;
2387 this.attributesStyle = attributesStyle; 2400 this.attributesStyle = attributesStyle;
2388 } 2401 }
2389 2402
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorStyleSheet.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698