| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 drawQuadHighlight(); | 397 drawQuadHighlight(); |
| 398 drawPausedInDebuggerMessage(); | 398 drawPausedInDebuggerMessage(); |
| 399 drawViewSize(); | 399 drawViewSize(); |
| 400 if (m_layoutEditor && !m_highlightNode) | 400 if (m_layoutEditor && !m_highlightNode) |
| 401 m_layoutEditor->rebuild(); | 401 m_layoutEditor->rebuild(); |
| 402 } | 402 } |
| 403 | 403 |
| 404 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize(const IntSi
ze& size) | 404 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize(const IntSi
ze& size) |
| 405 { | 405 { |
| 406 std::unique_ptr<protocol::DictionaryValue> result = protocol::DictionaryValu
e::create(); | 406 std::unique_ptr<protocol::DictionaryValue> result = protocol::DictionaryValu
e::create(); |
| 407 result->setNumber("width", size.width()); | 407 result->setInteger("width", size.width()); |
| 408 result->setNumber("height", size.height()); | 408 result->setInteger("height", size.height()); |
| 409 return result; | 409 return result; |
| 410 } | 410 } |
| 411 | 411 |
| 412 void InspectorOverlay::drawNodeHighlight() | 412 void InspectorOverlay::drawNodeHighlight() |
| 413 { | 413 { |
| 414 if (!m_highlightNode) | 414 if (!m_highlightNode) |
| 415 return; | 415 return; |
| 416 | 416 |
| 417 String selectors = m_nodeHighlightConfig.selectorList; | 417 String selectors = m_nodeHighlightConfig.selectorList; |
| 418 StaticElementList* elements = nullptr; | 418 StaticElementList* elements = nullptr; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 532 } |
| 533 | 533 |
| 534 LocalFrame* InspectorOverlay::overlayMainFrame() | 534 LocalFrame* InspectorOverlay::overlayMainFrame() |
| 535 { | 535 { |
| 536 return toLocalFrame(overlayPage()->mainFrame()); | 536 return toLocalFrame(overlayPage()->mainFrame()); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume
ntScrollOffset) | 539 void InspectorOverlay::reset(const IntSize& viewportSize, const IntPoint& docume
ntScrollOffset) |
| 540 { | 540 { |
| 541 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV
alue::create(); | 541 std::unique_ptr<protocol::DictionaryValue> resetData = protocol::DictionaryV
alue::create(); |
| 542 resetData->setNumber("deviceScaleFactor", m_webViewImpl->page()->deviceScale
Factor()); | 542 resetData->setDouble("deviceScaleFactor", m_webViewImpl->page()->deviceScale
Factor()); |
| 543 resetData->setNumber("pageScaleFactor", m_webViewImpl->page()->pageScaleFact
or()); | 543 resetData->setDouble("pageScaleFactor", m_webViewImpl->page()->pageScaleFact
or()); |
| 544 | 544 |
| 545 IntRect viewportInScreen = m_webViewImpl->chromeClient().viewportToScreen( | 545 IntRect viewportInScreen = m_webViewImpl->chromeClient().viewportToScreen( |
| 546 IntRect(IntPoint(), viewportSize), m_webViewImpl->mainFrameImpl()->frame
()->view()); | 546 IntRect(IntPoint(), viewportSize), m_webViewImpl->mainFrameImpl()->frame
()->view()); |
| 547 resetData->setObject("viewportSize", buildObjectForSize(viewportInScreen.siz
e())); | 547 resetData->setObject("viewportSize", buildObjectForSize(viewportInScreen.siz
e())); |
| 548 | 548 |
| 549 // 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 |
| 550 // (aka device scale factor), so cancel it. | 550 // (aka device scale factor), so cancel it. |
| 551 resetData->setNumber("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame
()->pageZoomFactor() / windowToViewportScale()); | 551 resetData->setDouble("pageZoomFactor", m_webViewImpl->mainFrameImpl()->frame
()->pageZoomFactor() / windowToViewportScale()); |
| 552 | 552 |
| 553 resetData->setNumber("scrollX", documentScrollOffset.x()); | 553 resetData->setInteger("scrollX", documentScrollOffset.x()); |
| 554 resetData->setNumber("scrollY", documentScrollOffset.y()); | 554 resetData->setInteger("scrollY", documentScrollOffset.y()); |
| 555 evaluateInOverlay("reset", std::move(resetData)); | 555 evaluateInOverlay("reset", std::move(resetData)); |
| 556 } | 556 } |
| 557 | 557 |
| 558 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg
ument) | 558 void InspectorOverlay::evaluateInOverlay(const String& method, const String& arg
ument) |
| 559 { | 559 { |
| 560 ScriptForbiddenScope::AllowUserAgentScript allowScript; | 560 ScriptForbiddenScope::AllowUserAgentScript allowScript; |
| 561 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create()
; | 561 std::unique_ptr<protocol::ListValue> command = protocol::ListValue::create()
; |
| 562 command->pushValue(protocol::StringValue::create(method)); | 562 command->pushValue(protocol::StringValue::create(method)); |
| 563 command->pushValue(protocol::StringValue::create(argument)); | 563 command->pushValue(protocol::StringValue::create(argument)); |
| 564 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld(
"dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen
ScriptsDisabled); | 564 toLocalFrame(overlayPage()->mainFrame())->script().executeScriptInMainWorld(
"dispatch(" + command->toJSONString() + ")", ScriptController::ExecuteScriptWhen
ScriptsDisabled); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 793 |
| 794 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) | 794 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) |
| 795 { | 795 { |
| 796 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) |
| 797 return; | 797 return; |
| 798 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()); |
| 799 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde
n(true); | 799 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde
n(true); |
| 800 } | 800 } |
| 801 | 801 |
| 802 } // namespace blink | 802 } // namespace blink |
| OLD | NEW |