Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 | 517 |
| 518 styleRules = []; | 518 styleRules = []; |
| 519 var pseudoId = pseudoElementCSSRules.pseudoId; | 519 var pseudoId = pseudoElementCSSRules.pseudoId; |
| 520 | 520 |
| 521 var entry = { isStyleSeparator: true, pseudoId: pseudoId }; | 521 var entry = { isStyleSeparator: true, pseudoId: pseudoId }; |
| 522 styleRules.push(entry); | 522 styleRules.push(entry); |
| 523 | 523 |
| 524 // Add rules in reverse order to match the cascade order. | 524 // Add rules in reverse order to match the cascade order. |
| 525 for (var j = pseudoElementCSSRules.rules.length - 1; j >= 0; --j) { | 525 for (var j = pseudoElementCSSRules.rules.length - 1; j >= 0; --j) { |
| 526 var rule = pseudoElementCSSRules.rules[j]; | 526 var rule = pseudoElementCSSRules.rules[j]; |
| 527 styleRules.push({ style: rule.style, selectorText: rule.selector Text, media: rule.media, sourceURL: rule.resourceURL(), rule: rule, editable: !! (rule.style && rule.style.styleSheetId) }); | 527 styleRules.push({ style: rule.style, selectorText: rule.selector Text, media: rule.media, rule: rule, editable: !!(rule.style && rule.style.style SheetId) }); |
| 528 } | 528 } |
| 529 usedProperties = {}; | 529 usedProperties = {}; |
| 530 this._markUsedProperties(styleRules, usedProperties); | 530 this._markUsedProperties(styleRules, usedProperties); |
| 531 this.sections[pseudoId] = this._rebuildSectionsForStyleRules(styleRu les, usedProperties, anchorElement); | 531 this.sections[pseudoId] = this._rebuildSectionsForStyleRules(styleRu les, usedProperties, anchorElement); |
| 532 } | 532 } |
| 533 | 533 |
| 534 if (this._filterRegex) | 534 if (this._filterRegex) |
| 535 this._updateFilter(false); | 535 this._updateFilter(false); |
| 536 this._nodeStylesUpdatedForTest(node, true); | 536 this._nodeStylesUpdatedForTest(node, true); |
| 537 }, | 537 }, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 | 587 |
| 588 // Add rules in reverse order to match the cascade order. | 588 // Add rules in reverse order to match the cascade order. |
| 589 var addedAttributesStyle; | 589 var addedAttributesStyle; |
| 590 for (var i = styles.matchedCSSRules.length - 1; i >= 0; --i) { | 590 for (var i = styles.matchedCSSRules.length - 1; i >= 0; --i) { |
| 591 var rule = styles.matchedCSSRules[i]; | 591 var rule = styles.matchedCSSRules[i]; |
| 592 if ((rule.isUser || rule.isUserAgent) && !addedAttributesStyle) { | 592 if ((rule.isUser || rule.isUserAgent) && !addedAttributesStyle) { |
| 593 // Show element's Style Attributes after all author rules. | 593 // Show element's Style Attributes after all author rules. |
| 594 addedAttributesStyle = true; | 594 addedAttributesStyle = true; |
| 595 addAttributesStyle(); | 595 addAttributesStyle(); |
| 596 } | 596 } |
| 597 styleRules.push({ style: rule.style, selectorText: rule.selectorText , media: rule.media, sourceURL: rule.resourceURL(), rule: rule, editable: !!(rul e.style && rule.style.styleSheetId) }); | 597 styleRules.push({ style: rule.style, selectorText: rule.selectorText , media: rule.media, rule: rule, editable: !!(rule.style && rule.style.styleShee tId) }); |
| 598 } | 598 } |
| 599 | 599 |
| 600 if (!addedAttributesStyle) | 600 if (!addedAttributesStyle) |
| 601 addAttributesStyle(); | 601 addAttributesStyle(); |
| 602 | 602 |
| 603 // Walk the node structure and identify styles with inherited properties . | 603 // Walk the node structure and identify styles with inherited properties . |
| 604 var parentNode = node.parentNode; | 604 var parentNode = node.parentNode; |
| 605 function insertInheritedNodeSeparator(node) | 605 function insertInheritedNodeSeparator(node) |
| 606 { | 606 { |
| 607 var entry = {}; | 607 var entry = {}; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 627 for (var i = parentStyles.matchedCSSRules.length - 1; i >= 0; --i) { | 627 for (var i = parentStyles.matchedCSSRules.length - 1; i >= 0; --i) { |
| 628 var rulePayload = parentStyles.matchedCSSRules[i]; | 628 var rulePayload = parentStyles.matchedCSSRules[i]; |
| 629 if (!this._containsInherited(rulePayload.style)) | 629 if (!this._containsInherited(rulePayload.style)) |
| 630 continue; | 630 continue; |
| 631 var rule = rulePayload; | 631 var rule = rulePayload; |
| 632 | 632 |
| 633 if (!separatorInserted) { | 633 if (!separatorInserted) { |
| 634 insertInheritedNodeSeparator(parentNode); | 634 insertInheritedNodeSeparator(parentNode); |
| 635 separatorInserted = true; | 635 separatorInserted = true; |
| 636 } | 636 } |
| 637 styleRules.push({ style: rule.style, selectorText: rule.selector Text, media: rule.media, sourceURL: rule.resourceURL(), rule: rule, isInherited: true, parentNode: parentNode, editable: !!(rule.style && rule.style.styleSheetI d) }); | 637 styleRules.push({ style: rule.style, selectorText: rule.selector Text, media: rule.media, rule: rule, isInherited: true, parentNode: parentNode, editable: !!(rule.style && rule.style.styleSheetId) }); |
| 638 } | 638 } |
| 639 parentNode = parentNode.parentNode; | 639 parentNode = parentNode.parentNode; |
| 640 } | 640 } |
| 641 return styleRules; | 641 return styleRules; |
| 642 }, | 642 }, |
| 643 | 643 |
| 644 _markUsedProperties: function(styleRules, usedProperties) | 644 _markUsedProperties: function(styleRules, usedProperties) |
| 645 { | 645 { |
| 646 var foundImportantProperties = {}; | 646 var foundImportantProperties = {}; |
| 647 var propertyToEffectiveRule = {}; | 647 var propertyToEffectiveRule = {}; |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1524 var property = style.newBlankProperty(index); | 1524 var property = style.newBlankProperty(index); |
| 1525 var item = new WebInspector.StylePropertyTreeElement(this._parentPane, t his.styleRule, style, property, false, false, false); | 1525 var item = new WebInspector.StylePropertyTreeElement(this._parentPane, t his.styleRule, style, property, false, false, false); |
| 1526 index = property.index; | 1526 index = property.index; |
| 1527 this.propertiesTreeOutline.insertChild(item, index); | 1527 this.propertiesTreeOutline.insertChild(item, index); |
| 1528 item.listItemElement.textContent = ""; | 1528 item.listItemElement.textContent = ""; |
| 1529 item._newProperty = true; | 1529 item._newProperty = true; |
| 1530 item.updateTitle(); | 1530 item.updateTitle(); |
| 1531 return item; | 1531 return item; |
| 1532 }, | 1532 }, |
| 1533 | 1533 |
| 1534 _createRuleOriginNode: function() | 1534 /** |
| 1535 * @param {?WebInspector.CSSRule} rule | |
| 1536 * @param {!WebInspector.TextRange=} ruleLocation | |
| 1537 * @return {!Node} | |
| 1538 */ | |
| 1539 _createRuleOriginNode: function(rule, ruleLocation) | |
| 1535 { | 1540 { |
| 1536 /** | 1541 /** |
| 1537 * @param {string} url | 1542 * @param {string} url |
| 1538 * @param {number} line | 1543 * @param {number} line |
| 1539 */ | 1544 */ |
| 1540 function linkifyUncopyable(url, line) | 1545 function linkifyUncopyable(url, line) |
| 1541 { | 1546 { |
| 1542 var link = WebInspector.linkifyResourceAsNode(url, line, "", url + " :" + (line + 1)); | 1547 var link = WebInspector.linkifyResourceAsNode(url, line, "", url + " :" + (line + 1)); |
| 1543 link.classList.add("webkit-html-resource-link"); | 1548 link.classList.add("webkit-html-resource-link"); |
| 1544 link.setAttribute("data-uncopyable", link.textContent); | 1549 link.setAttribute("data-uncopyable", link.textContent); |
| 1545 link.textContent = ""; | 1550 link.textContent = ""; |
| 1546 return link; | 1551 return link; |
| 1547 } | 1552 } |
| 1548 | 1553 |
| 1549 if (this.styleRule.sourceURL) { | 1554 if (!rule) |
| 1550 var firstMatchingIndex = this.styleRule.rule.matchingSelectors && th is.rule.matchingSelectors.length ? this.rule.matchingSelectors[0] : 0; | 1555 return document.createTextNode(""); |
| 1551 var matchingSelectorLocation = new WebInspector.CSSLocation(this._pa rentPane._target, this.rule.styleSheetId, this.styleRule.sourceURL, this.rule.li neNumberInSource(firstMatchingIndex), this.rule.columnNumberInSource(firstMatchi ngIndex)); | 1556 |
| 1552 return this._parentPane._linkifier.linkifyCSSLocation(matchingSelect orLocation) || linkifyUncopyable(this.styleRule.sourceURL, this.rule.lineNumberI nSource()); | 1557 if (!ruleLocation) { |
| 1558 var firstMatchingIndex = rule.matchingSelectors && rule.matchingSele ctors.length ? rule.matchingSelectors[0] : 0; | |
| 1559 ruleLocation = rule.selectors[firstMatchingIndex].range; | |
| 1553 } | 1560 } |
| 1554 | 1561 |
| 1555 if (!this.rule) | 1562 var sourceURL = rule.resourceURL(); |
| 1556 return document.createTextNode(""); | 1563 if (sourceURL && ruleLocation && rule.styleSheetId) { |
| 1564 var styleSheetHeader = this._parentPane._target.cssModel.styleSheetH eaderForId(rule.styleSheetId); | |
| 1565 var lineNumber = styleSheetHeader.lineNumberInSource(ruleLocation.st artLine); | |
| 1566 var columnNumber = styleSheetHeader.columnNumberInSource(ruleLocatio n.startLine, ruleLocation.startColumn); | |
| 1567 var matchingSelectorLocation = new WebInspector.CSSLocation(this._pa rentPane._target, rule.styleSheetId, sourceURL, lineNumber, columnNumber); | |
| 1568 return this._parentPane._linkifier.linkifyCSSLocation(matchingSelect orLocation) || linkifyUncopyable(sourceURL, 0); | |
| 1569 } | |
| 1557 | 1570 |
| 1558 if (this.rule.isUserAgent) | 1571 if (rule.isUserAgent) |
| 1559 return document.createTextNode(WebInspector.UIString("user agent sty lesheet")); | 1572 return document.createTextNode(WebInspector.UIString("user agent sty lesheet")); |
| 1560 if (this.rule.isUser) | 1573 if (rule.isUser) |
| 1561 return document.createTextNode(WebInspector.UIString("user styleshee t")); | 1574 return document.createTextNode(WebInspector.UIString("user styleshee t")); |
| 1562 if (this.rule.isViaInspector) | 1575 if (rule.isViaInspector) |
| 1563 return document.createTextNode(WebInspector.UIString("via inspector" )); | 1576 return this._createRuleViaInspectorOriginNode(); |
| 1564 return document.createTextNode(""); | 1577 return document.createTextNode(""); |
| 1565 }, | 1578 }, |
| 1566 | 1579 |
| 1580 /** | |
| 1581 * @return {!Node} | |
| 1582 */ | |
| 1583 _createRuleViaInspectorOriginNode: function() | |
| 1584 { | |
| 1585 return document.createTextNode(WebInspector.UIString("via inspector")); | |
| 1586 }, | |
| 1587 | |
| 1567 _handleEmptySpaceMouseDown: function() | 1588 _handleEmptySpaceMouseDown: function() |
| 1568 { | 1589 { |
| 1569 this._willCauseCancelEditing = this._parentPane._isEditingStyle; | 1590 this._willCauseCancelEditing = this._parentPane._isEditingStyle; |
| 1570 }, | 1591 }, |
| 1571 | 1592 |
| 1572 _handleEmptySpaceClick: function(event) | 1593 _handleEmptySpaceClick: function(event) |
| 1573 { | 1594 { |
| 1574 if (!this.editable) | 1595 if (!this.editable) |
| 1575 return; | 1596 return; |
| 1576 | 1597 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1685 if (!doesAffectSelectedNode) { | 1706 if (!doesAffectSelectedNode) { |
| 1686 this.noAffect = true; | 1707 this.noAffect = true; |
| 1687 this.element.classList.add("no-affect"); | 1708 this.element.classList.add("no-affect"); |
| 1688 } else { | 1709 } else { |
| 1689 delete this.noAffect; | 1710 delete this.noAffect; |
| 1690 this.element.classList.remove("no-affect"); | 1711 this.element.classList.remove("no-affect"); |
| 1691 } | 1712 } |
| 1692 | 1713 |
| 1693 var oldSelectorRange = this.rule.selectorRange; | 1714 var oldSelectorRange = this.rule.selectorRange; |
| 1694 this.rule = newRule; | 1715 this.rule = newRule; |
| 1695 this.styleRule = { section: this, style: newRule.style, selectorText : newRule.selectorText, media: newRule.media, sourceURL: newRule.resourceURL(), rule: newRule }; | 1716 this.styleRule = { section: this, style: newRule.style, selectorText : newRule.selectorText, media: newRule.media, rule: newRule }; |
| 1696 | 1717 |
| 1697 this._parentPane.update(selectedNode); | 1718 this._parentPane.update(selectedNode); |
| 1698 this._parentPane._styleSheetRuleEdited(this.rule, oldSelectorRange, this.rule.selectorRange); | 1719 this._parentPane._styleSheetRuleEdited(this.rule, oldSelectorRange, this.rule.selectorRange); |
| 1699 | 1720 |
| 1700 finishOperationAndMoveEditor.call(this, moveDirection); | 1721 finishOperationAndMoveEditor.call(this, moveDirection); |
| 1701 } | 1722 } |
| 1702 | 1723 |
| 1703 /** | 1724 /** |
| 1704 * @this {WebInspector.StylePropertiesSection} | 1725 * @this {WebInspector.StylePropertiesSection} |
| 1705 */ | 1726 */ |
| 1706 function finishOperationAndMoveEditor(direction) | 1727 function finishOperationAndMoveEditor(direction) |
| 1707 { | 1728 { |
| 1708 delete this._parentPane._userOperation; | 1729 delete this._parentPane._userOperation; |
| 1709 this._moveEditorFromSelector(direction); | 1730 this._moveEditorFromSelector(direction); |
| 1710 } | 1731 } |
| 1711 | 1732 |
| 1712 // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure. | 1733 // This gets deleted in finishOperationAndMoveEditor(), which is called both on success and failure. |
| 1713 this._parentPane._userOperation = true; | 1734 this._parentPane._userOperation = true; |
| 1714 this._parentPane._target.cssModel.setRuleSelector(this.rule, selectedNod e ? selectedNode.id : 0, newContent, successCallback.bind(this), finishOperation AndMoveEditor.bind(this, moveDirection)); | 1735 this._parentPane._target.cssModel.setRuleSelector(this.rule, selectedNod e ? selectedNode.id : 0, newContent, successCallback.bind(this), finishOperation AndMoveEditor.bind(this, moveDirection)); |
| 1715 }, | 1736 }, |
| 1716 | 1737 |
| 1717 _updateRuleOrigin: function() | 1738 _updateRuleOrigin: function() |
| 1718 { | 1739 { |
| 1719 this._selectorRefElement.removeChildren(); | 1740 this._selectorRefElement.removeChildren(); |
| 1720 this._selectorRefElement.appendChild(this._createRuleOriginNode()); | 1741 this._selectorRefElement.appendChild(this._createRuleOriginNode(this.rul e)); |
| 1721 }, | 1742 }, |
| 1722 | 1743 |
| 1723 _editingSelectorEnded: function() | 1744 _editingSelectorEnded: function() |
| 1724 { | 1745 { |
| 1725 delete this._parentPane._isEditingStyle; | 1746 delete this._parentPane._isEditingStyle; |
| 1726 }, | 1747 }, |
| 1727 | 1748 |
| 1728 editingSelectorCancelled: function() | 1749 editingSelectorCancelled: function() |
| 1729 { | 1750 { |
| 1730 this._editingSelectorEnded(); | 1751 this._editingSelectorEnded(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1847 | 1868 |
| 1848 var treeElement = this._propertyTreeElements[property.name.toLow erCase()]; | 1869 var treeElement = this._propertyTreeElements[property.name.toLow erCase()]; |
| 1849 if (treeElement) { | 1870 if (treeElement) { |
| 1850 var fragment = document.createDocumentFragment(); | 1871 var fragment = document.createDocumentFragment(); |
| 1851 var selector = fragment.createChild("span"); | 1872 var selector = fragment.createChild("span"); |
| 1852 selector.style.color = "gray"; | 1873 selector.style.color = "gray"; |
| 1853 selector.textContent = section.styleRule.selectorText; | 1874 selector.textContent = section.styleRule.selectorText; |
| 1854 fragment.appendChild(document.createTextNode(" - " + propert y.value + " ")); | 1875 fragment.appendChild(document.createTextNode(" - " + propert y.value + " ")); |
| 1855 var subtitle = fragment.createChild("span"); | 1876 var subtitle = fragment.createChild("span"); |
| 1856 subtitle.style.float = "right"; | 1877 subtitle.style.float = "right"; |
| 1857 subtitle.appendChild(section._createRuleOriginNode()); | 1878 subtitle.appendChild(section._createRuleOriginNode(section.r ule)); |
| 1858 var childElement = new TreeElement(fragment, null, false); | 1879 var childElement = new TreeElement(fragment, null, false); |
| 1859 treeElement.appendChild(childElement); | 1880 treeElement.appendChild(childElement); |
| 1860 if (property.inactive || section.isPropertyOverloaded(proper ty.name)) | 1881 if (property.inactive || section.isPropertyOverloaded(proper ty.name)) |
| 1861 childElement.listItemElement.classList.add("overloaded") ; | 1882 childElement.listItemElement.classList.add("overloaded") ; |
| 1862 if (!property.parsedOk) { | 1883 if (!property.parsedOk) { |
| 1863 childElement.listItemElement.classList.add("not-parsed-o k"); | 1884 childElement.listItemElement.classList.add("not-parsed-o k"); |
| 1864 childElement.listItemElement.insertBefore(WebInspector.S tylesSidebarPane.createExclamationMark(property), childElement.listItemElement.f irstChild); | 1885 childElement.listItemElement.insertBefore(WebInspector.S tylesSidebarPane.createExclamationMark(property), childElement.listItemElement.f irstChild); |
| 1865 if (WebInspector.StylesSidebarPane._ignoreErrorsForPrope rty(property)) | 1886 if (WebInspector.StylesSidebarPane._ignoreErrorsForPrope rty(property)) |
| 1866 childElement.listItemElement.classList.add("has-igno rable-error"); | 1887 childElement.listItemElement.classList.add("has-igno rable-error"); |
| 1867 } | 1888 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1884 * @extends {WebInspector.StylePropertiesSection} | 1905 * @extends {WebInspector.StylePropertiesSection} |
| 1885 * @param {!WebInspector.StylesSidebarPane} stylesPane | 1906 * @param {!WebInspector.StylesSidebarPane} stylesPane |
| 1886 * @param {string} defaultSelectorText | 1907 * @param {string} defaultSelectorText |
| 1887 * @param {string} styleSheetId | 1908 * @param {string} styleSheetId |
| 1888 * @param {!WebInspector.TextRange} ruleLocation | 1909 * @param {!WebInspector.TextRange} ruleLocation |
| 1889 * @param {!WebInspector.CSSRule=} insertAfterRule | 1910 * @param {!WebInspector.CSSRule=} insertAfterRule |
| 1890 */ | 1911 */ |
| 1891 WebInspector.BlankStylePropertiesSection = function(stylesPane, defaultSelectorT ext, styleSheetId, ruleLocation, insertAfterRule) | 1912 WebInspector.BlankStylePropertiesSection = function(stylesPane, defaultSelectorT ext, styleSheetId, ruleLocation, insertAfterRule) |
| 1892 { | 1913 { |
| 1893 var styleSheetHeader = WebInspector.cssModel.styleSheetHeaderForId(styleShee tId); | 1914 var styleSheetHeader = WebInspector.cssModel.styleSheetHeaderForId(styleShee tId); |
| 1894 WebInspector.StylePropertiesSection.call(this, stylesPane, {selectorText: de faultSelectorText, rule: {isViaInspector: styleSheetHeader.isViaInspector()}}, t rue, false); | 1915 WebInspector.StylePropertiesSection.call(this, stylesPane, { selectorText: d efaultSelectorText }, true, false); |
| 1895 this._ruleLocation = ruleLocation; | 1916 this._ruleLocation = ruleLocation; |
| 1896 this._styleSheetId = styleSheetId; | 1917 this._styleSheetId = styleSheetId; |
| 1897 if (insertAfterRule) | 1918 this._selectorRefElement.removeChildren(); |
| 1919 if (insertAfterRule) { | |
| 1920 this._selectorRefElement.appendChild(this._createRuleOriginNode(insertAf terRule, this._actualRuleLocation())); | |
| 1898 this._createMediaList(insertAfterRule); | 1921 this._createMediaList(insertAfterRule); |
| 1922 } else { | |
| 1923 this._selectorRefElement.appendChild(this._createRuleViaInspectorOriginN ode()); | |
| 1924 } | |
| 1899 this.element.classList.add("blank-section"); | 1925 this.element.classList.add("blank-section"); |
| 1900 } | 1926 } |
| 1901 | 1927 |
| 1902 WebInspector.BlankStylePropertiesSection.prototype = { | 1928 WebInspector.BlankStylePropertiesSection.prototype = { |
| 1929 /** | |
| 1930 * @return {!WebInspector.TextRange} | |
| 1931 */ | |
| 1932 _actualRuleLocation: function() | |
| 1933 { | |
| 1934 var prefix = this._rulePrefix(); | |
| 1935 var lines = prefix.split("\n"); | |
| 1936 var editRange = new WebInspector.TextRange(0, 0, lines.length - 1, lines [lines.length - 1].length); | |
|
apavlov
2014/08/15 08:29:38
lines.peekLast().length
| |
| 1937 return this._ruleLocation.rebaseAfterTextEdit(WebInspector.TextRange.cre ateFromLocation(0, 0), editRange); | |
| 1938 }, | |
| 1939 | |
| 1940 /** | |
| 1941 * @return {string} | |
| 1942 */ | |
| 1943 _rulePrefix: function() | |
| 1944 { | |
| 1945 return this._ruleLocation.startLine === 0 && this._ruleLocation.startCol umn === 0 ? "" : "\n\n"; | |
| 1946 }, | |
| 1947 | |
| 1903 get isBlank() | 1948 get isBlank() |
| 1904 { | 1949 { |
| 1905 return !this._normal; | 1950 return !this._normal; |
| 1906 }, | 1951 }, |
| 1907 | 1952 |
| 1908 expand: function() | 1953 expand: function() |
| 1909 { | 1954 { |
| 1910 if (!this.isBlank) | 1955 if (!this.isBlank) |
| 1911 WebInspector.StylePropertiesSection.prototype.expand.call(this); | 1956 WebInspector.StylePropertiesSection.prototype.expand.call(this); |
| 1912 }, | 1957 }, |
| 1913 | 1958 |
| 1914 editingSelectorCommitted: function(element, newContent, oldContent, context, moveDirection) | 1959 editingSelectorCommitted: function(element, newContent, oldContent, context, moveDirection) |
| 1915 { | 1960 { |
| 1916 if (!this.isBlank) { | 1961 if (!this.isBlank) { |
| 1917 WebInspector.StylePropertiesSection.prototype.editingSelectorCommitt ed.call(this, element, newContent, oldContent, context, moveDirection); | 1962 WebInspector.StylePropertiesSection.prototype.editingSelectorCommitt ed.call(this, element, newContent, oldContent, context, moveDirection); |
| 1918 return; | 1963 return; |
| 1919 } | 1964 } |
| 1920 | 1965 |
| 1921 /** | 1966 /** |
| 1922 * @param {!WebInspector.CSSRule} newRule | 1967 * @param {!WebInspector.CSSRule} newRule |
| 1923 * @this {WebInspector.StylePropertiesSection} | 1968 * @this {WebInspector.StylePropertiesSection} |
| 1924 */ | 1969 */ |
| 1925 function successCallback(newRule) | 1970 function successCallback(newRule) |
| 1926 { | 1971 { |
| 1927 var doesSelectorAffectSelectedNode = newRule.matchingSelectors.lengt h > 0; | 1972 var doesSelectorAffectSelectedNode = newRule.matchingSelectors.lengt h > 0; |
| 1928 var styleRule = { media: newRule.media, section: this, style: newRul e.style, selectorText: newRule.selectorText, sourceURL: newRule.resourceURL(), r ule: newRule }; | 1973 var styleRule = { media: newRule.media, section: this, style: newRul e.style, selectorText: newRule.selectorText, rule: newRule }; |
| 1929 this._makeNormal(styleRule); | 1974 this._makeNormal(styleRule); |
| 1930 | 1975 |
| 1931 if (!doesSelectorAffectSelectedNode) { | 1976 if (!doesSelectorAffectSelectedNode) { |
| 1932 this.noAffect = true; | 1977 this.noAffect = true; |
| 1933 this.element.classList.add("no-affect"); | 1978 this.element.classList.add("no-affect"); |
| 1934 } | 1979 } |
| 1935 | 1980 |
| 1936 var ruleTextLines = ruleText.split("\n"); | 1981 var ruleTextLines = ruleText.split("\n"); |
| 1937 var startLine = this._ruleLocation.startLine; | 1982 var startLine = this._ruleLocation.startLine; |
| 1938 var startColumn = this._ruleLocation.startColumn; | 1983 var startColumn = this._ruleLocation.startColumn; |
| 1939 var newRange = new WebInspector.TextRange(startLine, startColumn, st artLine + ruleTextLines.length - 1, startColumn + ruleTextLines[ruleTextLines.le ngth - 1].length); | 1984 var newRange = new WebInspector.TextRange(startLine, startColumn, st artLine + ruleTextLines.length - 1, startColumn + ruleTextLines[ruleTextLines.le ngth - 1].length); |
| 1940 this._parentPane._styleSheetRuleEdited(newRule, this._ruleLocation, newRange); | 1985 this._parentPane._styleSheetRuleEdited(newRule, this._ruleLocation, newRange); |
| 1941 | 1986 |
| 1942 this._updateRuleOrigin(); | 1987 this._updateRuleOrigin(); |
| 1943 this.expand(); | 1988 this.expand(); |
| 1944 if (this.element.parentElement) // Might have been detached already. | 1989 if (this.element.parentElement) // Might have been detached already. |
| 1945 this._moveEditorFromSelector(moveDirection); | 1990 this._moveEditorFromSelector(moveDirection); |
| 1946 | 1991 |
| 1947 delete this._parentPane._userOperation; | 1992 delete this._parentPane._userOperation; |
| 1948 this._editingSelectorEnded(); | 1993 this._editingSelectorEnded(); |
| 1949 this._markSelectorMatches(); | 1994 this._markSelectorMatches(); |
| 1950 } | 1995 } |
| 1951 | 1996 |
| 1952 if (newContent) | 1997 if (newContent) |
| 1953 newContent = newContent.trim(); | 1998 newContent = newContent.trim(); |
| 1954 this._parentPane._userOperation = true; | 1999 this._parentPane._userOperation = true; |
| 1955 | 2000 |
| 1956 var cssModel = this._parentPane._target.cssModel; | 2001 var cssModel = this._parentPane._target.cssModel; |
| 1957 var rulePrefix = this._ruleLocation.startLine === 0 && this._ruleLocatio n.startColumn === 0 ? "" : "\n\n"; | 2002 var ruleText = this._rulePrefix() + newContent + " {}"; |
| 1958 var ruleText = rulePrefix + newContent + " {}"; | |
| 1959 cssModel.addRule(this._styleSheetId, this._parentPane._node, ruleText, t his._ruleLocation, successCallback.bind(this), this.editingSelectorCancelled.bin d(this)); | 2003 cssModel.addRule(this._styleSheetId, this._parentPane._node, ruleText, t his._ruleLocation, successCallback.bind(this), this.editingSelectorCancelled.bin d(this)); |
| 1960 }, | 2004 }, |
| 1961 | 2005 |
| 1962 editingSelectorCancelled: function() | 2006 editingSelectorCancelled: function() |
| 1963 { | 2007 { |
| 1964 delete this._parentPane._userOperation; | 2008 delete this._parentPane._userOperation; |
| 1965 if (!this.isBlank) { | 2009 if (!this.isBlank) { |
| 1966 WebInspector.StylePropertiesSection.prototype.editingSelectorCancell ed.call(this); | 2010 WebInspector.StylePropertiesSection.prototype.editingSelectorCancell ed.call(this); |
| 1967 return; | 2011 return; |
| 1968 } | 2012 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2168 * @this {WebInspector.StylePropertyTreeElementBase} | 2212 * @this {WebInspector.StylePropertyTreeElementBase} |
| 2169 */ | 2213 */ |
| 2170 function linkifyURL(url) | 2214 function linkifyURL(url) |
| 2171 { | 2215 { |
| 2172 var hrefUrl = url; | 2216 var hrefUrl = url; |
| 2173 var match = hrefUrl.match(/['"]?([^'"]+)/); | 2217 var match = hrefUrl.match(/['"]?([^'"]+)/); |
| 2174 if (match) | 2218 if (match) |
| 2175 hrefUrl = match[1]; | 2219 hrefUrl = match[1]; |
| 2176 var container = document.createDocumentFragment(); | 2220 var container = document.createDocumentFragment(); |
| 2177 container.appendChild(document.createTextNode("url(")); | 2221 container.appendChild(document.createTextNode("url(")); |
| 2178 if (this._styleRule.sourceURL) | 2222 if (this._styleRule.rule && this._styleRule.rule.resourceURL()) |
| 2179 hrefUrl = WebInspector.ParsedURL.completeURL(this._styleRule.sou rceURL, hrefUrl); | 2223 hrefUrl = WebInspector.ParsedURL.completeURL(this._styleRule.rul e.resourceURL(), hrefUrl); |
| 2180 else if (this.node()) | 2224 else if (this.node()) |
| 2181 hrefUrl = this.node().resolveURL(hrefUrl); | 2225 hrefUrl = this.node().resolveURL(hrefUrl); |
| 2182 var hasResource = hrefUrl && !!WebInspector.resourceForURL(hrefUrl); | 2226 var hasResource = hrefUrl && !!WebInspector.resourceForURL(hrefUrl); |
| 2183 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI. | 2227 // FIXME: WebInspector.linkifyURLAsNode() should really use baseURI. |
| 2184 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl || url, url, undefined, !hasResource)); | 2228 container.appendChild(WebInspector.linkifyURLAsNode(hrefUrl || url, url, undefined, !hasResource)); |
| 2185 container.appendChild(document.createTextNode(")")); | 2229 container.appendChild(document.createTextNode(")")); |
| 2186 return container; | 2230 return container; |
| 2187 } | 2231 } |
| 2188 | 2232 |
| 2189 if (value) { | 2233 if (value) { |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3358 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase( ))) { | 3402 if (userEnteredText && (userEnteredText === userEnteredText.toUpperCase( ))) { |
| 3359 for (var i = 0; i < results.length; ++i) | 3403 for (var i = 0; i < results.length; ++i) |
| 3360 results[i] = results[i].toUpperCase(); | 3404 results[i] = results[i].toUpperCase(); |
| 3361 } | 3405 } |
| 3362 var selectedIndex = this._cssCompletions.mostUsedOf(results); | 3406 var selectedIndex = this._cssCompletions.mostUsedOf(results); |
| 3363 completionsReadyCallback(results, selectedIndex); | 3407 completionsReadyCallback(results, selectedIndex); |
| 3364 }, | 3408 }, |
| 3365 | 3409 |
| 3366 __proto__: WebInspector.TextPrompt.prototype | 3410 __proto__: WebInspector.TextPrompt.prototype |
| 3367 } | 3411 } |
| OLD | NEW |