diff options
Diffstat (limited to 'src/3rdparty/webkit/WebCore/inspector')
25 files changed, 1244 insertions, 284 deletions
diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp new file mode 100644 index 000000000..d50efd3e8 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.cpp @@ -0,0 +1,363 @@ +/* + * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> + * + * 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE 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 APPLE 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. + */ + +#include "config.h" +#include "InspectorBackend.h" + +#include "Element.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "HTMLFrameOwnerElement.h" +#include "InspectorClient.h" +#include "InspectorController.h" +#include "InspectorResource.h" + +#if ENABLE(JAVASCRIPT_DEBUGGER) +#include "JavaScriptCallFrame.h" +#include "JavaScriptDebugServer.h" +using namespace JSC; +#endif + +#include <wtf/RefPtr.h> +#include <wtf/StdLibExtras.h> + +using namespace std; + +namespace WebCore { + +InspectorBackend::InspectorBackend(InspectorController* inspectorController, InspectorClient* client) + : m_inspectorController(inspectorController) + , m_client(client) +{ +} + +InspectorBackend::~InspectorBackend() +{ +} + +void InspectorBackend::hideDOMNodeHighlight() +{ + if (m_inspectorController) + m_inspectorController->hideHighlight(); +} + +String InspectorBackend::localizedStringsURL() +{ + return m_client->localizedStringsURL(); +} + +String InspectorBackend::hiddenPanels() +{ + return m_client->hiddenPanels(); +} + +void InspectorBackend::windowUnloading() +{ + if (m_inspectorController) + m_inspectorController->close(); +} + +bool InspectorBackend::isWindowVisible() +{ + if (m_inspectorController) + return m_inspectorController->windowVisible(); + return false; +} + +void InspectorBackend::addResourceSourceToFrame(long identifier, Node* frame) +{ + if (!m_inspectorController) + return; + RefPtr<InspectorResource> resource = m_inspectorController->resources().get(identifier); + if (resource) { + String sourceString = resource->sourceString(); + if (!sourceString.isEmpty()) + addSourceToFrame(resource->mimeType(), sourceString, frame); + } +} + +bool InspectorBackend::addSourceToFrame(const String& mimeType, const String& source, Node* frameNode) +{ + ASSERT_ARG(frameNode, frameNode); + + if (!frameNode) + return false; + + if (!frameNode->attached()) { + ASSERT_NOT_REACHED(); + return false; + } + + ASSERT(frameNode->isElementNode()); + if (!frameNode->isElementNode()) + return false; + + Element* element = static_cast<Element*>(frameNode); + ASSERT(element->isFrameOwnerElement()); + if (!element->isFrameOwnerElement()) + return false; + + HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(element); + ASSERT(frameOwner->contentFrame()); + if (!frameOwner->contentFrame()) + return false; + + FrameLoader* loader = frameOwner->contentFrame()->loader(); + + loader->setResponseMIMEType(mimeType); + loader->begin(); + loader->write(source); + loader->end(); + + return true; +} + +void InspectorBackend::clearMessages() +{ + if (m_inspectorController) + m_inspectorController->clearConsoleMessages(); +} + +void InspectorBackend::toggleNodeSearch() +{ + if (m_inspectorController) + m_inspectorController->toggleSearchForNodeInPage(); +} + +void InspectorBackend::attach() +{ + if (m_inspectorController) + m_inspectorController->attachWindow(); +} + +void InspectorBackend::detach() +{ + if (m_inspectorController) + m_inspectorController->detachWindow(); +} + +void InspectorBackend::setAttachedWindowHeight(unsigned height) +{ + if (m_inspectorController) + m_inspectorController->setAttachedWindowHeight(height); +} + +void InspectorBackend::storeLastActivePanel(const String& panelName) +{ + if (m_inspectorController) + m_inspectorController->storeLastActivePanel(panelName); +} + +bool InspectorBackend::searchingForNode() +{ + if (m_inspectorController) + return m_inspectorController->searchingForNodeInPage(); + return false; +} + +void InspectorBackend::loaded() +{ + if (m_inspectorController) + m_inspectorController->scriptObjectReady(); +} + +void InspectorBackend::enableResourceTracking(bool always) +{ + if (m_inspectorController) + m_inspectorController->enableResourceTracking(always); +} + +void InspectorBackend::disableResourceTracking(bool always) +{ + if (m_inspectorController) + m_inspectorController->disableResourceTracking(always); +} + +bool InspectorBackend::resourceTrackingEnabled() const +{ + if (m_inspectorController) + return m_inspectorController->resourceTrackingEnabled(); + return false; +} + +void InspectorBackend::moveWindowBy(float x, float y) const +{ + if (m_inspectorController) + m_inspectorController->moveWindowBy(x, y); +} + +void InspectorBackend::closeWindow() +{ + if (m_inspectorController) + m_inspectorController->closeWindow(); +} + +const String& InspectorBackend::platform() const +{ +#if PLATFORM(MAC) +#ifdef BUILDING_ON_TIGER + DEFINE_STATIC_LOCAL(const String, platform, ("mac-tiger")); +#else + DEFINE_STATIC_LOCAL(const String, platform, ("mac-leopard")); +#endif +#elif PLATFORM(WIN_OS) + DEFINE_STATIC_LOCAL(const String, platform, ("windows")); +#elif PLATFORM(QT) + DEFINE_STATIC_LOCAL(const String, platform, ("qt")); +#elif PLATFORM(GTK) + DEFINE_STATIC_LOCAL(const String, platform, ("gtk")); +#elif PLATFORM(WX) + DEFINE_STATIC_LOCAL(const String, platform, ("wx")); +#else + DEFINE_STATIC_LOCAL(const String, platform, ("unknown")); +#endif + + return platform; +} + +#if ENABLE(JAVASCRIPT_DEBUGGER) +const ProfilesArray& InspectorBackend::profiles() const +{ + if (m_inspectorController) + return m_inspectorController->profiles(); + return m_emptyProfiles; +} + +void InspectorBackend::startProfiling() +{ + if (m_inspectorController) + m_inspectorController->startUserInitiatedProfiling(); +} + +void InspectorBackend::stopProfiling() +{ + if (m_inspectorController) + m_inspectorController->stopUserInitiatedProfiling(); +} + +void InspectorBackend::enableProfiler(bool always) +{ + if (m_inspectorController) + m_inspectorController->enableProfiler(always); +} + +void InspectorBackend::disableProfiler(bool always) +{ + if (m_inspectorController) + m_inspectorController->disableProfiler(always); +} + +bool InspectorBackend::profilerEnabled() +{ + if (m_inspectorController) + return m_inspectorController->profilerEnabled(); + return false; +} + +void InspectorBackend::enableDebugger(bool always) +{ + if (m_inspectorController) + m_inspectorController->enableDebuggerFromFrontend(always); +} + +void InspectorBackend::disableDebugger(bool always) +{ + if (m_inspectorController) + m_inspectorController->disableDebugger(always); +} + +bool InspectorBackend::debuggerEnabled() const +{ + if (m_inspectorController) + return m_inspectorController->debuggerEnabled(); + return false; +} + +JavaScriptCallFrame* InspectorBackend::currentCallFrame() const +{ + return JavaScriptDebugServer::shared().currentCallFrame(); +} + +void InspectorBackend::addBreakpoint(const String& sourceID, unsigned lineNumber) +{ + intptr_t sourceIDValue = sourceID.toIntPtr(); + JavaScriptDebugServer::shared().addBreakpoint(sourceIDValue, lineNumber); +} + +void InspectorBackend::removeBreakpoint(const String& sourceID, unsigned lineNumber) +{ + intptr_t sourceIDValue = sourceID.toIntPtr(); + JavaScriptDebugServer::shared().removeBreakpoint(sourceIDValue, lineNumber); +} + +bool InspectorBackend::pauseOnExceptions() +{ + return JavaScriptDebugServer::shared().pauseOnExceptions(); +} + +void InspectorBackend::setPauseOnExceptions(bool pause) +{ + JavaScriptDebugServer::shared().setPauseOnExceptions(pause); +} + +void InspectorBackend::pauseInDebugger() +{ + JavaScriptDebugServer::shared().pauseProgram(); +} + +void InspectorBackend::resumeDebugger() +{ + if (m_inspectorController) + m_inspectorController->resumeDebugger(); +} + +void InspectorBackend::stepOverStatementInDebugger() +{ + JavaScriptDebugServer::shared().stepOverStatement(); +} + +void InspectorBackend::stepIntoStatementInDebugger() +{ + JavaScriptDebugServer::shared().stepIntoStatement(); +} + +void InspectorBackend::stepOutOfFunctionInDebugger() +{ + JavaScriptDebugServer::shared().stepOutOfFunction(); +} + +#endif + +void InspectorBackend::highlight(Node* node) +{ + if (m_inspectorController) + m_inspectorController->highlight(node); +} + +} // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h new file mode 100644 index 000000000..bb891c2a2 --- /dev/null +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.h @@ -0,0 +1,140 @@ +/* + * Copyright (C) 2007 Apple 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE 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 APPLE 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. + */ + +#ifndef InspectorBackend_h +#define InspectorBackend_h + +#include "Console.h" +#include "InspectorController.h" +#include "PlatformString.h" + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class CachedResource; +class InspectorClient; +class JavaScriptCallFrame; +class Node; + +class InspectorBackend : public RefCounted<InspectorBackend> +{ +public: + static PassRefPtr<InspectorBackend> create(InspectorController* inspectorController, InspectorClient* client) + { + return adoptRef(new InspectorBackend(inspectorController, client)); + } + + ~InspectorBackend(); + + InspectorController* inspectorController() { return m_inspectorController; } + + void disconnectController() { m_inspectorController = 0; } + + void hideDOMNodeHighlight(); + + String localizedStringsURL(); + String hiddenPanels(); + + void windowUnloading(); + + bool isWindowVisible(); + + void addResourceSourceToFrame(long identifier, Node* frame); + bool addSourceToFrame(const String& mimeType, const String& source, Node* frame); + + void clearMessages(); + + void toggleNodeSearch(); + + void attach(); + void detach(); + + void setAttachedWindowHeight(unsigned height); + + void storeLastActivePanel(const String& panelName); + + bool searchingForNode(); + + void loaded(); + + void enableResourceTracking(bool always); + void disableResourceTracking(bool always); + bool resourceTrackingEnabled() const; + + void moveWindowBy(float x, float y) const; + void closeWindow(); + + const String& platform() const; + +#if ENABLE(JAVASCRIPT_DEBUGGER) + const ProfilesArray& profiles() const; + + void startProfiling(); + void stopProfiling(); + + void enableProfiler(bool always); + void disableProfiler(bool always); + bool profilerEnabled(); + + void enableDebugger(bool always); + void disableDebugger(bool always); + bool debuggerEnabled() const; + + JavaScriptCallFrame* currentCallFrame() const; + + void addBreakpoint(const String& sourceID, unsigned lineNumber); + void removeBreakpoint(const String& sourceID, unsigned lineNumber); + + bool pauseOnExceptions(); + void setPauseOnExceptions(bool pause); + + void pauseInDebugger(); + void resumeDebugger(); + + void stepOverStatementInDebugger(); + void stepIntoStatementInDebugger(); + void stepOutOfFunctionInDebugger(); +#endif + + // Generic code called from custom implementations. + void highlight(Node* node); + +private: + InspectorBackend(InspectorController* inspectorController, InspectorClient* client); + + InspectorController* m_inspectorController; + InspectorClient* m_client; +#if ENABLE(JAVASCRIPT_DEBUGGER) + ProfilesArray m_emptyProfiles; +#endif +}; + +} // namespace WebCore + +#endif // !defined(InspectorBackend_h) diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorController.idl b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.idl index c6263051a..21e6d99bc 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorController.idl +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorBackend.idl @@ -33,24 +33,23 @@ module core { interface [ GenerateConstructor - ] InspectorController { - [ImplementationFunction=hideHighlight] void hideDOMNodeHighlight(); + ] InspectorBackend { + void hideDOMNodeHighlight(); [Custom] void highlightDOMNode(in Node node); - [ImplementationFunction=scriptObjectReady] void loaded(); - [ImplementationFunction=close] void windowUnloading(); - [ImplementationFunction=attachWindow] void attach(); - [ImplementationFunction=detachWindow] void detach(); + void loaded(); + void windowUnloading(); + void attach(); + void detach(); void closeWindow(); - [ImplementationFunction=clearConsoleMessages] void clearMessages(); - [ImplementationFunction=toggleSearchForNodeInPage] void toggleNodeSearch(); + void clearMessages(); + void toggleNodeSearch(); - [ImplementationFunction=windowVisible] boolean isWindowVisible(); - [ImplementationFunction=searchingForNodeInPage] boolean searchingForNode(); + boolean isWindowVisible(); + boolean searchingForNode(); void addResourceSourceToFrame(in long identifier, in Node frame); boolean addSourceToFrame(in DOMString mimeType, in DOMString sourceValue, in Node frame); - [Custom] Node getResourceDocumentNode(in long long identifier); [Custom] void search(in Node node, in DOMString query); #if defined(ENABLE_DATABASE) && ENABLE_DATABASE [Custom] DOMObject databaseTableNames(in Database database); @@ -67,26 +66,34 @@ module core { boolean resourceTrackingEnabled(); void enableResourceTracking(in boolean always); void disableResourceTracking(in boolean always); + void storeLastActivePanel(in DOMString panelName); #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER - void enableDebuggerFromFrontend(in boolean always); + boolean debuggerEnabled(); + void enableDebugger(in boolean always); void disableDebugger(in boolean always); + + void addBreakpoint(in DOMString sourceID, in unsigned long lineNumber); + void removeBreakpoint(in DOMString sourceID, in unsigned long lineNumber); + void pauseInDebugger(); void resumeDebugger(); + void stepOverStatementInDebugger(); void stepIntoStatementInDebugger(); void stepOutOfFunctionInDebugger(); - boolean debuggerEnabled(); + + [Custom] DOMObject currentCallFrame(); + boolean pauseOnExceptions(); + void setPauseOnExceptions(in boolean pauseOnExceptions); + boolean profilerEnabled(); - [ImplementationFunction=startUserInitiatedProfiling] void startProfiling(); - [ImplementationFunction=stopUserInitiatedProfiling] void stopProfiling(); void enableProfiler(in boolean always); void disableProfiler(in boolean always); - [Custom] DOMObject currentCallFrame(); - void setPauseOnExceptions(in boolean pauseOnExceptions); - void addBreakpoint(in DOMString sourceID, in unsigned long lineNumber); - void removeBreakpoint(in DOMString sourceID, in unsigned long lineNumber); + + void startProfiling(); + void stopProfiling(); [Custom] Array profiles(); #endif diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp b/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp index 4b2dd59f7..2c7e5887d 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorController.cpp @@ -47,6 +47,7 @@ #include "GraphicsContext.h" #include "HTMLFrameOwnerElement.h" #include "HitTestResult.h" +#include "InspectorBackend.h" #include "InspectorClient.h" #include "InspectorFrontend.h" #include "InspectorDatabaseResource.h" @@ -99,65 +100,12 @@ static const char* const UserInitiatedProfileName = "org.webkit.profiles.user-in static const char* const resourceTrackingEnabledSettingName = "resourceTrackingEnabled"; static const char* const debuggerEnabledSettingName = "debuggerEnabled"; static const char* const profilerEnabledSettingName = "profilerEnabled"; +static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight"; +static const char* const lastActivePanelSettingName = "lastActivePanel"; -bool InspectorController::addSourceToFrame(const String& mimeType, const String& source, Node* frameNode) -{ - ASSERT_ARG(frameNode, frameNode); - - if (!frameNode) - return false; - - if (!frameNode->attached()) { - ASSERT_NOT_REACHED(); - return false; - } - - ASSERT(frameNode->isElementNode()); - if (!frameNode->isElementNode()) - return false; - - Element* element = static_cast<Element*>(frameNode); - ASSERT(element->isFrameOwnerElement()); - if (!element->isFrameOwnerElement()) - return false; - - HTMLFrameOwnerElement* frameOwner = static_cast<HTMLFrameOwnerElement*>(element); - ASSERT(frameOwner->contentFrame()); - if (!frameOwner->contentFrame()) - return false; - - FrameLoader* loader = frameOwner->contentFrame()->loader(); - - loader->setResponseMIMEType(mimeType); - loader->begin(); - loader->write(source); - loader->end(); - - return true; -} - -const String& InspectorController::platform() const -{ -#if PLATFORM(MAC) -#ifdef BUILDING_ON_TIGER - DEFINE_STATIC_LOCAL(const String, platform, ("mac-tiger")); -#else - DEFINE_STATIC_LOCAL(const String, platform, ("mac-leopard")); -#endif -#elif PLATFORM(WIN_OS) - DEFINE_STATIC_LOCAL(const String, platform, ("windows")); -#elif PLATFORM(QT) - DEFINE_STATIC_LOCAL(const String, platform, ("qt")); -#elif PLATFORM(GTK) - DEFINE_STATIC_LOCAL(const String, platform, ("gtk")); -#elif PLATFORM(WX) - DEFINE_STATIC_LOCAL(const String, platform, ("wx")); -#else - DEFINE_STATIC_LOCAL(const String, platform, ("unknown")); -#endif - - return platform; -} +static const unsigned defaultAttachedHeight = 300; +static const float minimumAttachedHeight = 250.0f; +static const float maximumAttachedHeightRatio = 0.75f; static unsigned s_inspectorControllerCount; static HashMap<String, InspectorController::Setting*>* s_settingCache; @@ -168,13 +116,14 @@ InspectorController::InspectorController(Page* page, InspectorClient* client) , m_page(0) , m_scriptState(0) , m_windowVisible(false) - , m_showAfterVisible(ElementsPanel) + , m_showAfterVisible(CurrentPanel) , m_nextIdentifier(-2) , m_groupLevel(0) , m_searchingForNode(false) , m_previousMessage(0) , m_resourceTrackingEnabled(false) , m_resourceTrackingSettingsLoaded(false) + , m_inspectorBackend(InspectorBackend::create(this, client)) #if ENABLE(JAVASCRIPT_DEBUGGER) , m_debuggerEnabled(false) , m_attachDebuggerWhenShown(false) @@ -209,6 +158,8 @@ InspectorController::~InspectorController() delete s_settingCache; s_settingCache = 0; } + + m_inspectorBackend->disconnectController(); } void InspectorController::inspectedPageDestroyed() @@ -279,20 +230,6 @@ void InspectorController::setSetting(const String& key, const Setting& setting) m_client->storeSetting(key, setting); } -String InspectorController::localizedStringsURL() -{ - if (!enabled()) - return String(); - return m_client->localizedStringsURL(); -} - -String InspectorController::hiddenPanels() -{ - if (!enabled()) - return String(); - return m_client->hiddenPanels(); -} - // Trying to inspect something in a frame with JavaScript disabled would later lead to // crashes trying to create JavaScript wrappers. Some day we could fix this issue, but // for now prevent crashes here by never targeting a node in such a frame. @@ -371,14 +308,27 @@ void InspectorController::setWindowVisible(bool visible, bool attached) if (m_windowVisible) { setAttachedWindow(attached); populateScriptObjects(); + + // Console panel is implemented as a 'fast view', so there should be + // real panel opened along with it. + bool showConsole = m_showAfterVisible == ConsolePanel; + if (m_showAfterVisible == CurrentPanel || showConsole) { + Setting lastActivePanelSetting = setting(lastActivePanelSettingName); + if (lastActivePanelSetting.type() == Setting::StringType) + m_showAfterVisible = specialPanelForJSName(lastActivePanelSetting.string()); + else + m_showAfterVisible = ElementsPanel; + } + if (m_nodeToFocus) focusNode(); #if ENABLE(JAVASCRIPT_DEBUGGER) if (m_attachDebuggerWhenShown) enableDebugger(); #endif - if (m_showAfterVisible != CurrentPanel) - showPanel(m_showAfterVisible); + showPanel(m_showAfterVisible); + if (showConsole) + showPanel(ConsolePanel); } else { #if ENABLE(JAVASCRIPT_DEBUGGER) // If the window is being closed with the debugger enabled, @@ -391,7 +341,6 @@ void InspectorController::setWindowVisible(bool visible, bool attached) #endif resetScriptObjects(); } - m_showAfterVisible = CurrentPanel; } @@ -453,11 +402,26 @@ void InspectorController::endGroup(MessageSource source, unsigned lineNumber, co addConsoleMessage(0, new ConsoleMessage(source, EndGroupMessageType, LogMessageLevel, String(), lineNumber, sourceURL, m_groupLevel)); } +static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight) +{ + return roundf(max(minimumAttachedHeight, min<float>(preferredHeight, totalWindowHeight * maximumAttachedHeightRatio))); +} + void InspectorController::attachWindow() { if (!enabled()) return; + + unsigned inspectedPageHeight = m_inspectedPage->mainFrame()->view()->visibleHeight(); + m_client->attachWindow(); + + Setting attachedHeight = setting(inspectorAttachedHeightName); + unsigned preferredHeight = attachedHeight.type() == Setting::IntegerType ? attachedHeight.integerValue() : defaultAttachedHeight; + + // We need to constrain the window height here in case the user has resized the inspected page's window so that + // the user's preferred height would be too big to display. + m_client->setAttachedWindowHeight(constrainedAttachedWindowHeight(preferredHeight, inspectedPageHeight)); } void InspectorController::detachWindow() @@ -479,7 +443,18 @@ void InspectorController::setAttachedWindowHeight(unsigned height) { if (!enabled()) return; - m_client->setAttachedWindowHeight(height); + + unsigned totalHeight = m_page->mainFrame()->view()->visibleHeight() + m_inspectedPage->mainFrame()->view()->visibleHeight(); + unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight); + + setSetting(inspectorAttachedHeightName, Setting(attachedHeight)); + + m_client->setAttachedWindowHeight(attachedHeight); +} + +void InspectorController::storeLastActivePanel(const String& panelName) +{ + setSetting(lastActivePanelSettingName, Setting(panelName)); } void InspectorController::toggleSearchForNodeInPage() @@ -492,19 +467,6 @@ void InspectorController::toggleSearchForNodeInPage() hideHighlight(); } -void InspectorController::addResourceSourceToFrame(long identifier, Node* frame) -{ - if (!enabled() || !m_frontend) - return; - - RefPtr<InspectorResource> resource = resources().get(identifier); - if (resource) { - String sourceString = resource->sourceString(); - if (!sourceString.isEmpty()) - addSourceToFrame(resource->mimeType(), sourceString, frame); - } -} - void InspectorController::mouseDidMoveOverElement(const HitTestResult& result, unsigned) { if (!enabled() || !m_searchingForNode) @@ -546,7 +508,7 @@ void InspectorController::windowScriptObjectAvailable() m_page->mainFrame()->document()->securityOrigin()->grantUniversalAccess(); m_scriptState = scriptStateFromPage(m_page); - ScriptGlobalObject::set(m_scriptState, "InspectorController", this); + ScriptGlobalObject::set(m_scriptState, "InspectorController", m_inspectorBackend.get()); } void InspectorController::scriptObjectReady() @@ -635,7 +597,18 @@ void InspectorController::close() void InspectorController::showWindow() { ASSERT(enabled()); + + unsigned inspectedPageHeight = m_inspectedPage->mainFrame()->view()->visibleHeight(); + m_client->showWindow(); + + Setting attachedHeight = setting(inspectorAttachedHeightName); + unsigned preferredHeight = attachedHeight.type() == Setting::IntegerType ? attachedHeight.integerValue() : defaultAttachedHeight; + + // This call might not go through (if the window starts out detached), but if the window is initially created attached, + // InspectorController::attachWindow is never called, so we need to make sure to set the attachedWindowHeight. + // FIXME: Clean up code so we only have to call setAttachedWindowHeight in InspectorController::attachWindow + m_client->setAttachedWindowHeight(constrainedAttachedWindowHeight(preferredHeight, inspectedPageHeight)); } void InspectorController::closeWindow() @@ -790,7 +763,9 @@ void InspectorController::addResource(InspectorResource* resource) void InspectorController::removeResource(InspectorResource* resource) { m_resources.remove(resource->identifier()); - m_knownResources.remove(resource->requestURL()); + String requestURL = resource->requestURL(); + if (!requestURL.isNull()) + m_knownResources.remove(requestURL); Frame* frame = resource->frame(); ResourcesMap* resourceMap = m_frameResources.get(frame); @@ -1116,7 +1091,7 @@ void InspectorController::addScriptProfile(Profile* profile) if (!m_frontend) return; - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); m_frontend->addProfile(toJS(m_scriptState, profile)); } @@ -1265,28 +1240,6 @@ void InspectorController::disableDebugger(bool always) m_frontend->debuggerWasDisabled(); } -JavaScriptCallFrame* InspectorController::currentCallFrame() const -{ - return JavaScriptDebugServer::shared().currentCallFrame(); -} - -bool InspectorController::pauseOnExceptions() -{ - return JavaScriptDebugServer::shared().pauseOnExceptions(); -} - -void InspectorController::setPauseOnExceptions(bool pause) -{ - JavaScriptDebugServer::shared().setPauseOnExceptions(pause); -} - -void InspectorController::pauseInDebugger() -{ - if (!m_debuggerEnabled) - return; - JavaScriptDebugServer::shared().pauseProgram(); -} - void InspectorController::resumeDebugger() { if (!m_debuggerEnabled) @@ -1294,39 +1247,6 @@ void InspectorController::resumeDebugger() JavaScriptDebugServer::shared().continueProgram(); } -void InspectorController::stepOverStatementInDebugger() -{ - if (!m_debuggerEnabled) - return; - JavaScriptDebugServer::shared().stepOverStatement(); -} - -void InspectorController::stepIntoStatementInDebugger() -{ - if (!m_debuggerEnabled) - return; - JavaScriptDebugServer::shared().stepIntoStatement(); -} - -void InspectorController::stepOutOfFunctionInDebugger() -{ - if (!m_debuggerEnabled) - return; - JavaScriptDebugServer::shared().stepOutOfFunction(); -} - -void InspectorController::addBreakpoint(const String& sourceID, unsigned lineNumber) -{ - intptr_t sourceIDValue = sourceID.toIntPtr(); - JavaScriptDebugServer::shared().addBreakpoint(sourceIDValue, lineNumber); -} - -void InspectorController::removeBreakpoint(const String& sourceID, unsigned lineNumber) -{ - intptr_t sourceIDValue = sourceID.toIntPtr(); - JavaScriptDebugServer::shared().removeBreakpoint(sourceIDValue, lineNumber); -} - // JavaScriptDebugListener functions void InspectorController::didParseSource(ExecState*, const SourceCode& source) @@ -1529,4 +1449,20 @@ bool InspectorController::stopTiming(const String& title, double& elapsed) return true; } +InspectorController::SpecialPanels InspectorController::specialPanelForJSName(const String& panelName) +{ + if (panelName == "elements") + return ElementsPanel; + else if (panelName == "resources") + return ResourcesPanel; + else if (panelName == "scripts") + return ScriptsPanel; + else if (panelName == "profiles") + return ProfilesPanel; + else if (panelName == "databases") + return DatabasesPanel; + else + return ElementsPanel; +} + } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/inspector/InspectorController.h b/src/3rdparty/webkit/WebCore/inspector/InspectorController.h index 4c90bc560..771f74154 100644 --- a/src/3rdparty/webkit/WebCore/inspector/InspectorController.h +++ b/src/3rdparty/webkit/WebCore/inspector/InspectorController.h @@ -56,6 +56,7 @@ class Database; class DocumentLoader; class GraphicsContext; class HitTestResult; +class InspectorBackend; class InspectorClient; class InspectorFrontend; class JavaScriptCallFrame; @@ -76,9 +77,9 @@ class InspectorDatabaseResource; class InspectorDOMStorageResource; class InspectorResource; -class InspectorController : public RefCounted<InspectorController> +class InspectorController #if ENABLE(JAVASCRIPT_DEBUGGER) - , JavaScriptDebugListener + : JavaScriptDebugListener #endif { public: @@ -113,6 +114,18 @@ public: m_simpleContent.m_boolean = value; } + explicit Setting(unsigned value) + : m_type(IntegerType) + { + m_simpleContent.m_integer = value; + } + + explicit Setting(const String& value) + : m_type(StringType) + { + m_string = value; + } + Type type() const { return m_type; } String string() const { ASSERT(m_type == StringType); return m_string; } @@ -139,14 +152,11 @@ public: bool m_boolean; } m_simpleContent; }; - - static PassRefPtr<InspectorController> create(Page* page, InspectorClient* inspectorClient) - { - return adoptRef(new InspectorController(page, inspectorClient)); - } - + InspectorController(Page*, InspectorClient*); ~InspectorController(); + InspectorBackend* inspectorBackend() { return m_inspectorBackend.get(); } + void inspectedPageDestroyed(); void pageDestroyed() { m_page = 0; } @@ -157,9 +167,6 @@ public: const Setting& setting(const String& key) const; void setSetting(const String& key, const Setting&); - String localizedStringsURL(); - String hiddenPanels(); - void inspect(Node*); void highlight(Node*); void hideHighlight(); @@ -171,8 +178,6 @@ public: bool windowVisible(); void setWindowVisible(bool visible = true, bool attached = false); - void addResourceSourceToFrame(long identifier, Node* frame); - bool addSourceToFrame(const String& mimeType, const String& source, Node*); void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*); void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); void clearConsoleMessages(); @@ -180,9 +185,6 @@ public: void attachWindow(); void detachWindow(); - void setAttachedWindow(bool); - void setAttachedWindowHeight(unsigned height); - void toggleSearchForNodeInPage(); bool searchingForNodeInPage() { return m_searchingForNode; }; void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); @@ -191,7 +193,6 @@ public: void inspectedWindowScriptObjectCleared(Frame*); void windowScriptObjectAvailable(); - void scriptObjectReady(); void setFrontendProxyObject(ScriptState* state, ScriptObject object); void populateScriptObjects(); @@ -225,9 +226,6 @@ public: const ResourcesMap& resources() const { return m_resources; } - void moveWindowBy(float x, float y) const; - void closeWindow(); - void drawNodeHighlight(GraphicsContext&) const; void count(const String& title, unsigned lineNumber, const String& sourceID); @@ -238,8 +236,6 @@ public: void startGroup(MessageSource source, ScriptCallStack* callFrame); void endGroup(MessageSource source, unsigned lineNumber, const String& sourceURL); - const String& platform() const; - #if ENABLE(JAVASCRIPT_DEBUGGER) void addProfile(PassRefPtr<JSC::Profile>, unsigned lineNumber, const JSC::UString& sourceURL); void addProfileFinishedMessageToConsole(PassRefPtr<JSC::Profile>, unsigned lineNumber, const JSC::UString& sourceURL); @@ -250,35 +246,19 @@ public: bool isRecordingUserInitiatedProfile() const { return m_recordingUserInitiatedProfile; } JSC::UString getCurrentUserInitiatedProfileName(bool incrementProfileNumber); - void startUserInitiatedProfilingSoon(); void startUserInitiatedProfiling(Timer<InspectorController>* = 0); void stopUserInitiatedProfiling(); - void toggleRecordButton(bool); void enableProfiler(bool always = false, bool skipRecompile = false); void disableProfiler(bool always = false); bool profilerEnabled() const { return enabled() && m_profilerEnabled; } - void enableDebuggerFromFrontend(bool always); void enableDebugger(); void disableDebugger(bool always = false); bool debuggerEnabled() const { return m_debuggerEnabled; } - JavaScriptCallFrame* currentCallFrame() const; - - void addBreakpoint(const String& sourceID, unsigned lineNumber); - void removeBreakpoint(const String& sourceID, unsigned lineNumber); - - bool pauseOnExceptions(); - void setPauseOnExceptions(bool pause); - - void pauseInDebugger(); void resumeDebugger(); - void stepOverStatementInDebugger(); - void stepIntoStatementInDebugger(); - void stepOutOfFunctionInDebugger(); - virtual void didParseSource(JSC::ExecState*, const JSC::SourceCode&); virtual void failedToParseSource(JSC::ExecState*, const JSC::SourceCode&, int errorLine, const JSC::UString& errorMessage); virtual void didPause(); @@ -286,7 +266,20 @@ public: #endif private: - InspectorController(Page*, InspectorClient*); + friend class InspectorBackend; + + // Following are used from InspectorBackend and internally. + void scriptObjectReady(); + void moveWindowBy(float x, float y) const; + void setAttachedWindow(bool); + void setAttachedWindowHeight(unsigned height); + void storeLastActivePanel(const String& panelName); + void closeWindow(); +#if ENABLE(JAVASCRIPT_DEBUGGER) + void startUserInitiatedProfilingSoon(); + void toggleRecordButton(bool); + void enableDebuggerFromFrontend(bool always); +#endif void focusNode(); @@ -303,6 +296,8 @@ private: bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl); + SpecialPanels specialPanelForJSName(const String& panelName); + Page* m_inspectedPage; InspectorClient* m_client; OwnPtr<InspectorFrontend> m_frontend; @@ -331,6 +326,7 @@ private: ConsoleMessage* m_previousMessage; bool m_resourceTrackingEnabled; bool m_resourceTrackingSettingsLoaded; + RefPtr<InspectorBackend> m_inspectorBackend; #if ENABLE(JAVASCRIPT_DEBUGGER) bool m_debuggerEnabled; bool m_attachDebuggerWhenShown; diff --git a/src/3rdparty/webkit/WebCore/inspector/JavaScriptCallFrame.cpp b/src/3rdparty/webkit/WebCore/inspector/JavaScriptCallFrame.cpp index 1ce0defcc..9225a0392 100644 --- a/src/3rdparty/webkit/WebCore/inspector/JavaScriptCallFrame.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/JavaScriptCallFrame.cpp @@ -104,7 +104,7 @@ JSValue JavaScriptCallFrame::evaluate(const UString& script, JSValue& exception) if (!m_isValid) return jsNull(); - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); return m_debuggerCallFrame.evaluate(script, exception); } diff --git a/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp b/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp index 84bc2f680..10eff26a1 100644 --- a/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/JavaScriptDebugServer.cpp @@ -554,7 +554,7 @@ void JavaScriptDebugServer::recompileAllJSFunctionsSoon() void JavaScriptDebugServer::recompileAllJSFunctions(Timer<JavaScriptDebugServer>*) { - JSLock lock(false); + JSLock lock(SilenceAssertionsOnly); JSGlobalData* globalData = JSDOMWindow::commonJSGlobalData(); // If JavaScript is running, it's not safe to recompile, since we'll end diff --git a/src/3rdparty/webkit/WebCore/inspector/JavaScriptProfileNode.cpp b/src/3rdparty/webkit/WebCore/inspector/JavaScriptProfileNode.cpp index 5b5c340b0..3c3e27978 100644 --- a/src/3rdparty/webkit/WebCore/inspector/JavaScriptProfileNode.cpp +++ b/src/3rdparty/webkit/WebCore/inspector/JavaScriptProfileNode.cpp @@ -84,7 +84,7 @@ static JSValueRef getLineNumber(JSContextRef ctx, JSObjectRef thisObject, JSStri static JSValueRef getTotalTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -95,7 +95,7 @@ static JSValueRef getTotalTime(JSContextRef ctx, JSObjectRef thisObject, JSStrin static JSValueRef getSelfTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -106,7 +106,7 @@ static JSValueRef getSelfTime(JSContextRef ctx, JSObjectRef thisObject, JSString static JSValueRef getTotalPercent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -117,7 +117,7 @@ static JSValueRef getTotalPercent(JSContextRef ctx, JSObjectRef thisObject, JSSt static JSValueRef getSelfPercent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -128,7 +128,7 @@ static JSValueRef getSelfPercent(JSContextRef ctx, JSObjectRef thisObject, JSStr static JSValueRef getNumberOfCalls(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -139,7 +139,7 @@ static JSValueRef getNumberOfCalls(JSContextRef ctx, JSObjectRef thisObject, JSS static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef* exception) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -186,7 +186,7 @@ static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSString static JSValueRef getParent(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -198,7 +198,7 @@ static JSValueRef getParent(JSContextRef ctx, JSObjectRef thisObject, JSStringRe static JSValueRef getHead(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -210,7 +210,7 @@ static JSValueRef getHead(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, static JSValueRef getVisible(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); @@ -221,7 +221,7 @@ static JSValueRef getVisible(JSContextRef ctx, JSObjectRef thisObject, JSStringR static JSValueRef getCallUID(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*) { - JSC::JSLock lock(false); + JSC::JSLock lock(SilenceAssertionsOnly); if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass())) return JSValueMakeUndefined(ctx); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/Breakpoint.js b/src/3rdparty/webkit/WebCore/inspector/front-end/Breakpoint.js index 8611cf5e2..347df6084 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/Breakpoint.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/Breakpoint.js @@ -29,6 +29,7 @@ WebInspector.Breakpoint = function(url, line, sourceID) this.line = line; this.sourceID = sourceID; this._enabled = true; + this._sourceText = ""; } WebInspector.Breakpoint.prototype = { @@ -48,6 +49,28 @@ WebInspector.Breakpoint.prototype = { this.dispatchEventToListeners("enabled"); else this.dispatchEventToListeners("disabled"); + }, + + get sourceText() + { + return this._sourceText; + }, + + set sourceText(text) + { + this._sourceText = text; + this.dispatchEventToListeners("text-changed"); + }, + + get label() + { + var displayName = (this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)")); + return displayName + ":" + this.line; + }, + + get id() + { + return this.sourceID + ":" + this.line; } } diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/BreakpointsSidebarPane.js b/src/3rdparty/webkit/WebCore/inspector/front-end/BreakpointsSidebarPane.js index 2b8f3cded..14f8c06c4 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/BreakpointsSidebarPane.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/BreakpointsSidebarPane.js @@ -27,7 +27,10 @@ WebInspector.BreakpointsSidebarPane = function() { WebInspector.SidebarPane.call(this, WebInspector.UIString("Breakpoints")); - this.breakpoints = []; + this.breakpoints = {}; + + this.listElement = document.createElement("ol"); + this.listElement.className = "breakpoint-list"; this.emptyElement = document.createElement("div"); this.emptyElement.className = "info"; @@ -39,11 +42,21 @@ WebInspector.BreakpointsSidebarPane = function() WebInspector.BreakpointsSidebarPane.prototype = { addBreakpoint: function(breakpoint) { - this.breakpoints.push(breakpoint); + if (this.breakpoints[breakpoint.id]) + return; + + this.breakpoints[breakpoint.id] = breakpoint; + breakpoint.addEventListener("enabled", this._breakpointEnableChanged, this); breakpoint.addEventListener("disabled", this._breakpointEnableChanged, this); + breakpoint.addEventListener("text-changed", this._breakpointTextChanged, this); - // FIXME: add to the breakpoints UI. + this._appendBreakpointElement(breakpoint); + + if (this.emptyElement.parentElement) { + this.bodyElement.removeChild(this.emptyElement); + this.bodyElement.appendChild(this.listElement); + } if (!InspectorController.debuggerEnabled() || !breakpoint.sourceID) return; @@ -52,13 +65,73 @@ WebInspector.BreakpointsSidebarPane.prototype = { InspectorController.addBreakpoint(breakpoint.sourceID, breakpoint.line); }, + _appendBreakpointElement: function(breakpoint) + { + function checkboxClicked() + { + breakpoint.enabled = !breakpoint.enabled; + } + + function labelClicked() + { + var script = WebInspector.panels.scripts.scriptOrResourceForID(breakpoint.sourceID); + if (script) + WebInspector.panels.scripts.showScript(script, breakpoint.line); + } + + var breakpointElement = document.createElement("li"); + breakpoint._breakpointListElement = breakpointElement; + breakpointElement._breakpointObject = breakpoint; + + var checkboxElement = document.createElement("input"); + checkboxElement.className = "checkbox-elem"; + checkboxElement.type = "checkbox"; + checkboxElement.checked = breakpoint.enabled; + checkboxElement.addEventListener("click", checkboxClicked, false); + breakpointElement.appendChild(checkboxElement); + + var labelElement = document.createElement("a"); + labelElement.textContent = breakpoint.label; + labelElement.addEventListener("click", labelClicked, false); + breakpointElement.appendChild(labelElement); + + var sourceTextElement = document.createElement("div"); + sourceTextElement.textContent = breakpoint.sourceText; + sourceTextElement.className = "source-text"; + breakpointElement.appendChild(sourceTextElement); + + var currentElement = this.listElement.firstChild; + while (currentElement) { + var currentBreak = currentElement._breakpointObject; + if (currentBreak.url > breakpoint.url) { + this.listElement.insertBefore(breakpointElement, currentElement); + return; + } else if (currentBreak.url == breakpoint.url && currentBreak.line > breakpoint.line) { + this.listElement.insertBefore(breakpointElement, currentElement); + return; + } + currentElement = currentElement.nextSibling; + } + this.listElement.appendChild(breakpointElement); + }, + removeBreakpoint: function(breakpoint) { - this.breakpoints.remove(breakpoint); + if (!this.breakpoints[breakpoint.id]) + return; + delete this.breakpoints[breakpoint.id]; + breakpoint.removeEventListener("enabled", null, this); breakpoint.removeEventListener("disabled", null, this); + breakpoint.removeEventListener("text-changed", null, this); - // FIXME: remove from the breakpoints UI. + var element = breakpoint._breakpointListElement; + element.parentElement.removeChild(element); + + if (!this.listElement.firstChild) { + this.bodyElement.removeChild(this.listElement); + this.bodyElement.appendChild(this.emptyElement); + } if (!InspectorController.debuggerEnabled() || !breakpoint.sourceID) return; @@ -70,7 +143,8 @@ WebInspector.BreakpointsSidebarPane.prototype = { { var breakpoint = event.target; - // FIXME: change the breakpoint checkbox state in the UI. + var checkbox = breakpoint._breakpointListElement.firstChild; + checkbox.checked = breakpoint.enabled; if (!InspectorController.debuggerEnabled() || !breakpoint.sourceID) return; @@ -79,6 +153,14 @@ WebInspector.BreakpointsSidebarPane.prototype = { InspectorController.addBreakpoint(breakpoint.sourceID, breakpoint.line); else InspectorController.removeBreakpoint(breakpoint.sourceID, breakpoint.line); + }, + + _breakpointTextChanged: function(event) + { + var breakpoint = event.target; + + var sourceTextElement = breakpoint._breakpointListElement.firstChild.nextSibling.nextSibling; + sourceTextElement.textContent = breakpoint.sourceText; } } diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/Console.js b/src/3rdparty/webkit/WebCore/inspector/front-end/Console.js index ca9ac0057..520e213a2 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/Console.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/Console.js @@ -409,16 +409,35 @@ WebInspector.Console.prototype = { }, \ dir: function() { return console.dir.apply(console, arguments) }, \ dirxml: function() { return console.dirxml.apply(console, arguments) }, \ - keys: function(o) { var a = []; for (k in o) a.push(k); return a; }, \ - values: function(o) { var a = []; for (k in o) a.push(o[k]); return a; }, \ + keys: function(o) { var a = []; for (var k in o) a.push(k); return a; }, \ + values: function(o) { var a = []; for (var k in o) a.push(o[k]); return a; }, \ profile: function() { return console.profile.apply(console, arguments) }, \ - profileEnd: function() { return console.profileEnd.apply(console, arguments) } \ + profileEnd: function() { return console.profileEnd.apply(console, arguments) }, \ + _inspectedNodes: [], \ + _addInspectedNode: function(node) { \ + var inspectedNodes = _inspectorCommandLineAPI._inspectedNodes; \ + inspectedNodes.unshift(node); \ + if (inspectedNodes.length >= 5) \ + inspectedNodes.pop(); \ + }, \ + get $0() { return _inspectorCommandLineAPI._inspectedNodes[0] }, \ + get $1() { return _inspectorCommandLineAPI._inspectedNodes[1] }, \ + get $2() { return _inspectorCommandLineAPI._inspectedNodes[2] }, \ + get $3() { return _inspectorCommandLineAPI._inspectedNodes[3] }, \ + get $4() { return _inspectorCommandLineAPI._inspectedNodes[4] } \ };"); inspectedWindow._inspectorCommandLineAPI.clear = InspectorController.wrapCallback(this.clearMessages.bind(this)); } }, - + + addInspectedNode: function(node) + { + var inspectedWindow = InspectorController.inspectedWindow(); + this._ensureCommandLineAPIInstalled(inspectedWindow); + inspectedWindow._inspectorCommandLineAPI._addInspectedNode(node); + }, + doEvalInWindow: function(expression, callback) { if (!expression) { diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/DatabasesPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/DatabasesPanel.js index 4644b3b22..b1d815f9c 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/DatabasesPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/DatabasesPanel.js @@ -332,7 +332,7 @@ WebInspector.DatabasesPanel.prototype = { var nodes = []; var length = domStorage.length; - for (index = 0; index < domStorage.length; index++) { + for (var index = 0; index < domStorage.length; index++) { var data = {}; var key = String(domStorage.key(index)); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js index 3c9be545b..76d97469e 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsPanel.js @@ -60,6 +60,8 @@ WebInspector.ElementsPanel = function() InspectorController.toggleNodeSearch(); this.panel.nodeSearchButton.removeStyleClass("toggled-on"); } + + WebInspector.console.addInspectedNode(this._focusedDOMNode); }; this.contentElement.appendChild(this.treeOutline.element); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js index 2da2f104b..ef5320915 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ElementsTreeOutline.js @@ -1,6 +1,7 @@ /* * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> + * Copyright (C) 2009 Joseph Pecoraro * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -255,6 +256,9 @@ WebInspector.ElementsTreeElement = function(node) // The title will be updated in onattach. TreeElement.call(this, "", node, titleInfo.hasChildren); + + if (this.representedObject.nodeType == Node.ELEMENT_NODE) + this._canAddAttributes = true; } WebInspector.ElementsTreeElement.prototype = { @@ -296,9 +300,36 @@ WebInspector.ElementsTreeElement.prototype = { this.listItemElement.addStyleClass("hovered"); } else this.listItemElement.removeStyleClass("hovered"); + if (this._canAddAttributes) + this.toggleNewAttributeButton(); } }, + toggleNewAttributeButton: function() + { + function removeWhenEditing(event) + { + if (this._addAttributeElement && this._addAttributeElement.parentNode) + this._addAttributeElement.parentNode.removeChild(this._addAttributeElement); + delete this._addAttributeElement; + } + + if (!this._addAttributeElement && this._hovered && !this._editing) { + var span = document.createElement("span"); + span.className = "add-attribute"; + span.textContent = "\u2026"; + span.addEventListener("dblclick", removeWhenEditing.bind(this), false); + this._addAttributeElement = span; + + var tag = this.listItemElement.getElementsByClassName("webkit-html-tag")[0]; + this._insertInLastAttributePosition(tag, span); + } else if (!this._hovered && this._addAttributeElement) { + if (this._addAttributeElement.parentNode) + this._addAttributeElement.parentNode.removeChild(this._addAttributeElement); + delete this._addAttributeElement; + } + }, + updateSelection: function() { var listItemElement = this.listItemElement; @@ -483,7 +514,7 @@ WebInspector.ElementsTreeElement.prototype = { if (this._editing) return; - if (this._startEditing(event)) + if (this._startEditing(event, treeElement)) return; if (this.treeOutline.panel) { @@ -495,7 +526,20 @@ WebInspector.ElementsTreeElement.prototype = { this.expand(); }, - _startEditing: function(event) + _insertInLastAttributePosition: function(tag, node) + { + if (tag.getElementsByClassName("webkit-html-attribute").length > 0) + tag.insertBefore(node, tag.lastChild); + else { + var nodeName = tag.textContent.match(/^<(.*?)>$/)[1]; + tag.textContent = ''; + tag.appendChild(document.createTextNode('<'+nodeName)); + tag.appendChild(node); + tag.appendChild(document.createTextNode('>')); + } + }, + + _startEditing: function(event, treeElement) { if (this.treeOutline.focusedDOMNode != this.representedObject) return; @@ -509,12 +553,51 @@ WebInspector.ElementsTreeElement.prototype = { var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-attribute"); if (attribute) - return this._startEditingAttribute(attribute, event); + return this._startEditingAttribute(attribute, event.target); + + var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attribute"); + if (newAttribute) + return this._addNewAttribute(treeElement.listItemElement); return false; }, - _startEditingAttribute: function(attribute, event) + _addNewAttribute: function(listItemElement) + { + var attr = document.createElement("span"); + attr.className = "webkit-html-attribute"; + attr.style.marginLeft = "2px"; // overrides the .editing margin rule + attr.style.marginRight = "2px"; // overrides the .editing margin rule + var name = document.createElement("span"); + name.className = "webkit-html-attribute-name new-attribute"; + name.textContent = " "; + var value = document.createElement("span"); + value.className = "webkit-html-attribute-value"; + attr.appendChild(name); + attr.appendChild(value); + + var tag = listItemElement.getElementsByClassName("webkit-html-tag")[0]; + this._insertInLastAttributePosition(tag, attr); + return this._startEditingAttribute(attr, attr); + }, + + _triggerEditAttribute: function(attributeName) + { + var attributeElements = this.listItemElement.getElementsByClassName("webkit-html-attribute-name"); + for (var i = 0, len = attributeElements.length; i < len; ++i) { + if (attributeElements[i].textContent === attributeName) { + for (var elem = attributeElements[i].nextSibling; elem; elem = elem.nextSibling) { + if (elem.nodeType !== Node.ELEMENT_NODE) + continue; + + if (elem.hasStyleClass("webkit-html-attribute-value")) + return this._startEditingAttribute(attributeElements[i].parentNode, elem); + } + } + } + }, + + _startEditingAttribute: function(attribute, elementForSelection) { if (WebInspector.isBeingEdited(attribute)) return true; @@ -545,7 +628,7 @@ WebInspector.ElementsTreeElement.prototype = { this._editing = true; WebInspector.startEditing(attribute, this._attributeEditingCommitted.bind(this), this._editingCancelled.bind(this), attributeName); - window.getSelection().setBaseAndExtent(event.target, 0, event.target, 1); + window.getSelection().setBaseAndExtent(elementForSelection, 0, elementForSelection, 1); return true; }, @@ -563,15 +646,56 @@ WebInspector.ElementsTreeElement.prototype = { return true; }, - _attributeEditingCommitted: function(element, newText, oldText, attributeName) + _attributeEditingCommitted: function(element, newText, oldText, attributeName, moveDirection) { delete this._editing; + // Before we do anything, determine where we should move + // next based on the current element's settings + var moveToAttribute; + var newAttribute; + if (moveDirection) { + var found = false; + var attributes = this.representedObject.attributes; + for (var i = 0, len = attributes.length; i < len; ++i) { + if (attributes[i].name === attributeName) { + found = true; + if (moveDirection === "backward" && i > 0) + moveToAttribute = attributes[i - 1].name; + else if (moveDirection === "forward" && i < attributes.length - 1) + moveToAttribute = attributes[i + 1].name; + else if (moveDirection === "forward" && i === attributes.length - 1) + newAttribute = true; + } + } + + if (!found && moveDirection === "backward") + moveToAttribute = attributes[attributes.length - 1].name; + else if (!found && moveDirection === "forward" && !/^\s*$/.test(newText)) + newAttribute = true; + } + + function moveToNextAttributeIfNeeded() { + if (moveToAttribute) + this._triggerEditAttribute(moveToAttribute); + else if (newAttribute) + this._addNewAttribute(this.listItemElement); + } + var parseContainerElement = document.createElement("span"); parseContainerElement.innerHTML = "<span " + newText + "></span>"; var parseElement = parseContainerElement.firstChild; - if (!parseElement || !parseElement.hasAttributes()) { - this._editingCancelled(element, context); + + if (!parseElement) { + this._editingCancelled(element, attributeName); + moveToNextAttributeIfNeeded.call(this); + return; + } + + if (!parseElement.hasAttributes()) { + InspectorController.inspectedWindow().Element.prototype.removeAttribute.call(this.representedObject, attributeName); + this._updateTitle(); + moveToNextAttributeIfNeeded.call(this); return; } @@ -579,7 +703,9 @@ WebInspector.ElementsTreeElement.prototype = { for (var i = 0; i < parseElement.attributes.length; ++i) { var attr = parseElement.attributes[i]; foundOriginalAttribute = foundOriginalAttribute || attr.name === attributeName; - InspectorController.inspectedWindow().Element.prototype.setAttribute.call(this.representedObject, attr.name, attr.value); + try { + InspectorController.inspectedWindow().Element.prototype.setAttribute.call(this.representedObject, attr.name, attr.value); + } catch(e) {} // ignore invalid attribute (innerHTML doesn't throw errors, but this can) } if (!foundOriginalAttribute) @@ -588,6 +714,8 @@ WebInspector.ElementsTreeElement.prototype = { this._updateTitle(); this.treeOutline.focusedNodeChanged(true); + + moveToNextAttributeIfNeeded.call(this); }, _textNodeEditingCommitted: function(element, newText) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js index 59e73747a..d8c34d7fb 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ObjectPropertiesSection.js @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2009 Joseph Pecoraro * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -58,7 +59,7 @@ WebInspector.ObjectPropertiesSection.prototype = { if (this.extraProperties) for (var prop in this.extraProperties) properties.push(prop); - properties.sort(); + properties.sort(this._displaySort); this.propertiesTreeOutline.removeChildren(); @@ -79,6 +80,44 @@ WebInspector.ObjectPropertiesSection.prototype = { var infoElement = new TreeElement(title, null, false); this.propertiesTreeOutline.appendChild(infoElement); } + }, + + _displaySort: function(a,b) { + + // if used elsewhere make sure to + // - convert a and b to strings (not needed here, properties are all strings) + // - check if a == b (not needed here, no two properties can be the same) + + var diff = 0; + var chunk = /^\d+|^\D+/; + var chunka, chunkb, anum, bnum; + while (diff === 0) { + if (!a && b) + return -1; + if (!b && a) + return 1; + chunka = a.match(chunk)[0]; + chunkb = b.match(chunk)[0]; + anum = !isNaN(chunka); + bnum = !isNaN(chunkb); + if (anum && !bnum) + return -1; + if (bnum && !anum) + return 1; + if (anum && bnum) { + diff = chunka - chunkb; + if (diff === 0 && chunka.length !== chunkb.length) { + if (!+chunka && !+chunkb) // chunks are strings of all 0s (special case) + return chunka.length - chunkb.length; + else + return chunkb.length - chunka.length; + } + } else if (chunka !== chunkb) + return (chunka < chunkb) ? -1 : 1; + a = a.substring(chunka.length); + b = b.substring(chunkb.length); + } + return diff; } } @@ -109,7 +148,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = { this.removeChildren(); var childObject = this.safePropertyValue(this.parentObject, this.propertyName); - var properties = Object.sortedProperties(childObject); + var properties = Object.sortedProperties(childObject, WebInspector.ObjectPropertiesSection.prototype._displaySort); for (var i = 0; i < properties.length; ++i) { var propertyName = properties[i]; if (propertyName === "__treeElementIdentifier") @@ -156,7 +195,7 @@ WebInspector.ObjectPropertyTreeElement.prototype = { var hasSubProperties = false; var type = typeof childObject; if (childObject && (type === "object" || type === "function")) { - for (subPropertyName in childObject) { + for (var subPropertyName in childObject) { if (subPropertyName === "__treeElementIdentifier") continue; hasSubProperties = true; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/Resource.js b/src/3rdparty/webkit/WebCore/inspector/front-end/Resource.js index 85d5cd2a0..bcb7b2a8e 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/Resource.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/Resource.js @@ -341,12 +341,6 @@ WebInspector.Resource.prototype = { } }, - get documentNode() { - if ("identifier" in this) - return InspectorController.getResourceDocumentNode(this.identifier); - return null; - }, - get requestHeaders() { if (this._requestHeaders === undefined) diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js index c4ea83f42..3804b5b6f 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ResourcesPanel.js @@ -1453,6 +1453,12 @@ WebInspector.ResourceSidebarTreeElement.prototype = { { WebInspector.SidebarTreeElement.prototype.onattach.call(this); + var link = document.createElement("a"); + link.href = this.resource.url; + link.className = "invisible"; + while (this._listItemNode.firstChild) + link.appendChild(this._listItemNode.firstChild); + this._listItemNode.appendChild(link); this._listItemNode.addStyleClass("resources-category-" + this.resource.category.name); }, @@ -1460,6 +1466,11 @@ WebInspector.ResourceSidebarTreeElement.prototype = { { WebInspector.panels.resources.showResource(this.resource); }, + + ondblclick: function(treeElement, event) + { + InspectorController.inspectedWindow().open(this.resource.url); + }, get mainTitle() { diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js b/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js index 68013c9a1..6fcf42f86 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/ScriptsPanel.js @@ -56,6 +56,7 @@ WebInspector.ScriptsPanel = function() this.filesSelectElement.className = "status-bar-item"; this.filesSelectElement.id = "scripts-files"; this.filesSelectElement.addEventListener("change", this._changeVisibleFile.bind(this), false); + this.filesSelectElement.handleKeyEvent = this.handleKeyEvent.bind(this); this.topStatusBar.appendChild(this.filesSelectElement); this.functionsSelectElement = document.createElement("select"); @@ -132,13 +133,11 @@ WebInspector.ScriptsPanel = function() for (var pane in this.sidebarPanes) this.sidebarElement.appendChild(this.sidebarPanes[pane].element); - // FIXME: remove the following line of code when the Breakpoints pane has content. - this.sidebarElement.removeChild(this.sidebarPanes.breakpoints.element); - this.sidebarPanes.callstack.expanded = true; this.sidebarPanes.callstack.addEventListener("call frame selected", this._callFrameSelected, this); this.sidebarPanes.scopechain.expanded = true; + this.sidebarPanes.breakpoints.expanded = true; var panelEnablerHeading = WebInspector.UIString("You need to enable debugging before you can use the Scripts panel."); var panelEnablerDisclaimer = WebInspector.UIString("Enabling debugging will make scripts run slower."); @@ -239,7 +238,7 @@ WebInspector.ScriptsPanel.prototype = { view.visible = false; } if (this._attachDebuggerWhenShown) { - InspectorController.enableDebuggerFromFrontend(false); + InspectorController.enableDebugger(false); delete this._attachDebuggerWhenShown; } }, @@ -298,6 +297,11 @@ WebInspector.ScriptsPanel.prototype = { this._addScriptToFilesMenu(script); }, + scriptOrResourceForID: function(id) + { + return this._sourceIDMap[id]; + }, + addBreakpoint: function(breakpoint) { this.sidebarPanes.breakpoints.addBreakpoint(breakpoint); @@ -359,12 +363,12 @@ WebInspector.ScriptsPanel.prototype = { updateInterface = true; var self = this; - function updatingCallbackWrapper(result) + function updatingCallbackWrapper(result, exception) { - callback(result); + callback(result, exception); if (updateInterface) self.sidebarPanes.scopechain.update(selectedCallFrame); - } + } this.doEvalInCallFrame(selectedCallFrame, code, updatingCallbackWrapper); }, @@ -428,7 +432,7 @@ WebInspector.ScriptsPanel.prototype = { attachDebuggerWhenShown: function() { if (this.element.parentElement) { - InspectorController.enableDebuggerFromFrontend(false); + InspectorController.enableDebugger(false); } else { this._attachDebuggerWhenShown = true; } @@ -862,7 +866,7 @@ WebInspector.ScriptsPanel.prototype = { if (InspectorController.debuggerEnabled()) InspectorController.disableDebugger(true); else - InspectorController.enableDebuggerFromFrontend(!!optionalAlways); + InspectorController.enableDebugger(!!optionalAlways); }, _togglePauseOnExceptions: function() diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js index 18d9073d0..930eb162b 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceFrame.js @@ -27,6 +27,7 @@ WebInspector.SourceFrame = function(element, addBreakpointDelegate) { this.messages = []; this.breakpoints = []; + this._shortcuts = {}; this.addBreakpointDelegate = addBreakpointDelegate; @@ -199,8 +200,16 @@ WebInspector.SourceFrame.prototype = { { WebInspector.addMainEventListeners(this.element.contentDocument); this.element.contentDocument.addEventListener("mousedown", this._documentMouseDown.bind(this), true); + this.element.contentDocument.addEventListener("keydown", this._documentKeyDown.bind(this), true); + this.element.contentDocument.addEventListener("keyup", WebInspector.documentKeyUp.bind(WebInspector), true); this.element.contentDocument.addEventListener("webkitAnimationEnd", this._highlightLineEnds.bind(this), false); + // Register 'eval' shortcut. + var isMac = InspectorController.platform().indexOf("mac-") === 0; + var platformSpecificModifier = isMac ? WebInspector.KeyboardShortcut.Modifiers.Meta : WebInspector.KeyboardShortcut.Modifiers.Ctrl; + var shortcut = WebInspector.KeyboardShortcut.makeKey(69 /* 'E' */, platformSpecificModifier | WebInspector.KeyboardShortcut.Modifiers.Shift); + this._shortcuts[shortcut] = this._evalSelectionInCallFrame.bind(this); + var headElement = this.element.contentDocument.getElementsByTagName("head")[0]; if (!headElement) { headElement = this.element.contentDocument.createElement("head"); @@ -286,6 +295,36 @@ WebInspector.SourceFrame.prototype = { this.addBreakpointDelegate(this.lineNumberForSourceRow(sourceRow)); }, + _documentKeyDown: function(event) + { + var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); + var handler = this._shortcuts[shortcut]; + if (handler) { + handler(event); + event.preventDefault(); + } else { + WebInspector.documentKeyDown(event); + } + }, + + _evalSelectionInCallFrame: function(event) + { + if (!WebInspector.panels.scripts || !WebInspector.panels.scripts.paused) + return; + + var selection = this.element.contentWindow.getSelection(); + if (!selection.rangeCount) + return; + + var expression = selection.getRangeAt(0).toString().trimWhitespace(); + WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, false, function(result, exception) { + WebInspector.showConsole(); + var commandMessage = new WebInspector.ConsoleCommand(expression); + WebInspector.console.addMessage(commandMessage); + WebInspector.console.addMessage(new WebInspector.ConsoleCommandResult(result, exception, commandMessage)); + }); + }, + _breakpointEnableChanged: function(event) { var breakpoint = event.target; @@ -332,6 +371,8 @@ WebInspector.SourceFrame.prototype = { if (!sourceRow) return; + breakpoint.sourceText = sourceRow.getElementsByClassName('webkit-line-content')[0].textContent; + this._drawBreakpointImagesIfNeeded(); sourceRow._breakpointObject = breakpoint; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js index 7510c8cad..97a5bd5d2 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/SourceView.js @@ -104,8 +104,11 @@ WebInspector.SourceView.prototype = { { delete this._frameNeedsSetup; this.sourceFrame.removeEventListener("content loaded", this._contentLoaded, this); - - if (this.resource.type === WebInspector.Resource.Type.Script) { + + if (this.resource.type === WebInspector.Resource.Type.Script + || this.resource.mimeType === 'application/json' + || this.resource.mimeType === 'application/javascript' + || /\.js(on)?$/.test(this.resource.lastPathComponent) ) { this.sourceFrame.addEventListener("syntax highlighting complete", this._syntaxHighlightingComplete, this); this.sourceFrame.syntaxHighlightJavascript(); } else diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/StylesSidebarPane.js b/src/3rdparty/webkit/WebCore/inspector/front-end/StylesSidebarPane.js index c30444ba0..1785d7781 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/StylesSidebarPane.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/StylesSidebarPane.js @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2009 Joseph Pecoraro * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -387,6 +388,11 @@ WebInspector.StylePropertiesSection.prototype = { child = child.traverseNextTreeElement(false, null, true); } } + + if (this._afterUpdate) { + this._afterUpdate(this); + delete this._afterUpdate; + } }, onpopulate: function() @@ -425,6 +431,26 @@ WebInspector.StylePropertiesSection.prototype = { var item = new WebInspector.StylePropertyTreeElement(style, name, isShorthand, inherited, overloaded, disabled); this.propertiesTreeOutline.appendChild(item); } + }, + + findTreeElementWithName: function(name) + { + var treeElement = this.propertiesTreeOutline.children[0]; + while (treeElement) { + if (treeElement.name === name) + return treeElement; + treeElement = treeElement.traverseNextTreeElement(true, null, true); + } + return null; + }, + + addNewBlankProperty: function() + { + var item = new WebInspector.StylePropertyTreeElement(this.styleRule.style, "", false, false, false, false); + this.propertiesTreeOutline.appendChild(item); + item.listItemElement.textContent = ""; + item._newProperty = true; + return item; } } @@ -558,10 +584,12 @@ WebInspector.StylePropertyTreeElement.prototype = { var nameElement = document.createElement("span"); nameElement.className = "name"; nameElement.textContent = this.name; + this.nameElement = nameElement; var valueElement = document.createElement("span"); valueElement.className = "value"; valueElement.innerHTML = htmlValue; + this.valueElement = valueElement; if (priority) { var priorityElement = document.createElement("span"); @@ -843,14 +871,56 @@ WebInspector.StylePropertyTreeElement.prototype = { this.editingEnded(context); }, - editingCommitted: function(element, userInput, previousContent, context) + editingCommitted: function(element, userInput, previousContent, context, moveDirection) { this.editingEnded(context); - if (userInput === previousContent) - return; // nothing changed, so do nothing else + // Determine where to move to before making changes + var newProperty = false; + var moveToPropertyName; + var moveTo = (moveDirection === "forward" ? this.nextSibling : this.previousSibling); + if (moveTo) + moveToPropertyName = moveTo.name; + else if (moveDirection === "forward") + newProperty = true; + + // Make the Changes and trigger the moveToNextCallback after updating + var blankInput = /^\s*$/.test(userInput); + if (userInput !== previousContent || (this._newProperty && blankInput)) { // only if something changed, or adding a new style and it was blank + this.treeOutline.section._afterUpdate = moveToNextCallback.bind(this, this._newProperty, !blankInput); + this.applyStyleText(userInput, true); + } else + moveToNextCallback(this._newProperty, false, this.treeOutline.section, false); + + // The Callback to start editing the next property + function moveToNextCallback(alreadyNew, valueChanged, section) { + if (!moveDirection) + return; + + // User just tabbed through without changes + if (moveTo && moveTo.parent) { + moveTo.startEditing(moveTo.valueElement); + return; + } + + // User has made a change then tabbed, wiping all the original treeElements, + // recalculate the new treeElement for the same property we were going to edit next + if (moveTo && !moveTo.parent) { + var treeElement = section.findTreeElementWithName(moveToPropertyName); + if (treeElement) + treeElement.startEditing(treeElement.valueElement); + return; + } + + // Create a new attribute in this section + if (newProperty) { + if (alreadyNew && !valueChanged) + return; - this.applyStyleText(userInput, true); + var item = section.addNewBlankProperty(); + item.startEditing(); + } + } }, applyStyleText: function(styleText, updateInterface) @@ -876,7 +946,9 @@ WebInspector.StylePropertyTreeElement.prototype = { if (!styleTextLength) { if (updateInterface) { - // The user deleted the everything, so remove the tree element and update. + // The user deleted everything, so remove the tree element and update. + if (!this._newProperty) + delete this.treeOutline.section._afterUpdate; if (this.treeOutline.section && this.treeOutline.section.pane) this.treeOutline.section.pane.update(); this.parent.removeChild(this); @@ -886,7 +958,12 @@ WebInspector.StylePropertyTreeElement.prototype = { if (!tempStyle.length) { // The user typed something, but it didn't parse. Just abort and restore - // the original title for this property. + // the original title for this property. If this was a new attribute and + // we couldn't parse, then just remove it. + if (this._newProperty) { + this.parent.removeChild(this); + return; + } if (updateInterface) this.updateTitle(); return; diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css index 929caa23d..dabadc25b 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.css @@ -644,6 +644,10 @@ body.console-visible #console { margin-right: -6px; } +.console-group-messages .add-attribute { + display: none; +} + .console-formatted-object, .console-formatted-node { position: relative; display: inline-block; @@ -768,6 +772,11 @@ body.console-visible #console { vertical-align: top; } +.invisible { + color: inherit; + text-decoration: none; +} + .webkit-line-gutter-backdrop { /* Keep this in sync with view-source.css (.webkit-line-gutter-backdrop) */ width: 31px; @@ -1090,6 +1099,11 @@ body.console-visible #console { text-decoration: underline; } +.add-attribute { + margin-left: 1px; + margin-right: 1px; +} + .placard { position: relative; margin-top: 1px; @@ -3102,3 +3116,41 @@ body.inactive .sidebar-tree-item.selected .bubble.search-matches { border-left: 1px solid rgb(184, 184, 184); margin-left: -1px; } + +ol.breakpoint-list { + -webkit-padding-start: 2px; + list-style: none; + margin: 0; +} + +.breakpoint-list li { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + margin: 4px 0; +} + +.breakpoint-list .checkbox-elem { + font-size: 10px; + margin: 0 4px; + vertical-align: top; + position: relative; + z-index: 1; +} + +.breakpoint-list .source-text { + font-family: monospace; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + margin: 2px 0 0px 20px; +} + +.breakpoint-list a { + color: rgb(33%, 33%, 33%); + cursor: pointer; +} + +.breakpoint-list a:hover { + color: rgb(15%, 15%, 15%); +} diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html index f211fb7bf..762074eec 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.html @@ -87,11 +87,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. <div class="toolbar-item"><input id="search" type="search" incremental results="0"><div id="search-toolbar-label" class="toolbar-label"></div></div> </div> <div id="main"> - <div id="main-panels" tabindex="0"></div> + <div id="main-panels" tabindex="0" spellcheck="false"></div> <div id="main-status-bar" class="status-bar"><div id="anchored-status-bar-items"><button id="dock-status-bar-item" class="status-bar-item toggled"></button><button id="console-status-bar-item" class="status-bar-item"></button><div id="error-warning-count" class="hidden"></div></div></div> </div> <div id="console"> - <div id="console-messages"><div id="console-prompt"><br></div></div> + <div id="console-messages"><div id="console-prompt" spellcheck="false"><br></div></div> <div id="console-status-bar" class="status-bar"><div id="other-console-status-bar-items"><button id="clear-console-status-bar-item" class="status-bar-item"></button></div></div> </div> </body> diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js index 91f2659e8..7e236925d 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/inspector.js @@ -117,6 +117,26 @@ var WebInspector = { } } } + + for (var panelName in WebInspector.panels) { + if (WebInspector.panels[panelName] == x) + InspectorController.storeLastActivePanel(panelName); + } + }, + + _createPanels: function() + { + var hiddenPanels = (InspectorController.hiddenPanels() || "").split(','); + if (hiddenPanels.indexOf("elements") === -1) + this.panels.elements = new WebInspector.ElementsPanel(); + if (hiddenPanels.indexOf("resources") === -1) + this.panels.resources = new WebInspector.ResourcesPanel(); + if (hiddenPanels.indexOf("scripts") === -1) + this.panels.scripts = new WebInspector.ScriptsPanel(); + if (hiddenPanels.indexOf("profiles") === -1) + this.panels.profiles = new WebInspector.ProfilesPanel(); + if (hiddenPanels.indexOf("databases") === -1) + this.panels.databases = new WebInspector.DatabasesPanel(); }, get attached() @@ -281,24 +301,16 @@ WebInspector.loaded = function() this.console = new WebInspector.Console(); this.panels = {}; - var hiddenPanels = (InspectorController.hiddenPanels() || "").split(','); - if (hiddenPanels.indexOf("elements") === -1) - this.panels.elements = new WebInspector.ElementsPanel(); - if (hiddenPanels.indexOf("resources") === -1) - this.panels.resources = new WebInspector.ResourcesPanel(); - if (hiddenPanels.indexOf("scripts") === -1) - this.panels.scripts = new WebInspector.ScriptsPanel(); - if (hiddenPanels.indexOf("profiles") === -1) - this.panels.profiles = new WebInspector.ProfilesPanel(); - if (hiddenPanels.indexOf("databases") === -1) - this.panels.databases = new WebInspector.DatabasesPanel(); + this._createPanels(); var toolbarElement = document.getElementById("toolbar"); var previousToolbarItem = toolbarElement.children[0]; + this.panelOrder = []; for (var panelName in this.panels) { var panel = this.panels[panelName]; var panelToolbarItem = panel.toolbarItem; + this.panelOrder.push(panel); panelToolbarItem.addEventListener("click", this._toolbarItemClicked.bind(this)); if (previousToolbarItem) toolbarElement.insertBefore(panelToolbarItem, previousToolbarItem.nextSibling); @@ -307,8 +319,6 @@ WebInspector.loaded = function() previousToolbarItem = panelToolbarItem; } - this.currentPanel = this.panels.elements; - this.resourceCategories = { documents: new WebInspector.ResourceCategory(WebInspector.UIString("Documents"), "documents"), stylesheets: new WebInspector.ResourceCategory(WebInspector.UIString("Stylesheets"), "stylesheets"), @@ -523,6 +533,36 @@ WebInspector.documentKeyDown = function(event) } break; + + case "U+005B": // [ key + if (isMac) + var isRotateLeft = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey; + else + var isRotateLeft = event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey; + + if (isRotateLeft) { + var index = this.panelOrder.indexOf(this.currentPanel); + index = (index === 0) ? this.panelOrder.length - 1 : index - 1; + this.panelOrder[index].toolbarItem.click(); + event.preventDefault(); + } + + break; + + case "U+005D": // ] key + if (isMac) + var isRotateRight = event.metaKey && !event.shiftKey && !event.ctrlKey && !event.altKey; + else + var isRotateRight = event.ctrlKey && !event.shiftKey && !event.metaKey && !event.altKey; + + if (isRotateRight) { + var index = this.panelOrder.indexOf(this.currentPanel); + index = (index + 1) % this.panelOrder.length; + this.panelOrder[index].toolbarItem.click(); + event.preventDefault(); + } + + break; } } } @@ -588,6 +628,7 @@ WebInspector.animateStyle = function(animations, duration, callback, complete) var start = null; var current = null; var end = null; + var key = null; for (key in animation) { if (key === "element") element = animation[key]; @@ -1278,6 +1319,7 @@ WebInspector.startEditing = function(element, committedCallback, cancelledCallba var oldText = element.textContent; var oldHandleKeyEvent = element.handleKeyEvent; + var moveDirection = ""; element.addStyleClass("editing"); @@ -1315,7 +1357,7 @@ WebInspector.startEditing = function(element, committedCallback, cancelledCallba function editingCommitted() { cleanUpAfterEditing.call(this); - committedCallback(this, this.textContent, oldText, context); + committedCallback(this, this.textContent, oldText, context, moveDirection); } element.handleKeyEvent = function(event) { @@ -1331,7 +1373,8 @@ WebInspector.startEditing = function(element, committedCallback, cancelledCallba editingCancelled.call(element); event.preventDefault(); event.handled = true; - } + } else if (event.keyIdentifier === "U+0009") // Tab key + moveDirection = (event.shiftKey ? "backward" : "forward"); } element.addEventListener("blur", blurEventListener, false); diff --git a/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js b/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js index 8fb50e202..4285785ed 100644 --- a/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js +++ b/src/3rdparty/webkit/WebCore/inspector/front-end/utilities.js @@ -38,7 +38,7 @@ Object.type = function(obj, win) win = win || window; if (obj instanceof win.Node) - return "node"; + return (obj.nodeType === undefined ? type : "node"); if (obj instanceof win.String) return "string"; if (obj instanceof win.Array) @@ -94,12 +94,12 @@ Object.describe = function(obj, abbreviated) } } -Object.sortedProperties = function(obj) +Object.sortedProperties = function(obj, sortFunc) { var properties = []; for (var prop in obj) properties.push(prop); - properties.sort(); + properties.sort(sortFunc); return properties; } |