| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 , m_overlay(&overlay) | 166 , m_overlay(&overlay) |
| 167 { } | 167 { } |
| 168 | 168 |
| 169 Member<ChromeClient> m_client; | 169 Member<ChromeClient> m_client; |
| 170 Member<InspectorOverlay> m_overlay; | 170 Member<InspectorOverlay> m_overlay; |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 | 173 |
| 174 InspectorOverlay::InspectorOverlay(WebViewImpl* webViewImpl) | 174 InspectorOverlay::InspectorOverlay(WebViewImpl* webViewImpl) |
| 175 : m_webViewImpl(webViewImpl) | 175 : m_webViewImpl(webViewImpl) |
| 176 , m_messageType(MessageType::Empty) |
| 176 , m_overlayHost(InspectorOverlayHost::create()) | 177 , m_overlayHost(InspectorOverlayHost::create()) |
| 177 , m_drawViewSize(false) | 178 , m_drawViewSize(false) |
| 178 , m_resizeTimerActive(false) | 179 , m_resizeTimerActive(false) |
| 179 , m_omitTooltip(false) | 180 , m_omitTooltip(false) |
| 180 , m_timer(this, &InspectorOverlay::onTimer) | 181 , m_timer(this, &InspectorOverlay::onTimer) |
| 181 , m_suspended(false) | 182 , m_suspended(false) |
| 182 , m_inLayout(false) | 183 , m_inLayout(false) |
| 183 , m_needsUpdate(false) | 184 , m_needsUpdate(false) |
| 184 , m_inspectMode(InspectorDOMAgent::NotSearching) | 185 , m_inspectMode(InspectorDOMAgent::NotSearching) |
| 185 { | 186 { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 if (inputEvent.type == WebInputEvent::MouseWheel) { | 284 if (inputEvent.type == WebInputEvent::MouseWheel) { |
| 284 PlatformWheelEvent wheelEvent = PlatformWheelEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebMouseWheelEvent&>(inputEvent
)); | 285 PlatformWheelEvent wheelEvent = PlatformWheelEventBuilder(m_webViewImpl-
>mainFrameImpl()->frameView(), static_cast<const WebMouseWheelEvent&>(inputEvent
)); |
| 285 handled = overlayMainFrame()->eventHandler().handleWheelEvent(wheelEvent
) != WebInputEventResult::NotHandled; | 286 handled = overlayMainFrame()->eventHandler().handleWheelEvent(wheelEvent
) != WebInputEventResult::NotHandled; |
| 286 } | 287 } |
| 287 | 288 |
| 288 return handled; | 289 return handled; |
| 289 } | 290 } |
| 290 | 291 |
| 291 void InspectorOverlay::setPausedInDebuggerMessage(const String& message) | 292 void InspectorOverlay::setPausedInDebuggerMessage(const String& message) |
| 292 { | 293 { |
| 293 m_pausedInDebuggerMessage = message; | 294 m_message = message; |
| 295 m_messageType = message.isNull() ? MessageType::Empty : MessageType::PausedI
nDebugger; |
| 294 scheduleUpdate(); | 296 scheduleUpdate(); |
| 295 } | 297 } |
| 296 | 298 |
| 299 void InspectorOverlay::setReloadingBanner(const String& message) |
| 300 { |
| 301 DCHECK(!message.isNull()); |
| 302 m_message = message; |
| 303 m_messageType = MessageType::Reloading; |
| 304 scheduleUpdate(); |
| 305 } |
| 306 |
| 307 void InspectorOverlay::maybeClearReloadingBanner() |
| 308 { |
| 309 if (m_messageType != MessageType::Reloading) |
| 310 return; |
| 311 m_message = String(); |
| 312 m_messageType = MessageType::Empty; |
| 313 if (m_suspended) |
| 314 clearInternal(); |
| 315 else |
| 316 scheduleUpdate(); |
| 317 } |
| 318 |
| 297 void InspectorOverlay::hideHighlight() | 319 void InspectorOverlay::hideHighlight() |
| 298 { | 320 { |
| 299 m_highlightNode.clear(); | 321 m_highlightNode.clear(); |
| 300 m_eventTargetNode.clear(); | 322 m_eventTargetNode.clear(); |
| 301 m_highlightQuad.reset(); | 323 m_highlightQuad.reset(); |
| 302 scheduleUpdate(); | 324 scheduleUpdate(); |
| 303 } | 325 } |
| 304 | 326 |
| 305 void InspectorOverlay::highlightNode(Node* node, const InspectorHighlightConfig&
highlightConfig, bool omitTooltip) | 327 void InspectorOverlay::highlightNode(Node* node, const InspectorHighlightConfig&
highlightConfig, bool omitTooltip) |
| 306 { | 328 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 void InspectorOverlay::highlightQuad(std::unique_ptr<FloatQuad> quad, const Insp
ectorHighlightConfig& highlightConfig) | 369 void InspectorOverlay::highlightQuad(std::unique_ptr<FloatQuad> quad, const Insp
ectorHighlightConfig& highlightConfig) |
| 348 { | 370 { |
| 349 m_quadHighlightConfig = highlightConfig; | 371 m_quadHighlightConfig = highlightConfig; |
| 350 m_highlightQuad = std::move(quad); | 372 m_highlightQuad = std::move(quad); |
| 351 m_omitTooltip = false; | 373 m_omitTooltip = false; |
| 352 scheduleUpdate(); | 374 scheduleUpdate(); |
| 353 } | 375 } |
| 354 | 376 |
| 355 bool InspectorOverlay::isEmpty() | 377 bool InspectorOverlay::isEmpty() |
| 356 { | 378 { |
| 357 if (m_suspended) | 379 if (m_suspended && m_messageType != MessageType::Reloading) |
| 358 return true; | 380 return true; |
| 359 bool hasVisibleElements = m_highlightNode || m_eventTargetNode || m_highligh
tQuad || (m_resizeTimerActive && m_drawViewSize) || !m_pausedInDebuggerMessage.
isNull(); | 381 bool hasVisibleElements = m_highlightNode || m_eventTargetNode || m_highligh
tQuad || (m_resizeTimerActive && m_drawViewSize) || !m_message.isNull(); |
| 360 return !hasVisibleElements && m_inspectMode == InspectorDOMAgent::NotSearchi
ng; | 382 return !hasVisibleElements && m_inspectMode == InspectorDOMAgent::NotSearchi
ng; |
| 361 } | 383 } |
| 362 | 384 |
| 363 void InspectorOverlay::scheduleUpdate() | 385 void InspectorOverlay::scheduleUpdate() |
| 364 { | 386 { |
| 365 if (isEmpty()) { | 387 if (isEmpty()) { |
| 366 if (m_pageOverlay) | 388 if (m_pageOverlay) |
| 367 m_pageOverlay.reset(); | 389 m_pageOverlay.reset(); |
| 368 return; | 390 return; |
| 369 } | 391 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 383 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s
ize(); | 405 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s
ize(); |
| 384 LocalFrame* frame = toLocalFrame(overlayPage()->mainFrame()); | 406 LocalFrame* frame = toLocalFrame(overlayPage()->mainFrame()); |
| 385 frame->view()->resize(viewportSize); | 407 frame->view()->resize(viewportSize); |
| 386 overlayPage()->frameHost().visualViewport().setSize(viewportSize); | 408 overlayPage()->frameHost().visualViewport().setSize(viewportSize); |
| 387 frame->setPageZoomFactor(windowToViewportScale()); | 409 frame->setPageZoomFactor(windowToViewportScale()); |
| 388 | 410 |
| 389 reset(viewportSize, visibleRectInDocument.location()); | 411 reset(viewportSize, visibleRectInDocument.location()); |
| 390 | 412 |
| 391 drawNodeHighlight(); | 413 drawNodeHighlight(); |
| 392 drawQuadHighlight(); | 414 drawQuadHighlight(); |
| 393 drawPausedInDebuggerMessage(); | 415 drawMessages(); |
| 394 drawViewSize(); | 416 drawViewSize(); |
| 395 if (m_layoutEditor && !m_highlightNode) | 417 if (m_layoutEditor && !m_highlightNode) |
| 396 m_layoutEditor->rebuild(); | 418 m_layoutEditor->rebuild(); |
| 397 } | 419 } |
| 398 | 420 |
| 399 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize(const IntSi
ze& size) | 421 static std::unique_ptr<protocol::DictionaryValue> buildObjectForSize(const IntSi
ze& size) |
| 400 { | 422 { |
| 401 std::unique_ptr<protocol::DictionaryValue> result = protocol::DictionaryValu
e::create(); | 423 std::unique_ptr<protocol::DictionaryValue> result = protocol::DictionaryValu
e::create(); |
| 402 result->setInteger("width", size.width()); | 424 result->setInteger("width", size.width()); |
| 403 result->setInteger("height", size.height()); | 425 result->setInteger("height", size.height()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 void InspectorOverlay::drawQuadHighlight() | 460 void InspectorOverlay::drawQuadHighlight() |
| 439 { | 461 { |
| 440 if (!m_highlightQuad) | 462 if (!m_highlightQuad) |
| 441 return; | 463 return; |
| 442 | 464 |
| 443 InspectorHighlight highlight(windowToViewportScale()); | 465 InspectorHighlight highlight(windowToViewportScale()); |
| 444 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad
HighlightConfig.contentOutline); | 466 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad
HighlightConfig.contentOutline); |
| 445 evaluateInOverlay("drawHighlight", highlight.asProtocolValue()); | 467 evaluateInOverlay("drawHighlight", highlight.asProtocolValue()); |
| 446 } | 468 } |
| 447 | 469 |
| 448 void InspectorOverlay::drawPausedInDebuggerMessage() | 470 void InspectorOverlay::drawMessages() |
| 449 { | 471 { |
| 450 if (m_inspectMode == InspectorDOMAgent::NotSearching && !m_pausedInDebuggerM
essage.isNull()) | 472 if (!m_suspended && m_inspectMode == InspectorDOMAgent::NotSearching && m_me
ssageType == MessageType::PausedInDebugger) |
| 451 evaluateInOverlay("drawPausedInDebuggerMessage", m_pausedInDebuggerMessa
ge); | 473 evaluateInOverlay("drawPausedInDebuggerMessage", m_message); |
| 474 else if (m_messageType == MessageType::Reloading) |
| 475 evaluateInOverlay("drawReloadingMessage", m_message); |
| 452 } | 476 } |
| 453 | 477 |
| 454 void InspectorOverlay::drawViewSize() | 478 void InspectorOverlay::drawViewSize() |
| 455 { | 479 { |
| 456 if (m_resizeTimerActive && m_drawViewSize) | 480 if (m_resizeTimerActive && m_drawViewSize) |
| 457 evaluateInOverlay("drawViewSize", ""); | 481 evaluateInOverlay("drawViewSize", ""); |
| 458 } | 482 } |
| 459 | 483 |
| 460 float InspectorOverlay::windowToViewportScale() const | 484 float InspectorOverlay::windowToViewportScale() const |
| 461 { | 485 { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 { | 610 { |
| 587 if (m_layoutEditor) | 611 if (m_layoutEditor) |
| 588 m_layoutEditor.clear(); | 612 m_layoutEditor.clear(); |
| 589 | 613 |
| 590 if (m_overlayPage) { | 614 if (m_overlayPage) { |
| 591 m_overlayPage->willBeDestroyed(); | 615 m_overlayPage->willBeDestroyed(); |
| 592 m_overlayPage.clear(); | 616 m_overlayPage.clear(); |
| 593 m_overlayChromeClient.clear(); | 617 m_overlayChromeClient.clear(); |
| 594 } | 618 } |
| 595 m_resizeTimerActive = false; | 619 m_resizeTimerActive = false; |
| 596 m_pausedInDebuggerMessage = String(); | 620 m_message = String(); |
| 597 m_inspectMode = InspectorDOMAgent::NotSearching; | 621 m_inspectMode = InspectorDOMAgent::NotSearching; |
| 598 m_timer.stop(); | 622 m_timer.stop(); |
| 599 hideHighlight(); | 623 hideHighlight(); |
| 600 } | 624 } |
| 601 | 625 |
| 602 void InspectorOverlay::clear() | 626 void InspectorOverlay::clear() |
| 603 { | 627 { |
| 604 clearInternal(); | 628 clearInternal(); |
| 605 m_v8Session = nullptr; | 629 m_v8Session = nullptr; |
| 606 m_domAgent.clear(); | 630 m_domAgent.clear(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 689 |
| 666 if (m_inspectModeHighlightConfig) | 690 if (m_inspectModeHighlightConfig) |
| 667 highlightNode(m_hoveredNodeForInspectMode.get(), *m_inspectModeHighlight
Config, false); | 691 highlightNode(m_hoveredNodeForInspectMode.get(), *m_inspectModeHighlight
Config, false); |
| 668 | 692 |
| 669 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde
n(false); | 693 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde
n(false); |
| 670 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursor(pointerC
ursor(), overlayMainFrame()); | 694 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursor(pointerC
ursor(), overlayMainFrame()); |
| 671 } | 695 } |
| 672 | 696 |
| 673 void InspectorOverlay::suspend() | 697 void InspectorOverlay::suspend() |
| 674 { | 698 { |
| 675 if (!m_suspended) { | 699 if (m_suspended) |
| 676 m_suspended = true; | 700 return; |
| 677 clearInternal(); | 701 m_suspended = true; |
| 678 } | 702 clearInternal(); |
| 679 } | 703 } |
| 680 | 704 |
| 681 void InspectorOverlay::resume() | 705 void InspectorOverlay::resume() |
| 682 { | 706 { |
| 683 m_suspended = false; | 707 m_suspended = false; |
| 684 } | 708 } |
| 685 | 709 |
| 686 void InspectorOverlay::pageLayoutInvalidated(bool resized) | 710 void InspectorOverlay::pageLayoutInvalidated(bool resized) |
| 687 { | 711 { |
| 688 if (resized && m_drawViewSize) { | 712 if (resized && m_drawViewSize) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 | 814 |
| 791 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) | 815 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) |
| 792 { | 816 { |
| 793 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node->
isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg
ent) | 817 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node->
isElementNode() || !node->ownerDocument()->isActive() || !m_cssAgent || !m_domAg
ent) |
| 794 return; | 818 return; |
| 795 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen
t, &overlayMainFrame()->script()); | 819 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen
t, &overlayMainFrame()->script()); |
| 796 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde
n(true); | 820 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde
n(true); |
| 797 } | 821 } |
| 798 | 822 |
| 799 } // namespace blink | 823 } // namespace blink |
| OLD | NEW |