Commit 913b8e0d authored by timothy@apple.com's avatar timothy@apple.com

<rdar://problem/5956403> Update the Develop menu to match the new Inspector items


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34027 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9bcbb033
2008-05-22 Timothy Hatcher <timothy@apple.com>
<rdar://problem/5956403> Update the Develop menu to match the new Inspector items
Reviewed by Adam Roben.
* English.lproj/localizedStrings.js:
* WebCore.base.exp:
* page/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::inspect):
(WebCore::InspectorController::setWindowVisible):
(WebCore::InspectorController::showPanel):
(WebCore::InspectorController::startUserInitiatedProfiling):
(WebCore::InspectorController::stopUserInitiatedProfiling):
(WebCore::InspectorController::startDebuggingAndReloadInspectedPage):
(WebCore::InspectorController::stopDebugging):
* page/InspectorController.h:
(WebCore::InspectorController::):
(WebCore::InspectorController::isRecordingUserInitiatedProfile):
* page/inspector/ProfilesPanel.js:
* page/inspector/ScriptsPanel.js:
* page/inspector/inspector.js:
2008-05-22 Josh Aas <joshmoz@gmail.com>
Reviewed by Anders.
Bvar localizedStrings = new Object;
......
This diff is collapsed.
......@@ -84,6 +84,8 @@ using namespace std;
namespace WebCore {
static const char* const UserInitiatedProfileName = "org.webkit.profiles.user-initiated";
static JSRetainPtr<JSStringRef> jsStringRef(const char* str)
{
return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString(str));
......@@ -1016,7 +1018,9 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
, m_scriptContext(0)
, m_windowVisible(false)
, m_debuggerAttached(false)
, m_showAfterVisible(FocusedNodeDocumentPanel)
, m_attachDebuggerWhenShown(false)
, m_recordingUserInitiatedProfile(false)
, m_showAfterVisible(ElementsPanel)
, m_nextIdentifier(-2)
{
ASSERT_ARG(page, page);
......@@ -1095,7 +1099,7 @@ void InspectorController::inspect(Node* node)
m_nodeToFocus = node;
if (!m_scriptObject) {
m_showAfterVisible = FocusedNodeDocumentPanel;
m_showAfterVisible = ElementsPanel;
return;
}
......@@ -1166,14 +1170,12 @@ void InspectorController::setWindowVisible(bool visible)
populateScriptObjects();
if (m_nodeToFocus)
focusNode();
if (m_showAfterVisible == ConsolePanel)
showConsole();
else if (m_showAfterVisible == TimelinePanel)
showTimeline();
if (m_attachDebuggerWhenShown)
startDebuggingAndReloadInspectedPage();
if (m_showAfterVisible != CurrentPanel)
showPanel(m_showAfterVisible);
} else
resetScriptObjects();
m_showAfterVisible = FocusedNodeDocumentPanel;
}
void InspectorController::addMessageToConsole(MessageSource source, MessageLevel level, ExecState* exec, const List& arguments, unsigned lineNumber, const String& sourceURL)
......@@ -1338,7 +1340,7 @@ void InspectorController::show()
showWindow();
}
void InspectorController::showConsole()
void InspectorController::showPanel(SpecialPanels panel)
{
if (!enabled())
return;
......@@ -1346,26 +1348,40 @@ void InspectorController::showConsole()
show();
if (!m_scriptObject) {
m_showAfterVisible = ConsolePanel;
m_showAfterVisible = panel;
return;
}
callSimpleFunction(m_scriptContext, m_scriptObject, "showConsole");
}
void InspectorController::showTimeline()
{
if (!enabled())
if (panel == CurrentPanel)
return;
show();
if (!m_scriptObject) {
m_showAfterVisible = TimelinePanel;
return;
const char* showFunctionName;
switch (panel) {
case ConsolePanel:
showFunctionName = "showConsole";
break;
case DatabasesPanel:
showFunctionName = "showDatabasesPanel";
break;
case ElementsPanel:
showFunctionName = "showElementsPanel";
break;
case ProfilesPanel:
showFunctionName = "showProfilesPanel";
break;
case ResourcesPanel:
showFunctionName = "showResourcesPanel";
break;
case ScriptsPanel:
showFunctionName = "showScriptsPanel";
break;
default:
ASSERT_NOT_REACHED();
showFunctionName = 0;
}
callSimpleFunction(m_scriptContext, m_scriptObject, "showTimeline");
if (showFunctionName)
callSimpleFunction(m_scriptContext, m_scriptObject, showFunctionName);
}
void InspectorController::close()
......@@ -1395,6 +1411,28 @@ void InspectorController::closeWindow()
m_client->closeWindow();
}
void InspectorController::startUserInitiatedProfiling()
{
if (!enabled())
return;
m_recordingUserInitiatedProfile = true;
ExecState* exec = toJSDOMWindow(m_inspectedPage->mainFrame())->globalExec();
Profiler::profiler()->startProfiling(exec, UserInitiatedProfileName);
}
void InspectorController::stopUserInitiatedProfiling()
{
if (!enabled())
return;
m_recordingUserInitiatedProfile = false;
ExecState* exec = toJSDOMWindow(m_inspectedPage->mainFrame())->globalExec();
Profiler::profiler()->stopProfiling(exec, UserInitiatedProfileName);
}
static void addHeaders(JSContextRef context, JSObjectRef object, const HTTPHeaderMap& headers, JSValueRef* exception)
{
ASSERT_ARG(context, context);
......@@ -2150,20 +2188,39 @@ void InspectorController::moveWindowBy(float x, float y) const
void InspectorController::startDebuggingAndReloadInspectedPage()
{
if (!enabled())
return;
if (!m_scriptContext || !m_scriptObject) {
m_attachDebuggerWhenShown = true;
return;
}
ASSERT(m_inspectedPage);
JavaScriptDebugServer::shared().addListener(this, m_inspectedPage);
m_debuggerAttached = true;
JavaScriptDebugServer::shared().clearBreakpoints();
m_debuggerAttached = true;
m_attachDebuggerWhenShown = false;
callSimpleFunction(m_scriptContext, m_scriptObject, "debuggerAttached");
m_inspectedPage->mainFrame()->loader()->reload();
}
void InspectorController::stopDebugging()
{
if (!enabled())
return;
ASSERT(m_inspectedPage);
JavaScriptDebugServer::shared().removeListener(this, m_inspectedPage);
m_debuggerAttached = false;
if (m_scriptContext && m_scriptObject)
callSimpleFunction(m_scriptContext, m_scriptObject, "debuggerDetached");
}
JavaScriptCallFrame* InspectorController::currentCallFrame() const
......
......@@ -67,9 +67,13 @@ public:
typedef HashSet<RefPtr<InspectorDatabaseResource> > DatabaseResourcesSet;
typedef enum {
FocusedNodeDocumentPanel,
CurrentPanel,
ConsolePanel,
TimelinePanel
DatabasesPanel,
ElementsPanel,
ProfilesPanel,
ResourcesPanel,
ScriptsPanel
} SpecialPanels;
InspectorController(Page*, InspectorClient*);
......@@ -89,10 +93,13 @@ public:
void hideHighlight();
void show();
void showConsole();
void showTimeline();
void showPanel(SpecialPanels);
void close();
bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; }
void startUserInitiatedProfiling();
void stopUserInitiatedProfiling();
bool windowVisible();
void setWindowVisible(bool visible = true);
......@@ -214,6 +221,8 @@ private:
JSContextRef m_scriptContext;
bool m_windowVisible;
bool m_debuggerAttached;
bool m_attachDebuggerWhenShown;
bool m_recordingUserInitiatedProfile;
SpecialPanels m_showAfterVisible;
long long m_nextIdentifier;
RefPtr<Node> m_highlightedNode;
......
......@@ -65,23 +65,16 @@ WebInspector.ProfilesPanel.prototype = {
WebInspector.Panel.prototype.show.call(this);
this._updateSidebarWidth();
if (this._populateProfiles) {
var profiles = InspectorController.profiles();
var profilesLength = profiles.length;
for (var i = 0; i < profilesLength; ++i) {
var profile = profiles[i];
this.addProfile(profile);
}
if (this.sidebarTree.children[0])
this.sidebarTree.children[0].select();
delete this._populateProfiles;
if (this._shouldPopulateProfiles) {
this._populateProfiles();
delete this._shouldPopulateProfiles;
}
},
reset: function()
{
this.nextUserInitiatedProfileNumber = 1;
if (this._profiles) {
var profiledLength = this._profiles.length;
for (var i = 0; i < profiledLength; ++i) {
......@@ -95,7 +88,10 @@ WebInspector.ProfilesPanel.prototype = {
this.sidebarTree.removeChildren();
this.profileViews.removeChildren();
this._populateProfiles = true;
if (this.visible)
this._populateProfiles();
else
this._shouldPopulateProfiles = true;
},
handleKeyEvent: function(event)
......@@ -139,6 +135,21 @@ WebInspector.ProfilesPanel.prototype = {
delete this.visibleProfileView;
},
_populateProfiles: function()
{
this.sidebarTree.removeChildren();
var profiles = InspectorController.profiles();
var profilesLength = profiles.length;
for (var i = 0; i < profilesLength; ++i) {
var profile = profiles[i];
this.addProfile(profile);
}
if (this.sidebarTree.children[0])
this.sidebarTree.children[0].select();
},
_startSidebarDragging: function(event)
{
WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDragging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize");
......@@ -186,6 +197,9 @@ WebInspector.ProfileSidebarTreeElement = function(profile)
{
this.profile = profile;
if (this.profile.title === "org.webkit.profiles.user-initiated")
this._profileNumber = WebInspector.panels.profiles.nextUserInitiatedProfileNumber++;
WebInspector.SidebarTreeElement.call(this, "profile-sidebar-tree-item", "", "", profile, false);
this.refreshTitles();
......@@ -199,6 +213,8 @@ WebInspector.ProfileSidebarTreeElement.prototype = {
get mainTitle()
{
if (this.profile.title === "org.webkit.profiles.user-initiated")
return WebInspector.UIString("Profile %d", this._profileNumber);
return this.profile.title;
},
......
......@@ -304,6 +304,16 @@ WebInspector.ScriptsPanel.prototype = {
callStackPane.selectedCallFrame = currentFrame;
},
debuggerAttached: function()
{
this.reset();
},
debuggerDetached: function()
{
this.reset();
},
reset: function()
{
this.visibleView = null;
......@@ -540,10 +550,15 @@ WebInspector.ScriptsPanel.prototype = {
this.debuggingButton.title = WebInspector.UIString("Stop debugging.");
this.debuggingButton.addStyleClass("toggled-on");
this.pauseButton.disabled = false;
if (this.attachOverlayElement.parentNode)
this.attachOverlayElement.parentNode.removeChild(this.attachOverlayElement);
} else {
this.debuggingButton.title = WebInspector.UIString("Start debugging and reload inspected page.");
this.debuggingButton.removeStyleClass("toggled-on");
this.pauseButton.disabled = true;
this.element.appendChild(this.attachOverlayElement);
}
this._updatePauseOnExceptionsButton();
......@@ -589,13 +604,10 @@ WebInspector.ScriptsPanel.prototype = {
this._waitingToPause = false;
this._stepping = false;
if (InspectorController.debuggerAttached()) {
this.element.appendChild(this.attachOverlayElement);
if (InspectorController.debuggerAttached())
InspectorController.stopDebugging();
} else {
this.attachOverlayElement.parentNode.removeChild(this.attachOverlayElement);
else
InspectorController.startDebuggingAndReloadInspectedPage();
}
this._clearInterface();
},
......
......@@ -692,11 +692,31 @@ WebInspector.showConsole = function()
this.console.show();
}
WebInspector.showTimeline = function()
WebInspector.showElementsPanel = function()
{
this.currentPanel = this.panels.elements;
}
WebInspector.showResourcesPanel = function()
{
this.currentPanel = this.panels.resources;
}
WebInspector.showScriptsPanel = function()
{
this.currentPanel = this.panels.scripts;
}
WebInspector.showProfilesPanel = function()
{
this.currentPanel = this.panels.profiles;
}
WebInspector.showDatabasesPanel = function()
{
this.currentPanel = this.panels.databases;
}
WebInspector.addResource = function(resource)
{
this.resources.push(resource);
......@@ -731,6 +751,16 @@ WebInspector.addDatabase = function(database)
this.panels.databases.addDatabase(database);
}
WebInspector.debuggerAttached = function()
{
this.panels.scripts.debuggerAttached();
}
WebInspector.debuggerDetached = function()
{
this.panels.scripts.debuggerDetached();
}
WebInspector.parsedScriptSource = function(sourceID, sourceURL, source, startingLine)
{
this.panels.scripts.addScript(sourceID, sourceURL, source, startingLine);
......
2008-05-22 Timothy Hatcher <timothy@apple.com>
<rdar://problem/5956403> Update the Develop menu to match the new Inspector items
Reviewed by Adam Roben.
* English.lproj/Localizable.strings: Added new strings.
2008-05-21 Anders Carlsson <andersca@apple.com>
Reviewed by Maciej.
......
B/* window title for a standalone image (uses multiplication symbol, not x) */
......
2008-05-22 Timothy Hatcher <timothy@apple.com>
<rdar://problem/5956403> Update the Develop menu to match the new Inspector items
Reviewed by Adam Roben.
* WebCoreSupport/WebInspectorClient.mm:
(-[WebInspectorWindowController showWebInspector:]):
(-[WebInspectorWindowController showErrorConsole:]):
(-[WebInspectorWindowController toggleDebuggingJavaScript:]):
(-[WebInspectorWindowController toggleProfilingJavaScript:]):
(-[WebInspectorWindowController validateUserInterfaceItem:]):
* WebInspector/WebInspector.h:
* WebInspector/WebInspector.mm:
(-[WebInspector showConsole:]):
(-[WebInspector showTimeline:]):
(-[WebInspector isDebuggingJavaScript]):
(-[WebInspector toggleDebuggingJavaScript:]):
(-[WebInspector startDebuggingJavaScript:]):
(-[WebInspector stopDebuggingJavaScript:]):
(-[WebInspector isProfilingJavaScript]):
(-[WebInspector toggleProfilingJavaScript:]):
(-[WebInspector startProfilingJavaScript:]):
(-[WebInspector stopProfilingJavaScript:]):
2008-05-22 Josh Aas <joshmoz@gmail.com>
Reviewed by Anders.
......
......@@ -30,6 +30,7 @@
#import "WebFrameInternal.h"
#import "WebFrameView.h"
#import "WebInspector.h"
#import "WebLocalizableStrings.h"
#import "WebNodeHighlight.h"
#import "WebPreferences.h"
......@@ -509,17 +510,42 @@ void WebInspectorClient::updateWindowTitle() const
// This method is really only implemented to keep any UI elements enabled.
- (void)showWebInspector:(id)sender
{
[_inspectedWebView page]->inspectorController()->show();
[[_inspectedWebView inspector] show:sender];
}
- (void)showErrorConsole:(id)sender
{
[_inspectedWebView page]->inspectorController()->showConsole();
[[_inspectedWebView inspector] showConsole:sender];
}
- (void)showNetworkTimeline:(id)sender
- (void)toggleDebuggingJavaScript:(id)sender
{
[_inspectedWebView page]->inspectorController()->showTimeline();
[[_inspectedWebView inspector] toggleDebuggingJavaScript:sender];
}
- (void)toggleProfilingJavaScript:(id)sender
{
[[_inspectedWebView inspector] toggleProfilingJavaScript:sender];
}
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
{
BOOL isMenuItem = [(id)item isKindOfClass:[NSMenuItem class]];
if ([item action] == @selector(toggleDebuggingJavaScript:) && isMenuItem) {
NSMenuItem *menuItem = (NSMenuItem *)item;
if ([[_inspectedWebView inspector] isDebuggingJavaScript])
[menuItem setTitle:UI_STRING("Stop Debugging JavaScript", "title for Stop Debugging JavaScript menu item")];
else
[menuItem setTitle:UI_STRING("Start Debugging JavaScript", "title for Start Debugging JavaScript menu item")];
} else if ([item action] == @selector(toggleProfilingJavaScript:) && isMenuItem) {
NSMenuItem *menuItem = (NSMenuItem *)item;
if ([[_inspectedWebView inspector] isProfilingJavaScript])
[menuItem setTitle:UI_STRING("Stop Profiling JavaScript", "title for Stop Profiling JavaScript menu item")];
else
[menuItem setTitle:UI_STRING("Start Profiling JavaScript", "title for Start Profiling JavaScript menu item")];
}
return YES;
}
@end
......@@ -38,8 +38,17 @@
- (void)webViewClosed;
- (void)show:(id)sender;
- (void)showConsole:(id)sender;
- (void)showTimeline:(id)sender;
- (void)close:(id)sender;
- (void)attach:(id)sender;
- (void)detach:(id)sender;
- (BOOL)isDebuggingJavaScript;
- (void)toggleDebuggingJavaScript:(id)sender;
- (void)startDebuggingJavaScript:(id)sender;
- (void)stopDebuggingJavaScript:(id)sender;
- (BOOL)isProfilingJavaScript;
- (void)toggleProfilingJavaScript:(id)sender;
- (void)startProfilingJavaScript:(id)sender;
- (void)stopProfilingJavaScript:(id)sender;
@end
......@@ -60,13 +60,72 @@ using namespace WebCore;
- (void)showConsole:(id)sender
{
if (Page* page = core(_webView))
page->inspectorController()->showConsole();
page->inspectorController()->showPanel(InspectorController::ConsolePanel);
}
- (void)showTimeline:(id)sender
{
// Not used anymore. Remove when a release of Safari non-longer calls this.
}
- (BOOL)isDebuggingJavaScript
{
if (Page* page = core(_webView))
return page->inspectorController()->debuggerAttached();
return NO;
}
- (void)toggleDebuggingJavaScript:(id)sender
{
if ([self isDebuggingJavaScript])
[self stopDebuggingJavaScript:sender];
else
[self startDebuggingJavaScript:sender];
}
- (void)startDebuggingJavaScript:(id)sender
{
Page* page = core(_webView);
if (!page)
return;
page->inspectorController()->showPanel(InspectorController::ScriptsPanel);
page->inspectorController()->startDebuggingAndReloadInspectedPage();
}
- (void)stopDebuggingJavaScript:(id)sender
{
if (Page* page = core(_webView))
page->inspectorController()->showTimeline();
page->inspectorController()->stopDebugging();
}
- (BOOL)isProfilingJavaScript
{
if (Page* page = core(_webView))
return page->inspectorController()->isRecordingUserInitiatedProfile();
return NO;
}
- (void)toggleProfilingJavaScript:(id)sender
{
if ([self isProfilingJavaScript])
[self stopProfilingJavaScript:sender];
else
[self startProfilingJavaScript:sender];
}
- (void)startProfilingJavaScript:(id)sender
{
if (Page* page = core(_webView))
page->inspectorController()->startUserInitiatedProfiling();
}
- (void)stopProfilingJavaScript:(id)sender
{
Page* page = core(_webView);
if (!page)
return;
page->inspectorController()->stopUserInitiatedProfiling();
page->inspectorController()->showPanel(InspectorController::ProfilesPanel);
}
- (void)close:(id)sender
......
2008-05-22 Timothy Hatcher <timothy@apple.com>
Changes to keep Windows building.
<rdar://problem/5956403> Update the Develop menu to match the new Inspector items
Reviewed by Adam Roben.