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)); |
| 1664 frontend()->flush(); |
| 1665 } |
1658 } | 1666 } |
1659 | 1667 |
1660 void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorStrin
g, int nodeId, const String& propertyName, const String& value) | 1668 void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorStrin
g, int nodeId, const String& propertyName, const String& value) |
1661 { | 1669 { |
1662 Element* element = elementForId(errorString, nodeId); | 1670 Element* element = elementForId(errorString, nodeId); |
1663 if (!element) | 1671 if (!element) |
1664 return; | 1672 return; |
1665 | 1673 |
1666 CSSPropertyID property = cssPropertyID(propertyName); | 1674 CSSPropertyID property = cssPropertyID(propertyName); |
1667 if (!property) { | 1675 if (!property) { |
(...skipping 16 matching lines...) Expand all Loading... |
1684 visitor->trace(m_documentToCSSStyleSheets); | 1692 visitor->trace(m_documentToCSSStyleSheets); |
1685 visitor->trace(m_invalidatedDocuments); | 1693 visitor->trace(m_invalidatedDocuments); |
1686 visitor->trace(m_nodeToInspectorStyleSheet); | 1694 visitor->trace(m_nodeToInspectorStyleSheet); |
1687 visitor->trace(m_documentToViaInspectorStyleSheet); | 1695 visitor->trace(m_documentToViaInspectorStyleSheet); |
1688 #endif | 1696 #endif |
1689 visitor->trace(m_inspectorUserAgentStyleSheet); | 1697 visitor->trace(m_inspectorUserAgentStyleSheet); |
1690 InspectorBaseAgent::trace(visitor); | 1698 InspectorBaseAgent::trace(visitor); |
1691 } | 1699 } |
1692 | 1700 |
1693 } // namespace blink | 1701 } // namespace blink |
OLD | NEW |