OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 | 328 |
329 return overlayPage()->mainFrame()->eventHandler().keyEvent(event); | 329 return overlayPage()->mainFrame()->eventHandler().keyEvent(event); |
330 } | 330 } |
331 | 331 |
332 void InspectorOverlay::drawOutline(GraphicsContext* context, const LayoutRect& r ect, const Color& color) | 332 void InspectorOverlay::drawOutline(GraphicsContext* context, const LayoutRect& r ect, const Color& color) |
333 { | 333 { |
334 FloatRect outlineRect = rect; | 334 FloatRect outlineRect = rect; |
335 drawOutlinedQuad(context, outlineRect, Color(), color); | 335 drawOutlinedQuad(context, outlineRect, Color(), color); |
336 } | 336 } |
337 | 337 |
338 void InspectorOverlay::resize(const IntSize& size) | |
339 { | |
340 m_size = size; | |
341 update(); | |
342 } | |
343 | |
344 void InspectorOverlay::setPausedInDebuggerMessage(const String* message) | 338 void InspectorOverlay::setPausedInDebuggerMessage(const String* message) |
345 { | 339 { |
346 m_pausedInDebuggerMessage = message ? *message : String(); | 340 m_pausedInDebuggerMessage = message ? *message : String(); |
347 update(); | 341 update(); |
348 } | 342 } |
349 | 343 |
350 void InspectorOverlay::setInspectModeEnabled(bool enabled) | 344 void InspectorOverlay::setInspectModeEnabled(bool enabled) |
351 { | 345 { |
352 m_inspectModeEnabled = enabled; | 346 m_inspectModeEnabled = enabled; |
353 update(); | 347 update(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 | 382 |
389 Node* InspectorOverlay::highlightedNode() const | 383 Node* InspectorOverlay::highlightedNode() const |
390 { | 384 { |
391 return m_highlightNode.get(); | 385 return m_highlightNode.get(); |
392 } | 386 } |
393 | 387 |
394 bool InspectorOverlay::isEmpty() | 388 bool InspectorOverlay::isEmpty() |
395 { | 389 { |
396 if (m_activeProfilerCount) | 390 if (m_activeProfilerCount) |
397 return true; | 391 return true; |
398 bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_hi ghlightQuad || !m_size.isEmpty() || m_drawViewSize; | 392 bool hasAlwaysVisibleElements = m_highlightNode || m_eventTargetNode || m_hi ghlightQuad || m_drawViewSize; |
399 bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull() ; | 393 bool hasInvisibleInInspectModeElements = !m_pausedInDebuggerMessage.isNull() ; |
400 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && ! m_inspectModeEnabled)); | 394 return !(hasAlwaysVisibleElements || (hasInvisibleInInspectModeElements && ! m_inspectModeEnabled)); |
401 } | 395 } |
402 | 396 |
403 void InspectorOverlay::update() | 397 void InspectorOverlay::update() |
404 { | 398 { |
405 if (isEmpty()) { | 399 if (isEmpty()) { |
406 m_client->hideHighlight(); | 400 m_client->hideHighlight(); |
407 return; | 401 return; |
408 } | 402 } |
409 | 403 |
410 FrameView* view = m_page->mainFrame()->view(); | 404 FrameView* view = m_page->mainFrame()->view(); |
411 if (!view) | 405 if (!view) |
412 return; | 406 return; |
413 IntRect viewRect = view->visibleContentRect(); | |
414 | 407 |
415 // Include scrollbars to avoid masking them by the gutter. | 408 // Include scrollbars to avoid masking them by the gutter. |
416 IntSize frameViewFullSize = view->visibleContentRect(IncludeScrollbars).size (); | 409 IntSize size = view->unscaledVisibleContentSize(IncludeScrollbars); |
417 IntSize size = m_size.isEmpty() ? frameViewFullSize : m_size; | |
418 size.scale(m_page->pageScaleFactor()); | |
419 overlayPage()->mainFrame()->view()->resize(size); | 410 overlayPage()->mainFrame()->view()->resize(size); |
420 | 411 |
421 // Clear canvas and paint things. | 412 // Clear canvas and paint things. |
422 reset(size, m_size.isEmpty() ? IntSize() : frameViewFullSize, viewRect.x(), viewRect.y()); | 413 IntRect viewRect = view->visibleContentRect(); |
414 reset(size, viewRect.x(), viewRect.y()); | |
423 | 415 |
424 drawNodeHighlight(); | 416 drawNodeHighlight(); |
425 drawQuadHighlight(); | 417 drawQuadHighlight(); |
426 if (!m_inspectModeEnabled) | 418 if (!m_inspectModeEnabled) |
427 drawPausedInDebuggerMessage(); | 419 drawPausedInDebuggerMessage(); |
428 drawViewSize(); | 420 drawViewSize(); |
429 | 421 |
430 // Position DOM elements. | 422 // Position DOM elements. |
431 overlayPage()->mainFrame()->document()->setNeedsStyleRecalc(SubtreeStyleChan ge); | 423 overlayPage()->mainFrame()->document()->setNeedsStyleRecalc(SubtreeStyleChan ge); |
432 overlayPage()->mainFrame()->document()->updateLayout(); | 424 overlayPage()->mainFrame()->document()->updateLayout(); |
433 | 425 |
434 // Kick paint. | 426 // Kick paint. |
435 m_client->highlight(); | 427 m_client->highlight(); |
436 } | 428 } |
437 | 429 |
438 void InspectorOverlay::hide() | 430 void InspectorOverlay::hide() |
439 { | 431 { |
440 m_timer.stop(); | 432 m_timer.stop(); |
441 m_highlightNode.clear(); | 433 m_highlightNode.clear(); |
442 m_eventTargetNode.clear(); | 434 m_eventTargetNode.clear(); |
443 m_highlightQuad.clear(); | 435 m_highlightQuad.clear(); |
444 m_pausedInDebuggerMessage = String(); | 436 m_pausedInDebuggerMessage = String(); |
445 m_size = IntSize(); | |
446 m_drawViewSize = false; | 437 m_drawViewSize = false; |
447 m_drawViewSizeWithGrid = false; | 438 m_drawViewSizeWithGrid = false; |
448 update(); | 439 update(); |
449 } | 440 } |
450 | 441 |
451 static PassRefPtr<JSONObject> buildObjectForPoint(const FloatPoint& point) | 442 static PassRefPtr<JSONObject> buildObjectForPoint(const FloatPoint& point) |
452 { | 443 { |
453 RefPtr<JSONObject> object = JSONObject::create(); | 444 RefPtr<JSONObject> object = JSONObject::create(); |
454 object->setNumber("x", point.x()); | 445 object->setNumber("x", point.x()); |
455 object->setNumber("y", point.y()); | 446 object->setNumber("y", point.y()); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 evaluateInOverlay("setPlatform", "windows"); | 725 evaluateInOverlay("setPlatform", "windows"); |
735 #elif OS(MACOSX) | 726 #elif OS(MACOSX) |
736 evaluateInOverlay("setPlatform", "mac"); | 727 evaluateInOverlay("setPlatform", "mac"); |
737 #elif OS(POSIX) | 728 #elif OS(POSIX) |
738 evaluateInOverlay("setPlatform", "linux"); | 729 evaluateInOverlay("setPlatform", "linux"); |
739 #endif | 730 #endif |
740 | 731 |
741 return m_overlayPage.get(); | 732 return m_overlayPage.get(); |
742 } | 733 } |
743 | 734 |
744 void InspectorOverlay::reset(const IntSize& viewportSize, const IntSize& frameVi ewFullSize, int scrollX, int scrollY) | 735 void InspectorOverlay::reset(const IntSize& viewportSize, int scrollX, int scrol lY) |
745 { | 736 { |
746 RefPtr<JSONObject> resetData = JSONObject::create(); | 737 RefPtr<JSONObject> resetData = JSONObject::create(); |
747 resetData->setNumber("pageScaleFactor", m_page->pageScaleFactor()); | 738 resetData->setNumber("pageScaleFactor", m_page->settings().pinchVirtualViewp ortEnabled() ? 1 : m_page->pageScaleFactor()); |
dgozman
2014/05/29 13:58:13
I think there should be utility method instead of
bokan
2014/05/29 15:09:06
page->pageScaleFactor() returns the actual, correc
dgozman
2014/05/29 15:15:08
We use pageScaleFactor to scale from css values (l
bokan
2014/05/29 15:21:16
Ok, in that case, once we remove the old path this
| |
748 resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor()); | 739 resetData->setNumber("deviceScaleFactor", m_page->deviceScaleFactor()); |
749 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); | 740 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); |
750 resetData->setObject("frameViewFullSize", buildObjectForSize(frameViewFullSi ze)); | |
751 resetData->setNumber("pageZoomFactor", m_page->mainFrame()->pageZoomFactor() ); | 741 resetData->setNumber("pageZoomFactor", m_page->mainFrame()->pageZoomFactor() ); |
752 resetData->setNumber("scrollX", scrollX); | 742 resetData->setNumber("scrollX", scrollX); |
753 resetData->setNumber("scrollY", scrollY); | 743 resetData->setNumber("scrollY", scrollY); |
754 evaluateInOverlay("reset", resetData.release()); | 744 evaluateInOverlay("reset", resetData.release()); |
755 } | 745 } |
756 | 746 |
757 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument) | 747 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument) |
758 { | 748 { |
759 RefPtr<JSONArray> command = JSONArray::create(); | 749 RefPtr<JSONArray> command = JSONArray::create(); |
760 command->pushString(method); | 750 command->pushString(method); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 hideHighlight(); | 787 hideHighlight(); |
798 } | 788 } |
799 | 789 |
800 void InspectorOverlay::startedRecordingProfile() | 790 void InspectorOverlay::startedRecordingProfile() |
801 { | 791 { |
802 if (!m_activeProfilerCount++) | 792 if (!m_activeProfilerCount++) |
803 freePage(); | 793 freePage(); |
804 } | 794 } |
805 | 795 |
806 } // namespace WebCore | 796 } // namespace WebCore |
OLD | NEW |