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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 WebDevToolsAgentImpl::WebDevToolsAgentImpl( | 192 WebDevToolsAgentImpl::WebDevToolsAgentImpl( |
193 WebViewImpl* webViewImpl, | 193 WebViewImpl* webViewImpl, |
194 WebDevToolsAgentClient* client) | 194 WebDevToolsAgentClient* client) |
195 : m_hostId(client->hostIdentifier()) | 195 : m_hostId(client->hostIdentifier()) |
196 , m_client(client) | 196 , m_client(client) |
197 , m_webViewImpl(webViewImpl) | 197 , m_webViewImpl(webViewImpl) |
198 , m_attached(false) | 198 , m_attached(false) |
199 , m_generatingEvent(false) | 199 , m_generatingEvent(false) |
200 , m_deviceMetricsEnabled(false) | 200 , m_deviceMetricsEnabled(false) |
| 201 , m_emulateViewportEnabled(false) |
| 202 , m_originalViewportEnabled(false) |
201 , m_isOverlayScrollbarsEnabled(false) | 203 , m_isOverlayScrollbarsEnabled(false) |
202 , m_isCSSViewportEnabled(false) | |
203 { | 204 { |
204 ASSERT(m_hostId > 0); | 205 ASSERT(m_hostId > 0); |
205 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); | 206 ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); |
206 } | 207 } |
207 | 208 |
208 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() | 209 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() |
209 { | 210 { |
210 ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl); | 211 ClientMessageLoopAdapter::inspectedViewClosed(m_webViewImpl); |
211 if (m_attached) | 212 if (m_attached) |
212 WebKit::Platform::current()->currentThread()->removeTaskObserver(this); | 213 WebKit::Platform::current()->currentThread()->removeTaskObserver(this); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(page->mainFram
e()->view(), *static_cast<const WebMouseEvent*>(&inputEvent)); | 308 PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(page->mainFram
e()->view(), *static_cast<const WebMouseEvent*>(&inputEvent)); |
308 return ic->handleMouseEvent(page->mainFrame(), mouseEvent); | 309 return ic->handleMouseEvent(page->mainFrame(), mouseEvent); |
309 } | 310 } |
310 if (WebInputEvent::isTouchEventType(inputEvent.type)) { | 311 if (WebInputEvent::isTouchEventType(inputEvent.type)) { |
311 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(page->mainFram
e()->view(), *static_cast<const WebTouchEvent*>(&inputEvent)); | 312 PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(page->mainFram
e()->view(), *static_cast<const WebTouchEvent*>(&inputEvent)); |
312 return ic->handleTouchEvent(page->mainFrame(), touchEvent); | 313 return ic->handleTouchEvent(page->mainFrame(), touchEvent); |
313 } | 314 } |
314 return false; | 315 return false; |
315 } | 316 } |
316 | 317 |
317 void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float de
viceScaleFactor, bool fitWindow) | 318 void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float de
viceScaleFactor, bool emulateViewport, bool fitWindow) |
318 { | 319 { |
319 if (!width && !height) { | 320 if (!width && !height) { |
320 if (m_deviceMetricsEnabled) { | 321 if (m_deviceMetricsEnabled) { |
321 m_deviceMetricsEnabled = false; | 322 m_deviceMetricsEnabled = false; |
322 m_webViewImpl->setBackgroundColorOverride(Color::transparent); | 323 m_webViewImpl->setBackgroundColorOverride(Color::transparent); |
323 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrol
lbarsEnabled); | 324 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrol
lbarsEnabled); |
324 | 325 disableViewportEmulation(); |
325 RuntimeEnabledFeatures::setCSSViewportEnabled(m_isCSSViewportEnabled
); | |
326 m_webViewImpl->settings()->setViewportEnabled(false); | |
327 m_webViewImpl->setIgnoreViewportTagScaleLimits(false); | |
328 m_webViewImpl->setPageScaleFactorLimits(1, 1); | |
329 | |
330 m_client->disableDeviceEmulation(); | 326 m_client->disableDeviceEmulation(); |
331 } | 327 } |
332 } else { | 328 } else { |
333 if (!m_deviceMetricsEnabled) { | 329 if (!m_deviceMetricsEnabled) { |
334 m_deviceMetricsEnabled = true; | 330 m_deviceMetricsEnabled = true; |
335 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); | 331 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); |
336 m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScroll
barsEnabled(); | 332 m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScroll
barsEnabled(); |
337 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); | 333 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); |
338 | |
339 m_isCSSViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled(
); | |
340 RuntimeEnabledFeatures::setCSSViewportEnabled(true); | |
341 m_webViewImpl->settings()->setViewportEnabled(true); | |
342 m_webViewImpl->setIgnoreViewportTagScaleLimits(true); | |
343 m_webViewImpl->setPageScaleFactorLimits(-1, -1); | |
344 } | 334 } |
| 335 if (emulateViewport) |
| 336 enableViewportEmulation(); |
| 337 else |
| 338 disableViewportEmulation(); |
345 m_client->enableDeviceEmulation(IntSize(width, height), IntRect(0, 0, wi
dth, height), deviceScaleFactor, fitWindow); | 339 m_client->enableDeviceEmulation(IntSize(width, height), IntRect(0, 0, wi
dth, height), deviceScaleFactor, fitWindow); |
346 } | 340 } |
347 } | 341 } |
348 | 342 |
| 343 void WebDevToolsAgentImpl::enableViewportEmulation() |
| 344 { |
| 345 if (m_emulateViewportEnabled) |
| 346 return; |
| 347 m_emulateViewportEnabled = true; |
| 348 m_originalViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled(); |
| 349 RuntimeEnabledFeatures::setCSSViewportEnabled(true); |
| 350 m_webViewImpl->settings()->setViewportEnabled(true); |
| 351 m_webViewImpl->setIgnoreViewportTagScaleLimits(true); |
| 352 m_webViewImpl->setPageScaleFactorLimits(-1, -1); |
| 353 } |
| 354 |
| 355 void WebDevToolsAgentImpl::disableViewportEmulation() |
| 356 { |
| 357 if (!m_emulateViewportEnabled) |
| 358 return; |
| 359 RuntimeEnabledFeatures::setCSSViewportEnabled(m_originalViewportEnabled); |
| 360 m_webViewImpl->settings()->setViewportEnabled(false); |
| 361 m_webViewImpl->setIgnoreViewportTagScaleLimits(false); |
| 362 m_webViewImpl->setPageScaleFactorLimits(1, 1); |
| 363 m_emulateViewportEnabled = false; |
| 364 } |
| 365 |
349 void WebDevToolsAgentImpl::getAllocatedObjects(HashSet<const void*>& set) | 366 void WebDevToolsAgentImpl::getAllocatedObjects(HashSet<const void*>& set) |
350 { | 367 { |
351 class CountingVisitor : public WebDevToolsAgentClient::AllocatedObjectVisito
r { | 368 class CountingVisitor : public WebDevToolsAgentClient::AllocatedObjectVisito
r { |
352 public: | 369 public: |
353 CountingVisitor() : m_totalObjectsCount(0) | 370 CountingVisitor() : m_totalObjectsCount(0) |
354 { | 371 { |
355 } | 372 } |
356 | 373 |
357 virtual bool visitObject(const void* ptr) | 374 virtual bool visitObject(const void* ptr) |
358 { | 375 { |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kProfiler_getCPUProfileCmd) | 617 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kProfiler_getCPUProfileCmd) |
601 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kHeapProfiler_getHeapSnapshotCmd); | 618 || commandName == InspectorBackendDispatcher::commandName(InspectorBacke
ndDispatcher::kHeapProfiler_getHeapSnapshotCmd); |
602 } | 619 } |
603 | 620 |
604 void WebDevToolsAgent::processPendingMessages() | 621 void WebDevToolsAgent::processPendingMessages() |
605 { | 622 { |
606 PageScriptDebugServer::shared().runPendingTasks(); | 623 PageScriptDebugServer::shared().runPendingTasks(); |
607 } | 624 } |
608 | 625 |
609 } // namespace WebKit | 626 } // namespace WebKit |
OLD | NEW |