| OLD | NEW |
| 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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 }, | 1532 }, |
| 1533 | 1533 |
| 1534 /** | 1534 /** |
| 1535 * @param {!Document} document | 1535 * @param {!Document} document |
| 1536 */ | 1536 */ |
| 1537 applyTheme: function(document) | 1537 applyTheme: function(document) |
| 1538 { | 1538 { |
| 1539 if (!this._hasTheme()) | 1539 if (!this._hasTheme()) |
| 1540 return; | 1540 return; |
| 1541 | 1541 |
| 1542 if (this._themeName === "dark" || this._themeName === "bw" || this._them
eName === "nostalgie") |
| 1543 document.body.classList.add("-theme-with-dark-background"); |
| 1544 |
| 1542 var styleSheets = document.styleSheets; | 1545 var styleSheets = document.styleSheets; |
| 1543 var result = []; | 1546 var result = []; |
| 1544 for (var i = 0; i < styleSheets.length; ++i) | 1547 for (var i = 0; i < styleSheets.length; ++i) |
| 1545 result.push(this._patchForTheme(styleSheets[i].href, styleSheets[i])
); | 1548 result.push(this._patchForTheme(styleSheets[i].href, styleSheets[i])
); |
| 1546 result.push("/*# sourceURL=inspector_theme.css */"); | 1549 result.push("/*# sourceURL=inspector_theme.css */"); |
| 1547 | 1550 |
| 1548 var styleElement = createElement("style"); | 1551 var styleElement = createElement("style"); |
| 1549 styleElement.type = "text/css"; | 1552 styleElement.type = "text/css"; |
| 1550 styleElement.textContent = result.join("\n"); | 1553 styleElement.textContent = result.join("\n"); |
| 1551 document.head.appendChild(styleElement); | 1554 document.head.appendChild(styleElement); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 { | 1626 { |
| 1624 if (!this._themableProperties.has(name)) | 1627 if (!this._themableProperties.has(name)) |
| 1625 return; | 1628 return; |
| 1626 | 1629 |
| 1627 var value = style.getPropertyValue(name); | 1630 var value = style.getPropertyValue(name); |
| 1628 if (!value || value === "none" || value === "inherit" || value === "init
ial" || value === "transparent") | 1631 if (!value || value === "none" || value === "inherit" || value === "init
ial" || value === "transparent") |
| 1629 return; | 1632 return; |
| 1630 if (name === "background-image" && value.indexOf("gradient") === -1) | 1633 if (name === "background-image" && value.indexOf("gradient") === -1) |
| 1631 return; | 1634 return; |
| 1632 | 1635 |
| 1636 if (selectorText.indexOf("-theme-") !== -1) |
| 1637 return; |
| 1638 |
| 1633 var isSelection = selectorText.indexOf("select") !== -1 || selectorText.
indexOf("execution") !== -1; | 1639 var isSelection = selectorText.indexOf("select") !== -1 || selectorText.
indexOf("execution") !== -1; |
| 1634 var isSyntax = selectorText.indexOf("cm-") === -1 && selectorText.indexO
f("webkit-") === -1; | |
| 1635 var isBackground = name.indexOf("background") === 0 || name.indexOf("bor
der") === 0; | 1640 var isBackground = name.indexOf("background") === 0 || name.indexOf("bor
der") === 0; |
| 1636 var isForeground = name.indexOf("background") === -1; | 1641 var isForeground = name.indexOf("background") === -1; |
| 1637 | 1642 |
| 1638 var colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3
}|\b\w+\b(?!-))/g; | 1643 var colorRegex = /((?:rgb|hsl)a?\([^)]+\)|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3
}|\b\w+\b(?!-))/g; |
| 1639 output.push(name); | 1644 output.push(name); |
| 1640 output.push(":"); | 1645 output.push(":"); |
| 1641 var items = value.replace(colorRegex, "\0$1\0").split("\0"); | 1646 var items = value.replace(colorRegex, "\0$1\0").split("\0"); |
| 1642 for (var i = 0; i < items.length; ++i) | 1647 for (var i = 0; i < items.length; ++i) |
| 1643 output.push(this._patchColor(items[i], isSelection, isSyntax, isBack
ground, isForeground)); | 1648 output.push(this._patchColor(items[i], isSelection, isBackground, is
Foreground)); |
| 1644 if (style.getPropertyPriority(name)) | 1649 if (style.getPropertyPriority(name)) |
| 1645 output.push(" !important"); | 1650 output.push(" !important"); |
| 1646 output.push(";"); | 1651 output.push(";"); |
| 1647 }, | 1652 }, |
| 1648 | 1653 |
| 1649 /** | 1654 /** |
| 1650 * @param {string} text | 1655 * @param {string} text |
| 1651 * @param {boolean} isSelection | 1656 * @param {boolean} isSelection |
| 1652 * @param {boolean} isSyntax | |
| 1653 * @param {boolean} isBackground | 1657 * @param {boolean} isBackground |
| 1654 * @param {boolean} isForeground | 1658 * @param {boolean} isForeground |
| 1655 * @return {string} | 1659 * @return {string} |
| 1656 */ | 1660 */ |
| 1657 _patchColor: function(text, isSelection, isSyntax, isBackground, isForegroun
d) | 1661 _patchColor: function(text, isSelection, isBackground, isForeground) |
| 1658 { | 1662 { |
| 1659 var color = WebInspector.Color.parse(text); | 1663 var color = WebInspector.Color.parse(text); |
| 1660 if (!color) | 1664 if (!color) |
| 1661 return text; | 1665 return text; |
| 1662 | 1666 |
| 1663 var hsla = color.hsla(); | 1667 var hsla = color.hsla(); |
| 1664 | 1668 |
| 1665 this._patchHSLA(hsla, isSelection, isSyntax, isBackground, isForeground)
; | 1669 this._patchHSLA(hsla, isSelection, isBackground, isForeground); |
| 1666 | 1670 |
| 1667 var rgba = []; | 1671 var rgba = []; |
| 1668 WebInspector.Color.hsl2rgb(hsla, rgba); | 1672 WebInspector.Color.hsl2rgb(hsla, rgba); |
| 1669 var outColor = new WebInspector.Color(rgba, color.format()); | 1673 var outColor = new WebInspector.Color(rgba, color.format()); |
| 1670 var outText = outColor.asString(null); | 1674 var outText = outColor.asString(null); |
| 1671 if (!outText) | 1675 if (!outText) |
| 1672 outText = outColor.asString(outColor.hasAlpha() ? WebInspector.Color
.Format.RGBA : WebInspector.Color.Format.RGB); | 1676 outText = outColor.asString(outColor.hasAlpha() ? WebInspector.Color
.Format.RGBA : WebInspector.Color.Format.RGB); |
| 1673 return outText || text; | 1677 return outText || text; |
| 1674 }, | 1678 }, |
| 1675 | 1679 |
| 1676 /** | 1680 /** |
| 1677 * @param {!Array<number>} hsla | 1681 * @param {!Array<number>} hsla |
| 1678 * @param {boolean} isSelection | 1682 * @param {boolean} isSelection |
| 1679 * @param {boolean} isSyntax | |
| 1680 * @param {boolean} isBackground | 1683 * @param {boolean} isBackground |
| 1681 * @param {boolean} isForeground | 1684 * @param {boolean} isForeground |
| 1682 */ | 1685 */ |
| 1683 _patchHSLA: function(hsla, isSelection, isSyntax, isBackground, isForeground
) | 1686 _patchHSLA: function(hsla, isSelection, isBackground, isForeground) |
| 1684 { | 1687 { |
| 1685 var hue = hsla[0]; | 1688 var hue = hsla[0]; |
| 1686 var sat = hsla[1]; | 1689 var sat = hsla[1]; |
| 1687 var lit = hsla[2]; | 1690 var lit = hsla[2]; |
| 1688 var alpha = hsla[3] | 1691 var alpha = hsla[3] |
| 1689 var isSelectionBlue = isSelection && hue > 0.57 && hue < 0.68; | 1692 var isSelectionBlue = isSelection && hue > 0.57 && hue < 0.68; |
| 1690 | 1693 |
| 1691 switch (this._themeName) { | 1694 switch (this._themeName) { |
| 1692 case "dark": | 1695 case "dark": |
| 1693 if (isSelectionBlue) | 1696 if (isSelectionBlue) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1715 sat = 0.82; | 1718 sat = 0.82; |
| 1716 } | 1719 } |
| 1717 break; | 1720 break; |
| 1718 case "blue": | 1721 case "blue": |
| 1719 if (sat < 0.17) { | 1722 if (sat < 0.17) { |
| 1720 hue = 0.66; | 1723 hue = 0.66; |
| 1721 sat = 0.82; | 1724 sat = 0.82; |
| 1722 } | 1725 } |
| 1723 break; | 1726 break; |
| 1724 case "bw": | 1727 case "bw": |
| 1725 if (isSelectionBlue) | |
| 1726 hue = 27 / 360; | |
| 1727 | |
| 1728 lit = 1 - lit; | 1728 lit = 1 - lit; |
| 1729 if (lit > 0.98 && isForeground) | 1729 if (lit > 0.98 && isForeground) |
| 1730 lit = 0.98; | 1730 lit = 0.98; |
| 1731 | 1731 |
| 1732 if (!isSyntax) { | 1732 if (lit > 0.8) |
| 1733 if (lit > 0.8) | 1733 lit = 1; |
| 1734 lit = 1; | 1734 if (lit < 0.2) |
| 1735 if (lit < 0.2) | 1735 lit = 0; |
| 1736 lit = 0; | 1736 sat = 0; |
| 1737 sat = 0; | 1737 |
| 1738 } | |
| 1739 break; | 1738 break; |
| 1740 case "nostalgie": | 1739 case "nostalgie": |
| 1741 lit = 1 - lit; | 1740 lit = 1 - lit; |
| 1742 | 1741 |
| 1743 if (isSelectionBlue) { | 1742 if (isSelectionBlue) { |
| 1744 hue = 0.5; | 1743 hue = 0.5; |
| 1745 lit -= 0.1; | 1744 lit -= 0.1; |
| 1746 break; | 1745 break; |
| 1747 } | 1746 } |
| 1748 | 1747 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1767 } | 1766 } |
| 1768 hsla[0] = Number.constrain(hue, 0, 1); | 1767 hsla[0] = Number.constrain(hue, 0, 1); |
| 1769 hsla[1] = Number.constrain(sat, 0, 1); | 1768 hsla[1] = Number.constrain(sat, 0, 1); |
| 1770 hsla[2] = Number.constrain(lit, 0, 1); | 1769 hsla[2] = Number.constrain(lit, 0, 1); |
| 1771 hsla[3] = Number.constrain(alpha, 0, 1); | 1770 hsla[3] = Number.constrain(alpha, 0, 1); |
| 1772 } | 1771 } |
| 1773 } | 1772 } |
| 1774 | 1773 |
| 1775 /** @type {!WebInspector.ThemeSupport} */ | 1774 /** @type {!WebInspector.ThemeSupport} */ |
| 1776 WebInspector.themeSupport; | 1775 WebInspector.themeSupport; |
| OLD | NEW |