Title: [124584] trunk
Revision
124584
Author
[email protected]
Date
2012-08-03 02:03:05 -0700 (Fri, 03 Aug 2012)

Log Message

Web Inspector: Make textModel private to textEditor
https://bugs.webkit.org/show_bug.cgi?id=92999

Patch by Jan Keromnes <[email protected]> on 2012-08-03
Reviewed by Pavel Feldman.

Source/WebCore:

Making textModel private to the textEditor ensures that it is accessed
only through the textEditor, making the latter more modular.

Tests were changed accordingly.

* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
(WebInspector._javascript_SourceFrame.prototype._restoreBreakpointsAfterEditing):
(WebInspector._javascript_SourceFrame.prototype._addBreakpointDecoration):
(WebInspector._javascript_SourceFrame.prototype._removeBreakpointDecoration):
(WebInspector._javascript_SourceFrame.prototype._lineNumberAfterEditing):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.prototype.setContent):
(WebInspector.SourceFrame.prototype.replaceAllWith):
(WebInspector.SourceFrame.prototype._collectRegexMatches):
(WebInspector.SourceFrame.prototype.addMessageToSource):
(WebInspector.SourceFrame.prototype.removeMessageFromSource):
(WebInspector.TextEditorDelegateForSourceFrame.prototype.commitEditing):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor.prototype.setText):
(WebInspector.TextEditor.prototype.text):
(WebInspector.TextEditor.prototype.range):
(WebInspector.TextEditor.prototype.line):
(WebInspector.TextEditor.prototype.get linesCount):
(WebInspector.TextEditor.prototype.setAttribute):
(WebInspector.TextEditor.prototype.getAttribute):
(WebInspector.TextEditor.prototype.removeAttribute):
* inspector/front-end/UISourceCodeFrame.js:
(WebInspector.UISourceCodeFrame.prototype.afterTextChanged):

LayoutTests:

Tests no longer access textModel directly from sourceFrame.

* http/tests/inspector/debugger-test.js:
(initialize_DebuggerTest):
* http/tests/inspector/live-edit-test.js:
(initialize_LiveEditTest.InspectorTest.replaceInSource):
(initialize_LiveEditTest):
* inspector/debugger/pause-in-inline-script.html:
* inspector/debugger/script-formatter.html:
* inspector/debugger/source-url-comment.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124583 => 124584)


--- trunk/LayoutTests/ChangeLog	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/LayoutTests/ChangeLog	2012-08-03 09:03:05 UTC (rev 124584)
@@ -1,3 +1,21 @@
+2012-08-03  Jan Keromnes  <[email protected]>
+
+        Web Inspector: Make textModel private to textEditor
+        https://bugs.webkit.org/show_bug.cgi?id=92999
+
+        Reviewed by Pavel Feldman.
+
+        Tests no longer access textModel directly from sourceFrame.
+
+        * http/tests/inspector/debugger-test.js:
+        (initialize_DebuggerTest):
+        * http/tests/inspector/live-edit-test.js:
+        (initialize_LiveEditTest.InspectorTest.replaceInSource):
+        (initialize_LiveEditTest):
+        * inspector/debugger/pause-in-inline-script.html:
+        * inspector/debugger/script-formatter.html:
+        * inspector/debugger/source-url-comment.html:
+
 2012-08-03  Yuta Kitamura  <[email protected]>
 
         Unreviewed, test expectation change only.

Modified: trunk/LayoutTests/http/tests/inspector/debugger-test.js (124583 => 124584)


--- trunk/LayoutTests/http/tests/inspector/debugger-test.js	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/LayoutTests/http/tests/inspector/debugger-test.js	2012-08-03 09:03:05 UTC (rev 124584)
@@ -128,9 +128,9 @@
 InspectorTest.dumpSourceFrameContents = function(sourceFrame)
 {
     InspectorTest.addResult("==Source frame contents start==");
-    var textModel = sourceFrame._textModel;
-    for (var i = 0; i < textModel.linesCount; ++i)
-        InspectorTest.addResult(textModel.line(i));
+    var textEditor = sourceFrame._textEditor;
+    for (var i = 0; i < textEditor.linesCount; ++i)
+        InspectorTest.addResult(textEditor.line(i));
     InspectorTest.addResult("==Source frame contents end==");
 };
 

Modified: trunk/LayoutTests/http/tests/inspector/live-edit-test.js (124583 => 124584)


--- trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/LayoutTests/http/tests/inspector/live-edit-test.js	2012-08-03 09:03:05 UTC (rev 124584)
@@ -5,7 +5,7 @@
     sourceFrame._textEditor._mainPanel.setReadOnly(false);
     sourceFrame.beforeTextChanged();
     var oldRange, newRange;
-    var lines = sourceFrame._textModel._lines;
+    var lines = sourceFrame._textEditor._textModel._lines;
     for (var i = 0; i < lines.length; ++i) {
         var column = lines[i].indexOf(string);
         if (column === -1)

Modified: trunk/LayoutTests/inspector/debugger/pause-in-inline-script.html (124583 => 124584)


--- trunk/LayoutTests/inspector/debugger/pause-in-inline-script.html	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/LayoutTests/inspector/debugger/pause-in-inline-script.html	2012-08-03 09:03:05 UTC (rev 124584)
@@ -65,7 +65,7 @@
     function didShowScript(sourceFrame)
     {
         InspectorTest.addResult("didShowScript");
-        var resourceText = sourceFrame._textModel.text();
+        var resourceText = sourceFrame._textEditor.text();
         var lines = resourceText.split("\n");
         var callFrames = WebInspector.debuggerModel.callFrames;
         InspectorTest.addResult("Source strings corresponding to the call stack:");

Modified: trunk/LayoutTests/inspector/debugger/script-formatter.html (124583 => 124584)


--- trunk/LayoutTests/inspector/debugger/script-formatter.html	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/LayoutTests/inspector/debugger/script-formatter.html	2012-08-03 09:03:05 UTC (rev 124584)
@@ -36,12 +36,12 @@
             InspectorTest.showScriptSource("obfuscated.js", didShowScriptSource);
             function didShowScriptSource(sourceFrame)
             {
-                formatter.formatContent("text/_javascript_", sourceFrame._textModel.text(), didFormatContent);
+                formatter.formatContent("text/_javascript_", sourceFrame._textEditor.text(), didFormatContent);
             }
 
             function didFormatContent(content, mapping)
             {
-                var source = WebInspector.panels.scripts.visibleView._textModel.text();
+                var source = WebInspector.panels.scripts.visibleView._textEditor.text();
                 var formattedSource = content;
 
                 function testMapping(string)

Modified: trunk/LayoutTests/inspector/debugger/source-url-comment.html (124583 => 124584)


--- trunk/LayoutTests/inspector/debugger/source-url-comment.html	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/LayoutTests/inspector/debugger/source-url-comment.html	2012-08-03 09:03:05 UTC (rev 124584)
@@ -20,7 +20,7 @@
 
             function didShowScriptSource(sourceFrame)
             {
-                InspectorTest.addResult(sourceFrame.textModel.text());
+                InspectorTest.addResult(sourceFrame.textEditor.text());
                 next();
             }
         }

Modified: trunk/Source/WebCore/ChangeLog (124583 => 124584)


--- trunk/Source/WebCore/ChangeLog	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/Source/WebCore/ChangeLog	2012-08-03 09:03:05 UTC (rev 124584)
@@ -1,3 +1,41 @@
+2012-08-03  Jan Keromnes  <[email protected]>
+
+        Web Inspector: Make textModel private to textEditor
+        https://bugs.webkit.org/show_bug.cgi?id=92999
+
+        Reviewed by Pavel Feldman.
+
+        Making textModel private to the textEditor ensures that it is accessed
+        only through the textEditor, making the latter more modular.
+
+        Tests were changed accordingly.
+
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.afterTextChanged):
+        (WebInspector._javascript_SourceFrame.prototype._restoreBreakpointsAfterEditing):
+        (WebInspector._javascript_SourceFrame.prototype._addBreakpointDecoration):
+        (WebInspector._javascript_SourceFrame.prototype._removeBreakpointDecoration):
+        (WebInspector._javascript_SourceFrame.prototype._lineNumberAfterEditing):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        (WebInspector.SourceFrame.prototype.setContent):
+        (WebInspector.SourceFrame.prototype.replaceAllWith):
+        (WebInspector.SourceFrame.prototype._collectRegexMatches):
+        (WebInspector.SourceFrame.prototype.addMessageToSource):
+        (WebInspector.SourceFrame.prototype.removeMessageFromSource):
+        (WebInspector.TextEditorDelegateForSourceFrame.prototype.commitEditing):
+        * inspector/front-end/TextEditor.js:
+        (WebInspector.TextEditor.prototype.setText):
+        (WebInspector.TextEditor.prototype.text):
+        (WebInspector.TextEditor.prototype.range):
+        (WebInspector.TextEditor.prototype.line):
+        (WebInspector.TextEditor.prototype.get linesCount):
+        (WebInspector.TextEditor.prototype.setAttribute):
+        (WebInspector.TextEditor.prototype.getAttribute):
+        (WebInspector.TextEditor.prototype.removeAttribute):
+        * inspector/front-end/UISourceCodeFrame.js:
+        (WebInspector.UISourceCodeFrame.prototype.afterTextChanged):
+
 2012-08-03  Adam Barth  <[email protected]>
 
         V8Proxy::retrieve(*) leads to really obfuscated code and should be removed

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (124583 => 124584)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-08-03 09:03:05 UTC (rev 124584)
@@ -150,7 +150,7 @@
     afterTextChanged: function(oldRange, newRange)
     {
         WebInspector.SourceFrame.prototype.afterTextChanged.call(this, oldRange, newRange);
-        this._javaScriptSource.setWorkingCopy(this.textModel.text());
+        this._javaScriptSource.setWorkingCopy(this._textEditor.text());
         this._restoreBreakpointsAfterEditing();
     },
 
@@ -192,8 +192,8 @@
     {
         if (!this._javaScriptSource.isDirty() || this._javaScriptSource.supportsEnabledBreakpointsWhileEditing()) {
             // Restore all muted breakpoints.
-            for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
-                var breakpointDecoration = this.textModel.getAttribute(lineNumber, "breakpoint");
+            for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
+                var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
                 if (breakpointDecoration) {
                     // Remove fake decoration
                     this._removeBreakpointDecoration(lineNumber);
@@ -333,7 +333,7 @@
             condition: condition,
             enabled: enabled
         };
-        this.textModel.setAttribute(lineNumber, "breakpoint", breakpoint);
+        this.textEditor.setAttribute(lineNumber, "breakpoint", breakpoint);
 
         this.textEditor.beginUpdates();
         this.textEditor.addDecoration(lineNumber, "webkit-breakpoint");
@@ -350,7 +350,7 @@
 
     _removeBreakpointDecoration: function(lineNumber)
     {
-        this.textModel.removeAttribute(lineNumber, "breakpoint");
+        this.textEditor.removeAttribute(lineNumber, "breakpoint");
         this.textEditor.beginUpdates();
         this.textEditor.removeDecoration(lineNumber, "webkit-breakpoint");
         this.textEditor.removeDecoration(lineNumber, "webkit-breakpoint-disabled");
@@ -460,7 +460,7 @@
         if (lineNumber === oldRange.startLine) {
             var whiteSpacesRegex = /^[\s\xA0]*$/;
             for (var i = 0; lineNumber + i <= newRange.endLine; ++i) {
-                if (!whiteSpacesRegex.test(this.textModel.line(lineNumber + i))) {
+                if (!whiteSpacesRegex.test(this.textEditor.line(lineNumber + i))) {
                     shiftOffset = i;
                     break;
                 }

Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (124583 => 124584)


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2012-08-03 09:03:05 UTC (rev 124584)
@@ -41,10 +41,8 @@
     this._url = contentProvider.contentURL();
     this._contentProvider = contentProvider;
 
-    this._textModel = new WebInspector.TextEditorModel();
-
     var textEditorDelegate = new WebInspector.TextEditorDelegateForSourceFrame(this);
-    this._textEditor = new WebInspector.TextEditor(this._textModel, this._url, textEditorDelegate);
+    this._textEditor = new WebInspector.TextEditor(this._url, textEditorDelegate);
 
     this._currentSearchResultIndex = -1;
     this._searchResults = [];
@@ -160,11 +158,6 @@
         this._textEditor.doResize();
     },
 
-    get textModel()
-    {
-        return this._textModel;
-    },
-
     /**
      * @param {number} line
      */
@@ -299,7 +292,7 @@
         this._textEditor.mimeType = mimeType;
 
         this._loaded = true;
-        this._textModel.setText(content || "");
+        this._textEditor.setText(content || "");
 
         this._textEditor.beginUpdates();
 
@@ -456,8 +449,8 @@
     {
         this._textEditor.markAndRevealRange(null);
 
-        var text = this._textModel.text();
-        var range = this._textModel.range();
+        var text = this._textEditor.text();
+        var range = this._textEditor.range();
         text = text.replace(WebInspector.SourceFrame.createSearchRegex(query, "g"), replacement);
 
         this._isReplacing = true;
@@ -468,8 +461,8 @@
     _collectRegexMatches: function(regexObject)
     {
         var ranges = [];
-        for (var i = 0; i < this._textModel.linesCount; ++i) {
-            var line = this._textModel.line(i);
+        for (var i = 0; i < this._textEditor.linesCount; ++i) {
+            var line = this._textEditor.line(i);
             var offset = 0;
             do {
                 var match = regexObject.exec(line);
@@ -493,8 +486,8 @@
 
     addMessageToSource: function(lineNumber, msg)
     {
-        if (lineNumber >= this._textModel.linesCount)
-            lineNumber = this._textModel.linesCount - 1;
+        if (lineNumber >= this._textEditor.linesCount)
+            lineNumber = this._textEditor.linesCount - 1;
         if (lineNumber < 0)
             lineNumber = 0;
 
@@ -567,8 +560,8 @@
 
     removeMessageFromSource: function(lineNumber, msg)
     {
-        if (lineNumber >= this._textModel.linesCount)
-            lineNumber = this._textModel.linesCount - 1;
+        if (lineNumber >= this._textEditor.linesCount)
+            lineNumber = this._textEditor.linesCount - 1;
         if (lineNumber < 0)
             lineNumber = 0;
 
@@ -662,7 +655,7 @@
 
     commitEditing: function()
     {
-        this._sourceFrame.commitEditing(this._sourceFrame._textModel.text());
+        this._sourceFrame.commitEditing(this._sourceFrame._textEditor.text());
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/TextEditor.js (124583 => 124584)


--- trunk/Source/WebCore/inspector/front-end/TextEditor.js	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/Source/WebCore/inspector/front-end/TextEditor.js	2012-08-03 09:03:05 UTC (rev 124584)
@@ -32,16 +32,15 @@
 /**
  * @extends {WebInspector.View}
  * @constructor
- * @param {WebInspector.TextEditorModel} textModel
  * @param {?string} url
  * @param {WebInspector.TextEditorDelegate} delegate
  */
-WebInspector.TextEditor = function(textModel, url, delegate)
+WebInspector.TextEditor = function(url, delegate)
 {
     WebInspector.View.call(this);
     this.registerRequiredCSS("textEditor.css");
 
-    this._textModel = textModel;
+    this._textModel = new WebInspector.TextEditorModel();
     this._textModel.addEventListener(WebInspector.TextEditorModel.Events.TextChanged, this._textChanged, this);
     this._textModel.resetUndoStack();
     this._delegate = delegate;
@@ -427,6 +426,76 @@
             this._mainPanel._restoreSelection(textRange);
     },
 
+    /**
+     * @param {string} text 
+     */
+    setText: function(text)
+    {
+        this._textModel.setText(text);
+    },
+
+    /**
+     * @return {string}
+     */
+    text: function()
+    {
+        return this._textModel.text();
+    },
+
+    /**
+     * @return {WebInspector.TextRange}
+     */
+    range: function()
+    {
+        return this._textModel.range();
+    },
+
+    /**
+     * @param {number} lineNumber
+     * @return {string}
+     */
+    line: function(lineNumber)
+    {
+        return this._textModel.line(lineNumber);
+    },
+
+    /**
+     * @return {number}
+     */
+    get linesCount()
+    {
+        return this._textModel.linesCount;
+    },
+
+    /**
+     * @param {number} line
+     * @param {string} name  
+     * @param {Object?} value  
+     */
+    setAttribute: function(line, name, value)
+    {
+        this._textModel.setAttribute(line, name, value);
+    },
+
+    /**
+     * @param {number} line
+     * @param {string} name  
+     * @return {Object|null} value  
+     */
+    getAttribute: function(line, name)
+    {
+        return this._textModel.getAttribute(line, name);
+    },
+
+    /**
+     * @param {number} line
+     * @param {string} name
+     */
+    removeAttribute: function(line, name)
+    {
+        this._textModel.removeAttribute(line, name);
+    },
+
     wasShown: function()
     {
         if (!this.readOnly())

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js (124583 => 124584)


--- trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js	2012-08-03 08:56:08 UTC (rev 124583)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js	2012-08-03 09:03:05 UTC (rev 124584)
@@ -61,7 +61,7 @@
 
     afterTextChanged: function(oldRange, newRange)
     {
-        this._uiSourceCode.setWorkingCopy(this.textModel.text());
+        this._uiSourceCode.setWorkingCopy(this._textEditor.text());
     },
 
     _didEditContent: function(error)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to