Chromium Code Reviews| Index: Source/core/inspector/InspectorCSSAgent.cpp |
| diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp |
| index c7fc11293f1f8b7a567a60f917e4a14cebb4ae54..71c4c382415a39d243e0a5923b4ca9ab95a4a0d1 100644 |
| --- a/Source/core/inspector/InspectorCSSAgent.cpp |
| +++ b/Source/core/inspector/InspectorCSSAgent.cpp |
| @@ -1636,13 +1636,15 @@ void InspectorCSSAgent::setCSSPropertyValue(ErrorString* errorString, Element* e |
| String styleSheetText; |
| inspectorStyleSheet->getText(&styleSheetText); |
| String styleText = styleSheetText.substring(bodyRange.start, bodyRange.length()); |
| - |
| + SourceRange changeRange; |
| if (foundIndex == -1) { |
| bool isImportant = inlineStyle->getPropertyPriority(longhand) == "important"; |
| String newPropertyText = "\n" + longhand + ": " + value + (isImportant ? " !important" : "") + ";"; |
| - if (!styleText.stripWhiteSpace().endsWith(';')) |
| + if (!styleText.isEmpty() && !styleText.stripWhiteSpace().endsWith(';')) |
| newPropertyText = ";" + newPropertyText; |
| styleText.append(newPropertyText); |
| + changeRange.start = bodyRange.end; |
| + changeRange.end = bodyRange.end + newPropertyText.length(); |
| } else { |
| CSSPropertySourceData declaration = properties[foundIndex]; |
| String newValueText; |
| @@ -1653,8 +1655,12 @@ void InspectorCSSAgent::setCSSPropertyValue(ErrorString* errorString, Element* e |
| String newPropertyText = declaration.name + ": " + newValueText + (declaration.important ? " !important" : "") + ";"; |
| styleText.replace(declaration.range.start - bodyRange.start, declaration.range.length(), newPropertyText); |
| + changeRange.start = declaration.range.start; |
| + changeRange.end = changeRange.start + newPropertyText.length(); |
| } |
| - setStyleText(errorString, inspectorStyleSheet, bodyRange, styleText); |
| + CSSStyleDeclaration* resultStyle = setStyleText(errorString, inspectorStyleSheet, bodyRange, styleText); |
| + if (resultStyle) |
| + frontend()->layoutEditorChange(inspectorStyleSheet->id(), inspectorStyleSheet->buildSourceRangeObject(changeRange)); |
|
pfeldman
2015/08/21 01:43:00
You might need to flush stylesheetadded events.
sergeyv
2015/08/21 04:05:42
Done.
|
| } |
| void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorString, int nodeId, const String& propertyName, const String& value) |