Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Side by Side Diff: Source/web/WebDevToolsAgentImpl.cpp

Issue 468083003: Cleanup namespace usage in Source/web/Web[A-H]*.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebasing Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/web/WebDateTimeSuggestion.cpp ('k') | Source/web/WebDevToolsFrontendImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (C) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "public/web/WebSettings.h" 67 #include "public/web/WebSettings.h"
68 #include "public/web/WebViewClient.h" 68 #include "public/web/WebViewClient.h"
69 #include "web/WebInputEventConversion.h" 69 #include "web/WebInputEventConversion.h"
70 #include "web/WebLocalFrameImpl.h" 70 #include "web/WebLocalFrameImpl.h"
71 #include "web/WebViewImpl.h" 71 #include "web/WebViewImpl.h"
72 #include "wtf/CurrentTime.h" 72 #include "wtf/CurrentTime.h"
73 #include "wtf/MathExtras.h" 73 #include "wtf/MathExtras.h"
74 #include "wtf/Noncopyable.h" 74 #include "wtf/Noncopyable.h"
75 #include "wtf/text/WTFString.h" 75 #include "wtf/text/WTFString.h"
76 76
77 using namespace blink;
78
79 namespace OverlayZOrders { 77 namespace OverlayZOrders {
80 // Use 99 as a big z-order number so that highlight is above other overlays. 78 // Use 99 as a big z-order number so that highlight is above other overlays.
81 static const int highlight = 99; 79 static const int highlight = 99;
82 } 80 }
83 81
84 namespace blink { 82 namespace blink {
85 83
86 class ClientMessageLoopAdapter : public PageScriptDebugServer::ClientMessageLoop { 84 class ClientMessageLoopAdapter : public PageScriptDebugServer::ClientMessageLoop {
87 public: 85 public:
88 static void ensureClientMessageLoopCreated(WebDevToolsAgentClient* client) 86 static void ensureClientMessageLoopCreated(WebDevToolsAgentClient* client)
(...skipping 12 matching lines...) Expand all
101 } 99 }
102 100
103 static void didNavigate() 101 static void didNavigate()
104 { 102 {
105 // Release render thread if necessary. 103 // Release render thread if necessary.
106 if (s_instance && s_instance->m_running) 104 if (s_instance && s_instance->m_running)
107 PageScriptDebugServer::shared().continueProgram(); 105 PageScriptDebugServer::shared().continueProgram();
108 } 106 }
109 107
110 private: 108 private:
111 ClientMessageLoopAdapter(PassOwnPtr<blink::WebDevToolsAgentClient::WebKitCli entMessageLoop> messageLoop) 109 ClientMessageLoopAdapter(PassOwnPtr<WebDevToolsAgentClient::WebKitClientMess ageLoop> messageLoop)
112 : m_running(false) 110 : m_running(false)
113 , m_messageLoop(messageLoop) { } 111 , m_messageLoop(messageLoop) { }
114 112
115 113
116 virtual void run(Page* page) 114 virtual void run(Page* page)
117 { 115 {
118 if (m_running) 116 if (m_running)
119 return; 117 return;
120 m_running = true; 118 m_running = true;
121 119
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 161
164 m_running = false; 162 m_running = false;
165 } 163 }
166 164
167 virtual void quitNow() 165 virtual void quitNow()
168 { 166 {
169 m_messageLoop->quitNow(); 167 m_messageLoop->quitNow();
170 } 168 }
171 169
172 bool m_running; 170 bool m_running;
173 OwnPtr<blink::WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLoop ; 171 OwnPtr<WebDevToolsAgentClient::WebKitClientMessageLoop> m_messageLoop;
174 typedef HashSet<WebViewImpl*> FrozenViewsSet; 172 typedef HashSet<WebViewImpl*> FrozenViewsSet;
175 FrozenViewsSet m_frozenViews; 173 FrozenViewsSet m_frozenViews;
176 // FIXME: The ownership model for s_instance is somewhat complicated. Can we make this simpler? 174 // FIXME: The ownership model for s_instance is somewhat complicated. Can we make this simpler?
177 static ClientMessageLoopAdapter* s_instance; 175 static ClientMessageLoopAdapter* s_instance;
178 }; 176 };
179 177
180 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = 0; 178 ClientMessageLoopAdapter* ClientMessageLoopAdapter::s_instance = 0;
181 179
182 class DebuggerTask : public PageScriptDebugServer::Task { 180 class DebuggerTask : public PageScriptDebugServer::Task {
183 public: 181 public:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 inspectorController()->setProcessId(processId); 219 inspectorController()->setProcessId(processId);
222 220
223 ASSERT(m_debuggerId > 0); 221 ASSERT(m_debuggerId > 0);
224 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); 222 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client);
225 } 223 }
226 224
227 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() 225 WebDevToolsAgentImpl::~WebDevToolsAgentImpl()
228 { 226 {
229 ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl); 227 ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl);
230 if (m_attached) 228 if (m_attached)
231 blink::Platform::current()->currentThread()->removeTaskObserver(this); 229 Platform::current()->currentThread()->removeTaskObserver(this);
232 } 230 }
233 231
234 void WebDevToolsAgentImpl::attach(const WebString& hostId) 232 void WebDevToolsAgentImpl::attach(const WebString& hostId)
235 { 233 {
236 if (m_attached) 234 if (m_attached)
237 return; 235 return;
238 236
239 inspectorController()->connectFrontend(hostId, this); 237 inspectorController()->connectFrontend(hostId, this);
240 blink::Platform::current()->currentThread()->addTaskObserver(this); 238 Platform::current()->currentThread()->addTaskObserver(this);
241 m_attached = true; 239 m_attached = true;
242 } 240 }
243 241
244 void WebDevToolsAgentImpl::reattach(const WebString& hostId, const WebString& sa vedState) 242 void WebDevToolsAgentImpl::reattach(const WebString& hostId, const WebString& sa vedState)
245 { 243 {
246 if (m_attached) 244 if (m_attached)
247 return; 245 return;
248 246
249 inspectorController()->reuseFrontend(hostId, this, savedState); 247 inspectorController()->reuseFrontend(hostId, this, savedState);
250 blink::Platform::current()->currentThread()->addTaskObserver(this); 248 Platform::current()->currentThread()->addTaskObserver(this);
251 m_attached = true; 249 m_attached = true;
252 } 250 }
253 251
254 void WebDevToolsAgentImpl::detach() 252 void WebDevToolsAgentImpl::detach()
255 { 253 {
256 blink::Platform::current()->currentThread()->removeTaskObserver(this); 254 Platform::current()->currentThread()->removeTaskObserver(this);
257 255
258 // Prevent controller from sending messages to the frontend. 256 // Prevent controller from sending messages to the frontend.
259 InspectorController* ic = inspectorController(); 257 InspectorController* ic = inspectorController();
260 ic->disconnectFrontend(); 258 ic->disconnectFrontend();
261 m_attached = false; 259 m_attached = false;
262 } 260 }
263 261
264 void WebDevToolsAgentImpl::continueProgram() 262 void WebDevToolsAgentImpl::continueProgram()
265 { 263 {
266 ClientMessageLoopAdapter::didNavigate(); 264 ClientMessageLoopAdapter::didNavigate();
(...skipping 21 matching lines...) Expand all
288 286
289 void WebDevToolsAgentImpl::didComposite() 287 void WebDevToolsAgentImpl::didComposite()
290 { 288 {
291 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "CompositeL ayers"); 289 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "CompositeL ayers");
292 if (InspectorController* ic = inspectorController()) 290 if (InspectorController* ic = inspectorController())
293 ic->didComposite(); 291 ic->didComposite();
294 } 292 }
295 293
296 void WebDevToolsAgentImpl::didCreateScriptContext(WebLocalFrameImpl* webframe, i nt worldId) 294 void WebDevToolsAgentImpl::didCreateScriptContext(WebLocalFrameImpl* webframe, i nt worldId)
297 { 295 {
298 if (blink::LocalFrame* frame = webframe->frame()) 296 if (LocalFrame* frame = webframe->frame())
299 frame->script().setWorldDebugId(worldId, m_debuggerId); 297 frame->script().setWorldDebugId(worldId, m_debuggerId);
300 // Skip non main world contexts. 298 // Skip non main world contexts.
301 if (worldId) 299 if (worldId)
302 return; 300 return;
303 m_webViewDidLayoutOnceAfterLoad = false; 301 m_webViewDidLayoutOnceAfterLoad = false;
304 } 302 }
305 303
306 bool WebDevToolsAgentImpl::handleInputEvent(blink::Page* page, const WebInputEve nt& inputEvent) 304 bool WebDevToolsAgentImpl::handleInputEvent(Page* page, const WebInputEvent& inp utEvent)
307 { 305 {
308 if (!m_attached && !m_generatingEvent) 306 if (!m_attached && !m_generatingEvent)
309 return false; 307 return false;
310 308
311 // FIXME: This workaround is required for touch emulation on Mac, where 309 // FIXME: This workaround is required for touch emulation on Mac, where
312 // compositor-side pinch handling is not enabled. See http://crbug.com/13800 3. 310 // compositor-side pinch handling is not enabled. See http://crbug.com/13800 3.
313 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve nt::GesturePinchEnd; 311 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve nt::GesturePinchEnd;
314 if (isPinch && m_touchEventEmulationEnabled) { 312 if (isPinch && m_touchEventEmulationEnabled) {
315 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); 313 FrameView* frameView = page->deprecatedLocalMainFrame()->view();
316 PlatformGestureEventBuilder gestureEvent(frameView, static_cast<const We bGestureEvent&>(inputEvent)); 314 PlatformGestureEventBuilder gestureEvent(frameView, static_cast<const We bGestureEvent&>(inputEvent));
317 float pageScaleFactor = page->pageScaleFactor(); 315 float pageScaleFactor = page->pageScaleFactor();
318 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { 316 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) {
319 m_lastPinchAnchorCss = adoptPtr(new blink::IntPoint(frameView->scrol lPosition() + gestureEvent.position())); 317 m_lastPinchAnchorCss = adoptPtr(new IntPoint(frameView->scrollPositi on() + gestureEvent.position()));
320 m_lastPinchAnchorDip = adoptPtr(new blink::IntPoint(gestureEvent.pos ition())); 318 m_lastPinchAnchorDip = adoptPtr(new IntPoint(gestureEvent.position() ));
321 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); 319 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor);
322 } 320 }
323 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi nchAnchorCss) { 321 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi nchAnchorCss) {
324 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); 322 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale();
325 blink::IntPoint anchorCss(*m_lastPinchAnchorDip.get()); 323 IntPoint anchorCss(*m_lastPinchAnchorDip.get());
326 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); 324 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor);
327 m_webViewImpl->setPageScaleFactor(newPageScaleFactor); 325 m_webViewImpl->setPageScaleFactor(newPageScaleFactor);
328 m_webViewImpl->setMainFrameScrollOffset(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss)); 326 m_webViewImpl->setMainFrameScrollOffset(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss));
329 } 327 }
330 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) { 328 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) {
331 m_lastPinchAnchorCss.clear(); 329 m_lastPinchAnchorCss.clear();
332 m_lastPinchAnchorDip.clear(); 330 m_lastPinchAnchorDip.clear();
333 } 331 }
334 return true; 332 return true;
335 } 333 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 m_webViewImpl->layout(); 654 m_webViewImpl->layout();
657 } 655 }
658 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); 656 m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight);
659 } 657 }
660 658
661 void WebDevToolsAgentImpl::hideHighlight() 659 void WebDevToolsAgentImpl::hideHighlight()
662 { 660 {
663 m_webViewImpl->removePageOverlay(this); 661 m_webViewImpl->removePageOverlay(this);
664 } 662 }
665 663
666 void WebDevToolsAgentImpl::sendMessageToFrontend(PassRefPtr<blink::JSONObject> m essage) 664 void WebDevToolsAgentImpl::sendMessageToFrontend(PassRefPtr<JSONObject> message)
667 { 665 {
668 m_frontendMessageQueue.append(message); 666 m_frontendMessageQueue.append(message);
669 } 667 }
670 668
671 void WebDevToolsAgentImpl::flush() 669 void WebDevToolsAgentImpl::flush()
672 { 670 {
673 flushPendingFrontendMessages(); 671 flushPendingFrontendMessages();
674 } 672 }
675 673
676 void WebDevToolsAgentImpl::updateInspectorStateCookie(const String& state) 674 void WebDevToolsAgentImpl::updateInspectorStateCookie(const String& state)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_removeBreakpointCmd) 736 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_removeBreakpointCmd)
739 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_setBreakpointsActiveCmd); 737 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_setBreakpointsActiveCmd);
740 } 738 }
741 739
742 void WebDevToolsAgent::processPendingMessages() 740 void WebDevToolsAgent::processPendingMessages()
743 { 741 {
744 PageScriptDebugServer::shared().runPendingTasks(); 742 PageScriptDebugServer::shared().runPendingTasks();
745 } 743 }
746 744
747 } // namespace blink 745 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebDateTimeSuggestion.cpp ('k') | Source/web/WebDevToolsFrontendImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698