Diff
Modified: trunk/LayoutTests/ChangeLog (110575 => 110576)
--- trunk/LayoutTests/ChangeLog 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/LayoutTests/ChangeLog 2012-03-13 16:37:36 UTC (rev 110576)
@@ -1,3 +1,13 @@
+2012-03-13 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Add snippets model.
+ https://bugs.webkit.org/show_bug.cgi?id=80863
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/debugger/snippets-model-expected.txt: Added.
+ * inspector/debugger/snippets-model.html: Added.
+
2012-03-13 Nikolas Zimmermann <[email protected]>
[Qt] svg/animations tests are very flaky
Added: trunk/LayoutTests/inspector/debugger/snippets-model-expected.txt (0 => 110576)
--- trunk/LayoutTests/inspector/debugger/snippets-model-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/debugger/snippets-model-expected.txt 2012-03-13 16:37:36 UTC (rev 110576)
@@ -0,0 +1,35 @@
+Tests how snippets model stores, saves and loads snippets
+
+Dumping saved snippets:
+Dumping model snippets:
+Snippet created.
+Dumping saved snippets:
+ Snippet: id = 1, name = 'Snippet #1', content = ''.
+Dumping model snippets:
+ Snippet: id = 1, name = 'Snippet #1', content = ''.
+Snippet renamed.
+Dumping saved snippets:
+ Snippet: id = 1, name = 'New snippet name', content = ''.
+Dumping model snippets:
+ Snippet: id = 1, name = 'New snippet name', content = ''.
+Snippet content changed.
+Dumping saved snippets:
+ Snippet: id = 1, name = 'New snippet name', content = 'New snippet content'.
+Dumping model snippets:
+ Snippet: id = 1, name = 'New snippet name', content = 'New snippet content'.
+Another snippet created.
+Dumping saved snippets:
+ Snippet: id = 1, name = 'New snippet name', content = 'New snippet content'.
+ Snippet: id = 2, name = 'Snippet #2', content = ''.
+Dumping model snippets:
+ Snippet: id = 1, name = 'New snippet name', content = 'New snippet content'.
+ Snippet: id = 2, name = 'Snippet #2', content = ''.
+Snippet deleted.
+Dumping saved snippets:
+ Snippet: id = 2, name = 'Snippet #2', content = ''.
+Dumping model snippets:
+ Snippet: id = 2, name = 'Snippet #2', content = ''.
+Another snippet deleted.
+Dumping saved snippets:
+Dumping model snippets:
+
Property changes on: trunk/LayoutTests/inspector/debugger/snippets-model-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/debugger/snippets-model.html (0 => 110576)
--- trunk/LayoutTests/inspector/debugger/snippets-model.html (rev 0)
+++ trunk/LayoutTests/inspector/debugger/snippets-model.html 2012-03-13 16:37:36 UTC (rev 110576)
@@ -0,0 +1,65 @@
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ function dumpSnippets(snippets)
+ {
+ for (var i = 0; i < snippets.length; ++i) {
+ var snippet = snippets[i];
+ InspectorTest.addResult(" Snippet: id = " + snippet.id + ", name = '" + snippet.name + "', content = '" + snippet.content + "'.");
+ }
+ }
+
+ function dumpSavedSnippets()
+ {
+ InspectorTest.addResult("Dumping saved snippets:");
+ dumpSnippets(WebInspector.snippetsModel._snippetsSetting.get());
+ }
+
+ function dumpModelSnippets()
+ {
+ InspectorTest.addResult("Dumping model snippets:");
+ dumpSnippets(WebInspector.snippetsModel.snippets);
+ }
+
+ // FIXME: Remove once snippets are taken out of experiments.
+ if (!WebInspector.experimentsSettings.snippetsSupport.isEnabled())
+ WebInspector.snippetsModel = new WebInspector.SnippetsModel();
+
+ dumpSavedSnippets();
+ dumpModelSnippets();
+ var snippet = WebInspector.snippetsModel.createSnippet();
+ InspectorTest.addResult("Snippet created.");
+ dumpSavedSnippets();
+ dumpModelSnippets();
+ snippet.name = "New snippet name";
+ InspectorTest.addResult("Snippet renamed.");
+ dumpSavedSnippets();
+ dumpModelSnippets();
+ snippet.content = "New snippet content";
+ InspectorTest.addResult("Snippet content changed.");
+ dumpSavedSnippets();
+ dumpModelSnippets();
+ var anotherSnippet = WebInspector.snippetsModel.createSnippet();
+ InspectorTest.addResult("Another snippet created.");
+ dumpSavedSnippets();
+ dumpModelSnippets();
+ WebInspector.snippetsModel.deleteSnippet(snippet);
+ InspectorTest.addResult("Snippet deleted.");
+ dumpSavedSnippets();
+ dumpModelSnippets();
+ WebInspector.snippetsModel.deleteSnippet(anotherSnippet);
+ InspectorTest.addResult("Another snippet deleted.");
+ dumpSavedSnippets();
+ dumpModelSnippets();
+
+ InspectorTest.completeTest();
+};
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests how snippets model stores, saves and loads snippets</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/snippets-model.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (110575 => 110576)
--- trunk/Source/WebCore/ChangeLog 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/ChangeLog 2012-03-13 16:37:36 UTC (rev 110576)
@@ -1,3 +1,22 @@
+2012-03-13 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Add snippets model.
+ https://bugs.webkit.org/show_bug.cgi?id=80863
+
+ Reviewed by Yury Semikhatsky.
+
+ Test: inspector/debugger/snippets-model.html
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/compile-front-end.py:
+ * inspector/front-end/Settings.js:
+ (WebInspector.ExperimentsSettings):
+ * inspector/front-end/SnippetsModel.js: Added.
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+ * inspector/front-end/inspector.js:
+
2012-03-13 'Pavel Feldman' <[email protected]>
Not reviewed: chromium build fix.
Modified: trunk/Source/WebCore/WebCore.gypi (110575 => 110576)
--- trunk/Source/WebCore/WebCore.gypi 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/WebCore.gypi 2012-03-13 16:37:36 UTC (rev 110576)
@@ -6288,6 +6288,7 @@
'inspector/front-end/SidebarOverlay.js',
'inspector/front-end/SidebarPane.js',
'inspector/front-end/SidebarTreeElement.js',
+ 'inspector/front-end/SnippetsModel.js',
'inspector/front-end/SoftContextMenu.js',
'inspector/front-end/SourceCSSTokenizer.js',
'inspector/front-end/SourceFrame.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (110575 => 110576)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-03-13 16:37:36 UTC (rev 110576)
@@ -73861,6 +73861,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\SnippetsModel.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\SoftContextMenu.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/compile-front-end.py (110575 => 110576)
--- trunk/Source/WebCore/inspector/compile-front-end.py 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/inspector/compile-front-end.py 2012-03-13 16:37:36 UTC (rev 110576)
@@ -81,6 +81,7 @@
"Script.js",
"ScriptFormatter.js",
"ScriptMapping.js",
+ "SnippetsModel.js",
"TimelineManager.js",
"TimelineModel.js",
"TimelinePresentationModel.js",
Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (110575 => 110576)
--- trunk/Source/WebCore/inspector/front-end/Settings.js 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js 2012-03-13 16:37:36 UTC (rev 110576)
@@ -180,6 +180,7 @@
this.showIndexedDB = this._createExperiment("showIndexedDB", "Show IndexedDB in Resources panel");
this.debugCSS = this._createExperiment("debugCSS", "Load CSS via link tags for debugging");
this.showShadowDOM = this._createExperiment("showShadowDOM", "Show shadow DOM");
+ this.snippetsSupport = this._createExperiment("snippetsSupport", "Snippets support");
this._cleanUpSetting();
}
Added: trunk/Source/WebCore/inspector/front-end/SnippetsModel.js (0 => 110576)
--- trunk/Source/WebCore/inspector/front-end/SnippetsModel.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/SnippetsModel.js 2012-03-13 16:37:36 UTC (rev 110576)
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
+ * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ */
+WebInspector.SnippetsModel = function()
+{
+ /** @type {Array.<WebInspector.Snippet>} */ this._snippets;
+
+ this._lastSnippetIdentifierSetting = WebInspector.settings.createSetting("lastSnippetIdentifier", 0);
+ this._snippetsSetting = WebInspector.settings.createSetting("snippets", []);
+
+ this._loadSettings();
+}
+
+WebInspector.SnippetsModel.EventTypes = {
+ SnippetAdded: "SnippetAdded",
+ SnippetRenamed: "SnippetRenamed",
+ SnippetDeleted: "SnippetDeleted",
+}
+
+WebInspector.SnippetsModel.prototype = {
+ /**
+ * @return {Array.<WebInspector.Snippet>}
+ */
+ get snippets()
+ {
+ return this._snippets.slice();
+ },
+
+ _saveSettings: function()
+ {
+ var savedSnippets = [];
+ for (var i = 0; i < this._snippets.length; ++i)
+ savedSnippets.push(this._snippets[i].serializeToObject());
+
+ this._snippetsSetting.set(savedSnippets);
+ },
+
+ _loadSettings: function()
+ {
+ this._snippets = [];
+ var savedSnippets = this._snippetsSetting.get();
+ for (var i = 0; i < savedSnippets.length; ++i)
+ this._snippetAdded(WebInspector.Snippet.fromObject(savedSnippets[i]));
+ },
+
+ /**
+ * @param {WebInspector.Snippet} snippet
+ */
+ deleteSnippet: function(snippet)
+ {
+ for (var i = 0; i < this._snippets.length; ++i) {
+ if (snippet.id === this._snippets[i].id) {
+ this._snippets.splice(i, 1);
+ this._saveSettings();
+ this.dispatchEventToListeners(WebInspector.SnippetsModel.EventTypes.SnippetDeleted, snippet);
+ break;
+ }
+ }
+ },
+
+ /**
+ * @return {WebInspector.Snippet}
+ */
+ createSnippet: function()
+ {
+ var snippetId = this._lastSnippetIdentifierSetting.get() + 1;
+ this._lastSnippetIdentifierSetting.set(snippetId);
+ var snippet = new WebInspector.Snippet(this, snippetId);
+ this._snippetAdded(snippet);
+ this._saveSettings();
+
+ return snippet;
+ },
+
+ /**
+ * @param {WebInspector.Snippet} snippet
+ */
+ _snippetAdded: function(snippet)
+ {
+ this._snippets.push(snippet);
+ this.dispatchEventToListeners(WebInspector.SnippetsModel.EventTypes.SnippetAdded, snippet);
+ },
+
+ /**
+ * @param {number} snippetId
+ */
+ _snippetContentUpdated: function(snippetId)
+ {
+ this._saveSettings();
+ },
+
+ /**
+ * @param {WebInspector.Snippet} snippet
+ */
+ _snippetRenamed: function(snippet)
+ {
+ this._saveSettings();
+ this.dispatchEventToListeners(WebInspector.SnippetsModel.EventTypes.SnippetRenamed, snippet);
+ },
+
+ /**
+ * @param {number} snippetId
+ * @return {WebInspector.Snippet|undefined}
+ */
+ snippetForId: function(snippetId)
+ {
+ return this._snippets[snippetId];
+ }
+}
+
+WebInspector.SnippetsModel.prototype.__proto__ = WebInspector.Object.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ * @param {WebInspector.SnippetsModel} model
+ * @param {number} id
+ * @param {string=} name
+ * @param {string=} content
+ */
+WebInspector.Snippet = function(model, id, name, content)
+{
+ this._model = model;
+ this._id = id;
+ this._name = name || "Snippet #" + id;
+ this._content = content || "";
+}
+
+/**
+ * @param {Object} serializedSnippet
+ * @return {WebInspector.Snippet}
+ */
+WebInspector.Snippet.fromObject = function(serializedSnippet)
+{
+ return new WebInspector.Snippet(this, serializedSnippet.id, serializedSnippet.name, serializedSnippet.content);
+}
+
+WebInspector.Snippet.prototype = {
+ /**
+ * @type {number}
+ */
+ get id()
+ {
+ return this._id;
+ },
+
+ /**
+ * @type {string}
+ */
+ get name()
+ {
+ return this._name;
+ },
+
+ set name(name)
+ {
+ if (this._name === name)
+ return;
+
+ this._name = name;
+ this._model._snippetRenamed(this);
+ },
+
+ /**
+ * @type {string}
+ */
+ get content()
+ {
+ return this._content;
+ },
+
+ set content(content)
+ {
+ if (this._content === content)
+ return;
+
+ this._content = content;
+ this._model._snippetContentUpdated(this._id);
+ },
+
+ /**
+ * @return {Object}
+ */
+ serializeToObject: function()
+ {
+ var serializedSnippet = {};
+ serializedSnippet.id = this.id;
+ serializedSnippet.name = this.name;
+ serializedSnippet.content = this.content;
+ return serializedSnippet;
+ }
+}
+
+WebInspector.Snippet.prototype.__proto__ = WebInspector.Object.prototype;
Property changes on: trunk/Source/WebCore/inspector/front-end/SnippetsModel.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (110575 => 110576)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-03-13 16:37:36 UTC (rev 110576)
@@ -132,6 +132,7 @@
<file>SidebarOverlay.js</file>
<file>SidebarPane.js</file>
<file>SidebarTreeElement.js</file>
+ <file>SnippetsModel.js</file>
<file>SoftContextMenu.js</file>
<file>SourceCSSTokenizer.js</file>
<file>SourceFrame.js</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (110575 => 110576)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2012-03-13 16:37:36 UTC (rev 110576)
@@ -198,6 +198,7 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
</head>
<body class="detached" id="-webkit-web-inspector">
<div id="toolbar">
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (110575 => 110576)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2012-03-13 16:33:37 UTC (rev 110575)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2012-03-13 16:37:36 UTC (rev 110576)
@@ -406,6 +406,8 @@
this.console.addEventListener(WebInspector.ConsoleModel.Events.RepeatCountUpdated, this._updateErrorAndWarningCounts, this);
this.debuggerModel = new WebInspector.DebuggerModel();
+ if (WebInspector.experimentsSettings.snippetsSupport.isEnabled())
+ this.snippetsModel = new WebInspector.SnippetsModel();
this.debuggerPresentationModel = new WebInspector.DebuggerPresentationModel();
this.drawer = new WebInspector.Drawer();