diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/devtools/js/devtools.js | 34 | ||||
-rw-r--r-- | webkit/glue/devtools/js/inspector_controller.js | 1 | ||||
-rw-r--r-- | webkit/glue/devtools/js/inspector_controller_impl.js | 13 | ||||
-rw-r--r-- | webkit/glue/devtools/tools_agent.h | 10 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.cc | 3 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.h | 1 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.cc | 73 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsclient_impl.h | 10 |
8 files changed, 106 insertions, 39 deletions
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js index a1e7bf5..30ae6ec 100644 --- a/webkit/glue/devtools/js/devtools.js +++ b/webkit/glue/devtools/js/devtools.js @@ -555,40 +555,6 @@ WebInspector.SidebarObjectPropertyTreeElement.prototype.onpopulate = /** - * This override is necessary for starting highlighting after the resource - * was added into the frame. - * @override - */ -WebInspector.SourceView.prototype.setupSourceFrameIfNeeded = function() { - if (!this._frameNeedsSetup) { - return; - } - - this.attach(); - - var self = this; - var identifier = this.resource.identifier; - var element = this.sourceFrame.element; - - devtools.tools.getResourceContentAsync(identifier, function(source) { - var resource = WebInspector.resources[identifier]; - if (InspectorController.addSourceToFrame(resource.mimeType, source, - element)) { - delete self._frameNeedsSetup; - if (resource.type === WebInspector.Resource.Type.Script) { - self.sourceFrame.addEventListener('syntax highlighting complete', - self._syntaxHighlightingComplete, self); - self.sourceFrame.syntaxHighlightJavascript(); - } else { - self._sourceFrameSetupFinished(); - } - } - }); - return true; -}; - - -/** * This override is necessary for adding script source asynchronously. * @override */ diff --git a/webkit/glue/devtools/js/inspector_controller.js b/webkit/glue/devtools/js/inspector_controller.js index 3882e15..4f9ae30 100644 --- a/webkit/glue/devtools/js/inspector_controller.js +++ b/webkit/glue/devtools/js/inspector_controller.js @@ -152,7 +152,6 @@ devtools.InspectorController.prototype.moveByUnrestricted = function(x, y) { */ devtools.InspectorController.prototype.addResourceSourceToFrame = function(identifier, element) { - return false; }; diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js index 699c2e2..748961c 100644 --- a/webkit/glue/devtools/js/inspector_controller_impl.js +++ b/webkit/glue/devtools/js/inspector_controller_impl.js @@ -53,6 +53,19 @@ devtools.InspectorControllerImpl.prototype.addSourceToFrame = /** * {@inheritDoc}. */ +devtools.InspectorControllerImpl.prototype.addResourceSourceToFrame = + function(identifier, element) { + var resource = WebInspector.resources[identifier]; + if (!resource) { + return; + } + DevToolsHost.addResourceSourceToFrame(identifier, resource.mimeType, element); +}; + + +/** + * {@inheritDoc}. + */ devtools.InspectorControllerImpl.prototype.hideDOMNodeHighlight = function() { RemoteToolsAgent.HideDOMNodeHighlight(); }; diff --git a/webkit/glue/devtools/tools_agent.h b/webkit/glue/devtools/tools_agent.h index dd6bdf7..a5bb671 100644 --- a/webkit/glue/devtools/tools_agent.h +++ b/webkit/glue/devtools/tools_agent.h @@ -54,12 +54,16 @@ DEFINE_RPC_CLASS(ToolsAgent, TOOLS_AGENT_STRUCT) /* Sends InspectorFrontend message to be dispatched on client. */ \ METHOD1(DispatchOnClient, String /* data */) \ \ - /* Response to the async call. */ \ - METHOD2(DidGetResourceContent, int /* call_id */, String /* content */) \ - \ /* Tells frontend if resources panel should be enabled in the UI. */ \ METHOD1(SetResourcesPanelEnabled, bool /* enabled. */) DEFINE_RPC_CLASS(ToolsAgentDelegate, TOOLS_AGENT_DELEGATE_STRUCT) +#define TOOLS_AGENT_NATIVE_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, \ + METHOD4) \ + /* Response to the async call. */ \ + METHOD2(DidGetResourceContent, int /* call_id */, String /* content */) \ + +DEFINE_RPC_CLASS(ToolsAgentNativeDelegate, TOOLS_AGENT_NATIVE_DELEGATE_STRUCT) + #endif // WEBKIT_GLUE_DEVTOOLS_TOOLS_AGENT_H_ diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index 7e441b2..ae781e0 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -54,6 +54,7 @@ WebDevToolsAgentImpl::WebDevToolsAgentImpl( debugger_agent_delegate_stub_.set(new DebuggerAgentDelegateStub(this)); dom_agent_delegate_stub_.set(new DomAgentDelegateStub(this)); tools_agent_delegate_stub_.set(new ToolsAgentDelegateStub(this)); + tools_agent_native_delegate_stub_.set(new ToolsAgentNativeDelegateStub(this)); } WebDevToolsAgentImpl::~WebDevToolsAgentImpl() { @@ -230,7 +231,7 @@ void WebDevToolsAgentImpl::GetResourceContent( RefPtr<InspectorResource> resource = page->inspectorController()->resources().get(identifier); if (resource.get()) { - tools_agent_delegate_stub_->DidGetResourceContent(call_id, + tools_agent_native_delegate_stub_->DidGetResourceContent(call_id, resource->sourceString()); } } diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h index dcf9a11..99fb3b5 100644 --- a/webkit/glue/webdevtoolsagent_impl.h +++ b/webkit/glue/webdevtoolsagent_impl.h @@ -91,6 +91,7 @@ class WebDevToolsAgentImpl OwnPtr<DebuggerAgentDelegateStub> debugger_agent_delegate_stub_; OwnPtr<DomAgentDelegateStub> dom_agent_delegate_stub_; OwnPtr<ToolsAgentDelegateStub> tools_agent_delegate_stub_; + OwnPtr<ToolsAgentNativeDelegateStub> tools_agent_native_delegate_stub_; OwnPtr<DebuggerAgentImpl> debugger_agent_impl_; OwnPtr<DomAgentImpl> dom_agent_impl_; bool attached_; diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc index 07c5444..8eb7ef8 100644 --- a/webkit/glue/webdevtoolsclient_impl.cc +++ b/webkit/glue/webdevtoolsclient_impl.cc @@ -47,6 +47,44 @@ DEFINE_RPC_JS_BOUND_OBJ(DomAgent, DOM_AGENT_STRUCT, DEFINE_RPC_JS_BOUND_OBJ(ToolsAgent, TOOLS_AGENT_STRUCT, ToolsAgentDelegate, TOOLS_AGENT_DELEGATE_STRUCT) +class ToolsAgentNativeDelegateImpl : public ToolsAgentNativeDelegate { + public: + struct ResourceContentRequestData { + String mime_type; + RefPtr<Node> frame; + }; + + ToolsAgentNativeDelegateImpl(WebFrameImpl* frame) : frame_(frame) {} + virtual ~ToolsAgentNativeDelegateImpl() {} + + // ToolsAgentNativeDelegate implementation. + virtual void DidGetResourceContent(int request_id, const String& content) { + if (!resource_content_requests_.contains(request_id)) { + NOTREACHED(); + return; + } + ResourceContentRequestData request = + resource_content_requests_.take(request_id); + + InspectorController* ic = frame_->frame()->page()->inspectorController(); + + ic->addSourceToFrame(request.mime_type, content, request.frame.get()); + } + + void RequestSent(int resource_id, String mime_type, Node* frame) { + ResourceContentRequestData data; + data.mime_type = mime_type; + data.frame = frame; + DCHECK(!resource_content_requests_.contains(resource_id)); + resource_content_requests_.set(resource_id, data); + } + + private: + WebFrameImpl* frame_; + HashMap<int, ResourceContentRequestData> resource_content_requests_; + DISALLOW_COPY_AND_ASSIGN(ToolsAgentNativeDelegateImpl); +}; + namespace { class RemoteDebuggerCommandExecutor : public CppBoundClass { @@ -99,6 +137,8 @@ WebDevToolsClientImpl::WebDevToolsClientImpl( dom_agent_obj_.set(new JsDomAgentBoundObj(this, frame, L"RemoteDomAgent")); tools_agent_obj_.set( new JsToolsAgentBoundObj(this, frame, L"RemoteToolsAgent")); + tools_agent_native_delegate_impl_.set( + new ToolsAgentNativeDelegateImpl(frame)); v8::HandleScope scope; v8::Handle<v8::Context> frame_context = V8Proxy::GetContext(frame->frame()); @@ -107,6 +147,9 @@ WebDevToolsClientImpl::WebDevToolsClientImpl( "addSourceToFrame", WebDevToolsClientImpl::JsAddSourceToFrame); dev_tools_host_->AddProtoFunction( + "addResourceSourceToFrame", + WebDevToolsClientImpl::JsAddResourceSourceToFrame); + dev_tools_host_->AddProtoFunction( "loaded", WebDevToolsClientImpl::JsLoaded); dev_tools_host_->AddProtoFunction( @@ -125,6 +168,14 @@ void WebDevToolsClientImpl::DispatchMessageFromAgent( const std::string& class_name, const std::string& method_name, const std::string& raw_msg) { + if (ToolsAgentNativeDelegateDispatch::Dispatch( + tools_agent_native_delegate_impl_.get(), + class_name, + method_name, + raw_msg)) { + return; + } + std::string expr = StringPrintf( "devtools.dispatch('%s','%s',%s)", class_name.c_str(), @@ -137,6 +188,13 @@ void WebDevToolsClientImpl::DispatchMessageFromAgent( ExecuteScript(expr); } +void WebDevToolsClientImpl::AddResourceSourceToFrame(int resource_id, + String mime_type, + Node* frame) { + tools_agent_obj_->GetResourceContent(resource_id, resource_id); + tools_agent_native_delegate_impl_->RequestSent(resource_id, mime_type, frame); +} + void WebDevToolsClientImpl::ExecuteScript(const std::string& expr) { web_view_impl_->GetMainFrame()->ExecuteScript( WebScriptSource(WebString::fromUTF8(expr))); @@ -178,6 +236,21 @@ v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddSourceToFrame( } // static +v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddResourceSourceToFrame( + const v8::Arguments& args) { + int resource_id = static_cast<int>(args[0]->NumberValue()); + String mime_type = WebCore::toWebCoreStringWithNullCheck(args[1]); + if (mime_type.isEmpty()) { + return v8::Undefined(); + } + Node* node = V8Proxy::DOMWrapperToNode<Node>(args[2]); + WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( + v8::External::Cast(*args.Data())->Value()); + client->AddResourceSourceToFrame(resource_id, mime_type, node); + return v8::Undefined(); +} + +// static v8::Handle<v8::Value> WebDevToolsClientImpl::JsLoaded( const v8::Arguments& args) { WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h index 07df265..922d51f 100644 --- a/webkit/glue/webdevtoolsclient_impl.h +++ b/webkit/glue/webdevtoolsclient_impl.h @@ -9,6 +9,7 @@ #include <wtf/HashMap.h> #include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> #include "v8.h" #include "webkit/glue/cpp_bound_class.h" @@ -16,6 +17,7 @@ #include "webkit/glue/webdevtoolsclient.h" namespace WebCore { +class Node; class Page; class String; } @@ -25,6 +27,7 @@ class JsDebuggerAgentBoundObj; class JsDomAgentBoundObj; class JsNetAgentBoundObj; class JsToolsAgentBoundObj; +class ToolsAgentNativeDelegateImpl; class WebDevToolsClientDelegate; class WebViewImpl; @@ -48,8 +51,14 @@ class WebDevToolsClientImpl : public WebDevToolsClient, const std::string& raw_msg); private: + void AddResourceSourceToFrame(int resource_id, + String mime_type, + WebCore::Node* frame); + void ExecuteScript(const std::string& expr); static v8::Handle<v8::Value> JsAddSourceToFrame(const v8::Arguments& args); + static v8::Handle<v8::Value> JsAddResourceSourceToFrame( + const v8::Arguments& args); static v8::Handle<v8::Value> JsLoaded(const v8::Arguments& args); static v8::Handle<v8::Value> JsActivateWindow(const v8::Arguments& args); @@ -62,6 +71,7 @@ class WebDevToolsClientImpl : public WebDevToolsClient, bool loaded_; Vector<std::string> pending_incoming_messages_; OwnPtr<BoundObject> dev_tools_host_; + OwnPtr<ToolsAgentNativeDelegateImpl> tools_agent_native_delegate_impl_; DISALLOW_COPY_AND_ASSIGN(WebDevToolsClientImpl); }; |