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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 1694433003: DevTools: [CSS] Add CSS.setMultipleStyleTexts command to CSS domain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: %zu is not cross-platform - do not use. Created 4 years, 10 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
Index: third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js
index 06759431f7011749dd740f8179f896fd0e71e48a..cf1ea20ce334cc1526dd74d311496be916a609bb 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSStyleModel.js
@@ -80,6 +80,48 @@ WebInspector.CSSStyleModel.PseudoStateMarker = "pseudo-state-marker";
WebInspector.CSSStyleModel.prototype = {
/**
+ * @param {!Array<!CSSAgent.StyleSheetId>} styleSheetIds
+ * @param {!Array<!WebInspector.TextRange>} ranges
+ * @param {!Array<string>} texts
+ * @param {boolean} majorChange
+ * @return {!Promise<?Array<!CSSAgent.CSSStyle>>}
+ */
+ setStyleTexts: function(styleSheetIds, ranges, texts, majorChange)
+ {
+ /**
+ * @param {?Protocol.Error} error
+ * @param {?Array<!CSSAgent.CSSStyle>} stylePayloads
+ * @return {?Array<!CSSAgent.CSSStyle>}
+ * @this {WebInspector.CSSStyleModel}
+ */
+ function parsePayload(error, stylePayloads)
+ {
+ if (error || !stylePayloads || !stylePayloads.length)
+ return null;
+
+ if (majorChange)
+ this._domModel.markUndoableState();
+ var uniqueIDs = new Set(styleSheetIds);
+ for (var styleSheetId of uniqueIDs)
+ this._fireStyleSheetChanged(styleSheetId);
+ return stylePayloads;
+ }
+
+ console.assert(styleSheetIds.length === ranges.length && ranges.length === texts.length, "Array lengths must be equal");
+ var edits = [];
+ for (var i = 0; i < styleSheetIds.length; ++i) {
+ edits.push({
+ styleSheetId: styleSheetIds[i],
+ range: ranges[i].serializeToObject(),
+ text: texts[i]
+ });
+ }
+
+ return this._agent.setStyleTexts(edits, parsePayload.bind(this))
+ .catchException(/** @type {?Array<!CSSAgent.CSSStyle>} */(null));
+ },
+
+ /**
* @return {!Promise.<!Array.<!WebInspector.CSSMedia>>}
*/
mediaQueriesPromise: function()
@@ -946,28 +988,21 @@ WebInspector.CSSStyleDeclaration.prototype = {
*/
setText: function(text, majorChange)
{
- if (!this.styleSheetId)
- return Promise.resolve(false);
-
/**
- * @param {?Protocol.Error} error
- * @param {?CSSAgent.CSSStyle} stylePayload
+ * @param {?Array<!CSSAgent.CSSStyle>} stylePayloads
* @return {boolean}
* @this {WebInspector.CSSStyleDeclaration}
*/
- function parsePayload(error, stylePayload)
+ function onPayload(stylePayloads)
{
- if (error || !stylePayload)
+ if (!stylePayloads)
return false;
-
- if (majorChange)
- this._cssModel._domModel.markUndoableState();
- this._reinitialize(stylePayload);
- this._cssModel._fireStyleSheetChanged(this.styleSheetId);
+ this._reinitialize(stylePayloads[0]);
return true;
}
- return this._cssModel._agent.setStyleText(this.styleSheetId, this.range.serializeToObject(), text, parsePayload.bind(this))
+ return this._cssModel.setStyleTexts([this.styleSheetId], [this.range], [text], majorChange)
+ .then(onPayload.bind(this))
.catchException(false);
},
« no previous file with comments | « third_party/WebKit/Source/core/inspector/InspectorHistory.cpp ('k') | third_party/WebKit/Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698