summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc56
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.h5
-rw-r--r--webkit/glue/devtools/dom_agent.h76
-rw-r--r--webkit/glue/devtools/dom_agent_impl.cc598
-rw-r--r--webkit/glue/devtools/dom_agent_impl.h155
-rw-r--r--webkit/glue/devtools/dom_agent_unittest.cc463
-rw-r--r--webkit/glue/devtools/js/devtools.html1
-rw-r--r--webkit/glue/devtools/js/devtools.js169
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js119
-rw-r--r--webkit/glue/devtools/js/dom_agent.js746
-rw-r--r--webkit/glue/devtools/js/inject.js62
-rw-r--r--webkit/glue/devtools/js/inject_dispatch.js9
-rw-r--r--webkit/glue/devtools/js/inspector_controller_impl.js105
-rw-r--r--webkit/glue/devtools/tools_agent.h19
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc77
-rw-r--r--webkit/glue/webdevtoolsagent_impl.h12
-rw-r--r--webkit/glue/webdevtoolsclient_impl.cc4
-rw-r--r--webkit/glue/webdevtoolsclient_impl.h2
-rw-r--r--webkit/tools/test_shell/test_shell.gyp1
-rw-r--r--webkit/webkit.gyp4
20 files changed, 58 insertions, 2625 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index 755227d..f58f3f7 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -190,62 +190,6 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
}
}
-String DebuggerAgentImpl::EvaluateJavaScript(
- v8::Handle<v8::Context> utility_context,
- const String& source,
- String* exception) {
- v8::HandleScope scope;
- ASSERT(!utility_context.IsEmpty());
- if (utility_context.IsEmpty()) {
- *exception = "No window utility context.";
- return "";
- }
-
- v8::Handle<v8::Value> res_obj;
- { // Do evaluate.
- DebuggerAgentManager::UtilityContextScope utility_scope;
- v8::Handle<v8::Context> v8Context =
- V8Proxy::context(GetPage()->mainFrame());
- if (v8Context.IsEmpty()) {
- *exception = "No window context.";
- return "";
- }
- V8Proxy* proxy = V8Proxy::retrieve(GetPage()->mainFrame());
- v8::Context::Scope context_scope(v8Context);
- v8::TryCatch try_catch;
- v8::Handle<v8::Script> script = proxy->compileScript(
- v8ExternalString(source),
- String(), // url
- 0); // source start
- res_obj = proxy->runScript(script, true);
- if (try_catch.HasCaught()) {
- v8::Handle<v8::String> msg = try_catch.Message()->Get();
- if (!msg.IsEmpty()) {
- *exception = WebCore::toWebCoreString(msg);
- } else {
- *exception = "Failed to evaluate.";
- }
- return "";
- }
- DCHECK(!res_obj.IsEmpty());
- }
-
- { // Wrap the result.
- v8::Context::Scope context_scope(utility_context);
-
- v8::Handle<v8::Object> devtools = v8::Local<v8::Object>::Cast(
- utility_context->Global()->Get(v8::String::New("devtools$$obj")));
- v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(
- devtools->Get(v8::String::New("serializeConsoleObject")));
-
- v8::Handle<v8::Value> args[] = {
- res_obj
- };
- res_obj = function->Call(devtools, 1, args);
- return WebCore::toWebCoreStringWithNullCheck(res_obj);
- }
-}
-
WebCore::Page* DebuggerAgentImpl::GetPage() {
return web_view_impl_->page();
}
diff --git a/webkit/glue/devtools/debugger_agent_impl.h b/webkit/glue/devtools/debugger_agent_impl.h
index 90f1d34..36c9367 100644
--- a/webkit/glue/devtools/debugger_agent_impl.h
+++ b/webkit/glue/devtools/debugger_agent_impl.h
@@ -57,11 +57,6 @@ class DebuggerAgentImpl : public DebuggerAgent {
const WebCore::String& json_args,
WebCore::String* exception);
- WebCore::String EvaluateJavaScript(
- v8::Handle<v8::Context> utility_context,
- const WebCore::String& source,
- WebCore::String* exception);
-
WebCore::Page* GetPage();
WebDevToolsAgentImpl* webdevtools_agent() { return webdevtools_agent_; };
diff --git a/webkit/glue/devtools/dom_agent.h b/webkit/glue/devtools/dom_agent.h
deleted file mode 100644
index 205e4d9..0000000
--- a/webkit/glue/devtools/dom_agent.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// 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.
-
-#ifndef WEBKIT_GLUE_DEVTOOLS_DOM_AGENT_H_
-#define WEBKIT_GLUE_DEVTOOLS_DOM_AGENT_H_
-
-#include "webkit/glue/devtools/devtools_rpc.h"
-
-// DomAgent is a utility object that covers DOM-related functionality of the
-// WebDevToolsAgent. It is capable of sending DOM tree to the client as well
-// as providing DOM notifications for the nodes known to the client.
-// DomAgent's environment is represented with the DomAgentDelegate interface.
-#define DOM_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4) \
- /* Requests that the document root element is sent to the delegate. */ \
- METHOD0(GetDocumentElement) \
- \
- /* Requests that the element's children are sent to the client. */ \
- METHOD2(GetChildNodes, int /* call_id */, int /* id */) \
- \
- /* Sets attribute value in the element with given id. */ \
- METHOD4(SetAttribute, int /* call_id */, int /* id */, String /* name */, \
- String /* value */) \
- \
- /* Removes attribute from the element with given id. */ \
- METHOD3(RemoveAttribute, int /* call_id */, int /* id */, \
- String /* name */) \
- \
- /* Sets text node value in the node with given id. */ \
- METHOD3(SetTextNodeValue, int /* call_id */, int /* id */, \
- String /* text */) \
- \
- /* Perform search. */ \
- METHOD2(PerformSearch, int /* call_id */, String /* query */) \
- \
- /* Tells dom agent that the client has lost all of the dom-related
- information and is no longer interested in the notifications related to the
- nodes issued earlier. */ \
- METHOD0(DiscardBindings)
-
-DEFINE_RPC_CLASS(DomAgent, DOM_AGENT_STRUCT)
-
-#define DOM_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, \
- METHOD4) \
- /* Response to GetChildNodes. */ \
- METHOD1(DidGetChildNodes, int /* call_id */) \
- \
- /* Perform search. */ \
- METHOD2(DidPerformSearch, int /* call_id */, Value /* results */) \
- \
- /* Ack for the Set/RemoveAttribute, SetTextNodeValue. */ \
- METHOD2(DidApplyDomChange, int /* call_id */, bool /* success */) \
- \
- /* Notifies the delegate that element's attributes are updated. */ \
- METHOD2(AttributesUpdated, int /* id */, Value /* attributes */) \
- \
- /* Sends document element to the delegate. */ \
- METHOD1(SetDocumentElement, Value /* root */) \
- \
- /* Notifies the delegate that element's child nodes have been updated. */ \
- METHOD2(SetChildNodes, int /* parent_id */, Value /* nodes */) \
- \
- /* Notifies the delegate that element's 'has children' state has been
- updated */ \
- METHOD2(HasChildrenUpdated, int /* id */, bool /* new_value */) \
- \
- /* Notifies the delegate that child node has been inserted. */ \
- METHOD3(ChildNodeInserted, int /* parent_id */ , int /* prev_id */, \
- Value /* node */) \
- \
- /* Notifies the delegate that child node has been deleted. */ \
- METHOD2(ChildNodeRemoved, int /* parent_id */, int /* id */)
-
-DEFINE_RPC_CLASS(DomAgentDelegate, DOM_AGENT_DELEGATE_STRUCT)
-
-#endif // WEBKIT_GLUE_DEVTOOLS_DOM_AGENT_H_
diff --git a/webkit/glue/devtools/dom_agent_impl.cc b/webkit/glue/devtools/dom_agent_impl.cc
deleted file mode 100644
index bcd477c..0000000
--- a/webkit/glue/devtools/dom_agent_impl.cc
+++ /dev/null
@@ -1,598 +0,0 @@
-// 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.
-
-#include "config.h"
-
-#include "AtomicString.h"
-#include "DOMWindow.h"
-#include "Document.h"
-#include "Event.h"
-#include "EventListener.h"
-#include "EventNames.h"
-#include "EventTarget.h"
-#include "HTMLFrameOwnerElement.h"
-#include "markup.h"
-#include "MutationEvent.h"
-#include "Node.h"
-#include "NodeList.h"
-#include "PlatformString.h"
-#include "Text.h"
-#include "XPathResult.h"
-#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/Vector.h>
-#undef LOG
-
-#include "base/string_util.h"
-#include "base/values.h"
-#include "webkit/glue/devtools/dom_agent_impl.h"
-#include "webkit/glue/glue_util.h"
-
-using namespace WebCore;
-
-const char DomAgentImpl::kExactTagNames[] = "//*[name() == '%s')]";
-const char DomAgentImpl::kPartialTagNames[] = "//*[contains(name(), '%s')]";
-const char DomAgentImpl::kStartOfTagNames[] = "//*[starts-with(name(), '%s')]";
-const char DomAgentImpl::kPartialTagNamesAndAttributeValues[] =
- "//*[contains(name(), '%s') or contains(@*, '%s')]";
-const char DomAgentImpl::kPartialAttributeValues[] = "//*[contains(@*, '%s')]";
-const char DomAgentImpl::kPlainText[] =
- "//text()[contains(., '%s')] | //comment()[contains(., '%s')]";
-
-// static
-PassRefPtr<DomAgentImpl::EventListenerWrapper>
- DomAgentImpl::EventListenerWrapper::Create(
- DomAgentImpl* dom_agent_impl) {
- return adoptRef(new EventListenerWrapper(dom_agent_impl));
-}
-
-DomAgentImpl::EventListenerWrapper::EventListenerWrapper(
- DomAgentImpl* dom_agent_impl) : dom_agent_impl_(dom_agent_impl) {
-}
-
-void DomAgentImpl::EventListenerWrapper::handleEvent(
- Event* event,
- bool isWindowEvent) {
- dom_agent_impl_->handleEvent(event, isWindowEvent);
-}
-
-DomAgentImpl::DomAgentImpl(DomAgentDelegate* delegate)
- : delegate_(delegate),
- last_node_id_(1),
- document_element_requested_(false) {
- event_listener_ = EventListenerWrapper::Create(this);
-}
-
-DomAgentImpl::~DomAgentImpl() {
- SetDocument(NULL);
-}
-
-void DomAgentImpl::SetDocument(Document* doc) {
- if (doc == GetMainFrameDocument()) {
- return;
- }
-
- ListHashSet<RefPtr<Document> > copy = documents_;
- for (ListHashSet<RefPtr<Document> >::iterator it = copy.begin();
- it != copy.end(); ++it) {
- StopListening((*it).get());
- }
- ASSERT(documents_.size() == 0);
-
- if (doc) {
- StartListening(doc);
- if (document_element_requested_) {
- GetDocumentElement();
- document_element_requested_ = false;
- }
- } else {
- DiscardBindings();
- }
-}
-
-void DomAgentImpl::StartListening(Document* doc) {
- if (documents_.contains(doc)) {
- return;
- }
- doc->addEventListener(eventNames().DOMContentLoadedEvent, event_listener_,
- false);
- doc->addEventListener(eventNames().DOMNodeInsertedEvent, event_listener_,
- false);
- doc->addEventListener(eventNames().DOMNodeRemovedEvent, event_listener_,
- false);
- doc->addEventListener(eventNames().DOMNodeRemovedFromDocumentEvent,
- event_listener_, true);
- doc->addEventListener(eventNames().DOMAttrModifiedEvent, event_listener_,
- false);
- documents_.add(doc);
-}
-
-void DomAgentImpl::StopListening(Document* doc) {
- if (!documents_.contains(doc)) {
- return;
- }
- doc->removeEventListener(eventNames().DOMContentLoadedEvent,
- event_listener_.get(), false);
- doc->removeEventListener(eventNames().DOMNodeInsertedEvent,
- event_listener_.get(), false);
- doc->removeEventListener(eventNames().DOMNodeRemovedEvent,
- event_listener_.get(), false);
- doc->removeEventListener(eventNames().DOMNodeRemovedFromDocumentEvent,
- event_listener_.get(), true);
- doc->removeEventListener(eventNames().DOMAttrModifiedEvent,
- event_listener_.get(), false);
- documents_.remove(doc);
-}
-
-int DomAgentImpl::Bind(Node* node) {
- HashMap<Node*, int>::iterator it = node_to_id_.find(node);
- if (it != node_to_id_.end())
- return it->second;
- int id = last_node_id_++;
- node_to_id_.set(node, id);
- id_to_node_.set(id, node);
- return id;
-}
-
-void DomAgentImpl::Unbind(Node* node) {
- if (node->isFrameOwnerElement()) {
- const HTMLFrameOwnerElement* frame_owner =
- static_cast<const HTMLFrameOwnerElement*>(node);
- StopListening(frame_owner->contentDocument());
- }
-
- HashMap<Node*, int>::iterator it = node_to_id_.find(node);
- if (it != node_to_id_.end()) {
- id_to_node_.remove(id_to_node_.find(it->second));
- children_requested_.remove(children_requested_.find(it->second));
- node_to_id_.remove(it);
- }
-}
-
-void DomAgentImpl::PushDocumentElementToClient() {
- Element* doc_elem = GetMainFrameDocument()->documentElement();
- if (!node_to_id_.contains(doc_elem)) {
- OwnPtr<Value> value(BuildValueForNode(doc_elem, 0));
- delegate_->SetDocumentElement(*value.get());
- }
-}
-
-void DomAgentImpl::PushChildNodesToClient(int element_id) {
- Node* node = GetNodeForId(element_id);
- if (!node || (node->nodeType() != Node::ELEMENT_NODE))
- return;
- if (children_requested_.contains(element_id))
- return;
-
- Element* element = static_cast<Element*>(node);
- OwnPtr<Value> children(BuildValueForElementChildren(element, 1));
- children_requested_.add(element_id);
- delegate_->SetChildNodes(element_id, *children.get());
-}
-
-void DomAgentImpl::DiscardBindings() {
- node_to_id_.clear();
- id_to_node_.clear();
- children_requested_.clear();
-}
-
-Node* DomAgentImpl::GetNodeForId(int id) {
- HashMap<int, Node*>::iterator it = id_to_node_.find(id);
- if (it != id_to_node_.end()) {
- return it->second;
- }
- return NULL;
-}
-
-int DomAgentImpl::GetIdForNode(Node* node) {
- if (node == NULL) {
- return 0;
- }
- HashMap<Node*, int>::iterator it = node_to_id_.find(node);
- if (it != node_to_id_.end()) {
- return it->second;
- }
- return 0;
-}
-
-void DomAgentImpl::handleEvent(Event* event, bool isWindowEvent) {
- AtomicString type = event->type();
- Node* node = event->target()->toNode();
-
- // Remove mapping entry if necessary.
- if (type == eventNames().DOMNodeRemovedFromDocumentEvent) {
- Unbind(node);
- return;
- }
-
- if (type == eventNames().DOMAttrModifiedEvent) {
- int id = GetIdForNode(node);
- if (!id) {
- // Node is not mapped yet -> ignore the event.
- return;
- }
- Element* element = static_cast<Element*>(node);
- OwnPtr<Value> attributesValue(BuildValueForElementAttributes(element));
- delegate_->AttributesUpdated(id, *attributesValue.get());
- } else if (type == eventNames().DOMNodeInsertedEvent) {
- if (IsWhitespace(node)) {
- return;
- }
- Node* parent = static_cast<MutationEvent*>(event)->relatedNode();
- int parent_id = GetIdForNode(parent);
- if (!parent_id) {
- // Parent is not mapped yet -> ignore the event.
- return;
- }
- if (!children_requested_.contains(parent_id)) {
- // No children are mapped yet -> only notify on changes of hasChildren.
- delegate_->HasChildrenUpdated(parent_id, true);
- } else {
- // Children have been requested -> return value of a new child.
- int prev_id = GetIdForNode(InnerPreviousSibling(node));
- OwnPtr<Value> value(BuildValueForNode(node, 0));
- delegate_->ChildNodeInserted(parent_id, prev_id, *value.get());
- }
- } else if (type == eventNames().DOMNodeRemovedEvent) {
- if (IsWhitespace(node)) {
- return;
- }
- Node* parent = static_cast<MutationEvent*>(event)->relatedNode();
- int parent_id = GetIdForNode(parent);
- if (!parent_id) {
- // Parent is not mapped yet -> ignore the event.
- return;
- }
- if (!children_requested_.contains(parent_id)) {
- // No children are mapped yet -> only notify on changes of hasChildren.
- if (InnerChildNodeCount(parent) == 1)
- delegate_->HasChildrenUpdated(parent_id, false);
- } else {
- int id = GetIdForNode(node);
- delegate_->ChildNodeRemoved(parent_id, id);
- }
- } else if (type == eventNames().DOMContentLoadedEvent) {
- // Re-push document once it is loaded.
- DiscardBindings();
- PushDocumentElementToClient();
- }
-}
-
-void DomAgentImpl::GetDocumentElement() {
- Document* main_document = GetMainFrameDocument();
- if (main_document) {
- PushDocumentElementToClient();
- } else {
- document_element_requested_ = true;
- }
-}
-
-void DomAgentImpl::GetChildNodes(int call_id, int element_id) {
- PushChildNodesToClient(element_id);
- delegate_->DidGetChildNodes(call_id);
-}
-
-int DomAgentImpl::PushNodePathToClient(Node* node_to_select) {
- ASSERT(node_to_select); // Invalid input
-
- // If we are sending information to the client that is currently being
- // created. Send root node first.
- PushDocumentElementToClient();
-
- // Return id in case the node is known.
- int result = GetIdForNode(node_to_select);
- if (result)
- return result;
-
- Element* element = InnerParentElement(node_to_select);
- ASSERT(element); // Node is detached or is a document itself
-
- Vector<Element*> path;
- while (element && !GetIdForNode(element)) {
- path.append(element);
- element = InnerParentElement(element);
- }
- // element is known to the client
- ASSERT(element);
- path.append(element);
- for (int i = path.size() - 1; i >= 0; --i) {
- int node_id = GetIdForNode(path.at(i));
- ASSERT(node_id);
- PushChildNodesToClient(node_id);
- }
- return GetIdForNode(node_to_select);
-}
-
-void DomAgentImpl::SetAttribute(
- int call_id,
- int element_id,
- const String& name,
- const String& value) {
- Node* node = GetNodeForId(element_id);
- if (node && (node->nodeType() == Node::ELEMENT_NODE)) {
- Element* element = static_cast<Element*>(node);
- ExceptionCode ec = 0;
- element->setAttribute(name, value, ec);
- delegate_->DidApplyDomChange(call_id, ec == 0);
- } else {
- delegate_->DidApplyDomChange(call_id, false);
- }
-}
-
-void DomAgentImpl::RemoveAttribute(
- int call_id,
- int element_id,
- const String& name) {
- Node* node = GetNodeForId(element_id);
- if (node && (node->nodeType() == Node::ELEMENT_NODE)) {
- Element* element = static_cast<Element*>(node);
- ExceptionCode ec = 0;
- element->removeAttribute(name, ec);
- delegate_->DidApplyDomChange(call_id, ec == 0);
- } else {
- delegate_->DidApplyDomChange(call_id, false);
- }
-}
-
-void DomAgentImpl::SetTextNodeValue(
- int call_id,
- int element_id,
- const String& value) {
- Node* node = GetNodeForId(element_id);
- if (node && (node->nodeType() == Node::TEXT_NODE)) {
- Text* text_node = static_cast<Text*>(node);
- ExceptionCode ec = 0;
- // TODO(pfeldman): Add error handling
- text_node->replaceWholeText(value, ec);
- delegate_->DidApplyDomChange(call_id, ec == 0);
- } else {
- delegate_->DidApplyDomChange(call_id, false);
- }
-}
-
-void DomAgentImpl::PerformSearch(int call_id, const String& query) {
- String tag_name_query = query;
- String attribute_name_query = query;
-
- bool start_tag_found = tag_name_query.startsWith("<", true);
- bool end_tag_found = tag_name_query.endsWith(">", true);
-
- if (start_tag_found || end_tag_found) {
- int tag_name_query_length = tag_name_query.length();
- int start = start_tag_found ? 1 : 0;
- int end = end_tag_found ? tag_name_query_length - 1 : tag_name_query_length;
- tag_name_query = tag_name_query.substring(start, end - start);
- }
-
- Vector<String> xpath_queries;
- xpath_queries.append(String::format(kPlainText, query.utf8().data(),
- query.utf8().data()));
- if (tag_name_query.length() && start_tag_found && end_tag_found) {
- xpath_queries.append(String::format(kExactTagNames,
- tag_name_query.utf8().data()));
- } else if (tag_name_query.length() && start_tag_found) {
- xpath_queries.append(String::format(kStartOfTagNames,
- tag_name_query.utf8().data()));
- } else if (tag_name_query.length() && end_tag_found) {
- // FIXME(pfeldman): we should have a matchEndOfTagNames search function if
- // endTagFound is true but not startTagFound.
- // This requires ends-with() support in XPath, WebKit only supports
- // starts-with() and contains().
- xpath_queries.append(String::format(kPartialTagNames,
- tag_name_query.utf8().data()));
- } else if (query == "//*" || query == "*") {
- // These queries will match every node. Matching everything isn't useful
- // and can be slow for large pages, so limit the search functions list to
- // plain text and attribute matching.
- xpath_queries.append(String::format(kPartialAttributeValues,
- query.utf8().data()));
- } else {
- // TODO(pfeldman): Add more patterns.
- xpath_queries.append(String::format(kPartialTagNamesAndAttributeValues,
- tag_name_query.utf8().data(),
- query.utf8().data()));
- }
-
- ExceptionCode ec = 0;
- Vector<Document*> search_documents;
- Document* main_document = GetMainFrameDocument();
- search_documents.append(main_document);
-
- // Find all frames, iframes and object elements to search their documents.
- RefPtr<NodeList> node_list = main_document->querySelectorAll(
- "iframe, frame, object", ec);
- if (ec) {
- ListValue list;
- delegate_->DidPerformSearch(call_id, list);
- return;
- }
- for (unsigned int i = 0; i < node_list->length(); ++i) {
- Node* node = node_list->item(i);
- if (node->isFrameOwnerElement()) {
- const HTMLFrameOwnerElement* frame_owner =
- static_cast<const HTMLFrameOwnerElement*>(node);
- if (frame_owner->contentDocument()) {
- search_documents.append(search_documents);
- }
- }
- }
-
- HashSet<int> node_ids;
- for (Vector<Document*>::iterator it = search_documents.begin();
- it != search_documents.end(); ++it) {
- for (Vector<String>::iterator qit = xpath_queries.begin();
- qit != xpath_queries.end(); ++qit) {
- String query = *qit;
- RefPtr<XPathResult> result = (*it)->evaluate(query, *it, NULL,
- XPathResult::UNORDERED_NODE_ITERATOR_TYPE, 0, ec);
- if (ec) {
- ListValue list;
- delegate_->DidPerformSearch(call_id, list);
- return;
- }
- Node* node = result->iterateNext(ec);
- while (node && !ec) {
- node_ids.add(PushNodePathToClient(node));
- node = result->iterateNext(ec);
- }
- }
- }
-
- ListValue list;
- for (HashSet<int>::iterator it = node_ids.begin();
- it != node_ids.end(); ++it) {
- list.Append(Value::CreateIntegerValue(*it));
- }
- delegate_->DidPerformSearch(call_id, list);
-}
-
-ListValue* DomAgentImpl::BuildValueForNode(Node* node, int depth) {
- OwnPtr<ListValue> value(new ListValue());
- int id = Bind(node);
- String nodeName;
- String nodeValue;
-
- switch (node->nodeType()) {
- case Node::TEXT_NODE:
- case Node::COMMENT_NODE:
- nodeValue = node->nodeValue();
- break;
- case Node::ATTRIBUTE_NODE:
- case Node::DOCUMENT_NODE:
- case Node::DOCUMENT_FRAGMENT_NODE:
- break;
- case Node::ELEMENT_NODE:
- default: {
- nodeName = node->nodeName();
- break;
- }
- }
-
- value->Append(Value::CreateIntegerValue(id));
- value->Append(Value::CreateIntegerValue(node->nodeType()));
- value->Append(Value::CreateStringValue(
- webkit_glue::StringToStdWString(nodeName)));
- value->Append(Value::CreateStringValue(
- webkit_glue::StringToStdWString(nodeValue)));
-
- if (node->nodeType() == Node::ELEMENT_NODE) {
- Element* element = static_cast<Element*>(node);
- value->Append(BuildValueForElementAttributes(element));
- int nodeCount = InnerChildNodeCount(element);
- value->Append(Value::CreateIntegerValue(nodeCount));
- OwnPtr<ListValue> children(BuildValueForElementChildren(element, depth));
- if (children->GetSize() > 0) {
- value->Append(children.release());
- }
- }
- return value.release();
-}
-
-ListValue* DomAgentImpl::BuildValueForElementAttributes(Element* element) {
- OwnPtr<ListValue> attributes_value(new ListValue());
- // Go through all attributes and serialize them.
- const NamedNodeMap* attr_map = element->attributes(true);
- if (!attr_map) {
- return attributes_value.release();
- }
- unsigned num_attrs = attr_map->length();
- for (unsigned i = 0; i < num_attrs; ++i) {
- // Add attribute pair
- const Attribute *attribute = attr_map->attributeItem(i);
- OwnPtr<Value> name(Value::CreateStringValue(
- webkit_glue::StringToStdWString(attribute->name().toString())));
- OwnPtr<Value> value(Value::CreateStringValue(
- webkit_glue::StringToStdWString(attribute->value())));
- attributes_value->Append(name.release());
- attributes_value->Append(value.release());
- }
- return attributes_value.release();
-}
-
-ListValue* DomAgentImpl::BuildValueForElementChildren(
- Element* element,
- int depth) {
- OwnPtr<ListValue> children(new ListValue());
- if (depth == 0) {
- // Special case the_only text child.
- if (InnerChildNodeCount(element) == 1) {
- Node *child = InnerFirstChild(element);
- if (child->nodeType() == Node::TEXT_NODE) {
- children->Append(BuildValueForNode(child, 0));
- }
- }
- return children.release();
- } else if (depth > 0) {
- depth--;
- }
-
- for (Node *child = InnerFirstChild(element); child != NULL;
- child = InnerNextSibling(child)) {
- children->Append(BuildValueForNode(child, depth));
- }
- return children.release();
-}
-
-Node* DomAgentImpl::InnerFirstChild(Node* node) {
- if (node->isFrameOwnerElement()) {
- HTMLFrameOwnerElement* frame_owner =
- static_cast<HTMLFrameOwnerElement*>(node);
- Document* doc = frame_owner->contentDocument();
- if (doc) {
- StartListening(doc);
- return doc->firstChild();
- }
- }
- node = node->firstChild();
- while (IsWhitespace(node)) {
- node = node->nextSibling();
- }
- return node;
-}
-
-Node* DomAgentImpl::InnerNextSibling(Node* node) {
- do {
- node = node->nextSibling();
- } while (IsWhitespace(node));
- return node;
-}
-
-Node* DomAgentImpl::InnerPreviousSibling(Node* node) {
- do {
- node = node->previousSibling();
- } while (IsWhitespace(node));
- return node;
-}
-
-int DomAgentImpl::InnerChildNodeCount(Node* node) {
- int count = 0;
- Node* child = InnerFirstChild(node);
- while (child) {
- count++;
- child = InnerNextSibling(child);
- }
- return count;
-}
-
-Element* DomAgentImpl::InnerParentElement(Node* node) {
- Element* element = node->parentElement();
- if (!element) {
- return node->ownerDocument()->ownerElement();
- }
- return element;
-}
-
-bool DomAgentImpl::IsWhitespace(Node* node) {
- return node != NULL && node->nodeType() == Node::TEXT_NODE &&
- node->nodeValue().stripWhiteSpace().length() == 0;
-}
-
-Document* DomAgentImpl::GetMainFrameDocument() {
- ListHashSet<RefPtr<WebCore::Document> >::iterator it = documents_.begin();
- if (it != documents_.end()) {
- return it->get();
- }
- return NULL;
-}
diff --git a/webkit/glue/devtools/dom_agent_impl.h b/webkit/glue/devtools/dom_agent_impl.h
deleted file mode 100644
index 5ee584b..0000000
--- a/webkit/glue/devtools/dom_agent_impl.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// 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.
-
-#ifndef WEBKIT_GLUE_DEVTOOLS_DOM_AGENT_IMPL_H_
-#define WEBKIT_GLUE_DEVTOOLS_DOM_AGENT_IMPL_H_
-
-#include "config.h"
-
-#include <wtf/ListHashSet.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-
-#include "webkit/glue/devtools/dom_agent.h"
-
-namespace WebCore {
-class Document;
-class Element;
-class Event;
-class NameNodeMap;
-class Node;
-}
-
-class DictionaryValue;
-class ListValue;
-class Value;
-
-// DomAgent implementation.
-class DomAgentImpl : public DomAgent {
- public:
- explicit DomAgentImpl(DomAgentDelegate* delegate);
- virtual ~DomAgentImpl();
-
- // DomAgent implementation.
- void GetDocumentElement();
- void GetChildNodes(int call_id, int element_id);
- void SetAttribute(
- int call_id,
- int element_id,
- const WebCore::String& name,
- const WebCore::String& value);
- void RemoveAttribute(
- int call_id,
- int element_id,
- const WebCore::String& name);
- void SetTextNodeValue(
- int call_id,
- int element_id,
- const WebCore::String& value);
- void PerformSearch(int call_id, const String& query);
- void DiscardBindings();
-
- // Initializes dom agent with the given document.
- void SetDocument(WebCore::Document* document);
-
- // Returns node for given id according to the present binding.
- WebCore::Node* GetNodeForId(int id);
-
- // Returns id for given node according to the present binding.
- int GetIdForNode(WebCore::Node* node);
-
- // Sends path to a given node to the client. Returns node's id according to
- // the resulting binding. Only sends nodes that are missing on the client.
- int PushNodePathToClient(WebCore::Node* node);
-
- private:
- static const char kExactTagNames[];
- static const char kPartialTagNames[];
- static const char kStartOfTagNames[];
- static const char kPartialTagNamesAndAttributeValues[];
- static const char kPartialAttributeValues[];
- static const char kPlainText[];
-
-// Convenience EventListner wrapper for cleaner Ref management.
- class EventListenerWrapper : public WebCore::EventListener {
- public:
- static PassRefPtr<EventListenerWrapper> Create(
- DomAgentImpl* dom_agent_impl);
- virtual ~EventListenerWrapper() {}
- virtual void handleEvent(WebCore::Event* event, bool is_window_event);
- private:
- explicit EventListenerWrapper(DomAgentImpl* dom_agent_impl);
- DomAgentImpl* dom_agent_impl_;
- DISALLOW_COPY_AND_ASSIGN(EventListenerWrapper);
- };
-
- void StartListening(WebCore::Document* document);
-
- void StopListening(WebCore::Document* document);
-
- // EventListener implementation
- friend class EventListenerWrapper;
- virtual void handleEvent(WebCore::Event* event, bool isWindowEvent);
-
- // Binds given node and returns its generated id.
- int Bind(WebCore::Node* node);
-
- // Releases Node to int binding.
- void Unbind(WebCore::Node* node);
-
- // Pushes document element to the client.
- void PushDocumentElementToClient();
-
- // Pushes child nodes to the client.
- void PushChildNodesToClient(int element_id);
-
- // Serializes given node into the list value.
- ListValue* BuildValueForNode(
- WebCore::Node* node,
- int depth);
-
- // Serializes given element's attributes into the list value.
- static ListValue* BuildValueForElementAttributes(WebCore::Element* elemen);
-
- // Serializes given elements's children into the list value.
- ListValue* BuildValueForElementChildren(
- WebCore::Element* element,
- int depth);
-
- // Serializes CSSStyleDeclaration into a list of properties
- // where aeach property represented as an array as an
- // [name, important, implicit, shorthand, value]
- static ListValue* BuildValueForStyle(
- const WebCore::CSSStyleDeclaration& style);
-
- // We represent embedded doms as a part of the same hierarchy. Hence we
- // treat children of frame owners differently. We also skip whitespace
- // text nodes conditionally. Following four methods encapsulate these
- // specifics.
- WebCore::Node* InnerFirstChild(WebCore::Node* node);
- WebCore::Node* InnerNextSibling(WebCore::Node* node);
- WebCore::Node* InnerPreviousSibling(WebCore::Node* node);
- int InnerChildNodeCount(WebCore::Node* node);
- WebCore::Element* InnerParentElement(WebCore::Node* node);
- bool IsWhitespace(WebCore::Node* node);
-
- WebCore::Document* GetMainFrameDocument();
-
- DomAgentDelegate* delegate_;
- HashMap<WebCore::Node*, int> node_to_id_;
- HashMap<int, WebCore::Node*> id_to_node_;
- HashSet<int> children_requested_;
- int last_node_id_;
- ListHashSet<RefPtr<WebCore::Document> > documents_;
- RefPtr<WebCore::EventListener> event_listener_;
- // Captures pending document element request's call id.
- // Defaults to 0 meaning no pending request.
- bool document_element_requested_;
-
- DISALLOW_COPY_AND_ASSIGN(DomAgentImpl);
-};
-
-#endif // WEBKIT_GLUE_DEVTOOLS_DOM_AGENT_IMPL_H_
diff --git a/webkit/glue/devtools/dom_agent_unittest.cc b/webkit/glue/devtools/dom_agent_unittest.cc
deleted file mode 100644
index ce01a50..0000000
--- a/webkit/glue/devtools/dom_agent_unittest.cc
+++ /dev/null
@@ -1,463 +0,0 @@
-// 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.
-
-#include "config.h"
-
-#include "CString.h"
-#include "Document.h"
-#include "EventListener.h"
-#include "HTMLFrameOwnerElement.h"
-#include "Node.h"
-#include "PlatformString.h"
-#include "Text.h"
-#include <wtf/OwnPtr.h>
-#undef LOG
-
-#include "base/file_path.h"
-#include "base/string_util.h"
-#include "base/values.h"
-#include "net/base/net_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/api/public/WebData.h"
-#include "webkit/api/public/WebFrame.h"
-#include "webkit/api/public/WebURL.h"
-#include "webkit/glue/devtools/devtools_mock_rpc.h"
-#include "webkit/glue/devtools/devtools_rpc.h"
-#include "webkit/glue/devtools/dom_agent_impl.h"
-#include "webkit/glue/dom_operations.h"
-#include "webkit/glue/glue_util.h"
-#include "webkit/glue/webframe_impl.h"
-#include "webkit/glue/webview.h"
-#include "webkit/tools/test_shell/test_shell_test.h"
-
-using WebCore::Document;
-using WebCore::Element;
-using WebCore::ExceptionCode;
-using WebCore::HTMLFrameOwnerElement;
-using WebCore::Node;
-using WebCore::String;
-using WebCore::Text;
-using WebKit::WebFrame;
-
-namespace {
-
-class MockDomAgentDelegate : public DomAgentDelegateStub,
- public DevToolsMockRpc {
- public:
- MockDomAgentDelegate() : DomAgentDelegateStub(NULL) {
- set_delegate(this);
- }
- ~MockDomAgentDelegate() {}
-};
-
-class DomAgentTests : public TestShellTest {
- public:
- DomAgentTests() : ec_(0) {}
-
- protected:
- // testing::Test
- virtual void SetUp() {
- TestShellTest::SetUp();
- test_shell_->ResetTestController();
- GURL file_url = net::FilePathToFileURL(data_dir_);
- WebFrame* main_frame = test_shell_->webView()->GetMainFrame();
- main_frame->loadHTMLString("<html> <head> </head> <body> </body> </html>",
- file_url);
- WebFrameImpl* main_frame_impl = static_cast<WebFrameImpl*>(main_frame);
-
- document_ = main_frame_impl->frame()->document();
- Node* html = document_->documentElement();
- head_ = static_cast<Element*>(html->firstChild());
- body_ = static_cast<Element*>(head_->nextSibling());
- mock_delegate_.set(new MockDomAgentDelegate());
- dom_agent_.set(new DomAgentImpl(mock_delegate_.get()));
- dom_agent_->SetDocument(document_.get());
- }
-
- virtual void TearDown() {
- TestShellTest::TearDown();
- dom_agent_.set(NULL);
- body_ = NULL;
- document_ = NULL;
- }
-
- static const int kHtmlElemId = 1;
- static const int kHeadElemId = 2;
- static const int kBodyElemId = 3;
- enum {
- kCallIdAny = 0,
- kCallId1,
- kCallId2,
- kCallId3,
- kCallId4
- };
-
- RefPtr<Document> document_;
- RefPtr<Element> head_;
- RefPtr<Element> body_;
- OwnPtr<DomAgentImpl> dom_agent_;
- ExceptionCode ec_;
- OwnPtr<MockDomAgentDelegate> mock_delegate_;
-};
-
-// Requests document node and tests that the callback with the serialized
-// version is called.
-TEST_F(DomAgentTests, GetDocumentElement) {
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[1,1,\"HTML\",\"\",[],2]"));
- mock_delegate_->SetDocumentElement(*v.get());
- mock_delegate_->Replay();
-
- dom_agent_->GetDocumentElement();
- mock_delegate_->Verify();
-}
-
-// Requests element's children and tests that the callback with the serialized
-// version is called.
-TEST_F(DomAgentTests, GetChildNodes) {
- dom_agent_->GetDocumentElement();
- mock_delegate_->Reset();
-
- OwnPtr<Value> v(DevToolsRpc::ParseMessage(
- "[[2,1,\"HEAD\",\"\",[],0],[3,1,\"BODY\",\"\",[],0]]"));
- mock_delegate_->SetChildNodes(kHtmlElemId, *v.get());
- mock_delegate_->DidGetChildNodes(kCallId2);
- mock_delegate_->Replay();
-
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeInsertedUnknownParent) {
- dom_agent_->GetDocumentElement();
- mock_delegate_->Reset();
-
- // There should be no events fired until parent node is known to client.
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
- mock_delegate_->Replay();
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeInsertedKnownParent) {
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // but the event should not be specific.
- mock_delegate_->HasChildrenUpdated(kBodyElemId, true);
- mock_delegate_->Replay();
-
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeInsertedKnownChildren) {
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // Since children were already requested, event should have all the
- // new child data.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[4,1,\"DIV\",\"\",[],0]"));
- mock_delegate_->ChildNodeInserted(kBodyElemId, 0, *v.get());
- mock_delegate_->Replay();
-
- // Blank text should be transparent.
- RefPtr<Text> text = document_->createTextNode(" ");
- body_->appendChild(text, ec_);
-
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired after push path to
-// node request.
-TEST_F(DomAgentTests, ChildNodeInsertedAfterPushPathToNode) {
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->PushNodePathToClient(div.get());
- mock_delegate_->Reset();
-
- // Since children were already requested via path to node, event should have
- // all the new child data.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[5,1,\"DIV\",\"\",[],0]"));
- mock_delegate_->ChildNodeInserted(kBodyElemId, 4, *v.get());
- mock_delegate_->Replay();
-
- RefPtr<Element> div2 = document_->createElement("DIV", ec_);
- body_->appendChild(div2, ec_);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodePrepend) {
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // Since children were already requested, event should have all the
- // new child data.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[5,1,\"DIV\",\"\",[],0]"));
- mock_delegate_->ChildNodeInserted(kBodyElemId, 0, *v.get());
- mock_delegate_->Replay();
-
- RefPtr<Element> new_div = document_->createElement("DIV", ec_);
- body_->insertBefore(new_div, div.get(), ec_, false);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeAppend) {
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // Since children were already requested, event should have all the
- // new child data.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[5,1,\"DIV\",\"\",[],0]"));
- mock_delegate_->ChildNodeInserted(kBodyElemId, 4, *v.get());
- mock_delegate_->Replay();
-
- RefPtr<Element> new_div = document_->createElement("DIV", ec_);
- body_->appendChild(new_div, ec_, false);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeInsert) {
- RefPtr<Element> div1 = document_->createElement("DIV", ec_);
- body_->appendChild(div1, ec_);
- RefPtr<Element> div2 = document_->createElement("DIV", ec_);
- body_->appendChild(div2, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // Since children were already requested, event should have all the
- // new child data.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[6,1,\"DIV\",\"\",[],0]"));
- mock_delegate_->ChildNodeInserted(kBodyElemId, 4, *v.get());
- mock_delegate_->Replay();
-
- RefPtr<Element> new_div = document_->createElement("DIV", ec_);
- body_->insertBefore(new_div, div2.get(), ec_, false);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeRemovedUnknownParent) {
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
-
- dom_agent_->GetDocumentElement();
- mock_delegate_->Reset();
-
- // There should be no events fired until parent node is known to client.
- mock_delegate_->Replay();
- body_->removeChild(div.get(), ec_);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeRemovedKnownParent) {
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // but the event should not be specific.
- mock_delegate_->HasChildrenUpdated(kBodyElemId, false);
- mock_delegate_->Replay();
-
- body_->removeChild(div.get(), ec_);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeRemovedKnownChildren) {
- RefPtr<Element> div = document_->createElement("DIV", ec_);
- body_->appendChild(div, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // Since children were already requested, event should have removed child id.
- mock_delegate_->ChildNodeRemoved(kBodyElemId, 4);
- mock_delegate_->Replay();
-
- body_->removeChild(div.get(), ec_);
- mock_delegate_->Verify();
-}
-
-// Tests that "PushNodePathToClient" sends all missing events in path.
-TEST_F(DomAgentTests, PushPathToKnownNode) {
- RefPtr<Element> div1 = document_->createElement("DIV", ec_);
- body_->appendChild(div1, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // We expect no messages - node is already known.
- mock_delegate_->Replay();
-
- int id = dom_agent_->PushNodePathToClient(div1.get());
- mock_delegate_->Verify();
- EXPECT_EQ(4, id);
-}
-
-// Tests that "PushNodePathToClient" sends all missing events in path.
-TEST_F(DomAgentTests, PushPathToKnownParent) {
- RefPtr<Element> div1 = document_->createElement("DIV", ec_);
- body_->appendChild(div1, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- mock_delegate_->Reset();
-
- OwnPtr<Value> v1(DevToolsRpc::ParseMessage("[[4,1,\"DIV\",\"\",[],0]]"));
- mock_delegate_->SetChildNodes(kBodyElemId, *v1.get());
- mock_delegate_->Replay();
-
- int id = dom_agent_->PushNodePathToClient(div1.get());
- mock_delegate_->Verify();
- EXPECT_EQ(4, id);
-}
-
-// Tests that "PushNodePathToClient" sends all missing events in path.
-TEST_F(DomAgentTests, PushPathToUnknownNode) {
- RefPtr<Element> div1 = document_->createElement("DIV", ec_);
- RefPtr<Element> div2 = document_->createElement("DIV", ec_);
- RefPtr<Element> div3 = document_->createElement("DIV", ec_);
- RefPtr<Element> div4 = document_->createElement("DIV", ec_);
- body_->appendChild(div1, ec_);
- div1->appendChild(div2, ec_);
- div2->appendChild(div3, ec_);
- div3->appendChild(div4, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- mock_delegate_->Reset();
-
- OwnPtr<Value> v1(DevToolsRpc::ParseMessage("[[4,1,\"DIV\",\"\",[],1]]"));
- OwnPtr<Value> v2(DevToolsRpc::ParseMessage("[[5,1,\"DIV\",\"\",[],1]]"));
- OwnPtr<Value> v3(DevToolsRpc::ParseMessage("[[6,1,\"DIV\",\"\",[],1]]"));
- OwnPtr<Value> v4(DevToolsRpc::ParseMessage("[[7,1,\"DIV\",\"\",[],0]]"));
- mock_delegate_->SetChildNodes(kBodyElemId, *v1.get());
- mock_delegate_->SetChildNodes(4, *v2.get());
- mock_delegate_->SetChildNodes(5, *v3.get());
- mock_delegate_->SetChildNodes(6, *v4.get());
- mock_delegate_->Replay();
-
- int id = dom_agent_->PushNodePathToClient(div4.get());
- mock_delegate_->Verify();
- EXPECT_EQ(7, id);
-}
-
-// Tests that "GetChildNodes" crosses frame owner boundaries.
-TEST_F(DomAgentTests, GetChildNodesOfFrameOwner) {
- RefPtr<Element> iframe = document_->createElement("IFRAME", ec_);
- body_->appendChild(iframe, ec_);
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallId3, kBodyElemId);
- mock_delegate_->Reset();
-
- // Expecting HTML child with two (head, body) children.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[[5,1,\"HTML\",\"\",[],2]]"));
- mock_delegate_->SetChildNodes(4, *v.get());
- mock_delegate_->DidGetChildNodes(kCallId4);
- mock_delegate_->Replay();
-
- dom_agent_->GetChildNodes(kCallId4, 4);
- mock_delegate_->Verify();
-}
-
-// Tests that "PushNodePathToClient" crosses frame owner boundaries.
-TEST_F(DomAgentTests, SendPathToNodeOverFrameOwner) {
- RefPtr<Element> iframe = document_->createElement("IFRAME", ec_);
- body_->appendChild(iframe, ec_);
- HTMLFrameOwnerElement* frame_owner =
- static_cast<HTMLFrameOwnerElement*>(iframe.get());
- Node* inner_body = frame_owner->contentDocument()->firstChild()->
- firstChild();
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallId2, kHtmlElemId);
- mock_delegate_->Reset();
-
- OwnPtr<Value> v1(DevToolsRpc::ParseMessage("[[4,1,\"IFRAME\",\"\",[],1]]"));
- OwnPtr<Value> v2(DevToolsRpc::ParseMessage("[[5,1,\"HTML\",\"\",[],2]]"));
- OwnPtr<Value> v3(DevToolsRpc::ParseMessage(
- "[[6,1,\"HEAD\",\"\",[],0],[7,1,\"BODY\",\"\",[],0]]"));
- mock_delegate_->SetChildNodes(3, *v1.get());
- mock_delegate_->SetChildNodes(4, *v2.get());
- mock_delegate_->SetChildNodes(5, *v3.get());
- mock_delegate_->Replay();
-
- dom_agent_->PushNodePathToClient(inner_body);
- mock_delegate_->Verify();
-}
-
-// Tests that "child node inserted" event is being fired.
-TEST_F(DomAgentTests, ChildNodeInsertUnderFrameOwner) {
- RefPtr<Element> iframe = document_->createElement("IFRAME", ec_);
- body_->appendChild(iframe, ec_);
- HTMLFrameOwnerElement* frame_owner =
- static_cast<HTMLFrameOwnerElement*>(iframe.get());
- Node* inner_body = frame_owner->contentDocument()->firstChild()->
- firstChild()->nextSibling();
-
- dom_agent_->GetDocumentElement();
- dom_agent_->GetChildNodes(kCallIdAny, kHtmlElemId);
- dom_agent_->GetChildNodes(kCallIdAny, kBodyElemId);
- dom_agent_->GetChildNodes(kCallIdAny, 4); // IFrame children
- dom_agent_->GetChildNodes(kCallIdAny, 5); // IFrame html's children
- dom_agent_->GetChildNodes(kCallIdAny, 7); // IFrame body's children
- mock_delegate_->Reset();
-
- // There should be an event fired in case parent node is known to client,
- // Since children were already requested, event should have all the
- // new child data.
- OwnPtr<Value> v(DevToolsRpc::ParseMessage("[8,1,\"DIV\",\"\",[],0]"));
- mock_delegate_->ChildNodeInserted(7, 0, *v.get());
- mock_delegate_->Replay();
-
- RefPtr<Element> new_div = document_->createElement("DIV", ec_);
- inner_body->appendChild(new_div.get(), ec_, false);
- mock_delegate_->Verify();
-}
-
-} // namespace
diff --git a/webkit/glue/devtools/js/devtools.html b/webkit/glue/devtools/js/devtools.html
index 2bc83c7..a568f67 100644
--- a/webkit/glue/devtools/js/devtools.html
+++ b/webkit/glue/devtools/js/devtools.html
@@ -49,7 +49,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="treeoutline.js"></script>
<script type="text/javascript" src="devtools_callback.js"></script>
<script type="text/javascript" src="debugger_agent.js"></script>
- <script type="text/javascript" src="dom_agent.js"></script>
<script type="text/javascript" src="inspector_controller.js"></script>
<script type="text/javascript" src="inspector.js"></script>
<script type="text/javascript" src="codemap.js"></script>
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index be76df6..16cbd0f 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -10,7 +10,6 @@
goog.provide('devtools.Tools');
goog.require('devtools.DebuggerAgent');
-goog.require('devtools.DomAgent');
/**
@@ -36,11 +35,8 @@ devtools.dispatch = function(remoteName, methodName, msg) {
devtools.ToolsAgent = function() {
- RemoteToolsAgent.DidEvaluateJavaScript = devtools.Callback.processCallback;
RemoteToolsAgent.DidExecuteUtilityFunction =
devtools.Callback.processCallback;
- RemoteToolsAgent.UpdateFocusedNode =
- goog.bind(this.updateFocusedNode_, this);
RemoteToolsAgent.FrameNavigate =
goog.bind(this.frameNavigate_, this);
RemoteToolsAgent.DispatchOnClient =
@@ -48,7 +44,6 @@ devtools.ToolsAgent = function() {
RemoteToolsAgent.SetResourcesPanelEnabled =
goog.bind(this.setResourcesPanelEnabled_, this);
this.debuggerAgent_ = new devtools.DebuggerAgent();
- this.domAgent_ = new devtools.DomAgent();
};
@@ -57,10 +52,7 @@ devtools.ToolsAgent = function() {
*/
devtools.ToolsAgent.prototype.reset = function() {
DevToolsHost.reset();
- this.domAgent_.reset();
this.debuggerAgent_.reset();
-
- this.domAgent_.getDocumentElementAsync();
};
@@ -72,16 +64,7 @@ devtools.ToolsAgent.prototype.reset = function() {
*/
devtools.ToolsAgent.prototype.evaluateJavaScript = function(script,
opt_callback) {
- var callbackId = devtools.Callback.wrap(function(result, exception) {
- if (opt_callback) {
- if (exception) {
- opt_callback(exception, true /* result is exception */);
- } else {
- opt_callback(JSON.parse(result), false);
- }
- }
- });
- RemoteToolsAgent.EvaluateJavaScript(callbackId, script);
+ InspectorController.evaluate(script, opt_callback || function() {});
};
@@ -92,24 +75,6 @@ devtools.ToolsAgent.prototype.getDebuggerAgent = function() {
return this.debuggerAgent_;
};
-/**
- * DomAgent accessor.
- * @return {devtools.DomAgent} Dom agent instance.
- */
-devtools.ToolsAgent.prototype.getDomAgent = function() {
- return this.domAgent_;
-};
-
-
-/**
- * @see tools_agent.h
- * @private
- */
-devtools.ToolsAgent.prototype.updateFocusedNode_ = function(nodeId) {
- var node = this.domAgent_.getNodeForId(nodeId);
- WebInspector.updateFocusedNode(node);
-};
-
/**
* @param {string} url Url frame navigated to.
@@ -251,94 +216,6 @@ var webkitUpdateChildren =
/**
- * @override
- */
-WebInspector.ElementsTreeElement.prototype.updateChildren = function() {
- var self = this;
- devtools.tools.getDomAgent().getChildNodesAsync(this.representedObject,
- function() {
- webkitUpdateChildren.call(self);
- });
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.performSearch = function(query) {
- this.searchCanceled();
- devtools.tools.getDomAgent().performSearch(query,
- goog.bind(this.performSearchCallback_, this));
-};
-
-
-WebInspector.ElementsPanel.prototype.performSearchCallback_ = function(nodes) {
- for (var i = 0; i < nodes.length; ++i) {
- var treeElement = this.treeOutline.findTreeElement(nodes[i]);
- if (treeElement)
- treeElement.highlighted = true;
- }
-
- if (nodes.length) {
- this.currentSearchResultIndex_ = 0;
- this.focusedDOMNode = nodes[0];
- }
-
- this.searchResultCount_ = nodes.length;
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.searchCanceled = function() {
- this.currentSearchResultIndex_ = 0;
- this.searchResultCount_ = 0;
- devtools.tools.getDomAgent().searchCanceled(
- goog.bind(this.searchCanceledCallback_, this));
-};
-
-
-WebInspector.ElementsPanel.prototype.searchCanceledCallback_ = function(nodes) {
- for (var i = 0; i < nodes.length; i++) {
- var treeElement = this.treeOutline.findTreeElement(nodes[i]);
- if (treeElement)
- treeElement.highlighted = false;
- }
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.jumpToNextSearchResult = function() {
- if (!this.searchResultCount_)
- return;
-
- if (++this.currentSearchResultIndex_ >= this.searchResultCount_)
- this.currentSearchResultIndex_ = 0;
-
- this.focusedDOMNode = devtools.tools.getDomAgent().
- getSearchResultNode(this.currentSearchResultIndex_);
-};
-
-
-/**
- * @override
- */
-WebInspector.ElementsPanel.prototype.jumpToPreviousSearchResult = function() {
- if (!this.searchResultCount_)
- return;
-
- if (--this.currentSearchResultIndex_ < 0)
- this.currentSearchResultIndex_ = this.searchResultCount_ - 1;
-
- this.focusedDOMNode = devtools.tools.getDomAgent().
- getSearchResultNode(this.currentSearchResultIndex_);
-};
-
-
-/**
* This override is necessary for adding script source asynchronously.
* @override
*/
@@ -382,39 +259,6 @@ WebInspector.ScriptView.prototype.didResolveScriptSource_ = function() {
/**
- * Callback function used with the getNodeProperties.
- */
-WebInspector.didGetNodePropertiesAsync_ = function(treeOutline, constructor,
- nodeId, path, json) {
- var props = JSON.parse(json);
- var properties = [];
- var obj = {};
- obj.devtools$$nodeId_ = nodeId;
- obj.devtools$$path_ = path;
- for (var i = 0; i < props.length; i += 4) {
- var type = props[i];
- var name = props[i + 1];
- var value = props[i + 2];
- var className = props[i + 3];
- properties.push(name);
- if (type == 'object' || type == 'function') {
- // fake object is going to be replaced on expand.
- obj[name] = new WebInspector.UnresolvedPropertyValue(type, className);
- } else {
- obj[name] = value;
- }
- }
- properties.sort();
- treeOutline.removeChildren();
-
- for (var i = 0; i < properties.length; ++i) {
- var propertyName = properties[i];
- treeOutline.appendChild(new constructor(obj, propertyName));
- }
-};
-
-
-/**
* @param {string} type Type of the the property value('object' or 'function').
* @param {string} className Class name of the property value.
* @constructor
@@ -655,17 +499,6 @@ WebInspector.ScriptsPanel.prototype.__defineGetter__(
WebInspector.searchableViews_);
-WebInspector.ConsoleView.prototype.doEvalInWindow =
- function(expression, callback) {
- if (!expression ) {
- // Empty expression should evaluate to the global object for completions to
- // work.
- expression = "this";
- }
- devtools.tools.evaluateJavaScript(expression, callback);
-};
-
-
WebInspector.ScriptsPanel.prototype.doEvalInCallFrame =
function(callFrame, expression, callback) {
if (!expression) {
diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js
index 73255fe..783d29c 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -81,107 +81,6 @@ RemoteDebuggerAgentStub.prototype.GetNextLogLines = function() {
/**
* @constructor
*/
-RemoteDomAgentStub = function() {
-};
-
-
-RemoteDomAgentStub.sendDocumentElement_ = function() {
- RemoteDomAgent.SetDocumentElement([
- 1, // id
- 1, // type = Node.ELEMENT_NODE,
- 'HTML', // nodeName
- '', // nodeValue
- ['foo','bar'], // attributes
- 2, // childNodeCount
- ]);
-};
-
-
-RemoteDomAgentStub.sendChildNodes_ = function(id) {
- if (id == 1) {
- RemoteDomAgent.SetChildNodes(id,
- [
- [
- 2, // id
- 1, // type = Node.ELEMENT_NODE,
- 'DIV', // nodeName
- '', // nodeValue
- ['foo','bar'], // attributes
- 1, // childNodeCount
- ],
- [
- 3, // id
- 3, // type = Node.TEXT_NODE,
- '', // nodeName
- 'Text', // nodeValue
- ]
- ]);
- } else if (id == 2) {
- RemoteDomAgent.SetChildNodes(id,
- [
- [
- 4, // id
- 1, // type = Node.ELEMENT_NODE,
- 'span', // nodeName
- '', // nodeValue
- ['foo','bar'], // attributes
- 0, // childNodeCount
- ]
- ]);
- }
-};
-
-
-RemoteDomAgentStub.prototype.GetDocumentElement = function(callId) {
- setTimeout(function() {
- RemoteDomAgentStub.sendDocumentElement_();
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.GetChildNodes = function(callId, id) {
- setTimeout(function() {
- RemoteDomAgentStub.sendChildNodes_(id);
- RemoteDomAgent.DidGetChildNodes(callId);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.SetAttribute = function(callId) {
- setTimeout(function() {
- RemoteDomAgent.DidApplyDomChange(callId, true);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.RemoveAttribute = function(callId) {
- setTimeout(function() {
- RemoteDomAgent.DidApplyDomChange(callId, true);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.SetTextNodeValue = function(callId) {
- setTimeout(function() {
- RemoteDomAgent.DidApplyDomChange(callId, true);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.PerformSearch = function(callId, query) {
- setTimeout(function() {
- RemoteDomAgent.DidPerformSearch(callId, [1]);
- }, 0);
-};
-
-
-RemoteDomAgentStub.prototype.DiscardBindings = function() {
-};
-
-
-/**
- * @constructor
- */
RemoteToolsAgentStub = function() {
};
@@ -259,18 +158,6 @@ RemoteToolsAgentStub.prototype.ExecuteUtilityFunction = function(callId,
};
-RemoteToolsAgentStub.prototype.GetNodePrototypes = function(callId, nodeId) {
- setTimeout(function() {
- RemoteToolsAgent.DidGetNodePrototypes(callId,
- JSON.stringify());
- }, 0);
-};
-
-
-RemoteToolsAgentStub.prototype.ClearConsoleMessages = function() {
-};
-
-
RemoteToolsAgentStub.prototype.SetResourceTrackingEnabled = function(enabled, always) {
RemoteToolsAgent.SetResourcesPanelEnabled(enabled);
if (enabled) {
@@ -384,12 +271,7 @@ function addDummyResource() {
DevToolsHostStub.prototype.loaded = function() {
- RemoteDomAgentStub.sendDocumentElement_();
- RemoteDomAgentStub.sendChildNodes_(1);
- RemoteDomAgentStub.sendChildNodes_(2);
- devtools.tools.updateFocusedNode_(4);
addDummyResource();
-
uiTests.runAllTests();
};
@@ -417,7 +299,6 @@ if (!window['DevToolsHost']) {
window['RemoteDebuggerAgent'] = new RemoteDebuggerAgentStub();
window['RemoteDebuggerCommandExecutor'] =
new RemoteDebuggerCommandExecutorStub();
- window['RemoteDomAgent'] = new RemoteDomAgentStub();
window['RemoteToolsAgent'] = new RemoteToolsAgentStub();
window['DevToolsHost'] = new DevToolsHostStub();
}
diff --git a/webkit/glue/devtools/js/dom_agent.js b/webkit/glue/devtools/js/dom_agent.js
deleted file mode 100644
index ca08205..0000000
--- a/webkit/glue/devtools/js/dom_agent.js
+++ /dev/null
@@ -1,746 +0,0 @@
-// 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 Dom and DomNode are used to represent remote DOM in the
- * web inspector.
- */
-goog.provide('devtools.DomAgent');
-goog.provide('devtools.DomDocument');
-goog.provide('devtools.DomNode');
-
-goog.require('devtools.Callback');
-
-
-/**
- * Defines indexes for the node payload properties.
- */
-devtools.PayloadIndex = {
- ID : 0,
- TYPE : 1,
- NAME : 2,
- VALUE : 3,
- ATTRS : 4,
- HAS_CHILDREN : 5,
- CHILD_NODES : 6
-};
-
-
-/**
- * Creates document node in a given document based on a given payload data.
- * @param {devtools.Doc} doc Document to create node in.
- * @param {Array.<Object>} payload Data to build node based upon.
- * @constructor
- */
-devtools.DomNode = function(doc, payload) {
- this.ownerDocument = doc;
-
- this.id_ = payload[devtools.PayloadIndex.ID];
- this.nodeType = payload[devtools.PayloadIndex.TYPE];
- this.nodeName = payload[devtools.PayloadIndex.NAME];
- this.nodeValue_ = payload[devtools.PayloadIndex.VALUE];
- this.textContent = this.nodeValue;
-
- this.attributes = [];
- this.attributesMap_ = {};
- if (payload.length > devtools.PayloadIndex.ATTRS) {
- this.setAttributesPayload_(payload[devtools.PayloadIndex.ATTRS]);
- }
-
- this.childNodesCount_ = payload[devtools.PayloadIndex.HAS_CHILDREN];
- this.children = null;
-
- this.nextSibling = null;
- this.prevSibling = null;
- this.firstChild = null;
- this.parentNode = null;
-
- if (payload.length > devtools.PayloadIndex.CHILD_NODES) {
- // Has children payloads
- this.setChildrenPayload_(
- payload[devtools.PayloadIndex.CHILD_NODES]);
- }
-};
-
-
-/**
- * Overrides for getters and setters.
- */
-devtools.DomNode.prototype = {
- get nodeValue() {
- return this.nodeValue_;
- },
-
- set nodeValue(value) {
- if (this.nodeType != Node.TEXT_NODE) {
- return;
- }
- var self = this;
- this.ownerDocument.domAgent_.setTextNodeValueAsync(this, value,
- function() {
- self.nodeValue_ = value;
- self.textContent = value;
- });
- }
-};
-
-
-/**
- * Sets attributes for a given node based on a given attrs payload.
- * @param {Array.<string>} attrs Attribute key-value pairs to set.
- * @private
- */
-devtools.DomNode.prototype.setAttributesPayload_ = function(attrs) {
- for (var i = 0; i < attrs.length; i += 2) {
- this.addAttribute_(attrs[i], attrs[i + 1]);
- }
-};
-
-
-/**
- * @return True iff node has attributes.
- */
-devtools.DomNode.prototype.hasAttributes = function() {
- return this.attributes.length > 0;
-};
-
-
-/**
- * @return True iff node has child nodes.
- */
-devtools.DomNode.prototype.hasChildNodes = function() {
- return this.childNodesCount_ > 0;
-};
-
-
-/**
- * Inserts child node into this node after a given anchor.
- * @param {devtools.DomNode} prev Node to insert child after.
- * @param {Array.<Object>} payload Child node data.
- * @private
- */
-devtools.DomNode.prototype.insertChild_ = function(prev, payload) {
- var node = new devtools.DomNode(this.ownerDocument, payload);
- if (!prev) {
- // First node
- this.children = [ node ];
- } else {
- this.children.splice(this.children.indexOf(prev) + 1, 0, node);
- }
- this.renumber_();
- return node;
-};
-
-
-/**
- * Removes child node from this node.
- * @param {devtools.DomNode} node Node to remove.
- * @private
- */
-devtools.DomNode.prototype.removeChild_ = function(node) {
- this.children.splice(this.children.indexOf(node), 1);
- node.parentNode = null;
- this.renumber_();
-};
-
-
-/**
- * Sets children for this node based on the given payload.
- * @param {Array.<Object>} payload Data for children.
- * @private
- */
-devtools.DomNode.prototype.setChildrenPayload_ = function(payloads) {
- this.children = [];
- for (var i = 0; i < payloads.length; ++i) {
- var payload = payloads[i];
- var node = new devtools.DomNode(this.ownerDocument, payload);
- this.children.push(node);
- }
- this.renumber_();
-};
-
-
-/**
- * Normalizes prev/next/parent/firstChild links for this node's children.
- * @private
- */
-devtools.DomNode.prototype.renumber_ = function() {
- this.childNodesCount_ = this.children.length;
- if (this.childNodesCount_ == 0) {
- this.firstChild = null;
- return;
- }
- this.firstChild = this.children[0];
- for (var i = 0; i < this.childNodesCount_; ++i) {
- var child = this.children[i];
- child.nextSibling = i + 1 < this.childNodesCount_ ?
- this.children[i + 1] : null;
- child.prevSibling = i - 1 >= 0 ? this.children[i - 1] : null;
- child.parentNode = this;
- }
-};
-
-
-/**
- * Returns attribute value.
- * @param {string} name Attribute name to get value for.
- * @return {string} Attribute value.
- */
-devtools.DomNode.prototype.getAttribute = function(name) {
- var attr = this.attributesMap_[name];
- return attr ? attr.value : undefined;
-};
-
-
-/**
- * Sends 'set attribute' command to the remote agent.
- * @param {string} name Attribute name to set value for.
- * @param {string} value Attribute value to set.
- */
-devtools.DomNode.prototype.setAttribute = function(name, value) {
- var self = this;
- this.ownerDocument.domAgent_.setAttributeAsync(this, name, value,
- function() {
- var attr = self.attributesMap_[name];
- if (attr) {
- attr.value = value;
- } else {
- attr = self.addAttribute_(name, value);
- }
- });
-};
-
-
-/**
- * Creates an attribute-like object and adds it to the object.
- * @param {string} name Attribute name to set value for.
- * @param {string} value Attribute value to set.
- */
-devtools.DomNode.prototype.addAttribute_ = function(name, value) {
- var attr = {
- 'name': name,
- 'value': value,
- node_: this
- };
-
- this.attributesMap_[name] = attr;
- this.attributes.push(attr);
-};
-
-
-/**
- * Sends 'remove attribute' command to the remote agent.
- * @param {string} name Attribute name to set value for.
- */
-devtools.DomNode.prototype.removeAttribute = function(name) {
- var self = this;
- this.ownerDocument.domAgent_.removeAttributeAsync(this, name, function() {
- delete self.attributesMap_[name];
- for (var i = 0; i < self.attributes.length; ++i) {
- if (self.attributes[i].name == name) {
- self.attributes.splice(i, 1);
- break;
- }
- }
- });
-};
-
-
-/**
- * Remote Dom document abstraction.
- * @param {devtools.DomAgent} domAgent owner agent.
- * @param {devtools.DomWindow} defaultView owner window.
- * @constructor.
- */
-devtools.DomDocument = function(domAgent, defaultView) {
- devtools.DomNode.call(this, null,
- [
- 0, // id
- 9, // type = Node.DOCUMENT_NODE,
- '', // nodeName
- '', // nodeValue
- [], // attributes
- 0, // childNodeCount
- ]);
- this.listeners_ = {};
- this.domAgent_ = domAgent;
- this.defaultView = defaultView;
-};
-goog.inherits(devtools.DomDocument, devtools.DomNode);
-
-
-/**
- * Adds event listener to the Dom.
- * @param {string} name Event name.
- * @param {function(Event):undefined} callback Listener callback.
- * @param {bool} useCapture Listener's useCapture settings.
- */
-devtools.DomDocument.prototype.addEventListener =
- function(name, callback, useCapture) {
- var listeners = this.listeners_[name];
- if (!listeners) {
- listeners = [];
- this.listeners_[name] = listeners;
- }
- listeners.push(callback);
-};
-
-
-/**
- * Removes event listener from the Dom.
- * @param {string} name Event name.
- * @param {function(Event):undefined} callback Listener callback.
- * @param {bool} useCapture Listener's useCapture settings.
- */
-devtools.DomDocument.prototype.removeEventListener =
- function(name, callback, useCapture) {
- var listeners = this.listeners_[name];
- if (!listeners) {
- return;
- }
- var index = listeners.indexOf(callback);
- if (index != -1) {
- listeners.splice(index, 1);
- }
-};
-
-
-/**
- * Fires Dom event to the listeners for given event type.
- * @param {string} name Event type.
- * @param {Event} event Event to fire.
- * @private
- */
-devtools.DomDocument.prototype.fireDomEvent_ = function(name, event) {
- var listeners = this.listeners_[name];
- if (!listeners) {
- return;
- }
- for (var i = 0; i < listeners.length; ++i) {
- listeners[i](event);
- }
-};
-
-
-
-/**
- * Simulation of inspected DOMWindow.
- * @param {devtools.DomAgent} domAgent owner agent.
- * @constructor
- */
-devtools.DomWindow = function(domAgent) {
- this.document = new devtools.DomDocument(domAgent, this);
-};
-
-
-/**
- * Represents DOM Node class.
- */
-devtools.DomWindow.prototype.__defineGetter__('Node', function() {
- return devtools.DomNode;
-});
-
-
-/**
- * Represents DOM NodeList class.
- * @constructor
- */
-devtools.DomWindow.prototype.__defineGetter__('NodeList', function() {
- return function() {};
-});
-
-
-/**
- * Represents DOM Element class.
- * @constructor
- */
-devtools.DomWindow.prototype.__defineGetter__('Element', function() {
- return devtools.DomNode;
-});
-
-
-/**
- * See usages in ScopeChainSidebarPane.js where it's called as
- * constructor.
- */
-devtools.DomWindow.prototype.Object = function() {
-};
-
-
-/**
- * Creates DomAgent Js representation.
- * @constructor
- */
-devtools.DomAgent = function() {
- RemoteDomAgent.DidGetChildNodes =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidPerformSearch =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidApplyDomChange =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidRemoveAttribute =
- devtools.Callback.processCallback;
- RemoteDomAgent.DidSetTextNodeValue =
- devtools.Callback.processCallback;
- RemoteDomAgent.AttributesUpdated =
- goog.bind(this.attributesUpdated_, this);
- RemoteDomAgent.SetDocumentElement =
- goog.bind(this.setDocumentElement_, this);
- RemoteDomAgent.SetChildNodes =
- goog.bind(this.setChildNodes_, this);
- RemoteDomAgent.HasChildrenUpdated =
- goog.bind(this.hasChildrenUpdated_, this);
- RemoteDomAgent.ChildNodeInserted =
- goog.bind(this.childNodeInserted_, this);
- RemoteDomAgent.ChildNodeRemoved =
- goog.bind(this.childNodeRemoved_, this);
-
- /**
- * Top-level (and the only) document.
- * @type {devtools.DomWindow}
- * @private
- */
- this.window_ = null;
-
- /**
- * Id to node mapping.
- * @type {Object}
- * @private
- */
- this.idToDomNode_ = null;
-
- /**
- * @type {Array.<number>} Node ids for search results.
- * @private
- */
- this.searchResults_ = null;
-};
-
-
-/**
- * Resets dom agent to its initial state.
- */
-devtools.DomAgent.prototype.reset = function() {
- this.window_ = new devtools.DomWindow(this);
- this.idToDomNode_ = { 0 : this.getDocument() };
- this.searchResults_ = [];
-};
-
-
-/**
- * @return {devtools.DomWindow} Window for the top level (and the only) document.
- */
-devtools.DomAgent.prototype.getWindow = function() {
- return this.window_;
-};
-
-
-/**
- * @return {devtools.DomDocument} A document of the top level window.
- */
-devtools.DomAgent.prototype.getDocument = function() {
- return this.window_.document;
-};
-
-
-/**
- * Requests that the document element is sent from the agent.
- */
-devtools.DomAgent.prototype.getDocumentElementAsync = function() {
- if (this.getDocument().documentElement) {
- return;
- }
- RemoteDomAgent.GetDocumentElement();
-};
-
-
-/**
- * Asynchronously fetches children from the element with given id.
- * @param {devtools.DomNode} parent Element to get children for.
- * @param {function(devtools.DomNode):undefined} opt_callback Callback with
- * the result.
- */
-devtools.DomAgent.prototype.getChildNodesAsync = function(parent,
- opt_callback) {
- var children = parent.children;
- if (children && opt_callback) {
- opt_callback(children);
- return;
- }
- var mycallback = function() {
- if (opt_callback) {
- opt_callback(parent.children);
- }
- };
- var callId = devtools.Callback.wrap(mycallback);
- RemoteDomAgent.GetChildNodes(callId, parent.id_);
-};
-
-
-/**
- * Sends 'set attribute' command to the remote agent.
- * @param {devtools.DomNode} node Node to change.
- * @param {string} name Attribute name to set value for.
- * @param {string} value Attribute value to set.
- * @param {function():undefined} opt_callback Callback on success.
- */
-devtools.DomAgent.prototype.setAttributeAsync = function(node, name, value,
- callback) {
- var mycallback = goog.bind(this.didApplyDomChange_, this, node, callback);
- RemoteDomAgent.SetAttribute(devtools.Callback.wrap(mycallback),
- node.id_, name, value);
-};
-
-
-/**
- * Sends 'remove attribute' command to the remote agent.
- * @param {devtools.DomNode} node Node to change.
- * @param {string} name Attribute name to set value for.
- * @param {function():undefined} opt_callback Callback on success.
- */
-devtools.DomAgent.prototype.removeAttributeAsync = function(node, name,
- callback) {
- var mycallback = goog.bind(this.didApplyDomChange_, this, node, callback);
- RemoteDomAgent.RemoveAttribute(devtools.Callback.wrap(mycallback),
- node.id_, name);
-};
-
-
-/**
- * Sends 'set text node value' command to the remote agent.
- * @param {devtools.DomNode} node Node to change.
- * @param {string} text Text value to set.
- * @param {function():undefined} opt_callback Callback on success.
- */
-devtools.DomAgent.prototype.setTextNodeValueAsync = function(node, text,
- callback) {
- var mycallback = goog.bind(this.didApplyDomChange_, this, node, callback);
- RemoteDomAgent.SetTextNodeValue(devtools.Callback.wrap(mycallback),
- node.id_, text);
-};
-
-
-/**
- * Universal callback wrapper for edit dom operations.
- * @param {devtools.DomNode} node Node to apply local changes on.
- * @param {Function} callback Post-operation call.
- * @param {boolean} success True iff operation has completed successfully.
- * @private
- */
-devtools.DomAgent.prototype.didApplyDomChange_ = function(node,
- callback, success) {
- if (!success) {
- return;
- }
- callback();
- var elem = WebInspector.panels.elements.treeOutline.findTreeElement(node);
- if (elem) {
- elem._updateTitle();
- }
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.attributesUpdated_ = function(nodeId, attrsArray) {
- var node = this.idToDomNode_[nodeId];
- node.setAttributesPayload_(attrsArray);
-};
-
-
-/**
- * Returns node for id.
- * @param {number} nodeId Id to get node for.
- * @return {devtools.DomNode} Node with given id.
- */
-devtools.DomAgent.prototype.getNodeForId = function(nodeId) {
- return this.idToDomNode_[nodeId];
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.setDocumentElement_ = function(payload) {
- var doc = this.getDocument();
- if (doc.documentElement) {
- this.reset();
- doc = this.getDocument();
- }
- this.setChildNodes_(0, [payload]);
- doc.documentElement = doc.firstChild;
- doc.documentElement.ownerDocument = doc;
- WebInspector.panels.elements.reset();
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.setChildNodes_ = function(parentId, payloads) {
- var parent = this.idToDomNode_[parentId];
- if (parent.children) {
- return;
- }
- parent.setChildrenPayload_(payloads);
- this.bindNodes_(parent.children);
-};
-
-
-/**
- * Binds nodes to ids recursively.
- * @param {Array.<devtools.DomNode>} children Nodes to bind.
- * @private
- */
-devtools.DomAgent.prototype.bindNodes_ = function(children) {
- for (var i = 0; i < children.length; ++i) {
- var child = children[i];
- this.idToDomNode_[child.id_] = child;
- if (child.children) {
- this.bindNodes_(child.children);
- }
- }
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.hasChildrenUpdated_ = function(nodeId, newValue) {
- var node = this.idToDomNode_[nodeId];
- var outline = WebInspector.panels.elements.treeOutline;
- var treeElement = outline.findTreeElement(node);
- if (treeElement) {
- treeElement.hasChildren = newValue;
- treeElement.whitespaceIgnored = Preferences.ignoreWhitespace;
- }
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.childNodeInserted_ = function(
- parentId, prevId, payload) {
- var parent = this.idToDomNode_[parentId];
- var prev = this.idToDomNode_[prevId];
- var node = parent.insertChild_(prev, payload);
- this.idToDomNode_[node.id_] = node;
- var event = { target : node, relatedNode : parent };
- this.getDocument().fireDomEvent_('DOMNodeInserted', event);
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- * @private
- */
-devtools.DomAgent.prototype.childNodeRemoved_ = function(
- parentId, nodeId) {
- var parent = this.idToDomNode_[parentId];
- var node = this.idToDomNode_[nodeId];
- parent.removeChild_(node);
- var event = { target : node, relatedNode : parent };
- this.getDocument().fireDomEvent_('DOMNodeRemoved', event);
- delete this.idToDomNode_[nodeId];
-};
-
-
-/**
- * @see DomAgentDelegate.
- * {@inheritDoc}.
- */
-devtools.DomAgent.prototype.performSearch = function(query, callback) {
- this.searchResults_ = [];
- RemoteDomAgent.PerformSearch(
- devtools.Callback.wrap(
- goog.bind(this.performSearchCallback_, this, callback,
- this.searchResults_)),
- query);
-};
-
-
-/**
- * Invokes callback for nodes that needs to clear highlighting.
- * @param {function(Array.<devtools.DomNode>)} callback to accept the result.
- */
-devtools.DomAgent.prototype.searchCanceled = function(callback) {
- if (!this.searchResults_)
- return;
-
- var nodes = [];
- for (var i = 0; i < this.searchResults_.length; ++i) {
- var nodeId = this.searchResults_[i];
- var node = this.idToDomNode_[nodeId];
- nodes.push(node);
- }
-
- callback(nodes);
- this.searchResults_ = null;
-};
-
-
-/**
- * Invokes callback for each node that needs to gain highlighting.
- * @param {function(Array.<devtools.DomNode>)} callback to accept the result.
- * @param {Array.<number>} searchResults to be populated.
- * @param {Array.<number>} nodeIds Ids to highlight.
- * @private
- */
-devtools.DomAgent.prototype.performSearchCallback_ = function(callback,
- searchResults, nodeIds) {
-
- if (this.searchResults_ !== searchResults)
- return; // another search has requested and this results are obsolete
-
- var nodes = [];
-
- for (var i = 0; i < nodeIds.length; ++i) {
- var node = this.idToDomNode_[nodeIds[i]];
- searchResults.push(nodeIds[i]);
- nodes.push(node);
- }
-
- callback(nodes);
-};
-
-
-/**
- * Returns a node by index from the actual search results
- * (last performSearch).
- * @param {number} index in the results.
- * @return {devtools.DomNode}
- */
-devtools.DomAgent.prototype.getSearchResultNode = function(index) {
- return this.idToDomNode_[this.searchResults_[index]];
-};
-
-
-function firstChildSkippingWhitespace() {
- return this.firstChild;
-}
-
-
-function onlyTextChild() {
- if (!this.children) {
- return null;
- } else if (this.children.length == 1 &&
- this.children[0].nodeType == Node.TEXT_NODE) {
- return this.children[0];
- } else {
- return null;
- }
-}
diff --git a/webkit/glue/devtools/js/inject.js b/webkit/glue/devtools/js/inject.js
index 0d4e0e3..e214766 100644
--- a/webkit/glue/devtools/js/inject.js
+++ b/webkit/glue/devtools/js/inject.js
@@ -14,55 +14,6 @@ goog.provide('devtools.Injected');
* @constructor.
*/
devtools.Injected = function() {
- /**
- * This cache contains mapping from object it to an object instance for
- * all results of the evaluation / console logs.
- */
- this.cachedConsoleObjects_ = {};
-
- /**
- * Last id for the cache above.
- */
- this.lastCachedConsoleObjectId_ = 1;
-};
-
-
-/**
- * Caches console object for subsequent calls to getConsoleObjectProperties.
- * @param {Object} obj Object to cache.
- * @return {Object} console object wrapper.
- */
-devtools.Injected.prototype.wrapConsoleObject = function(obj) {
- var type = typeof obj;
- if ((type == 'object' && obj != null) || type == 'function') {
- var objId = '#consoleobj#' + this.lastCachedConsoleObjectId_++;
- this.cachedConsoleObjects_[objId] = obj;
- var result = { ___devtools_id : objId };
- result.___devtools_class_name = Object.describe(obj, true);
- // Loop below fills dummy object with properties for completion.
- for (var name in obj) {
- result[name] = '';
- }
- return result;
- }
- return obj;
-};
-
-
-/**
- * Caches console object for subsequent calls to getConsoleObjectProperties.
- * @param {Object} obj Object to cache.
- * @return {string} Console object wrapper serialized into a JSON string.
- */
-devtools.Injected.prototype.serializeConsoleObject = function(obj) {
- var result = this.wrapConsoleObject(obj);
- return JSON.stringify(result,
- function (key, value) {
- if (value === undefined) {
- return 'undefined';
- }
- return value;
- });
};
@@ -93,19 +44,6 @@ InjectedScript._window = function() {
};
-InjectedScript._nodeForId = function(nodeId) {
- return DevToolsAgentHost.getNodeForId(nodeId);
-};
-
-
-InjectedScript._objectForId = function(id) {
- if (typeof id == 'number') {
- return DevToolsAgentHost.getNodeForId(id);
- }
- return devtools$$obj.cachedConsoleObjects_[id];
-};
-
-
Object.type = function(obj, win)
{
if (obj === null)
diff --git a/webkit/glue/devtools/js/inject_dispatch.js b/webkit/glue/devtools/js/inject_dispatch.js
index 0416676..9cc68f7 100644
--- a/webkit/glue/devtools/js/inject_dispatch.js
+++ b/webkit/glue/devtools/js/inject_dispatch.js
@@ -40,14 +40,7 @@ var dispatch = function(method, var_args) {
// Handle all messages with non-primitieve arguments here.
var args = Array.prototype.slice.call(arguments);
- // Serialize objects here.
- if (method == 'addMessageToConsole') {
- // Skip first argument since it is serializable.
- // Method has index 0, first argument has index 1. Skip both.
- for (var i = 2; i < args.length; ++i) {
- args[i] = devtools$$obj.wrapConsoleObject(args[i]);
- }
- } else if (method == 'inspectedWindowCleared' ||
+ if (method == 'inspectedWindowCleared' ||
method == 'reset' ||
method == 'setAttachedWindow') {
// Filter out messages we don't need here.
diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js
index 459d9c4..b0c6947 100644
--- a/webkit/glue/devtools/js/inspector_controller_impl.js
+++ b/webkit/glue/devtools/js/inspector_controller_impl.js
@@ -13,18 +13,32 @@ devtools.InspectorControllerImpl = function() {
devtools.InspectorController.call(this);
this.frame_element_id_ = 1;
- this.installInjectedScriptDelegate_('getStyles', true);
- this.installInjectedScriptDelegate_('getComputedStyle', true);
- this.installInjectedScriptDelegate_('getInlineStyle', true);
+ this.installInspectorControllerDelegate_('clearMessages');
+ this.installInspectorControllerDelegate_('storeLastActivePanel');
+ this.installInspectorControllerDelegate_('highlightDOMNode');
+ this.installInspectorControllerDelegate_('hideDOMNodeHighlight');
+ this.installInspectorControllerDelegate_('getChildNodes');
+ this.installInspectorControllerDelegate_('setAttribute');
+ this.installInspectorControllerDelegate_('removeAttribute');
+ this.installInspectorControllerDelegate_('setTextNodeValue');
+
+ this.installInjectedScriptDelegate_('getStyles');
+ this.installInjectedScriptDelegate_('getComputedStyle');
+ this.installInjectedScriptDelegate_('getInlineStyle');
this.installInjectedScriptDelegate_('applyStyleText');
this.installInjectedScriptDelegate_('setStyleText');
this.installInjectedScriptDelegate_('toggleStyleEnabled');
this.installInjectedScriptDelegate_('applyStyleRuleText');
this.installInjectedScriptDelegate_('addStyleSelector');
this.installInjectedScriptDelegate_('setStyleProperty');
- this.installInjectedScriptDelegate_('getPrototypes', true);
- this.installInjectedScriptDelegate_('getProperties', true);
- this.installInjectedScriptDelegate_('setPropertyValue', true);
+ this.installInjectedScriptDelegate_('getPrototypes');
+ this.installInjectedScriptDelegate_('getProperties');
+ this.installInjectedScriptDelegate_('setPropertyValue');
+
+ this.installInjectedScriptDelegate_('evaluate');
+ this.installInjectedScriptDelegate_('addInspectedNode');
+ this.installInjectedScriptDelegate_('performSearch');
+ this.installInjectedScriptDelegate_('searchCanceled');
};
goog.inherits(devtools.InspectorControllerImpl,
devtools.InspectorController);
@@ -65,24 +79,6 @@ devtools.InspectorControllerImpl.prototype.detach = function() {
/**
* {@inheritDoc}.
*/
-devtools.InspectorControllerImpl.prototype.storeLastActivePanel = function(panel) {
- RemoteToolsAgent.ExecuteUtilityFunction(
- devtools.Callback.wrap(undefined),
- 'InspectorController', JSON.stringify(['storeLastActivePanel', panel]));
-};
-
-
-/**
- * {@inheritDoc}.
- */
-devtools.InspectorControllerImpl.prototype.clearMessages = function() {
- RemoteToolsAgent.ClearConsoleMessages();
-};
-
-
-/**
- * {@inheritDoc}.
- */
devtools.InspectorControllerImpl.prototype.hiddenPanels = function() {
return 'databases';
};
@@ -130,25 +126,8 @@ devtools.InspectorControllerImpl.prototype.addResourceSourceToFrame =
/**
* {@inheritDoc}.
*/
-devtools.InspectorControllerImpl.prototype.hideDOMNodeHighlight = function() {
- RemoteToolsAgent.HideDOMNodeHighlight();
-};
-
-
-/**
- * {@inheritDoc}.
- */
-devtools.InspectorControllerImpl.prototype.highlightDOMNode =
- function(hoveredNode) {
- RemoteToolsAgent.HighlightDOMNode(hoveredNode.id_);
-};
-
-
-/**
- * {@inheritDoc}.
- */
devtools.InspectorControllerImpl.prototype.inspectedWindow = function() {
- return devtools.tools.getDomAgent().getWindow();
+ return null;
};
@@ -268,14 +247,11 @@ devtools.InspectorControllerImpl.prototype.storeLastActivePanel =
/**
* Installs delegating handler into the inspector controller.
- * @param {number} argsCound Number of the arguments in the delegating call
- * excluding callback.
* @param {string} methodName Method to install delegating handler for.
- * @parma {boolean} unwrap Replace first argument with its id.
*/
devtools.InspectorControllerImpl.prototype.installInjectedScriptDelegate_ =
- function(methodName, unwrap) {
- this[methodName] = goog.bind(this.callInjectedScript_, this, unwrap,
+ function(methodName) {
+ this[methodName] = goog.bind(this.callInjectedScript_, this,
methodName);
};
@@ -285,23 +261,40 @@ devtools.InspectorControllerImpl.prototype.installInjectedScriptDelegate_ =
* implementation.
*/
devtools.InspectorControllerImpl.prototype.callInjectedScript_ =
- function(unwrap, methodName, var_arg) {
+ function(methodName, var_arg) {
var allArgs = Array.prototype.slice.call(arguments);
var callback = allArgs[allArgs.length - 1];
- var args = Array.prototype.slice.call(allArgs, 1, allArgs.length - 1);
- if (unwrap) {
- if (args[1].id_) {
- args[1] = args[1].id_;
- } else if (args[1].objectId && args[1].objectId.id_) {
- args[1].objectId = args[1].objectId.id_;
- }
- }
+ var args = Array.prototype.slice.call(allArgs, 0, allArgs.length - 1);
RemoteToolsAgent.ExecuteUtilityFunction(
devtools.InspectorControllerImpl.parseWrap_(callback),
'InjectedScript', JSON.stringify(args));
};
+/**
+ * Installs delegating handler into the inspector controller.
+ * @param {string} methodName Method to install delegating handler for.
+ */
+devtools.InspectorControllerImpl.prototype.installInspectorControllerDelegate_
+ = function(methodName) {
+ this[methodName] = goog.bind(this.callInspectorController_, this,
+ methodName);
+};
+
+
+/**
+ * Bound function with the installInjectedScriptDelegate_ actual
+ * implementation.
+ */
+devtools.InspectorControllerImpl.prototype.callInspectorController_ =
+ function(methodName, var_arg) {
+ var args = Array.prototype.slice.call(arguments);
+ RemoteToolsAgent.ExecuteUtilityFunction(
+ devtools.InspectorControllerImpl.parseWrap_(undefined),
+ 'InspectorController', JSON.stringify(args));
+};
+
+
devtools.InspectorControllerImpl.parseWrap_ = function(callback) {
return devtools.Callback.wrap(
function(data) {
diff --git a/webkit/glue/devtools/tools_agent.h b/webkit/glue/devtools/tools_agent.h
index be72dc8..bddc159 100644
--- a/webkit/glue/devtools/tools_agent.h
+++ b/webkit/glue/devtools/tools_agent.h
@@ -10,22 +10,10 @@
// Tools agent provides API for enabling / disabling other agents as well as
// API for auxiliary UI functions such as dom elements highlighting.
#define TOOLS_AGENT_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, METHOD4) \
- /* Highlights Dom node with given ID */ \
- METHOD1(HighlightDOMNode, int /* node_id */) \
- \
- /* Clears Dom Node highlight. */ \
- METHOD0(HideDOMNodeHighlight) \
- \
/* Requests that utility js function is executed with the given args. */ \
METHOD3(ExecuteUtilityFunction, int /* call_id */, \
String /* function_name */, String /* json_args */) \
\
- /* Requests that the js source is executed within the inspected page. */ \
- METHOD2(EvaluateJavaScript, int /* call_id */, String /* source*/) \
- \
- /* Clears cached console messages. */ \
- METHOD0(ClearConsoleMessages) \
- \
/* Requests that the agent sends content of the resource with given id to the
delegate. */ \
METHOD2(GetResourceContent, int /* call_id */, int /* identifier */) \
@@ -38,19 +26,12 @@ DEFINE_RPC_CLASS(ToolsAgent, TOOLS_AGENT_STRUCT)
#define TOOLS_AGENT_DELEGATE_STRUCT(METHOD0, METHOD1, METHOD2, METHOD3, \
METHOD4) \
/* Updates focused node on the client. */ \
- METHOD1(UpdateFocusedNode, int /* node_id */) \
- \
- /* Updates focused node on the client. */ \
METHOD1(FrameNavigate, std::string /* url */) \
\
/* Response to the GetNodeProperties. */ \
METHOD3(DidExecuteUtilityFunction, int /* call_id */, String /* result */, \
String /* exception */) \
\
- /* Response to the EvaluateJavaScript. */ \
- METHOD3(DidEvaluateJavaScript, int /* call_id */, String /* result */, \
- String /* exception */) \
- \
/* Sends InspectorFrontend message to be dispatched on client. */ \
METHOD1(DispatchOnClient, String /* data */) \
\
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc
index ac0f1da..4cbcbf5 100644
--- a/webkit/glue/webdevtoolsagent_impl.cc
+++ b/webkit/glue/webdevtoolsagent_impl.cc
@@ -29,7 +29,6 @@
#include "webkit/glue/devtools/bound_object.h"
#include "webkit/glue/devtools/debugger_agent_impl.h"
#include "webkit/glue/devtools/debugger_agent_manager.h"
-#include "webkit/glue/devtools/dom_agent_impl.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webdevtoolsagent_delegate.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
@@ -61,7 +60,6 @@ WebDevToolsAgentImpl::WebDevToolsAgentImpl(
document_(NULL),
attached_(false) {
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));
}
@@ -87,7 +85,6 @@ void WebDevToolsAgentImpl::Attach() {
debugger_agent_delegate_stub_.get(),
this));
Page* page = web_view_impl_->page();
- dom_agent_impl_.set(new DomAgentImpl(dom_agent_delegate_stub_.get()));
// We are potentially attaching to the running page -> init agents with
// Document if any.
@@ -99,17 +96,20 @@ void WebDevToolsAgentImpl::Attach() {
InitDevToolsAgentHost();
}
- dom_agent_impl_->SetDocument(doc);
-
InspectorController* ic = web_view_impl_->page()->inspectorController();
// Unhide resources panel if necessary.
tools_agent_delegate_stub_->SetResourcesPanelEnabled(
ic->resourceTrackingEnabled());
v8::HandleScope scope;
+ v8::Context::Scope context_scope(utility_context_);
+
ScriptState* state = scriptStateFromPage(web_view_impl_->page());
+ v8::Handle<v8::Object> injected_script = v8::Local<v8::Object>::Cast(
+ utility_context_->Global()->Get(v8::String::New("InjectedScript")));
ic->setFrontendProxyObject(
state,
- ScriptObject(state, utility_context_->Global()));
+ ScriptObject(state, utility_context_->Global()),
+ ScriptObject(state, injected_script));
// Allow controller to send messages to the frontend.
ic->setWindowVisible(true, false);
}
@@ -120,10 +120,8 @@ void WebDevToolsAgentImpl::Detach() {
// Prevent controller from sending messages to the frontend.
InspectorController* ic = web_view_impl_->page()->inspectorController();
ic->setWindowVisible(false, false);
- HideDOMNodeHighlight();
devtools_agent_host_.set(NULL);
debugger_agent_impl_.set(NULL);
- dom_agent_impl_.set(NULL);
attached_ = false;
}
@@ -148,7 +146,6 @@ void WebDevToolsAgentImpl::SetMainFrameDocumentReady(bool ready) {
debugger_agent_impl_->ResetUtilityContext(doc, &utility_context_);
InitDevToolsAgentHost();
}
- dom_agent_impl_->SetDocument(doc);
}
void WebDevToolsAgentImpl::DidCommitLoadForFrame(
@@ -186,25 +183,6 @@ void WebDevToolsAgentImpl::ForceRepaint() {
delegate_->ForceRepaint();
}
-void WebDevToolsAgentImpl::HighlightDOMNode(int node_id) {
- if (!attached_) {
- return;
- }
- Node* node = dom_agent_impl_->GetNodeForId(node_id);
- if (!node) {
- return;
- }
- Page* page = web_view_impl_->page();
- page->inspectorController()->highlight(node);
-}
-
-void WebDevToolsAgentImpl::HideDOMNodeHighlight() {
- Page* page = web_view_impl_->page();
- if (page) {
- page->inspectorController()->hideHighlight();
- }
-}
-
void WebDevToolsAgentImpl::ExecuteUtilityFunction(
int call_id,
const String& function_name,
@@ -217,23 +195,6 @@ void WebDevToolsAgentImpl::ExecuteUtilityFunction(
result, exception);
}
-void WebDevToolsAgentImpl::EvaluateJavaScript(
- int call_id,
- const WebCore::String& source) {
- String exception;
- String result = debugger_agent_impl_->EvaluateJavaScript(utility_context_,
- source, &exception);
- tools_agent_delegate_stub_->DidEvaluateJavaScript(call_id, result, exception);
-}
-
-void WebDevToolsAgentImpl::ClearConsoleMessages() {
-// TODO(pfeldman): restore once migrated to DOMAgent.
-// Page* page = web_view_impl_->page();
-// if (page) {
-// page->inspectorController()->clearConsoleMessages();
-// }
-}
-
void WebDevToolsAgentImpl::GetResourceContent(
int call_id,
int identifier) {
@@ -284,21 +245,10 @@ void WebDevToolsAgentImpl::DispatchMessageFromClient(
*message.get())) {
return;
}
-
- if (DomAgentDispatch::Dispatch(
- dom_agent_impl_.get(), class_name, method_name, *message.get())) {
- return;
- }
}
void WebDevToolsAgentImpl::InspectElement(int x, int y) {
- Node* node = web_view_impl_->GetNodeForWindowPos(x, y);
- if (!node) {
- return;
- }
-
- int node_id = dom_agent_impl_->PushNodePathToClient(node);
- tools_agent_delegate_stub_->UpdateFocusedNode(node_id);
+ // TODO(pfeldman): implement using new inspector controller API.
}
void WebDevToolsAgentImpl::SendRpcMessage(
@@ -314,9 +264,6 @@ void WebDevToolsAgentImpl::InitDevToolsAgentHost() {
devtools_agent_host_->AddProtoFunction(
"dispatch",
WebDevToolsAgentImpl::JsDispatchOnClient);
- devtools_agent_host_->AddProtoFunction(
- "getNodeForId",
- WebDevToolsAgentImpl::JsGetNodeForId);
devtools_agent_host_->Build();
v8::HandleScope scope;
@@ -343,16 +290,6 @@ v8::Handle<v8::Value> WebDevToolsAgentImpl::JsDispatchOnClient(
}
// static
-v8::Handle<v8::Value> WebDevToolsAgentImpl::JsGetNodeForId(
- const v8::Arguments& args) {
- int node_id = static_cast<int>(args[0]->NumberValue());
- WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(
- v8::External::Cast(*args.Data())->Value());
- Node* node = agent->dom_agent_impl_->GetNodeForId(node_id);
- return V8DOMWrapper::convertToV8Object(V8ClassIndex::NODE, node);
-}
-
-// static
void WebDevToolsAgent::ExecuteDebuggerCommand(
const std::string& command,
int caller_id) {
diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h
index a756ce0..81b22f4 100644
--- a/webkit/glue/webdevtoolsagent_impl.h
+++ b/webkit/glue/webdevtoolsagent_impl.h
@@ -11,7 +11,6 @@
#include "v8.h"
#include "webkit/glue/devtools/devtools_rpc.h"
-#include "webkit/glue/devtools/dom_agent.h"
#include "webkit/glue/devtools/tools_agent.h"
#include "webkit/glue/webdevtoolsagent.h"
@@ -28,8 +27,6 @@ class WebFrame;
class BoundObject;
class DebuggerAgentDelegateStub;
class DebuggerAgentImpl;
-class DomAgentImpl;
-class NetAgentImpl;
class Value;
class WebDevToolsAgentDelegate;
class WebFrameImpl;
@@ -45,16 +42,10 @@ class WebDevToolsAgentImpl
virtual ~WebDevToolsAgentImpl();
// ToolsAgent implementation.
- virtual void HighlightDOMNode(int node_id);
- virtual void HideDOMNodeHighlight();
virtual void ExecuteUtilityFunction(
int call_id,
const WebCore::String& function_name,
const WebCore::String& json_args);
- virtual void EvaluateJavaScript(
- int call_id,
- const WebCore::String& source);
- virtual void ClearConsoleMessages();
virtual void GetResourceContent(
int call_id,
int identifier);
@@ -88,7 +79,6 @@ class WebDevToolsAgentImpl
private:
static v8::Handle<v8::Value> JsDispatchOnClient(const v8::Arguments& args);
- static v8::Handle<v8::Value> JsGetNodeForId(const v8::Arguments& args);
void DisposeUtilityContext();
void InitDevToolsAgentHost();
@@ -98,11 +88,9 @@ class WebDevToolsAgentImpl
WebViewImpl* web_view_impl_;
WebCore::Document* document_;
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_;
// TODO(pfeldman): This should not be needed once GC styles issue is fixed
// for matching rules.
diff --git a/webkit/glue/webdevtoolsclient_impl.cc b/webkit/glue/webdevtoolsclient_impl.cc
index 0a85288..1194045 100644
--- a/webkit/glue/webdevtoolsclient_impl.cc
+++ b/webkit/glue/webdevtoolsclient_impl.cc
@@ -30,7 +30,6 @@
#include "webkit/glue/devtools/bound_object.h"
#include "webkit/glue/devtools/debugger_agent.h"
#include "webkit/glue/devtools/devtools_rpc_js.h"
-#include "webkit/glue/devtools/dom_agent.h"
#include "webkit/glue/devtools/tools_agent.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/webdevtoolsclient_delegate.h"
@@ -44,8 +43,6 @@ using WebKit::WebString;
DEFINE_RPC_JS_BOUND_OBJ(DebuggerAgent, DEBUGGER_AGENT_STRUCT,
DebuggerAgentDelegate, DEBUGGER_AGENT_DELEGATE_STRUCT)
-DEFINE_RPC_JS_BOUND_OBJ(DomAgent, DOM_AGENT_STRUCT,
- DomAgentDelegate, DOM_AGENT_DELEGATE_STRUCT)
DEFINE_RPC_JS_BOUND_OBJ(ToolsAgent, TOOLS_AGENT_STRUCT,
ToolsAgentDelegate, TOOLS_AGENT_DELEGATE_STRUCT)
@@ -148,7 +145,6 @@ WebDevToolsClientImpl::WebDevToolsClientImpl(
delegate, frame, L"RemoteDebuggerCommandExecutor"));
debugger_agent_obj_.set(new JsDebuggerAgentBoundObj(
this, frame, L"RemoteDebuggerAgent"));
- dom_agent_obj_.set(new JsDomAgentBoundObj(this, frame, L"RemoteDomAgent"));
tools_agent_obj_.set(
new JsToolsAgentBoundObj(this, frame, L"RemoteToolsAgent"));
diff --git a/webkit/glue/webdevtoolsclient_impl.h b/webkit/glue/webdevtoolsclient_impl.h
index ce07dd4..3e5b250 100644
--- a/webkit/glue/webdevtoolsclient_impl.h
+++ b/webkit/glue/webdevtoolsclient_impl.h
@@ -24,7 +24,6 @@ class String;
class BoundObject;
class JsDebuggerAgentBoundObj;
-class JsDomAgentBoundObj;
class JsNetAgentBoundObj;
class JsToolsAgentBoundObj;
class ToolsAgentNativeDelegateImpl;
@@ -74,7 +73,6 @@ class WebDevToolsClientImpl : public WebDevToolsClient,
WebDevToolsClientDelegate* delegate_;
OwnPtr<CppBoundClass> debugger_command_executor_obj_;
OwnPtr<JsDebuggerAgentBoundObj> debugger_agent_obj_;
- OwnPtr<JsDomAgentBoundObj> dom_agent_obj_;
OwnPtr<JsToolsAgentBoundObj> tools_agent_obj_;
bool loaded_;
Vector<std::string> pending_incoming_messages_;
diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp
index 8bd938f..eadd0b0 100644
--- a/webkit/tools/test_shell/test_shell.gyp
+++ b/webkit/tools/test_shell/test_shell.gyp
@@ -475,7 +475,6 @@
'../../glue/context_menu_unittest.cc',
'../../glue/cpp_bound_class_unittest.cc',
'../../glue/cpp_variant_unittest.cc',
- '../../glue/devtools/dom_agent_unittest.cc',
'../../glue/devtools/devtools_rpc_unittest.cc',
'../../glue/dom_operations_unittest.cc',
'../../glue/dom_serializer_unittest.cc',
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 9e48f63..9af9e28 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -1275,9 +1275,6 @@
'glue/devtools/debugger_agent_impl.h',
'glue/devtools/debugger_agent_manager.cc',
'glue/devtools/debugger_agent_manager.h',
- 'glue/devtools/dom_agent.h',
- 'glue/devtools/dom_agent_impl.cc',
- 'glue/devtools/dom_agent_impl.h',
'glue/devtools/tools_agent.h',
'glue/media/buffered_data_source.cc',
'glue/media/buffered_data_source.h',
@@ -1531,7 +1528,6 @@
'glue/devtools/js/devtools.js',
'glue/devtools/js/devtools_callback.js',
'glue/devtools/js/devtools_host_stub.js',
- 'glue/devtools/js/dom_agent.js',
'glue/devtools/js/heap_profiler_panel.js',
'glue/devtools/js/inject.js',
'glue/devtools/js/inspector_controller.js',