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

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

Issue 1450133003: [DevTools] Promote Device Mode v2 to default experiments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 5 years, 1 month 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 { } 174 { }
175 175
176 RawPtrWillBeMember<ChromeClient> m_client; 176 RawPtrWillBeMember<ChromeClient> m_client;
177 RawPtrWillBeMember<InspectorOverlay> m_overlay; 177 RawPtrWillBeMember<InspectorOverlay> m_overlay;
178 }; 178 };
179 179
180 180
181 InspectorOverlay::InspectorOverlay(WebViewImpl* webViewImpl) 181 InspectorOverlay::InspectorOverlay(WebViewImpl* webViewImpl)
182 : m_webViewImpl(webViewImpl) 182 : m_webViewImpl(webViewImpl)
183 , m_overlayHost(InspectorOverlayHost::create()) 183 , m_overlayHost(InspectorOverlayHost::create())
184 , m_drawViewSize(false)
185 , m_drawViewSizeWithGrid(false)
186 , m_resizeTimerActive(false)
187 , m_omitTooltip(false) 184 , m_omitTooltip(false)
188 , m_timer(this, &InspectorOverlay::onTimer)
189 , m_suspendCount(0) 185 , m_suspendCount(0)
190 , m_inLayout(false) 186 , m_inLayout(false)
191 , m_needsUpdate(false) 187 , m_needsUpdate(false)
192 , m_inspectMode(InspectorDOMAgent::NotSearching) 188 , m_inspectMode(InspectorDOMAgent::NotSearching)
193 { 189 {
194 } 190 }
195 191
196 InspectorOverlay::~InspectorOverlay() 192 InspectorOverlay::~InspectorOverlay()
197 { 193 {
198 ASSERT(!m_overlayPage); 194 ASSERT(!m_overlayPage);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 m_quadHighlightConfig = highlightConfig; 354 m_quadHighlightConfig = highlightConfig;
359 m_highlightQuad = quad; 355 m_highlightQuad = quad;
360 m_omitTooltip = false; 356 m_omitTooltip = false;
361 scheduleUpdate(); 357 scheduleUpdate();
362 } 358 }
363 359
364 bool InspectorOverlay::isEmpty() 360 bool InspectorOverlay::isEmpty()
365 { 361 {
366 if (m_suspendCount) 362 if (m_suspendCount)
367 return true; 363 return true;
368 bool hasVisibleElements = m_highlightNode || m_eventTargetNode || m_highligh tQuad || (m_resizeTimerActive && m_drawViewSize) || !m_pausedInDebuggerMessage. isNull(); 364 bool hasVisibleElements = m_highlightNode || m_eventTargetNode || m_highligh tQuad || !m_pausedInDebuggerMessage.isNull();
369 return !hasVisibleElements && m_inspectMode == InspectorDOMAgent::NotSearchi ng; 365 return !hasVisibleElements && m_inspectMode == InspectorDOMAgent::NotSearchi ng;
370 } 366 }
371 367
372 void InspectorOverlay::scheduleUpdate() 368 void InspectorOverlay::scheduleUpdate()
373 { 369 {
374 if (isEmpty()) { 370 if (isEmpty()) {
375 if (m_pageOverlay) 371 if (m_pageOverlay)
376 m_pageOverlay.clear(); 372 m_pageOverlay.clear();
377 return; 373 return;
378 } 374 }
379 m_needsUpdate = true; 375 m_needsUpdate = true;
380 m_webViewImpl->page()->chromeClient().scheduleAnimation(); 376 m_webViewImpl->page()->chromeClient().scheduleAnimation();
381 } 377 }
382 378
383 void InspectorOverlay::rebuildOverlayPage() 379 void InspectorOverlay::rebuildOverlayPage()
384 { 380 {
385 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView(); 381 FrameView* view = m_webViewImpl->mainFrameImpl()->frameView();
386 if (!view) 382 if (!view)
387 return; 383 return;
388 384
389 IntRect visibleRectInDocument = view->scrollableArea()->visibleContentRect() ; 385 IntRect visibleRectInDocument = view->scrollableArea()->visibleContentRect() ;
390 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize(); 386 IntSize viewportSize = m_webViewImpl->page()->frameHost().visualViewport().s ize();
391 toLocalFrame(overlayPage()->mainFrame())->view()->resize(viewportSize); 387 toLocalFrame(overlayPage()->mainFrame())->view()->resize(viewportSize);
392 overlayPage()->frameHost().visualViewport().setSize(viewportSize); 388 overlayPage()->frameHost().visualViewport().setSize(viewportSize);
393 reset(viewportSize, visibleRectInDocument.location()); 389 reset(viewportSize, visibleRectInDocument.location());
394 390
395 drawNodeHighlight(); 391 drawNodeHighlight();
396 drawQuadHighlight(); 392 drawQuadHighlight();
397 drawPausedInDebuggerMessage(); 393 drawPausedInDebuggerMessage();
398 drawViewSize();
399 if (m_layoutEditor && !m_highlightNode) 394 if (m_layoutEditor && !m_highlightNode)
400 m_layoutEditor->rebuild(); 395 m_layoutEditor->rebuild();
401 } 396 }
402 397
403 static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size) 398 static PassRefPtr<JSONObject> buildObjectForSize(const IntSize& size)
404 { 399 {
405 RefPtr<JSONObject> result = JSONObject::create(); 400 RefPtr<JSONObject> result = JSONObject::create();
406 result->setNumber("width", size.width()); 401 result->setNumber("width", size.width());
407 result->setNumber("height", size.height()); 402 result->setNumber("height", size.height());
408 return result.release(); 403 return result.release();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad HighlightConfig.contentOutline); 440 highlight.appendQuad(*m_highlightQuad, m_quadHighlightConfig.content, m_quad HighlightConfig.contentOutline);
446 evaluateInOverlay("drawHighlight", highlight.asJSONObject()); 441 evaluateInOverlay("drawHighlight", highlight.asJSONObject());
447 } 442 }
448 443
449 void InspectorOverlay::drawPausedInDebuggerMessage() 444 void InspectorOverlay::drawPausedInDebuggerMessage()
450 { 445 {
451 if (m_inspectMode == InspectorDOMAgent::NotSearching && !m_pausedInDebuggerM essage.isNull()) 446 if (m_inspectMode == InspectorDOMAgent::NotSearching && !m_pausedInDebuggerM essage.isNull())
452 evaluateInOverlay("drawPausedInDebuggerMessage", m_pausedInDebuggerMessa ge); 447 evaluateInOverlay("drawPausedInDebuggerMessage", m_pausedInDebuggerMessa ge);
453 } 448 }
454 449
455 void InspectorOverlay::drawViewSize()
456 {
457 if (m_resizeTimerActive && m_drawViewSize)
458 evaluateInOverlay("drawViewSize", m_drawViewSizeWithGrid ? "true" : "fal se");
459 }
460
461 Page* InspectorOverlay::overlayPage() 450 Page* InspectorOverlay::overlayPage()
462 { 451 {
463 if (m_overlayPage) 452 if (m_overlayPage)
464 return m_overlayPage.get(); 453 return m_overlayPage.get();
465 454
466 ScriptForbiddenScope::AllowUserAgentScript allowScript; 455 ScriptForbiddenScope::AllowUserAgentScript allowScript;
467 456
468 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, dummyFrameLoa derClient, (EmptyFrameLoaderClient::create())); 457 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, dummyFrameLoa derClient, (EmptyFrameLoaderClient::create()));
469 Page::PageClients pageClients; 458 Page::PageClients pageClients;
470 fillWithEmptyClients(pageClients); 459 fillWithEmptyClients(pageClients);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 546 }
558 547
559 String InspectorOverlay::evaluateInOverlayForTest(const String& script) 548 String InspectorOverlay::evaluateInOverlayForTest(const String& script)
560 { 549 {
561 ScriptForbiddenScope::AllowUserAgentScript allowScript; 550 ScriptForbiddenScope::AllowUserAgentScript allowScript;
562 v8::HandleScope handleScope(toIsolate(overlayMainFrame())); 551 v8::HandleScope handleScope(toIsolate(overlayMainFrame()));
563 v8::Local<v8::Value> string = toLocalFrame(overlayPage()->mainFrame())->scri pt().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script), ScriptCont roller::ExecuteScriptWhenScriptsDisabled); 552 v8::Local<v8::Value> string = toLocalFrame(overlayPage()->mainFrame())->scri pt().executeScriptInMainWorldAndReturnValue(ScriptSourceCode(script), ScriptCont roller::ExecuteScriptWhenScriptsDisabled);
564 return toCoreStringWithUndefinedOrNullCheck(string); 553 return toCoreStringWithUndefinedOrNullCheck(string);
565 } 554 }
566 555
567 void InspectorOverlay::onTimer(Timer<InspectorOverlay>*)
568 {
569 m_resizeTimerActive = false;
570 scheduleUpdate();
571 }
572
573 void InspectorOverlay::clear() 556 void InspectorOverlay::clear()
574 { 557 {
575 if (m_layoutEditor) 558 if (m_layoutEditor)
576 m_layoutEditor.clear(); 559 m_layoutEditor.clear();
577 560
578 if (m_overlayPage) { 561 if (m_overlayPage) {
579 m_overlayPage->willBeDestroyed(); 562 m_overlayPage->willBeDestroyed();
580 m_overlayPage.clear(); 563 m_overlayPage.clear();
581 m_overlayChromeClient.clear(); 564 m_overlayChromeClient.clear();
582 } 565 }
583 m_resizeTimerActive = false;
584 m_pausedInDebuggerMessage = String(); 566 m_pausedInDebuggerMessage = String();
585 m_inspectMode = InspectorDOMAgent::NotSearching; 567 m_inspectMode = InspectorDOMAgent::NotSearching;
586 m_timer.stop();
587 hideHighlight(); 568 hideHighlight();
588 } 569 }
589 570
590 void InspectorOverlay::overlayResumed() 571 void InspectorOverlay::overlayResumed()
591 { 572 {
592 if (m_debuggerAgent) { 573 if (m_debuggerAgent) {
593 ErrorString error; 574 ErrorString error;
594 m_debuggerAgent->resume(&error); 575 m_debuggerAgent->resume(&error);
595 } 576 }
596 } 577 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 { 638 {
658 if (!m_suspendCount++) 639 if (!m_suspendCount++)
659 clear(); 640 clear();
660 } 641 }
661 642
662 void InspectorOverlay::profilingStopped() 643 void InspectorOverlay::profilingStopped()
663 { 644 {
664 --m_suspendCount; 645 --m_suspendCount;
665 } 646 }
666 647
667 void InspectorOverlay::pageLayoutInvalidated(bool resized) 648 void InspectorOverlay::pageLayoutInvalidated()
668 { 649 {
669 if (resized && m_drawViewSize) {
670 m_resizeTimerActive = true;
671 m_timer.startOneShot(1, BLINK_FROM_HERE);
672 }
673 scheduleUpdate(); 650 scheduleUpdate();
674 } 651 }
675 652
676 void InspectorOverlay::setShowViewportSizeOnResize(bool show, bool showGrid)
677 {
678 m_drawViewSize = show;
679 m_drawViewSizeWithGrid = showGrid;
680 }
681
682 bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event) 653 bool InspectorOverlay::handleMouseMove(const PlatformMouseEvent& event)
683 { 654 {
684 if (!shouldSearchForNode()) 655 if (!shouldSearchForNode())
685 return false; 656 return false;
686 657
687 LocalFrame* frame = m_webViewImpl->mainFrameImpl()->frame(); 658 LocalFrame* frame = m_webViewImpl->mainFrameImpl()->frame();
688 if (!frame->view() || !frame->contentLayoutObject()) 659 if (!frame->view() || !frame->contentLayoutObject())
689 return false; 660 return false;
690 Node* node = hoveredNodeForEvent(frame, event, event.shiftKey()); 661 Node* node = hoveredNodeForEvent(frame, event, event.shiftKey());
691 662
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 742
772 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node) 743 void InspectorOverlay::initializeLayoutEditorIfNeeded(Node* node)
773 { 744 {
774 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive()) 745 if (m_inspectMode != InspectorDOMAgent::ShowLayoutEditor || !node || !node-> isElementNode() || !node->ownerDocument()->isActive())
775 return; 746 return;
776 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script()); 747 m_layoutEditor = LayoutEditor::create(toElement(node), m_cssAgent, m_domAgen t, &overlayMainFrame()->script());
777 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true); 748 toChromeClientImpl(m_webViewImpl->page()->chromeClient()).setCursorOverridde n(true);
778 } 749 }
779 750
780 } // namespace blink 751 } // 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