diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index a72ec7140e17..77b88445cfbf 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,108 @@ +2010-03-11 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * GNUmakefile.am: + * WebCore.Inspector.exp: + * WebCore.base.exp: + * WebCore.gypi: + * WebCore.order: + * WebCore.pro: + * WebCore.xcodeproj/project.pbxproj: + * inspector/ConsoleMessage.cpp: + (WebCore::ConsoleMessage::addToFrontend): + * inspector/ConsoleMessage.h: + * inspector/InspectorClient.h: + * inspector/InspectorController.cpp: + (WebCore::InspectorController::InspectorController): + (WebCore::InspectorController::~InspectorController): + (WebCore::InspectorController::inspectedPageDestroyed): + (WebCore::InspectorController::windowVisible): + (WebCore::InspectorController::frontendReady): + (WebCore::InspectorController::willCloseFrontend): + (WebCore::InspectorController::addConsoleMessage): + (WebCore::InspectorController::setInspectorFrontendClient): + (WebCore::InspectorController::inspectedWindowScriptObjectCleared): + (WebCore::InspectorController::setFrontend): + (WebCore::InspectorController::show): + (WebCore::InspectorController::close): + (WebCore::InspectorController::releaseDOMAgent): + (WebCore::InspectorController::populateScriptObjects): + (WebCore::InspectorController::didCommitLoad): + (WebCore::InspectorController::getProfile): + (WebCore::InspectorController::enableDebugger): + * inspector/InspectorController.h: + (WebCore::InspectorController::hasInspectorFrontendClient): + * inspector/InspectorFrontend.cpp: + (WebCore::InspectorFrontend::InspectorFrontend): + (WebCore::InspectorFrontend::~InspectorFrontend): + (WebCore::InspectorFrontend::addConsoleMessage): + (WebCore::InspectorFrontend::bringToFront): + (WebCore::InspectorFrontend::inspectedURLChanged): + * inspector/InspectorFrontend.h: + * inspector/InspectorFrontendClient.h: Added. + (WebCore::InspectorFrontendClient::~InspectorFrontendClient): + * inspector/InspectorFrontendClientLocal.cpp: Added. + (WebCore::FrontendMenuProvider::create): + (WebCore::FrontendMenuProvider::disconnect): + (WebCore::FrontendMenuProvider::FrontendMenuProvider): + (WebCore::FrontendMenuProvider::~FrontendMenuProvider): + (WebCore::FrontendMenuProvider::populateContextMenu): + (WebCore::FrontendMenuProvider::contextMenuItemSelected): + (WebCore::FrontendMenuProvider::contextMenuCleared): + (WebCore::InspectorFrontendClientLocal::InspectorFrontendClientLocal): + (WebCore::InspectorFrontendClientLocal::~InspectorFrontendClientLocal): + (WebCore::InspectorFrontendClientLocal::windowObjectCleared): + (WebCore::InspectorFrontendClientLocal::frontendLoaded): + (WebCore::InspectorFrontendClientLocal::canAttachWindow): + (WebCore::InspectorFrontendClientLocal::changeAttachedWindowHeight): + (WebCore::InspectorFrontendClientLocal::moveWindowBy): + (WebCore::InspectorFrontendClientLocal::showContextMenu): + (WebCore::InspectorFrontendClientLocal::setAttachedWindow): + (WebCore::InspectorFrontendClientLocal::restoreAttachedWindowHeight): + (WebCore::InspectorFrontendClientLocal::constrainedAttachedWindowHeight): + * inspector/InspectorFrontendClientLocal.h: Added. + * inspector/InspectorFrontendHost.cpp: + (WebCore::InspectorFrontendHost::InspectorFrontendHost): + (WebCore::InspectorFrontendHost::~InspectorFrontendHost): + (WebCore::InspectorFrontendHost::loaded): + (WebCore::InspectorFrontendHost::attach): + (WebCore::InspectorFrontendHost::detach): + (WebCore::InspectorFrontendHost::closeWindow): + (WebCore::InspectorFrontendHost::bringToFront): + (WebCore::InspectorFrontendHost::inspectedURLChanged): + (WebCore::InspectorFrontendHost::canAttachWindow): + (WebCore::InspectorFrontendHost::setAttachedWindowHeight): + (WebCore::InspectorFrontendHost::moveWindowBy): + (WebCore::InspectorFrontendHost::showContextMenu): + * inspector/InspectorFrontendHost.h: + (WebCore::InspectorFrontendHost::create): + * inspector/InspectorFrontendHost.idl: + * inspector/front-end/InspectorFrontendHostStub.js: + (.WebInspector.InspectorFrontendHostStub.prototype.bringToFront): + (.WebInspector.InspectorFrontendHostStub.prototype.inspectedURLChanged): + * inspector/front-end/inspector.js: + (WebInspector.loaded): + (WebInspector.close): + (WebInspector.bringToFront): + (WebInspector.inspectedURLChanged): + * loader/EmptyClients.h: + (WebCore::EmptyInspectorClient::openInspectorFrontend): + * loader/FrameLoader.cpp: + (WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld): + * page/Page.cpp: + (WebCore::Page::Page): + (WebCore::Page::~Page): + * page/Page.h: + * platform/ContextMenu.cpp: + (WebCore::ContextMenu::populate): + (WebCore::ContextMenu::addInspectElementItem): + 2010-03-16 Pavel Feldman Reviewed by Timothy Hatcher. diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am index dae85dcc5c5d..76a59a2d8960 100644 --- a/WebCore/GNUmakefile.am +++ b/WebCore/GNUmakefile.am @@ -1239,6 +1239,9 @@ webcore_sources += \ WebCore/inspector/InspectorController.h \ WebCore/inspector/InspectorFrontend.cpp \ WebCore/inspector/InspectorFrontend.h \ + WebCore/inspector/InspectorFrontendClient.h \ + WebCore/inspector/InspectorFrontendClientLocal.cpp \ + WebCore/inspector/InspectorFrontendClientLocal.h \ WebCore/inspector/InspectorFrontendHost.cpp \ WebCore/inspector/InspectorFrontendHost.h \ WebCore/inspector/InspectorResource.cpp \ diff --git a/WebCore/WebCore.Inspector.exp b/WebCore/WebCore.Inspector.exp index 379b7a2673f1..f77473977d27 100644 --- a/WebCore/WebCore.Inspector.exp +++ b/WebCore/WebCore.Inspector.exp @@ -1,11 +1,10 @@ __ZN7WebCore19InspectorController10setSettingERKNS_6StringES3_ -__ZN7WebCore19InspectorController12attachWindowEv -__ZN7WebCore19InspectorController12detachWindowEv __ZN7WebCore19InspectorController14enableDebuggerEv __ZN7WebCore19InspectorController14enableProfilerEbb __ZN7WebCore19InspectorController15disableDebuggerEb __ZN7WebCore19InspectorController15disableProfilerEb -__ZN7WebCore19InspectorController16setWindowVisibleEbb +__ZN7WebCore19InspectorController18disconnectFrontendEv +__ZN7WebCore19InspectorController26setInspectorFrontendClientEN3WTF10PassOwnPtrINS_23InspectorFrontendClientEEE __ZN7WebCore19InspectorController26stopUserInitiatedProfilingEv __ZN7WebCore19InspectorController27startUserInitiatedProfilingEPNS_5TimerIS0_EE __ZN7WebCore19InspectorController4showEv @@ -18,3 +17,13 @@ __ZNK7WebCore19InspectorController7enabledEv __ZNK7WebCore19InspectorController7settingERKNS_6StringE __ZN7WebCore19InspectorController21startTimelineProfilerEv __ZN7WebCore19InspectorController20stopTimelineProfilerEv +__ZN7WebCore28InspectorFrontendClientLocalC2EPNS_19InspectorControllerEPNS_4PageE +__ZN7WebCore28InspectorFrontendClientLocalD2Ev +__ZN7WebCore28InspectorFrontendClientLocal19windowObjectClearedEv +__ZN7WebCore28InspectorFrontendClientLocal14frontendLoadedEv +__ZN7WebCore28InspectorFrontendClientLocal27restoreAttachedWindowHeightEv +__ZN7WebCore28InspectorFrontendClientLocal12moveWindowByEff +__ZN7WebCore28InspectorFrontendClientLocal15canAttachWindowEv +__ZN7WebCore28InspectorFrontendClientLocal15showContextMenuEPNS_5EventERKN3WTF6VectorIPNS_15ContextMenuItemELm0EEE +__ZN7WebCore28InspectorFrontendClientLocal17setAttachedWindowEb +__ZN7WebCore28InspectorFrontendClientLocal26changeAttachedWindowHeightEj diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp index 4364aea20d51..9bafad77e303 100644 --- a/WebCore/WebCore.base.exp +++ b/WebCore/WebCore.base.exp @@ -874,7 +874,6 @@ __ZNK7WebCore16VisibleSelection23isContentRichlyEditableEv __ZNK7WebCore16VisibleSelection5isAllENS_21StayInEditableContentE __ZNK7WebCore17ResourceErrorBase8lazyInitEv __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEv -__ZNK7WebCore19InspectorController15canAttachWindowEv __ZNK7WebCore19ResourceRequestBase10httpMethodEv __ZNK7WebCore19ResourceRequestBase3urlEv __ZNK7WebCore19ResourceRequestBase7isEmptyEv diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index 8e6fa3ad9f1e..759fedb41db0 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -1630,6 +1630,9 @@ 'inspector/InspectorDOMStorageResource.h', 'inspector/InspectorFrontend.cpp', 'inspector/InspectorFrontend.h', + 'inspector/InspectorFrontendClient.h', + 'inspector/InspectorFrontendClientLocal.cpp', + 'inspector/InspectorFrontendClientLocal.h', 'inspector/InspectorFrontendHost.cpp', 'inspector/InspectorFrontendHost.h', 'inspector/InspectorResource.cpp', diff --git a/WebCore/WebCore.order b/WebCore/WebCore.order index a8d20fd2b330..48f321bb7aaf 100644 --- a/WebCore/WebCore.order +++ b/WebCore/WebCore.order @@ -23789,7 +23789,6 @@ __ZN7WebCore18ScriptFunctionCall14appendArgumentEb __ZN7WebCore18ScriptFunctionCall4callEv __ZN7WebCore18ScriptFunctionCall4callERbb __ZN7WebCore44jsInspectorControllerPrototypeFunctionAttachEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE -__ZN7WebCore19InspectorController12attachWindowEv __ZN7WebCore19InspectorController21populateScriptObjectsEv __ZN7WebCoreL18callSimpleFunctionEPN3JSC9ExecStateERKNS_12ScriptObjectEPKc __ZN7WebCore19InspectorController9showPanelENS0_13SpecialPanelsE @@ -23850,7 +23849,6 @@ __ZN7WebCoreL19drawHighlightForBoxERNS_15GraphicsContextERKNS_9FloatQuadES4_S4_S __ZN7WebCoreL16drawOutlinedQuadERNS_15GraphicsContextERKNS_9FloatQuadERKNS_5ColorE __ZN7WebCoreL10quadToPathERKNS_9FloatQuadE __ZN7WebCore44jsInspectorControllerPrototypeFunctionDetachEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE -__ZN7WebCore19InspectorController12detachWindowEv __ZN7WebCore56jsInspectorControllerPrototypeFunctionMoveByUnrestrictedEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgL __ZNK7WebCore19InspectorController12moveWindowByEff __ZN7WebCoreL24drawOutlinedQuadWithClipERNS_15GraphicsContextERKNS_9FloatQuadES4_RKNS_5ColorE diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro index 41ce4cec5302..99e02591daf7 100644 --- a/WebCore/WebCore.pro +++ b/WebCore/WebCore.pro @@ -697,6 +697,7 @@ SOURCES += \ inspector/InspectorDOMAgent.cpp \ inspector/InspectorDOMStorageResource.cpp \ inspector/InspectorFrontend.cpp \ + inspector/InspectorFrontendClientLocal.cpp \ inspector/InspectorFrontendHost.cpp \ inspector/InspectorResource.cpp \ inspector/InspectorTimelineAgent.cpp \ @@ -1403,6 +1404,8 @@ HEADERS += \ inspector/InspectorDatabaseResource.h \ inspector/InspectorDOMStorageResource.h \ inspector/InspectorFrontend.h \ + inspector/InspectorFrontendClient.h \ + inspector/InspectorFrontendClientLocal.h \ inspector/InspectorFrontendHost.h \ inspector/InspectorResource.h \ inspector/InspectorTimelineAgent.h \ diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj index 5968cbec4d5f..2e1c177b21e7 100644 --- a/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/WebCore/WebCore.vcproj/WebCore.vcproj @@ -42860,6 +42860,18 @@ RelativePath="..\inspector\InspectorFrontend.h" > + + + + + + diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj index 97a9f7b3a1ba..aa804b100e6d 100644 --- a/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/WebCore/WebCore.xcodeproj/project.pbxproj @@ -4863,6 +4863,9 @@ ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED501DC50B249F2900AE18D9 /* EditorMac.mm */; }; EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = EDE3A4FF0C7A430600956A37 /* ColorMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; }; + F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; + F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */; settings = {ATTRIBUTES = (Private, ); }; }; + F344C75811294FF600F26EEE /* InspectorFrontendClientLocal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */; }; F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; }; F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; }; F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; }; @@ -10203,6 +10206,9 @@ ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = EditorMac.mm; path = mac/EditorMac.mm; sourceTree = ""; }; EDE3A4FF0C7A430600956A37 /* ColorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMac.h; sourceTree = ""; }; EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = ""; tabWidth = 4; usesTabs = 0; }; + F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendClient.h; sourceTree = ""; }; + F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendClientLocal.h; sourceTree = ""; }; + F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorFrontendClientLocal.cpp; sourceTree = ""; }; F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = ""; }; F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = ""; }; F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = ""; }; @@ -10738,6 +10744,9 @@ 41F061720F5F00AC00A07EAC /* InspectorDOMStorageResource.h */, 7AED3E030FBB1EAA00D2B03C /* InspectorFrontend.cpp */, 7AED3E040FBB1EAA00D2B03C /* InspectorFrontend.h */, + F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */, + F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */, + F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */, 7A0E770B10C00A8800A0276E /* InspectorFrontendHost.cpp */, 7A0E770C10C00A8800A0276E /* InspectorFrontendHost.h */, 7A0E770D10C00A8800A0276E /* InspectorFrontendHost.idl */, @@ -17430,6 +17439,8 @@ 7A24587C1021EAF4000A00AA /* InspectorDOMAgent.h in Headers */, 41F061740F5F00AC00A07EAC /* InspectorDOMStorageResource.h in Headers */, 7AED3E060FBB1EAA00D2B03C /* InspectorFrontend.h in Headers */, + F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */, + F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */, 7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */, 41F062010F5F0B6600A07EAC /* InspectorResource.h in Headers */, 754133A8102E00E800075D00 /* InspectorTimelineAgent.h in Headers */, @@ -19645,6 +19656,7 @@ 7A24587B1021EAF4000A00AA /* InspectorDOMAgent.cpp in Sources */, 41F061750F5F00AC00A07EAC /* InspectorDOMStorageResource.cpp in Sources */, 7AED3E050FBB1EAA00D2B03C /* InspectorFrontend.cpp in Sources */, + F344C75811294FF600F26EEE /* InspectorFrontendClientLocal.cpp in Sources */, 7A0E770E10C00A8800A0276E /* InspectorFrontendHost.cpp in Sources */, 41F062020F5F0B6600A07EAC /* InspectorResource.cpp in Sources */, 754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */, diff --git a/WebCore/inspector/ConsoleMessage.cpp b/WebCore/inspector/ConsoleMessage.cpp index 5539e9d7bf1d..405499686655 100644 --- a/WebCore/inspector/ConsoleMessage.cpp +++ b/WebCore/inspector/ConsoleMessage.cpp @@ -31,9 +31,12 @@ #include "config.h" #include "ConsoleMessage.h" +#include "InjectedScript.h" +#include "InjectedScriptHost.h" #include "InspectorFrontend.h" #include "ScriptCallStack.h" #include "ScriptObject.h" +#include "SerializedScriptValue.h" namespace WebCore { @@ -80,7 +83,7 @@ ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, S } #if ENABLE(INSPECTOR) -void ConsoleMessage::addToConsole(InspectorFrontend* frontend) +void ConsoleMessage::addToFrontend(InspectorFrontend* frontend, InjectedScriptHost* injectedScriptHost) { ScriptObject jsonObj = frontend->newScriptObject(); jsonObj.set("source", static_cast(m_source)); @@ -90,7 +93,15 @@ void ConsoleMessage::addToConsole(InspectorFrontend* frontend) jsonObj.set("url", m_url); jsonObj.set("groupLevel", static_cast(m_groupLevel)); jsonObj.set("repeatCount", static_cast(m_repeatCount)); - frontend->addConsoleMessage(jsonObj, m_frames, m_scriptState, m_arguments, m_message); + Vector > arguments; + if (!m_arguments.isEmpty()) { + InjectedScript injectedScript = injectedScriptHost->injectedScriptFor(m_scriptState); + for (unsigned i = 0; i < m_arguments.size(); ++i) { + RefPtr serializedValue = injectedScript.wrapForConsole(m_arguments[i]); + arguments.append(serializedValue); + } + } + frontend->addConsoleMessage(jsonObj, m_frames, arguments, m_message); } void ConsoleMessage::updateRepeatCountInConsole(InspectorFrontend* frontend) diff --git a/WebCore/inspector/ConsoleMessage.h b/WebCore/inspector/ConsoleMessage.h index e9ae13075aee..53f425506655 100644 --- a/WebCore/inspector/ConsoleMessage.h +++ b/WebCore/inspector/ConsoleMessage.h @@ -38,40 +38,41 @@ #include namespace WebCore { - class InspectorFrontend; - class ScriptCallStack; - class ScriptString; +class InjectedScriptHost; +class InspectorFrontend; +class ScriptCallStack; +class ScriptString; - class ConsoleMessage : public Noncopyable { - public: - ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g); - ConsoleMessage(MessageSource, MessageType, MessageLevel, ScriptCallStack*, unsigned g, bool storeTrace = false); +class ConsoleMessage : public Noncopyable { +public: + ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u, unsigned g); + ConsoleMessage(MessageSource, MessageType, MessageLevel, ScriptCallStack*, unsigned g, bool storeTrace = false); #if ENABLE(INSPECTOR) - void addToConsole(InspectorFrontend* frontend); - void updateRepeatCountInConsole(InspectorFrontend* frontend); + void addToFrontend(InspectorFrontend*, InjectedScriptHost*); + void updateRepeatCountInConsole(InspectorFrontend* frontend); #endif - void incrementCount() { ++m_repeatCount; }; - bool isEqual(ScriptState*, ConsoleMessage* msg) const; + void incrementCount() { ++m_repeatCount; } + bool isEqual(ScriptState*, ConsoleMessage* msg) const; - MessageSource source() const { return m_source; } - const String& message() const { return m_message; } + MessageSource source() const { return m_source; } + const String& message() const { return m_message; } - private: - MessageSource m_source; - MessageType m_type; - MessageLevel m_level; - String m_message; +private: + MessageSource m_source; + MessageType m_type; + MessageLevel m_level; + String m_message; #if ENABLE(INSPECTOR) - Vector m_arguments; - ScriptState* m_scriptState; + Vector m_arguments; + ScriptState* m_scriptState; #endif - Vector m_frames; - unsigned m_line; - String m_url; - unsigned m_groupLevel; - unsigned m_repeatCount; - }; + Vector m_frames; + unsigned m_line; + String m_url; + unsigned m_groupLevel; + unsigned m_repeatCount; +}; } // namespace WebCore diff --git a/WebCore/inspector/InspectorClient.h b/WebCore/inspector/InspectorClient.h index e448cd2b7e80..841c15eb0e6b 100644 --- a/WebCore/inspector/InspectorClient.h +++ b/WebCore/inspector/InspectorClient.h @@ -30,6 +30,7 @@ namespace WebCore { +class InspectorController; class Node; class Page; class String; @@ -40,29 +41,13 @@ class InspectorClient { virtual void inspectorDestroyed() = 0; - virtual Page* createPage() = 0; - - virtual String localizedStringsURL() = 0; - - virtual String hiddenPanels() = 0; - - virtual void showWindow() = 0; - virtual void closeWindow() = 0; - - virtual void attachWindow() = 0; - virtual void detachWindow() = 0; - - virtual void setAttachedWindowHeight(unsigned height) = 0; + virtual void openInspectorFrontend(InspectorController*) = 0; virtual void highlight(Node*) = 0; virtual void hideHighlight() = 0; - virtual void inspectedURLChanged(const String& newURL) = 0; - virtual void populateSetting(const String& key, String* value) = 0; virtual void storeSetting(const String& key, const String& value) = 0; - - virtual void inspectorWindowObjectCleared() = 0; }; } // namespace WebCore diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp index b2ca3a867286..e5f222f8d71f 100644 --- a/WebCore/inspector/InspectorController.cpp +++ b/WebCore/inspector/InspectorController.cpp @@ -57,11 +57,11 @@ #include "InjectedScriptHost.h" #include "InspectorBackend.h" #include "InspectorClient.h" +#include "InspectorFrontendClient.h" #include "InspectorDOMAgent.h" #include "InspectorDOMStorageResource.h" #include "InspectorDatabaseResource.h" #include "InspectorFrontend.h" -#include "InspectorFrontendHost.h" #include "InspectorResource.h" #include "InspectorWorkerResource.h" #include "InspectorTimelineAgent.h" @@ -144,10 +144,8 @@ static unsigned s_inspectorControllerCount; InspectorController::InspectorController(Page* page, InspectorClient* client) : m_inspectedPage(page) , m_client(client) - , m_page(0) + , m_openingFrontend(false) , m_expiredConsoleMessageCount(0) - , m_frontendScriptState(0) - , m_windowVisible(false) , m_showAfterVisible(CurrentPanel) , m_groupLevel(0) , m_searchingForNode(false) @@ -155,7 +153,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* client) , m_resourceTrackingEnabled(false) , m_resourceTrackingSettingsLoaded(false) , m_inspectorBackend(InspectorBackend::create(this)) - , m_inspectorFrontendHost(InspectorFrontendHost::create(this, client)) , m_injectedScriptHost(InjectedScriptHost::create(this)) #if ENABLE(JAVASCRIPT_DEBUGGER) , m_debuggerEnabled(false) @@ -178,9 +175,7 @@ InspectorController::~InspectorController() { // These should have been cleared in inspectedPageDestroyed(). ASSERT(!m_client); - ASSERT(!m_frontendScriptState); ASSERT(!m_inspectedPage); - ASSERT(!m_page || (m_page && !m_page->parentInspectorController())); deleteAllValues(m_frameResources); deleteAllValues(m_consoleMessages); @@ -191,18 +186,14 @@ InspectorController::~InspectorController() releaseDOMAgent(); m_inspectorBackend->disconnectController(); - m_inspectorFrontendHost->disconnectController(); m_injectedScriptHost->disconnectController(); } void InspectorController::inspectedPageDestroyed() { - close(); + if (m_frontend) + m_frontend->inspectedPageDestroyed(); - if (m_frontendScriptState) { - ScriptGlobalObject::remove(m_frontendScriptState, "InspectorBackend"); - ScriptGlobalObject::remove(m_frontendScriptState, "InspectorFrontendHost"); - } ASSERT(m_inspectedPage); m_inspectedPage = 0; @@ -297,47 +288,7 @@ void InspectorController::hideHighlight() bool InspectorController::windowVisible() { - return m_windowVisible; -} - -void InspectorController::setWindowVisible(bool visible, bool attached) -{ - if (visible == m_windowVisible || !m_frontend) - return; - - m_windowVisible = visible; - - if (m_windowVisible) { - setAttachedWindow(attached); - populateScriptObjects(); - - if (m_showAfterVisible == CurrentPanel) { - String lastActivePanelSetting = setting(lastActivePanelSettingName); - m_showAfterVisible = specialPanelForJSName(lastActivePanelSetting); - } - - if (m_nodeToFocus) - focusNode(); -#if ENABLE(JAVASCRIPT_DEBUGGER) - if (m_attachDebuggerWhenShown) - enableDebugger(); -#endif - showPanel(m_showAfterVisible); - } else { -#if ENABLE(JAVASCRIPT_DEBUGGER) - // If the window is being closed with the debugger enabled, - // remember this state to re-enable debugger on the next window - // opening. - bool debuggerWasEnabled = m_debuggerEnabled; - disableDebugger(); - if (debuggerWasEnabled) - m_attachDebuggerWhenShown = true; -#endif - setSearchingForNode(false); - resetScriptObjects(); - stopTimelineProfiler(); - } - m_showAfterVisible = CurrentPanel; + return m_frontend; } void InspectorController::addMessageToConsole(MessageSource source, MessageType type, MessageLevel level, ScriptCallStack* callStack) @@ -370,7 +321,7 @@ void InspectorController::addConsoleMessage(ScriptState* scriptState, ConsoleMes m_previousMessage = consoleMessage; m_consoleMessages.append(consoleMessage); if (windowVisible()) - m_previousMessage->addToConsole(m_frontend.get()); + m_previousMessage->addToFrontend(m_frontend.get(), m_injectedScriptHost.get()); } if (!windowVisible() && m_consoleMessages.size() >= maximumConsoleMessages) { @@ -418,69 +369,6 @@ void InspectorController::markTimeline(const String& message) timelineAgent()->didMarkTimeline(message); } -static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight) -{ - return roundf(max(minimumAttachedHeight, min(preferredHeight, totalWindowHeight * maximumAttachedHeightRatio))); -} - -bool InspectorController::canAttachWindow() const -{ - if (!enabled()) - return false; - - unsigned inspectedPageHeight = m_inspectedPage->mainFrame()->view()->visibleHeight(); - - // Don't allow the attach if the window would be too small to accommodate the minimum inspector height. - return minimumAttachedHeight <= inspectedPageHeight * maximumAttachedHeightRatio; -} - -void InspectorController::attachWindow() -{ - if (!enabled()) - return; - - unsigned inspectedPageHeight = m_inspectedPage->mainFrame()->view()->visibleHeight(); - - String attachedHeight = setting(inspectorAttachedHeightName); - bool success = true; - int height = attachedHeight.toInt(&success); - unsigned preferredHeight = success ? height : defaultAttachedHeight; - - m_client->attachWindow(); - - // 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() -{ - if (!enabled()) - return; - m_client->detachWindow(); -} - -void InspectorController::setAttachedWindow(bool attached) -{ - if (!enabled() || !m_frontend) - return; - - m_frontend->setAttachedWindow(attached); -} - -void InspectorController::setAttachedWindowHeight(unsigned height) -{ - if (!enabled()) - return; - - unsigned totalHeight = m_page->mainFrame()->view()->visibleHeight() + m_inspectedPage->mainFrame()->view()->visibleHeight(); - unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight); - - setSetting(inspectorAttachedHeightName, String::number(attachedHeight)); - - m_client->setAttachedWindowHeight(attachedHeight); -} - void InspectorController::storeLastActivePanel(const String& panelName) { setSetting(lastActivePanelSettingName, panelName); @@ -512,23 +400,22 @@ void InspectorController::handleMousePressOnNode(Node* node) inspect(node); } -void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) +void InspectorController::setInspectorFrontendClient(PassOwnPtr client) { - if (!enabled() || !m_frontend || frame != m_inspectedPage->mainFrame()) - return; - m_injectedScriptHost->discardInjectedScripts(); + ASSERT(!m_inspectorFrontendClient); + m_inspectorFrontendClient = client; } -void InspectorController::windowScriptObjectAvailable() +void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame) { - if (!m_page || !enabled()) - return; + // If the page is supposed to serve as InspectorFrontend notify inspetor frontend + // client that it's cleared so that the client can expose inspector bindings. + if (m_inspectorFrontendClient && frame == m_inspectedPage->mainFrame()) + m_inspectorFrontendClient->windowObjectCleared(); - // Grant the inspector the ability to script the inspected page. - m_page->mainFrame()->document()->securityOrigin()->grantUniversalAccess(); - m_frontendScriptState = scriptStateFromPage(debuggerWorld(), m_page); - ScriptGlobalObject::set(m_frontendScriptState, "InspectorBackend", m_inspectorBackend.get()); - ScriptGlobalObject::set(m_frontendScriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get()); + if (!enabled() || !m_frontend || frame != m_inspectedPage->mainFrame()) + return; + m_injectedScriptHost->discardInjectedScripts(); } void InspectorController::setSearchingForNode(bool enabled) @@ -546,18 +433,16 @@ void InspectorController::setSearchingForNode(bool enabled) } } -void InspectorController::scriptObjectReady() +void InspectorController::setFrontend(PassOwnPtr frontend) { - ASSERT(m_frontendScriptState); - if (!m_frontendScriptState) - return; - - ScriptObject webInspectorObj; - if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) - return; - setFrontendProxyObject(m_frontendScriptState, webInspectorObj); - -#if ENABLE(JAVASCRIPT_DEBUGGER) + ASSERT(frontend); + m_openingFrontend = false; + m_frontend = frontend; + releaseDOMAgent(); + m_domAgent = InspectorDOMAgent::create(m_frontend.get()); + if (m_timelineAgent) + m_timelineAgent->resetFrontendProxyObject(m_frontend.get()); +#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) String debuggerEnabled = setting(debuggerEnabledSettingName); if (debuggerEnabled == "true") enableDebugger(); @@ -566,48 +451,36 @@ void InspectorController::scriptObjectReady() enableProfiler(); #endif - // If no preference is set - default to an attached window. This is important for inspector LayoutTests. - String shouldAttachValue = setting(inspectorStartsAttachedSettingName()); - bool shouldAttach = shouldAttachValue != "false"; + populateScriptObjects(); - if (shouldAttach && !canAttachWindow()) - shouldAttach = false; - - // Make sure our window is visible now that the page loaded - setWindowVisible(true, shouldAttach); - - m_client->inspectorWindowObjectCleared(); -} - -void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject) -{ - m_frontendScriptState = scriptState; - m_frontend.set(new InspectorFrontend(this, webInspectorObj)); - releaseDOMAgent(); - m_domAgent = InspectorDOMAgent::create(m_frontend.get()); - if (m_timelineAgent) - m_timelineAgent->resetFrontendProxyObject(m_frontend.get()); + if (m_showAfterVisible == CurrentPanel) { + String lastActivePanelSetting = setting(lastActivePanelSettingName); + m_showAfterVisible = specialPanelForJSName(lastActivePanelSetting); + } + + if (m_nodeToFocus) + focusNode(); +#if ENABLE(JAVASCRIPT_DEBUGGER) + if (m_attachDebuggerWhenShown) + enableDebugger(); +#endif + showPanel(m_showAfterVisible); } void InspectorController::show() { if (!enabled()) return; - - if (!m_page) { - if (m_frontend) - return; // We are using custom frontend - no need to create page. - - m_page = m_client->createPage(); - if (!m_page) - return; - m_page->setParentInspectorController(this); - // showWindow() will be called after the page loads in scriptObjectReady() + if (m_openingFrontend) return; + + if (m_frontend) + m_frontend->bringToFront(); + else { + m_openingFrontend = true; + m_client->openInspectorFrontend(this); } - - showWindow(); } void InspectorController::showPanel(SpecialPanels panel) @@ -630,49 +503,40 @@ void InspectorController::showPanel(SpecialPanels panel) void InspectorController::close() { - if (!enabled()) + if (!m_frontend) return; - -#if ENABLE(JAVASCRIPT_DEBUGGER) - stopUserInitiatedProfiling(); - disableDebugger(); -#endif - closeWindow(); - - releaseDOMAgent(); - m_frontend.set(0); - m_timelineAgent = 0; - m_frontendScriptState = 0; - if (m_page) { - if (!m_page->mainFrame() || !m_page->mainFrame()->loader() || !m_page->mainFrame()->loader()->isLoading()) { - m_page->setParentInspectorController(0); - m_page = 0; - } - } + m_frontend->close(); } -void InspectorController::showWindow() +void InspectorController::disconnectFrontend() { - ASSERT(enabled()); + if (!m_frontend) + return; + m_frontend.clear(); - unsigned inspectedPageHeight = m_inspectedPage->mainFrame()->view()->visibleHeight(); +#if ENABLE(JAVASCRIPT_DEBUGGER) + // If the window is being closed with the debugger enabled, + // remember this state to re-enable debugger on the next window + // opening. + bool debuggerWasEnabled = m_debuggerEnabled; + disableDebugger(); + if (debuggerWasEnabled) + m_attachDebuggerWhenShown = true; +#endif + setSearchingForNode(false); + resetScriptObjects(); + stopTimelineProfiler(); - m_client->showWindow(); + m_showAfterVisible = CurrentPanel; - String attachedHeight = setting(inspectorAttachedHeightName); - bool success = true; - int height = attachedHeight.toInt(&success); - unsigned preferredHeight = success ? height : defaultAttachedHeight; + hideHighlight(); - // 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)); -} +#if ENABLE(JAVASCRIPT_DEBUGGER) + stopUserInitiatedProfiling(); +#endif -void InspectorController::closeWindow() -{ - m_client->closeWindow(); + releaseDOMAgent(); + m_timelineAgent.clear(); } void InspectorController::releaseDOMAgent() @@ -681,7 +545,7 @@ void InspectorController::releaseDOMAgent() // no references to the DOM agent from the DOM tree. if (m_domAgent) m_domAgent->reset(); - m_domAgent = 0; + m_domAgent.clear(); } void InspectorController::populateScriptObjects() @@ -715,7 +579,7 @@ void InspectorController::populateScriptObjects() m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount); unsigned messageCount = m_consoleMessages.size(); for (unsigned i = 0; i < messageCount; ++i) - m_consoleMessages[i]->addToConsole(m_frontend.get()); + m_consoleMessages[i]->addToFrontend(m_frontend.get(), m_injectedScriptHost.get()); #if ENABLE(JAVASCRIPT_DEBUGGER) if (m_debuggerEnabled) @@ -750,10 +614,6 @@ void InspectorController::resetScriptObjects() if (!m_frontend) return; - ResourcesMap::iterator resourcesEnd = m_resources.end(); - for (ResourcesMap::iterator it = m_resources.begin(); it != resourcesEnd; ++it) - it->second->releaseScriptObject(m_frontend.get(), false); - #if ENABLE(DATABASE) DatabaseResourcesMap::iterator databasesEnd = m_databaseResources.end(); for (DatabaseResourcesMap::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it) @@ -787,8 +647,8 @@ void InspectorController::pruneResources(ResourcesMap* resourceMap, DocumentLoad if (!loaderToKeep || !resource->isSameLoader(loaderToKeep)) { removeResource(resource); - if (windowVisible()) - resource->releaseScriptObject(m_frontend.get(), true); + if (m_frontend) + resource->releaseScriptObject(m_frontend.get()); } } } @@ -801,7 +661,8 @@ void InspectorController::didCommitLoad(DocumentLoader* loader) ASSERT(m_inspectedPage); if (loader->frame() == m_inspectedPage->mainFrame()) { - m_client->inspectedURLChanged(loader->url().string()); + if (m_frontend) + m_frontend->inspectedURLChanged(loader->url().string()); m_injectedScriptHost->discardInjectedScripts(); clearConsoleMessages(); @@ -1437,16 +1298,6 @@ InspectorDOMStorageResource* InspectorController::getDOMStorageResourceForId(int } #endif -void InspectorController::moveWindowBy(float x, float y) const -{ - if (!m_page || !enabled()) - return; - - FloatRect frameRect = m_page->chrome()->windowRect(); - frameRect.move(x, y); - m_page->chrome()->setWindowRect(frameRect); -} - #if ENABLE(JAVASCRIPT_DEBUGGER) void InspectorController::addProfile(PassRefPtr prpProfile, unsigned lineNumber, const String& sourceURL) { @@ -1499,7 +1350,7 @@ void InspectorController::getProfile(long callId, unsigned uid) ProfilesMap::iterator it = m_profiles.find(uid); #if USE(JSC) if (it != m_profiles.end()) - m_frontend->didGetProfile(callId, toJS(m_frontendScriptState, it->second.get())); + m_frontend->didGetProfile(callId, toJS(m_frontend->scriptState(), it->second.get())); #endif } @@ -1636,7 +1487,7 @@ void InspectorController::enableDebugger() if (m_debuggerEnabled) return; - if (!m_frontendScriptState || !m_frontend) + if (!m_frontend) m_attachDebuggerWhenShown = true; else { m_frontend->attachDebuggerWhenShown(); diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h index ead4d5e627d3..0ca9d17537dd 100644 --- a/WebCore/inspector/InspectorController.h +++ b/WebCore/inspector/InspectorController.h @@ -66,7 +66,7 @@ class InjectedScriptHost; class InspectorBackend; class InspectorClient; class InspectorFrontend; -class InspectorFrontendHost; +class InspectorFrontendClient; class InspectorTimelineAgent; class JavaScriptCallFrame; class KURL; @@ -116,11 +116,9 @@ class InspectorController ~InspectorController(); InspectorBackend* inspectorBackend() { return m_inspectorBackend.get(); } - InspectorFrontendHost* inspectorFrontendHost() { return m_inspectorFrontendHost.get(); } InjectedScriptHost* injectedScriptHost() { return m_injectedScriptHost.get(); } void inspectedPageDestroyed(); - void pageDestroyed() { m_page = 0; } bool enabled() const; @@ -136,28 +134,24 @@ class InspectorController void show(); void showPanel(SpecialPanels); void close(); - - bool windowVisible(); - void setWindowVisible(bool visible = true, bool attached = false); + void disconnectFrontend(); void addMessageToConsole(MessageSource, MessageType, MessageLevel, ScriptCallStack*); void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceID); void clearConsoleMessages(); const Vector& consoleMessages() const { return m_consoleMessages; } - bool canAttachWindow() const; - void attachWindow(); - void detachWindow(); - bool searchingForNodeInPage() const { return m_searchingForNode; } void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags); void handleMousePressOnNode(Node*); + void setInspectorFrontendClient(PassOwnPtr client); + bool hasInspectorFrontendClient() const { return m_inspectorFrontendClient; } + void inspectedWindowScriptObjectCleared(Frame*); - void windowScriptObjectAvailable(); - void setFrontendProxyObject(ScriptState* state, ScriptObject webInspectorObj, ScriptObject injectedScriptObj = ScriptObject()); - ScriptState* frontendScriptState() const { return m_frontendScriptState; } + bool windowVisible(); + void setFrontend(PassOwnPtr); void populateScriptObjects(); void resetScriptObjects(); @@ -263,19 +257,13 @@ class InspectorController static const String& frontendSettingsSettingName(); friend class InspectorBackend; - friend class InspectorFrontendHost; friend class InjectedScriptHost; // Following are used from InspectorBackend and internally. - void setSearchingForNode(bool enabled); - void scriptObjectReady(); - void moveWindowBy(float x, float y) const; - void setAttachedWindow(bool); - void setAttachedWindowHeight(unsigned height); + // Following are used from InspectorBackend and internally. void storeLastActivePanel(const String& panelName); - void closeWindow(); InspectorDOMAgent* domAgent() { return m_domAgent.get(); } void releaseDOMAgent(); @@ -316,8 +304,6 @@ class InspectorController void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0); void removeAllResources(ResourcesMap* map) { pruneResources(map); } - void showWindow(); - bool isMainResourceLoader(DocumentLoader* loader, const KURL& requestUrl); SpecialPanels specialPanelForJSName(const String& panelName); @@ -326,10 +312,11 @@ class InspectorController Page* m_inspectedPage; InspectorClient* m_client; + OwnPtr m_inspectorFrontendClient; + bool m_openingFrontend; OwnPtr m_frontend; RefPtr m_domAgent; OwnPtr m_timelineAgent; - Page* m_page; RefPtr m_nodeToFocus; RefPtr m_mainResource; ResourcesMap m_resources; @@ -345,8 +332,6 @@ class InspectorController #if ENABLE(DOM_STORAGE) DOMStorageResourcesMap m_domStorageResources; #endif - ScriptState* m_frontendScriptState; - bool m_windowVisible; SpecialPanels m_showAfterVisible; RefPtr m_highlightedNode; unsigned m_groupLevel; @@ -355,7 +340,6 @@ class InspectorController bool m_resourceTrackingEnabled; bool m_resourceTrackingSettingsLoaded; RefPtr m_inspectorBackend; - RefPtr m_inspectorFrontendHost; RefPtr m_injectedScriptHost; typedef HashMap Settings; diff --git a/WebCore/inspector/InspectorFrontend.cpp b/WebCore/inspector/InspectorFrontend.cpp index 54a44144a14d..74bd8a2c7bd4 100755 --- a/WebCore/inspector/InspectorFrontend.cpp +++ b/WebCore/inspector/InspectorFrontend.cpp @@ -49,9 +49,8 @@ namespace WebCore { -InspectorFrontend::InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector) - : m_inspectorController(inspectorController) - , m_webInspector(webInspector) +InspectorFrontend::InspectorFrontend(ScriptObject webInspector) + : m_webInspector(webInspector) { } @@ -60,6 +59,18 @@ InspectorFrontend::~InspectorFrontend() m_webInspector = ScriptObject(); } +void InspectorFrontend::close() +{ + ScriptFunctionCall function(m_webInspector, "close"); + function.call(); +} + +void InspectorFrontend::inspectedPageDestroyed() +{ + ScriptFunctionCall function(m_webInspector, "inspectedPageDestroyed"); + function.call(); +} + ScriptArray InspectorFrontend::newScriptArray() { return ScriptArray::createNew(scriptState()); @@ -91,7 +102,7 @@ void InspectorFrontend::updateConsoleMessageExpiredCount(unsigned count) function.call(); } -void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector& frames, ScriptState* scriptState, const Vector arguments, const String& message) +void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const Vector& frames, const Vector >& arguments, const String& message) { ScriptFunctionCall function(m_webInspector, "dispatch"); function.appendArgument("addConsoleMessage"); @@ -100,10 +111,8 @@ void InspectorFrontend::addConsoleMessage(const ScriptObject& messageObj, const for (unsigned i = 0; i < frames.size(); ++i) function.appendArgument(frames[i]); } else if (!arguments.isEmpty()) { - InjectedScript injectedScript = m_inspectorController->injectedScriptHost()->injectedScriptFor(scriptState); for (unsigned i = 0; i < arguments.size(); ++i) { - RefPtr serializedValue = injectedScript.wrapForConsole(arguments[i]); - ScriptValue scriptValue = ScriptValue::deserialize(this->scriptState(), serializedValue.get()); + ScriptValue scriptValue = ScriptValue::deserialize(scriptState(), arguments[i].get()); if (scriptValue.hasNoValue()) { ASSERT_NOT_REACHED(); return; @@ -220,6 +229,19 @@ void InspectorFrontend::reset() callSimpleFunction("reset"); } +void InspectorFrontend::bringToFront() +{ + callSimpleFunction("bringToFront"); +} + +void InspectorFrontend::inspectedURLChanged(const String& url) +{ + ScriptFunctionCall function(m_webInspector, "dispatch"); + function.appendArgument("inspectedURLChanged"); + function.appendArgument(url); + function.call(); +} + void InspectorFrontend::resourceTrackingWasEnabled() { callSimpleFunction("resourceTrackingWasEnabled"); diff --git a/WebCore/inspector/InspectorFrontend.h b/WebCore/inspector/InspectorFrontend.h index 61c1a8c3b4be..17c4c8b25d4c 100644 --- a/WebCore/inspector/InspectorFrontend.h +++ b/WebCore/inspector/InspectorFrontend.h @@ -49,8 +49,11 @@ namespace WebCore { class InspectorFrontend : public Noncopyable { public: - InspectorFrontend(InspectorController* inspectorController, ScriptObject webInspector); + InspectorFrontend(ScriptObject webInspector); ~InspectorFrontend(); + + void close(); + void inspectedPageDestroyed(); ScriptArray newScriptArray(); ScriptObject newScriptObject(); @@ -60,7 +63,7 @@ namespace WebCore { void populateFrontendSettings(const String& settings); void updateConsoleMessageExpiredCount(unsigned count); - void addConsoleMessage(const ScriptObject& messageObj, const Vector& frames, ScriptState*, const Vector arguments, const String& message); + void addConsoleMessage(const ScriptObject& messageObj, const Vector& frames, const Vector >& arguments, const String& message); void updateConsoleMessageRepeatCount(unsigned count); void clearConsoleMessages(); @@ -73,6 +76,9 @@ namespace WebCore { void showPanel(int panel); void populateInterface(); void reset(); + + void bringToFront(); + void inspectedURLChanged(const String&); void resourceTrackingWasEnabled(); void resourceTrackingWasDisabled(); diff --git a/WebCore/inspector/InspectorFrontendClient.h b/WebCore/inspector/InspectorFrontendClient.h new file mode 100644 index 000000000000..058346b2b154 --- /dev/null +++ b/WebCore/inspector/InspectorFrontendClient.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 InspectorFrontendClient_h +#define InspectorFrontendClient_h + +#include + +namespace WebCore { + +class ContextMenuItem; +class Event; +class String; + +class InspectorFrontendClient { +public: + virtual ~InspectorFrontendClient() { } + + virtual void windowObjectCleared() = 0; + virtual void frontendLoaded() = 0; + + virtual void moveWindowBy(float x, float y) = 0; + + virtual String localizedStringsURL() = 0; + virtual String hiddenPanels() = 0; + + virtual void bringToFront() = 0; + virtual void closeWindow() = 0; + + virtual bool canAttachWindow() = 0; + virtual void attachWindow() = 0; + virtual void detachWindow() = 0; + virtual void changeAttachedWindowHeight(unsigned) = 0; + + virtual void inspectedURLChanged(const String&) = 0; + + virtual void showContextMenu(Event*, const Vector&) = 0; +}; + +} // namespace WebCore + +#endif diff --git a/WebCore/inspector/InspectorFrontendClientLocal.cpp b/WebCore/inspector/InspectorFrontendClientLocal.cpp new file mode 100644 index 000000000000..1888fbd078a4 --- /dev/null +++ b/WebCore/inspector/InspectorFrontendClientLocal.cpp @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 "InspectorFrontendClientLocal.h" + +#if ENABLE(INSPECTOR) + +#include "Chrome.h" +#include "ContextMenu.h" +#include "ContextMenuController.h" +#include "ContextMenuItem.h" +#include "ContextMenuProvider.h" +#include "FloatRect.h" +#include "Frame.h" +#include "FrameView.h" +#include "InspectorController.h" +#include "InspectorFrontend.h" +#include "InspectorFrontendHost.h" +#include "Page.h" +#include "PlatformString.h" +#include "ScriptFunctionCall.h" +#include "ScriptObject.h" + +namespace WebCore { + +class FrontendMenuProvider : public ContextMenuProvider { +public: + static PassRefPtr create(InspectorFrontendClientLocal* frontendClient, ScriptObject webInspector, const Vector& items) + { + return adoptRef(new FrontendMenuProvider(frontendClient, webInspector, items)); + } + + void disconnect() + { + m_webInspector = ScriptObject(); + m_frontendClient = 0; + } + +private: + FrontendMenuProvider(InspectorFrontendClientLocal* frontendClient, ScriptObject webInspector, const Vector& items) + : m_frontendClient(frontendClient) + , m_webInspector(webInspector) + , m_items(items) + { + } + + virtual ~FrontendMenuProvider() + { + contextMenuCleared(); + } + + virtual void populateContextMenu(ContextMenu* menu) + { + for (size_t i = 0; i < m_items.size(); ++i) + menu->appendItem(*m_items[i]); + } + + virtual void contextMenuItemSelected(ContextMenuItem* item) + { + int itemNumber = item->action() - ContextMenuItemBaseCustomTag; + + ScriptFunctionCall function(m_webInspector, "dispatch"); + function.appendArgument("contextMenuItemSelected"); + function.appendArgument(itemNumber); + function.call(); + } + + virtual void contextMenuCleared() + { + + if (m_frontendClient) { + ScriptFunctionCall function(m_webInspector, "dispatch"); + function.appendArgument("contextMenuCleared"); + function.call(); + + m_frontendClient->m_menuProvider = 0; + } + deleteAllValues(m_items); + m_items.clear(); + } + + InspectorFrontendClientLocal* m_frontendClient; + ScriptObject m_webInspector; + Vector m_items; +}; + +static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight"; +static const unsigned defaultAttachedHeight = 300; +static const float minimumAttachedHeight = 250.0f; +static const float maximumAttachedHeightRatio = 0.75f; + +InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController* inspectorController, Page* frontendPage) + : m_inspectorController(inspectorController) + , m_frontendPage(frontendPage) + , m_frontendScriptState(0) + , m_menuProvider(0) +{ +} + +InspectorFrontendClientLocal::~InspectorFrontendClientLocal() +{ + if (m_frontendHost) + m_frontendHost->disconnectClient(); + if (m_menuProvider) + m_menuProvider->disconnect(); + m_frontendScriptState = 0; + m_frontendPage = 0; + m_inspectorController = 0; +} + +void InspectorFrontendClientLocal::windowObjectCleared() +{ + // Grant the inspector the ability to script the inspected page. + m_frontendPage->mainFrame()->document()->securityOrigin()->grantUniversalAccess(); + // FIXME: don't keep reference to the script state + m_frontendScriptState = scriptStateFromPage(debuggerWorld(), m_frontendPage); + ScriptGlobalObject::set(m_frontendScriptState, "InspectorBackend", m_inspectorController->inspectorBackend()); + m_frontendHost = InspectorFrontendHost::create(this); + ScriptGlobalObject::set(m_frontendScriptState, "InspectorFrontendHost", m_frontendHost.get()); +} + +void InspectorFrontendClientLocal::frontendLoaded() +{ + bringToFront(); + // Create InspectorFrontend and set it to InspectorController. + ASSERT(m_frontendScriptState); + ScriptObject webInspectorObj; + if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) { + ASSERT_NOT_REACHED(); + return; + } + m_inspectorController->setFrontend(new InspectorFrontend(webInspectorObj)); +} + +bool InspectorFrontendClientLocal::canAttachWindow() +{ + unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight(); + + // Don't allow the attach if the window would be too small to accommodate the minimum inspector height. + return minimumAttachedHeight <= inspectedPageHeight * maximumAttachedHeightRatio; +} + +void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height) +{ + unsigned totalHeight = m_frontendPage->mainFrame()->view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight(); + unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight); + m_inspectorController->setSetting(inspectorAttachedHeightName, String::number(attachedHeight)); + setAttachedWindowHeight(attachedHeight); +} + +void InspectorFrontendClientLocal::moveWindowBy(float x, float y) +{ + FloatRect frameRect = m_frontendPage->chrome()->windowRect(); + frameRect.move(x, y); + m_frontendPage->chrome()->setWindowRect(frameRect); +} + +void InspectorFrontendClientLocal::showContextMenu(Event* event, const Vector& items) +{ + ScriptObject webInspectorObj; + if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) { + ASSERT_NOT_REACHED(); + return; + } + + RefPtr menuProvider = FrontendMenuProvider::create(this, webInspectorObj, items); + ContextMenuController* menuController = m_frontendPage->contextMenuController(); + menuController->showContextMenu(event, menuProvider); + m_menuProvider = menuProvider.get(); +} + +void InspectorFrontendClientLocal::setAttachedWindow(bool attached) +{ + ScriptObject webInspectorObj; + if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) { + ASSERT_NOT_REACHED(); + return; + } + ScriptFunctionCall function(webInspectorObj, "dispatch"); + function.appendArgument("setAttachedWindow"); + function.appendArgument(attached); + function.call(); +} + +void InspectorFrontendClientLocal::restoreAttachedWindowHeight() +{ + unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight(); + String attachedHeight = m_inspectorController->setting(inspectorAttachedHeightName); + bool success = true; + int height = attachedHeight.toInt(&success); + unsigned preferredHeight = success ? height : 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 + setAttachedWindowHeight(constrainedAttachedWindowHeight(preferredHeight, inspectedPageHeight)); +} + +unsigned InspectorFrontendClientLocal::constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight) +{ + using namespace std; + return roundf(max(minimumAttachedHeight, min(preferredHeight, totalWindowHeight * maximumAttachedHeightRatio))); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/inspector/InspectorFrontendClientLocal.h b/WebCore/inspector/InspectorFrontendClientLocal.h new file mode 100644 index 000000000000..918c47901e98 --- /dev/null +++ b/WebCore/inspector/InspectorFrontendClientLocal.h @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 InspectorFrontendClientLocal_h +#define InspectorFrontendClientLocal_h + +#include "InspectorFrontendClient.h" +#include "ScriptState.h" +#include + +namespace WebCore { + +class FrontendMenuProvider; +class InspectorController; +class InspectorFrontendHost; +class Page; + +class InspectorFrontendClientLocal : public InspectorFrontendClient, public Noncopyable { +public: + InspectorFrontendClientLocal(InspectorController*, Page*); + virtual ~InspectorFrontendClientLocal(); + + virtual void windowObjectCleared(); + virtual void frontendLoaded(); + + virtual void moveWindowBy(float x, float y); + + virtual bool canAttachWindow(); + virtual void changeAttachedWindowHeight(unsigned); + + virtual void showContextMenu(Event*, const Vector&); + +protected: + virtual void setAttachedWindowHeight(unsigned) = 0; + + void setAttachedWindow(bool); + void restoreAttachedWindowHeight(); + +private: + static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight); + + friend class FrontendMenuProvider; + InspectorController* m_inspectorController; + Page* m_frontendPage; + ScriptState* m_frontendScriptState; + // TODO(yurys): this ref shouldn't be needed. + RefPtr m_frontendHost; + FrontendMenuProvider* m_menuProvider; +}; + +} // namespace WebCore + +#endif diff --git a/WebCore/inspector/InspectorFrontendHost.cpp b/WebCore/inspector/InspectorFrontendHost.cpp index c1a1761a813f..23be44c2c14b 100644 --- a/WebCore/inspector/InspectorFrontendHost.cpp +++ b/WebCore/inspector/InspectorFrontendHost.cpp @@ -41,8 +41,7 @@ #include "FrameLoader.h" #include "HitTestResult.h" #include "HTMLFrameOwnerElement.h" -#include "InspectorClient.h" -#include "InspectorFrontend.h" +#include "InspectorFrontendClient.h" #include "InspectorResource.h" #include "Page.h" #include "Pasteboard.h" @@ -54,65 +53,74 @@ using namespace std; namespace WebCore { -InspectorFrontendHost::InspectorFrontendHost(InspectorController* inspectorController, InspectorClient* client) - : m_inspectorController(inspectorController) - , m_client(client) +InspectorFrontendHost::InspectorFrontendHost(InspectorFrontendClient* client) + : m_client(client) { } InspectorFrontendHost::~InspectorFrontendHost() { - if (m_menuProvider) - m_menuProvider->disconnect(); + ASSERT(!m_client); +} + +void InspectorFrontendHost::disconnectClient() +{ + m_client = 0; } void InspectorFrontendHost::loaded() { - if (m_inspectorController) - m_inspectorController->scriptObjectReady(); + if (m_client) + m_client->frontendLoaded(); } void InspectorFrontendHost::attach() { - if (m_inspectorController) - m_inspectorController->attachWindow(); + if (m_client) + m_client->attachWindow(); } void InspectorFrontendHost::detach() { - if (m_inspectorController) - m_inspectorController->detachWindow(); + if (m_client) + m_client->detachWindow(); } void InspectorFrontendHost::closeWindow() { - if (m_inspectorController) - m_inspectorController->closeWindow(); + if (m_client) { + m_client->closeWindow(); + disconnectClient(); // Disconnect from client. + } +} + +void InspectorFrontendHost::bringToFront() +{ + if (m_client) + m_client->bringToFront(); } -void InspectorFrontendHost::windowUnloading() +void InspectorFrontendHost::inspectedURLChanged(const String& newURL) { - if (m_inspectorController) - m_inspectorController->close(); + if (m_client) + m_client->inspectedURLChanged(newURL); } bool InspectorFrontendHost::canAttachWindow() const { - if (m_inspectorController) - return m_inspectorController->canAttachWindow(); - return false; + return m_client && m_client->canAttachWindow(); } void InspectorFrontendHost::setAttachedWindowHeight(unsigned height) { - if (m_inspectorController) - m_inspectorController->setAttachedWindowHeight(height); + if (m_client) + m_client->changeAttachedWindowHeight(height); } void InspectorFrontendHost::moveWindowBy(float x, float y) const { - if (m_inspectorController) - m_inspectorController->moveWindowBy(x, y); + if (m_client) + m_client->moveWindowBy(x, y); } String InspectorFrontendHost::localizedStringsURL() @@ -161,30 +169,8 @@ void InspectorFrontendHost::copyText(const String& text) void InspectorFrontendHost::showContextMenu(Event* event, const Vector& items) { - if (!m_inspectorController) - return; - if (!m_inspectorController->windowVisible()) - return; - - - m_menuProvider = MenuProvider::create(this, items); - ContextMenuController* menuController = m_inspectorController->m_page->contextMenuController(); - menuController->showContextMenu(event, m_menuProvider); -} - -void InspectorFrontendHost::contextMenuItemSelected(ContextMenuItem* item) -{ - if (m_inspectorController && m_inspectorController->windowVisible()) { - int itemNumber = item->action() - ContextMenuItemBaseCustomTag; - m_inspectorController->m_frontend->contextMenuItemSelected(itemNumber); - } -} - -void InspectorFrontendHost::contextMenuCleared() -{ - m_menuProvider = 0; - if (m_inspectorController && m_inspectorController->windowVisible()) - m_inspectorController->m_frontend->contextMenuCleared(); + if (m_client) + m_client->showContextMenu(event, items); } } // namespace WebCore diff --git a/WebCore/inspector/InspectorFrontendHost.h b/WebCore/inspector/InspectorFrontendHost.h index cbe6a9ba9872..f5ba9d7f7d3b 100644 --- a/WebCore/inspector/InspectorFrontendHost.h +++ b/WebCore/inspector/InspectorFrontendHost.h @@ -43,27 +43,26 @@ namespace WebCore { class ContextMenuItem; class Event; class InspectorClient; +class InspectorFrontendClient; class Node; class InspectorFrontendHost : public RefCounted { public: - static PassRefPtr create(InspectorController* inspectorController, InspectorClient* client) + static PassRefPtr create(InspectorFrontendClient* client) { - return adoptRef(new InspectorFrontendHost(inspectorController, client)); + return adoptRef(new InspectorFrontendHost(client)); } ~InspectorFrontendHost(); - - InspectorController* inspectorController() { return m_inspectorController; } - - void disconnectController() { m_inspectorController = 0; } + void disconnectClient(); void loaded(); void attach(); void detach(); void closeWindow(); - void windowUnloading(); + void bringToFront(); + void inspectedURLChanged(const String&); bool canAttachWindow() const; void setAttachedWindowHeight(unsigned height); @@ -80,59 +79,9 @@ class InspectorFrontendHost : public RefCounted void showContextMenu(Event*, const Vector& items); private: - class MenuProvider : public ContextMenuProvider { - public: - static PassRefPtr create(InspectorFrontendHost* frontendHost, const Vector& items) - { - return adoptRef(new MenuProvider(frontendHost, items)); - } - - virtual ~MenuProvider() - { - contextMenuCleared(); - } - - void disconnect() - { - m_frontendHost = 0; - } - - virtual void populateContextMenu(ContextMenu* menu) - { - for (size_t i = 0; i < m_items.size(); ++i) - menu->appendItem(*m_items[i]); - } - - virtual void contextMenuItemSelected(ContextMenuItem* item) - { - if (m_frontendHost) - m_frontendHost->contextMenuItemSelected(item); - } - - virtual void contextMenuCleared() - { - if (m_frontendHost) - m_frontendHost->contextMenuCleared(); - deleteAllValues(m_items); - m_items.clear(); - } - - private: - MenuProvider(InspectorFrontendHost* frontendHost, const Vector& items) - : m_frontendHost(frontendHost) - , m_items(items) { } - InspectorFrontendHost* m_frontendHost; - Vector m_items; - }; - - InspectorFrontendHost(InspectorController* inspectorController, InspectorClient* client); - - void contextMenuItemSelected(ContextMenuItem*); - void contextMenuCleared(); - - InspectorController* m_inspectorController; - InspectorClient* m_client; - RefPtr m_menuProvider; + InspectorFrontendHost(InspectorFrontendClient* client); + + InspectorFrontendClient* m_client; }; } // namespace WebCore diff --git a/WebCore/inspector/InspectorFrontendHost.idl b/WebCore/inspector/InspectorFrontendHost.idl index 150e9fc7f537..0aef5c43c5f6 100644 --- a/WebCore/inspector/InspectorFrontendHost.idl +++ b/WebCore/inspector/InspectorFrontendHost.idl @@ -36,7 +36,8 @@ module core { void attach(); void detach(); void closeWindow(); - void windowUnloading(); + void bringToFront(); + void inspectedURLChanged(in DOMString newURL); boolean canAttachWindow(); void setAttachedWindowHeight(in unsigned long height); diff --git a/WebCore/inspector/InspectorResource.cpp b/WebCore/inspector/InspectorResource.cpp index b6b6057a2f9a..7a0b46ea495b 100644 --- a/WebCore/inspector/InspectorResource.cpp +++ b/WebCore/inspector/InspectorResource.cpp @@ -213,15 +213,12 @@ void InspectorResource::updateScriptObject(InspectorFrontend* frontend) m_changes.clearAll(); } -void InspectorResource::releaseScriptObject(InspectorFrontend* frontend, bool callRemoveResource) +void InspectorResource::releaseScriptObject(InspectorFrontend* frontend) { m_changes.setAll(); for (size_t i = 0; i < m_redirects.size(); ++i) - m_redirects[i]->releaseScriptObject(frontend, callRemoveResource); - - if (!callRemoveResource) - return; + m_redirects[i]->releaseScriptObject(frontend); frontend->removeResource(m_identifier); } diff --git a/WebCore/inspector/InspectorResource.h b/WebCore/inspector/InspectorResource.h index d347e5cabe8c..9746e1fbde14 100644 --- a/WebCore/inspector/InspectorResource.h +++ b/WebCore/inspector/InspectorResource.h @@ -79,7 +79,7 @@ namespace WebCore { PassRefPtr appendRedirect(unsigned long identifier, const KURL& redirectURL); void updateScriptObject(InspectorFrontend* frontend); - void releaseScriptObject(InspectorFrontend* frontend, bool callRemoveResource); + void releaseScriptObject(InspectorFrontend* frontend); void updateRequest(const ResourceRequest&); void updateResponse(const ResourceResponse&); diff --git a/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/WebCore/inspector/front-end/InspectorFrontendHostStub.js index eff25183447a..545606928c3c 100644 --- a/WebCore/inspector/front-end/InspectorFrontendHostStub.js +++ b/WebCore/inspector/front-end/InspectorFrontendHostStub.js @@ -48,6 +48,11 @@ WebInspector.InspectorFrontendHostStub.prototype = { return "unknown"; }, + bringToFront: function() + { + this._windowVisible = true; + }, + closeWindow: function() { this._windowVisible = false; @@ -87,7 +92,7 @@ WebInspector.InspectorFrontendHostStub.prototype = { return ""; }, - windowUnloading: function() + inspectedURLChanged: function(url) { }, diff --git a/WebCore/inspector/front-end/inspector.js b/WebCore/inspector/front-end/inspector.js index eb40a28a0f8c..1d2c46dee566 100644 --- a/WebCore/inspector/front-end/inspector.js +++ b/WebCore/inspector/front-end/inspector.js @@ -478,7 +478,6 @@ WebInspector.loaded = function() this.addMainEventListeners(document); - window.addEventListener("unload", this.windowUnload.bind(this), true); window.addEventListener("resize", this.windowResize.bind(this), true); document.addEventListener("focus", this.focusChanged.bind(this), true); @@ -562,11 +561,6 @@ WebInspector.dispatch = function() { setTimeout(delayDispatch, 0); } -WebInspector.windowUnload = function(event) -{ - InspectorFrontendHost.windowUnloading(); -} - WebInspector.windowResize = function(event) { if (this.currentPanel) @@ -604,9 +598,17 @@ WebInspector.setAttachedWindow = function(attached) WebInspector.close = function(event) { + if (this._isClosing) + return; + this._isClosing = true; InspectorFrontendHost.closeWindow(); } +WebInspector.inspectedPageDestroyed = function() +{ + WebInspector.close(); +} + WebInspector.documentMouseOver = function(event) { if (event.target.tagName !== "A") @@ -1321,6 +1323,16 @@ WebInspector.reset = function() this.console.clearMessages(); } +WebInspector.bringToFront = function() +{ + InspectorFrontendHost.bringToFront(); +} + +WebInspector.inspectedURLChanged = function(url) +{ + InspectorFrontendHost.inspectedURLChanged(url); +} + WebInspector.resourceURLChanged = function(resource, oldURL) { delete this.resourceURLMap[oldURL]; diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h index a267374a2c17..8bce5296cbdb 100644 --- a/WebCore/loader/EmptyClients.h +++ b/WebCore/loader/EmptyClients.h @@ -471,29 +471,14 @@ class EmptyInspectorClient : public InspectorClient, public Noncopyable { virtual ~EmptyInspectorClient() { } virtual void inspectorDestroyed() { } - - virtual Page* createPage() { return 0; }; - - virtual String localizedStringsURL() { return String(); } - - virtual String hiddenPanels() { return String(); } - - virtual void showWindow() { } - virtual void closeWindow() { } - - virtual void attachWindow() { } - virtual void detachWindow() { } - - virtual void setAttachedWindowHeight(unsigned) { } + + virtual void openInspectorFrontend(InspectorController*) { } virtual void highlight(Node*) { } virtual void hideHighlight() { } - virtual void inspectedURLChanged(const String&) { } virtual void populateSetting(const String&, String*) { } virtual void storeSetting(const String&, const String&) { } - - virtual void inspectorWindowObjectCleared() { } }; } diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 54c7972d1ba4..e10b58f9c45e 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -3944,8 +3944,6 @@ void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* world) if (Page* page = m_frame->page()) { if (InspectorController* inspector = page->inspectorController()) inspector->inspectedWindowScriptObjectCleared(m_frame); - if (InspectorController* inspector = page->parentInspectorController()) - inspector->windowScriptObjectAvailable(); } #endif } diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index 7d1e62444e31..d66e49702aac 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -138,9 +138,6 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi , m_areMemoryCacheClientCallsEnabled(true) , m_mediaVolume(1) , m_javaScriptURLsAreAllowed(true) -#if ENABLE(INSPECTOR) - , m_parentInspectorController(0) -#endif , m_didLoadUserStyleSheet(false) , m_userStyleSheetModificationTime(0) , m_group(0) @@ -196,8 +193,6 @@ Page::~Page() m_editorClient->pageDestroyed(); #if ENABLE(INSPECTOR) - if (m_parentInspectorController) - m_parentInspectorController->pageDestroyed(); m_inspectorController->inspectedPageDestroyed(); #endif diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h index f698287c374f..94e6dd5e555a 100644 --- a/WebCore/page/Page.h +++ b/WebCore/page/Page.h @@ -149,11 +149,6 @@ namespace WebCore { #endif Settings* settings() const { return m_settings.get(); } ProgressTracker* progress() const { return m_progress.get(); } - -#if ENABLE(INSPECTOR) - void setParentInspectorController(InspectorController* controller) { m_parentInspectorController = controller; } - InspectorController* parentInspectorController() const { return m_parentInspectorController; } -#endif void setTabKeyCyclesThroughElements(bool b) { m_tabKeyCyclesThroughElements = b; } bool tabKeyCyclesThroughElements() const { return m_tabKeyCyclesThroughElements; } @@ -286,10 +281,6 @@ namespace WebCore { bool m_javaScriptURLsAreAllowed; -#if ENABLE(INSPECTOR) - InspectorController* m_parentInspectorController; -#endif - String m_userStyleSheetPath; mutable String m_userStyleSheet; mutable bool m_didLoadUserStyleSheet; diff --git a/WebCore/platform/ContextMenu.cpp b/WebCore/platform/ContextMenu.cpp index 283aa565d57e..0022a4738d18 100644 --- a/WebCore/platform/ContextMenu.cpp +++ b/WebCore/platform/ContextMenu.cpp @@ -359,6 +359,9 @@ void ContextMenu::populate() appendItem(SpeechMenuItem); #endif } else { +#if ENABLE(INSPECTOR) + if (!(frame->page() && frame->page()->inspectorController()->hasInspectorFrontendClient())) { +#endif #if PLATFORM(GTK) appendItem(BackItem); appendItem(ForwardItem); @@ -378,6 +381,9 @@ void ContextMenu::populate() else appendItem(ReloadItem); #endif +#if ENABLE(INSPECTOR) + } +#endif if (frame->page() && frame != frame->page()->mainFrame()) appendItem(OpenFrameItem); @@ -550,7 +556,6 @@ void ContextMenu::addInspectElementItem() return; ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElement, contextMenuItemTagInspectElement()); - appendItem(*separatorItem()); appendItem(InspectElementItem); } #endif // ENABLE(INSPECTOR) diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog index eef08cc9e5e9..d215bbf151b7 100644 --- a/WebKit/ChangeLog +++ b/WebKit/ChangeLog @@ -1,3 +1,16 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * efl/WebCoreSupport/InspectorClientEfl.cpp: + (WebCore::InspectorClientEfl::openInspectorFrontend): + * efl/WebCoreSupport/InspectorClientEfl.h: + 2010-03-13 Leandro Pereira Reviewed by Kenneth Rohde Christiansen. diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog index c9851828f807..fd45d2109bb7 100644 --- a/WebKit/chromium/ChangeLog +++ b/WebKit/chromium/ChangeLog @@ -1,3 +1,29 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * src/InspectorClientImpl.cpp: + (WebKit::InspectorClientImpl::openInspectorFrontend): + * src/InspectorClientImpl.h: + * src/WebDevToolsAgentImpl.cpp: + (WebKit::WebDevToolsAgentImpl::attach): + (WebKit::WebDevToolsAgentImpl::didCommitProvisionalLoad): + (WebKit::WebDevToolsAgentImpl::createInspectorFrontendProxy): + (WebKit::WebDevToolsAgentImpl::setInspectorFrontendProxyToInspectorController): + * src/WebDevToolsAgentImpl.h: + * src/WebDevToolsFrontendImpl.cpp: + (WebKit::WebDevToolsFrontendImpl::WebDevToolsFrontendImpl): + (WebKit::WebDevToolsFrontendImpl::jsBringToFront): + (WebKit::WebDevToolsFrontendImpl::jsInspectedURLChanged): + * src/WebDevToolsFrontendImpl.h: + * src/js/InjectDispatch.js: + (close): + 2010-03-16 Pavel Feldman Not reviewed: chromium tests fix. diff --git a/WebKit/chromium/src/InspectorClientImpl.cpp b/WebKit/chromium/src/InspectorClientImpl.cpp index 54550d1a0362..f69ef72a71ad 100644 --- a/WebKit/chromium/src/InspectorClientImpl.cpp +++ b/WebKit/chromium/src/InspectorClientImpl.cpp @@ -63,46 +63,8 @@ void InspectorClientImpl::inspectorDestroyed() // Our lifetime is bound to the WebViewImpl. } -Page* InspectorClientImpl::createPage() +void InspectorClientImpl::openInspectorFrontend(InspectorController*) { - // This method should never be called in Chrome as inspector front-end lives - // in a separate process. - ASSERT_NOT_REACHED(); - return 0; -} - -void InspectorClientImpl::showWindow() -{ - ASSERT(m_inspectedWebView->devToolsAgentPrivate()); - m_inspectedWebView->page()->inspectorController()->setWindowVisible(true); -} - -void InspectorClientImpl::closeWindow() -{ - if (m_inspectedWebView->page()) - m_inspectedWebView->page()->inspectorController()->setWindowVisible(false); -} - -bool InspectorClientImpl::windowVisible() -{ - ASSERT(m_inspectedWebView->devToolsAgentPrivate()); - return false; -} - -void InspectorClientImpl::attachWindow() -{ - // FIXME: Implement this -} - -void InspectorClientImpl::detachWindow() -{ - // FIXME: Implement this -} - -void InspectorClientImpl::setAttachedWindowHeight(unsigned int height) -{ - // FIXME: Implement this - notImplemented(); } static void invalidateNodeBoundingRect(WebViewImpl* webView) @@ -130,23 +92,6 @@ void InspectorClientImpl::hideHighlight() invalidateNodeBoundingRect(m_inspectedWebView); } -void InspectorClientImpl::inspectedURLChanged(const String& newURL) -{ - // FIXME: Implement this -} - -String InspectorClientImpl::localizedStringsURL() -{ - notImplemented(); - return String(); -} - -String InspectorClientImpl::hiddenPanels() -{ - notImplemented(); - return ""; -} - void InspectorClientImpl::populateSetting(const String& key, String* value) { loadSettings(); @@ -161,11 +106,6 @@ void InspectorClientImpl::storeSetting(const String& key, const String& value) saveSettings(); } -void InspectorClientImpl::inspectorWindowObjectCleared() -{ - notImplemented(); -} - void InspectorClientImpl::loadSettings() { if (m_settings) diff --git a/WebKit/chromium/src/InspectorClientImpl.h b/WebKit/chromium/src/InspectorClientImpl.h index 6f7f8b1bf8f3..ccbcef72c059 100644 --- a/WebKit/chromium/src/InspectorClientImpl.h +++ b/WebKit/chromium/src/InspectorClientImpl.h @@ -45,25 +45,15 @@ class InspectorClientImpl : public WebCore::InspectorClient { // InspectorClient methods: virtual void inspectorDestroyed(); - virtual WebCore::Page* createPage(); - virtual WebCore::String localizedStringsURL(); - virtual WebCore::String hiddenPanels(); - virtual void showWindow(); - virtual void closeWindow(); - virtual bool windowVisible(); - virtual void attachWindow(); - virtual void detachWindow(); - virtual void setAttachedWindowHeight(unsigned height); + virtual void openInspectorFrontend(WebCore::InspectorController*); virtual void highlight(WebCore::Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const WebCore::String& newURL); virtual void populateSetting( const WebCore::String& key, WebCore::String* value); virtual void storeSetting( const WebCore::String& key, const WebCore::String& value); - virtual void inspectorWindowObjectCleared(); private: void loadSettings(); diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp index af5062a4595a..21f31f4cbd22 100644 --- a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp +++ b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp @@ -169,7 +169,7 @@ void WebDevToolsAgentImpl::attach() new DebuggerAgentImpl(m_webViewImpl, m_debuggerAgentDelegateStub.get(), this)); - resetInspectorFrontendProxy(); + createInspectorFrontendProxy(); // Allow controller to send messages to the frontend. InspectorController* ic = inspectorController(); @@ -185,7 +185,7 @@ void WebDevToolsAgentImpl::attach() } } - ic->setWindowVisible(true, false); + setInspectorFrontendProxyToInspectorController(); m_attached = true; } @@ -216,7 +216,6 @@ void WebDevToolsAgentImpl::didCommitProvisionalLoad(WebFrameImpl* webframe, bool ds->unreachableURL() : request.url(); if (!webframe->parent()) { - resetInspectorFrontendProxy(); m_toolsAgentDelegateStub->frameNavigate(WebCore::KURL(url).string()); SetApuAgentEnabledInUtilityContext(m_utilityContext, m_apuAgentEnabled); } @@ -357,7 +356,7 @@ v8::Local WebDevToolsAgentImpl::createInspectorBackendV8Wrapper() return instance; } -void WebDevToolsAgentImpl::resetInspectorFrontendProxy() +void WebDevToolsAgentImpl::createInspectorFrontendProxy() { disposeUtilityContext(); m_utilityContext = v8::Context::New(); @@ -368,8 +367,16 @@ void WebDevToolsAgentImpl::resetInspectorFrontendProxy() v8::Context::Scope contextScope(m_utilityContext); ScriptState* state = ScriptState::forContext( v8::Local::New(m_utilityContext)); +} + +void WebDevToolsAgentImpl::setInspectorFrontendProxyToInspectorController() +{ + v8::HandleScope scope; + ScriptState* state = ScriptState::forContext( + v8::Local::New(m_utilityContext)); InspectorController* ic = inspectorController(); - ic->setFrontendProxyObject(state, ScriptObject(state, m_utilityContext->Global())); + ic->setFrontend(new InspectorFrontend( + ScriptObject(state, m_utilityContext->Global()))); } void WebDevToolsAgentImpl::setApuAgentEnabled(bool enabled) diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.h b/WebKit/chromium/src/WebDevToolsAgentImpl.h index 207bada5ed4d..455dcefd6586 100644 --- a/WebKit/chromium/src/WebDevToolsAgentImpl.h +++ b/WebKit/chromium/src/WebDevToolsAgentImpl.h @@ -109,7 +109,8 @@ class WebDevToolsAgentImpl : public WebDevToolsAgentPrivate, void compileUtilityScripts(); void initDevToolsAgentHost(); - void resetInspectorFrontendProxy(); + void createInspectorFrontendProxy(); + void setInspectorFrontendProxyToInspectorController(); void setApuAgentEnabled(bool enabled); WebCore::InspectorController* inspectorController(); diff --git a/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp b/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp index d5b8ebce0b8d..8a2f81cc5a0e 100644 --- a/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp +++ b/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp @@ -156,8 +156,11 @@ WebDevToolsFrontendImpl::WebDevToolsFrontendImpl( "setSetting", WebDevToolsFrontendImpl::jsSetSetting); devToolsHost.addProtoFunction( - "windowUnloading", - WebDevToolsFrontendImpl::jsWindowUnloading); + "bringToFront", + WebDevToolsFrontendImpl::jsBringToFront); + devToolsHost.addProtoFunction( + "inspectedURLChanged", + WebDevToolsFrontendImpl::jsInspectedURLChanged); devToolsHost.addProtoFunction( "showContextMenu", WebDevToolsFrontendImpl::jsShowContextMenu); @@ -346,9 +349,13 @@ v8::Handle WebDevToolsFrontendImpl::jsDebuggerPauseScript(const v8::A return v8::Undefined(); } -v8::Handle WebDevToolsFrontendImpl::jsWindowUnloading(const v8::Arguments& args) +v8::Handle WebDevToolsFrontendImpl::jsBringToFront(const v8::Arguments& args) +{ + return v8::Undefined(); +} + +v8::Handle WebDevToolsFrontendImpl::jsInspectedURLChanged(const v8::Arguments& args) { - // TODO(pfeldman): Implement this. return v8::Undefined(); } diff --git a/WebKit/chromium/src/WebDevToolsFrontendImpl.h b/WebKit/chromium/src/WebDevToolsFrontendImpl.h index ba0013bed0fb..6591693b4ca2 100644 --- a/WebKit/chromium/src/WebDevToolsFrontendImpl.h +++ b/WebKit/chromium/src/WebDevToolsFrontendImpl.h @@ -142,7 +142,8 @@ class WebDevToolsFrontendImpl : public WebKit::WebDevToolsFrontend static v8::Handle jsSetting(const v8::Arguments& args); static v8::Handle jsSetSetting(const v8::Arguments& args); static v8::Handle jsDebuggerPauseScript(const v8::Arguments& args); - static v8::Handle jsWindowUnloading(const v8::Arguments& args); + static v8::Handle jsBringToFront(const v8::Arguments& args); + static v8::Handle jsInspectedURLChanged(const v8::Arguments& args); static v8::Handle jsShowContextMenu(const v8::Arguments& args); static v8::Handle jsCanAttachWindow(const v8::Arguments& args); diff --git a/WebKit/chromium/src/js/InjectDispatch.js b/WebKit/chromium/src/js/InjectDispatch.js index e070c42c90c7..68bcdbdf9070 100644 --- a/WebKit/chromium/src/js/InjectDispatch.js +++ b/WebKit/chromium/src/js/InjectDispatch.js @@ -104,3 +104,7 @@ function dispatch(method, var_args) { var call = JSON.stringify(args); DevToolsAgentHost.dispatch(call); }; + +function close() { + // This method is called when InspectorFrontend closes in layout tests. +} diff --git a/WebKit/efl/WebCoreSupport/InspectorClientEfl.cpp b/WebKit/efl/WebCoreSupport/InspectorClientEfl.cpp index 83c7d8e47ba8..8892d7fb78ba 100644 --- a/WebKit/efl/WebCoreSupport/InspectorClientEfl.cpp +++ b/WebKit/efl/WebCoreSupport/InspectorClientEfl.cpp @@ -33,45 +33,7 @@ void InspectorClientEfl::inspectorDestroyed() delete this; } -Page* InspectorClientEfl::createPage() -{ - notImplemented(); - return 0; -} - -String InspectorClientEfl::localizedStringsURL() -{ - notImplemented(); - return String(); -} - -String InspectorClientEfl::hiddenPanels() -{ - notImplemented(); - return String(); -} - -void InspectorClientEfl::showWindow() -{ - notImplemented(); -} - -void InspectorClientEfl::closeWindow() -{ - notImplemented(); -} - -void InspectorClientEfl::attachWindow() -{ - notImplemented(); -} - -void InspectorClientEfl::detachWindow() -{ - notImplemented(); -} - -void InspectorClientEfl::setAttachedWindowHeight(unsigned) +void InspectorClientEfl::openInspectorFrontend(InspectorController*) { notImplemented(); } @@ -86,16 +48,6 @@ void InspectorClientEfl::hideHighlight() notImplemented(); } -void InspectorClientEfl::inspectedURLChanged(const String&) -{ - notImplemented(); -} - -void InspectorClientEfl::inspectorWindowObjectCleared() -{ - notImplemented(); -} - void InspectorClientEfl::populateSetting(const String&, String*) { notImplemented(); @@ -106,9 +58,4 @@ void InspectorClientEfl::storeSetting(const String&, const String&) notImplemented(); } -void InspectorClientEfl::removeSetting(const String&) -{ - notImplemented(); -} - } diff --git a/WebKit/efl/WebCoreSupport/InspectorClientEfl.h b/WebKit/efl/WebCoreSupport/InspectorClientEfl.h index 853e7bdbce31..30c9caf68dcc 100644 --- a/WebKit/efl/WebCoreSupport/InspectorClientEfl.h +++ b/WebKit/efl/WebCoreSupport/InspectorClientEfl.h @@ -43,28 +43,13 @@ class InspectorClientEfl : public WebCore::InspectorClient { public: virtual void inspectorDestroyed(); - virtual WebCore::Page* createPage(); + virtual void openInspectorFrontend(InspectorController*); - virtual WebCore::String localizedStringsURL(); - - virtual String hiddenPanels(); - - virtual void showWindow(); - virtual void closeWindow(); - - virtual void attachWindow(); - virtual void detachWindow(); - - virtual void setAttachedWindowHeight(unsigned height); - - virtual void highlight(WebCore::Node*); + virtual void highlight(Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const WebCore::String& newURL); - virtual void inspectorWindowObjectCleared(); - virtual void populateSetting(const WebCore::String& key, WebCore::String*); - virtual void storeSetting(const WebCore::String& key, const WebCore::String&); - virtual void removeSetting(const WebCore::String& key); + virtual void populateSetting(const String& key, String* value); + virtual void storeSetting(const String& key, const String& value); }; } diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index 519caa508189..964362cfbf74 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,34 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::notifyWebViewDestroyed): + (WebKit::InspectorClient::InspectorClient): + (WebKit::InspectorClient::inspectorDestroyed): + (WebKit::InspectorClient::openInspectorFrontend): + (WebKit::InspectorClient::highlight): + (WebKit::InspectorClient::hideHighlight): + (WebKit::InspectorClient::populateSetting): + (WebKit::InspectorClient::storeSetting): + (WebKit::InspectorFrontendClient::InspectorFrontendClient): + (WebKit::InspectorFrontendClient::~InspectorFrontendClient): + (WebKit::InspectorFrontendClient::destroyInspectorWindow): + (WebKit::InspectorFrontendClient::localizedStringsURL): + (WebKit::InspectorFrontendClient::hiddenPanels): + (WebKit::InspectorFrontendClient::bringToFront): + (WebKit::InspectorFrontendClient::closeWindow): + (WebKit::InspectorFrontendClient::attachWindow): + (WebKit::InspectorFrontendClient::detachWindow): + (WebKit::InspectorFrontendClient::setAttachedWindowHeight): + (WebKit::InspectorFrontendClient::inspectedURLChanged): + * WebCoreSupport/InspectorClientGtk.h: + 2010-03-15 Joanmarie Diggs Reviewed by Holger Freyther. diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp index 99bc627927e3..775e35079393 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp @@ -31,67 +31,40 @@ using namespace WebCore; namespace WebKit { -static void notifyWebViewDestroyed(WebKitWebView* webView, InspectorClient* inspectorClient) +static void notifyWebViewDestroyed(WebKitWebView* webView, InspectorFrontendClient* inspectorFrontendClient) { - inspectorClient->webViewDestroyed(); + inspectorFrontendClient->destroyInspectorWindow(); } InspectorClient::InspectorClient(WebKitWebView* webView) - : m_webView(0) - , m_inspectedWebView(webView) - , m_webInspector(0) + : m_inspectedWebView(webView) {} void InspectorClient::inspectorDestroyed() { - if (m_webInspector) - g_object_unref(m_webInspector); - delete this; } -void InspectorClient::webViewDestroyed() -{ - m_webView = 0; - core(m_inspectedWebView)->inspectorController()->pageDestroyed(); - - // createPage will be called again, if the user chooses to inspect - // something else, and the inspector will be referenced again, - // there. - g_object_unref(m_webInspector); - m_webInspector = 0; -} - -Page* InspectorClient::createPage() +void InspectorClient::openInspectorFrontend(InspectorController* controller) { - if (m_webView) { - gboolean handled = FALSE; - g_signal_emit_by_name(m_webInspector, "destroy", &handled); - - /* we can now dispose our own reference */ - g_object_unref(m_webInspector); - } - // This g_object_get will ref the inspector. We're not doing an // unref if this method succeeds because the inspector object must // be alive even after the inspected WebView is destroyed - the // close-window and destroy signals still need to be // emitted. - WebKitWebInspector* webInspector; + WebKitWebInspector* webInspector = 0; g_object_get(m_inspectedWebView, "web-inspector", &webInspector, NULL); - m_webInspector = webInspector; + ASSERT(webInspector); - g_signal_emit_by_name(m_webInspector, "inspect-web-view", m_inspectedWebView, &m_webView); + WebKitWebView* inspectorWebView = 0; + g_signal_emit_by_name(webInspector, "inspect-web-view", m_inspectedWebView, &inspectorWebView); - if (!m_webView) { - g_object_unref(m_webInspector); - return 0; + if (!inspectorWebView) { + g_object_unref(webInspector); + return; } - webkit_web_inspector_set_web_view(m_webInspector, m_webView); - - g_signal_connect(m_webView, "destroy", - G_CALLBACK(notifyWebViewDestroyed), (gpointer)this); + webkit_web_inspector_set_web_view(webInspector, inspectorWebView); GOwnPtr inspectorURI; @@ -103,14 +76,73 @@ Page* InspectorClient::createPage() } else inspectorURI.set(g_filename_to_uri(DATA_DIR"/webkit-1.0/webinspector/inspector.html", NULL, NULL)); - webkit_web_view_load_uri(m_webView, inspectorURI.get()); + webkit_web_view_load_uri(inspectorWebView, inspectorURI.get()); + + gtk_widget_show(GTK_WIDGET(inspectorWebView)); + + Page* inspectorPage = core(inspectorWebView); + inspectorPage->inspectorController()->setInspectorFrontendClient(new InspectorFrontendClient(m_inspectedWebView, inspectorWebView, webInspector, inspectorPage)); +} + +void InspectorClient::highlight(Node* node) +{ + notImplemented(); +} + +void InspectorClient::hideHighlight() +{ + notImplemented(); +} + +void InspectorClient::populateSetting(const String& key, String* value) +{ + notImplemented(); +} + +void InspectorClient::storeSetting(const String& key, const String& value) +{ + notImplemented(); +} + + +bool destroyed = TRUE; + +InspectorFrontendClient::InspectorFrontendClient(WebKitWebView* inspectedWebView, WebKitWebView* inspectorWebView, WebKitWebInspector* webInspector, Page* inspectorPage) + : InspectorFrontendClientLocal(core(inspectedWebView)->inspectorController(), inspectorPage) + , m_inspectorWebView(inspectorWebView) + , m_inspectedWebView(inspectedWebView) + , m_webInspector(webInspector) +{ + g_signal_connect(m_inspectorWebView, "destroy", + G_CALLBACK(notifyWebViewDestroyed), (gpointer)this); +} + +InspectorFrontendClient::~InspectorFrontendClient() +{ + ASSERT(!m_webInspector); +} + +void InspectorFrontendClient::destroyInspectorWindow() +{ + if (!m_webInspector) + return; + WebKitWebInspector* webInspector = m_webInspector; + m_webInspector = 0; + + g_signal_handlers_disconnect_by_func(m_inspectorWebView, (gpointer)notifyWebViewDestroyed, (gpointer)this); + m_inspectorWebView = 0; + + core(m_inspectedWebView)->inspectorController()->disconnectFrontend(); - gtk_widget_show(GTK_WIDGET(m_webView)); + gboolean handled = FALSE; + g_signal_emit_by_name(webInspector, "close-window", &handled); + ASSERT(handled); - return core(m_webView); + /* we should now dispose our own reference */ + g_object_unref(webInspector); } -String InspectorClient::localizedStringsURL() +String InspectorFrontendClient::localizedStringsURL() { GOwnPtr URL; @@ -126,89 +158,56 @@ String InspectorClient::localizedStringsURL() return String::fromUTF8(URL.get()); } -String InspectorClient::hiddenPanels() +String InspectorFrontendClient::hiddenPanels() { notImplemented(); return String(); } -void InspectorClient::showWindow() +void InspectorFrontendClient::bringToFront() { - if (!m_webView) + if (!m_inspectorWebView) return; gboolean handled = FALSE; g_signal_emit_by_name(m_webInspector, "show-window", &handled); - - core(m_inspectedWebView)->inspectorController()->setWindowVisible(true); } -void InspectorClient::closeWindow() +void InspectorFrontendClient::closeWindow() { - if (!m_webView) - return; - - gboolean handled = FALSE; - g_signal_emit_by_name(m_webInspector, "close-window", &handled); - - core(m_inspectedWebView)->inspectorController()->setWindowVisible(false); + destroyInspectorWindow(); } -void InspectorClient::attachWindow() +void InspectorFrontendClient::attachWindow() { - if (!m_webView) + if (!m_inspectorWebView) return; gboolean handled = FALSE; g_signal_emit_by_name(m_webInspector, "attach-window", &handled); } -void InspectorClient::detachWindow() +void InspectorFrontendClient::detachWindow() { - if (!m_webView) + if (!m_inspectorWebView) return; gboolean handled = FALSE; g_signal_emit_by_name(m_webInspector, "detach-window", &handled); } -void InspectorClient::setAttachedWindowHeight(unsigned height) -{ - notImplemented(); -} - -void InspectorClient::highlight(Node* node) -{ - notImplemented(); -} - -void InspectorClient::hideHighlight() +void InspectorFrontendClient::setAttachedWindowHeight(unsigned height) { notImplemented(); } -void InspectorClient::inspectedURLChanged(const String& newURL) +void InspectorFrontendClient::inspectedURLChanged(const String& newURL) { - if (!m_webView) + if (!m_inspectorWebView) return; webkit_web_inspector_set_inspected_uri(m_webInspector, newURL.utf8().data()); } -void InspectorClient::inspectorWindowObjectCleared() -{ - notImplemented(); -} - -void InspectorClient::populateSetting(const String& key, String* value) -{ - notImplemented(); -} - -void InspectorClient::storeSetting(const String& key, const String& value) -{ - notImplemented(); -} - } diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h index 297fd8f8a7b2..cdb537573b8e 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h @@ -30,6 +30,7 @@ #define InspectorClientGtk_h #include "InspectorClient.h" +#include "InspectorFrontendClientLocal.h" #include "webkitwebview.h" #include "webkitwebinspector.h" @@ -46,15 +47,30 @@ namespace WebKit { InspectorClient(WebKitWebView* webView); virtual void inspectorDestroyed(); - void webViewDestroyed(); - virtual WebCore::Page* createPage(); + virtual void openInspectorFrontend(WebCore::InspectorController*); + + virtual void highlight(WebCore::Node*); + virtual void hideHighlight(); + + virtual void populateSetting(const WebCore::String& key, WebCore::String* value); + virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); + + private: + WebKitWebView* m_inspectedWebView; + }; + + class InspectorFrontendClient : public WebCore::InspectorFrontendClientLocal { + public: + InspectorFrontendClient(WebKitWebView* inspectedWebView, WebKitWebView* inspectorWebView, WebKitWebInspector* webInspector, WebCore::Page* inspectorPage); + + void destroyInspectorWindow(); virtual WebCore::String localizedStringsURL(); virtual WebCore::String hiddenPanels(); - virtual void showWindow(); + virtual void bringToFront(); virtual void closeWindow(); virtual void attachWindow(); @@ -62,17 +78,12 @@ namespace WebKit { virtual void setAttachedWindowHeight(unsigned height); - virtual void highlight(WebCore::Node*); - virtual void hideHighlight(); virtual void inspectedURLChanged(const WebCore::String& newURL); - virtual void populateSetting(const WebCore::String& key, WebCore::String* value); - virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); - - virtual void inspectorWindowObjectCleared(); - private: - WebKitWebView* m_webView; + virtual ~InspectorFrontendClient(); + + WebKitWebView* m_inspectorWebView; WebKitWebView* m_inspectedWebView; WebKitWebInspector* m_webInspector; }; diff --git a/WebKit/haiku/ChangeLog b/WebKit/haiku/ChangeLog index 1c6870a52367..2118b67c21cb 100644 --- a/WebKit/haiku/ChangeLog +++ b/WebKit/haiku/ChangeLog @@ -1,3 +1,16 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * WebCoreSupport/InspectorClientHaiku.cpp: + (WebCore::InspectorClientHaiku::openInspectorFrontend): + * WebCoreSupport/InspectorClientHaiku.h: + 2010-03-11 Anders Carlsson Reviewed by David Hyatt. diff --git a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp index f06e96bff12a..59232e9419c4 100644 --- a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp +++ b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.cpp @@ -42,45 +42,7 @@ void InspectorClientHaiku::inspectorDestroyed() notImplemented(); } -Page* InspectorClientHaiku::createPage() -{ - notImplemented(); - return 0; -} - -String InspectorClientHaiku::localizedStringsURL() -{ - notImplemented(); - return String(); -} - -String InspectorClientHaiku::hiddenPanels() -{ - notImplemented(); - return String(); -} - -void InspectorClientHaiku::showWindow() -{ - notImplemented(); -} - -void InspectorClientHaiku::closeWindow() -{ - notImplemented(); -} - -void InspectorClientHaiku::attachWindow() -{ - notImplemented(); -} - -void InspectorClientHaiku::detachWindow() -{ - notImplemented(); -} - -void InspectorClientHaiku::setAttachedWindowHeight(unsigned height) +void InspectorClientHaiku::openInspectorFrontend(WebCore::InspectorController*) { notImplemented(); } @@ -95,16 +57,6 @@ void InspectorClientHaiku::hideHighlight() notImplemented(); } -void InspectorClientHaiku::inspectedURLChanged(const String&) -{ - notImplemented(); -} - -void InspectorClientHaiku::inspectorWindowObjectCleared() -{ - notImplemented(); -} - void InspectorClientHaiku::populateSetting(const String& key, String* value) { notImplemented(); diff --git a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h index 8788a5fab3b5..d427670d11b0 100644 --- a/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h +++ b/WebKit/haiku/WebCoreSupport/InspectorClientHaiku.h @@ -42,29 +42,13 @@ namespace WebCore { public: virtual void inspectorDestroyed(); - virtual Page* createPage(); - - virtual String localizedStringsURL(); - - virtual String hiddenPanels(); - - virtual void showWindow(); - virtual void closeWindow(); - - virtual void attachWindow(); - virtual void detachWindow(); - - virtual void setAttachedWindowHeight(unsigned height); + virtual void openInspectorFrontend(WebCore::InspectorController*); virtual void highlight(Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const WebCore::String& key, WebCore::String* value); virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); - - virtual void inspectorWindowObjectCleared(); }; } // namespace WebCore diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index e6d3046e3a9c..8decc584453c 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,49 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * WebCoreSupport/WebInspectorClient.h: + * WebCoreSupport/WebInspectorClient.mm: + (WebInspectorClient::WebInspectorClient): + (WebInspectorClient::inspectorDestroyed): + (WebInspectorClient::openInspectorFrontend): + (WebInspectorClient::highlight): + (WebInspectorClient::hideHighlight): + (WebInspectorFrontendClient::WebInspectorFrontendClient): + (WebInspectorFrontendClient::frontendLoaded): + (WebInspectorFrontendClient::localizedStringsURL): + (WebInspectorFrontendClient::hiddenPanels): + (WebInspectorFrontendClient::bringToFront): + (WebInspectorFrontendClient::closeWindow): + (WebInspectorFrontendClient::attachWindow): + (WebInspectorFrontendClient::detachWindow): + (WebInspectorFrontendClient::setAttachedWindowHeight): + (WebInspectorFrontendClient::inspectedURLChanged): + (WebInspectorFrontendClient::updateWindowTitle): + (-[WebInspectorWindowController dealloc]): + (-[WebInspectorWindowController windowShouldClose:]): + (-[WebInspectorWindowController close]): + (-[WebInspectorWindowController showWindow:]): + (-[WebInspectorWindowController attach]): + (-[WebInspectorWindowController detach]): + (-[WebInspectorWindowController attached]): + (-[WebInspectorWindowController setFrontendClient:]): + (-[WebInspectorWindowController destroyInspectorView]): + (-[WebNodeHighlighter initWithInspectedWebView:]): + (-[WebNodeHighlighter dealloc]): + (-[WebNodeHighlighter highlightNode:]): + (-[WebNodeHighlighter hideHighlight]): + (-[WebNodeHighlighter didAttachWebNodeHighlight:]): + (-[WebNodeHighlighter willDetachWebNodeHighlight:]): + * WebInspector/WebInspector.mm: + (-[WebInspector attach:]): + (-[WebInspector detach:]): + 2010-03-15 Andy Estes Reviewed by John Sullivan. diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.h b/WebKit/mac/WebCoreSupport/WebInspectorClient.h index 64621f86cfba..ee81b25d4216 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.h +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.h @@ -27,15 +27,18 @@ */ #import +#import #import #import #ifdef __OBJC__ @class WebInspectorWindowController; +@class WebNodeHighlighter; @class WebView; #else class WebInspectorWindowController; +class WebNodeHighlighter; class WebView; #endif @@ -45,32 +48,41 @@ class WebInspectorClient : public WebCore::InspectorClient { virtual void inspectorDestroyed(); - virtual WebCore::Page* createPage(); - virtual WebCore::String localizedStringsURL(); - - virtual WebCore::String hiddenPanels(); - - virtual void showWindow(); - virtual void closeWindow(); - - virtual void attachWindow(); - virtual void detachWindow(); - - virtual void setAttachedWindowHeight(unsigned height); + virtual void openInspectorFrontend(WebCore::InspectorController*); virtual void highlight(WebCore::Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const WebCore::String& newURL); virtual void populateSetting(const WebCore::String& key, WebCore::String* value); virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); - virtual void inspectorWindowObjectCleared(); +private: + WebView *m_webView; + RetainPtr m_highlighter; +}; + +class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal { +public: + WebInspectorFrontendClient(WebView*, WebInspectorWindowController*, WebCore::InspectorController*, WebCore::Page*); + + virtual void frontendLoaded(); + + virtual WebCore::String localizedStringsURL(); + virtual WebCore::String hiddenPanels(); + + virtual void bringToFront(); + virtual void closeWindow(); + + virtual void attachWindow(); + virtual void detachWindow(); + + virtual void setAttachedWindowHeight(unsigned height); + virtual void inspectedURLChanged(const WebCore::String& newURL); private: void updateWindowTitle() const; - WebView *m_webView; + WebView* m_inspectedWebView; RetainPtr m_windowController; WebCore::String m_inspectedURL; }; diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm index c5f17290829a..00c51a964e49 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm @@ -41,6 +41,7 @@ #import #import #import +#import using namespace WebCore; @@ -48,45 +49,94 @@ @interface WebInspectorWindowController : NSWindowController @private WebView *_inspectedWebView; WebView *_webView; - WebNodeHighlight *_currentHighlight; + WebInspectorFrontendClient* _frontendClient; BOOL _attachedToInspectedWebView; BOOL _shouldAttach; BOOL _visible; - BOOL _movingWindows; + BOOL _destroyingInspectorView; } - (id)initWithInspectedWebView:(WebView *)webView; -- (BOOL)inspectorVisible; - (WebView *)webView; - (void)attach; - (void)detach; +- (BOOL)attached; +- (void)setFrontendClient:(WebInspectorFrontendClient*)frontendClient; - (void)setAttachedWindowHeight:(unsigned)height; +- (void)destroyInspectorView; +@end + +#pragma mark - + +@interface WebNodeHighlighter : NSObject { +@private + WebView *_inspectedWebView; + WebNodeHighlight *_currentHighlight; +} +- (id)initWithInspectedWebView:(WebView *)webView; - (void)highlightNode:(DOMNode *)node; - (void)hideHighlight; @end #pragma mark - + WebInspectorClient::WebInspectorClient(WebView *webView) : m_webView(webView) +, m_highlighter(AdoptNS, [[WebNodeHighlighter alloc] initWithInspectedWebView:webView]) { } void WebInspectorClient::inspectorDestroyed() { - [[m_windowController.get() webView] close]; delete this; } -Page* WebInspectorClient::createPage() +void WebInspectorClient::openInspectorFrontend(InspectorController* inspectorController) { - if (m_windowController) - [[m_windowController.get() webView] close]; - m_windowController.adoptNS([[WebInspectorWindowController alloc] initWithInspectedWebView:m_webView]); + RetainPtr windowController(AdoptNS, [[WebInspectorWindowController alloc] initWithInspectedWebView:m_webView]); + Page* frontendPage = core([windowController.get() webView]); - return core([m_windowController.get() webView]); + frontendPage->inspectorController()->setInspectorFrontendClient(new WebInspectorFrontendClient(m_webView, windowController.get(), inspectorController, frontendPage)); } -String WebInspectorClient::localizedStringsURL() +void WebInspectorClient::highlight(Node* node) +{ + [m_highlighter.get() highlightNode:kit(node)]; +} + +void WebInspectorClient::hideHighlight() +{ + [m_highlighter.get() hideHighlight]; +} + +WebInspectorFrontendClient::WebInspectorFrontendClient(WebView* inspectedWebView, WebInspectorWindowController* windowController, InspectorController* inspectorController, Page* frontendPage) + : InspectorFrontendClientLocal(inspectorController, frontendPage) + , m_inspectedWebView(inspectedWebView) + , m_windowController(windowController) +{ + [windowController setFrontendClient:this]; +} + +void WebInspectorFrontendClient::frontendLoaded() +{ + [m_windowController.get() showWindow:nil]; + if ([m_windowController.get() attached]) + restoreAttachedWindowHeight(); + + InspectorFrontendClientLocal::frontendLoaded(); + + WebFrame *frame = [m_inspectedWebView mainFrame]; + + WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_inspectedWebView); + if (implementations->didClearInspectorWindowObjectForFrameFunc) + CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_inspectedWebView, + @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame); + + bool attached = [m_windowController.get() attached]; + setAttachedWindow(attached); +} + +String WebInspectorFrontendClient::localizedStringsURL() { NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"localizedStrings" ofType:@"js"]; if (path) @@ -94,7 +144,7 @@ - (void)hideHighlight; return String(); } -String WebInspectorClient::hiddenPanels() +String WebInspectorFrontendClient::hiddenPanels() { NSString *hiddenPanels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebKitInspectorHiddenPanels"]; if (hiddenPanels) @@ -102,63 +152,47 @@ - (void)hideHighlight; return String(); } -void WebInspectorClient::showWindow() +void WebInspectorFrontendClient::bringToFront() { updateWindowTitle(); [m_windowController.get() showWindow:nil]; } -void WebInspectorClient::closeWindow() +void WebInspectorFrontendClient::closeWindow() { - [m_windowController.get() close]; + [m_windowController.get() destroyInspectorView]; } -void WebInspectorClient::attachWindow() +void WebInspectorFrontendClient::attachWindow() { + if ([m_windowController.get() attached]) + return; [m_windowController.get() attach]; + restoreAttachedWindowHeight(); } -void WebInspectorClient::detachWindow() +void WebInspectorFrontendClient::detachWindow() { [m_windowController.get() detach]; } -void WebInspectorClient::setAttachedWindowHeight(unsigned height) +void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height) { [m_windowController.get() setAttachedWindowHeight:height]; } -void WebInspectorClient::highlight(Node* node) -{ - [m_windowController.get() highlightNode:kit(node)]; -} - -void WebInspectorClient::hideHighlight() -{ - [m_windowController.get() hideHighlight]; -} - -void WebInspectorClient::inspectedURLChanged(const String& newURL) +void WebInspectorFrontendClient::inspectedURLChanged(const String& newURL) { m_inspectedURL = newURL; updateWindowTitle(); } -void WebInspectorClient::updateWindowTitle() const +void WebInspectorFrontendClient::updateWindowTitle() const { NSString *title = [NSString stringWithFormat:UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)m_inspectedURL]; [[m_windowController.get() window] setTitle:title]; } -void WebInspectorClient::inspectorWindowObjectCleared() -{ - WebFrame *frame = [m_webView mainFrame]; - - WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_webView); - if (implementations->didClearInspectorWindowObjectForFrameFunc) - CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_webView, - @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame); -} #pragma mark - @@ -221,18 +255,12 @@ - (id)initWithInspectedWebView:(WebView *)webView - (void)dealloc { - ASSERT(!_currentHighlight); [_webView release]; [super dealloc]; } #pragma mark - -- (BOOL)inspectorVisible -{ - return _visible; -} - - (WebView *)webView { return _webView; @@ -271,11 +299,7 @@ - (NSWindow *)window - (BOOL)windowShouldClose:(id)sender { - _visible = NO; - - [_inspectedWebView page]->inspectorController()->setWindowVisible(false); - - [self hideHighlight]; + [self destroyInspectorView]; return YES; } @@ -287,11 +311,6 @@ - (void)close _visible = NO; - if (!_movingWindows) - [_inspectedWebView page]->inspectorController()->setWindowVisible(false); - - [self hideHighlight]; - if (_attachedToInspectedWebView) { if ([_inspectedWebView _isClosed]) return; @@ -328,7 +347,7 @@ - (IBAction)showWindow:(id)sender String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(InspectorController::inspectorStartsAttachedSettingName()); _shouldAttach = shouldAttach != "false"; - if (_shouldAttach && ![_inspectedWebView page]->inspectorController()->canAttachWindow()) + if (_shouldAttach && !_frontendClient->canAttachWindow()) _shouldAttach = NO; if (_shouldAttach) { @@ -352,8 +371,6 @@ - (IBAction)showWindow:(id)sender [super showWindow:nil]; } - - [_inspectedWebView page]->inspectorController()->setWindowVisible(true, _shouldAttach); } #pragma mark - @@ -364,12 +381,9 @@ - (void)attach return; [_inspectedWebView page]->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "true"); - _movingWindows = YES; [self close]; [self showWindow:nil]; - - _movingWindows = NO; } - (void)detach @@ -378,13 +392,19 @@ - (void)detach return; [_inspectedWebView page]->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "false"); - _movingWindows = YES; [self close]; [self showWindow:nil]; +} - _movingWindows = NO; +- (BOOL)attached +{ + return _attachedToInspectedWebView; +} +- (void)setFrontendClient:(WebInspectorFrontendClient*)frontendClient +{ + _frontendClient = frontendClient; } - (void)setAttachedWindowHeight:(unsigned)height @@ -405,29 +425,17 @@ - (void)setAttachedWindowHeight:(unsigned)height [frameView setFrame:frameViewRect]; } -#pragma mark - - -- (void)highlightNode:(DOMNode *)node +- (void)destroyInspectorView { - // The scrollview's content view stays around between page navigations, so target it - NSView *view = [[[[[_inspectedWebView mainFrame] frameView] documentView] enclosingScrollView] contentView]; - if (![view window]) - return; // skip the highlight if we have no window (e.g. hidden tab) - - if (!_currentHighlight) { - _currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()]; - [_currentHighlight setDelegate:self]; - [_currentHighlight attach]; - } else - [[_currentHighlight highlightView] setNeedsDisplay:YES]; -} + if (_destroyingInspectorView) + return; + _destroyingInspectorView = YES; -- (void)hideHighlight -{ - [_currentHighlight detach]; - [_currentHighlight setDelegate:nil]; - [_currentHighlight release]; - _currentHighlight = nil; + if (_attachedToInspectedWebView) + [self close]; + _visible = NO; + [_inspectedWebView page]->inspectorController()->disconnectFrontend(); + [_webView close]; } #pragma mark - @@ -497,3 +505,60 @@ - (BOOL)validateUserInterfaceItem:(id )item } @end + + +#pragma mark - + +@implementation WebNodeHighlighter +- (id)initWithInspectedWebView:(WebView *)webView +{ + // Don't retain to avoid a circular reference + _inspectedWebView = webView; + return self; +} + +- (void)dealloc +{ + ASSERT(!_currentHighlight); + [super dealloc]; +} + +#pragma mark - + +- (void)highlightNode:(DOMNode *)node +{ + // The scrollview's content view stays around between page navigations, so target it + NSView *view = [[[[[_inspectedWebView mainFrame] frameView] documentView] enclosingScrollView] contentView]; + if (![view window]) + return; // skip the highlight if we have no window (e.g. hidden tab) + + if (!_currentHighlight) { + _currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()]; + [_currentHighlight setDelegate:self]; + [_currentHighlight attach]; + } else + [[_currentHighlight highlightView] setNeedsDisplay:YES]; +} + +- (void)hideHighlight +{ + [_currentHighlight detach]; + [_currentHighlight setDelegate:nil]; + [_currentHighlight release]; + _currentHighlight = nil; +} + +#pragma mark - +#pragma mark WebNodeHighlight delegate + +- (void)didAttachWebNodeHighlight:(WebNodeHighlight *)highlight +{ + [_inspectedWebView setCurrentNodeHighlight:highlight]; +} + +- (void)willDetachWebNodeHighlight:(WebNodeHighlight *)highlight +{ + [_inspectedWebView setCurrentNodeHighlight:nil]; +} + +@end diff --git a/WebKit/mac/WebInspector/WebInspector.mm b/WebKit/mac/WebInspector/WebInspector.mm index 258dd015f2fd..9b1745969b23 100644 --- a/WebKit/mac/WebInspector/WebInspector.mm +++ b/WebKit/mac/WebInspector/WebInspector.mm @@ -175,14 +175,10 @@ - (void)close:(id)sender - (void)attach:(id)sender { - if (Page* page = core(_webView)) - page->inspectorController()->attachWindow(); } - (void)detach:(id)sender { - if (Page* page = core(_webView)) - page->inspectorController()->detachWindow(); } - (void)evaluateInFrontend:(id)sender callId:(long)callId script:(NSString *)script diff --git a/WebKit/qt/Api/qwebinspector.cpp b/WebKit/qt/Api/qwebinspector.cpp index c3ef5305697a..c0e527771051 100644 --- a/WebKit/qt/Api/qwebinspector.cpp +++ b/WebKit/qt/Api/qwebinspector.cpp @@ -161,6 +161,10 @@ void QWebInspector::showEvent(QShowEvent* event) /*! \reimp */ void QWebInspector::hideEvent(QHideEvent* event) { +#if ENABLE(INSPECTOR) + if (d->page) + d->page->d->inspectorController()->close(); +#endif } /*! \reimp */ @@ -168,7 +172,7 @@ void QWebInspector::closeEvent(QCloseEvent* event) { #if ENABLE(INSPECTOR) if (d->page) - d->page->d->inspectorController()->setWindowVisible(false); + d->page->d->inspectorController()->close(); #endif } diff --git a/WebKit/qt/Api/qwebinspector.h b/WebKit/qt/Api/qwebinspector.h index 6cda479b582a..f192e921b639 100644 --- a/WebKit/qt/Api/qwebinspector.h +++ b/WebKit/qt/Api/qwebinspector.h @@ -52,5 +52,6 @@ class QWEBKIT_EXPORT QWebInspector : public QWidget { friend class QWebPage; friend class QWebPagePrivate; friend class WebCore::InspectorClientQt; + friend class WebCore::InspectorFrontendClientQt; }; #endif diff --git a/WebKit/qt/Api/qwebpage.h b/WebKit/qt/Api/qwebpage.h index 4766cbdaf30b..076fb7c177ba 100644 --- a/WebKit/qt/Api/qwebpage.h +++ b/WebKit/qt/Api/qwebpage.h @@ -54,6 +54,7 @@ namespace WebCore { class EditorClientQt; class FrameLoaderClientQt; class InspectorClientQt; + class InspectorFrontendClientQt; class ResourceHandle; class HitTestResult; class QNetworkReplyHandler; @@ -361,6 +362,7 @@ public Q_SLOTS: friend class WebCore::EditorClientQt; friend class WebCore::FrameLoaderClientQt; friend class WebCore::InspectorClientQt; + friend class WebCore::InspectorFrontendClientQt; friend class WebCore::ResourceHandle; friend class WebCore::QNetworkReplyHandler; }; diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog index 98ed39a13d28..e8569c0e5752 100644 --- a/WebKit/qt/ChangeLog +++ b/WebKit/qt/ChangeLog @@ -1,3 +1,32 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * Api/qwebinspector.cpp: + (QWebInspector::hideEvent): + (QWebInspector::closeEvent): + * Api/qwebinspector.h: + * Api/qwebpage.h: + * WebCoreSupport/InspectorClientQt.cpp: + (WebCore::InspectorClientQt::openInspectorFrontend): + (WebCore::InspectorFrontendClientQt::InspectorFrontendClientQt): + (WebCore::InspectorFrontendClientQt::frontendLoaded): + (WebCore::InspectorFrontendClientQt::localizedStringsURL): + (WebCore::InspectorFrontendClientQt::hiddenPanels): + (WebCore::InspectorFrontendClientQt::bringToFront): + (WebCore::InspectorFrontendClientQt::closeWindow): + (WebCore::InspectorFrontendClientQt::attachWindow): + (WebCore::InspectorFrontendClientQt::detachWindow): + (WebCore::InspectorFrontendClientQt::setAttachedWindowHeight): + (WebCore::InspectorFrontendClientQt::inspectedURLChanged): + (WebCore::InspectorFrontendClientQt::updateWindowTitle): + * WebCoreSupport/InspectorClientQt.h: + 2010-03-15 Laszlo Gombos Unreviewed. diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp index cde64c8013b0..9bf7b2e8318c 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp @@ -81,15 +81,12 @@ void InspectorClientQt::inspectorDestroyed() delete this; } -Page* InspectorClientQt::createPage() -{ - QWebView* inspectorView = m_inspectorView.get(); - if (!inspectorView) { - inspectorView = new QWebView; - InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView); - inspectorView->setPage(inspectorPage); - m_inspectorView.set(inspectorView); - } + +void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*) +{ + QWebView* inspectorView = new QWebView; + InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView); + inspectorView->setPage(inspectorPage); QUrl inspectorUrl = m_inspectedWebPage->settings()->inspectorUrl(); if (!inspectorUrl.isValid()) @@ -98,50 +95,7 @@ Page* InspectorClientQt::createPage() m_inspectedWebPage->d->inspectorFrontend = inspectorView; m_inspectedWebPage->d->getOrCreateInspector()->d->setFrontend(inspectorView); - return inspectorView->page()->d->page; -} - -String InspectorClientQt::localizedStringsURL() -{ - notImplemented(); - return String(); -} - -String InspectorClientQt::hiddenPanels() -{ - notImplemented(); - return String(); -} - -void InspectorClientQt::showWindow() -{ - updateWindowTitle(); - -#if ENABLE(INSPECTOR) - m_inspectedWebPage->d->inspectorController()->setWindowVisible(true, true); -#endif -} - -void InspectorClientQt::closeWindow() -{ -#if ENABLE(INSPECTOR) - m_inspectedWebPage->d->inspectorController()->setWindowVisible(false); -#endif -} - -void InspectorClientQt::attachWindow() -{ - notImplemented(); -} - -void InspectorClientQt::detachWindow() -{ - notImplemented(); -} - -void InspectorClientQt::setAttachedWindowHeight(unsigned) -{ - notImplemented(); + inspectorView->page()->d->page->inspectorController()->setInspectorFrontendClient(new InspectorFrontendClientQt(m_inspectedWebPage, inspectorView)); } void InspectorClientQt::highlight(Node*) @@ -154,25 +108,6 @@ void InspectorClientQt::hideHighlight() notImplemented(); } -void InspectorClientQt::inspectedURLChanged(const String& newURL) -{ - m_inspectedURL = newURL; - updateWindowTitle(); -} - -void InspectorClientQt::inspectorWindowObjectCleared() -{ - notImplemented(); -} - -void InspectorClientQt::updateWindowTitle() -{ - if (m_inspectedWebPage->d->inspector) { - QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2").arg(m_inspectedURL); - m_inspectedWebPage->d->inspector->setWindowTitle(caption); - } -} - void InspectorClientQt::populateSetting(const String& key, String* setting) { QSettings qsettings; @@ -226,6 +161,81 @@ static QVariant settingToVariant(const String& setting) return retVal; } +InspectorFrontendClientQt::InspectorFrontendClientQt(QWebPage* inspectedWebPage, PassOwnPtr inspectorView) + : InspectorFrontendClientLocal(inspectedWebPage->d->page->inspectorController(), inspectorView->page()->d->page) + , m_inspectedWebPage(inspectedWebPage) + , m_inspectorView(inspectorView) + , m_destroyingInspectorView(false) +{ +} + +void InspectorFrontendClientQt::frontendLoaded() +{ + InspectorFrontendClientLocal::frontendLoaded(); + setAttachedWindow(true); +} + +String InspectorFrontendClientQt::localizedStringsURL() +{ + notImplemented(); + return String(); +} + +String InspectorFrontendClientQt::hiddenPanels() +{ + notImplemented(); + return String(); +} + +void InspectorFrontendClientQt::bringToFront() +{ + updateWindowTitle(); +} + +void InspectorFrontendClientQt::closeWindow() +{ + if (m_destroyingInspectorView) + return; + m_destroyingInspectorView = true; + + // Clear reference from QWebInspector to the frontend view. + m_inspectedWebPage->d->getOrCreateInspector()->d->setFrontend(0); +#if ENABLE(INSPECTOR) + m_inspectedWebPage->d->inspectorController()->disconnectFrontend(); +#endif + // Clear pointer before deleting WebView to avoid recursive calls to its destructor. + delete m_inspectorView.release(); +} + +void InspectorFrontendClientQt::attachWindow() +{ + notImplemented(); +} + +void InspectorFrontendClientQt::detachWindow() +{ + notImplemented(); +} + +void InspectorFrontendClientQt::setAttachedWindowHeight(unsigned) +{ + notImplemented(); +} + +void InspectorFrontendClientQt::inspectedURLChanged(const String& newURL) +{ + m_inspectedURL = newURL; + updateWindowTitle(); +} + +void InspectorFrontendClientQt::updateWindowTitle() +{ + if (m_inspectedWebPage->d->inspector) { + QString caption = QCoreApplication::translate("QWebPage", "Web Inspector - %2").arg(m_inspectedURL); + m_inspectedWebPage->d->inspector->setWindowTitle(caption); + } +} + } #include "InspectorClientQt.moc" diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h index c9548b012f18..4beadabe98bd 100644 --- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h +++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h @@ -31,7 +31,9 @@ #define InspectorClientQt_h #include "InspectorClient.h" +#include "InspectorFrontendClientLocal.h" #include "OwnPtr.h" +#include "PassOwnPtr.h" #include class QWebPage; @@ -48,13 +50,29 @@ class InspectorClientQt : public InspectorClient { virtual void inspectorDestroyed(); - virtual Page* createPage(); + virtual void openInspectorFrontend(WebCore::InspectorController*); + + virtual void highlight(Node*); + virtual void hideHighlight(); + + virtual void populateSetting(const String& key, String* value); + virtual void storeSetting(const String& key, const String& value); + +private: + QWebPage* m_inspectedWebPage; +}; + +class InspectorFrontendClientQt : public InspectorFrontendClientLocal { +public: + InspectorFrontendClientQt(QWebPage* inspectedWebPage, PassOwnPtr inspectorView); + + virtual void frontendLoaded(); virtual String localizedStringsURL(); virtual String hiddenPanels(); - virtual void showWindow(); + virtual void bringToFront(); virtual void closeWindow(); virtual void attachWindow(); @@ -62,20 +80,14 @@ class InspectorClientQt : public InspectorClient { virtual void setAttachedWindowHeight(unsigned height); - virtual void highlight(Node*); - virtual void hideHighlight(); virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const String& key, String* value); - virtual void storeSetting(const String& key, const String& value); - - virtual void inspectorWindowObjectCleared(); - private: void updateWindowTitle(); QWebPage* m_inspectedWebPage; OwnPtr m_inspectorView; QString m_inspectedURL; + bool m_destroyingInspectorView; }; } diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog index b6a32030b8f9..7d5a87c9a0ef 100644 --- a/WebKit/win/ChangeLog +++ b/WebKit/win/ChangeLog @@ -1,3 +1,47 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * WebCoreSupport/WebInspectorClient.cpp: + (WebInspectorClient::WebInspectorClient): + (WebInspectorClient::~WebInspectorClient): + (WebInspectorClient::openInspectorFrontend): + (WebInspectorClient::highlight): + (WebInspectorClient::hideHighlight): + (WebInspectorClient::updateHighlight): + (WebInspectorFrontendClient::WebInspectorFrontendClient): + (WebInspectorFrontendClient::~WebInspectorFrontendClient): + (WebInspectorFrontendClient::frontendLoaded): + (WebInspectorFrontendClient::localizedStringsURL): + (WebInspectorFrontendClient::hiddenPanels): + (WebInspectorFrontendClient::bringToFront): + (WebInspectorFrontendClient::closeWindow): + (WebInspectorFrontendClient::attachWindow): + (WebInspectorFrontendClient::detachWindow): + (WebInspectorFrontendClient::setAttachedWindowHeight): + (WebInspectorFrontendClient::inspectedURLChanged): + (WebInspectorFrontendClient::closeWindowWithoutNotifications): + (WebInspectorFrontendClient::showWindowWithoutNotifications): + (WebInspectorFrontendClient::destroyInspectorView): + (WebInspectorFrontendClient::updateWindowTitle): + (WebInspectorFrontendClient::onGetMinMaxInfo): + (WebInspectorFrontendClient::onSize): + (WebInspectorFrontendClient::onClose): + (WebInspectorFrontendClient::onSetFocus): + (WebInspectorFrontendClient::onWebViewWindowPosChanging): + (WebInspectorWndProc): + (WebInspectorFrontendClient::windowReceivedMessage): + * WebCoreSupport/WebInspectorClient.h: + (WebInspectorClient::frontendClosing): + * WebInspector.cpp: + (WebInspector::attach): + (WebInspector::detach): + 2010-03-14 Dan Bernstein Reviewed by Darin Adler. diff --git a/WebKit/win/WebCoreSupport/WebInspectorClient.cpp b/WebKit/win/WebCoreSupport/WebInspectorClient.cpp index 6a10c0dea058..16ad172c5789 100644 --- a/WebKit/win/WebCoreSupport/WebInspectorClient.cpp +++ b/WebKit/win/WebCoreSupport/WebInspectorClient.cpp @@ -69,25 +69,13 @@ static CFBundleRef getWebKitBundle() WebInspectorClient::WebInspectorClient(WebView* webView) : m_inspectedWebView(webView) - , m_hwnd(0) - , m_webViewHwnd(0) - , m_shouldAttachWhenShown(false) - , m_attached(false) { ASSERT(m_inspectedWebView); - m_inspectedWebView->viewWindow((OLE_HANDLE*)&m_inspectedWebViewHwnd); - - // FIXME: Implement window size/position save/restore -#if 0 - [self setWindowFrameAutosaveName:@"Web Inspector"]; -#endif } WebInspectorClient::~WebInspectorClient() { - if (m_hwnd) - ::DestroyWindow(m_hwnd); } void WebInspectorClient::inspectorDestroyed() @@ -95,35 +83,30 @@ void WebInspectorClient::inspectorDestroyed() delete this; } -Page* WebInspectorClient::createPage() +void WebInspectorClient::openInspectorFrontend(InspectorController* inspectorController) { registerWindowClass(); - if (m_hwnd) - ::DestroyWindow(m_hwnd); - - m_hwnd = ::CreateWindowEx(0, kWebInspectorWindowClassName, 0, WS_OVERLAPPEDWINDOW, + HWND frontendHwnd = ::CreateWindowEx(0, kWebInspectorWindowClassName, 0, WS_OVERLAPPEDWINDOW, defaultWindowRect().x(), defaultWindowRect().y(), defaultWindowRect().width(), defaultWindowRect().height(), 0, 0, 0, 0); - if (!m_hwnd) - return 0; - - ::SetProp(m_hwnd, kWebInspectorPointerProp, reinterpret_cast(this)); + if (!frontendHwnd) + return; - m_webView.adoptRef(WebView::createInstance()); + COMPtr frontendWebView(AdoptCOM, WebView::createInstance()); - if (FAILED(m_webView->setHostWindow((OLE_HANDLE)(ULONG64)m_hwnd))) - return 0; + if (FAILED(frontendWebView->setHostWindow((OLE_HANDLE)(ULONG64)frontendHwnd))) + return; RECT rect; - GetClientRect(m_hwnd, &rect); - if (FAILED(m_webView->initWithFrame(rect, 0, 0))) - return 0; + GetClientRect(frontendHwnd, &rect); + if (FAILED(frontendWebView->initWithFrame(rect, 0, 0))) + return; COMPtr delegate(AdoptCOM, WebInspectorDelegate::createInstance()); - if (FAILED(m_webView->setUIDelegate(delegate.get()))) - return 0; + if (FAILED(frontendWebView->setUIDelegate(delegate.get()))) + return; // Keep preferences separate from the rest of the client, making sure we are using expected preference values. // One reason this is good is that it keeps the inspector out of history via "private browsing". @@ -134,66 +117,126 @@ Page* WebInspectorClient::createPage() COMPtr tempPreferences(AdoptCOM, WebPreferences::createInstance()); COMPtr iPreferences; if (FAILED(tempPreferences->initWithIdentifier(BString(L"WebInspectorPreferences"), &iPreferences))) - return 0; + return; COMPtr preferences(Query, iPreferences); if (!preferences) - return 0; + return; if (FAILED(preferences->setAutosaves(FALSE))) - return 0; + return; if (FAILED(preferences->setPrivateBrowsingEnabled(TRUE))) - return 0; + return; if (FAILED(preferences->setLoadsImagesAutomatically(TRUE))) - return 0; + return; if (FAILED(preferences->setAuthorAndUserStylesEnabled(TRUE))) - return 0; + return; if (FAILED(preferences->setAllowsAnimatedImages(TRUE))) - return 0; + return; if (FAILED(preferences->setLoadsImagesAutomatically(TRUE))) - return 0; + return; if (FAILED(preferences->setPlugInsEnabled(FALSE))) - return 0; + return; if (FAILED(preferences->setJavaEnabled(FALSE))) - return 0; + return; if (FAILED(preferences->setUserStyleSheetEnabled(FALSE))) - return 0; + return; if (FAILED(preferences->setTabsToLinks(FALSE))) - return 0; + return; if (FAILED(preferences->setMinimumFontSize(0))) - return 0; + return; if (FAILED(preferences->setMinimumLogicalFontSize(9))) - return 0; + return; if (FAILED(preferences->setFixedFontFamily(BString(L"Courier New")))) - return 0; + return; if (FAILED(preferences->setDefaultFixedFontSize(13))) - return 0; + return; - if (FAILED(m_webView->setPreferences(preferences.get()))) - return 0; + if (FAILED(frontendWebView->setPreferences(preferences.get()))) + return; - m_webView->setProhibitsMainFrameScrolling(TRUE); + frontendWebView->setProhibitsMainFrameScrolling(TRUE); - if (FAILED(m_webView->viewWindow(reinterpret_cast(&m_webViewHwnd)))) - return 0; + HWND frontendWebViewHwnd; + if (FAILED(frontendWebView->viewWindow(reinterpret_cast(&frontendWebViewHwnd)))) + return; - COMPtr request; - request.adoptRef(WebMutableURLRequest::createInstance()); + COMPtr request(AdoptCOM, WebMutableURLRequest::createInstance()); RetainPtr htmlURLRef(AdoptCF, CFBundleCopyResourceURL(getWebKitBundle(), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector"))); if (!htmlURLRef) - return 0; + return; CFStringRef urlStringRef = ::CFURLGetString(htmlURLRef.get()); if (FAILED(request->initWithURL(BString(urlStringRef), WebURLRequestUseProtocolCachePolicy, 60))) - return 0; + return; - if (FAILED(m_webView->topLevelFrame()->loadRequest(request.get()))) - return 0; + if (FAILED(frontendWebView->topLevelFrame()->loadRequest(request.get()))) + return; - return core(m_webView.get()); + Page* page = core(frontendWebView.get()); + page->inspectorController()->setInspectorFrontendClient(new WebInspectorFrontendClient(m_inspectedWebView, m_inspectedWebViewHwnd, frontendHwnd, frontendWebView, frontendWebViewHwnd, this)); + m_frontendHwnd = frontendHwnd; } +void WebInspectorClient::highlight(Node*) +{ + bool creatingHighlight = !m_highlight; + + if (creatingHighlight) + m_highlight.set(new WebNodeHighlight(m_inspectedWebView)); -String WebInspectorClient::localizedStringsURL() + if (m_highlight->isShowing()) + m_highlight->update(); + else + m_highlight->setShowsWhileWebViewIsVisible(true); + + if (creatingHighlight && IsWindowVisible(m_frontendHwnd)) + m_highlight->placeBehindWindow(m_frontendHwnd); +} + +void WebInspectorClient::hideHighlight() +{ + if (m_highlight) + m_highlight->setShowsWhileWebViewIsVisible(false); +} + +void WebInspectorClient::updateHighlight() +{ + if (m_highlight && m_highlight->isShowing()) + m_highlight->update(); +} + +WebInspectorFrontendClient::WebInspectorFrontendClient(WebView* inspectedWebView, HWND inspectedWebViewHwnd, HWND frontendHwnd, const COMPtr& frontendWebView, HWND frontendWebViewHwnd, WebInspectorClient* inspectorClient) + : InspectorFrontendClientLocal(inspectedWebView->page()->inspectorController(), core(frontendWebView.get())) + , m_inspectedWebView(inspectedWebView) + , m_inspectedWebViewHwnd(inspectedWebViewHwnd) + , m_inspectorClient(inspectorClient) + , m_frontendHwnd(frontendHwnd) + , m_frontendWebView(frontendWebView) + , m_frontendWebViewHwnd(frontendWebViewHwnd) + , m_shouldAttachWhenShown(false) + , m_attached(false) + , m_destroyingInspectorView(false) +{ + ::SetProp(frontendHwnd, kWebInspectorPointerProp, reinterpret_cast(this)); + // FIXME: Implement window size/position save/restore +#if 0 + [self setWindowFrameAutosaveName:@"Web Inspector"]; +#endif +} + +WebInspectorFrontendClient::~WebInspectorFrontendClient() +{ + destroyInspectorView(); +} + +void WebInspectorFrontendClient::frontendLoaded() +{ + InspectorFrontendClientLocal::frontendLoaded(); + + setAttachedWindow(m_attached); +} + +String WebInspectorFrontendClient::localizedStringsURL() { RetainPtr url(AdoptCF, CFBundleCopyResourceURL(getWebKitBundle(), CFSTR("localizedStrings"), CFSTR("js"), 0)); if (!url) @@ -202,31 +245,23 @@ String WebInspectorClient::localizedStringsURL() return CFURLGetString(url.get()); } - -String WebInspectorClient::hiddenPanels() +String WebInspectorFrontendClient::hiddenPanels() { // FIXME: implement this return String(); } -void WebInspectorClient::showWindow() +void WebInspectorFrontendClient::bringToFront() { showWindowWithoutNotifications(); - m_inspectedWebView->page()->inspectorController()->setWindowVisible(true, m_shouldAttachWhenShown); -} - -void WebInspectorClient::closeWindow() -{ - closeWindowWithoutNotifications(); - m_inspectedWebView->page()->inspectorController()->setWindowVisible(false, m_shouldAttachWhenShown); } -bool WebInspectorClient::windowVisible() +void WebInspectorFrontendClient::closeWindow() { - return !!::IsWindowVisible(m_hwnd); + destroyInspectorView(); } -void WebInspectorClient::attachWindow() +void WebInspectorFrontendClient::attachWindow() { if (m_attached) return; @@ -237,7 +272,7 @@ void WebInspectorClient::attachWindow() showWindowWithoutNotifications(); } -void WebInspectorClient::detachWindow() +void WebInspectorFrontendClient::detachWindow() { if (!m_attached) return; @@ -248,7 +283,7 @@ void WebInspectorClient::detachWindow() showWindowWithoutNotifications(); } -void WebInspectorClient::setAttachedWindowHeight(unsigned height) +void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height) { if (!m_attached) return; @@ -266,101 +301,73 @@ void WebInspectorClient::setAttachedWindowHeight(unsigned height) int totalHeight = hostWindowRect.bottom - hostWindowRect.top; int webViewWidth = inspectedRect.right - inspectedRect.left; - SetWindowPos(m_webViewHwnd, 0, 0, totalHeight - height, webViewWidth, height, SWP_NOZORDER); + SetWindowPos(m_frontendWebViewHwnd, 0, 0, totalHeight - height, webViewWidth, height, SWP_NOZORDER); // We want to set the inspected web view height to the totalHeight, because the height adjustment // of the inspected web view happens in onWebViewWindowPosChanging, not here. SetWindowPos(m_inspectedWebViewHwnd, 0, 0, 0, webViewWidth, totalHeight, SWP_NOZORDER); - RedrawWindow(m_webViewHwnd, 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); + RedrawWindow(m_frontendWebViewHwnd, 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); RedrawWindow(m_inspectedWebViewHwnd, 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW); } -void WebInspectorClient::highlight(Node*) -{ - bool creatingHighlight = !m_highlight; - - if (creatingHighlight) - m_highlight.set(new WebNodeHighlight(m_inspectedWebView)); - - if (m_highlight->isShowing()) - m_highlight->update(); - else - m_highlight->setShowsWhileWebViewIsVisible(true); - - if (creatingHighlight && IsWindowVisible(m_hwnd)) - m_highlight->placeBehindWindow(m_hwnd); -} - -void WebInspectorClient::hideHighlight() -{ - if (m_highlight) - m_highlight->setShowsWhileWebViewIsVisible(false); -} - -void WebInspectorClient::inspectedURLChanged(const String& newURL) +void WebInspectorFrontendClient::inspectedURLChanged(const String& newURL) { m_inspectedURL = newURL; updateWindowTitle(); } -void WebInspectorClient::inspectorWindowObjectCleared() -{ - notImplemented(); -} - -void WebInspectorClient::closeWindowWithoutNotifications() +void WebInspectorFrontendClient::closeWindowWithoutNotifications() { - if (!m_hwnd) + if (!m_frontendHwnd) return; if (!m_attached) { - ShowWindow(m_hwnd, SW_HIDE); + ShowWindow(m_frontendHwnd, SW_HIDE); return; } - ASSERT(m_webView); + ASSERT(m_frontendWebView); ASSERT(m_inspectedWebViewHwnd); - ASSERT(!IsWindowVisible(m_hwnd)); + ASSERT(!IsWindowVisible(m_frontendHwnd)); // Remove the Inspector's WebView from the inspected WebView's parent window. WindowMessageBroadcaster::removeListener(m_inspectedWebViewHwnd, this); m_attached = false; - m_webView->setHostWindow(reinterpret_cast(m_hwnd)); + m_frontendWebView->setHostWindow(reinterpret_cast(m_frontendHwnd)); // Make sure everything has the right size/position. HWND hostWindow; if (SUCCEEDED(m_inspectedWebView->hostWindow((OLE_HANDLE*)&hostWindow))) SendMessage(hostWindow, WM_SIZE, 0, 0); - if (m_highlight && m_highlight->isShowing()) - m_highlight->update(); + m_inspectorClient->updateHighlight(); } -void WebInspectorClient::showWindowWithoutNotifications() +void WebInspectorFrontendClient::showWindowWithoutNotifications() { - if (!m_hwnd) + if (!m_frontendHwnd) return; - ASSERT(m_webView); + ASSERT(m_frontendWebView); ASSERT(m_inspectedWebViewHwnd); // If no preference is set - default to an attached window. This is important for inspector LayoutTests. String shouldAttach = m_inspectedWebView->page()->inspectorController()->setting(InspectorController::inspectorStartsAttachedSettingName()); m_shouldAttachWhenShown = shouldAttach != "false"; - if (m_shouldAttachWhenShown && !m_inspectedWebView->page()->inspectorController()->canAttachWindow()) + if (m_shouldAttachWhenShown && !canAttachWindow()) m_shouldAttachWhenShown = false; if (!m_shouldAttachWhenShown) { // Put the Inspector's WebView inside our window and show it. - m_webView->setHostWindow(reinterpret_cast(m_hwnd)); - SendMessage(m_hwnd, WM_SIZE, 0, 0); + m_frontendWebView->setHostWindow(reinterpret_cast(m_frontendHwnd)); + SendMessage(m_frontendHwnd, WM_SIZE, 0, 0); updateWindowTitle(); - SetWindowPos(m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(m_frontendHwnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE); return; } @@ -371,20 +378,32 @@ void WebInspectorClient::showWindowWithoutNotifications() if (FAILED(m_inspectedWebView->hostWindow(reinterpret_cast(&hostWindow)))) return; - m_webView->setHostWindow(reinterpret_cast(hostWindow)); + m_frontendWebView->setHostWindow(reinterpret_cast(hostWindow)); // Then hide our own window. - ShowWindow(m_hwnd, SW_HIDE); + ShowWindow(m_frontendHwnd, SW_HIDE); m_attached = true; // Make sure everything has the right size/position. SendMessage(hostWindow, WM_SIZE, 0, 0); - if (m_highlight && m_highlight->isShowing()) - m_highlight->update(); + m_inspectorClient->updateHighlight(); +} + +void WebInspectorFrontendClient::destroyInspectorView() +{ + if (m_destroyingInspectorView) + return; + m_destroyingInspectorView = true; + + m_inspectedWebView->page()->inspectorController()->disconnectFrontend(); + + closeWindowWithoutNotifications(); + m_inspectorClient->frontendClosing(); + ::DestroyWindow(m_frontendHwnd); } -void WebInspectorClient::updateWindowTitle() +void WebInspectorFrontendClient::updateWindowTitle() { // FIXME: The series of appends should be replaced with a call to String::format() // when it can be figured out how to get the unicode em-dash to show up. @@ -392,10 +411,10 @@ void WebInspectorClient::updateWindowTitle() title.append((UChar)0x2014); // em-dash title.append(' '); title.append(m_inspectedURL); - ::SetWindowText(m_hwnd, title.charactersWithNullTermination()); + ::SetWindowText(m_frontendHwnd, title.charactersWithNullTermination()); } -LRESULT WebInspectorClient::onGetMinMaxInfo(WPARAM, LPARAM lParam) +LRESULT WebInspectorFrontendClient::onGetMinMaxInfo(WPARAM, LPARAM lParam) { MINMAXINFO* info = reinterpret_cast(lParam); POINT size = {400, 400}; @@ -404,33 +423,31 @@ LRESULT WebInspectorClient::onGetMinMaxInfo(WPARAM, LPARAM lParam) return 0; } -LRESULT WebInspectorClient::onSize(WPARAM, LPARAM) +LRESULT WebInspectorFrontendClient::onSize(WPARAM, LPARAM) { RECT rect; - ::GetClientRect(m_hwnd, &rect); + ::GetClientRect(m_frontendHwnd, &rect); - ::SetWindowPos(m_webViewHwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); + ::SetWindowPos(m_frontendWebViewHwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); return 0; } -LRESULT WebInspectorClient::onClose(WPARAM, LPARAM) +LRESULT WebInspectorFrontendClient::onClose(WPARAM, LPARAM) { - ::ShowWindow(m_hwnd, SW_HIDE); - m_inspectedWebView->page()->inspectorController()->setWindowVisible(false, m_shouldAttachWhenShown); - - hideHighlight(); + ::ShowWindow(m_frontendHwnd, SW_HIDE); + m_inspectedWebView->page()->inspectorController()->close(); return 0; } -LRESULT WebInspectorClient::onSetFocus() +LRESULT WebInspectorFrontendClient::onSetFocus() { - SetFocus(m_webViewHwnd); + SetFocus(m_frontendWebViewHwnd); return 0; } -void WebInspectorClient::onWebViewWindowPosChanging(WPARAM, LPARAM lParam) +void WebInspectorFrontendClient::onWebViewWindowPosChanging(WPARAM, LPARAM lParam) { ASSERT(m_attached); @@ -441,17 +458,17 @@ void WebInspectorClient::onWebViewWindowPosChanging(WPARAM, LPARAM lParam) return; RECT inspectorRect; - GetClientRect(m_webViewHwnd, &inspectorRect); + GetClientRect(m_frontendWebViewHwnd, &inspectorRect); unsigned inspectorHeight = inspectorRect.bottom - inspectorRect.top; windowPos->cy -= inspectorHeight; - SetWindowPos(m_webViewHwnd, 0, windowPos->x, windowPos->y + windowPos->cy, windowPos->cx, inspectorHeight, SWP_NOZORDER); + SetWindowPos(m_frontendWebViewHwnd, 0, windowPos->x, windowPos->y + windowPos->cy, windowPos->cx, inspectorHeight, SWP_NOZORDER); } static LRESULT CALLBACK WebInspectorWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - WebInspectorClient* client = reinterpret_cast(::GetProp(hwnd, kWebInspectorPointerProp)); + WebInspectorFrontendClient* client = reinterpret_cast(::GetProp(hwnd, kWebInspectorPointerProp)); if (!client) return ::DefWindowProc(hwnd, msg, wParam, lParam); @@ -471,7 +488,7 @@ static LRESULT CALLBACK WebInspectorWndProc(HWND hwnd, UINT msg, WPARAM wParam, return ::DefWindowProc(hwnd, msg, wParam, lParam); } -void WebInspectorClient::windowReceivedMessage(HWND, UINT msg, WPARAM wParam, LPARAM lParam) +void WebInspectorFrontendClient::windowReceivedMessage(HWND, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_WINDOWPOSCHANGING: diff --git a/WebKit/win/WebCoreSupport/WebInspectorClient.h b/WebKit/win/WebCoreSupport/WebInspectorClient.h index 3f65b0afd816..455e3a1c6677 100644 --- a/WebKit/win/WebCoreSupport/WebInspectorClient.h +++ b/WebKit/win/WebCoreSupport/WebInspectorClient.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -39,44 +40,60 @@ class WebNodeHighlight; class WebView; -class WebInspectorClient : public WebCore::InspectorClient, WebCore::WindowMessageListener { +class WebInspectorClient : public WebCore::InspectorClient { public: WebInspectorClient(WebView*); // InspectorClient virtual void inspectorDestroyed(); - virtual WebCore::Page* createPage(); - - virtual WebCore::String localizedStringsURL(); - - virtual WebCore::String hiddenPanels(); - - virtual void showWindow(); - virtual void closeWindow(); - virtual bool windowVisible(); - - virtual void attachWindow(); - virtual void detachWindow(); - - virtual void setAttachedWindowHeight(unsigned height); + virtual void openInspectorFrontend(WebCore::InspectorController*); virtual void highlight(WebCore::Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const WebCore::String& newURL); - virtual void populateSetting(const WebCore::String& key, WebCore::String* value); virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); - virtual void inspectorWindowObjectCleared(); + void updateHighlight(); + void frontendClosing() { m_frontendHwnd = 0; } private: ~WebInspectorClient(); + WebView* m_inspectedWebView; + HWND m_inspectedWebViewHwnd; + HWND m_frontendHwnd; + + OwnPtr m_highlight; +}; + +class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal, WebCore::WindowMessageListener { +public: + WebInspectorFrontendClient(WebView* inspectedWebView, HWND inspectedWebViewHwnd, HWND frontendHwnd, const COMPtr& frotnendWebView, HWND frontendWebViewHwnd, WebInspectorClient* inspectorClient); + + virtual void frontendLoaded(); + + virtual WebCore::String localizedStringsURL(); + virtual WebCore::String hiddenPanels(); + + virtual void bringToFront(); + virtual void closeWindow(); + + virtual void attachWindow(); + virtual void detachWindow(); + + virtual void setAttachedWindowHeight(unsigned height); + virtual void inspectedURLChanged(const WebCore::String& newURL); + +private: + ~WebInspectorFrontendClient(); + void closeWindowWithoutNotifications(); void showWindowWithoutNotifications(); + void destroyInspectorView(); + void updateWindowTitle(); LRESULT onGetMinMaxInfo(WPARAM, LPARAM); @@ -90,16 +107,16 @@ class WebInspectorClient : public WebCore::InspectorClient, WebCore::WindowMessa WebView* m_inspectedWebView; HWND m_inspectedWebViewHwnd; - HWND m_hwnd; - COMPtr m_webView; - HWND m_webViewHwnd; + HWND m_frontendHwnd; + WebInspectorClient* m_inspectorClient; + COMPtr m_frontendWebView; + HWND m_frontendWebViewHwnd; bool m_shouldAttachWhenShown; bool m_attached; - OwnPtr m_highlight; - WebCore::String m_inspectedURL; + bool m_destroyingInspectorView; static friend LRESULT CALLBACK WebInspectorWndProc(HWND, UINT, WPARAM, LPARAM); }; diff --git a/WebKit/win/WebInspector.cpp b/WebKit/win/WebInspector.cpp index e4ac32ba2942..033771197329 100644 --- a/WebKit/win/WebInspector.cpp +++ b/WebKit/win/WebInspector.cpp @@ -131,19 +131,11 @@ HRESULT STDMETHODCALLTYPE WebInspector::close() HRESULT STDMETHODCALLTYPE WebInspector::attach() { - if (m_webView) - if (Page* page = m_webView->page()) - page->inspectorController()->attachWindow(); - return S_OK; } HRESULT STDMETHODCALLTYPE WebInspector::detach() { - if (m_webView) - if (Page* page = m_webView->page()) - page->inspectorController()->detachWindow(); - return S_OK; } diff --git a/WebKit/wx/ChangeLog b/WebKit/wx/ChangeLog index df2a89f5be91..8850f5b74da2 100644 --- a/WebKit/wx/ChangeLog +++ b/WebKit/wx/ChangeLog @@ -1,3 +1,15 @@ +2010-03-16 Yury Semikhatsky + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * WebKitSupport/InspectorClientWx.cpp: + * WebKitSupport/InspectorClientWx.h: + 2010-03-11 Anders Carlsson Reviewed by David Hyatt. diff --git a/WebKit/wx/WebKitSupport/InspectorClientWx.cpp b/WebKit/wx/WebKitSupport/InspectorClientWx.cpp index ff21ae04acd1..43fbb2bc347f 100644 --- a/WebKit/wx/WebKitSupport/InspectorClientWx.cpp +++ b/WebKit/wx/WebKitSupport/InspectorClientWx.cpp @@ -47,45 +47,8 @@ void InspectorClientWx::inspectorDestroyed() notImplemented(); } -Page* InspectorClientWx::createPage() -{ - notImplemented(); - return 0; -} - -String InspectorClientWx::localizedStringsURL() -{ - notImplemented(); - return String(); -} - -String InspectorClientWx::hiddenPanels() -{ - notImplemented(); - return String(); -} - -void InspectorClientWx::showWindow() -{ - notImplemented(); -} - -void InspectorClientWx::closeWindow() -{ - notImplemented(); -} - -void InspectorClientWx::attachWindow() -{ - notImplemented(); -} - -void InspectorClientWx::detachWindow() -{ - notImplemented(); -} -void InspectorClientWx::setAttachedWindowHeight(unsigned height) +void InspectorClientWx::openInspectorFrontend(WebCore::InspectorController*); { notImplemented(); } @@ -100,11 +63,6 @@ void InspectorClientWx::hideHighlight() notImplemented(); } -void InspectorClientWx::inspectedURLChanged(const String& newURL) -{ - notImplemented(); -} - void InspectorClientWx::populateSetting(const String& key, String* setting) { notImplemented(); @@ -115,9 +73,4 @@ void InspectorClientWx::storeSetting(const String& key, const String& setting) notImplemented(); } -void InspectorClientWx::inspectorWindowObjectCleared() -{ - notImplemented(); -} - }; diff --git a/WebKit/wx/WebKitSupport/InspectorClientWx.h b/WebKit/wx/WebKitSupport/InspectorClientWx.h index f90581722289..7675dc179e7e 100644 --- a/WebKit/wx/WebKitSupport/InspectorClientWx.h +++ b/WebKit/wx/WebKitSupport/InspectorClientWx.h @@ -41,29 +41,13 @@ class InspectorClientWx : public InspectorClient { virtual void inspectorDestroyed(); - virtual Page* createPage(); - - virtual String localizedStringsURL(); - - virtual String hiddenPanels(); - - virtual void showWindow(); - virtual void closeWindow(); - - virtual void attachWindow(); - virtual void detachWindow(); - - virtual void setAttachedWindowHeight(unsigned height); + virtual void openInspectorFrontend(WebCore::InspectorController*); virtual void highlight(Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const String& newURL); - virtual void populateSetting(const String& key, String* value); virtual void storeSetting(const String& key, const String& value); - - virtual void inspectorWindowObjectCleared(); }; } // namespace WebCore