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

Side by Side Diff: third_party/WebKit/Source/web/InspectorOverlay.cpp

Issue 2108803006: Fix inspector overlay when use-zoom-for-dsf is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash when FrameView is null Created 4 years, 5 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 | « third_party/WebKit/Source/web/InspectorOverlay.h ('k') | no next file » | 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) 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 { 382 {
383 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); 383 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView();
384 if (!view) 384 if (!view)
385 return; 385 return;
386 386
387 IntRect visibleRectInDocument = view->getScrollableArea()->visibleContentRec t(); 387 IntRect visibleRectInDocument = view->getScrollableArea()->visibleContentRec t();
388 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize(); 388 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize();
389 LocalFrame* frame = toLocalFrame(overlayPage()->mainFrame()); 389 LocalFrame* frame = toLocalFrame(overlayPage()->mainFrame());
390 frame->view()->resize(viewportSize); 390 frame->view()->resize(viewportSize);
391 overlayPage()->frameHost().visualViewport().setSize(viewportSize); 391 overlayPage()->frameHost().visualViewport().setSize(viewportSize);
392 float windowToViewportScale = m_webViewImpl->chromeClient().windowToViewport Scalar(1.0f); 392 frame->setPageZoomFactor(windowToViewportScale());
393 frame->setPageZoomFactor(windowToViewportScale);
394 393
395 reset(viewportSize, visibleRectInDocument.location()); 394 reset(viewportSize, visibleRectInDocument.location());
396 395
397 drawNodeHighlight(); 396 drawNodeHighlight();
398 drawQuadHighlight(); 397 drawQuadHighlight();
399 drawPausedInDebuggerMessage(); 398 drawPausedInDebuggerMessage();
400 drawViewSize(); 399 drawViewSize();
401 if (m_layoutEditor && !m_highlightNode) 400 if (m_layoutEditor && !m_highlightNode)
402 m_layoutEditor->rebuild(); 401 m_layoutEditor->rebuild();
403 } 402 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 438
440 std::unique_ptr<protocol::DictionaryValue> highlightJSON = highlight.asProto colValue(); 439 std::unique_ptr<protocol::DictionaryValue> highlightJSON = highlight.asProto colValue();
441 evaluateInOverlay("drawHighlight", std::move(highlightJSON)); 440 evaluateInOverlay("drawHighlight", std::move(highlightJSON));
442 } 441 }
443 442
444 void InspectorOverlay::drawQuadHighlight() 443 void InspectorOverlay::drawQuadHighlight()
445 { 444 {
446 if (!m_highlightQuad) 445 if (!m_highlightQuad)
447 return; 446 return;
448 447
449 InspectorHighlight highlight; 448 InspectorHighlight highlight(windowToViewportScale());
450 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad HighlightConfig.contentOutline); 449 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad HighlightConfig.contentOutline);
451 evaluateInOverlay("drawHighlight", highlight.asProtocolValue()); 450 evaluateInOverlay("drawHighlight", highlight.asProtocolValue());
452 } 451 }
453 452
454 void InspectorOverlay::drawPausedInDebuggerMessage() 453 void InspectorOverlay::drawPausedInDebuggerMessage()
455 { 454 {
456 if (m_inspectMode == InspectorDOMAgent::NotSearching && !m_pausedInDebuggerM essage.isNull()) 455 if (m_inspectMode == InspectorDOMAgent::NotSearching && !m_pausedInDebuggerM essage.isNull())
457 evaluateInOverlay("drawPausedInDebuggerMessage", m_pausedInDebuggerMessa ge); 456 evaluateInOverlay("drawPausedInDebuggerMessage", m_pausedInDebuggerMessa ge);
458 } 457 }
459 458
460 void InspectorOverlay::drawViewSize() 459 void InspectorOverlay::drawViewSize()
461 { 460 {
462 if (m_resizeTimerActive && m_drawViewSize) 461 if (m_resizeTimerActive && m_drawViewSize)
463 evaluateInOverlay("drawViewSize", ""); 462 evaluateInOverlay("drawViewSize", "");
464 } 463 }
465 464
465 float InspectorOverlay::windowToViewportScale() const
466 {
467 return m_webViewImpl->chromeClient().windowToViewportScalar(1.0f);
468 }
469
466 Page* InspectorOverlay::overlayPage() 470 Page* InspectorOverlay::overlayPage()
467 { 471 {
468 if (m_overlayPage) 472 if (m_overlayPage)
469 return m_overlayPage.get(); 473 return m_overlayPage.get();
470 474
471 ScriptForbiddenScope::AllowUserAgentScript allowScript; 475 ScriptForbiddenScope::AllowUserAgentScript allowScript;
472 476
473 DEFINE_STATIC_LOCAL(FrameLoaderClient, dummyFrameLoaderClient, (EmptyFrameLo aderClient::create())); 477 DEFINE_STATIC_LOCAL(FrameLoaderClient, dummyFrameLoaderClient, (EmptyFrameLo aderClient::create()));
474 Page::PageClients pageClients; 478 Page::PageClients pageClients;
475 fillWithEmptyClients(pageClients); 479 fillWithEmptyClients(pageClients);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV alue::create(); 541 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV alue::create();
538 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale Factor()); 542 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale Factor());
539 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact or()); 543 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact or());
540 544
541 IntRect viewportInScreen = m_webViewImpl->chromeClient().viewportToScreen( 545 IntRect viewportInScreen = m_webViewImpl->chromeClient().viewportToScreen(
542 IntRect(IntPoint(), viewportSize), m_webViewImpl->mainFrameImpl()->frame ()->view()); 546 IntRect(IntPoint(), viewportSize), m_webViewImpl->mainFrameImpl()->frame ()->view());
543 resetData->setObject("viewportSize", buildObjectForSize(viewportInScreen.siz e())); 547 resetData->setObject("viewportSize", buildObjectForSize(viewportInScreen.siz e()));
544 548
545 // The zoom factor in the overlay frame already has been multiplied by the w indow to viewport scale 549 // The zoom factor in the overlay frame already has been multiplied by the w indow to viewport scale
546 // (aka device scale factor), so cancel it. 550 // (aka device scale factor), so cancel it.
547 float windowToViewportScale = m_webViewImpl->chromeClient().windowToViewport Scalar(1.0f); 551 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame ()->pageZoomFactor() / windowToViewportScale());
548 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame ()->pageZoomFactor() / windowToViewportScale);
549 552
550 resetData->setNumber("scrollX", documentScrollOffset.x()); 553 resetData->setNumber("scrollX", documentScrollOffset.x());
551 resetData->setNumber("scrollY", documentScrollOffset.y()); 554 resetData->setNumber("scrollY", documentScrollOffset.y());
552 evaluateInOverlay("reset", std::move(resetData)); 555 evaluateInOverlay("reset", std::move(resetData));
553 } 556 }
554 557
555 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument) 558 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument)
556 { 559 {
557 ScriptForbiddenScope::AllowUserAgentScript allowScript; 560 ScriptForbiddenScope::AllowUserAgentScript allowScript;
558 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create() ; 561 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create() ;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 793
791 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) 794 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node)
792 { 795 {
793 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg ent) 796 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg ent)
794 return; 797 return;
795 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script()); 798 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script());
796 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true); 799 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true);
797 } 800 }
798 801
799 } // namespace blink 802 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/InspectorOverlay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698