Diff
Modified: trunk/LayoutTests/ChangeLog (131164 => 131165)
--- trunk/LayoutTests/ChangeLog 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/LayoutTests/ChangeLog 2012-10-12 09:38:43 UTC (rev 131165)
@@ -1,3 +1,13 @@
+2012-10-12 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Extract domain specific editing handling logic from UISourceCode descendants (step 1).
+ https://bugs.webkit.org/show_bug.cgi?id=98912
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/debugger/live-edit.html:
+ * inspector/extensions/extensions-resources.html:
+
2012-10-12 Kenichi Ishibashi <[email protected]>
Unreviewed test expectations update after r131134
Modified: trunk/LayoutTests/inspector/debugger/live-edit.html (131164 => 131165)
--- trunk/LayoutTests/inspector/debugger/live-edit.html 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/LayoutTests/inspector/debugger/live-edit.html 2012-10-12 09:38:43 UTC (rev 131165)
@@ -42,12 +42,7 @@
function didShowScriptSource(sourceFrame)
{
- InspectorTest.addSniffer(WebInspector._javascript_SourceFrame.prototype, "_didEditContent", didEditScriptSource);
InspectorTest.replaceInSource(sourceFrame, ",\"I'm good\"", "\"I'm good\"");
- }
-
- function didEditScriptSource()
- {
InspectorTest.dumpSourceFrameContents(panel.visibleView);
next();
}
Modified: trunk/LayoutTests/inspector/extensions/extensions-resources.html (131164 => 131165)
--- trunk/LayoutTests/inspector/extensions/extensions-resources.html 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/LayoutTests/inspector/extensions/extensions-resources.html 2012-10-12 09:38:43 UTC (rev 131165)
@@ -80,15 +80,15 @@
});
}
-// Extensions tests override WebInspector.StyleSource.updateTimeout because otherwise extensions don't have any control over applying changes to domain specific bindings.
+// Extensions tests override WebInspector.StyleFile.updateTimeout because otherwise extensions don't have any control over applying changes to domain specific bindings.
function extension_setFakeStyleSheetUpdateTimeout(callback)
{
- evaluateOnFrontend("WebInspector.oldStyleSheetUpdateTimeout = WebInspector.StyleSource.updateTimeout; WebInspector.StyleSource.updateTimeout = -1; reply();", callback);
+ evaluateOnFrontend("WebInspector.oldStyleSheetUpdateTimeout = WebInspector.StyleFile.updateTimeout; WebInspector.StyleFile.updateTimeout = -1; reply();", callback);
}
function extension_resetStyleSheetUpdateTimeout(callback)
{
- evaluateOnFrontend("WebInspector.StyleSource.updateTimeout = WebInspector.oldStyleSheetUpdateTimeout; delete WebInspector.oldStyleSheetUpdateTimeout; reply();", callback);
+ evaluateOnFrontend("WebInspector.StyleFile.updateTimeout = WebInspector.oldStyleSheetUpdateTimeout; delete WebInspector.oldStyleSheetUpdateTimeout; reply();", callback);
}
function extension_testSetResourceContent(nextTest)
Modified: trunk/Source/WebCore/ChangeLog (131164 => 131165)
--- trunk/Source/WebCore/ChangeLog 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/ChangeLog 2012-10-12 09:38:43 UTC (rev 131165)
@@ -1,3 +1,63 @@
+2012-10-12 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Extract domain specific editing handling logic from UISourceCode descendants (step 1).
+ https://bugs.webkit.org/show_bug.cgi?id=98912
+
+ Reviewed by Pavel Feldman.
+
+ This is the first step that introduces StyleFile and ScriptFile and extracts domain specific editing handling logic.
+ StyleFile and ScriptFile should listen for the UISourceCode events and process them, this will be done in the next patch.
+
+ * inspector/front-end/BreakpointManager.js:
+ (WebInspector.BreakpointManager.Breakpoint.prototype._updateBreakpoint):
+ * inspector/front-end/_javascript_Source.js:
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame):
+ (WebInspector._javascript_SourceFrame.prototype.onTextChanged):
+ * inspector/front-end/ResourceScriptMapping.js:
+ (WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
+ (WebInspector.ResourceScriptMapping.prototype._hasDivergedFromVMChanged):
+ (WebInspector.ResourceScriptMapping.prototype._bindUISourceCodeToScripts):
+ (WebInspector.ScriptFile):
+ (WebInspector.ScriptFile.prototype.hasDivergedFromVM):
+ (WebInspector.ScriptFile.prototype.isDivergingFromVM):
+ (WebInspector.ScriptFile.prototype.addEventListener):
+ (WebInspector.ScriptFile.prototype.removeEventListener):
+ (WebInspector.ResourceScriptFile):
+ (WebInspector.ResourceScriptFile.prototype.workingCopyCommitted):
+ (WebInspector.ResourceScriptFile.prototype.workingCopyChanged):
+ (WebInspector.ResourceScriptFile.prototype.fireHasDivergedFromVMChanged):
+ (WebInspector.ResourceScriptFile.prototype.hasDivergedFromVM):
+ (WebInspector.ResourceScriptFile.prototype.isDivergingFromVM):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
+ (WebInspector.SnippetScriptFile):
+ (WebInspector.SnippetScriptFile.prototype.hasDivergedFromVM):
+ (WebInspector.SnippetScriptFile.prototype.setHasDivergedFromVM):
+ (WebInspector.SnippetScriptFile.prototype.isDivergingFromVM):
+ (WebInspector.SnippetScriptFile.prototype.setIsDivergingFromVM):
+ (WebInspector.SnippetScriptFile.prototype.workingCopyCommitted):
+ (WebInspector.SnippetScriptFile.prototype.workingCopyChanged):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._revealExecutionLine):
+ * inspector/front-end/StyleSource.js:
+ * inspector/front-end/StylesSourceMapping.js:
+ (WebInspector.StylesSourceMapping.prototype._uiSourceCodeAddedToWorkspace):
+ (WebInspector.StylesSourceMapping.prototype._addUISourceCode):
+ (WebInspector.StyleFile):
+ (WebInspector.StyleFile.prototype.workingCopyCommitted):
+ (WebInspector.StyleFile.prototype.workingCopyChanged):
+ (WebInspector.StyleFile.prototype._callOrSetTimeout):
+ (WebInspector.StyleFile.prototype._commitIncrementalEdit):
+ (WebInspector.StyleFile.prototype._clearIncrementalUpdateTimer):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode.prototype.scriptFile):
+ (WebInspector.UISourceCode.prototype.setScriptFile):
+ (WebInspector.UISourceCode.prototype.styleFile):
+ (WebInspector.UISourceCode.prototype.setStyleFile):
+ (WebInspector.UISourceCode.prototype.setWorkingCopy):
+ (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+
2012-10-12 Zeno Albisser <[email protected]>
[Qt][WK2] GraphicsSurfaceGLX should keep track of previous GL context.
Modified: trunk/Source/WebCore/inspector/front-end/BreakpointManager.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -63,11 +63,6 @@
return uiSourceCode.formatted() ? "deobfuscated:" + uiSourceCode.url : uiSourceCode.url;
}
-WebInspector.BreakpointManager.hasDivergedFromVM = function(uiSourceCode)
-{
- return uiSourceCode.isDirty() || uiSourceCode.hasDivergedFromVM;
-}
-
WebInspector.BreakpointManager.prototype = {
/**
* @param {WebInspector.UISourceCode} uiSourceCode
@@ -438,7 +433,8 @@
this._condition = condition;
this._breakpointManager._storage._updateBreakpoint(this);
- if (this._enabled && !WebInspector.BreakpointManager.hasDivergedFromVM(this._primaryUILocation.uiSourceCode)) {
+ var scriptFile = this._primaryUILocation.uiSourceCode.scriptFile();
+ if (this._enabled && !(scriptFile && scriptFile.hasDivergedFromVM())) {
this._setInDebugger();
return;
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -40,49 +40,6 @@
WebInspector.UISourceCode.call(this, url, contentProvider, isEditable);
}
-WebInspector._javascript_Source.Events = {
- HasDivergedFromVMChanged: "HasDivergedFromVMChanged"
-}
-
WebInspector._javascript_Source.prototype = {
- /**
- * @param {function(?string)} callback
- */
- workingCopyCommitted: function(callback)
- {
- /**
- * @param {?string} error
- */
- function innerCallback(error)
- {
- if (error)
- this.hasDivergedFromVM = true;
- else
- delete this.hasDivergedFromVM;
- this.fireHasDivergedFromVMChanged();
-
- callback(error);
- }
- var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ this.uiLocationToRawLocation(0, 0);
- if (!rawLocation) {
- callback(null);
- return;
- }
- var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
- WebInspector.debuggerModel.setScriptSource(script.scriptId, this.workingCopy(), innerCallback.bind(this));
- },
-
- workingCopyChanged: function()
- {
- this.fireHasDivergedFromVMChanged();
- },
-
- fireHasDivergedFromVMChanged: function()
- {
- this.isDivergingFromVM = true;
- this.dispatchEventToListeners(WebInspector._javascript_Source.Events.HasDivergedFromVMChanged, this);
- delete this.isDivergingFromVM;
- },
-
__proto__: WebInspector.UISourceCode.prototype
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -39,6 +39,7 @@
this._scriptsPanel = scriptsPanel;
this._breakpointManager = WebInspector.breakpointManager;
this._javaScriptSource = _javascript_Source;
+ this._scriptFile = this._javaScriptSource.scriptFile();
var locations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource);
for (var i = 0; i < locations.length; ++i)
@@ -150,16 +151,11 @@
contextMenu.appendApplicableItems(this._javaScriptSource);
},
- _hasDivergedFromVM: function()
- {
- return this._javaScriptSource.isDirty() || this._javaScriptSource.hasDivergedFromVM;
- },
-
onTextChanged: function(oldRange, newRange)
{
WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange);
- var wasDiverged = this._hasDivergedFromVM();
+ var wasDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM();
this._preserveDecorations = true;
this._javaScriptSource.setWorkingCopy(this._textEditor.text());
@@ -168,7 +164,7 @@
if (this._supportsEnabledBreakpointsWhileEditing())
return;
- var isDiverged = this._hasDivergedFromVM();
+ var isDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM();
if (!wasDiverged && isDiverged)
this._muteBreakpointsWhileEditing();
else if (wasDiverged && !isDiverged) {
Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -56,7 +56,7 @@
var uiSourceCode = this._workspaceUISourceCodeForScript(script);
if (!uiSourceCode)
uiSourceCode = this._getOrCreateTemporaryUISourceCode(script);
- else if (uiSourceCode.isDirty() || uiSourceCode.hasDivergedFromVM) {
+ else if (uiSourceCode.scriptFile() && uiSourceCode.scriptFile().hasDivergedFromVM()) {
var temporaryUISourceCode = this._getOrCreateTemporaryUISourceCode(script);
temporaryUISourceCode.divergedVersion = uiSourceCode;
uiSourceCode = temporaryUISourceCode;
@@ -73,7 +73,7 @@
return;
for (var i = 0; i < scripts.length; ++i)
scripts[i].setSourceMapping(this);
- if (!uiSourceCode.isDirty() && !uiSourceCode.hasDivergedFromVM)
+ if (uiSourceCode.scriptFile() && !uiSourceCode.scriptFile().hasDivergedFromVM())
this._deleteTemporaryUISourceCodeForScripts(scripts);
},
@@ -148,9 +148,11 @@
scripts[i].setSourceMapping(this);
uiSourceCode.isContentScript = scripts[0].isContentScript;
uiSourceCode.setSourceMapping(this);
- if (!uiSourceCode.isTemporary)
- uiSourceCode.addEventListener(WebInspector._javascript_Source.Events.HasDivergedFromVMChanged, this._hasDivergedFromVMChanged, this);
-
+ if (!uiSourceCode.isTemporary) {
+ var scriptFile = new WebInspector.ResourceScriptFile(uiSourceCode);
+ uiSourceCode.setScriptFile(scriptFile);
+ scriptFile.addEventListener(WebInspector.ScriptFile.Events.HasDivergedFromVMChanged, this._hasDivergedFromVMChanged, this);
+ }
},
/**
@@ -243,3 +245,111 @@
this._scripts = [];
},
}
+
+/**
+ * @interface
+ */
+WebInspector.ScriptFile = function()
+{
+}
+
+WebInspector.ScriptFile.Events = {
+ HasDivergedFromVMChanged: "HasDivergedFromVMChanged",
+}
+
+WebInspector.ScriptFile.prototype = {
+ /**
+ * @return {boolean}
+ */
+ hasDivergedFromVM: function() { return false; },
+
+ /**
+ * @return {boolean}
+ */
+ isDivergingFromVM: function() { return false; },
+
+ /**
+ * @param {string} eventType
+ * @param {function(WebInspector.Event)} listener
+ * @param {Object=} thisObject
+ */
+ addEventListener: function(eventType, listener, thisObject) { },
+
+ /**
+ * @param {string} eventType
+ * @param {function(WebInspector.Event)} listener
+ * @param {Object=} thisObject
+ */
+ removeEventListener: function(eventType, listener, thisObject) { }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ScriptFile}
+ * @extends {WebInspector.Object}
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ */
+WebInspector.ResourceScriptFile = function(uiSourceCode)
+{
+ WebInspector.ScriptFile.call(this);
+ this._uiSourceCode = uiSourceCode;
+}
+
+WebInspector.ResourceScriptFile.prototype = {
+ /**
+ * @param {function(?string)} callback
+ */
+ workingCopyCommitted: function(callback)
+ {
+ /**
+ * @param {?string} error
+ */
+ function innerCallback(error)
+ {
+ if (error)
+ this._hasDivergedFromVM = true;
+ else
+ delete this._hasDivergedFromVM;
+ this.fireHasDivergedFromVMChanged();
+
+ callback(error);
+ }
+ var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ this._uiSourceCode.uiLocationToRawLocation(0, 0);
+ if (!rawLocation) {
+ callback(null);
+ return;
+ }
+ var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
+ WebInspector.debuggerModel.setScriptSource(script.scriptId, this._uiSourceCode.workingCopy(), innerCallback.bind(this));
+ },
+
+ workingCopyChanged: function()
+ {
+ this.fireHasDivergedFromVMChanged();
+ },
+
+ fireHasDivergedFromVMChanged: function()
+ {
+ this._isDivergingFromVM = true;
+ this.dispatchEventToListeners(WebInspector.ScriptFile.Events.HasDivergedFromVMChanged, this._uiSourceCode);
+ delete this._isDivergingFromVM;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ hasDivergedFromVM: function()
+ {
+ return this._uiSourceCode.isDirty() || this._hasDivergedFromVM;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ isDivergingFromVM: function()
+ {
+ return this._isDivergingFromVM;
+ },
+
+ __proto__: WebInspector.Object.prototype
+}
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -83,7 +83,8 @@
_addScriptSnippet: function(snippet)
{
var snippetJavaScriptSource = new WebInspector.SnippetJavaScriptSource(snippet.name, new WebInspector.SnippetContentProvider(snippet), this);
- snippetJavaScriptSource.hasDivergedFromVM = true;
+ var scriptFile = new WebInspector.SnippetScriptFile(this, snippetJavaScriptSource);
+ snippetJavaScriptSource.setScriptFile(scriptFile);
this._snippetIdForJavaScriptSource.put(snippetJavaScriptSource, snippet.id);
snippetJavaScriptSource.setSourceMapping(this._snippetScriptMapping);
this._snippetJavaScriptSourceForSnippetId[snippet.id] = snippetJavaScriptSource;
@@ -309,7 +310,7 @@
console.assert(!this._scriptForUISourceCode.get(snippetJavaScriptSource));
this._uiSourceCodeForScriptId[script.scriptId] = snippetJavaScriptSource;
this._scriptForUISourceCode.put(snippetJavaScriptSource, script);
- delete snippetJavaScriptSource.hasDivergedFromVM;
+ snippetJavaScriptSource.scriptFile().setHasDivergedFromVM(false);
script.setSourceMapping(this._snippetScriptMapping);
},
@@ -365,13 +366,13 @@
if (!script)
return null;
- snippetJavaScriptSource.isDivergingFromVM = true;
- snippetJavaScriptSource.hasDivergedFromVM = true;
+ snippetJavaScriptSource.scriptFile().setIsDivergingFromVM(true);
+ snippetJavaScriptSource.scriptFile().setHasDivergedFromVM(true);
delete this._uiSourceCodeForScriptId[script.scriptId];
this._scriptForUISourceCode.remove(snippetJavaScriptSource);
delete snippetJavaScriptSource._evaluationIndex;
var uiSourceCode = this._createUISourceCodeForScript(script);
- delete snippetJavaScriptSource.isDivergingFromVM;
+ snippetJavaScriptSource.scriptFile().setIsDivergingFromVM(false);
return uiSourceCode;
},
@@ -433,21 +434,72 @@
}
WebInspector.SnippetJavaScriptSource.prototype = {
+ __proto__: WebInspector._javascript_Source.prototype
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ScriptFile}
+ * @extends {WebInspector.Object}
+ * @param {WebInspector.ScriptSnippetModel} scriptSnippetModel
+ * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ */
+WebInspector.SnippetScriptFile = function(scriptSnippetModel, snippetJavaScriptSource)
+{
+ WebInspector.ScriptFile.call(this);
+ this._scriptSnippetModel = scriptSnippetModel;
+ this._snippetJavaScriptSource = snippetJavaScriptSource;
+ this._hasDivergedFromVM = true;
+}
+
+WebInspector.SnippetScriptFile.prototype = {
/**
+ * @return {boolean}
+ */
+ hasDivergedFromVM: function()
+ {
+ return this._hasDivergedFromVM;
+ },
+
+ /**
+ * @param {boolean} hasDivergedFromVM
+ */
+ setHasDivergedFromVM: function(hasDivergedFromVM)
+ {
+ this._hasDivergedFromVM = hasDivergedFromVM;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ isDivergingFromVM: function()
+ {
+ return this._isDivergingFromVM;
+ },
+
+ /**
+ * @param {boolean} isDivergingFromVM
+ */
+ setIsDivergingFromVM: function(isDivergingFromVM)
+ {
+ this._isDivergingFromVM = isDivergingFromVM;
+ },
+
+ /**
* @param {function(?string)} callback
*/
workingCopyCommitted: function(callback)
- {
- this._scriptSnippetModel._setScriptSnippetContent(this, this.workingCopy());
+ {
+ this._scriptSnippetModel._setScriptSnippetContent(this._snippetJavaScriptSource, this._snippetJavaScriptSource.workingCopy());
callback(null);
},
workingCopyChanged: function()
- {
- this._scriptSnippetModel._scriptSnippetEdited(this);
+ {
+ this._scriptSnippetModel._scriptSnippetEdited(this._snippetJavaScriptSource);
},
- __proto__: WebInspector._javascript_Source.prototype
+ __proto__: WebInspector.Object.prototype
}
/**
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -506,7 +506,7 @@
var uiSourceCode = uiLocation.uiSourceCode;
// Some scripts (anonymous and snippets evaluations) are not added to files select by default.
if (uiSourceCode.isTemporary) {
- if (this._currentUISourceCode && this._currentUISourceCode.isDivergingFromVM)
+ if (this._currentUISourceCode && this._currentUISourceCode.scriptFile() && this._currentUISourceCode.scriptFile().isDivergingFromVM())
return;
this._editorContainer.addUISourceCode(uiSourceCode);
if (uiSourceCode.formatted() !== this._toggleFormatSourceButton.toggled)
Modified: trunk/Source/WebCore/inspector/front-end/StyleSource.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/StyleSource.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/StyleSource.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -36,50 +36,6 @@
WebInspector.UISourceCode.call(this, contentProvider.contentURL(), contentProvider, true);
}
-WebInspector.StyleSource.updateTimeout = 200;
-
WebInspector.StyleSource.prototype = {
- /**
- * @param {function(?string)} callback
- */
- workingCopyCommitted: function(callback)
- {
- this._commitIncrementalEdit(true, callback);
- },
-
- workingCopyChanged: function()
- {
- this._callOrSetTimeout(this._commitIncrementalEdit.bind(this, false, function() {}));
- },
-
- /**
- * @param {function(?string)} callback
- */
- _callOrSetTimeout: function(callback)
- {
- // FIXME: Extensions tests override updateTimeout because extensions don't have any control over applying changes to domain specific bindings.
- if (WebInspector.StyleSource.updateTimeout >= 0)
- this._incrementalUpdateTimer = setTimeout(callback, WebInspector.StyleSource.updateTimeout);
- else
- callback(null);
- },
-
- /**
- * @param {boolean} majorChange
- * @param {function(?string)} callback
- */
- _commitIncrementalEdit: function(majorChange, callback)
- {
- this._clearIncrementalUpdateTimer();
- WebInspector.styleContentBinding.setStyleContent(this, this.workingCopy(), majorChange, callback);
- },
-
- _clearIncrementalUpdateTimer: function()
- {
- if (this._incrementalUpdateTimer)
- clearTimeout(this._incrementalUpdateTimer);
- delete this._incrementalUpdateTimer;
- },
-
__proto__: WebInspector.UISourceCode.prototype
}
Modified: trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -70,7 +70,7 @@
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
if (!uiSourceCode.url || this._uiSourceCodeForURL[uiSourceCode.url])
return;
- if (uiSourceCode.contentType() !== WebInspector.resourceTypes.StyleSheet)
+ if (uiSourceCode.contentType() !== WebInspector.resourceTypes.Stylesheet)
return;
this._addUISourceCode(uiSourceCode);
@@ -83,6 +83,8 @@
{
this._uiSourceCodeForURL[uiSourceCode.url] = uiSourceCode;
uiSourceCode.setSourceMapping(this);
+ var styleFile = new WebInspector.StyleFile(uiSourceCode);
+ uiSourceCode.setStyleFile(styleFile);
WebInspector.cssModel.setSourceMapping(uiSourceCode.url, this);
},
@@ -95,6 +97,62 @@
/**
* @constructor
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ */
+WebInspector.StyleFile = function(uiSourceCode)
+{
+ this._uiSourceCode = uiSourceCode;
+}
+
+WebInspector.StyleFile.updateTimeout = 200;
+
+WebInspector.StyleFile.prototype = {
+ /**
+ * @param {function(?string)} callback
+ */
+ workingCopyCommitted: function(callback)
+ {
+ this._commitIncrementalEdit(true, callback);
+ },
+
+ workingCopyChanged: function()
+ {
+ this._callOrSetTimeout(this._commitIncrementalEdit.bind(this, false, function() {}));
+ },
+
+ /**
+ * @param {function(?string)} callback
+ */
+ _callOrSetTimeout: function(callback)
+ {
+ // FIXME: Extensions tests override updateTimeout because extensions don't have any control over applying changes to domain specific bindings.
+ if (WebInspector.StyleFile.updateTimeout >= 0)
+ this._incrementalUpdateTimer = setTimeout(callback, WebInspector.StyleFile.updateTimeout);
+ else
+ callback(null);
+ },
+
+ /**
+ * @param {boolean} majorChange
+ * @param {function(?string)} callback
+ */
+ _commitIncrementalEdit: function(majorChange, callback)
+ {
+ this._clearIncrementalUpdateTimer();
+ WebInspector.styleContentBinding.setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), majorChange, callback);
+ },
+
+ _clearIncrementalUpdateTimer: function()
+ {
+ if (this._incrementalUpdateTimer)
+ clearTimeout(this._incrementalUpdateTimer);
+ delete this._incrementalUpdateTimer;
+ },
+}
+
+
+/**
+ * @constructor
* @param {WebInspector.CSSStyleModel} cssModel
*/
WebInspector.StyleContentBinding = function(cssModel)
@@ -105,14 +163,14 @@
WebInspector.StyleContentBinding.prototype = {
/**
- * @param {WebInspector.StyleSource} styleSource
+ * @param {WebInspector.UISourceCode} uiSourceCode
* @param {string} content
* @param {boolean} majorChange
* @param {function(?string)} userCallback
*/
- setStyleContent: function(styleSource, content, majorChange, userCallback)
+ setStyleContent: function(uiSourceCode, content, majorChange, userCallback)
{
- var resource = WebInspector.resourceForURL(styleSource.url);
+ var resource = WebInspector.resourceForURL(uiSourceCode.url);
this._cssModel.resourceBinding().requestStyleSheetIdForResource(resource, callback.bind(this));
/**
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (131164 => 131165)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-12 09:36:54 UTC (rev 131164)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-12 09:38:43 UTC (rev 131165)
@@ -118,6 +118,38 @@
},
/**
+ * @return {WebInspector.ScriptFile}
+ */
+ scriptFile: function()
+ {
+ return this._scriptFile;
+ },
+
+ /**
+ * @param {WebInspector.ScriptFile} scriptFile
+ */
+ setScriptFile: function(scriptFile)
+ {
+ this._scriptFile = scriptFile;
+ },
+
+ /**
+ * @return {WebInspector.StyleFile}
+ */
+ styleFile: function()
+ {
+ return this._styleFile;
+ },
+
+ /**
+ * @param {WebInspector.StyleFile} styleFile
+ */
+ setStyleFile: function(styleFile)
+ {
+ this._styleFile = styleFile;
+ },
+
+ /**
* @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)
@@ -278,15 +310,13 @@
delete this._workingCopy;
else
this._workingCopy = newWorkingCopy;
- this.workingCopyChanged();
+ if (this.scriptFile())
+ this.scriptFile().workingCopyChanged();
+ else if (this.styleFile())
+ this.styleFile().workingCopyChanged();
this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy});
},
- workingCopyChanged: function()
- {
- // Overridden.
- },
-
/**
* @param {function(?string)} callback
*/
@@ -298,19 +328,14 @@
}
var newContent = this._workingCopy;
- this.workingCopyCommitted(callback);
+ if (this.scriptFile())
+ this.scriptFile().workingCopyCommitted(callback);
+ else if (this.styleFile())
+ this.styleFile().workingCopyCommitted(callback);
this.addRevision(newContent);
},
/**
- * @param {function(?string)} callback
- */
- workingCopyCommitted: function(callback)
- {
- // Overridden.
- },
-
- /**
* @return {boolean}
*/
isDirty: function()