Diff
Modified: trunk/Source/WebCore/ChangeLog (103706 => 103707)
--- trunk/Source/WebCore/ChangeLog 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/ChangeLog 2011-12-27 10:26:18 UTC (rev 103707)
@@ -1,3 +1,41 @@
+2011-12-26 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Create tabbed editor for scripts panel.
+ https://bugs.webkit.org/show_bug.cgi?id=75230
+
+ Reviewed by Pavel Feldman.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/compile-front-end.sh:
+ * inspector/front-end/ScriptsNavigator.js:
+ (WebInspector.ScriptsNavigator.prototype.replaceUISourceCodes.get if):
+ (WebInspector.ScriptsNavigator.prototype.replaceUISourceCodes):
+ (WebInspector.NavigatorScriptTreeElement.prototype.ondblclick):
+ (WebInspector.NavigatorScriptTreeElement.prototype.onenter):
+ * inspector/front-end/ScriptsPanel.js:
+ * inspector/front-end/TabbedEditorContainer.js: Added.
+ * inspector/front-end/TabbedPane.js:
+ (WebInspector.TabbedPane.prototype.get visibleView):
+ (WebInspector.TabbedPane.prototype.get selectedTabId):
+ (WebInspector.TabbedPane.prototype.closeAllTabs):
+ (WebInspector.TabbedPane.prototype.changeTabTitle):
+ (WebInspector.TabbedPane.prototype.changeTabView):
+ (WebInspector.TabbedPaneTab):
+ (WebInspector.TabbedPaneTab.prototype.get title):
+ (WebInspector.TabbedPaneTab.prototype.set title):
+ (WebInspector.TabbedPaneTab.prototype.get view):
+ (WebInspector.TabbedPaneTab.prototype.set view):
+ (WebInspector.TabbedPaneTab.prototype._createTabElement):
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+ * inspector/front-end/scriptsPanel.css:
+ (.scripts-views-container):
+ (.script-view):
+ (#scripts-editor-container-tabbed-pane .tabbed-pane-header):
+ (#scripts-editor-container-tabbed-pane .tabbed-pane-header-contents):
+ (#scripts-editor-container-tabbed-pane .tabbed-pane-content):
+
2011-12-27 Pavel Feldman <[email protected]>
Not reviewed: Rolling out r103703 for breaking Canvas2DLayerChromiumTest.testFullLifecycle.
Modified: trunk/Source/WebCore/WebCore.gypi (103706 => 103707)
--- trunk/Source/WebCore/WebCore.gypi 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/WebCore.gypi 2011-12-27 10:26:18 UTC (rev 103707)
@@ -6491,6 +6491,7 @@
'inspector/front-end/SplitView.js',
'inspector/front-end/StatusBarButton.js',
'inspector/front-end/StylesSidebarPane.js',
+ 'inspector/front-end/TabbedEditorContainer.js',
'inspector/front-end/TabbedPane.js',
'inspector/front-end/TestController.js',
'inspector/front-end/TextEditorHighlighter.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (103706 => 103707)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-12-27 10:26:18 UTC (rev 103707)
@@ -72029,6 +72029,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\TabbedEditorContainer.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\tabbedPane.css"
>
</File>
Modified: trunk/Source/WebCore/inspector/compile-front-end.sh (103706 => 103707)
--- trunk/Source/WebCore/inspector/compile-front-end.sh 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/compile-front-end.sh 2011-12-27 10:26:18 UTC (rev 103707)
@@ -151,10 +151,11 @@
--js Source/WebCore/inspector/front-end/DatabaseTableView.js \
--js Source/WebCore/inspector/front-end/DOMStorageItemsView.js \
--js Source/WebCore/inspector/front-end/ResourcesPanel.js \
- --module jsmodule_scripts:9:jsmodule_components \
+ --module jsmodule_scripts:10:jsmodule_components \
--js Source/WebCore/inspector/front-end/CallStackSidebarPane.js \
--js Source/WebCore/inspector/front-end/ScopeChainSidebarPane.js \
--js Source/WebCore/inspector/front-end/_javascript_SourceFrame.js \
+ --js Source/WebCore/inspector/front-end/TabbedEditorContainer.js \
--js Source/WebCore/inspector/front-end/ScriptsNavigator.js \
--js Source/WebCore/inspector/front-end/ScriptsPanel.js \
--js Source/WebCore/inspector/front-end/ScriptsSearchScope.js \
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js (103706 => 103707)
--- trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js 2011-12-27 10:26:18 UTC (rev 103707)
@@ -135,7 +135,11 @@
*/
setScriptSourceIsDirty: function(uiSourceCode, isDirty)
{
- // FIXME: implement
+ var scriptTreeElement = this._scriptTreeElementsByUISourceCode.get(uiSourceCode);
+ var title = uiSourceCode.displayName;
+ if (isDirty)
+ title += "*";
+ scriptTreeElement.titleText = title;
},
/**
@@ -144,7 +148,22 @@
*/
replaceUISourceCodes: function(oldUISourceCodeList, uiSourceCodeList)
{
- // FIXME: implement
+ var selected = false;
+ for (var i = 0; i < oldUISourceCodeList.length; ++i) {
+ var uiSourceCode = oldUISourceCodeList[i];
+ var treeElement = this._scriptTreeElementsByUISourceCode.get(uiSourceCode);
+ if (treeElement) {
+ if (this._lastSelectedUISourceCode && this._lastSelectedUISourceCode === uiSourceCode)
+ selected = true;
+ this.removeUISourceCode(uiSourceCode);
+ }
+ }
+
+ for (var i = 0; i < uiSourceCodeList.length; ++i)
+ this.addUISourceCode(uiSourceCodeList[i]);
+
+ if (selected)
+ this.revealUISourceCode(uiSourceCodeList[0]);
},
/**
@@ -436,13 +455,16 @@
},
/**
- * @param {TreeElement} treeElement
- * @param {boolean=} selectedByUser
+ * @param {Event} event
*/
- onselect: function(treeElement, selectedByUser)
+ ondblclick: function(event)
{
- if (selectedByUser)
- this._navigator.scriptSelected(this.uiSourceCode);
+ this._navigator.scriptSelected(this.uiSourceCode);
+ },
+
+ onenter: function()
+ {
+ this._navigator.scriptSelected(this.uiSourceCode);
}
}
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (103706 => 103707)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-12-27 10:26:18 UTC (rev 103707)
@@ -78,8 +78,7 @@
this.editorView.installResizer(this._navigatorResizeWidgetElement);
this.editorView.sidebarElement.appendChild(this._navigatorResizeWidgetElement);
- // FIXME: We should use new TabbedEditor here.
- this._editorContainer = new WebInspector.ScriptsPanel.SingleFileEditorContainer();
+ this._editorContainer = new WebInspector.TabbedEditorContainer();
this._editorContainer.show(this.editorView.mainElement);
} else {
this._fileSelector = new WebInspector.ScriptsPanel.ComboBoxFileSelector(this._presentationModel);
@@ -87,7 +86,7 @@
this._fileSelector.addEventListener(WebInspector.ScriptsPanel.FileSelector.Events.ScriptSelected, this._scriptSelected, this);
this._fileSelector.addEventListener(WebInspector.ScriptsPanel.FileSelector.Events.ReleasedFocusAfterSelection, this._fileSelectorReleasedFocus, this);
this._fileSelector.show(this.splitView.mainElement);
-
+
this._editorContainer = new WebInspector.ScriptsPanel.SingleFileEditorContainer();
this._editorContainer.show(this.splitView.mainElement);
}
@@ -281,6 +280,9 @@
setScriptSourceIsBeingEdited: function(uiSourceCode, inEditMode)
{
this._fileSelector.setScriptSourceIsDirty(uiSourceCode, inEditMode);
+ var sourceFrame = this._sourceFramesByUISourceCode.get(uiSourceCode)
+ if (sourceFrame)
+ this._editorContainer.setSourceFrameIsDirty(sourceFrame, inEditMode);
},
_consoleMessagesCleared: function()
Added: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (0 => 103707)
--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js 2011-12-27 10:26:18 UTC (rev 103707)
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+/**
+ * @implements {WebInspector.ScriptsPanel.EditorContainer}
+ * @constructor
+ */
+WebInspector.TabbedEditorContainer = function()
+{
+ this._tabbedPane = new WebInspector.TabbedPane();
+ this._tabbedPane.closeableTabs = true;
+ this._tabbedPane.element.id = "scripts-editor-container-tabbed-pane";
+
+ this._titles = new Map();
+ this._tabIds = new Map();
+}
+
+WebInspector.TabbedEditorContainer._tabId = 0;
+
+WebInspector.TabbedEditorContainer.prototype = {
+ /**
+ * @type {WebInspector.SourceFrame}
+ */
+ get currentSourceFrame()
+ {
+ return this._tabbedPane.visibleView;
+ },
+
+ /**
+ * @param {Element} parentElement
+ */
+ show: function(parentElement)
+ {
+ this._tabbedPane.show(parentElement);
+ },
+
+ /**
+ * @param {string} title
+ * @param {WebInspector.SourceFrame} sourceFrame
+ */
+ showSourceFrame: function(title, sourceFrame)
+ {
+ var tabId = this._tabIds.get(sourceFrame) || this._appendSourceFrameTab(title, sourceFrame);
+ this._tabbedPane.selectTab(tabId);
+ },
+
+ /**
+ * @param {string} title
+ * @param {WebInspector.SourceFrame} sourceFrame
+ */
+ _appendSourceFrameTab: function(title, sourceFrame)
+ {
+ var tabId = this._generateTabId();
+ this._tabIds.put(sourceFrame, tabId)
+ this._titles.put(sourceFrame, title)
+
+ this._tabbedPane.appendTab(tabId, title, sourceFrame);
+ return tabId;
+ },
+
+ /**
+ * @param {WebInspector.SourceFrame} sourceFrame
+ */
+ _removeSourceFrameTab: function(sourceFrame)
+ {
+ var tabId = this._tabIds.get(sourceFrame);
+
+ if (tabId) {
+ this._tabbedPane.closeTab(tabId);
+ this._tabIds.remove(sourceFrame);
+ this._titles.remove(sourceFrame);
+ }
+ },
+
+ /**
+ * @param {string} title
+ * @param {WebInspector.SourceFrame} sourceFrame
+ */
+ _replaceSourceFrameTab: function(oldSourceFrame, title, sourceFrame)
+ {
+ var tabId = this._tabIds.get(oldSourceFrame);
+
+ if (tabId) {
+ this._tabIds.remove(oldSourceFrame);
+ this._titles.remove(oldSourceFrame);
+
+ this._tabIds.put(sourceFrame, tabId);
+ this._titles.put(sourceFrame, title);
+
+ this._tabbedPane.changeTabTitle(tabId, title);
+ this._tabbedPane.changeTabView(tabId, sourceFrame);
+ }
+ },
+
+ /**
+ * @param {WebInspector.SourceFrame} sourceFrame
+ * @return {boolean}
+ */
+ isSourceFrameOpen: function(sourceFrame)
+ {
+ return !!this._tabIds.get(sourceFrame);
+ },
+
+ /**
+ * @param {Array.<WebInspector.SourceFrame>} oldSourceFrames
+ * @param {string} title
+ * @param {WebInspector.SourceFrame} sourceFrame
+ */
+ replaceSourceFrames: function(oldSourceFrames, title, sourceFrame)
+ {
+ var mainSourceFrame;
+ for (var i = 0; i < oldSourceFrames.length; ++i) {
+ var tabId = this._tabIds.get(oldSourceFrames[i]);
+ if (tabId && (!mainSourceFrame || this._tabbedPane.selectedTabId === tabId)) {
+ mainSourceFrame = oldSourceFrames[i];
+ break;
+ }
+ }
+
+ if (mainSourceFrame)
+ this._replaceSourceFrameTab(mainSourceFrame, title, sourceFrame);
+
+ for (var i = 0; i < oldSourceFrames.length; ++i)
+ this._removeSourceFrameTab(oldSourceFrames[i]);
+ },
+
+ /**
+ * @param {WebInspector.SourceFrame} sourceFrame
+ * @param {boolean} isDirty
+ */
+ setSourceFrameIsDirty: function(sourceFrame, isDirty)
+ {
+ var tabId = this._tabIds.get(sourceFrame);
+ if (tabId) {
+ var title = this._titles.get(sourceFrame);
+ if (isDirty)
+ title += "*";
+ this._tabbedPane.changeTabTitle(tabId, title);
+ }
+ },
+
+ reset: function()
+ {
+ this._tabbedPane.closeAllTabs();
+ this._titles = new Map();
+ this._tabIds = new Map();
+ },
+
+ /**
+ * @return {string}
+ */
+ _generateTabId: function()
+ {
+ return "tab_" + (WebInspector.TabbedEditorContainer._tabId++);
+ }
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/TabbedPane.js (103706 => 103707)
--- trunk/Source/WebCore/inspector/front-end/TabbedPane.js 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/front-end/TabbedPane.js 2011-12-27 10:26:18 UTC (rev 103707)
@@ -50,6 +50,22 @@
WebInspector.TabbedPane.prototype = {
/**
+ * @type {WebInspector.View}
+ */
+ get visibleView()
+ {
+ return this._currentTab ? this._currentTab.view : null;
+ },
+
+ /**
+ * @type {string}
+ */
+ get selectedTabId()
+ {
+ return this._currentTab ? this._currentTab.id : null;
+ },
+
+ /**
* @type {boolean} shrinkableTabs
*/
set shrinkableTabs(shrinkableTabs)
@@ -105,6 +121,12 @@
return true;
},
+ closeAllTabs: function()
+ {
+ for (var i = 0; i < this._tabs.length; ++i)
+ this.closeTab(this._tabs[i].id, false);
+ },
+
/**
* @param {string} id
* @param {boolean=} userGesture
@@ -131,6 +153,32 @@
return true;
},
+ /**
+ * @param {string} id
+ * @param {string} tabTitle
+ */
+ changeTabTitle: function(id, tabTitle)
+ {
+ var tab = this._tabsById[id];
+ tab.title = tabTitle;
+ this._updateTabElements();
+ },
+
+ /**
+ * @param {string} id
+ * @param {WebInspector.View} view
+ */
+ changeTabView: function(id, view)
+ {
+ var tab = this._tabsById[id];
+ if (this._currentTab && this._currentTab.id === tab.id) {
+ this._hideTab(tab);
+ tab.view = view;
+ this._showTab(tab);
+ } else
+ tab.view = view;
+ },
+
onResize: function()
{
this._updateTabElements();
@@ -372,8 +420,8 @@
this._tabbedPane = tabbedPane;
this._measureElement = measureElement;
this._id = id;
- this.title = title;
- this.view = view;
+ this._title = title;
+ this._view = view;
this.shown = false;
}
@@ -387,6 +435,35 @@
},
/**
+ * @type {string}
+ */
+ get title()
+ {
+ return this._title;
+ },
+
+ set title(title)
+ {
+ this._title = title;
+ if (this._titleElement)
+ this._titleElement.textContent = title;
+ delete this._measuredWidth;
+ },
+
+ /**
+ * @type {WebInspector.View}
+ */
+ get view()
+ {
+ return this._view;
+ },
+
+ set view(view)
+ {
+ this._view = view;
+ },
+
+ /**
* @type {Element}
*/
get tabElement()
@@ -432,8 +509,10 @@
var tabElement = document.createElement("div");
tabElement.addStyleClass("tabbed-pane-header-tab");
- var tabTitleElement = tabElement.createChild("span", "tabbed-pane-header-tab-title");
- tabTitleElement.textContent = this.title;
+ var titleElement = tabElement.createChild("span", "tabbed-pane-header-tab-title");
+ titleElement.textContent = this.title;
+ if (!measuring)
+ this._titleElement = titleElement;
if (this._closeable) {
var closeButtonSpan = tabElement.createChild("span", "tabbed-pane-header-tab-close-button");
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (103706 => 103707)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-12-27 10:26:18 UTC (rev 103707)
@@ -132,6 +132,7 @@
<file>SplitView.js</file>
<file>StatusBarButton.js</file>
<file>StylesSidebarPane.js</file>
+ <file>TabbedEditorContainer.js</file>
<file>TabbedPane.js</file>
<file>TestController.js</file>
<file>TextEditorHighlighter.js</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (103706 => 103707)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2011-12-27 10:26:18 UTC (rev 103707)
@@ -116,6 +116,7 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
Modified: trunk/Source/WebCore/inspector/front-end/scriptsPanel.css (103706 => 103707)
--- trunk/Source/WebCore/inspector/front-end/scriptsPanel.css 2011-12-27 10:21:51 UTC (rev 103706)
+++ trunk/Source/WebCore/inspector/front-end/scriptsPanel.css 2011-12-27 10:26:18 UTC (rev 103707)
@@ -153,16 +153,19 @@
background-position: center;
}
-.script-view {
- display: none;
- overflow: hidden;
+.scripts-views-container {
position: absolute;
top: 23px;
- left: 0;
right: 0;
bottom: 0;
+ left: 0;
}
+.script-view {
+ display: none;
+ overflow: hidden;
+}
+
.script-view.visible {
display: block;
}
@@ -211,6 +214,19 @@
margin-top: 1px;
}
+#scripts-editor-container-tabbed-pane .tabbed-pane-header {
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#F5F5F5), to(#E5E5E5));
+}
+
+#scripts-editor-container-tabbed-pane .tabbed-pane-header-contents {
+ margin-left: 1px;
+ margin-right: 16px;
+}
+
+#scripts-editor-container-tabbed-pane .tabbed-pane-content {
+ margin-top: 1px;
+}
+
.scripts.panel .navigator li {
height: 17px;
white-space: nowrap;