Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1008)

Unified Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 1310433002: Devtools: [LayoutEditor] highlight changed value in the SSP (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/inspector/InspectorStyleSheet.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorCSSAgent.cpp
diff --git a/Source/core/inspector/InspectorCSSAgent.cpp b/Source/core/inspector/InspectorCSSAgent.cpp
index c7fc11293f1f8b7a567a60f917e4a14cebb4ae54..09b3a882864f1167f861819cd8709cd95414bd79 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,14 @@ 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();
+ }
+ CSSStyleDeclaration* resultStyle = setStyleText(errorString, inspectorStyleSheet, bodyRange, styleText);
+ if (resultStyle) {
+ frontend()->layoutEditorChange(inspectorStyleSheet->id(), inspectorStyleSheet->buildSourceRangeObject(changeRange));
+ frontend()->flush();
}
- setStyleText(errorString, inspectorStyleSheet, bodyRange, styleText);
}
void InspectorCSSAgent::setEffectivePropertyValueForNode(ErrorString* errorString, int nodeId, const String& propertyName, const String& value)
« no previous file with comments | « no previous file | Source/core/inspector/InspectorStyleSheet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698