Chromium Code Reviews| 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 15 matching lines...) Expand all Loading... | |
| 419 StaticElementList* elements = nullptr; | 418 StaticElementList* elements = nullptr; |
| 420 TrackExceptionState exceptionState; | 419 TrackExceptionState exceptionState; |
| 421 ContainerNode* queryBase = m_highlightNode->containingShadowRoot(); | 420 ContainerNode* queryBase = m_highlightNode->containingShadowRoot(); |
| 422 if (!queryBase) | 421 if (!queryBase) |
| 423 queryBase = m_highlightNode->ownerDocument(); | 422 queryBase = m_highlightNode->ownerDocument(); |
| 424 if (selectors.length()) | 423 if (selectors.length()) |
| 425 elements = queryBase->querySelectorAll(AtomicString(selectors), exceptio nState); | 424 elements = queryBase->querySelectorAll(AtomicString(selectors), exceptio nState); |
| 426 if (elements && !exceptionState.hadException()) { | 425 if (elements && !exceptionState.hadException()) { |
| 427 for (unsigned i = 0; i < elements->length(); ++i) { | 426 for (unsigned i = 0; i < elements->length(); ++i) { |
| 428 Element* element = elements->item(i); | 427 Element* element = elements->item(i); |
| 429 InspectorHighlight highlight(element, m_nodeHighlightConfig, false); | 428 InspectorHighlight highlight(element, m_nodeHighlightConfig, false, windowToViewportScale()); |
|
oshima
2016/07/01 12:03:18
can you pass this value in resetData instead? That
Bret
2016/07/01 18:24:35
Ah yes, that's better. Done.
| |
| 430 std::unique_ptr<protocol::DictionaryValue> highlightJSON = highlight .asProtocolValue(); | 429 std::unique_ptr<protocol::DictionaryValue> highlightJSON = highlight .asProtocolValue(); |
| 431 evaluateInOverlay("drawHighlight", std::move(highlightJSON)); | 430 evaluateInOverlay("drawHighlight", std::move(highlightJSON)); |
| 432 } | 431 } |
| 433 } | 432 } |
| 434 | 433 |
| 435 bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highli ghtNode->document().frame(); | 434 bool appendElementInfo = m_highlightNode->isElementNode() && !m_omitTooltip && m_nodeHighlightConfig.showInfo && m_highlightNode->layoutObject() && m_highli ghtNode->document().frame(); |
| 436 InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, a ppendElementInfo); | 435 InspectorHighlight highlight(m_highlightNode.get(), m_nodeHighlightConfig, a ppendElementInfo, windowToViewportScale()); |
| 437 if (m_eventTargetNode) | 436 if (m_eventTargetNode) |
| 438 highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighligh tConfig); | 437 highlight.appendEventTargetQuads(m_eventTargetNode.get(), m_nodeHighligh tConfig); |
| 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; |
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |