diff options
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/devtools/debugger_agent_impl.cc | 72 | ||||
-rw-r--r-- | webkit/glue/devtools/debugger_agent_impl.h | 9 | ||||
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.cc | 33 | ||||
-rw-r--r-- | webkit/glue/devtools/debugger_agent_manager.h | 11 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent.h | 9 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_delegate.h | 3 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.cc | 9 | ||||
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 10 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 3 |
10 files changed, 133 insertions, 28 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc index 88fc171..03f8ba7 100644 --- a/webkit/glue/devtools/debugger_agent_impl.cc +++ b/webkit/glue/devtools/debugger_agent_impl.cc @@ -4,8 +4,15 @@ #include "config.h" +#include <wtf/HashSet.h> +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> + #include "Document.h" +#include "Frame.h" #include "Node.h" +#include "Page.h" +#include "PageGroup.h" #undef LOG #include "grit/webkit_resources.h" @@ -16,12 +23,16 @@ #include "webkit/glue/devtools/debugger_agent_impl.h" #include "webkit/glue/devtools/debugger_agent_manager.h" #include "webkit/glue/glue_util.h" +#include "webkit/glue/webdevtoolsagent_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview_impl.h" using WebCore::DOMWindow; using WebCore::Document; +using WebCore::Frame; using WebCore::Node; +using WebCore::Page; +using WebCore::PageGroup; using WebCore::String; using WebCore::V8ClassIndex; using WebCore::V8Custom; @@ -40,6 +51,7 @@ DebuggerAgentImpl::DebuggerAgentImpl( DebuggerAgentImpl::~DebuggerAgentImpl() { DebuggerAgentManager::DebugDetach(this); + web_view_impl_->SetIgnoreInputEvents(false); } void DebuggerAgentImpl::DebugBreak() { @@ -48,6 +60,8 @@ void DebuggerAgentImpl::DebugBreak() { void DebuggerAgentImpl::DebuggerOutput(const std::string& command) { delegate_->DebuggerOutput(command); + // TODO(pfeldman): Uncomment this once v8 changes are landed. + // webdevtools_agent_->ForceRepaint(); } void DebuggerAgentImpl::SetDocument(Document* document) { @@ -129,6 +143,64 @@ String DebuggerAgentImpl::ExecuteUtilityFunction( return WebCore::toWebCoreString(res_json); } +void DebuggerAgentImpl::RunWithDeferredMessages( + const HashSet<DebuggerAgentImpl*>& agents, + WebDevToolsAgent::MessageLoopDispatchHandler handler) { + + // TODO(pfeldman): Make PageGroupLoadDeferrer visible and use it from here. + // Code below is derived from the Chrome.cpp's PageGroupLoadDeferrer: + // 1. Disable active objects and input events. + Vector<RefPtr<Frame>, 16> deferred_frames; + for (HashSet<DebuggerAgentImpl*>::const_iterator ag_it = agents.begin(); + ag_it != agents.end(); ++ag_it) { + DebuggerAgentImpl* agent = *ag_it; + agent->web_view()->SetIgnoreInputEvents(true); + const HashSet<Page*>& pages = agent->GetPage()->group().pages(); + HashSet<Page*>::const_iterator end = pages.end(); + for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { + Page* other_page = *it; + if (!other_page->defersLoading()) { + deferred_frames.append(other_page->mainFrame()); +#if !PLATFORM(MAC) + for (Frame* frame = other_page->mainFrame(); frame; + frame = frame->tree()->traverseNext()) { + frame->document()->suspendActiveDOMObjects(); + } +#endif + } + } + } + + // 2. Disable loading. + size_t count = deferred_frames.size(); + for (size_t i = 0; i < count; ++i) { + if (Page* page = deferred_frames[i]->page()) { + page->setDefersLoading(true); + } + } + // 3. Process messages. + handler(); + + // 4. Bring things back. + for (size_t i = 0; i < deferred_frames.size(); ++i) { + if (Page* page = deferred_frames[i]->page()) { + page->setDefersLoading(false); + +#if !PLATFORM(MAC) + for (Frame* frame = page->mainFrame(); frame; frame = + frame->tree()->traverseNext()) { + frame->document()->resumeActiveDOMObjects(); + } +#endif + } + } + + for (HashSet<DebuggerAgentImpl*>::const_iterator ag_it = agents.begin(); + ag_it != agents.end(); ++ag_it) { + (*ag_it)->web_view()->SetIgnoreInputEvents(false); + } +} + 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 acce569..c1d3cb1 100644 --- a/webkit/glue/devtools/debugger_agent_impl.h +++ b/webkit/glue/devtools/debugger_agent_impl.h @@ -5,8 +5,11 @@ #ifndef WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_IMPL_H_ #define WEBKIT_GLUE_DEVTOOLS_DEBUGGER_AGENT_IMPL_H_ +#include <wtf/HashSet.h> + #include "v8.h" #include "webkit/glue/devtools/debugger_agent.h" +#include "webkit/glue/webdevtoolsagent.h" class WebDevToolsAgentImpl; class WebViewImpl; @@ -41,9 +44,15 @@ class DebuggerAgentImpl : public DebuggerAgent { WebCore::Node* node, const WebCore::String& json_args); + static void RunWithDeferredMessages( + const HashSet<DebuggerAgentImpl*>& agents, + WebDevToolsAgent::MessageLoopDispatchHandler handler); + WebCore::Page* GetPage(); WebDevToolsAgentImpl* webdevtools_agent() { return webdevtools_agent_; }; + WebViewImpl* web_view() { return web_view_impl_; } + private: v8::Persistent<v8::Context> context_; WebViewImpl* web_view_impl_; diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc index ef37b7d..907dd76 100644 --- a/webkit/glue/devtools/debugger_agent_manager.cc +++ b/webkit/glue/devtools/debugger_agent_manager.cc @@ -21,6 +21,8 @@ #include "v8/include/v8-debug.h" #endif +WebDevToolsAgent::MessageLoopDispatchHandler + DebuggerAgentManager::message_loop_dispatch_handler_ = NULL; // static void DebuggerAgentManager::V8DebugMessageHandler(const uint16_t* message, @@ -33,13 +35,13 @@ void DebuggerAgentManager::V8DebugMessageHandler(const uint16_t* message, #endif } -void DebuggerAgentManager::V8DebugHostDispatchHandler( - void* dispatch, - void* data) { - WebDevToolsAgent::Message* m = - reinterpret_cast<WebDevToolsAgent::Message*>(dispatch); - m->Dispatch(); - delete m; +void DebuggerAgentManager::V8DebugHostDispatchHandler() { + if (DebuggerAgentManager::message_loop_dispatch_handler_ + && attached_agents_) { + DebuggerAgentImpl::RunWithDeferredMessages( + *attached_agents_, + message_loop_dispatch_handler_); + } } // static @@ -53,11 +55,10 @@ void DebuggerAgentManager::DebugAttach(DebuggerAgentImpl* debugger_agent) { attached_agents_ = new AttachedAgentsSet(); v8::Debug::SetMessageHandler( &DebuggerAgentManager::V8DebugMessageHandler, - NULL, /* no additional data */ false /* don't create separate thread for sending debugger output */); - v8::Debug::SetHostDispatchHandler( - &DebuggerAgentManager::V8DebugHostDispatchHandler, - NULL /* no additional data */); + // TODO(pfeldman): Uncomment once V8 changes are landed. +// v8::Debug::SetHostDispatchHandler( +// &DebuggerAgentManager::V8DebugHostDispatchHandler, 100 /* ms */); } attached_agents_->add(debugger_agent); #endif @@ -165,7 +166,6 @@ bool DebuggerAgentManager::SendCommandResponse(DictionaryValue* response) { return true; } - // static void DebuggerAgentManager::ExecuteDebuggerCommand( const std::string& command, @@ -178,11 +178,9 @@ void DebuggerAgentManager::ExecuteDebuggerCommand( } // static -void DebuggerAgentManager::ScheduleMessageDispatch( - WebDevToolsAgent::Message* message) { -#if USE(V8) - v8::Debug::SendHostDispatch(message); -#endif +void DebuggerAgentManager::SetMessageLoopDispatchHandler( + WebDevToolsAgent::MessageLoopDispatchHandler handler) { + message_loop_dispatch_handler_ = handler; } // static @@ -193,7 +191,6 @@ void DebuggerAgentManager::SendCommandToV8(const std::wstring& cmd) { #endif } - // static DebuggerAgentImpl* DebuggerAgentManager::FindAgentForCurrentV8Context() { if (!attached_agents_) { diff --git a/webkit/glue/devtools/debugger_agent_manager.h b/webkit/glue/devtools/debugger_agent_manager.h index 42f03cc..390ecc2 100644 --- a/webkit/glue/devtools/debugger_agent_manager.h +++ b/webkit/glue/devtools/debugger_agent_manager.h @@ -39,10 +39,8 @@ class DebuggerAgentManager { static void ExecuteDebuggerCommand(const std::string& command, int caller_id); - - // Requests that debugger makes a callback on the render thread while on - // breakpoint. - static void ScheduleMessageDispatch(WebDevToolsAgent::Message* message); + static void SetMessageLoopDispatchHandler( + WebDevToolsAgent::MessageLoopDispatchHandler handler); private: DebuggerAgentManager(); @@ -51,7 +49,7 @@ class DebuggerAgentManager { static void V8DebugMessageHandler(const uint16_t* message, int length, void* data); - static void V8DebugHostDispatchHandler(void* dispatch, void* data); + static void V8DebugHostDispatchHandler(); static void DebuggerOutput(const std::string& out); static void SendCommandToV8(const std::wstring& cmd); static bool SendCommandResponse(DictionaryValue* response); @@ -67,6 +65,9 @@ class DebuggerAgentManager { typedef HashSet<DebuggerAgentImpl*> AttachedAgentsSet; static AttachedAgentsSet* attached_agents_; + static WebDevToolsAgent::MessageLoopDispatchHandler + message_loop_dispatch_handler_; + DISALLOW_COPY_AND_ASSIGN(DebuggerAgentManager); }; diff --git a/webkit/glue/webdevtoolsagent.h b/webkit/glue/webdevtoolsagent.h index 049964b..9680e84 100644 --- a/webkit/glue/webdevtoolsagent.h +++ b/webkit/glue/webdevtoolsagent.h @@ -37,9 +37,12 @@ class WebDevToolsAgent { static void ExecuteDebuggerCommand(const std::string& command, int caller_id); - // Requests that debugger makes a callback on the render thread while on - // breakpoint. Takes ownership of message. - static void ScheduleMessageDispatch(Message* message); + typedef void (*MessageLoopDispatchHandler)(); + + // Installs dispatch handle that is going to be called periodically + // while on a breakpoint. + static void SetMessageLoopDispatchHandler( + MessageLoopDispatchHandler handler); private: DISALLOW_COPY_AND_ASSIGN(WebDevToolsAgent); diff --git a/webkit/glue/webdevtoolsagent_delegate.h b/webkit/glue/webdevtoolsagent_delegate.h index 4112e4f..5c596ff 100644 --- a/webkit/glue/webdevtoolsagent_delegate.h +++ b/webkit/glue/webdevtoolsagent_delegate.h @@ -15,6 +15,9 @@ class WebDevToolsAgentDelegate { virtual void SendMessageToClient(const std::string& raw_msg) = 0; + // Invalidates widget which leads to the repaint. + virtual void ForceRepaint() = 0; + // Returns the id of the entity hosting this agent. virtual int GetHostId() = 0; diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index 11c64764..769a477 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -154,6 +154,10 @@ void WebDevToolsAgentImpl::AddMessageToConsole( } } +void WebDevToolsAgentImpl::ForceRepaint() { + delegate_->ForceRepaint(); +} + void WebDevToolsAgentImpl::HighlightDOMNode(int node_id) { if (!attached_) { return; @@ -252,6 +256,7 @@ void WebDevToolsAgent::ExecuteDebuggerCommand( } // static -void WebDevToolsAgent::ScheduleMessageDispatch(Message* message) { - DebuggerAgentManager::ScheduleMessageDispatch(message); +void WebDevToolsAgent::SetMessageLoopDispatchHandler( + MessageLoopDispatchHandler handler) { + DebuggerAgentManager::SetMessageLoopDispatchHandler(handler); } diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h index 232e8e3..4a3c9ea 100644 --- a/webkit/glue/webdevtoolsagent_impl.h +++ b/webkit/glue/webdevtoolsagent_impl.h @@ -71,6 +71,8 @@ class WebDevToolsAgentImpl const WebCore::String& source_id, unsigned int line_no); + void ForceRepaint(); + int host_id() { return host_id_; } NetAgentImpl* net_agent_impl() { return net_agent_impl_.get(); } diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index e974d44..9906a27 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -358,6 +358,7 @@ WebViewImpl::WebViewImpl() zoom_level_(0), context_menu_allowed_(false), doing_drag_and_drop_(false), + ignore_input_events_(false), suppress_next_keypress_event_(false), window_open_disposition_(IGNORE_ACTION), ime_accept_events_(true), @@ -1018,6 +1019,10 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) { // we're done. if (doing_drag_and_drop_) return true; + + if (ignore_input_events_) + return true; + // TODO(eseidel): Remove g_current_input_event. // This only exists to allow ChromeClient::show() to know which mouse button // triggered a window.open event. @@ -1881,6 +1886,11 @@ void WebViewImpl::HideAutoCompletePopup() { } } +void WebViewImpl::SetIgnoreInputEvents(bool new_value) { + DCHECK(ignore_input_events_ != new_value); + ignore_input_events_ = new_value; +} + WebCore::Node* WebViewImpl::GetNodeForWindowPos(int x, int y) { HitTestResult result = HitTestResultForWindowPos(IntPoint(x, y)); return result.innerNonSharedNode(); diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 9080bf4..71a5a86 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -120,6 +120,7 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { const std::vector<std::wstring>& suggestions, int default_suggestion_index); virtual void HideAutofillPopup(); + virtual void SetIgnoreInputEvents(bool new_value); virtual WebDevToolsAgent* GetWebDevToolsAgent(); WebDevToolsAgentImpl* GetWebDevToolsAgentImpl(); @@ -304,6 +305,8 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { bool doing_drag_and_drop_; + bool ignore_input_events_; + // Webkit expects keyPress events to be suppressed if the associated keyDown // event was handled. Safari implements this behavior by peeking out the // associated WM_CHAR event if the keydown was handled. We emulate |