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

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

Issue 336553003: Change Page::m_mainFrame to be a Frame. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/PageWidgetDelegate.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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputE vent& inputEvent) 301 bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputE vent& inputEvent)
302 { 302 {
303 if (!m_attached && !m_generatingEvent) 303 if (!m_attached && !m_generatingEvent)
304 return false; 304 return false;
305 305
306 // FIXME: This workaround is required for touch emulation on Mac, where 306 // FIXME: This workaround is required for touch emulation on Mac, where
307 // compositor-side pinch handling is not enabled. See http://crbug.com/13800 3. 307 // compositor-side pinch handling is not enabled. See http://crbug.com/13800 3.
308 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve nt::GesturePinchEnd; 308 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve nt::GesturePinchEnd;
309 if (isPinch && m_touchEventEmulationEnabled && m_emulateViewportEnabled) { 309 if (isPinch && m_touchEventEmulationEnabled && m_emulateViewportEnabled) {
310 FrameView* frameView = page->mainFrame()->view(); 310 FrameView* frameView = page->deprecatedLocalMainFrame()->view();
311 PlatformGestureEventBuilder gestureEvent(frameView, *static_cast<const W ebGestureEvent*>(&inputEvent)); 311 PlatformGestureEventBuilder gestureEvent(frameView, *static_cast<const W ebGestureEvent*>(&inputEvent));
312 float pageScaleFactor = page->pageScaleFactor(); 312 float pageScaleFactor = page->pageScaleFactor();
313 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { 313 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) {
314 m_lastPinchAnchorCss = adoptPtr(new WebCore::IntPoint(frameView->scr ollPosition() + gestureEvent.position())); 314 m_lastPinchAnchorCss = adoptPtr(new WebCore::IntPoint(frameView->scr ollPosition() + gestureEvent.position()));
315 m_lastPinchAnchorDip = adoptPtr(new WebCore::IntPoint(gestureEvent.p osition())); 315 m_lastPinchAnchorDip = adoptPtr(new WebCore::IntPoint(gestureEvent.p osition()));
316 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); 316 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor);
317 } 317 }
318 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi nchAnchorCss) { 318 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi nchAnchorCss) {
319 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); 319 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale();
320 WebCore::IntPoint anchorCss(*m_lastPinchAnchorDip.get()); 320 WebCore::IntPoint anchorCss(*m_lastPinchAnchorDip.get());
321 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor); 321 anchorCss.scale(1.f / newPageScaleFactor, 1.f / newPageScaleFactor);
322 m_webViewImpl->setPageScaleFactor(newPageScaleFactor); 322 m_webViewImpl->setPageScaleFactor(newPageScaleFactor);
323 m_webViewImpl->setMainFrameScrollOffset(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss)); 323 m_webViewImpl->setMainFrameScrollOffset(*m_lastPinchAnchorCss.get() - toIntSize(anchorCss));
324 } 324 }
325 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) { 325 if (gestureEvent.type() == PlatformEvent::GesturePinchEnd) {
326 m_lastPinchAnchorCss.clear(); 326 m_lastPinchAnchorCss.clear();
327 m_lastPinchAnchorDip.clear(); 327 m_lastPinchAnchorDip.clear();
328 } 328 }
329 return true; 329 return true;
330 } 330 }
331 331
332 InspectorController* ic = inspectorController(); 332 InspectorController* ic = inspectorController();
333 if (!ic) 333 if (!ic)
334 return false; 334 return false;
335 335
336 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) { 336 if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) {
337 // Only let GestureTab in (we only need it and we know PlatformGestureEv entBuilder supports it). 337 // Only let GestureTab in (we only need it and we know PlatformGestureEv entBuilder supports it).
338 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(page->ma inFrame()->view(), *static_cast<const WebGestureEvent*>(&inputEvent)); 338 PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(page->de precatedLocalMainFrame()->view(), *static_cast<const WebGestureEvent*>(&inputEve nt));
339 return ic->handleGestureEvent(page->mainFrame(), gestureEvent); 339 return ic->handleGestureEvent(toLocalFrame(page->mainFrame()), gestureEv ent);
340 } 340 }
341 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W ebInputEvent::MouseEnter) { 341 if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != W ebInputEvent::MouseEnter) {
342 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f ilter it out manually. 342 // PlatformMouseEventBuilder does not work with MouseEnter type, so we f ilter it out manually.
343 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(page->mainFram e()->view(), *static_cast<const WebMouseEvent*>(&inputEvent)); 343 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(page->deprecat edLocalMainFrame()->view(), *static_cast<const WebMouseEvent*>(&inputEvent));
344 return ic->handleMouseEvent(page->mainFrame(), mouseEvent); 344 return ic->handleMouseEvent(toLocalFrame(page->mainFrame()), mouseEvent) ;
345 } 345 }
346 if (WebInputEvent::isTouchEventType(inputEvent.type)) { 346 if (WebInputEvent::isTouchEventType(inputEvent.type)) {
347 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(page->mainFram e()->view(), *static_cast<const WebTouchEvent*>(&inputEvent)); 347 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(page->deprecat edLocalMainFrame()->view(), *static_cast<const WebTouchEvent*>(&inputEvent));
348 return ic->handleTouchEvent(page->mainFrame(), touchEvent); 348 return ic->handleTouchEvent(toLocalFrame(page->mainFrame()), touchEvent) ;
349 } 349 }
350 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { 350 if (WebInputEvent::isKeyboardEventType(inputEvent.type)) {
351 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(*stat ic_cast<const WebKeyboardEvent*>(&inputEvent)); 351 PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(*stat ic_cast<const WebKeyboardEvent*>(&inputEvent));
352 return ic->handleKeyboardEvent(page->mainFrame(), keyboardEvent); 352 return ic->handleKeyboardEvent(page->deprecatedLocalMainFrame(), keyboar dEvent);
353 } 353 }
354 return false; 354 return false;
355 } 355 }
356 356
357 void WebDevToolsAgentImpl::setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow) 357 void WebDevToolsAgentImpl::setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow)
358 { 358 {
359 if (!m_deviceMetricsEnabled) { 359 if (!m_deviceMetricsEnabled) {
360 m_deviceMetricsEnabled = true; 360 m_deviceMetricsEnabled = true;
361 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); 361 m_webViewImpl->setBackgroundColorOverride(Color::darkGray);
362 } 362 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 InspectorController* WebDevToolsAgentImpl::inspectorController() 610 InspectorController* WebDevToolsAgentImpl::inspectorController()
611 { 611 {
612 if (Page* page = m_webViewImpl->page()) 612 if (Page* page = m_webViewImpl->page())
613 return &page->inspectorController(); 613 return &page->inspectorController();
614 return 0; 614 return 0;
615 } 615 }
616 616
617 LocalFrame* WebDevToolsAgentImpl::mainFrame() 617 LocalFrame* WebDevToolsAgentImpl::mainFrame()
618 { 618 {
619 if (Page* page = m_webViewImpl->page()) 619 if (Page* page = m_webViewImpl->page())
620 return page->mainFrame(); 620 return page->deprecatedLocalMainFrame();
621 return 0; 621 return 0;
622 } 622 }
623 623
624 // WebPageOverlay 624 // WebPageOverlay
625 void WebDevToolsAgentImpl::paintPageOverlay(WebCanvas* canvas) 625 void WebDevToolsAgentImpl::paintPageOverlay(WebCanvas* canvas)
626 { 626 {
627 InspectorController* ic = inspectorController(); 627 InspectorController* ic = inspectorController();
628 if (ic) { 628 if (ic) {
629 GraphicsContext context(canvas); 629 GraphicsContext context(canvas);
630 context.setCertainlyOpaque(false); 630 context.setCertainlyOpaque(false);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_removeBreakpointCmd) 722 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_removeBreakpointCmd)
723 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_setBreakpointsActiveCmd); 723 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke ndDispatcher::kDebugger_setBreakpointsActiveCmd);
724 } 724 }
725 725
726 void WebDevToolsAgent::processPendingMessages() 726 void WebDevToolsAgent::processPendingMessages()
727 { 727 {
728 PageScriptDebugServer::shared().runPendingTasks(); 728 PageScriptDebugServer::shared().runPendingTasks();
729 } 729 }
730 730
731 } // namespace blink 731 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/PageWidgetDelegate.cpp ('k') | Source/web/WebDevToolsFrontendImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698