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

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

Issue 2057493003: [UseZoomForDSF:DevTools] Apply the zoom factor equivalent to device scale factor to overlay frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply the zoom factor equivalent to device scale factor to overlay frame. Created 4 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
« no previous file with comments | « no previous file | 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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 378 }
379 379
380 void InspectorOverlay::rebuildOverlayPage() 380 void InspectorOverlay::rebuildOverlayPage()
381 { 381 {
382 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); 382 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView();
383 if (!view) 383 if (!view)
384 return; 384 return;
385 385
386 IntRect visibleRectInDocument = view->getScrollableArea()->visibleContentRec t(); 386 IntRect visibleRectInDocument = view->getScrollableArea()->visibleContentRec t();
387 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize(); 387 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize();
388 toLocalFrame(overlayPage()->mainFrame())->view()->resize(viewportSize); 388 LocalFrame* frame = toLocalFrame(overlayPage()->mainFrame());
389 frame->view()->resize(viewportSize);
389 overlayPage()->frameHost().visualViewport().setSize(viewportSize); 390 overlayPage()->frameHost().visualViewport().setSize(viewportSize);
391 float windowToViewportScale = m_webViewImpl->chromeClient().windowToViewport Scalar(1.0f);
392 frame->setPageZoomFactor(windowToViewportScale);
393
390 reset(viewportSize, visibleRectInDocument.location()); 394 reset(viewportSize, visibleRectInDocument.location());
391 395
392 drawNodeHighlight(); 396 drawNodeHighlight();
393 drawQuadHighlight(); 397 drawQuadHighlight();
394 drawPausedInDebuggerMessage(); 398 drawPausedInDebuggerMessage();
395 drawViewSize(); 399 drawViewSize();
396 if (m_layoutEditor && !m_highlightNode) 400 if (m_layoutEditor && !m_highlightNode)
397 m_layoutEditor->rebuild(); 401 m_layoutEditor->rebuild();
398 } 402 }
399 403
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 LocalFrame* InspectorOverlay::overlayMainFrame() 529 LocalFrame* InspectorOverlay::overlayMainFrame()
526 { 530 {
527 return toLocalFrame(overlayPage()->mainFrame()); 531 return toLocalFrame(overlayPage()->mainFrame());
528 } 532 }
529 533
530 void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume ntScrollOffset) 534 void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume ntScrollOffset)
531 { 535 {
532 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV alue::create(); 536 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV alue::create();
533 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale Factor()); 537 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale Factor());
534 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact or()); 538 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact or());
535 resetData->setObject("viewportSize", buildObjectForSize(viewportSize)); 539
536 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame ()->pageZoomFactor()); 540 IntRect viewportInScreen = m_webViewImpl->chromeClient().viewportToScreen(
541 IntRect(IntPoint(), viewportSize), m_webViewImpl->mainFrameImpl()->frame ()->view());
542 resetData->setObject("viewportSize", buildObjectForSize(viewportInScreen.siz e()));
543
544 // The zoom factor in the overlay frame already has been multiplied by the w indow to viewport scale
545 // (aka device scale factor), so cancel it.
546 float windowToViewportScale = m_webViewImpl->chromeClient().windowToViewport Scalar(1.0f);
547 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame ()->pageZoomFactor() / windowToViewportScale);
548
537 resetData->setNumber("scrollX", documentScrollOffset.x()); 549 resetData->setNumber("scrollX", documentScrollOffset.x());
538 resetData->setNumber("scrollY", documentScrollOffset.y()); 550 resetData->setNumber("scrollY", documentScrollOffset.y());
539 evaluateInOverlay("reset", std::move(resetData)); 551 evaluateInOverlay("reset", std::move(resetData));
540 } 552 }
541 553
542 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument) 554 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg ument)
543 { 555 {
544 ScriptForbiddenScope::AllowUserAgentScript allowScript; 556 ScriptForbiddenScope::AllowUserAgentScript allowScript;
545 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create() ; 557 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create() ;
546 command->pushValue(protocol::StringValue::create(method)); 558 command->pushValue(protocol::StringValue::create(method));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 789
778 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) 790 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node)
779 { 791 {
780 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg ent) 792 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg ent)
781 return; 793 return;
782 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script()); 794 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script());
783 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true); 795 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true);
784 } 796 }
785 797
786 } // namespace blink 798 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698