Title: [90743] trunk
Revision
90743
Author
podivi...@chromium.org
Date
2011-07-11 07:08:57 -0700 (Mon, 11 Jul 2011)

Log Message

Web Inspector: make SourceFrame a View.
https://bugs.webkit.org/show_bug.cgi?id=64274

Reviewed by Pavel Feldman.

* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.createSearchRegex):
(WebInspector.SourceFrame.prototype.show):
(WebInspector.SourceFrame.prototype.hide):
(WebInspector.SourceFrame.prototype._beforeTextChanged):
(WebInspector.SourceFrame.prototype._afterTextChanged):
(WebInspector.SourceFrame.prototype._initializeTextViewer):
(WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
(WebInspector.SourceFrame.prototype.performSearch):
(WebInspector.SourceFrame.prototype._populateTextAreaContextMenu):
(WebInspector.SourceFrame.prototype._suggestedFileName):
(WebInspector.SourceFrame.prototype._doubleClick):
(WebInspector.SourceFrame.prototype._cancelEditing):
(WebInspector.TextViewerDelegateForSourceFrame):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.doubleClick):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.beforeTextChanged):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.afterTextChanged):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.commitEditing):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.cancelEditing):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.populateLineGutterContextMenu):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.populateTextAreaContextMenu):
(WebInspector.TextViewerDelegateForSourceFrame.prototype.suggestedFileName):
* inspector/front-end/TextViewer.js:
(WebInspector.TextViewerDelegate.prototype.populateLineGutterContextMenu):

Modified Paths

Diff

Modified: trunk/LayoutTests/inspector/debugger/live-edit.html (90742 => 90743)


--- trunk/LayoutTests/inspector/debugger/live-edit.html	2011-07-11 14:03:44 UTC (rev 90742)
+++ trunk/LayoutTests/inspector/debugger/live-edit.html	2011-07-11 14:08:57 UTC (rev 90743)
@@ -112,7 +112,7 @@
     {
         InspectorTest.addSniffer(WebInspector.debuggerModel, "_didEditScriptSource", callback);
         sourceFrame._textViewer._mainPanel.readOnly = false;
-        sourceFrame.beforeTextChanged();
+        sourceFrame._beforeTextChanged();
         var oldRange, newRange;
         var lines = sourceFrame._textModel._lines;
         for (var i = 0; i < lines.length; ++i) {
@@ -126,7 +126,7 @@
             newRange = new WebInspector.TextRange(i, column, i + lineEndings.length - 1, lastLineLength);
             break;
         }
-        sourceFrame.afterTextChanged(oldRange, newRange);
+        sourceFrame._afterTextChanged(oldRange, newRange);
         sourceFrame._textViewer._commitEditing();
     }
 };

Modified: trunk/Source/WebCore/ChangeLog (90742 => 90743)


--- trunk/Source/WebCore/ChangeLog	2011-07-11 14:03:44 UTC (rev 90742)
+++ trunk/Source/WebCore/ChangeLog	2011-07-11 14:08:57 UTC (rev 90743)
@@ -1,3 +1,36 @@
+2011-07-11  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: make SourceFrame a View.
+        https://bugs.webkit.org/show_bug.cgi?id=64274
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        (WebInspector.SourceFrame.createSearchRegex):
+        (WebInspector.SourceFrame.prototype.show):
+        (WebInspector.SourceFrame.prototype.hide):
+        (WebInspector.SourceFrame.prototype._beforeTextChanged):
+        (WebInspector.SourceFrame.prototype._afterTextChanged):
+        (WebInspector.SourceFrame.prototype._initializeTextViewer):
+        (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
+        (WebInspector.SourceFrame.prototype.performSearch):
+        (WebInspector.SourceFrame.prototype._populateTextAreaContextMenu):
+        (WebInspector.SourceFrame.prototype._suggestedFileName):
+        (WebInspector.SourceFrame.prototype._doubleClick):
+        (WebInspector.SourceFrame.prototype._cancelEditing):
+        (WebInspector.TextViewerDelegateForSourceFrame):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.doubleClick):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.beforeTextChanged):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.afterTextChanged):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.commitEditing):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.cancelEditing):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.populateLineGutterContextMenu):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.populateTextAreaContextMenu):
+        (WebInspector.TextViewerDelegateForSourceFrame.prototype.suggestedFileName):
+        * inspector/front-end/TextViewer.js:
+        (WebInspector.TextViewerDelegate.prototype.populateLineGutterContextMenu):
+
 2011-07-11  Noel Gordon  <noel.gor...@gmail.com>
 
         Reviewed by Adam Roben.

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


--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-07-11 14:03:44 UTC (rev 90742)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js	2011-07-11 14:08:57 UTC (rev 90743)
@@ -30,7 +30,8 @@
 
 WebInspector.SourceFrame = function(delegate, url)
 {
-    WebInspector.TextViewerDelegate.call(this);
+    WebInspector.View.call(this);
+    this.element.addStyleClass("script-view");
 
     this._delegate = delegate;
     this._url = url;
@@ -38,9 +39,9 @@
     this._textModel = new WebInspector.TextEditorModel();
     this._textModel.replaceTabsWithSpaces = true;
 
-    this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url, this);
-    this._textViewer.element.addStyleClass("script-view");
-    this._visible = false;
+    var textViewerDelegate = new WebInspector.TextViewerDelegateForSourceFrame(this);
+    this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url, textViewerDelegate);
+    this.element.appendChild(this._textViewer.element);
 
     this._currentSearchResultIndex = -1;
     this._searchResults = [];
@@ -59,7 +60,7 @@
 WebInspector.SourceFrame.createSearchRegex = function(query)
 {
     var regex;
-    
+
     // First try creating regex if user knows the / / hint.
     try {
         if (/^\/.*\/$/.test(query))
@@ -69,30 +70,20 @@
     }
 
     // Otherwise just do case-insensitive search.
-    if (!regex) 
+    if (!regex)
         regex = createSearchRegex(query);
-    
+
     return regex;
 }
 
 
 WebInspector.SourceFrame.prototype = {
-    get visible()
+    show: function(parentElement)
     {
-        return this._textViewer.visible;
-    },
+        WebInspector.View.prototype.show.call(this, parentElement);
 
-    set visible(x)
-    {
-        this._textViewer.visible = x;
-    },
-
-    show: function(parentElement)
-    {
         this._ensureContentLoaded();
 
-        this._textViewer.show(parentElement);
-
         if (this.loaded) {
             if (this._scrollTop)
                 this._textViewer.scrollTop = this._scrollTop;
@@ -105,6 +96,8 @@
 
     hide: function()
     {
+        WebInspector.View.prototype.hide.call(this);
+
         if (this.loaded) {
             this._scrollTop = this._textViewer.scrollTop;
             this._scrollLeft = this._textViewer.scrollLeft;
@@ -116,16 +109,6 @@
         this._clearLineHighlight();
     },
 
-    detach: function()
-    {
-        this._textViewer.detach();
-    },
-
-    get element()
-    {
-        return this._textViewer.element;
-    },
-
     get loaded()
     {
         return !!this._content;
@@ -254,7 +237,7 @@
         delete this._viewerState;
     },
 
-    beforeTextChanged: function()
+    _beforeTextChanged: function()
     {
         if (!this._viewerState) {
             this._saveViewerState();
@@ -265,7 +248,7 @@
         this.clearMessages();
     },
 
-    afterTextChanged: function(oldRange, newRange)
+    _afterTextChanged: function(oldRange, newRange)
     {
         if (!oldRange || !newRange)
             return;
@@ -348,9 +331,6 @@
         this.dispatchEventToListeners(WebInspector.SourceFrame.Events.Loaded);
 
         this._textViewer.endUpdates();
-
-        if (this._parentElement)
-            this.show(this._parentElement)
     },
 
     _setTextViewerDecorations: function()
@@ -380,7 +360,7 @@
 
             var regex = WebInspector.SourceFrame.createSearchRegex(query);
             this._searchResults = this._collectRegexMatches(regex);
-            
+
             callback(this, this._searchResults.length);
         }
 
@@ -613,7 +593,7 @@
         this._textViewer.endUpdates();
     },
 
-    populateLineGutterContextMenu: function(lineNumber, contextMenu)
+    _populateLineGutterContextMenu: function(lineNumber, contextMenu)
     {
         contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Continue to here" : "Continue to Here"), this._delegate.continueToLine.bind(this._delegate, lineNumber));
 
@@ -658,11 +638,11 @@
         }
     },
 
-    populateTextAreaContextMenu: function(contextMenu)
+    _populateTextAreaContextMenu: function(contextMenu)
     {
     },
 
-    suggestedFileName: function()
+    _suggestedFileName: function()
     {
         return this._delegate.suggestedFileName();
     },
@@ -892,7 +872,7 @@
         this._textViewer.resize();
     },
 
-    doubleClick: function(lineNumber)
+    _doubleClick: function(lineNumber)
     {
         if (!this._delegate.canEditScriptSource())
             return;
@@ -903,7 +883,7 @@
         this._setReadOnly(false);
     },
 
-    commitEditing: function()
+    _commitEditing: function()
     {
         if (!this._viewerState) {
             // No editing was actually done.
@@ -951,7 +931,7 @@
         this._delegate.setScriptSource(newContent, callback);
     },
 
-    cancelEditing: function()
+    _cancelEditing: function()
     {
         this._restoreViewerState();
         this._setReadOnly(true);
@@ -966,9 +946,59 @@
     }
 }
 
-WebInspector.SourceFrame.prototype.__proto__ = WebInspector.TextViewerDelegate.prototype;
+WebInspector.SourceFrame.prototype.__proto__ = WebInspector.View.prototype;
 
 
+WebInspector.TextViewerDelegateForSourceFrame = function(sourceFrame)
+{
+    this._sourceFrame = sourceFrame;
+}
+
+WebInspector.TextViewerDelegateForSourceFrame.prototype = {
+    doubleClick: function(lineNumber)
+    {
+        this._sourceFrame._doubleClick(lineNumber);
+    },
+
+    beforeTextChanged: function()
+    {
+        this._sourceFrame._beforeTextChanged();
+    },
+
+    afterTextChanged: function(oldRange, newRange)
+    {
+        this._sourceFrame._afterTextChanged(oldRange, newRange);
+    },
+
+    commitEditing: function()
+    {
+        this._sourceFrame._commitEditing();
+    },
+
+    cancelEditing: function()
+    {
+        this._sourceFrame._cancelEditing();
+    },
+
+    populateLineGutterContextMenu: function(lineNumber, contextMenu)
+    {
+        this._sourceFrame._populateLineGutterContextMenu(lineNumber, contextMenu);
+    },
+
+    populateTextAreaContextMenu: function(contextMenu)
+    {
+        this._sourceFrame._populateTextAreaContextMenu(contextMenu);
+    },
+
+    suggestedFileName: function()
+    {
+        return this._sourceFrame._suggestedFileName();
+    }
+};
+
+WebInspector.TextViewerDelegateForSourceFrame.prototype.__proto__ = WebInspector.TextViewerDelegate.prototype;
+
+
 WebInspector.SourceFrameDelegate = function()
 {
 }

Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (90742 => 90743)


--- trunk/Source/WebCore/inspector/front-end/TextViewer.js	2011-07-11 14:03:44 UTC (rev 90742)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js	2011-07-11 14:08:57 UTC (rev 90743)
@@ -357,7 +357,7 @@
         // Should be implemented by subclasses.
     },
 
-    populateLineGutterContextMenu: function(contextMenu)
+    populateLineGutterContextMenu: function(lineNumber, contextMenu)
     {
         // Should be implemented by subclasses.
     },
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to