Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1629 foundIndex = properties.size() - i - 1; | 1629 foundIndex = properties.size() - i - 1; |
| 1630 | 1630 |
| 1631 if (property.important) | 1631 if (property.important) |
| 1632 break; | 1632 break; |
| 1633 } | 1633 } |
| 1634 | 1634 |
| 1635 SourceRange bodyRange = sourceData->ruleBodyRange; | 1635 SourceRange bodyRange = sourceData->ruleBodyRange; |
| 1636 String styleSheetText; | 1636 String styleSheetText; |
| 1637 inspectorStyleSheet->getText(&styleSheetText); | 1637 inspectorStyleSheet->getText(&styleSheetText); |
| 1638 String styleText = styleSheetText.substring(bodyRange.start, bodyRange.lengt h()); | 1638 String styleText = styleSheetText.substring(bodyRange.start, bodyRange.lengt h()); |
| 1639 | 1639 SourceRange changeRange; |
| 1640 if (foundIndex == -1) { | 1640 if (foundIndex == -1) { |
| 1641 bool isImportant = inlineStyle->getPropertyPriority(longhand) == "import ant"; | 1641 bool isImportant = inlineStyle->getPropertyPriority(longhand) == "import ant"; |
| 1642 String newPropertyText = "\n" + longhand + ": " + value + (isImportant ? " !important" : "") + ";"; | 1642 String newPropertyText = "\n" + longhand + ": " + value + (isImportant ? " !important" : "") + ";"; |
| 1643 if (!styleText.stripWhiteSpace().endsWith(';')) | 1643 if (!styleText.isEmpty() && !styleText.stripWhiteSpace().endsWith(';')) |
| 1644 newPropertyText = ";" + newPropertyText; | 1644 newPropertyText = ";" + newPropertyText; |
| 1645 styleText.append(newPropertyText); | 1645 styleText.append(newPropertyText); |
| 1646 changeRange.start = bodyRange.end; | |
| 1647 changeRange.end = bodyRange.end + newPropertyText.length(); | |
| 1646 } else { | 1648 } else { |
| 1647 CSSPropertySourceData declaration = properties[foundIndex]; | 1649 CSSPropertySourceData declaration = properties[foundIndex]; |
| 1648 String newValueText; | 1650 String newValueText; |
| 1649 if (declaration.name == shorthand) | 1651 if (declaration.name == shorthand) |
| 1650 newValueText = createShorthandValue(ownerDocument, shorthand, declar ation.value, longhand, value); | 1652 newValueText = createShorthandValue(ownerDocument, shorthand, declar ation.value, longhand, value); |
| 1651 else | 1653 else |
| 1652 newValueText = value; | 1654 newValueText = value; |
| 1653 | 1655 |
| 1654 String newPropertyText = declaration.name + ": " + newValueText + (decla ration.important ? " !important" : "") + ";"; | 1656 String newPropertyText = declaration.name + ": " + newValueText + (decla ration.important ? " !important" : "") + ";"; |
| 1655 styleText.replace(declaration.range.start - bodyRange.start, declaration .range.length(), newPropertyText); | 1657 styleText.replace(declaration.range.start - bodyRange.start, declaration .range.length(), newPropertyText); |
| 1658 changeRange.start = declaration.range.start; | |
| 1659 changeRange.end = changeRange.start + newPropertyText.length(); | |
| 1656 } | 1660 } |
| 1657 setStyleText(errorString, inspectorStyleSheet, bodyRange, styleText); | 1661 CSSStyleDeclaration* resultStyle = setStyleText(errorString, inspectorStyleS heet, bodyRange, styleText); |
| 1662 if (resultStyle) | |
| 1663 frontend()->layoutEditorChange(inspectorStyleSheet->id(), inspectorStyle Sheet->buildSourceRangeObject(changeRange)); | |
|
pfeldman
2015/08/21 01:43:00
You might need to flush stylesheetadded events.
sergeyv
2015/08/21 04:05:42
Done.
| |
| 1658 } | 1664 } |
| 1659 | 1665 |
| 1660 void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorStrin g, int nodeId, const String& propertyName, const String& value) | 1666 void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorStrin g, int nodeId, const String& propertyName, const String& value) |
| 1661 { | 1667 { |
| 1662 Element* element = elementForId(errorString, nodeId); | 1668 Element* element = elementForId(errorString, nodeId); |
| 1663 if (!element) | 1669 if (!element) |
| 1664 return; | 1670 return; |
| 1665 | 1671 |
| 1666 CSSPropertyID property = cssPropertyID(propertyName); | 1672 CSSPropertyID property = cssPropertyID(propertyName); |
| 1667 if (!property) { | 1673 if (!property) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1684 visitor->trace(m_documentToCSSStyleSheets); | 1690 visitor->trace(m_documentToCSSStyleSheets); |
| 1685 visitor->trace(m_invalidatedDocuments); | 1691 visitor->trace(m_invalidatedDocuments); |
| 1686 visitor->trace(m_nodeToInspectorStyleSheet); | 1692 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1687 visitor->trace(m_documentToViaInspectorStyleSheet); | 1693 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1688 #endif | 1694 #endif |
| 1689 visitor->trace(m_inspectorUserAgentStyleSheet); | 1695 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1690 InspectorBaseAgent::trace(visitor); | 1696 InspectorBaseAgent::trace(visitor); |
| 1691 } | 1697 } |
| 1692 | 1698 |
| 1693 } // namespace blink | 1699 } // namespace blink |
| OLD | NEW |