| OLD | NEW |
| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 WebViewImpl* webViewImpl, | 201 WebViewImpl* webViewImpl, |
| 202 WebDevToolsAgentClient* client) | 202 WebDevToolsAgentClient* client) |
| 203 : m_debuggerId(client->debuggerId()) | 203 : m_debuggerId(client->debuggerId()) |
| 204 , m_layerTreeId(0) | 204 , m_layerTreeId(0) |
| 205 , m_client(client) | 205 , m_client(client) |
| 206 , m_webViewImpl(webViewImpl) | 206 , m_webViewImpl(webViewImpl) |
| 207 , m_attached(false) | 207 , m_attached(false) |
| 208 , m_generatingEvent(false) | 208 , m_generatingEvent(false) |
| 209 , m_webViewDidLayoutOnceAfterLoad(false) | 209 , m_webViewDidLayoutOnceAfterLoad(false) |
| 210 , m_deviceMetricsEnabled(false) | 210 , m_deviceMetricsEnabled(false) |
| 211 , m_emulateViewportEnabled(false) | 211 , m_emulateMobileEnabled(false) |
| 212 , m_originalViewportEnabled(false) | 212 , m_originalViewportEnabled(false) |
| 213 , m_isOverlayScrollbarsEnabled(false) | 213 , m_isOverlayScrollbarsEnabled(false) |
| 214 , m_originalMinimumPageScaleFactor(0) | 214 , m_originalMinimumPageScaleFactor(0) |
| 215 , m_originalMaximumPageScaleFactor(0) | 215 , m_originalMaximumPageScaleFactor(0) |
| 216 , m_pageScaleLimitsOverriden(false) | 216 , m_pageScaleLimitsOverriden(false) |
| 217 , m_touchEventEmulationEnabled(false) | 217 , m_touchEventEmulationEnabled(false) |
| 218 { | 218 { |
| 219 ASSERT(m_debuggerId > 0); | 219 ASSERT(m_debuggerId > 0); |
| 220 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); | 220 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); |
| 221 } | 221 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 300 } |
| 301 | 301 |
| 302 bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputE
vent& inputEvent) | 302 bool WebDevToolsAgentImpl::handleInputEvent(WebCore::Page* page, const WebInputE
vent& inputEvent) |
| 303 { | 303 { |
| 304 if (!m_attached && !m_generatingEvent) | 304 if (!m_attached && !m_generatingEvent) |
| 305 return false; | 305 return false; |
| 306 | 306 |
| 307 // FIXME: This workaround is required for touch emulation on Mac, where | 307 // FIXME: This workaround is required for touch emulation on Mac, where |
| 308 // compositor-side pinch handling is not enabled. See http://crbug.com/13800
3. | 308 // compositor-side pinch handling is not enabled. See http://crbug.com/13800
3. |
| 309 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE
vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve
nt::GesturePinchEnd; | 309 bool isPinch = inputEvent.type == WebInputEvent::GesturePinchBegin || inputE
vent.type == WebInputEvent::GesturePinchUpdate || inputEvent.type == WebInputEve
nt::GesturePinchEnd; |
| 310 if (isPinch && m_touchEventEmulationEnabled && m_emulateViewportEnabled) { | 310 if (isPinch && m_touchEventEmulationEnabled && m_emulateMobileEnabled) { |
| 311 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); | 311 FrameView* frameView = page->deprecatedLocalMainFrame()->view(); |
| 312 PlatformGestureEventBuilder gestureEvent(frameView, *static_cast<const W
ebGestureEvent*>(&inputEvent)); | 312 PlatformGestureEventBuilder gestureEvent(frameView, *static_cast<const W
ebGestureEvent*>(&inputEvent)); |
| 313 float pageScaleFactor = page->pageScaleFactor(); | 313 float pageScaleFactor = page->pageScaleFactor(); |
| 314 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { | 314 if (gestureEvent.type() == PlatformEvent::GesturePinchBegin) { |
| 315 m_lastPinchAnchorCss = adoptPtr(new WebCore::IntPoint(frameView->scr
ollPosition() + gestureEvent.position())); | 315 m_lastPinchAnchorCss = adoptPtr(new WebCore::IntPoint(frameView->scr
ollPosition() + gestureEvent.position())); |
| 316 m_lastPinchAnchorDip = adoptPtr(new WebCore::IntPoint(gestureEvent.p
osition())); | 316 m_lastPinchAnchorDip = adoptPtr(new WebCore::IntPoint(gestureEvent.p
osition())); |
| 317 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); | 317 m_lastPinchAnchorDip->scale(pageScaleFactor, pageScaleFactor); |
| 318 } | 318 } |
| 319 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi
nchAnchorCss) { | 319 if (gestureEvent.type() == PlatformEvent::GesturePinchUpdate && m_lastPi
nchAnchorCss) { |
| 320 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); | 320 float newPageScaleFactor = pageScaleFactor * gestureEvent.scale(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return ic->handleKeyboardEvent(page->deprecatedLocalMainFrame(), keyboar
dEvent); | 353 return ic->handleKeyboardEvent(page->deprecatedLocalMainFrame(), keyboar
dEvent); |
| 354 } | 354 } |
| 355 return false; | 355 return false; |
| 356 } | 356 } |
| 357 | 357 |
| 358 void WebDevToolsAgentImpl::didLayout() | 358 void WebDevToolsAgentImpl::didLayout() |
| 359 { | 359 { |
| 360 m_webViewDidLayoutOnceAfterLoad = true; | 360 m_webViewDidLayoutOnceAfterLoad = true; |
| 361 } | 361 } |
| 362 | 362 |
| 363 void WebDevToolsAgentImpl::setDeviceMetricsOverride(int width, int height, float
deviceScaleFactor, bool emulateViewport, bool fitWindow, float scale, float off
setX, float offsetY) | 363 void WebDevToolsAgentImpl::setDeviceMetricsOverride(int width, int height, float
deviceScaleFactor, bool mobile, bool fitWindow, float scale, float offsetX, flo
at offsetY) |
| 364 { | 364 { |
| 365 if (!m_deviceMetricsEnabled) { | 365 if (!m_deviceMetricsEnabled) { |
| 366 m_deviceMetricsEnabled = true; | 366 m_deviceMetricsEnabled = true; |
| 367 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); | 367 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); |
| 368 } | 368 } |
| 369 if (emulateViewport) | 369 if (mobile) |
| 370 enableViewportEmulation(); | 370 enableMobileEmulation(); |
| 371 else | 371 else |
| 372 disableViewportEmulation(); | 372 disableMobileEmulation(); |
| 373 | 373 |
| 374 WebDeviceEmulationParams params; | 374 WebDeviceEmulationParams params; |
| 375 params.screenPosition = emulateViewport ? WebDeviceEmulationParams::Mobile :
WebDeviceEmulationParams::Desktop; | 375 params.screenPosition = mobile ? WebDeviceEmulationParams::Mobile : WebDevic
eEmulationParams::Desktop; |
| 376 params.deviceScaleFactor = deviceScaleFactor; | 376 params.deviceScaleFactor = deviceScaleFactor; |
| 377 params.viewSize = WebSize(width, height); | 377 params.viewSize = WebSize(width, height); |
| 378 params.fitToView = fitWindow; | 378 params.fitToView = fitWindow; |
| 379 params.scale = scale; | 379 params.scale = scale; |
| 380 params.offset = WebFloatPoint(offsetX, offsetY); | 380 params.offset = WebFloatPoint(offsetX, offsetY); |
| 381 m_client->enableDeviceEmulation(params); | 381 m_client->enableDeviceEmulation(params); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void WebDevToolsAgentImpl::clearDeviceMetricsOverride() | 384 void WebDevToolsAgentImpl::clearDeviceMetricsOverride() |
| 385 { | 385 { |
| 386 if (m_deviceMetricsEnabled) { | 386 if (m_deviceMetricsEnabled) { |
| 387 m_deviceMetricsEnabled = false; | 387 m_deviceMetricsEnabled = false; |
| 388 m_webViewImpl->setBackgroundColorOverride(Color::transparent); | 388 m_webViewImpl->setBackgroundColorOverride(Color::transparent); |
| 389 disableViewportEmulation(); | 389 disableMobileEmulation(); |
| 390 m_client->disableDeviceEmulation(); | 390 m_client->disableDeviceEmulation(); |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 | 393 |
| 394 void WebDevToolsAgentImpl::setTouchEventEmulationEnabled(bool enabled) | 394 void WebDevToolsAgentImpl::setTouchEventEmulationEnabled(bool enabled) |
| 395 { | 395 { |
| 396 m_client->setTouchEventEmulationEnabled(enabled, enabled); | 396 m_client->setTouchEventEmulationEnabled(enabled, enabled); |
| 397 m_touchEventEmulationEnabled = enabled; | 397 m_touchEventEmulationEnabled = enabled; |
| 398 updatePageScaleFactorLimits(); | 398 updatePageScaleFactorLimits(); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void WebDevToolsAgentImpl::enableViewportEmulation() | 401 void WebDevToolsAgentImpl::enableMobileEmulation() |
| 402 { | 402 { |
| 403 if (m_emulateViewportEnabled) | 403 if (m_emulateMobileEnabled) |
| 404 return; | 404 return; |
| 405 m_emulateViewportEnabled = true; | 405 m_emulateMobileEnabled = true; |
| 406 m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnab
led(); | 406 m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnab
led(); |
| 407 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); | 407 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); |
| 408 m_originalViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled(); | 408 m_originalViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled(); |
| 409 RuntimeEnabledFeatures::setCSSViewportEnabled(true); | 409 RuntimeEnabledFeatures::setCSSViewportEnabled(true); |
| 410 m_webViewImpl->settings()->setViewportEnabled(true); | 410 m_webViewImpl->settings()->setViewportEnabled(true); |
| 411 m_webViewImpl->settings()->setViewportMetaEnabled(true); | 411 m_webViewImpl->settings()->setViewportMetaEnabled(true); |
| 412 m_webViewImpl->settings()->setShrinksViewportContentToFit(true); | 412 m_webViewImpl->settings()->setShrinksViewportContentToFit(true); |
| 413 m_webViewImpl->setIgnoreViewportTagScaleLimits(true); | 413 m_webViewImpl->setIgnoreViewportTagScaleLimits(true); |
| 414 m_webViewImpl->setZoomFactorOverride(1); | 414 m_webViewImpl->setZoomFactorOverride(1); |
| 415 updatePageScaleFactorLimits(); | 415 updatePageScaleFactorLimits(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 void WebDevToolsAgentImpl::disableViewportEmulation() | 418 void WebDevToolsAgentImpl::disableMobileEmulation() |
| 419 { | 419 { |
| 420 if (!m_emulateViewportEnabled) | 420 if (!m_emulateMobileEnabled) |
| 421 return; | 421 return; |
| 422 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrollbarsEna
bled); | 422 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrollbarsEna
bled); |
| 423 RuntimeEnabledFeatures::setCSSViewportEnabled(m_originalViewportEnabled); | 423 RuntimeEnabledFeatures::setCSSViewportEnabled(m_originalViewportEnabled); |
| 424 m_webViewImpl->settings()->setViewportEnabled(false); | 424 m_webViewImpl->settings()->setViewportEnabled(false); |
| 425 m_webViewImpl->settings()->setViewportMetaEnabled(false); | 425 m_webViewImpl->settings()->setViewportMetaEnabled(false); |
| 426 m_webViewImpl->settings()->setShrinksViewportContentToFit(false); | 426 m_webViewImpl->settings()->setShrinksViewportContentToFit(false); |
| 427 m_webViewImpl->setIgnoreViewportTagScaleLimits(false); | 427 m_webViewImpl->setIgnoreViewportTagScaleLimits(false); |
| 428 m_webViewImpl->setZoomFactorOverride(0); | 428 m_webViewImpl->setZoomFactorOverride(0); |
| 429 m_emulateViewportEnabled = false; | 429 m_emulateMobileEnabled = false; |
| 430 updatePageScaleFactorLimits(); | 430 updatePageScaleFactorLimits(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void WebDevToolsAgentImpl::updatePageScaleFactorLimits() | 433 void WebDevToolsAgentImpl::updatePageScaleFactorLimits() |
| 434 { | 434 { |
| 435 if (m_touchEventEmulationEnabled || m_emulateViewportEnabled) { | 435 if (m_touchEventEmulationEnabled || m_emulateMobileEnabled) { |
| 436 if (!m_pageScaleLimitsOverriden) { | 436 if (!m_pageScaleLimitsOverriden) { |
| 437 m_originalMinimumPageScaleFactor = m_webViewImpl->minimumPageScaleFa
ctor(); | 437 m_originalMinimumPageScaleFactor = m_webViewImpl->minimumPageScaleFa
ctor(); |
| 438 m_originalMaximumPageScaleFactor = m_webViewImpl->maximumPageScaleFa
ctor(); | 438 m_originalMaximumPageScaleFactor = m_webViewImpl->maximumPageScaleFa
ctor(); |
| 439 m_pageScaleLimitsOverriden = true; | 439 m_pageScaleLimitsOverriden = true; |
| 440 } | 440 } |
| 441 if (m_emulateViewportEnabled) { | 441 if (m_emulateMobileEnabled) { |
| 442 m_webViewImpl->setPageScaleFactorLimits(-1, -1); | 442 m_webViewImpl->setPageScaleFactorLimits(-1, -1); |
| 443 m_webViewImpl->setInitialPageScaleOverride(-1); | 443 m_webViewImpl->setInitialPageScaleOverride(-1); |
| 444 } else { | 444 } else { |
| 445 m_webViewImpl->setPageScaleFactorLimits(1, 4); | 445 m_webViewImpl->setPageScaleFactorLimits(1, 4); |
| 446 m_webViewImpl->setInitialPageScaleOverride(1); | 446 m_webViewImpl->setInitialPageScaleOverride(1); |
| 447 } | 447 } |
| 448 } else { | 448 } else { |
| 449 if (m_pageScaleLimitsOverriden) { | 449 if (m_pageScaleLimitsOverriden) { |
| 450 m_pageScaleLimitsOverriden = false; | 450 m_pageScaleLimitsOverriden = false; |
| 451 m_webViewImpl->setPageScaleFactorLimits(m_originalMinimumPageScaleFa
ctor, m_originalMaximumPageScaleFactor); | 451 m_webViewImpl->setPageScaleFactorLimits(m_originalMinimumPageScaleFa
ctor, m_originalMaximumPageScaleFactor); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_removeBreakpointCmd) | 739 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_removeBreakpointCmd) |
| 740 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_setBreakpointsActiveCmd); | 740 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kDebugger_setBreakpointsActiveCmd); |
| 741 } | 741 } |
| 742 | 742 |
| 743 void WebDevToolsAgent::processPendingMessages() | 743 void WebDevToolsAgent::processPendingMessages() |
| 744 { | 744 { |
| 745 PageScriptDebugServer::shared().runPendingTasks(); | 745 PageScriptDebugServer::shared().runPendingTasks(); |
| 746 } | 746 } |
| 747 | 747 |
| 748 } // namespace blink | 748 } // namespace blink |
| OLD | NEW |