Commit d43c374d authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: keep links on the edited styles so that they are not collected...

DevTools: keep links on the edited styles so that they are not collected between debugging sessions.

Review URL: http://codereview.chromium.org/100159

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14844 0039d316-1c4b-4281-b951-d872f2087c98
parent 0b5f62f6
......@@ -61,13 +61,13 @@ void DebuggerAgentImpl::DebuggerOutput(const std::string& command) {
webdevtools_agent_->ForceRepaint();
}
void DebuggerAgentImpl::SetDocument(Document* document) {
v8::HandleScope scope;
if (!document) {
context_.Dispose();
return;
void DebuggerAgentImpl::CreateUtilityContext(
Document* document,
v8::Persistent<v8::Context>* context) {
if (!context->IsEmpty()) {
context->Dispose();
}
v8::HandleScope scope;
// TODO(pfeldman): Validate against Soeren.
// Set up the DOM window as the prototype of the new global object.
......@@ -91,12 +91,12 @@ void DebuggerAgentImpl::SetDocument(Document* document) {
V8Custom::v8DOMWindowIndexedSecurityCheck,
v8::Integer::New(V8ClassIndex::DOMWINDOW));
context_ = v8::Context::New(
*context = v8::Context::New(
NULL /* no extensions */,
global_template,
v8::Handle<v8::Object>());
v8::Context::Scope context_scope(context_);
v8::Handle<v8::Object> global = context_->Global();
v8::Context::Scope context_scope(*context);
v8::Handle<v8::Object> global = (*context)->Global();
v8::Handle<v8::String> implicit_proto_string = v8::String::New("__proto__");
global->Set(implicit_proto_string, window_wrapper);
......@@ -119,15 +119,16 @@ void DebuggerAgentImpl::SetDocument(Document* document) {
}
String DebuggerAgentImpl::ExecuteUtilityFunction(
v8::Handle<v8::Context> context,
const String &function_name,
Node* node,
const String& json_args,
String* exception) {
v8::HandleScope scope;
ASSERT(!context_.IsEmpty());
v8::Context::Scope context_scope(context_);
ASSERT(!context.IsEmpty());
v8::Context::Scope context_scope(context);
v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(
context_->Global()->Get(v8::String::New("devtools$$dispatch")));
context->Global()->Get(v8::String::New("devtools$$dispatch")));
v8::Handle<v8::Value> node_wrapper =
V8Proxy::ToV8Object(V8ClassIndex::NODE, node);
......@@ -142,7 +143,7 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
};
v8::TryCatch try_catch;
v8::Handle<v8::Value> res_obj = function->Call(context_->Global(), 3, args);
v8::Handle<v8::Value> res_obj = function->Call(context->Global(), 3, args);
if (try_catch.HasCaught()) {
*exception = WebCore::ToWebCoreString(try_catch.Message()->Get());
return "";
......
......@@ -28,18 +28,20 @@ class DebuggerAgentImpl : public DebuggerAgent {
WebDevToolsAgentImpl* webdevtools_agent);
virtual ~DebuggerAgentImpl();
// Initializes dom agent with the given document.
void SetDocument(WebCore::Document* document);
// Creates utility context with injected js agent.
void CreateUtilityContext(WebCore::Document* document,
v8::Persistent<v8::Context>* context);
// DebuggerAgent implementation.
virtual void DebugBreak();
void DebuggerOutput(const std::string& out);
// Executes utility function with the given node and json
// args as parameters. These functions must be implemented in
// the inject.js file.
// Executes function with the given name in the utility context. Passes node
// and json args as parameters. Note that the function called must be
// implemented in the inject.js file.
WebCore::String ExecuteUtilityFunction(
v8::Handle<v8::Context> context,
const WebCore::String& function_name,
WebCore::Node* node,
const WebCore::String& json_args,
......@@ -55,7 +57,6 @@ class DebuggerAgentImpl : public DebuggerAgent {
WebViewImpl* web_view() { return web_view_impl_; }
private:
v8::Persistent<v8::Context> context_;
WebViewImpl* web_view_impl_;
DebuggerAgentDelegate* delegate_;
WebDevToolsAgentImpl* webdevtools_agent_;
......
......@@ -289,7 +289,6 @@ WebInspector.ElementsPanel.prototype.updateStyles = function(forceUpdate) {
stylesSidebarPane.needsUpdate = false;
node.clearStyles();
};
devtools.tools.getDomAgent().getNodeStylesAsync(
node,
!Preferences.showUserAgentStyles,
......@@ -570,6 +569,7 @@ WebInspector.StylePropertyTreeElement.prototype.toggleEnabled =
devtools.tools.getDomAgent().toggleNodeStyleAsync(this.style, !disabled,
this.name,
function() {
WebInspector.panels.elements.sidebarPanes.styles.needsUpdate = true;
WebInspector.panels.elements.updateStyles(true);
});
};
This diff is collapsed.
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Injects 'injected' object into the inspectable page.
*/
/**
* Dispatches host calls into the injected function calls.
*/
goog.require('devtools.Injected');
/**
* Injected singleton.
*/
var devtools$$obj = new devtools.Injected();
/**
* Main dispatch method, all calls from the host go through this one.
* @param {string} functionName Function to call
* @param {Node} node Node context of the call.
* @param {string} json_args JSON-serialized call parameters.
* @return {string} JSON-serialized result of the dispatched call.
*/
function devtools$$dispatch(functionName, node, json_args) {
var params = goog.json.parse(json_args);
params.splice(0, 0, node);
var result = devtools$$obj[functionName].apply(devtools$$obj, params);
return goog.json.serialize(result);
};
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Injects 'injected' object into the inspectable page.
*/
/**
* Dispatches host calls into the injected function calls.
*/
goog.require('devtools.Injected');
/**
* Injected singleton.
*/
var devtools$$obj = new devtools.Injected();
/**
* Main dispatch method, all calls from the host go through this one.
* @param {string} functionName Function to call
* @param {Node} node Node context of the call.
* @param {string} json_args JSON-serialized call parameters.
* @return {string} JSON-serialized result of the dispatched call.
*/
function devtools$$dispatch(functionName, node, json_args) {
var params = goog.json.parse(json_args);
params.splice(0, 0, node);
var result = devtools$$obj[functionName].apply(devtools$$obj, params);
return goog.json.serialize(result);
};
......@@ -56,6 +56,9 @@ WebDevToolsAgentImpl::WebDevToolsAgentImpl(
}
WebDevToolsAgentImpl::~WebDevToolsAgentImpl() {
if (!utility_context_.IsEmpty()) {
utility_context_.Dispose();
}
}
void WebDevToolsAgentImpl::Attach() {
......@@ -73,7 +76,10 @@ void WebDevToolsAgentImpl::Attach() {
Page* page = web_view_impl_->page();
Document* doc = page->mainFrame()->document();
if (doc) {
debugger_agent_impl_->SetDocument(doc);
// Reuse existing context in case detached/attached.
if (utility_context_.IsEmpty()) {
debugger_agent_impl_->CreateUtilityContext(doc, &utility_context_);
}
dom_agent_impl_->SetDocument(doc);
net_agent_impl_->SetDocument(doc);
}
......@@ -110,7 +116,7 @@ void WebDevToolsAgentImpl::SetMainFrameDocumentReady(bool ready) {
} else {
doc = NULL;
}
debugger_agent_impl_->SetDocument(doc);
debugger_agent_impl_->CreateUtilityContext(doc, &utility_context_);
dom_agent_impl_->SetDocument(doc);
net_agent_impl_->SetDocument(doc);
}
......@@ -197,8 +203,8 @@ void WebDevToolsAgentImpl::ExecuteUtilityFunction(
String result;
String exception;
if (node) {
result = debugger_agent_impl_->ExecuteUtilityFunction(function_name, node,
json_args, &exception);
result = debugger_agent_impl_->ExecuteUtilityFunction(utility_context_,
function_name, node, json_args, &exception);
}
tools_agent_delegate_stub_->DidExecuteUtilityFunction(call_id,
result, exception);
......
......@@ -10,6 +10,7 @@
#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
#include "v8.h"
#include "webkit/glue/devtools/devtools_rpc.h"
#include "webkit/glue/devtools/dom_agent.h"
#include "webkit/glue/devtools/net_agent.h"
......@@ -110,6 +111,7 @@ class WebDevToolsAgentImpl
OwnPtr<NetAgentImpl> net_agent_impl_;
Vector<ConsoleMessage> console_log_;
bool attached_;
v8::Persistent<v8::Context> utility_context_;
DISALLOW_COPY_AND_ASSIGN(WebDevToolsAgentImpl);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment