Diff
Modified: trunk/LayoutTests/ChangeLog (131457 => 131458)
--- trunk/LayoutTests/ChangeLog 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/LayoutTests/ChangeLog 2012-10-16 15:43:13 UTC (rev 131458)
@@ -1,3 +1,14 @@
+2012-10-15 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Extract domain specific editing handling logic from UISourceCode (step 2).
+ https://bugs.webkit.org/show_bug.cgi?id=99301
+
+ Reviewed by Pavel Feldman.
+
+ * http/tests/inspector/debugger-test.js:
+ (initialize_DebuggerTest):
+ * inspector/styles/edit-inspector-stylesheet.html:
+
2012-10-16 Dana Jansens <[email protected]>
Layout Test fast/forms/date/calendar-picker-key-operations.html is failing
Modified: trunk/LayoutTests/http/tests/inspector/debugger-test.js (131457 => 131458)
--- trunk/LayoutTests/http/tests/inspector/debugger-test.js 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/LayoutTests/http/tests/inspector/debugger-test.js 2012-10-16 15:43:13 UTC (rev 131458)
@@ -160,7 +160,7 @@
InspectorTest.showScriptSource = function(scriptName, callback)
{
- var panel = WebInspector.panel("scripts");
+ var panel = WebInspector.showPanel("scripts");
var uiSourceCodes = panel._workspace.uiSourceCodes();
for (var i = 0; i < uiSourceCodes.length; ++i) {
if (uiSourceCodes[i].parsedURL.lastPathComponent === scriptName) {
Modified: trunk/LayoutTests/inspector/styles/edit-inspector-stylesheet.html (131457 => 131458)
--- trunk/LayoutTests/inspector/styles/edit-inspector-stylesheet.html 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/LayoutTests/inspector/styles/edit-inspector-stylesheet.html 2012-10-16 15:43:13 UTC (rev 131458)
@@ -14,25 +14,24 @@
function step1(node)
{
- WebInspector.panel("scripts")._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, sourceCodeAdded);
WebInspector.cssModel.addRule(node.id, "#inspected", successCallback, failureCallback);
- function successCallback() { }
+ function successCallback()
+ {
+ // setTimwout is needed here because showScriptSource callback is triggered by uiSourceCode addRevision handling
+ // and we need to wait until the code flow exits StyleFile.addRevision.
+ InspectorTest.showScriptSource("inspector-stylesheet", setTimeout.bind(this, step2, 0));
+ }
function failureCallback()
{
InspectorTest.addResult("Failed to add rule.");
InspectorTest.completeTest();
}
-
- function sourceCodeAdded(event)
- {
- if (event.data.parsedURL.scheme === "inspector")
- InspectorTest.showScriptSource("inspector-stylesheet", step2.bind(this, event.data));
- }
}
- function step2(styleSource, sourceFrame)
+ function step2(sourceFrame)
{
+ var styleSource = sourceFrame._uiSourceCode;
InspectorTest.addResult("Inspector stylesheet URL: " + styleSource.parsedURL.displayName);
styleSource.requestContent(printContent());
Modified: trunk/Source/WebCore/ChangeLog (131457 => 131458)
--- trunk/Source/WebCore/ChangeLog 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/Source/WebCore/ChangeLog 2012-10-16 15:43:13 UTC (rev 131458)
@@ -1,3 +1,45 @@
+2012-10-15 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Extract domain specific editing handling logic from UISourceCode (step 2).
+ https://bugs.webkit.org/show_bug.cgi?id=99301
+
+ Reviewed by Pavel Feldman.
+
+ StyleFile and ScriptFile now listen for the UISourceCode WorkingCopyChanged/Committed events and process
+ them instead of being called explicitly.
+
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame):
+ (WebInspector._javascript_SourceFrame.prototype.onTextChanged):
+ (WebInspector._javascript_SourceFrame.prototype._willMergeToVM):
+ (WebInspector._javascript_SourceFrame.prototype._didMergeToVM):
+ (WebInspector._javascript_SourceFrame.prototype._willDivergeFromVM):
+ (WebInspector._javascript_SourceFrame.prototype._didDivergeFromVM):
+ (WebInspector._javascript_SourceFrame.prototype._muteBreakpointsWhileEditing):
+ (WebInspector._javascript_SourceFrame.prototype._restoreBreakpointsAfterEditing):
+ * inspector/front-end/ResourceScriptMapping.js:
+ (WebInspector.ResourceScriptMapping.prototype._hasMergedToVM):
+ (WebInspector.ResourceScriptMapping.prototype._hasDivergedFromVM):
+ (WebInspector.ResourceScriptMapping.prototype._bindUISourceCodeToScripts):
+ (WebInspector.ResourceScriptFile):
+ (WebInspector.ResourceScriptFile.prototype._workingCopyCommitted):
+ (WebInspector.ResourceScriptFile.prototype._workingCopyChanged):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.SnippetScriptFile):
+ (WebInspector.SnippetScriptFile.prototype._workingCopyCommitted):
+ (WebInspector.SnippetScriptFile.prototype._workingCopyChanged):
+ * inspector/front-end/StylesSourceMapping.js:
+ (WebInspector.StyleFile):
+ (WebInspector.StyleFile.prototype._workingCopyCommitted):
+ (WebInspector.StyleFile.prototype._workingCopyChanged):
+ (WebInspector.StyleFile.prototype._commitIncrementalEdit):
+ (WebInspector.StyleFile.prototype._clearIncrementalUpdateTimer):
+ (WebInspector.StyleFile.prototype.addRevision):
+ (WebInspector.StyleContentBinding.prototype._innerStyleSheetChanged):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode.prototype.setWorkingCopy):
+ (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+
2012-10-16 Alexander Pavlov <[email protected]>
Web Inspector: [Elements] Double-click to live edit style tags changes text to 'undefined' in some situations
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (131457 => 131458)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-16 15:43:13 UTC (rev 131458)
@@ -63,6 +63,13 @@
this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded, this._consoleMessageAdded, this);
this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageRemoved, this._consoleMessageRemoved, this);
this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this);
+
+ if (this._scriptFile) {
+ this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.WillMergeToVM, this._willMergeToVM, this);
+ this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidMergeToVM, this._didMergeToVM, this);
+ this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._willDivergeFromVM, this);
+ this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._didDivergeFromVM, this);
+ }
}
WebInspector._javascript_SourceFrame.prototype = {
@@ -87,7 +94,7 @@
},
/**
- * @param {string} text
+ * @param {string} text
*/
commitEditing: function(text)
{
@@ -95,8 +102,7 @@
return;
this._isCommittingEditing = true;
- var breakpoints = this._getBreakpointDecorations();
- this._javaScriptSource.commitWorkingCopy(this._didEditContent.bind(this, breakpoints));
+ this._javaScriptSource.commitWorkingCopy(function() { });
delete this._isCommittingEditing;
},
@@ -177,43 +183,43 @@
onTextChanged: function(oldRange, newRange)
{
WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange);
-
- var wasDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM();
-
- this._preserveDecorations = true;
this._isSettingWorkingCopy = true;
this._javaScriptSource.setWorkingCopy(this._textEditor.text());
delete this._isSettingWorkingCopy;
- delete this._preserveDecorations;
+ },
+ _willMergeToVM: function()
+ {
if (this._supportsEnabledBreakpointsWhileEditing())
return;
+ this._preserveDecorations = true;
+ },
- var isDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM();
- if (!wasDiverged && isDiverged)
- this._muteBreakpointsWhileEditing();
- else if (wasDiverged && !isDiverged) {
- var breakpoints = this._getBreakpointDecorations();
- this._restoreBreakpointsAfterEditing(breakpoints);
- }
+ _didMergeToVM: function()
+ {
+ if (this._supportsEnabledBreakpointsWhileEditing())
+ return;
+ delete this._preserveDecorations;
+ this._restoreBreakpointsAfterEditing();
},
- _getBreakpointDecorations: function()
+ _willDivergeFromVM: function()
{
- var breakpoints = {};
- // Restore all muted breakpoints.
- for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
- var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
- if (breakpointDecoration)
- breakpoints[lineNumber] = breakpointDecoration;
- }
+ if (this._supportsEnabledBreakpointsWhileEditing())
+ return;
+ this._preserveDecorations = true;
+ },
- return breakpoints;
+ _didDivergeFromVM: function()
+ {
+ if (this._supportsEnabledBreakpointsWhileEditing())
+ return;
+ delete this._preserveDecorations;
+ this._muteBreakpointsWhileEditing();
},
_muteBreakpointsWhileEditing: function()
{
- var breakpoints = this._getBreakpointDecorations();
for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
if (!breakpointDecoration)
@@ -228,19 +234,19 @@
return this._javaScriptSource.isSnippet;
},
- _didEditContent: function(breakpoints, error)
+ _restoreBreakpointsAfterEditing: function()
{
- if (!this._supportsEnabledBreakpointsWhileEditing())
- this._restoreBreakpointsAfterEditing(breakpoints);
-
- if (error) {
- WebInspector.showErrorMessage(error);
- return;
+ var breakpoints = {};
+ // Save and remove muted breakpoint decorations.
+ for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
+ var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
+ if (breakpointDecoration) {
+ breakpoints[lineNumber] = breakpointDecoration;
+ this._removeBreakpointDecoration(lineNumber);
+ }
}
- },
- _restoreBreakpointsAfterEditing: function(breakpoints)
- {
+ // Remove all breakpoints.
var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource);
var lineNumbers = {};
for (var i = 0; i < breakpointLocations.length; ++i) {
@@ -248,16 +254,12 @@
breakpointLocations[i].breakpoint.remove();
}
- for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber)
- this._removeBreakpointDecoration(lineNumber);
-
- // Restore all muted breakpoints.
+ // Restore all breakpoints from saved decorations.
for (var lineNumberString in breakpoints) {
var lineNumber = parseInt(lineNumberString, 10);
if (isNaN(lineNumber))
continue;
var breakpointDecoration = breakpoints[lineNumberString];
- // Set new breakpoint
this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled);
}
},
Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (131457 => 131458)
--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-10-16 15:43:13 UTC (rev 131458)
@@ -65,19 +65,32 @@
return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0);
},
- _hasDivergedFromVMChanged: function(event)
+ /**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ */
+ _hasMergedToVM: function(uiSourceCode)
{
- var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
var scripts = this._scriptsForUISourceCode(uiSourceCode);
if (!scripts.length)
return;
for (var i = 0; i < scripts.length; ++i)
scripts[i].setSourceMapping(this);
- if (uiSourceCode.scriptFile() && !uiSourceCode.scriptFile().hasDivergedFromVM())
- this._deleteTemporaryUISourceCodeForScripts(scripts);
+ this._deleteTemporaryUISourceCodeForScripts(scripts);
},
/**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ */
+ _hasDivergedFromVM: function(uiSourceCode)
+ {
+ var scripts = this._scriptsForUISourceCode(uiSourceCode);
+ if (!scripts.length)
+ return;
+ for (var i = 0; i < scripts.length; ++i)
+ scripts[i].setSourceMapping(this);
+ },
+
+ /**
* @param {WebInspector.Script} script
* @return {WebInspector.UISourceCode}
*/
@@ -149,9 +162,8 @@
uiSourceCode.isContentScript = scripts[0].isContentScript;
uiSourceCode.setSourceMapping(this);
if (!uiSourceCode.isTemporary) {
- var scriptFile = new WebInspector.ResourceScriptFile(uiSourceCode);
+ var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode);
uiSourceCode.setScriptFile(scriptFile);
- scriptFile.addEventListener(WebInspector.ScriptFile.Events.HasDivergedFromVMChanged, this._hasDivergedFromVMChanged, this);
}
},
@@ -254,7 +266,10 @@
}
WebInspector.ScriptFile.Events = {
- HasDivergedFromVMChanged: "HasDivergedFromVMChanged",
+ WillMergeToVM: "WillMergeToVM",
+ DidMergeToVM: "DidMergeToVM",
+ WillDivergeFromVM: "WillDivergeFromVM",
+ DidDivergeFromVM: "DidDivergeFromVM",
}
WebInspector.ScriptFile.prototype = {
@@ -287,51 +302,51 @@
* @constructor
* @implements {WebInspector.ScriptFile}
* @extends {WebInspector.Object}
+ * @param {WebInspector.ResourceScriptMapping} resourceScriptMapping
* @param {WebInspector.UISourceCode} uiSourceCode
*/
-WebInspector.ResourceScriptFile = function(uiSourceCode)
+WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode)
{
WebInspector.ScriptFile.call(this);
+ this._resourceScriptMapping = resourceScriptMapping;
this._uiSourceCode = uiSourceCode;
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
}
WebInspector.ResourceScriptFile.prototype = {
- /**
- * @param {function(?string)} callback
- */
- workingCopyCommitted: function(callback)
+ _workingCopyCommitted: function(event)
{
/**
- * @param {?string} error
+ * @param {?string} error
*/
function innerCallback(error)
{
- if (error)
- this._hasDivergedFromVM = true;
- else
- delete this._hasDivergedFromVM;
- this.fireHasDivergedFromVMChanged();
+ if (error) {
+ WebInspector.showErrorMessage(error);
+ return;
+ }
- callback(error);
+ this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillMergeToVM, this);
+ delete this._hasDivergedFromVM;
+ this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode);
+ this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidMergeToVM, this);
}
+
var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ this._uiSourceCode.uiLocationToRawLocation(0, 0);
- if (!rawLocation) {
- callback(null);
+ if (!rawLocation)
return;
- }
var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
WebInspector.debuggerModel.setScriptSource(script.scriptId, this._uiSourceCode.workingCopy(), innerCallback.bind(this));
},
- workingCopyChanged: function()
+ _workingCopyChanged: function(event)
{
- this.fireHasDivergedFromVMChanged();
- },
-
- fireHasDivergedFromVMChanged: function()
- {
this._isDivergingFromVM = true;
- this.dispatchEventToListeners(WebInspector.ScriptFile.Events.HasDivergedFromVMChanged, this._uiSourceCode);
+ this.dispatchEventToListeners(WebInspector.ScriptFile.Events.WillDivergeFromVM, this._uiSourceCode);
+ this._hasDivergedFromVM = true;
+ this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode);
+ this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._uiSourceCode);
delete this._isDivergingFromVM;
},
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (131457 => 131458)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-10-16 15:43:13 UTC (rev 131458)
@@ -450,6 +450,8 @@
this._scriptSnippetModel = scriptSnippetModel;
this._snippetJavaScriptSource = snippetJavaScriptSource;
this._hasDivergedFromVM = true;
+ this._snippetJavaScriptSource.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
+ this._snippetJavaScriptSource.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
}
WebInspector.SnippetScriptFile.prototype = {
@@ -485,16 +487,12 @@
this._isDivergingFromVM = isDivergingFromVM;
},
- /**
- * @param {function(?string)} callback
- */
- workingCopyCommitted: function(callback)
+ _workingCopyCommitted: function()
{
this._scriptSnippetModel._setScriptSnippetContent(this._snippetJavaScriptSource, this._snippetJavaScriptSource.workingCopy());
- callback(null);
},
- workingCopyChanged: function()
+ _workingCopyChanged: function()
{
this._scriptSnippetModel._scriptSnippetEdited(this._snippetJavaScriptSource);
},
Modified: trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js (131457 => 131458)
--- trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js 2012-10-16 15:43:13 UTC (rev 131458)
@@ -102,52 +102,68 @@
WebInspector.StyleFile = function(uiSourceCode)
{
this._uiSourceCode = uiSourceCode;
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
}
WebInspector.StyleFile.updateTimeout = 200;
WebInspector.StyleFile.prototype = {
- /**
- * @param {function(?string)} callback
- */
- workingCopyCommitted: function(callback)
+ _workingCopyCommitted: function(event)
{
- this._commitIncrementalEdit(true, callback);
+ if (this._isAddingRevision)
+ return;
+
+ this._commitIncrementalEdit(true);
},
- workingCopyChanged: function()
+ _workingCopyChanged: function(event)
{
- this._callOrSetTimeout(this._commitIncrementalEdit.bind(this, false, function() {}));
- },
+ if (this._isAddingRevision)
+ return;
- /**
- * @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);
+ if (WebInspector.StyleFile.updateTimeout >= 0) {
+ this._incrementalUpdateTimer = setTimeout(this._commitIncrementalEdit.bind(this, false), WebInspector.StyleFile.updateTimeout)
+ } else
+ this._commitIncrementalEdit(false);
},
/**
* @param {boolean} majorChange
- * @param {function(?string)} callback
*/
- _commitIncrementalEdit: function(majorChange, callback)
+ _commitIncrementalEdit: function(majorChange)
{
+ /**
+ * @param {?string} error
+ */
+ function callback(error)
+ {
+ if (error)
+ WebInspector.showErrorMessage(error);
+ }
+
this._clearIncrementalUpdateTimer();
WebInspector.styleContentBinding.setStyleContent(this._uiSourceCode, this._uiSourceCode.workingCopy(), majorChange, callback);
},
_clearIncrementalUpdateTimer: function()
{
- if (this._incrementalUpdateTimer)
- clearTimeout(this._incrementalUpdateTimer);
+ if (!this._incrementalUpdateTimer)
+ return;
+ clearTimeout(this._incrementalUpdateTimer);
delete this._incrementalUpdateTimer;
},
+
+ /**
+ * @param {string} content
+ */
+ addRevision: function(content)
+ {
+ this._isAddingRevision = true;
+ this._uiSourceCode.addRevision(content);
+ delete this._isAddingRevision;
+ },
}
@@ -245,8 +261,8 @@
if (!uiSourceCode)
return;
- if (uiSourceCode.contentType() === WebInspector.resourceTypes.Stylesheet)
- uiSourceCode.addRevision(content);
+ if (uiSourceCode.styleFile())
+ uiSourceCode.styleFile().addRevision(content);
}
this._cssModel.resourceBinding().requestResourceURLForStyleSheetId(styleSheetId, callback.bind(this));
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (131457 => 131458)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-16 15:41:01 UTC (rev 131457)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-16 15:43:13 UTC (rev 131458)
@@ -308,10 +308,6 @@
delete this._workingCopy;
else
this._workingCopy = newWorkingCopy;
- if (this.scriptFile())
- this.scriptFile().workingCopyChanged();
- else if (this.styleFile())
- this.styleFile().workingCopyChanged();
this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()});
},
@@ -325,11 +321,8 @@
return;
}
- if (this.scriptFile())
- this.scriptFile().workingCopyCommitted(callback);
- else if (this.styleFile())
- this.styleFile().workingCopyCommitted(callback);
this._commitContent(this._workingCopy);
+ callback(null);
},
/**